Episode 292

Uniswap – An Automated Decentralized Exchange for Ethereum

The concept of a decentralized exchange has been a holy grail in the cryptocurrency space for many years. Many attempts have been made, but most decentralized exchanges suffered from central points of failure, poor user experience and little liquidity.

Launched during Ethereum’s DevCon 2018, Uniswap is one of the first fully decentralized exchanges and managed to become the leading DEX very fast. We were joined by Uniswap Founder Hayden Adams to discuss Uniswap’s unique model, the different participants in the protocol and the importance of decentralized exchanges for the blockchain space.

Topics discussed in the episode

  • How Hayden’s exploratory project to learn smart contract development took off and became Uniswap
  • How Uniswap works and its different participants
  • The advantage of an automated exchange instead of using order books
  • The role of liquidity providers in Uniswap
  • Feedback loops that can make Uniswap markets popular or collapse
  • The challenging economics of liquidity shares
  • Addressing Arthur Hayes’ criticism of decentralized exchanges
  • Why Uniswap didn’t create a tokeneconomic monetization model

Brian Fabian Crain: So we’re here today with Hayden Adams. He’s the founder of Uniswap and Uniswap was one of these things that kind of came out of nowhere and you know, all of a sudden there was lots of activity happening and it kind of became one of the main  used Ethereum kind of defied dapps. So yeah, we’re really excited to have Hayden on today to dive a little bit into what Uniswap is and his thoughts on the future of decentralized exchanges and decentralized finance. So thanks so much for joining us today.

Hayden Adams: And thank you for having me on.

Brian: Okay. What was your journey how did you kind of become involved in the Ethereum space and find your way towards working on Uniswap?

Hayden: Well, yeah, it might feel like Uniswap came out of nowhere for you guys, but actually before it was even announced I worked on it for over a year. But yeah, I basically I was a mechanical engineering major. So I spent you know out after I graduated from college I spent a year working in thermodynamics studying heat flow and car designs, but I was sort of passively following the crypto space. A good friend of mine from college Karl Floersch had joined the Ethereum foundation and so he was sort of constantly talking about Ethereum and slowly piquing my interest and I actually got laid off from work in about I believe June 2017 just as the sort of crypto bull run started and I really was interested in the space at that point and I wanted to get more involved and I decided you know mechanical engineering was interesting but not that interesting and I just decided to dive into crypto and I spent, you know, a couple months just messing around learning Solidity, you know, trying out token contracts, but I was looking for a real project to sort of grow and improve on and really become a smart contract developer. Karl at the time pointed me to some blog posts from Vitalik talking about something called  x times y equals k market maker and so I basically started working on the first version of you Uniswap in October 2017. And so it was basically my first project, to some extent it was my first big project as a developer and it was definitely my first project in crypto. And so I spent a few months building a proof of concept for that and I never really thought it would go that far but I just created this initial website that allowed you to swap between two tokens. And then I slowly started adding features onto it, pooled liquidity across multiple liquidity providers, chaining swap so you could go your ERC-20 to ETH, and then ETH to another ERC-20 in a single transaction, I figured out fee payouts. Once it started to seem like this could be a little bit more than just a side project I applied for an Ethereum Foundation grant and this was in April 2018, so I worked on it through the winter basically on my own and I continued to spec it out from there. The Ethereum Foundation grant was granted and so at that point it became a lot more real. So I hired a runtime verification to formalize the coding spec and formalize the x times y equals k model and I hired some contractors to work on the interface. I wrote the white paper. I wrote documentation. And this was through the summer into early fall 2018. And then I announced it on Twitter to a few hundred Twitter followers in Devcon 3 in Prague, November 2nd, I believe or November 4th 2018 and then it kind of exploded from there.

Sunny Aggarwal: And so this was sort of your first-ever software engineering project you really took on.

Hayden: Yeah to some extent. I mean, I was a mechanical engineer before so it’s not that it’s not that I had never written code before, but the code I had written with more like Matlab style or you know, Arduino robots are very very small stuff. The first interface for Uniswap was my first website and the Uniswap contract was my first. Yeah, so and like the testing for Uniswap was the first unit tests I’d ever and so it was you know, yeah, it was basically the first coding project. Yeah.

Sunny: And so did you also have any experience with like, you know trading and stuff or any experience with like, dealing with exchanges as a user?

Hayden: Okay, so not really, as a user a little bit, I had used Coinbase I had used Bittrex. I do some of the centralized exchanges and I had heard a lot about Mt Gox. I I knew about EtherDelta and so at the time I started working on Uniswap, EtherDelta was the DEX, you know, and it was a big step forward in some ways. It was non-custodial which was a big deal. I kind of recognized that. The exchange no longer held your funds and it couldn’t steal them but it wasn’t decentralized in the way that Ethereum was decentralized and it wasn’t censorship resistant the way Ethereum was censorship resistant and it was kind of a pain to use and so when I started experimenting with Uniswap, it was an experiment in being as uncompromising as possible on the decentralization and censorship resistant front and on UX front as well. Basically, yeah, those were the properties of Ethereum that had interested me, you know, the fact that you couldn’t just shut down Ethereum, the fact that no one controlled Ethereum, even though no one could steal the funds in EtherDelta people could still shut it down, there was still someone hosting an order book. There was still someone that was able to take down the smart contracts or upgrade them or control the token listing or take fees off of every transaction. It wasn’t decentralized in the way that Ethereum is and so that was like the sort of from a research side from a sort of experimental side, that’s what I was going for with Uniswap.

Brian: Was there a deeper reason why you cared about, you know, this particular aspect, you know, there’s so many different things that you could build out in the Ethereum space and smart contract space. So why focus on exchange?

Hayden: Well, I mean to some extent I kind of wandered into it. It wasn’t something that I you know, I didn’t enter the Ethereum space immediately saying oh I need to work on exchange, but it was more like I need a project to learn on. I need a project to you know, figure out how smart contracts work and what they really do and that just ended up being you know, the more time I spent building it the more interested in exchange I got the more interested in automated market-making I got, so it kind of developed naturally. But it seems like funny enough it was the most overcrowded space and yet it was still not being served in certain ways, right? There were a lot of projects in the space, but they all had compromised on certain things that I didn’t think should be compromised on or at least I thought it was worth experimenting in a project that did not compromise on those things. Yeah.

Brian: Well, let’s dive into Uniswap a little bit. So I mean we mentioned decentralized exchange, you mention this market maker thing, give us your high level overview of how does Uniswap work?

Hayden: Yeah for sure. Uniswap is a decentralized exchange protocol on high levels and it’s made up of a series of automated market makers. So basically the way it works is that there’s a series of exchange contracts, one for each token and each exchange contract represents an ERC-20 to Ether pair. So it allows you to trade between Ether and ERC-20 tokens and they are all linked together by a factory / registry contract, that basically holds a mapping of token addresses to exchange addresses and so that allows you to look up if you have a token address it allows you to look up the exchange address associated with that token, and so if you want to dive into more how each exchange contract works, let’s say you have an ETH to DAI pair. Right? So anyone who wants can call contract and deploy this DAI exchange contract and then anyone who wants can deposit liquidity into that DAI exchange contract and so there’s two classes of users in one of these exchanges. There’s liquidity providers and there’s traders. Liquidity providers basically deposit two tokens, Ether and the ERC-20 into one of these exchange contracts and then traders basically send one token to the contract and get the other token out. One of the cool sort of aspects that it’s trying to solve is removing the need to coordinate users under an order book and you know,  it’s sort of solving some of the coordination between liquidity providers and traders.

You have one of these exchange contracts and let’s say the first liquidity provider would put in an equivalent USD value of ETH in that ERC-20 token. So they might put in $50,000 worth of ETH and fifty thousand dollars worth of dai, and then exchanged between the two assets are automated using this formula x times y equals K, which were calling the Constant Product Market Making formula. And basically the way it works is, you know, you have ten ETH and a thousand DAI in the contract. Then the constant would be 10,000 and then if you send one ETH to the contract then now there’s 11 ETH in the contract, the contract says well the ETH times the DAI in the contract needs to be held constant. So you do you know 10,000 divided by 11 and that gives you the amount of DAI that should be in the contract which is 909 and so it returns 91 back to the buyer. Which is, you know, the difference between the amount that’s in the contract and amount of should be in the contract.

Sunny: So essentially what is happening here just to just to clarify is that basically, the more that people are buying the system sort of is automatically cranking up the price and the more people are selling its cranking down the price.

Hayden: Correct Yeah, the more you sell, the higher the exchange rate goes and that’s basically what we’re calling slippage. So if you in general want to make a trade that is small relative to the total size and the liquidity reserves. So, you know, if you have a million dollars in the contract, you can make $10,000 trades you can’t make $500,000 trades because that will have a huge amount of slippage.

Brian: Yeah, and of course some of our listeners will remember our episode with Bancor,  which you know is a few years ago now but Bancor kind of had a similar mechanism right where you also have like this contract on chain, and then the idea is okay anybody can go there and you know, there’s always a price right the contract’s always willing to trade with you, whereas, you know, traditionally change you have like buyers and sellers in there has to be some sort of matching and let’s say there’s a little liquidity and maybe there are no buyers or very few buyers. Whereas here, I guess one of the benefits is that it might work especially well for you know, illiquid pockets too.

Hayden: Yeah correct Bancor is very similar to Uniswap. One of the main differences is that Uniswap uses Ether, so Bancor and Uniswap both have a common pair, in Uniswap it’s Ether and in Bancor BNT token, we think that sort of part of the idea is that having Ether is sort of more liquid and represents the sort of underlying token for the protocol whereas BNT was this just token the Bancor made and sold 30 percent over a hundred and fifty million dollars or something crazy like that. I don’t know the exact extent they sold but I know the exact amount that raised which is a hundred fifty three million.

Brian: What’s the what’s the trading volume today on Uniswap versus Bancor?

Hayden: Today? It’s hard to measure the Bancor volume because they kind of track their volume on EOS and then they double count volume through BNT. But Uniswap volume today is 500,000.

Sunny: Just for some context, I know when I checked a few weeks ago, Uniswap has the highest volume of any exchange. It’s volume is about 10 x dot of 0 x

Hayden: If it is on Sundays not today. Today actually Xerox is higher volume but Uniswap hit a peak volume of six million dollars in one day about two weeks ago. Today is just like a low-volume day. But yeah on many days it’s the number one DEX in Ethereum.

Sunny: So to go back to some of the mechanisms of how it works. So the tunnel like what’s happening here is that, you know, the concept of slippage exist in normal markets as well on  any exchange but it’s usually rather in most exchanges and order books it’s an emergent property of the behavior that’s exhibited by the actors in the system. Right? So, you know, you’ll often have market makers that come into the ecosystem and you know provide liquidity and to incentivize themselves there’s a spread between the bid and the ask and that’s what creates the slippage. Here in Uniswap instead of like slippage being an emergent property it is sort of the core property into the protocol. And so can you explain what some of the rationale behind this and what are some of the implications and second-order implications of such a radical change to happen we normally think about markets

Hayden: Yeah. So you pretty much nailed it on an order book you basically have constant bids and asks and market makers are maintaining spreads right , I’ll always buy this token for $1.01 and I’ll always sell it for $1.05 something like that and then the more expensive you get the more people are willing to sell at that price and that sort of creates this natural the more you buy the more the price slips. In Uniswap, it locks you into a curve and it says basically the more you buy relative to the current liquidity available, it’s a deterministic amount of slippage and part of what that does is it forces all liquidity providers to basically work together rather than to compete, right? So on traditional order books liquidity providers are basically people with a lot of money usually and very sophisticated setups and competing to offer the lowest slippage possible and sometimes that actually, you know, the way it works out in many exchanges is that they basically are paid by the exchange itself to operate tighter spreads to give users better rates and then the company sort of kick some of that money back and so the exchange basically takes money on fees and then they kick it back to the liquidity providers, Uniswap in some ways fully automates that it basically says we collect fees on trades that all goes back to liquidity providers, but all liquidity providers are going to basically offer the same rates in the same slippage and then we’ll buy pro-rata from all of them and then we’ll pay fees out to them pro rata as well. It’s a pretty big departure. I haven’t heard a very many pro rata exchanges in the traditional finance world, but I think it’s something that is very difficult to do in the traditional finance world. It’s something that almost you need something like Ethereum to create at least in a way that is kind of doesn’t require having, you know, people custody all their funds under one person who’s maintaining some some formula. And yeah, one of the cool aspects of it is basically reducing the complexity of market making and reducing the barrier of entry to market making so, Uniswap basically fully automated the spread so, you know, rather than needing to constantly sort of be watching the price in maintaining the spread if you’re a Uniswap liquidity provider you could sort of look at how you think the prices of the tokens will move long term and then you can just lock liquidity up in Uniswap and kind of leave it in its, you know, you’re taking more bets on the initial and end price. And as long as you’re kind of expecting some some volume. It also allows you to contribute a very small amount of liquidity. So traditionally market makers, you know, they have they have to have a lot of money to sort of be able to operate these businesses and Uniswap since it lumps everyone’s liquidy together and pays out fees pro rata and take some them pro rata, you know, you could put in ten dollars or you can put in a thousand dollars you can put in a million dollars and no matter what you’ll get a portion of the fees directly proportional to your contribution, which is the risk that you’re taking in the system. So Uniswap has thousands of liquidity, like in the ETH to DAI pair for example in Uniswap has three million dollars and more than 25 percent of that comes from providers who put in less than 1% of the total liquidity. So there’s plenty of people who put in a hundred dollars or fifty dollars and they’re all collecting fees which you know, normally you can’t be a market maker with fifty dollars. So to some extent it can for some users turn it into like an almost Robin Hood-like experience for your like putting in a little bit of money and earning passive income while for other people they’re putting in a larger amounts and they may be updating their prices and and paying a little bit closer attention.

Brian: I’d love to dive in a bit this business model of the liquidity provider because basically let’s say in the example you made, so we have three million dollars that are kind of like locked in this liquidity pool. Now, let’s say I put up a million, so a third of this, and now all of the trading that’s going on 0.3% is basically a fee and that kind of gets added to the liquidity pool. So I put up a third let’s say of the liquidity pool, but the liquidity pool now grows because fees are collected. Right? So I’m now entitled to a third and you know, let’s say over time maybe a million dollars after like half a year a million dollars where fees are kind of a crude in the liquidity pool, and so now there is four million in there even though only three was put in as cash, so I could like take it out and I would get you know, one plus a third of a million out and that would basically be sort of my profits right.

Hayden: Correct. Yeah, there’s some rules of thumb with it. So basically if you take the the daily volume times the fee rate which is 0.3% which is 0,003, and then you multiply that by 365 days in a year. It’s basically the daily volume times 1.09, but you can kind of rule of thumb added daily volume times 1 is the value and fees generated. So to put it in a different way if you do a million dollars in trading per day on Uniswap, then Uniswap will generate about a million dollars per year in fees. And so there’s a profit side in a loss side. I’m just going to focus on the fees and the profits and then we’ll get into where the losses come from because they’re very separate. So, you know, if you have 10 million dollars in a liquidity pool and you do a million dollars per day in trading then you’ll basically, you know, ignoring losses you have about 10 percent returns because you generate a million dollars per year in fees off 10 million in the pool. And so that’s 11 million ten percent APR. There’s a whole losses side which kind of you have to factor in as well.

Brian: Yeah. I know I just wanted to ask very briefly on this profit side. So in the DAI example you made, because in the end it kind of works out like an interest rate right like I put in some money and then these fees and it’s kind of like you make some return on that.

Hayden: So right if you had a very dependable volume in a constant amount of liquidity, then it’s basically just the daily volume over the total liquidity is your interest rate.

Brian: Right so a highly variable interest rate, potentially. But so what is that right now for this DAI market for example.

Hayden: You know, it fluctuates really because of how the trading works. There have been days where the DAI market did like two million dollars in trading off a three million dollar pool, which would be like a crazy return right? It’s almost a 60 percent return on that day. If it did that every day for a year, it would be 60 percent return but then there are other days where it does two hundred thousand dollars off of a three million dollar pool, which is a little bit lower but the profits in general of the DAI pool has been growing at a rate of about 11% so it’s about an 11% return right now on the DAI pool sort of averaged out, ignoring the losses side, which once again I’ll get into.

Brian: And one of the interesting dynamics seems to be here so let’s say now in this DAI example, I mean if you have two million dollars worth of trading on this market then okay, the return would be so high. But of course it means that there is a huge incentive for anybody else to come in and add liquidity to it and then they can basically take a part of this return and you get this kind of dilution, right? So you’d expect if there’s a high trading volume the liquidity pool kind of grows and then the returns come down again, right?

Hayden: Yeah, correct. Here you’re sort of expecting the liquidity pools to grow, basically in my mind the volume drive liquidity more than liquidity drive volume though it’s kind of both ways. It’s a little bit weird, right? Because if you have higher volume then suddenly people are more liquidity suddenly people can get better rates, then they can make larger trade. So maybe more people come into the market. So it kind of could be a positive feedback loop. It could be the reverse where you know, everything’s in a death spiral.Or you know if I find some happy medium. But yeah, basically you’re expecting the pools to grow proportional to the volume where everyone’s kind of expecting to get some reasonable interest rate kind of similar to where they might be able to get somewhere else.

Sunny: Is there any incentive for early liquidity providers? So like, you know for let’s say there’s illiquid market and I can be the first one to find liquidity and that can help them market grow.

