Mastering Cross Chain Swaps Insights on 1inch Fusion+ ETHGlobal Singapore 2024
ETHGlobal·Wed, Oct 9, 2024, 12:00 AM
Join us for a workshop with Sergej Kunz titled, "Mastering Cross Chain Swaps Insights on 1inch Fusion+" Dive into the mechanics of cross-chain swaps powered by an intent-based solution. This workshop took place at ETHGlobal Singapore 2024, a 3-day hackathon held from September 20 to 22, 2024, that brought together the most skilled web3 developers, designers and product builders from all around the globe for a weekend-long adventure to advance the Ethereum ecosystem! ________ Follow us: x.com/ethglobal Website: https://ethglobal.com Email us at: hello@ethglobal.com
Transcript
[Music] uh thanks for coming uh today I'm going to show you something so two days ago we had huge announcements here at token 2049 we are going to um we are going to go for cross chain so one second to switch like okay so um the name of this uh Workshop is mastering cross chain swaps insights on 1in Fusion my name is Ser Co I'm co-founder of 1in network soft engineer soft architect for 20 years so why cross chain is important why it matters we have um a huge amount of liquidity um fragmented cross cross chain we have 55 percentages uh on etherium but we have also salana arbitrum base Avalanche polygon B smart chain and we want to be efficient we three in distalized finances and that's why we should uh aggregate cross chain liquidity so if you look uh on the um on the volumes we have uh in 2023 2024 uh already 70 billions uh on Cross chain volumes um most Bridge tokens are eth with 48 percentages T coins around 40 percentages some other with 12 cross chain bridges are used for CR cross chain um transfers of assets um but there are some disadvantages so if you're speaking about user Centric products uh user face bet act you need to find the right Bridge so you need if you want to swap from gnosis chain to ethereum you need to find the original gnosis chain and to be sure that it's not a scam website right so it's really pain maybe you get worse rate uh in terms of um specific token pair not every bridge support all tokens or only maybe Stables so you you manage the how as a user so and uh if you're developer it's really terrible you need to rebuild the wheel Again by just aggregating potentially this uh Bridges and other cross Chain Solutions or you use someone who maybe got hacked what we have seen recently um some Bridge aggregators got hacked because the allowance uh was set like written not not properly programmed in in a smart contract so someone could exploit the approvals of users so and if you don't um take care to read the smart contract of the um of the uh of the integration party then you could potentially face a huge loss in in funds or your customers could face the the loss um it's it's slow to use the bridge I personally had really bad experience with gnosis gnosis Native chain um Bridge um and you wait like 30 minutes you know of course they they protect themselves um and um protect you as well but it's terrible terrible user experience yeah you get already said bad bad rates as well and maybe you they charge fees on you so Central cross chain bridges are centralized some of them some of them try to be more decentralized expensive unsafe inconvenient we have questioning swap solution they use messaging protocols like layer zero layer zero is cool but for swap is dangerous because someone can became greedy when like hundreds of millions of US Dollars flowing through messaging protocol by by using messaging protocol through cross Chain Solutions cross chain swaps someone can be greedent start maybe to attack or Val became greedent start to Fake Messages um so there's there a security risks so and here again we have also slow slow swaps uh you get charged so I discovered some some providers they charge fees um we from 1 in we have different uh point of view on that so we should grow the space and um not make money on small amount of uh people um of course we need to be sustainable but um it's yeah if you cannot if can you if if you can operate more or less in sustainable for the next five years it's two to to five years then maybe it makes no sense to charge so it's too complex also if they are cross chain swaps um potentially you need to do the transaction by yourself so you take the risks maybe of Sandwich attacks as well or front Runing attacks and say for large swaps I said already someone can try to attack when and it's became more e economically um uh for for that so um you can be also Rock pull so someone can maybe remove liquidity from from the bridge and you your stock maybe somewhere in the middle as well so um our solution is um Atomic swamps together with our intent based protocol so we ran intent-based protocol for swaps since December 2022 I personally came to this problem with um executing transaction by myself when I had to rebalance my portfolio I was under one year uh of holding period in Germany I'm German citizen I need to pay taxes for my um for my like trades when I earn and I had to sell all ethereum what I had and some other assets and to buy it again so it's like I can fix the loss and in the Bild um so I did it and I recognize I was front run also by using 1 inch for the classic swaps I did the transaction by myself someone became very smart and started to also front run our users that's why um we figured out with our team to build an intent based protocol where user just create an offchain aura and we use specific D Auction approach I will show you how does it work a little bit later uh to ensure that the user get fair and uh I I would say best execution what they can get um by having a MAF protection so and then we were looking to to build the same uh with the intend based protocol also for cross chain since it was terrible to use the bridge and I had my personal pain so I I got my payouts from real T it's a tokiz real estate um project where you get every week use DC payouts onos chain to send just over and I have a 1 in debit card what I use normally to pay coffee for for coffee or some other small things and I had the problem I had to transfer from gnosis chain to ethereum it took 30 to 30 minutes to one hour once I forgot to claim and then on the website it disappears then I had to find out how to get the money from from the from the bridge so um we found out that uh someone posted uh 2012 on bitcoin talk Forum proposal um about hash time lock contracts so it's Atomic Atomic swap approach where you can just easily ensure that uh everyone get the money doesn't matter is it cross chain or this is just another P2P deal yeah you can do it also on on the same chain in atomic manner so to to find the proper rate where the user is okay with the rate and the market maker is also able to settle because it makes sense in terms of uh uh business uh we came to the Dutch auction approach I'll show a little bit later so we call it in based Atomic crossan swaps uh it's seamless secure gasless you don't pay for the execution itself it's included already in the rate and the price comes from the competition between market makers that that means you you get really good execution um and good good rate it's self custodial it's very important so everything what we are building self custodial we we don't trust anyone I don't trust anyone I always verify everything so it's extensible so anyone can uh build um um integration for Fusion so also here on the Heaton if you want a nice Bounty you can for example build um uh based on our white paper and already existing implementation what you can find on GitHub of our smart contract you can build on salana ton on whatever chain even you can just write Bitcoin script on bitcoin uh and you can Implement um our protocol and you can get really nice Bounty this is efficient again Dutch auction um competitive resolvers compete between each other so we try to create a situation where yeah they they they comp compete between each other it's trustless there are no third parties no messaging protocols in between Bridges or something else onein Fusion plus looks like that so we have here in the middle uh here on we have like you select on what chain you want to sell tokens and what chain you want to receive tokens uh under the hood we have MTH protection by Design it's just the architecture of intend based protocols it's not possible to sandwich or to front run uh it's P2P it's uh zero gas costs um already said uh very cool thing maybe no one recognized this um you can trade asynchron so in a traditional blockchain uh transaction you have nonsense so you you create one transaction you sent you create another transaction you sent so the first transaction needs to be executed and then the second transaction can be only executed if the higher Nots and this is not the case here you can just create 50 trades and all the 50 trades going to be executed uh completely asynchron why because arbitr Traders fill they can do also partti of fills they can also take only parts of the order and um they F in different ordas and um you just don't care and it's happening just asynchron because there are no nonsense or something uh in the orders uh there are but for cancellation only so um we have resolvers professional market makers arit traders who trade among um different networks uh different platforms Al Cal exchanges they Source liquidity from everywhere they even use options you know like to hatch position and to sell maybe ethereum um to be more liquid than the others pinders use under the hood to get the market rates uh to uh understand okay what is the current marketing condition and what you see in the swap interface at 1 in um it's pessimistic uh quote it's what you would get in worse case but you would get in most cases you get better uh better rate or or the same as you have seen um we have compliance layer here in place uh 1 in Foundation take care that every Market maker is um every resolver is uh clean so they do KYB they do ml screening uh so we ensure that there are no North Korean hackers sitting and feeling AAS also if someone create an order like an hacker from North Korea happen multiple times create order we don't accept we we act as resolve as a relayer in um in between to replicate the uh messages like the the auras uh between user and market makers and here also one more thing what you can build build a PTP Network just uh look into uh ipfs Library there are some nice PTP libraries that you can use build a PTP Network and simulate uh replication of uh user orders to resolvers yeah uh I I would love to build in the next two years something like that that we introduce fully distalization of of apis so we can store orders and share with resolvers and we can do actually much more things but this real real case also you can create nice bount here yeah let's go further how does it work um we use we have a specific flow for this Atomic swap um user create um offchain Aura it's shared with the market makers market makers um settle um Parts partially the aura or fully when it becomes profitable for them what they do they go to the smart cont to the protocol On the Origin chain with their order and executing transaction to create escrow escrow for the the market maker itself on the origin chain and the user funds are transferred to this ascr after that um Market maker like resolver create on the destination chain additional escrow um and the escrow is assigned to my wallet uh and the uh resol deposit the right amount what what they need to to to deposit the user client verifies that um this the right amount is there SC is created and and the wallet is the the owner fit and the um um after that the client share the secret yeah so the order is created with the hash of the secret so and as soon the resolver get the secret they can go and actually withdraw from origin chain the assets to own pocket and then we force the resolver to transfer the tokens to the user wallet from the origin destination escr so we have seamless experience for the user user don't do any transaction at all except maybe approval for the smart contract if they don't have if the token don't um doesn't uh accept permit so if the to token doesn't support permit where you can just give a signature inste of approval so uh that's that's uh it um then we have time locks um and uh to to ensure just that we have finality here that we avoid reorganizations of the blockchain most of the the risks are on the resolver side so they need to take care that uh they wait wait wait enough uh to avoid reorganization so if resolver um start the process of the um of the settlement but somehow stop because something goes wrong or they don't like anymore there's another resolver who can do the settlement and get uh additional payments for this work uh because um the origin uh resolver the first resolver who do the settlement need to deposit security deposit so so we have really nice flow and fall back if something goes wrong with the resolver who settle Dutch auction um it's smart Dutch auction we actually we launch Fusion December 2022 with a linear duction it was uh you see in the left top Corner this is spot price spot price what you see on coin market cap and coin Geo so uh here in the middle you see the market rate market rate you get when you exchange the full amount uh in this case uh 5,436 if it's real case from someone and um you would face price impact the difference between uh the spot price and the market rate is the price impact So to avoid the price impact um I had uh somehow like after a long discussion with a friend uh he pit really crazy idea complete different topic somehow my brain did this picture it the theory is you have uh this sell in time just imagine like maybe 6 minutes in six minutes we would we would like to sell the full amount in this six minutes we try to sell for the better rate for the user we try to sell almost on a spot price how we Define the price uh points here you see here yellow these are price points so these price points I defined uh by take the full amount divide by six then we have first uh Point uh one six second point 26 36 46 66 here at the end for the full amount so and we say okay in the in the one six of the time we set the price of one six of the uh amount you swap and it works you see these green lines market makers fill the ordas not on the market rate so this guy got $40,000 W more compared to just normal old classic way to execute among this realized exchanges in one single transaction huge improval for big trades works very well also with small amounts uh thanks to this idea as well so I was working like easy like half year with the problem that the settlement sometimes didn't happen immediately or in in the first minutes uh it cost not support Sim this experience and it was because the price sometimes has spikes like it grows the the G the the gas price grows on ethereum sometimes and then we don't meet the market conditions and no one would like to settle because they don't make any money that's why we decided to make the price points Dynamic based on the gas uh price in the block so when the user create the order we give them uh we we put in the order the information to what gas cost they sign the order and we know how much did we calculate for the gas execution cost to to just ensure that the that someone Settle yeah and then we adopt the price and maybe move it below but still an acceptable um um price range for the user and after that we have 75% faster settlement than than before so this how does it work right now on the on the D app you just um enable it in settings still in kind of better testing we collect analytic information and uh still do uh waiting for more resolvers to join for to to solve the cross chain and so you select just what you have on one chain what you want on the other chain and settlement happens here you see partial fields and here you see it's a little B gamification here with Quantum Quantum security scan and so on just small from my side um It's anywh Magic what what's happening under the hood so yeah um how you can integrate Fusion uh we have under 1 in. da in our da portal you can get a free access unit any help our team is here with such t-shirts or just 1 in t-shirts um we can help you in any way uh you can get easily a free um Al key from our one. d portal and you can um use our SDK we have already small SDK uh if you want to improve the SDK because you find something you can contribute it's also option to get some some price for this well so for contribution um yeah you can get AAS you can get the quote you can uh Place oras yeah so um take a look at your documentations well described um if if not then just give a feedback to our team we will improve uh shortly so yeah just check it out on our Dev portal if you have any questions I'm here so I'm not sure if you have time uh do I have time minut nine nine minutes okay I was very fast so um I open for like for questions you have questions just ask we can devel with free tier right yeah yeah you you can develop a free tier if it's not enough for you for something for some use cases we can enable Enterprise plan for you for a short period of time for the Heaton no problem so in general also if you run your own startup you build your own startup via have support program so you can get Enterprise uh for free um Enterprise plan um we support like uh up to one year for free and then we discuss further so we uh we are coming from hecaton I don't know maybe you don't know we um we were born on ethereum global Heaton here in Singapore uh no not in Singapore in New York uh our first heon was in Singapore T Global so my journey began here in this city and uh in New York we have built um over a couple of um sleepless night um I have small keynote also today so um I will show you how how this started uh yeah we support developers uh you can just operate for free if you don't make any money is on support question is so uh in terms of tokens uh tokens can be added in the form uh in the UI uh if you do it programmatically it should actually work with custom tokens as well so you can for example if you ask for quote you uh right you just put the addresses here you see so there's no problem you you can build small on un user interface you can work just with the API for example in terms of uh the uh cancellation of the order you mean like it can expire you don't pay any any any funds like uh also if it's cancels you get the funds back so in the in the floor um in the settlement when the market maker comes and settle the your tokens are transer to the escrow if it something goes wrong and no one settles you just get your funds back because the resolver move your funds with a security deposit so and someone else will just move your funds back to your wallet you don't pay anything for this all risks are on resolver resolver they don't like this so I got already some calls what we are doing and why we put all the risks on the resolvers I told them you're professionals or or we we are not in kindergarten so U we need to protect users and in CHS also regulation uh sooner or later we need to provide high grade of user experience yes we are looking to to make own standards but um I spoke uh two days ago with Unis swap team they have already proposal we have some commments to this uh to this cross chain standard what they um um introduced with across uh if they change what if you want then we go with the standard of unisoft necross and we will upgrade to in the next version the thing is uh smart contracts were already done last year in December with completely with security audit so we were just a little bit slow with uh the backend team uh and some frontend teams at actually we did two two three weeks Heck on in Dubai now we we are we have headquarters so you're welcome to visit us if you want when you are in Dubai um we did like hackaton and delivered the last things like in Heaton mode thanks to the team um yeah I hope we will go with just United Standard we ensure it on Smart contract level so that Chun is in smart contract so the order if you look on the order how it's created there's additional information what you need to set you you can put price points into it and then it's just in short in the settlement contract yeah so nothing can go go wrong theoretically uh if no one settles the aura expires uh if someone settles it's on the conditions you actually Define when you create the aura and the aura is also Min return so less than Min return you cannot get yeah and we share we share we share the ordas with uh with the resolvers Um this can be we can go maybe wrong that our servers are down or something that's why I ask here someone to build a PTP system so we can just rely on thisiz infrastructure any other questions questions to bounties or something or you have maybe idea to build something you are not sure or something you can also come to me if you want so if you don't want to share the idea with others yeah what's again uh I didn't write the by myself so um this a good documentation you can take a look and we have a technical uh Team here so tner can answer also questions regarding this um this just normal standard atomic approach with the secret and the hash of the secret when you create the AA so um yeah my my team will provide help as much as we can so we have right now uh ethereum polygon B smart chain arbitrum optimism base um avalange B smart chain in support um we want more for sure we will add salana ton Bitcoin but we need also your help yeah so uh it's also possible to Pro to to get grants so we have da we have1 15 Millions US dollars right now for for different grants so you can actually get um one year's salary so it's going to be streamed you can just work full-time if if uh our committee will select you if you want to do this yeah kind of to build I don't know Bitcoin script uh based uh implementation of our of our protocol cool then thank you very much was a pleasure see you [Music]
Automatic transcript — names and jargon may be misspelled.