Building On Uniswap by Daniel Robinson, Hayden Adams
Devcon·Fri, Oct 9, 2020, 12:00 AM
Visit the https://archive.devcon.org/ to gain access to the entire library of Devcon talks with the ease of filtering, playlists, personalized suggestions, decentralized access on IPFS and more. https://archive.devcon.org/archive/watch/5/building-on-uniswap Uniswap is an automated market maker on Ethereum. It can be used directly as an exchange, but arguably its most interesting use is as a building block for other protocols and applications. This talk will discuss how Uniswap was designed to favor composability, including offering synchronous contract-accessible liquidity, turning pooled market maker liquidity into its own fungible asset, and aiming for simplicity and efficiency rather than completeness. The talk will demonstrate ways in which Uniswap can be composed with other protocols to create new kinds of on-chain financial products. The talk will also preview some future features of Uniswap—ERC20-ERC20 pairs and Uniswap-based price oracles—and show how they would expand Uniswap’s usefulness as a building block of decentralized finance. Speaker(s): Hayden Adams, Daniel Robinson Skill level: beginner Track: Developer Infrastructure Keywords: technical Follow us: https://twitter.com/efdevcon, https://twitter.com/ethereum Learn more about devcon: https://www.devcon.org/ Learn more about ethereum: https://ethereum.org/ Devcon is the Ethereum conference for developers, researchers, thinkers, and makers. Devcon 5 was held in Osaka, Japan on Oct 8 - 11, 2019. Devcon is organized and presented by the Ethereum Foundation, with the support of our sponsors. To find out more, please visit https://ethereum.foundation/
Transcript
[Applause] all right my name is Hayden adams and i'm the founder at units law building on your phone so what does this talk about it was going to be talking about gonna swap but now it's a weather advisory a hurricane in the top of the site in north pacific any signor tested a typhoon is a tropical cyclone that takes place in the Northwest Pacific super typhoon to give this is a category 5 hurricane is on its way all right what does this talked about this talked about you know spot it's about what can be built on it today it's about how we can expand its utility you know and you as well version two and then how we can skill you as well while retaining its utility so what is you know swap its first and foremost in decentralized exchange protocol and it makes use of automated market making it makes use of pooled and tokenize liquidity but what that means is in a and a traditional exchange you kind of have buyers and sellers matched up on an order bus in unity sort of automate that whole process and then you gives people a token that sort of represents their position it's easy to understand that youth and that's one of the most important things so why they need it first it lowers the barrier of entry to the participation in fines so can you stop anyone can be a market maker this is the current distribution of market makers on you as well as a few weeks ago about 25 percent of people in the 2.5 billion dollars dipole come from users who but who you less than 1% so it basically allows you to pull together a lot of small market makers and do what used to be only a whales game anyone can create analyst an asset this is super important in units WAP right now is over 800 tokens about 100 250 have actual usage it's a lot easier to get listed on you know up the Nasdaq or even on essentially are on a centralized exchange or even on us sort of off chain order both decentralized to sync this anyone can build on top of it and this is more the topic of this talk part of the reason for that is it's all open source the open source front-end documentation or contact SDK and so you know since they launched last November in a number of projects have started building on top of it so like one of the one of these faces right now it seems like a lot of demand for trading tokens on material so trading interfaces wallets deft aggregators and then we have you know some people want to use it to earn interest as a market maker what they're doing is they're maintaining a 50/50 ratio in the New York when a token and then they're burning fees on trades between the two you could one option you could do is you could use that liquidity as collateral take out a loan against it basically be able to leverage up on market making another option is create a liquidity source gonna have a patient you care about so make your doubt but it's a lot or there's a lot of MKR is a lot of Spain and the reason is tokens like spank have a really hard time getting listed on exchanges because they're about to do if you don't industry some people and this is the one that I'm more interested in its like integrating eunice walk directly inside of applications so for example you could you know locked up eat and maybe devoured ice Popp that die for eat locked out and make it out you can kind of loop through protocols to leverage out though they've been you know some projects have tried this out like open new odessa and stuff like this but what we really want to do is we want to improve you as well so they can serve more uses than I just innate and we're gonna do that weekend as well version two okay so the first and most and one of my favorite features is a decentralized price horrible the second is you know direct gives you twenty two or three twenty pairs now Eunice Bob Forsyth all tokens to be parody and there's a lot of is a big advantage there and they've also some versatility versatility that you can get allowing arbitrary pairs and finally we've refactored the entire code base to make it a lot more flexible I think more secure and better than a lot care okay so how do these Oracle's work well the idea of the Oracle's that that it provides a maximally decentralized chain pricey for any RC 20 token with a very clear incentive structure very easy to reason about that like the cost of attack how secure it is and it can be useful for things like synthetics lending automated trading stuff like that one example use case that we're looking at is no augur needs a got to eat spicy or so actually before we get on I mean I maybe explain a little bit of how these Oracle's work so the the most meaningful price that you know right now there's already projects using a spot with an Oracle or they try to checkpoint the price for maybe some sort of blending system or synthetic asset but it it can be front run any transaction that checks the present unis Bob someone committed you like the price right ahead of that transaction and basically you know mess up the Oracle for a relatively cheap for a pretty cheap it doesn't cost that much especially since you can synchronously like front run it move the price let an Oracle transaction go through and then push the price back so what we're gonna do is we're basically gonna have every every transaction on Eunice book check the price and if it's the first transaction of the block or in store that price and what we can do is we can basically average prices across multiple blocks so that no manipulating the price on you this fall if you could know you might be able to manipulate it for one block but for many manipulating across a thousand blocks here across an hour or a day you know you what we're ideally wanting to expose is a lot build pretty much arbitrary time length Oracle's on top of you know swath so if you check the Oracle once at the beginning today and once at the end of the day we can get it perfect one hour on time weighted average price or the price on unit swap at the beginning of the block the reason we do it beginning the block is basically because in order to manipulate the price at the beginning of block you have to the last transaction in the previous block which means you're opening yourself up to an arbitrage in the next block and doing that accost you know a thousand blocks can be very expensive the microphone oh you can hear me yes about that okay the the other feature who are working on is the earthy 20 to go see 20 pairs the main idea here is to allow the pretty providers to take on a wider range of positions also allow for lower slippage and fees on direct here some 22 years to 20 pairs for one two with any of them right now you know when you go here's the 20 or 20 you have to go here's the 22 ëthere see 20 you pay 0.3% see on both sides and then the slippage on both sides it is in general we think reading increases the protocol flexibility so an example for the use case where the most interesting with allowing tokens to be parroting in stable coins or even stable point compared against each other or just have very highly correlated assets you know if you create there's all sorts of different projects where they they create assets that are you know meant to be correlated with each other for example you can imagine like C die and die between the two you're just gonna you're gonna have very low loss you're very low basically the losses in units while coming from the prices diverging so an example use case would be AC died to see us DC pair unlock this this is a so well that we were thinking about the idea of ayodhya TOS BC pair as an example use case or or this but one thing that kept coming up was the opportunity cost of lending a stabilizer so right now if you if you let make about 15 percent return versus if you were looking provider on the system and you know swap you would have to be making a fifteen percent return for it to be worth it but if we have these sort of ability to create arbitrary here C 20 or C 20 pairs we could create a pair between C dot HTM CC where when someone wants to trade you know the trader is extracted from them they just send some tired of the contract the dye is go through compound converts until she died and then she dies goes through you know swap converted to see us DC Co species back to compound or us decays and then us DC back to unit swap in a single transaction and what you have is for the liquidity provider they're able they're basically leveraging up they are earning interest on compound while earning fees on you know swapped for the trader all they deal with his dying this PC and so they have a much lower opportunity cost in this case or the provider yeah so there's no healthy loss in London and in this case now this is not true you should be telling me that's wrong because technically they can have a different interest rate so they were maybe that's very very small very very small potential loss between the two but not not very much so yeah users can swap die for us to see the very low prices and then you could also even imagine this see the height to you if you see liquidity pool tokens then being used as collateral because it's very stable and then not only have you leveraged up by lending in market making at the same time but then you're taking out a loan against that same platter again yes the money Legos get kind of crazy but we have a lot of fun with it okay so one of the things that the thing that this has been focused on Safari is like the idea of building on top of unis wall and we also want to improve the you execute as well and one of the best ways to improve UX parades for a single application is using layer 2 but with most layer tools that have existed up until some point it's been oh it's always made this sacrifice but we can no longer interoperate cleanly and smoothly with other with other applications so there's you know a few different applications out there there's plasma there's a Corolla and have about mr. Corolla maybe I'll very briefly very very quickly high level with explain optimistic roll up you post blocks you often you execute them optimistically which means you assume everything is valid unless it's proven invalid and then basically there's some data off chain that users can have proof induction is valid or invalid very very scalable because you basically have to get everything off chain and you don't put any data on chain then you have zk roll up this is the idea that you can do a you can put data on chain very lik minimal data for transaction and then you do a stars proof that all those data all that data was executed properly optimistic roll-up basically combines the two ideas we've execute everything optimistically is blocks that are posted and you assume that they're valid but then you post the data that you need for the Frog proof to ethereal okay so optimistic roll-up is lit optimistic roll-up can scale Eunice pop we can do generalize mark contract oh oh yeah an optimistic roll up in scale generalized interoperable Smart Objects an ethereal so we can continue to build up on top latina swap while scaling you some some credit to plasma group there's Karl over there I don't know if anyone else from flattener grips in here maybe not but middle of England when Karl flourish Ben Jones will Meister and then cut it to the tower group aleck who had also done a lot of most of the research how most have researched by he you know there was a platinum research to the role of recent research for sure and creating a theory so an optimistic develop do unit swap yes it can and we built it and can do about and by we I mean you know swap created a front end and a group created back end it can do about 250 transactions per second or it can if we optimize the client on Istanbul it can you know has native meta transactions that you can queue up multiple transactions and we have it was built by UNESCO and Plasma group so now I'm gonna ask you all to pick a team really important are you Team Unicorn you know ones are majestic their side they're beautiful and they love long walks in nature or are you can hitting take that cute they're very smart they're the life of the party and they love eating until they fall asleep okay raise your hands a new team unique okay [Music] okay it seems to be 50/50 mathematically but I'm in this room if the page like it's called unit big dot exchange I'm gonna demo it right now I think I have time good all right I actually have people to heart regressions I wanted to okay go alright you know thinking that exchange and a demo with Eunice pop an optimistic roll up and working on it for the last month alright so the first thing you we need some form of civil resistance because the money is all fake we can't show you fees alright so you can fo get tokens from Twitter we have a pretty great Farrah Fawcett alright it brings up is tweeting at you the pig exchange in a tweet yeah okay so we just got sent 30 uni tokens and 30 piggy tokens on our layer to wallet this wallet is a burner wallet built into the browser you see there's a wallet now I'm like most Emily was I'm not gonna be bidding very long these transactions to confirm and it's done and it's done we don't want to we want to we want to sell all our pigs so that increases the value of okay we also have good integrity of this is is basically to encourage participation of two people who match up and they both have wallets on they can scan each other ready just like that report there you go and I got 10 tokens on this account and tokens on the other account yeah so the the real thing with optimistic roll-up is it's a massive massive UX improvement over over using in the base train right you can get instant confirmation you can get two of your 50 transaction for a second you can you know you don't need to do the approve and transfer you can basically queue them up together basically doesn't need this yeah let's hear stats here so we've done about 2100 transactions through our depth on we've had a bunch of people try this demo I didn't realize this I always pay really high gas price for my transactions the average gas cost of a gentleman or the average wait time of transactions on aetherium in over a minute so we've saved two thousand six hundred minutes on these two thousand transaction people just sitting around waiting so that a lot of time yeah all right anyway I think I'm gonna open up your questions if you have any questions about this demo about music I can too if the transactions are optimistic how soon will people know that my people know they're lying okay as soon as they they get the uh basically say you have someone from a blog they submit that block so it's a block header and a half it can work over it and then some daily anyone in the world as long a minute here iam no and they'll see all that data and that's all they needed to sort of validate everything every transaction like lots of ideally someone's watching the chain I knew who cares about it can watch the chain catch invalid or into the transactions and so basically as soon as I submitted someone who put on some swatches you have it any other you know what trading baseball cards or [Music] do you happen to work in a crypt if none of the trades that involve baseball cards oh no no I agree I so one thing I really like about about this sort of but it's not really validating about building this demo is that I do feel like you could create something kind of like the way crypto Kitty's went viral and it just kind of shut down in theory own we could you know create something like that worth of our you know think it's not necessarily like a super viral games because it doesn't have that many elements to it but you can create something crypto please like that could have rejoined much much much wider audience of people without a good question I think that the way that I see it playing out is that for the vast majority of tokens they would still be paired with II the only really eath or maybe some stable coins I think that there's very specific use cases I don't know if you've heard of like yield protocol that maybe makes usage of sort of arbiter of of the young trade fairs but for most of them I just see them being paired like maybe eat maybe die maybe go Stacie with a couple and if you're only routing through a couple it's actually not that difficult to kind of check the price on a couple different ones yeah actually if you want to set the idea of the yield protocol is that if you pick Y tokens and pull them a terrorist respective tokens if you'd like yok R + MK r I'm Eunice wah and you have the Oracle features when you can create an interest rate Oracle doing this consistently calm down yeah any other questions I've heard discussions about the termite determining the transaction feel yunusov as it meets or really have a constant slippage for a given price and you research like instead of using a point three percent it just having something that's more there is there has been research if you love that research I don't have you know comparative Charlie noise paradigm media investigating investigating that at the current moment I don't have any sort of formula that I can choose a better what options you could just really create a pool that fuses in nominations them we problem there is you once again national quiddity it's definitely like a important Eric research I some of my intuition around this is basically if you had a different fee all it would really mean is like you may be almost like a different would it be level where it means equilibrium like is a sort of a point where the volume it like the natural volume and look with any kind of matches up you can I think that that point just kind of changes based on 50 level but for certain pairs is true that like you know if you can have a specific pair that's really really 20 minutes but basically if you could have a specific pair that's like really like tightly like a very very tight margins on another exchange obviously as well becomes less efficient for that so this doesn't use meta transactions actually this uses a unit pic uses a in browser burn our wallet which is nice looking like sign for your private keys it's stored in your in your local storage on here so really so that the idea when I said native minute transactions what I really mean in the native account abstraction basically the idea is in Bitcoin for example you can you can sort of take multiple UFC of those and you can kind of send them like you can basically paralyzed their like say these three transactions all need to have been synchronously in unis Bob Brennaman on ethereum you have to do it like so it makes it a little bit more complicated to kind of queue up for example if you want to do and approve and then I trend action that you could transfer from you can't naturally queue them up correctly from your wallet but something like optimistic roll-up would essentially allow you to queue up transactions so that you can yeah yeah alright I think that [Music] [Applause]
Automatic transcript — names and jargon may be misspelled.