Hayden: There’s only an incentive in that if there’s already a high demand and there’s no liquidity then while you’re the earlier provider you’re getting a higher percentage of the fees until more people join the market, but the way Uniswap works is your fees are directly proportional to the liquidity that you put up and so you can put in a million dollars and you’re the first person and you do it for a month and you’re getting a hundred percent of the fees, someone else comes in puts in another million dollars, they’re getting 50% you’re getting 50% and maybe they’re willing to take less profit then you and so maybe you have to exit a little bit of your liquidity. It’s really just proportional to what you put in. There’s no benefits just because you were there earlier.

Sunny: And is there any “on bonding period” from a liquidity pool?

Hayden: No, it’s all instant.

Sunny: So as a provider I could, given that ETH is like the common trading volume, it’s in my incentive to be running some sort of node that is automatically like rebalancing my ETH from like different liquidity pools.

Hayden: Yeah. So I mean I talked earlier about how like market makers could get the almost the Robin Hood level experience with a little bit of work on our end, but for people who are more sophisticated who want to make higher profits, they can essentially adjust their rates. So in Uniswap people say it always lags the market. You can’t adjust your spot price, but you really can by making a trade and adding adding liquidity or making a trade and removing liquidity or removing liquidity making a trade and then adding it back in synchronously you just like line up a series of transactions that sort of adjust the rate and your liquidity contributions, so there’s definitely room for a lot more sophisticated market makers and that’s something that we’re sort of very into and we’re experimenting with as well. And also sort of optimizing, you know, ideally you can model the optimal amount of liquidity for an asset based off certain properties such as volatility of the asset and yeah and demand for it.

Brian: So one of the things that seems like a challenging aspect here. Let’s say you have a market where you know, there’s not that much liquidity your liquidity goes down then okay, but maybe I can go and I can lend my ETH somewhere and I make 6% there. But now the trading volume is very low and you know, I’m only making two percent on Uniswap. So I want to take my ETH out and put it somewhere else. But of course that means that now the liquidity is decreased the slippage is higher so it becomes even more unattractive to trade so like there’s this kind of like death spiral seems to be pretty likely to happen often.

Hayden: So that’s what I was worried about when I released Uniswap. It seems to have been the other side of the death spiral. It seems to be a life spiral of like trading drives liquidity drive more trading drive more liquidity drives more trading drives more liquidity, I was worried about that early on and you know, it still is possible, especially if some assets change a huge amount in value. One thing I’ve noticed is that when an asset does go down a lot in value there is also a lot more trading in that moment. Before we get too far into this maybe I should explain a little bit of how the losses in Uniswap work. So profits are just there based off the fee volume, right and every trade that happens affects the the fee profits and every trade is profitable for liquidity providers in one way, and we call it like path dependent. Everything that happens on Uniswap affects your fees Yeah. So basically if an asset goes up in Uniswap very high relative to the other, so you have ETH and MKR, let’s say MKR triples and ETH stays the same, as MKR goes up in value the contract automatically rebalances all the liquidity providers more heavily towards ETH right so it sells on the way up and buys on the way down. So you don’t get all of the benefits of that MKR tripling and so that basically loses you money relative to holding those assets. And so what you need is you need the profits from fees to outweigh losses from this from this auto rebalancing and those numbers are really kind of deterministic. So, you know, if you put an ETH and DAI and the price of ETH doubles relative to DAI. So when you put an ETH and DAI you put in 50 percent value of ETH and fifty percent value of DAI, so maybe it’s you know,a hundred thousand dollars of each, and then if ETH were to double in value, you know, if you were holding your assets outside of Uniswap you would now have a hundred thousand dollars of DAI still because the DAI is the same but you now have two hundred thousand of ETH right? So your total value at the end would be three hundred thousand dollars. But in Uniswap, it would auto rebalance some of your ETH towards DAI as ETH was increasing in price. So if ETH were to double you’d actually have five percent less in value than you would if you held your initial position, and so in order for that to be profitable you need to have made at least 5% in fees during that period of time.

Brian: And on the way down is the same way, right? So basically you’re always worse off, I mean again ignoring the fees if you’re holding kind your liquidity pair then if you just holding like ETH and DAI in this example.

Hayden: Correct, although the numbers at which you’re worse off is not insanely high and it always performs in between the two assets. So you basically get the geometric mean of the returns instead of the arithmetic mean. So normally if one asset goes up 200% in the other asset goes up 100%, then between the two you get 150% returns on the initial value versus in Uniswap you basically get the geometric mean which is always a little bit less than the arithmetic mean. So of a 2X that’s 5% less, off a 3X it’s 13% less off of 50% change its 2% less off a 25% change its 0.5% less, but these numbers are really, you know, they can all be predetermined. You know, if I put me in my assets and they started this price and I take them out and they end at this price you’ll know exactly what that loss is and so if you know what the daily volume will be in that time period you can sort of adjust your risk and you can sort of see whether or not it will be profitable for you.

Sunny: Given that it’s pretty easy to mathematically model what the expected loss would be is there no way we could design a fee mechanism to the market makers that ensures that it overcomes that loss essentially where to make sure that not not not having it be so constant because that’s another thing I see is that like the fact that it’s fixed at 0.3% and you know right now there’s no sort of way for anyone to change that, we had the DX DAO project on the show a couple months ago. And so they actually have this DAO that controls the governance of this Dutch X exchange and the reason that they’re able to do this is so that the DAO can modify parameters of the Dutch X in order to make it be competitive with like market forces and so, you know, they could change the liquidity shares, the fee and whatnot. But if there’s no DAO here in Uniswap to like do this kind of stuff, how do we make sure that Uniswap is able to remain competitive?

Hayden: Yeah. here’s a few options and definitely dynamic fees is an open research topic that we’re heavily looking into. There are all sorts of proposals such as you know, automating the fee-based, you know proportional to the slippage of the transaction. That’s one example, or you know, so we’re looking into it and the other option is basically, you could have a different contract for different fee levels and liquidity providers could just kind of deposit their liquidity and the one that they think is, you know, most likely to be profitable and you know, you would assume that liquidity kind of accumulates in the one that has the highest fees. Part of the issue there is that you might split up your liquidity which gives you worse rates for users if you know something if have the liquidity providers on a pair of put them in one fee level and half put in another but it is something we’re really looking into and ideally, you know governance DAOs are fun and we would love to have it fully automated in a way that can still be profitable and that’s something we’re happily looking into. And then one option is also to have it proportional to volatility because that is one of the most important metrics for losses and for fees.

Sunny: Right. So it seems that there’s essentially three main factors we should be taking into account, one is volume which is what it currently is doing. The other is spread which is kind of what most market makers on order book basic changes that’s where their primary profit comes from is off the spread and then the third is the volatility and that’s important to take into account because like we said based off of how the losses in Uniswap work, that is what we need to offset. So kind of dealing with those three aspects.

Hayden: Yeah, I mean, funny enough the 0.3% was a YOLO from a conversation with me and Vitalik about like what might be the most optimal fee and the way the way we chose it was basically to be competitive with other DEX’s and sort of not having it too low not having it too high and it’s actually working for a lot of markets which is pretty cool. So the MKR pair for example has been fairly profitable. The DAI pair has been fairly profitable for liquidity providers and it is working pretty well with the YOLO fee amount and so now we’re putting a lot more time. We have a lot more data to work with because these are this exchange has been running for a while. It’s done, you know close to 200 million dollars in trading since November. There;’s 20 million dollars locked up and so we’re able to look a little bit closer and maybe see how different fee levels would have performed. So you have different types of dynamic fees might have performed and kind of model it a little bit better and it is very likely we’re going to propose a Version Two of the protocol that adds in some new features. Version One of Uniswap is very good, but I don’t think it’s like the best it can be.

Sunny: And then one more thing that might you know, I’d be personally interested in a Version Two would be more complex bonding curves, right? Because currently I think you know x times y equals k seems to be highly simplistic and it’s asymptotical on both ends and you know, is there any reason why it couldn’t be closer to flat or like, you know, even have constants so it skews it somewhat and so is that something, one what is the benefit of that x times y equals k. Is there some special properties about this equation that makes it useful.

Hayden: Yeah. So the special property about the equation is that it always keeps a 50-50 value of both assets and there are other equations that might work but it also minimizes slippage or at least that’s what the sort of current belief is. Is that we haven’t found any other curves that would allow you to have, like if the curve moves kind of steeper in some places and more shallow and other places then you’re going to have more slippage on those places and so in Uniswap because it’s kind of an even curve, no matter where you are in the in the in the market you’re going to have kind of the least slippage possible while maintaining a 50-50 value of each.

Brian: Now one one topic that we should bring up here briefly which is of course always a topic for decentralized exchanges is the topic front running for example, like a miner can see okay, you’re putting in a big order. there’s going to be some sort of slippage and then they can try to exploit that in some way. Maybe they can like reorder the transactions and put one of theirs in first or you know, maybe do some other things. So is this front running a concern, have you seen any evidence of people actually doing front running and you know, what’s kind of your thoughts in general.

Hayden: There’s definitely front running. If you go to frontrun.me and either / revenue or profit, there you basically can see a list of all front running transactions on Ethereum it’s a really interesting research. But yeah, so there’s definitely front running very active on all Ethereum DEX’s and no front running is unlikely except for maybe unless it has some sort of centralized component to it, which is preventing it, I guess Airswap is fairly front running resistant and I guess Dutch X is fairly front running resistant. But so on Uniswap the current parameters that are sort of preventing some level of front running is there’s a minimum slippage parameter that you can set when you make a trade so the type of front-running that’s really scary for users is you know, I’m selling one ETH then the front-runner sees this transaction coming in they put in a transaction ahead of it that pushes the price gives me a worse rate. And so I make a trade at the worse rate and then they trade back against my trade and they take some profits and the the most baked in mechanism is, there’s a few baked in mechanisms, one is just the fees on the transactions, so if you do a large trade in both directions on Uniswap that really pushes the right a significant amount in a larger liquidity pool, you might actually have to pay a pretty large fee to liquidity providers for that. But you can still find trades where it’s guaranteed profit for the front-runner. So that’s not really that big a mitigation. But the main slippage value is basically now I’m selling one ETH and the current price is 200 DAI and if I get any less than 199.7 DAI I want the transaction to fail and so, you know, you don’t know someone can push the price ahead of you but only up to the amount that you’ve allowed in your transaction. So that’s the main mitigation in Uniswap. The balance that you’re trying to find is essentially if you make it too tight, you know, if you say even a 0.0001% slippage will make my transaction fail. Then transactions could fail from normal trading volume, which you don’t really want to happen it’s kind of bad UX to have all your transactions failing. So you want to make some allowance but not so much that it’s extremely profitable for front runners. Another sort of mitigation is these deadlines parameters, which is basically, you know, this transaction can only execute within this time frame and so it prevents miners from holding transactions and executing them at a time where it’s more profitable for the miner. It prevents it from holding them for too long, you know, if you set it to 5 minutes and the miner only has a five minute window where they can execute your trade at a better time for them and worse for you. Now, we’re looking into some very cool stuff which can help reduce front running or to some extent socialize it, it’s it’s kind of interesting mechanism where we call it Trader DAO, but it doesn’t need to be a DAO. Essentially what it is is a pool of liquidity that grants a specific party first arbitrage rights on Uniswap in exchange for rebating some of their arbitrage profits to the trader. It’s kind of an interesting mechanism. But basically the way it works is I want to make a sale on Uniswap. Do you know how Kyber works? Kyber basically, it’s unlike Uniswap which automates the spread, they have, you know, market makers that are posting prices and then they have a spread so they have  their own like price oracle stuff each on chain reserve for a token and then it creates a spread around that price and so they’ll always buy it one price and sell at one price and so you could have a similar contract that fits in between traders and Uniswap contracts and if I want to sell let’s say I want to sell a million dollars on Uniswap, if I’m selling it into a pool which only has two million dollars in it I’m gonna get 50% slippage on my transaction that’s pretty awful and the person who profits off that 50% slippage is not the liquidity provider as you might expect, the person who profits off that slippage is the first arbitrageur to shift that rate to make the trade in the reverse direction to shift that right back to the to the real rate. They make all the profits from that except for the 0.3% fee profit. And so instead you could have a liquidity pool that maintains a sort of privately managed liquidity pool. This maintaining its own sort of price feed that has a large liquidity reserve in it. And then I want to make my trade on you as well by say I want to sell this million dollars on Uniswap. You can either do one of two things you can forward this trade on to Uniswap and it will execute like normal. You can’t make the transaction fail. You can forward it to Uniswap or you can execute this trade on Uniswap and then synchronously execute the arbitrage back and then you know if if this shift the right 50% you can shift the rate back from 50 to 45 and then I’ll only have 5% slippage and then the person who pushes the price back, the trader dao basically could take profits on shifting the rest of the way so the 5% to the 0%. So that basically is an interesting way of giving better execution to users and reducing slippage for large trades. Does that kinda make sense?

