Some of you are doing stupid shit on Uniswap because you don't understand how it works. So here's an intro highlighting some gotchas while trading on there, or while providing liquidity to Uniswap pools:
Let's look at the USDC/WETH pool as an example, a large one with almost 20M liquidity. WETH is just ERC20-wrapped ETH, you can think of it as ETH for now. Screenshot from https://pools.fyi/ .
If you go to that pool on Uniswap and want to swap one ETH for USDC, you get a price very close to the current price of ETH, 387$. at 100 ETH, you're down to 381$ per ETH, and at 1000 ETH, to 368$.
Now it gets crazy, the pool will also quote you a price for 10,000 ETH: 276$/ETH, and even for a million ETH: 9.7$/ETH (2016 remembers). In fact, it never stops. A billion ETH? NP, you just won't get that good of a price.
Remember: this is a large pool. You'll experience the same with smaller pools using way less money. This phenomenon is called "slippage": the difference between the expected price of a trade and the price at which the trade is executed. But what happens in the background?
Uniswap doesn't have an orderbook, it quotes your price based on simple inputs: the size of the pool you trade against, the distribution of coins in it, and the size and direction of your order. This is a flavor of an Automated Market Maker (AMM).
When quoting a price, Uniswap makes sure that, if you should take the trade, the value distribution of the coins in the pool will always remain 50/50 (so roughly 10M worth of ETH in the above example, and 10M worth of USDC, for a total of 20M, the pool size).
Each time you sell a bit of ETH into the pool (and take out USDC), you tip the balance in favor of USDC (and often, somebody else then comes and does the opposite). If you sell a lot relative to the pool size, slippage will punish you for trying to move the pool too much.
So, slippage, especially against smaller pools, is the first gotcha when trading on Uniswap. Always pay attention to it. It's displayed in the interface and you can set a hard limit in the settings.
Uniswap's AMM determines prices without any connection to the external world. It doesn't use an oracle or look up the price of ETH on Binance. Why does it still work? Free market actors make sure that the prices on Uniswap don't go out of whack by watching any sizable pool:
If you'd be stupid enough to take the above trade and sell a million ETH into the ETH/USDC pool, the ETH price offered by that pool would go down to 9.7$. Somebody's bot would spot this difference relative, to, say, Binance, gobble up cheap ETH, and tip the pool back to normal.
There's a second, smaller gotcha in there: New, or tiny pools maybe don't have bots watching them. So they can go WAY out of whack while people fomo in or out of a coin. Always compare prices.
As long as you pay attention to prices and slippage, and make sure to trade the coins you want to trade, Uniswap offers a pleasant and safe experience. Things get a bit more complicated if you want to provide liquidity to Uniswap pools to farm some of that sweet yield.
Uniswap quotes prices without taking into account outside market information. This sounds pretty stupid, right? It actually is, and in theory this approach shouldn't even work. Yet it normally does.
Imagine that China tries something different and bans Ethereum for once. So there would be a real reason for the price of ETH to tank, and it would immediately do so on, say, Binance. Meanwhile, the above Uniswap pool would merrily continue offering good prices for ETH, until...
... the price difference got arbed out by somebody's bot. This event would cause our ETH/USDC pool to make some pretty stupid trades. The effect would be a loss for the pool, called an "impermanent" loss on Uniswap. The loss is called impermanent, because...
... normally, such events even out over time, and because normally, in the situation we're in, the trading fees and people accepting too much slippage on their trades make up for any losses paid to more attentive market actors and their bots.
Still, impermanent loss on Uniswap pools can become permanent, e.g. because a project constantly produces hard to foresee news, or in some cases that are way worse:
Imagine that you staked some coins in a pool for ETH/SOMESHITTOKEN (SHT). Now, the dev of SHT decides to mint an infinite amount of new tokens and dump them into your pool. ...
The pool, trying to preserve that 50/50 ratio, will over time end up with an enormous amount of SHT, and very little ETH. So by staking in a pool, you always risk the full amount of your stake, not only the amount that you are holding in SHT.
In fact, you can think of your stake in an Uniswap pool as some kind of fund that always rebalances to 50/50 in value of the pool's components. If one of the components goes to 0, you'll loose the value of the other too.
When staking on Uniswap V2, you'll receive a token in return that represents the size of your stake. Some projects, like YAM (rip), allow you to stake this staking token, or you could also simply send it to a friend. But remember...
... that this token is actually the key to your stake. If it gets stuck in another smart contract, or somebody steals it from you, you won't be able to remove the funds that you put in the corresponding pool.
We learned that AMMs are dumb, but still work because other market actors are even dumber. Now, there's a type of AMM that is more intelligent than any other possible type of market making:
If you can be sure that the two tokens in a pool will never experience substantial outside price events, AMMs are the most efficient way to price a swap on a blockchain. Fast, lean, and cheap. Enter Curve.
Curve offers trades between coins that should normally have the same value, e.g. USDC/USDT. So it can make stronger assumptions regarding correct pricing. In essence, it can "flatten the curve" around the expected 1:1 exchange price.
Unless one of the coins on Curve goes defunct, this leaves Curve with trading fees, little to no impermanent loss (remember, no outside events), and the ability to offer much more favorable exchange rates compared to Uniswap. Hence its wild success for 1:1 swaps.
Balancer tries something different: it offers pools with more than just two tokens and will draw a curve that works just like on Uniswap, but keeping a predefined value ratio for all coins in a pool. Maybe I'll find time to do Balancer justice some other time.
You can follow @cryptic_monk.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: