1inch Workshop | Nick Kozlov | Deep Dive into 1inch Fusion | ETHDam 2023
CryptoCanal·Sat, Oct 7, 2023, 12:00 AM
Nick Kozlov is a backend team lead at 1inch. https://twitter.com/EnormousRage 1inch Network https://1inch.io/ ETHDam is a Hackathon & Conference that gathered over 500 DeFi and Privacy builders on the 20th and 21st of May 2023 in Amsterdam. Privacy is normal. Following the arrest of Alex Pertsev, a Tornado Cash developer in the Netherlands, ETHDam 2023 is determined to counter the chilling effects of the lawsuit and bridge worlds to discuss the future of privacy and encourage to build on the shoulders of cypherpunk giants. ETHDam is powered by CryptoCanal, - a blockchain education and events platform growing in Amsterdam, spreading its roots to Rotterdam and Zurich. ETHDam 2024 is on the map already! Keep up with us to see updates: CryptoCanal https://www.cryptocanal.org/ CryptoCanal Twitter https://twitter.com/CryptoCanal Join CryptoCanal Community https://t.me/CryptoCanalCommunity We would like to thank our partners and sponsors that made this event possible. 🌷 Our BFF 1inch https://1inch.io/ Our Frens: Sismo https://www.sismo.io/ Aleph Zero https://alephzero.org/ Scroll https://scroll.io/ RAILGUN https://railgun.org/#/ And our Sisters: oasis.app https://oasis.app/#earn Maven11 https://www.maven11.com/ bitvavo https://bitvavo.com/en Lido https://lido.fi/ Spankchain https://spankchain.com/ API3 https://api3.org/ Gelato https://www.gelato.network/ VanEck https://www.vaneck.com/nl/en/crypto-etn Marlin Protocol https://www.marlin.org/ Silent Protocol https://www.silentprotocol.org/ Cyber Capital https://cyber.capital/ … and Proto https://twitter.com/protolambda 🍍
Transcript
foreign [Music] Fusion why is the future of defy and why it's so useful for the developers and for the community for everyone who is trying to use it actually let's start from small recap what is one inch maybe somebody don't know what is it basically right now it's one of the leading defy project we do have almost 3 million users we do have a multi-billion volumes of of liquidity going through us we do have 70 percent volume of aggregation like a 70 aggregation market share and vanish was built on one of the hackathons like this a couple of years ago at New York basically yeah like then there you go it was a birthday or financial almost four years we are on the market right now um for the for the for these years we built multiple protocols right now it's not only aggregation protocol it's a list of protocols uh it's a also limited order protocol that and Anthony recently just had a talk about limit order protocol like almost two hours ago on the main stage we do also have a vanish Fusion protocol we do have a vantage wallet it's a non-custodial wallet for multiple platforms like Android and Apple and we do have Advantage Pro as a product for institutions so um I just want to make a small recap about my one of the main two protocols the first one is aggregation protocol it's our OG protocol the first one basically what it helps to do it helps you to basically to build a road to from any token to any other token here's a 20 token I mean and execute the all of these roads in one Atomic transaction and what is cool about that that when you do something like this it's this road actually is quite smart and quite well optimized we split uh the swap from Talking Source talking to the destination Target into some several small parts and we optimize percentage of each share that we goes through each part and it can be quite Advanced we do we can have more than 100 parts during the swap so basically uh this how we started and it's quite easy to actually start to use aggregation protocol there are two parties here the first one is one each router and almost anyone can just make a transaction on each other it's completely open sourced you can take a look how it works exactly how it works basically what you need just to make a transaction like just to build a transaction and pay pay for it and execute it on the ethereum and we do have an API for that and basically what you can do you can use one inch API to get first the quote basically to understand what will be the return amount of any token and if you are okay with that you basically just go and swap it but basically just build cool data firstly and later execute it on the transaction it's quite simple it's only on chain but there are some issues that is happening right now the one of it is actually myth attacks like if your user will just try to execute a very large swap during like on the public network it can be easily sandwiched and lose a lot of money because of the slippage it requires users to actually set sleep Edge quite lower if you set super very low your transaction can be reverted because the market conditions can change so it's also a problem how to balance your transaction how to set up it so you will not be sandwiched or somehow attacked by somebody who is searching for move and at the same time you need to execute it without any painful experience without any behaviors so you don't want to wait too much in this case so um yeah you could basically use one inch so like one inch swap even right now it's quite easy there is a quark with the link about on the documentation so we do have a quite Advanced developer portal that is evolving every day so you can take a look we're always welcome to take a look um so we started to research on how we can make it even more advanced how you can trade with some without any slippage with sewage protection and so an instrument protocol like appeared basically um it helps you to set up a limit order quite the same logic as on any any sex so you don't have any issues with the slippage also it's a completely off chain for the user so you don't pay for the gas at all the only thing that you need to specify the price the rates for your for your return amount after that you send it to the vanish app like to the vanish database basically or like it can be PCP as well you don't need only database if you want to if you want to do this and after that any party on the indify can execute this order if the price is actually quite okay for this party there is no any price guarantee that it will be executed but if the price is quite okay for example if you make another photo right now for 100 1700 ethereum hour per day anyway if somebody will executed because it's quite profitable for this party so there are a lot of features that can build on top of limit order but the most important is just it's well optimized it's quite efficient and we have about 80 percent of volumes going through our limit order right now um yeah so um let's talk a bit how it works like basically there are two parties it's a market maker it's a user who basically just create and sign the order and share this order through all the network and there is another party it's Market taker that basically needs to search across all users others and if the market taker basically finds something that is suitable that is quite profitable they just need to execute that that's it basically there is a quite good Market on that and that's like a small scheme how it works you do have a small separation here that's going for whatever is going off chain and where it's on chain so basically only part that is on chain it's a execution of limit order all other all other parts are actually of chain so um we have like right now we have two great particles one is for Market cell basically you can use aggregation protocol if you just need to sell something very fast with any slippage for example you don't care you just need to sell something it works quite well it gets one of the best roads on the market and we do have a quite Advanced trading protocol for professionals who want to specify the rates who are okay to wait a bit this is limited other protocol but what if we want to do what we have we want to have some balance between it why what if we want to actually have something like Market cell but we are okay to wait a bit like in an aggregation protocol you basically made only one transaction one on chain Transaction what if you want to sell on the market but you can wait and you don't need like to wait for if you don't want to make only one on chain transaction you're okay to have multiple of them for example in this case um diffusion actually burned we decided to make an auction basically it's kind of a fusion between aggregation protocol and and limit other protocol basically you're trying to make a market cell at the same time you have specific hard-coded like rates going down during a specific amount of time so on each moment of this time the price is going is quite okay and anyone any party who is trying to actually take your order and execute it they have enough time to calculate the profits and to find any resources to any liquidity to execute this order at the same time you don't need to pay for gas and at the same time it's also what basically works on the market because there is a competition between multiple parties who are trying to fill your order so basically uh that's uh what is actually is Fusion it works quite the same as almost our Legacy protocol its aggregation protocol it's happened to the same user experience but we have additional features on top of it for the user sometimes it can be taken a bit wrong so I just want to go through all of them and just explain how it actually works and how what are the trade-offs in this in this case so there are three main features it's firstly gasless execution so basically you don't need to pay for gas in ethereum for a native currency for example if you use ethereum Network yeah you have a myth protection by default so basically nobody can front run you or like do something with with the user and also we don't have issues with liquidity because it's almost Limitless because basically any party can aggregate liquidity from any source and they have enough time for that so uh let's talk about gas execution a bit it's quite simple like it's almost the same as experience with limit order because user just needs to sign specific data structure it's completely off chain it goes to the storage database and basically that's it uh in there is one problem that even if you don't do anything on chain it means that it doesn't mean that it's completely free there is no any commission or fee in terms of swap because we still need to somebody still need to fill the transaction somebody still need to pay on chain and that basically means that the price of the of the of the trade is some species are included in the into the rate so the rate goes a bit maybe less less less better than it can be executed in case of the like in case of aggregation protocol in some cases well that's actually not that transparent it depends only on the market taker party and it can go much more better than an aggregation particle it can go worse it depends Case by case that because we have like a competition market and we can't predict what will be the fee for the user in the interval usually it can be a bit less expensive than paying for gas directly because the main reason why it is while it is like that um Fusion is quite optimized you don't need to make too much on chain transactions and also parties who actually feel Fusion orders they can batch all of them so they pay only they make only one Unchained transaction and fill multiple Fusion orders at the same time so it's a bit more optimized because we have a bundle inside so basically yeah all others actually executed on the blockchain side by market takers actually we call them resolvers in terms in terms of fusion let's like see the scheme about actual resolvers this party after user sends something to the limit of the storage to the storage with all these Fusion orders there is a there's always actually actually searching for all all orders that are happening on of chain and what they need to do basically they see how the price going down and when the price is when they see the Target price is quite profitable for them they trying to execute this trade of on chain paying commission and gas fee for that at this at that moment basically they had there is a small issue it's because it's happening on chain there is a possibility that somebody can actually front-end the resolvers so but of course the protection from the user users are completely protected in this case because there is a myth protection and on the user side because there is no anyone chain activity on their side basically but that doesn't mean there is no completely male protection on all steps of the protocol so us needs to take to pay some risks to understand how to get out of these attacks and um so there is a small issue here but it's always quite okay because results can only lose money that only lose their profits they can lose your order or your like your assets they only lose their money from executing the from the pro from the profits of the straight if somebody can try to attack them and for example for sandwich attack so basically uh another opportunity in here is that there is always always a professional Traders they have quite a lot of experience executing orders and in this case it's quite okay because if only users if users need to think about me protection it's quite painful if it's only resolvers who are professionals it's quite okay for them basically they can handle that and they're like they do this and a small point about Limitless liquidity um so what does it basically mean the main reason why it works so well is because we don't have one Atomic transaction the problem with aggregation protocol is that Pathfinder or any algo that we do have it needs to aggregate all liquidity and make transaction on chain immediately we don't have enough time to wait until some confirmations from other exchanges we don't we can't log unlock something inside one transaction so it's quite painful we don't have enough opportunities sometimes to collect some some Equity from other chains especially in case of some coins for example let's imagine you do swap on one chain and you want to trade on another chain the same coin but there is no any liquidity there if people try to do something completely on chain it will be quite impossible to aggregate liquidity from other chain if you don't know about this order if you are doing something the same on Fusion you basically have is always basically they have enough time to search across multiple chains to get to find this liquidity trying to bridge this liquidity to this chain and just get a better rate for the user so in the end of all the user gets more than on their legacy in legacy mode um so this is like basic scheme how it works um it's quite almost the same as limit orders but there is a small difference it is always and this mechanism of the mechanics how we allow like how the Dow allows some resolvers to execute others right now if you want to execute the orders from a niche Network you need to be on the top 10 of the resolvers for to make it possible you firstly need to register resolver and after that you need to ask your users the users the stakers of vanish token to delegate some tokens to to your party basically to the resolver so top 10 of them can execute all this all Fusion orders and so it's quite simple and works almost the same as limit order there is a search database it's going through the database shares all Fusion orders to the resolvers any parts you can execute any resolver parts you can execute any order any out at any moment uh using them financially with other protocol and also on each router to ensure that it will be completely secure and in the end of all user will get enough tokens that was promised on the conditions of the transaction that was signed um so let's talk a bit how we can work with vanish fusion and maybe make a small um like exam I will show some some small examples about that there are actually multiple options how you can work as a software developer with on each Fusion uh the first one is quite simple you can integrate on each Fusion to your API to your wallet to your D app basically any app that requires to swap any token to any other token it's quite a good use case to use one inch Fusion also it's completely free and there is no any commission fee basically we just you just need to integrate and that's it we do have a Partnerships and you can also get Enterprise API if you're a large business if you do need some additional quotes additional limits it's also possible right now and another option is basically that you can try to be a resolver I have an inch resolver and also execute orders on behalf of the users and actually get some profits in this case all of that is quite open and quite transparent and quite easy to build um so we do have a vanish documentation and the most easiest way how you can work with financial Fusion right now it's a vanish Fusion SDK it's written on the typescript right now there is also a rust version and you do also can work with API or with the smart contract directly but if you want to take a look and just to try to make some fun SDK is one of the best options and we do have several examples how to work with that data directly in the documentation and in the GitHub repository of that um so let's like make a run and go through several options how we can run a transaction uh we're using one each fusion um I think just open my IDE and just show how it works um so let's take a look I it's basically just basic basic projects uh that I made on the typescript using node that's what I want to do here I just want to find a way how we can get a quote basically what I what I want I want to understand how to make a quote from die to rap vmb for example to understand what will be the expected amount what will be the return rate if you want to integrate something I want firstly to start to get a quotes on that so it's almost one line of code this is example how you can actually implement it uh using one Edge Fusion it's almost like I don't know like 16 lines 10 lines of code all you need is just specify a network in this case let it be binance for example it can be any other chain that we do support we do support almost 10 chains right now only for the fusion and after that you just need to specify by default only several parameters it's from Taken address token address and amount in terms of front I can address and after that it just basically it's just a basic API call so just let's let's run it let's just take a look I'm sorry I think I don't have an internet right now um so um basically I always executed almost like a couple of minutes ago and there is example what it will return it's basically a file like a structure fifth recommendations and with return rate uh that you got uh you can see that we do have a from Target amount that I already specified and there are multiple presets how auction can be executed you can specify any preset and we just do recommend to use the default preset the recommend that one so the transaction will go through with the most efficient and the fastest way but you can also specify different presets for the auction and also add the digital parameters such as pyramid or additional fee if you want to specify fee for example for your app um so the experience is quite the same when you understand that the Chrome described okay for you in the state in this case this is actually the two token amount this is like the array that you get in wrapped in V tokens swapping 1000 die so it's like three two three something it will be like this actually in BNB case like um it's a bit outdated because I just run it like 10 minutes ago but it's close to the reality uh if you're okay with this price the Second Step that you need to do after you actually get a quote you need to execute transaction basically you need to create a fusion order on the behalf of the user um to make it that possible you just can take a look on the example on documentation or on this on in this in this code uh it's almost the same you just need to specify from token address to they can address the same amount that you already specified also wallet address who is like basically making this transaction making this other to get a wallet address and actually to sign this transaction you need to actually have a private key so you can ask you can you you can use one of the abstractions that we do have on SDK for the private key it's quite easy to use it you just need to install your free web free and Implement several functions you can use any library for that not only web free but other sjs for example or any event Free Library that just signs transaction basically um and you also do need to have a note for the for executing the transaction so basically that's that's it if you will execute this transaction you also need to have a proof before before you're making this transaction you don't need to forget that every everyone every maker everyone who is making another it needs to make a proof with the amount of tokens that you want to execute on the one inch router address any other otherwise it will be not executed because uh it's quite it's impossible to withdraw any Targets from your address and yeah basically that's it after you execute the transaction you will get another ID and after basically we'll get another ID it's quite you need what you need you basically need to understand how to track this order how to understand what it will be executed so there are another two functions to get make it possible um you can you can get orders of any party uh using uh two functions the first one is get all active orders it just shows the whole list of all others that are on the advantage limit order like database and another one is actually allows you to specify the maker basically the user who made the transaction so you can take a look on all users all the limit orders and take a look all the details that are happening there um yeah that's the quick overview how to work with vanish SDK everyone just wants to repeat there is um also a way how you can delegate some tokens to any vanish resolver this is how UI looks like uh there is top 10 resolvers and any user can delegate only to one resolver some manage tokens and top 10 of them have opportunity to execute all of these orders that are created even your resolver can participate here the entry player is quite low right now so I just do if you want and you like the business of resolvers or Market taking or Market making business if you are quite inverse here or like it you can participate and just get small some market share and earn on it um yeah the I just want to mention that if you have an issue resolver um you don't have we don't have a specific scheme that every resolver first to pay something to the users basically you don't you cannot pay nothing but in this case if you will pay nothing you will be quite unpopular and we'll you will get out of top 10 and nobody will Delegate for you so it's always they haven't seen incentives to pay for the users some rewards from the profits of these transactions otherwise they will be not in top 10 right now um so yeah basically that's it um if you have any questions about resolvers and fusion integration to the vanish Fusion resolvers I will be downstairs I will be always happy to help and if you have some questions right now I will be also happy to answer them thank you oh thanks um yeah I was interested so the barrier though to becoming a resolver right is that it seems like from what I was looking at like you need to have put up a couple hundred thousand dollars in in one inch tokens right so no no basically um the first point what you need to do when you become a resolver uh you just need to create a pod it's actually a function inside salinity you just need to be register as a resolver it requires some Unleashed tokens but the entry point is like 50 100 one inch tokens uh so it's quite low but if you want to be in the top 10 yes in this case you need to attract attention from the users from the delegations delegations it it must be not only fans of the resolver it can be fans of any party any user um yeah okay because I I thought that I read that it said that the only the top ten get access to the fusion order book yes yes but so but if I can't get into the top 10 without having a significant amount of users initially delegate to me yeah so you need to attract some users in this case uh we do have a grants to help resolvers to actually get into the top 10 and basically the incubator right now is not hungry as thousands of unleash tokens it's a bit lower so you can just take a look on the front-end side for example so like the top 10 is like actually quite lower than like thousands of vanish tokens uh let's take a look at uh sorry I don't don't have internet right now so no it's okay and then for delivery right because I've used the one in uh the fusion router right and I've seen sort of the paths that they sort of take to resolve the things though yeah if I'm resolving through a centralized exchange right then it's just a matter of delivering the amount of tokens for the specified rate as opposed to actually sourcing the back on chain and then sort of taking the users right so somebody's trying to swap the uh 10 million huge order of usdc to beat to BTC and I have the BTC or to wrap BTC in my wallet right then it's just a matter of sort of I can just do a delivery and I can on my own back end right yeah okay yeah basically the main case here is that if servers are quite open they don't have any restrictions to execute the order they just need to be compliant in our case we obligatory to be compliant uh but you server can have any logic how they execute the order so for example you can use your own funds you can use Avi borrowing liquidity from from the users of the Avi for example Vivica lateral you can be any logic the only thing that you need from the resolver party there is a one function called fill Fusion order and you just need to specify the order and the amount and that's it it's can or even be not Atomic you can feel the same order several times if you have some like opportunity to feel it right okay and and you said that for the solvers it's written in rust or there's a rust implementation for uh there is a library in Rust you can execute you can use it uh you can you actually it's quite open you just need the only thing that you need from us basically right now is just access to the you the data of the of other of the others uh it's going through there are multiple options like websocket and you can execute everything on your own language so there is no any requirements for resolver to use specific language or specific like stack a framework there are we do have a two libraries that are quite simpler to work like this is a good start it's a rust Library this is a community version and we do have SDK in typescript as a entry player to have a low entry barrier yeah got it thank you very interesting can I ask a question yeah first of all thanks Nikita for a great presentation and I also have a question regarding the russet uh raster Decay you mentioned that it's a community owned so it's not in the official documents of the uh there is a link there uh or you can take a look in the GitHub for example there is a list of all libraries and one of them is rust implementation um yeah it's Community version so you take your own risks if you're if you're working with that but basically what what you can say that's almost working with one each Fusion SDK if you especially are resolver it's quite it's quite simple it's extremely simple and basically if you want if you're going seriously on that you don't almost don't need any SDK it's just like three functions implemented you can take a look how they are implemented and basically implemented on their own if you just need to specify some Advanced parameters for example so SDK is more first just to take a look and to play basically the agency better is just smart contracts and one one API handle to get the order that's it okay thanks um yeah and the one more question regarding the how how can we test the resolver so is there any test net or we can do it online prod right now uh it's only possible production but if you're building your own resolver basically what you can do you can make your own environment like in travel there are some options we actually have implementation of basic resolver contract so we have right now we are working to have a small local system that you can run on locally and basically run a resolver and all the parties on localhost with your own local Fork of the network it's quite um it's work it's a work in progress right now here uh if you are taking serious that that point you just need to write it on your own like write it is over and run it on your local network like ganache or something like that okay thank you you're welcome thank you [Applause]
Automatic transcript — names and jargon may be misspelled.