Brian: I think that does make sense in a high level. Now, I would love to speak a little bit about decentralized exchanges in general. So, you know we’ve kind of talked about how Uniswap works but what do you think are some of the unique things and use cases where you think that you know, maybe decentralized exchanges or Uniswap in particular really have like an advantage versus centralized exchanges.

Hayden: Yeah. I mean, there are all sorts of problems with these with centralized exchanges, you know Mt Gox, that’s the one people point to but like you can look two weeks ago to Binance losing 50 million dollars of Bitcoin. So the biggest problem with centralized exchange is probably security, but then they also, you know, they can shut down your account. I used to have a Bittrex account and you know, they removed all trading in New York. They deactivated my account this week so I can no longer use Bittrex, and if I didn’t withdraw funds in time, then I would have lost them all never been able to withdraw. Another example is someone once sent me some ZRX tokens, they asked me for my Coinbase address to give me some ETH and I didn’t realize that they sent we’re sending me ZRX tokens, which you can send to in an Ethereum address on Coinbase, but because I was in New York, you know, I was actually not allowed to withdraw them and so they’re just permanently locked in Coinbase the ZRX token, because I thought I was getting paid in Eth. So that’s like another example of centralized exchanges not being so great. So there’s all sorts of security issues. There’s all sorts of issues with censorship and things getting shut down. They’re also they’re also charging really high fees, Coinbase if I want to buy some ETH there’s like a 1% fee or something crazy, but you know, I guess in which Uniswap tries to lower to 2.3%. Yeah. Were you mostly asking about decentralized versus centralized or decentralized with other decentralized.

Brian: Yeah. No I think that was good. I mean one of the things that I would encourage our listeners to watch is this great talk by Arthur Hayes and he’s the CEO or one of the founders of this exchange called BitMEX and this is I think the largest volume kind of trading platform with gigantic volumes and it’s interesting because it’s to talk about decentralized exchanges. And of course, he runs a centralized exchange, but then you know, he basically says ok, what are the people kind of proposing that are building decentralized exchanges and you know do people actually care about it. And he makes this argument that okay, but people care about you know, number one is liquidity, number two is leverage and those are the two most important things and then he says three, ease of use and then your security is nice to have but people don’t care about it that much and it was pretty interesting because it kind of brings up the question your to what extent you know, are these things that we’re kind of building out of this idealism and may be coming to crypto with this idea okay, people should own their own assets and control the keys and stuff like that versus things that people actually truly demand and want and value.

Hayden: Yeah, I mean, I think that’s kind of yes, not to insult Arthur Hayes. But I think that it’s true to some extent. I think that you know, there are things people care about and there are things people don’t really care about but if we don’t care about decentralization and we don’t care about censorship resistance and we don’t care about being non-custodial then why have blockchains like what a what are any of us doing here, right? None of it matters if we don’t care about these things, like I also think that like hand-waving security is a little bit weird and I think that security is one of the biggest properties of decentralized exchanges that matter, reducing you know, single points of failure. I agree that you can get a lot of volume in a centralized exchange. I think a lot of people who are speculating don’t care but I think that a lot of people who are building decentralized projects on Ethereum  do care about decentralization and I think Uniswap’s kind of success so far has been evidence of that. You can see sort of some examples to kind of continue some of the kind of benefits, I didn’t really even get through my complaints on centralized exchanges I just forgot some of them in the moment, which is for example token listing, like if I want to list my token on an exchange what do I have to do? Sometimes I have to pay $20,000 sometimes have to pay $50,000. I can’t do it and if you sort of envisage a world with a lot of tokens that sort of our each fill different use cases, you know, maybe you have personal tokens maybe have communal tokens, not everyone wants to like sort of pay the entry fee and one thing you could do with Uniswap is basically anyone can create the exchange for their own token and anyone can trade it anyone can pool liquidity and there have been some like really cool examples of this in Uniswap so far. So the one cool one for example with the Reddit karma donuts or basically someone created a a on-ramp for Reddit Karma, basically Reddit introduced a feature that allowed you to track Karma on a per subreddit basis and actually transferred around and use it in polls. And so they created a governance system on on the ETH trader subreddit and they allowed people to sort of use their Reddit karma and then someone created a bridge that allowed you to turn that into an ERC- 20 token on Ethereum and someone pinged me one day and was like by the way people are trading Reddit Karma on Uniswap and I was like wait what? I created Uniswap. I made the smart contract to make the front end but I didn’t know about this and then you know, I look through the contracts and within three days of someone creating this Reddit ERC-20 bridge people traded $30,000 worth of Reddit Karma on Uniswap which you know allowed them to vote in governance polls. And then the guy operating the bridge kind of freaked out and shut it down but you know, ideally the the social media platform would have a more decentralized component that wouldn’t allow anyone to shut it down. Yeah, so and another example would be like, you know for real tokens like spank or MKR that have not traditionally the team’s behind them have really been adamant on not paying listing fees and not like, you know, they’ve been really hard to buy MKR for most exchanges. But because of the permissionless nature of Uniswap it now has six million dollars in the ETH to MKR pool and has basically become the largest exchange for MKR and similarly it’s the largest exchange for spank tokens, which you know, also they don’t want to pay the pay any exchanges to list their token and it’s also one of the larger exchange for FOAM, which is another project that sort of follows these values. So I think that the permission listing allowing anyone to deploy their own exchange stuff like this is a big deal.

