New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

1inch Network 🛠 From the First DEXes to Fusion Mode

ETHGlobalWed, Oct 9, 2024, 12:00 AM

Join us for a 1Inch Swap Evolution workshop! From November 17-19 2023, ETHGlobal welcomed developers from around the globe to take part in shaping the future of Ethereum at ETHGlobal Istanbul. Over $600,000 USD in prizes were given away at the prestige Istanbul Congress Center... thanks for an amazing weekend hackers! ----------------- Follow us: https://x.com/ETHGlobal?s=20 Check us out: https://ethglobal.com/ Email us at: hello@ethglobal.com

Transcript

[Music] my name is Kil I'm the backend team lead uh in 1 inch where we actually build the future of decentralized trading experience uh today I'm going to talk about how we came up with an idea to build 1-in Fusion which problems it solves and um how it actually works and and also we will dive a bit into the history of decentralized exchanges in a distant years um the was born with appearance of first um um MMS uh and since then the defi Market has grown about 70 times uh and we built a lot of cool projects the combination of these projects to build the defi even more efficient than the centralized exchanges the first step in the five world was um dexes like amm uh developers decided to create some formula on a smart contract that allows to provide liquidity with two tokens and swap one token to another so but there was a problem I at the beginning it was about five uh dexes and you need to find the best one so what I can do I can open several tabs in the browser and at the same moment look at all uh exchanges and try to compare exchange rates and also transaction costs because each Dex has uh their own computation uh and you need to pay gas for this computation uh this is how actually 1 in agre ation protocol was born in the hecaton in 2019 it was the eum global if New York Heaton and actually what is an aggregator aggregator allows to execute the transaction um atomically uh by aggregating between different uh automated market makers uh private market makers and also limit orders uh the p just built uh through several um exchanges you can split uh the entire token amount into several uh dexes and even you can use connector tokens to catch the deepest liquidity but anyway there is a problem with the aggregators uh as a user I need to fight with mbots because Mev Bots can front run your transaction they can sandwich you and for the ordinary Trader it's a bit complicated thing the second is gas price I need to know which gas price should I set and I don't want to overpay for gas costs as a user so it's also complex for beginners and there is a price impact so if you trade some token that has not very good liquidity then you will lose like tokens on the rate next you have failed transactions if Market moves and you don't pass uh slipage tolerance then your transaction just failed you pay for nothing you pay for two minor for fail transaction and also as a user I need to have native token on a balance to be able to send the transaction so it's hard to uh attract new users to defy if we have such problems this is how we came up with an idea of fusion so Fusion is intent Centric orders based on Doge auction uh that filled by professional market makers and what we have Fusion is gas free you don't need to pay for um gas cost Fusion protected from MEF attack by Design and fusion has Limitless liquidity uh let's look at this uh things and figure out why it is so why Fusion is gasless uh Fusion is simply a structure where you define the token pair and the amount that you would like to swap and you sign this order and send to relay so you don't need to send a transaction you just make a uh signature of chain and send to the relayer um next resolvers just catch this order and execute on behalf of the user uh and the user uh pay for the transaction and the uh fees included in exchange rate because resolvers should execute the transaction on behalf of the user and anyway pay for gas fees but if I'm a user and I don't have either or other native currency of on another blockchain then it's okay if token supports permit uh standard then I can just send the transaction with zero either on a balance next how Fusion protected from the MEF attacks as I said Fusion based on Doge auction that means that at the specific block the price curve has the fixed price there is no any formula and at the moment the price is fixed and only resolvers can be front round but they are professionals they know how to protect themsel and they will they can be front Rand but only for their profit for the user at the specific block the price is fixed like in limit orders and what about liquidity uh with aggregators we need to trust that the aggregator integrate all possible liquidity sources into their algorithm but anyway it's almost impossible uh because there are different um market makers uh small big anyway and what is fusion fusion is intent based you just submit some action that I want to swap and for me doesn't matter how this swap will happen and we have resolvers who connected to the network and they can execute orders like arbitraging with the centralized exchanges liquidity they can Arbitrage any dexes they can even uh match to Fusion orders between each other yeah this is cool and even maybe a cross-chain liquidity can be involved in this process it's up to resolver so we have Limitless liquidity and let's see how Fusion Works in total uh me as the maker first of all need to give an approval or permit to 1-in router contract then I just sign and send the transaction to reler and resolvers subscribed for the new orders and each time when resolvers see that oh this price is good for me I can execute it then the resolver just submit the transaction into the net Network that's that's it so simple and regarding the Dodge auction what is it and uh what defined uh by the Doge auction the Doge auction it's kind of a curve uh that has the duration uh you can set any duration of your order when the price will be slightly decrease from the uh from the highest price to the minimal acceptable price the second parameter is minimal return this in in case of Market movements how much you are okay to receive and also initial rate bump this is the difference between start return amount and mean return and also our Doge curve customized with the additional points uh like these points change their price speed between two different points uh let's see what is it and even um Fusion uh price curve can improve the market price for example uh either costs 2,000 U usdt uh but I swap the large amount and I can even improve the price let's see how it happens so uh on the screen you can see the real order that uh happened on chain uh some defi Raiders swapped more than 5,000 either to usdc and he received 40K more compared to the market price when the order was placed and how it works we takes we take into account the market liquidity we try to split like to find the price for the smallest uh amount to um disable price impact and we add additional points on this curve um to uh improve the price at the beginning so we start from the spot price we go to the market price to third of the auction time and in the end in case of uh transaction uh in case of Market movements uh your order can be executed by minimal return or not executed at all so in this case uh you pay nothing if order uh hasn't been executed uh because you haven't sent any transaction you don't have failed transaction and in this case uh there was about 11 partial Fields by the resolvers uh and even it happened um uh like about three or four resolvers uh submit uh their partial fields in parallel within the single block and you can see that when auction just started some resolver filled 10% of the order and in one block in 12 seconds some other resolvers filled 30% and this is how the user received more than he expected by the market price because when you swap small amount of the order arbitragers come to the market see that the market is imbalance and swap back and balance uh and balance the liquidity price goes back resolver fill one more time Etc repeat repeat repeat yeah so um what we can build uh with the fusion it's up you to you hackers but we have 1in developer portal that we released recently and you can taken advantage of different apis inclusion including Fusion API swap API balances token prices Etc so you just need to go to portal. onein dodev log in with your GitHub account get an API key and you can go through the docs and learn more so like what you can build with this the spot price like if you want to place the fat price the fat representation of the token on UD app you can use spot price API if you want to uh scan balances on of different wets you can use balances API if you want to get an access to more than six million tokens and tokens you can use tokens API and search not only using CES but even by symbol or name and all tokens sorted by the rating so you will never lose the right token um by these cor codes you can search how to create Fusion orders uh how to connect to the dev portal and how to become a resolver if you are professional Market maker uh on the hackaton we have four bounties uh the first is about the fusion just built a cool project that makes sense on top of the Fusion engine uh the second is about irc2 the the second is about token plugins it's an rc20 based extensions that allows to extend the functionality of tokenized assets and actually regarding the dev portal uh we would like to see some interesting use cases uh made by uh that uses the 1-in developer portal apis and the last is open track yeah that's it thank you if you have any questions feel free to ask me y uh so the question is uh can we use a limit order from the smart contract the answer yes totally so um the fusion orders it's they based on 1 in limit order protocol and there is a standard that said that uh if the maker of the fusion order is smart contract then um in in in time of execution uh we validate not the signature edca uh you validate you you call is valid signature function on the main maker address and this function should Returns the selector of uh like selector of this function or in case if something not okay for you then this function uh throw an error or just return some random bites yes it's possible to use but you need to implement on your maker address on the smart contract is Val it signature function that has two arguments it's a cash of the order and some arbitrary data that you provide for validation any other questions yeah we have a boo you can come ask questions and during the hecaton okay thank [Applause] you

Automatic transcript — names and jargon may be misspelled.