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

Loading player…

Philipp Seifert | Tokenlon - The quest to build a front-running- & trade collision-free DEX

Taipei Ethereum MeetupFri, Oct 9, 2020, 12:00 AM

Event web site: https://crosslink.taipei ===== 加入 Meetup 以得知下次聚會時間地點: http://www.meetup.com/Taipei-Ethereum-Meetup/ slack 討論:https://ethertw.slack.com 。請先從網站取得邀請信: http://bit.ly­/252hNY0 通關密語:decentralized 臉書社團: https://www.facebook.com/groups/443751072484739 歷次講座投影片、程式碼整理: https://github.com/EtherTW/Taipei-Ethereum-Wiki/wiki

Transcript

national film that I token the director of business department now mentioned iosing shelfie okay my Sharpie okay ha ha ha delicioso true and answer what sang ba gua was young showing well alright the talk for today will be about talk Milan which is the decent last exchange within I'm tour map the in the agenda the talk is marked as beginner so I will try to explain all the basic concepts but if you have questions we will have time for Q&A after the talk so regarding talk Milan talk known as the exchange and I want to there is some story behind our iterations of how we developed this exchange in the last year what we actually learned from our users I hope you can take away something from this and so I will talk about this from the past I would talk about where we are today like how talking on looks like today what we changed and I will give a brief overview of what we plan to do in the future as for a little bit of context speaking about talk Milan so as I said talk Milan as part of i'm totin of the wallet app I'm in Taunton um most of you probably heard about it it's a noncustodial wallet app we started three years ago almost three and a half years ago in China as an a theorem wallet and noncustodial wallet and noncustodial again means the user so you yourself is the only one in control of the wallet so you can in i'm totin case back up your seat phrase on a piece of paper for example if your phone gets destroyed then you still have your backup phrase and can start again by downloading i'm talking or use another wallet what you can see here is I'm talking you enter I'm talking and that's actually the new version we introduced last year the new version not only includes a theorem but also Bitcoin and some other block chains there's going to be more in the future and it includes the SC 20 tons it also includes NFD tokens like crypto kiddies for example and it includes a dab browser so if you know somebody or if you're a developer of a decentralized application please let me know we always try to help to get more users on interesting these endless applications such as mega Dow khyber network ride and last but not least token on exchange and that's pretty much the latest versions or the screenshot is from today the latest iteration on our token on exchange and what I said earlier today the M key hardware wallets so which is basically approved with hardware wallet you can use with i'm totin and it's pretty small so that's this one as for talking lon there is some story behind token on so we started to integrate this like native exchange feature last year last year was the first time we released it and we started with having it based on copper network and 0x protocol in a way that it was two interfaces and so what you can see on the right is basically one interface for khyber network the blue one and one for 0x exchange and for those of you who don't know exactly what Kaiba network is the Kaiba network is basically a decentralized exchange something like a decentralized shape-shift so you basically have two tokens you say I want to exchange ether to die for example you pick an amount of a totem and you get the best price that Khyber offers at this point in time and you say I want to trade or I don't want to trade after trading you basically get a price that's very similar to what they suggested and when you click I want to trade see Rex is a little bit different so see Rex gives you the ability to also trade to the current price that's available but it also gives you the bility to use limit orders and limit orders especially not I want to trade right now to the best best price but I'm going to I want to trade this amount to a better price in the future right I want to buy or sell to a better price and this makes this order book right that that's what we integrated the order book but with the order book there was some problems and we we looked at it for a couple of months and we found actually there's pretty low liquidity on CRX so see reacts has this idea and it's it's improving a lot and we're still building on CRX to that later but 0xs this idea of sharing liquidity between different exchanges right every exchange that builds on CRX can share their order book so if you trade on the old version of top Malone you would be able to see trades that somebody else did or offers on another exchange and the other way around but still there was not a lot of liquidity and there's different reasons for this one of which may be that at this point you had to exchange two w eth the rapt ether Totten before you actually were able to trade on 0 X and there were front-running issues which means and I will get into details about this later but which means that you may be that your trade maybe fails or you get a worse price so in the end what people did actually use was the khyber feature and the khyber feature probably because it's way easier right you only have two totems you click exchange and that's it you get a price estimation and your final price is very similar to the price that's estimated which means you don't get exactly the price that they show you what we actually learn from this and what we did as a result is basically what you see on this slide that's basically the exchange how it looks like right now and there's two main points for me personally what we changed on total on one is basically make easier to use and being easier to use means still using CRX but now we build the swap feature that Kaiba actually offers ourselves on 0x and we are hiding the W eath complexity more on that later and second not like unlike Kaiba where you don't get the price that you actually that they suggest in the first place before your trade in total on we make the technical side in a way that you actually can see the final price before you enter the exchange before you enter the trade before you click I want to trade that also means there can't be front-running more on that the technical details right now that's a general overview but I'm again we take this as beginner talks I want to go through it slowly in the next few slides that's the general overview how talking looks like from a technical perspective and there's basically two areas the upper part I checked with off chain is basically the communication of a set of market makers and the user at market makers are basically the people or companies that give you a price when you enter the app you enter a price and those people that you trade with another market makers there's a set of market makers there can be a set of market makers that give you a different price for one trade and turn on automatically gives you the takes the best price out of that set of market makers on Shane then after the price is set the only thing that basically happens is the traders finished the traders settled so both tokens on both sides get exchanged now how does it work technically there is basically several steps that I want to walk you through and the first step is basically before I do any exchange in ESC 20 tones I want to set an allowance that's kind of special that's something we introduced in a specific way the first part is you only do this when you trade ESC 20 times - yes e 20 or years II 2012 means - either you don't need to do this when you trade ether to any ESC 2012 but it gives you one big plus point which is it eliminates front-running now okay what does it mean so let's start with the user proxy the user proxy is basically a contract that lives on ethereum and that's one contract that every user on token on users should trade it's not it's basically not the user trading on 0 X protocol it's the user proxy that trades so in the 0 X protocol yes for every trade defined who the two parties are the maker and the taker and the taker the person that accepts the trade is in our case internal case always the user proxy which means that in the older version of our CRX implementation there were people who could say I'm the taker but in this version it's always the same taker that's called front-running but let's look into half what front-run exactly is I think then it will get clearer I actually took that picture from a CRX blog post if you search for 0x and front-running you will find a pretty nice blog post explain it for pretty length what front-running is and what kind of different different kind of collisions and fun training models you have um but the very basic idea is basically there's somebody who wants to make a trade let's say I want to make a trade on top melon on the old version of top known at least I'm the taker right I want to make a trade on 0x now the strait is already finished I said I want to trade one 1/3 to 200 die there's another party who wants to take who wants to send me the die who wants to take the ether everything's finished and we published this to the ethereum blockchain now on the ethereum blockchain this transaction was first go to the mmm pool right - is the theorem pending transactions pool which means there's a short time at least of some seconds and the until the transaction gets accepted into a block that somebody else can see oh there is this specific trade and could front run the trade that means somebody could take advantage by seeing this trade and either block your trade or get a better price by taking exactly this trade how would the front-runner do this and what would he get out of this the front one I would basically do exactly the same transaction and set a higher gas price the transaction would be inserted or mind by if there are - earlier and your trade would be invalid what does the front when I get out of it well either he gets a gets exactly the trade that you wanted to do and he gets a good price because maybe he knows that you are an expert and you know what a good price is so he seizes and takes this good price or he actually takes your price and offers you another price if he's in a position to offer you another trade maybe it exactly the same point in time and you actually get a worse price in exactly the same trade and he gets a better price or maybe the spread between the two trades of yours so again we eliminate this front running at least a specific kind of front running in this case by saying not Phillip is the trader in this case Philips address but always we use a proxy contract it's always the same address and the only thing I need to do is set an allowance to this address so there is nobody from the outside of Totten on who can front run and say I want to take this trade and in the next step let's say I open the app I put in some amount and talking alone I put in what specific jobs I want to trade and as soon as I do that I get some prize for this trading pair I want to trade one ether to two hundred I I get a specific price right I get this specific price every second it updates and it's off chain but it is already a signed order that means the order that the market maker sent me already says this trade is exactly for this user and the signed order is already an order that can be accepted by this year X smart contract so in the third step when the user actually clicks on trade he already knows that this price that he actually saw and remember Kaiba where it's not certain that you get the price that you see in Tottenham you know because the market maker already signs this order that this order with is actually exactly this price will be settled on chain on the zero x mark contract now that actually means that there is another special case of front-running that can't happen especially nobody inside of turin that can take exactly this order - exactly this price for this trade because it's specified that you like the one user with a user ID can only take this trade and that also means that as soon as you click on trade you know the trade will be finished the trade will be settled on chain with a super high certainty from experience from the last couple of months that we have been running total on I think there was like one case where the trade didn't went through because of some Network error but there is no this literally like no case where somebody front runs because it's impossible and it's not impossible on Kaiba and it actually happens on Kaiba and the old CRX implementation and again because the user proxy is the trader in our case is the taker and CRX terminology he can also do with the we3 peng so if I tried ether to some other Taunton I don't need to wrap ether first I don't know it don't need to exchange to W eath or lock either and the W is a smart contract but I just send ether and the rest happens within the user proxy smart contract in the last point we actually pay for your EC 20 transaction cost so remember you certain allowance for the EOC 20 contract and that means we can actually pay for the transaction that sense the SE 20 when you am cell and yes you 20 at all now what's next there is a roadmap for talking on there's a roadmap for I'm talking and there's a couple of ideas that we have you saw what tone on what how talking on looks like right now and this is some topics that will come in the future maybe already in the very near future and one of which is I am BTC I am BTC it's the idea of building some product based on what our experience tells us what our users actually want and what they actually want is receiving some income and why not lock BTC to receive some income on your ptc on your Bitcoin as a child like since since over a year already I'm talking with also Bitcoin wallets so we have users that have a Bitcoin right and you can trade on Tottenham so why not finance a income on your locked BTC by a token on trading fees this is the bigger idea stay tuned there will be maybe an announcement soon another few ideas photon on in the future is of course opening to unknown as I said cotton on right now is kind of this closed system you can trade on token on and I'm cotton in your wallet but of course the idea is that more people or at least people outside of I'm talking can use chalk known for trading why is this interesting of course for us it's interesting because we can get more users but there has been happening a lot of changes recently to the text space if you look at the numbers of what Texas I actually used it changes a lot and then there where some new parties introduced in the last half year in the text space and those parties are actually aggregators there as I think you talked many talked about it yesterday 1-inch exchange and total index dot H II there's different players that actually aggregate decent US exchanges and of course what we want to do is we want to aggregate exchanges as well we want to give our users the best price which we are pretty close to or certainly are sometimes at giving the best price but if you are able to aggregate all the prices over all these in lots exchanges and you can give the user still the security of indigenous decentralized exchange right being certain that the trade will happen and noncustodial shop while having always a super good price and liquidity now that means we can integrate we plan to integrate more exchanges as market makers on one end and on the other end of course we also want to open the API at some point to top Malone so that other people can trade from without from outside of Tottenham and that also means building a front end the desktop front end for using totem alone on a web app you could call a totem on Deb now CRX version 3 if your ex protocol that we are using for settlement basically is also going to introduce a lot of changes in a version 3 right now it's version 2 of t-rex protocol they are also going to introduce a lot of changes which we are anticipating and part of which are about staking part of which are about aggregating for example okay the video doesn't load but I'm prepared now let's just walk through really quickly how it actually looks like now opened i'm totin and this is you talkin on exchange get some small introduction and after the introduction you will be able to trade as currently a small fee on this is the current interface right so you pick and choose which taught me so you want to trade you insert the amount you want to trade and as soon as you insert the amount you get a price right and you can also see it compares to a hobby and other exchanges so that you can see that you actually get a good price or the best use your fingerprint or face ID and then it's it will be submitted on the chain now now you basically already know it's still pending it's not being mined yet it has been - hasn't been mined yet but you know that for certain you will get this price so this already concludes my talk we do I think still have more questions yes so we can come back you to a section right now do you have any questions for the audience gentlemen at our backs hello I'm a little bit confused about how to you prevent like their phones running by DX because you mentioned you have to sign the order sign the bankers order I think that if you make the may the maker to sign order that means if you settle and maker order and you have to wait if someone takes order then you have to keep for the information like signatures so I'm a little bit confused how do you cheese's I didn't really understand the last part if maked us can you explain again how do you achieve the preventing the ds2 to perform from landing well what I mean by it Thanks performing front running is basically the the decks for example AC extra layer what 0x exchange would see are the straight happening even before it's in the men pool of a theorem right and they would insert a trade that front runs that the other trade right in Tottenham that can't happen because the market maker defines a user and only this user will be able to this trade has already for this user this users top imbalance will be deducted and this user will get a term in return right so it takes won't be able to say I'm another user and I will take I will do exactly the same trade who performs the meshing is the meshing engine by soaking on or or if every order have to be placed on onto the chain because since I the the order couldn't should be signed and to send to the and matching will be performed by you of system right is it a question matching so it's a request for quotation right and the market maker already signs the order that will be settled on chain right defining who is going to be both parties one is themselves the market maker and one is the other party the only thing that talking on then does is basically uses this forwards this transaction to the chain right and then the 0x contract basically uses this information to settle the trade which means perform the atomic swap does it make sense oh it's just a relay to send yeah if you say talking lon the token on back and right you could also say of course the user proxy is also part of top Malone right but yeah I think that makes sense in your context thank you thank you do you have any more questions for the audience now more smart 20ma send a JK Ichi your win team ah Vinnie lovely chat hello I'm just wondering how much does it cost for a token loan to support free GRC twenties exchange because you you pay the gas fees for the users so how much it normally cost for s organization to do this yep um how much does like how much do we pay and gas cost for one ESC twenty trade I'm not completely sure that something oh I'm not sure that probably changes a lot I think I would I would be safer to talk about gas cost right and that's probably something around one hundred thousand maybe more I had some traffic on the gas cost for different exchanges was between fifty thousand and two hundred thousand I think so yeah let's talk about it afterwards Nanak can talk about exact numbers but yeah I think they did most the only cost is basically the gas constant pretty much it's on to the back end part yeah you should see it on on chain as well right let's talk about it afterwards thank you okay one last question I don't know what's the business model and how to make money before me there's a fee right so there's a 0.3% fear right now that you pay on a trade so that the piie is it is enough to pay for for a new server tool to change for the token for free yeah so yeah I would need to think about it the fee of course we only pay the fee for AC 20 transactions right but this should be the fee is always the same for AC 20 transactions no matter what the amount is of torrents right so if somebody traits like a million died right then 20.3% is a lot compared to the gas cost if somebody only traits like a hundred died and it's different it pays right now thank you thank you okay we actually do have a little bit of time for one last question anybody IRA or ahuyama Nakamura heard that you and Ohana now um enjoy finding Shia janja now insights I can see on the shelf a thank you very much for your sherry thanks [Applause] you

Automatic transcript — names and jargon may be misspelled.