Sunny: I mean I totally agree with that. I think like one of the places where decentralized exchanges really shine over the centralized ones is in this listing of exotic assets like you mentioned and for example, let’s say someone had created a staking derivative of bonded atoms to the course one validator right, like which exchange is going to go list that on, you know, you’re not going to get BitMEX to go list that and provide all those features but anyone can then go ahead and take that staking derivative and create a Uniswap contract on it and I think given that that’s where you know, I think out of where Uniswap really shines is that it provides some level of usability to even very low liquidity assets and because of this I think it works well where like you can have this like, you know it I think it’s probably why we’ve seen Uniswap grow to be the largest decentralized exchange so far is because it really hit that product market figure where it is the one that’s best for dealing with exotic assets, which is what people are actually using decentralized exchanges for.

Hayden: Yeah. No, I agree with that. It’s also there’s also a UX component to it and a kind of integrations component to it so Uniswap is incredibly simple. It’s accessible fully on-chain, you can integrate it into your project very easily. You can bootstrap your own liquidity really easily. It’s you know, highly programmable. I guess one thing that we kind of didn’t talk about which I sort of I think I saw in some of the notes was the aspect of liquidity tokens and this actually plays into the leverage that Arthur Hays was talking about which is basically if you’re a liquidity provider on Uniswap you could lock up some ETH and some DAI and actually while your tokens are locked up. So you have the ability to withdraw your proportional share at any moment, but you also get in the ERC-20 token that represents your right to withdraw that share and so you basically burn this token to withdraw your liquidity, but you can also transfer it around and it can also be used in other contracts. So an example usage could be that you you lock up your your liquidity in Uniswap, you get your liquidity shares, you collateralize and so you now have a position on both assets in Uniswap, you know, maybe ETH and MKR and you’re also generating fees on Uniswap and then you could actually take out a loan against these liquidity tokens. You could open up a CDP and multicolateral DAI or you could take a loan out against these assets trustlessly and then you could increase your leverage, maybe you could collateralize your liquidity shares and take out enough ETH to become a validator or maybe in proof of stake when that exists and maybe you can take out some ETH and swap half of it for DAI and you put that back into the liquidity pool. Now you’ve leveraged up on Uniswap fees.

Sunny: Has anyone created a Uniswap Market against liquidity pool liquidity tokens.

Hayden: Yeah, someone did create a Uniswap liquidity pool for ETH to DAI shares on Uniswap, which is kind of funny. It’s you know, it kind of worked it kind of makes sense. There’s not much liquidity in it right now but it could be kind of a cool way to like on ramp onto Uniswap really easily. If you want to become a liquidity provider you could just send some ETH to this contract and you’ll immediately be a liquidity provider. Another kind of interesting thing that happened is I think Compound sort of saw this this model that we created for Uniswap where you have shares that represent your portion of the pool and they’ve kind of added this thing they call C tokens or compound tokens, which are basically if you lend your DAI on Compound you get something called cDAI which represents your ability to withdraw the DAI that you lent on compound plus any interest generated and so you can do the same thing in reverse, you can lend your DAI on Compound and then take out the cDAI and then you can lock those in a Uniswap pool against ETH . And actually now you can immediately go from owning an ETH position to owning an interest generating DAI position and a single swap on Uniswap. This is actually happening and allows you to increase your leveraging once again, and this actually already happened, you know, once again without me doing anything, without me saying anything because it’s decentralized, Compound or some people affiliated or just some random person took, you know, $150,000 worth of Compound DAI and put it in a Uniswap pool. So now you can swap between Ether and Compound DAI or Compound DAI and other ERC-20 token through Uniswap in a single transaction.

Brian: I totally agree. I think that’s probably the most powerful thing about decentralized exchange is this aspect of like okay, you can easily integrate it and innovate on top. So let’s speak about business model, right because Uniswap doesn’t, you know many tokens like you mentioned or omit many projects you mentioned for example Bancor is an example which is similar, but then they put in the Bancor token and of course the Bancor token did an ICO and they own part of it and if it succeeds it will be worth a lot of money and you know kind of traditional way of monetizing crypto project and now you haven’t gone down that way, there is no direct way that Uniswap is monetizing. You did raise a seed round recently. Congratulations on that. And so you have a company now, what’s the business model of that company.

Hayden: To jump back I think ultimately there was this ICO boom, and everyone was selling a token, but I think it became clear to a lot of people that it didn’t make sense, a lot of these tokens didn’t make sense and I’m not going to point fingers but I think that the projects that are going to be successful in crypto are projects that build the best version that they can, not a version that’s easiest to monetize and that was sort of the idea going into Uniswap. That said, you know, it’s a very legitimate question you how how do you how do you make money on a public good, because I know Uniswap is essentially a public good and I will say that I raised money on the idea that there’s value to the brand and the reputation that I’m creating and there’s value to being at the center of DeFi and to being at the center of this like decentralized exchange thing and this decentralized financial system. We are still deciding, you know, we have a lot of cool things we want to build like a lot a lot a lot of cool things we want to build on top of Uniwap and we think some of them can have cool business models to them. I’m not ready to kind of like immediately just start listing things off, but I will say it’s more about you know, like it’s not that crazy to have companies that aren’t immediately generating revenue that are valuable, right, you know a lot of projects in Silicon Valley right now are still not profitable and worth, you know, fifty billion dollars or something, right? I don’t even know if Uber makes money yet. Long story short, we’ll see. But we have some really cool things we want to build but you know still I don’t want to go too far down the path of exactly what it is until we’ve more clearly decided on the exact route.

Brian: Did you ever consider integrating a token in there or like was it clear to you kind of from the start that it didn’t really make sense.

Hayden: I’m not against tokens. I’m not even against integrating tokens into Uniswap. Breaking news. I am against doing things for no reason. If it becomes clear that for Uniswap to make sense we need an actual group of people modifying parameters, then maybe we need a token to to control that but I’m not kind of letting the cart lead the horse on introducing unnecessary features, introducing a token before we before it’s very clear that it’s necessary. So yes, there are potential, you know DAO mechanisms that can make sense or maybe build a contract that adds some service or build some cool thing on top of you to swap that it takes out a little fee and it’s not built into the core protocol. I don’t think that everything needs to be built into the core protocol. Something that I’m still sort of thinking through but something that I’ve been thinking about a lot recently is that the Silicon Valley model for companies has been like someone creates something, they own a percentage of it forever for all eternity. And I don’t know how much that makes sense. I think what if Mark Zuckerberg created Facebook and Facebook owed him ten billion dollars. And then after he got paid ten billion dollars like screw Mark Zuckerberg, he doesn’t need any more money for what he did building Facebook initially. So I’ve sort of been thinking about this idea of protocols owing their creators something but not something forever.

Brian: The he would be very poor.

Hayden: How awful would it be if he only had ten billion dollars and not you know, 50% of Facebook for all eternity. Yeah. So it’s something I’ve been thinking about, I think there is a really interesting trade-off between like profitable projects and optimal project in the crypto space and it’s kind of interesting but ideally, you know, you can strike a balance, and I’m not like personally too worried. We have a pretty decent runway to work with from our seed round and we have a lot of cool ideas.

Sunny: Yeah, I mean that’s why I think things like the Z cash founders reward and stuff are also like interesting ideas. And so really quickly, going back to exotic assets and your revenue model, I think one of the most exotic assets I’ve heard about being traded on Uniswap is these tokenized socks. Could you tell us a little bit about these?

Hayden: Yeah. This is the project I really just wanted to do for an incredibly long time. It kind of came out of so I’m wearing one of these Uniswap shirts which were sort of cool. And so people kept telling me Oh, you should create a liquidity pool for your uniform shirts and you know people I’ve been sort of thinking about what it means to kind of combine these digital assets with these physical assets and so sort of a high overview of what Unisocks is is we created a token SOCKS, that’s the ticker and the name is Unisocks Edition one and the idea is simple you create these socks a limited scarce supply. So we created 500 SOCKS tokens and then we lock them in a liquidity pool with some ETH and so that sets this initial bonding curve where you can send ETH to the contract and you get SOCKS out or you could send SOCKS to the contract and you get ETH out, but because we put the total supply of all SOCKS from the very beginning and no more can be created directly into the liquidity pool with ETH that kind of starts you all the way at the bottom of the curve. So every pair of socks you buy kind of increases the cost of the next one, but at any point in time, you can sell back into the market. So if you buy 10 SOCKS and someone else buys 10 SOCKS, then the first person can sell them back and actually make some profit and so it’s kind of a funny thing but what will happen is that you know, every sock token will be redeemable, so there’s 500 SOCK tokens and you can burn a SOCK token and it will be redeemable and basically send your address and we’ll mail you a pair of socks, limited edition high quality socks with a cool design on it anywhere in the world basically. Well almost anywhere in the world. There was a tax created on Unisocks the other day and it was pointed out that two things we couldn’t send is sanctioned countries. So that would be an attack if you burned a sock token and say send it to this address in a sanctioned country obviously we’re not going to do that. The other attack would be ordering a few pairs of socks to an address, getting out a restraining order for some weird person sending you socks and then ordering more socks. But anyway, that’s kind of going way down a rabbit hole. The point is that obviously we’ll only send it to a reasonable location. But yeah, so every SOCKS token can be burned and will be redeemable for a real pair of socks mailed directly to your address and it’s an experiment with UX in buying stuff on through crypto. It’s an experiment in price discovery for rare merchandise. So an interesting thing is that if Nike releases a rare pair of sneakers or something, there’s a limited supply and they sell them at a flat rate. At say $200 or $300 each but then there’s this whole secondary market that’s created around it where people buy them for $300 and they resell them for $2000 or you know, the first people to buy them can sell them a lot more and strangely, Nike doesn’t really directly benefit and the creators and the designers of the shoe don’t directly benefit from the socks going to $3,000 dollars versus $300 unless they maybe keep a few pairs for themselves or something like that. So the idea with this is that you put it on this bonding curve and then the price of the asset will just automatically go to whatever the value is whatever people are willing to buy for it. And the company who created it, the designers behind it they can kind of directly profit from the secondary market, there’s no need for secondary market because it’s built into the primary market.

Brian: So that is your business model.

Hayden: It’s not our business model directly. But it’s an experiment. I mean, we didn’t do it for no reason. We technically sold $10,000 worth of socks in two days back and funny enough, you know, we sold $10,000 of stocks, but people are trading them back and forth now and there’s been probably like $50,000 worth of stocks trading not stocks trading, stocks trading in the past few weeks, which is pretty funny.

Brian: Cool. Thanks so much for coming on, it was really interesting to hear about Uniswap and you plans I think lots and lots of exciting things here and we’re really excited to see what’s going to come out of it with all these improvements and different plans and iterations on it. So, yeah. Thanks so much for coming on.

Hayden: Yeah. Thanks for having me.


  • Microsoft Azure

    Deploy enterprise-ready consortium blockchain networks that scale in just a few clicks. More at aka.ms/epicenter.
  • Trail of Bits

    Trust the team at the forefront of blockchain security research. Learn more at TrailofBits.com.

0:00:00 | -:--:--

Subcribe to the podcast

New episodes every Tuesday