Uniswap: an easier way to trade ERC-20 tokens

Our DeFi Guy explains how he used the smart contract interface for swapping ERC20 tokens to buy a tiny fraction of a collectible T-shirt. Crazy!

5 min read
Uniswap makes it easy-ish to exchange ERC-20 tokens

As one journeys through the wonderment that is DeFi, it doesn’t take long before you inevitably stumble across Uniswap. While it’s super simple to use, it always felt like one of those things that you conceptually understand, but can’t quite figure it out, like:

You, an idiot: Uniswap is like a decentralized exchange (DEX)

Me, an intellectual: Really, it’s a bit more like a decentralized market maker

Vitalik  Buterin: It’s a public good.

Still fuzzy?

What it is

DEX's allow traders to submit orders to trade, against other traders doing the same thing. The standard method of doing this is called a “central limit order book.” This ranks orders to buy (bids) by price, with the highest at the top. On the other side of the book are the orders to sell (asks), again ranked by price, but this time we’re interested in the lowest price. Here’s what it looks like at Binance for Ethereum and Bitcoin:


While Binance is a centralized exchange, DEXs essentially offer the same feature. This means that traders can submit and cancel orders, and change the price and amount they wish to buy and/or sell.

Uniswap is completely different. Rather than setting the price you want to buy or sell at, you contribute, or “pool” an amount of both ETH and a token which you are willing to either buy or sell. The market works out the price and you. In theory this helps the market stay more liquid. Why would one do that? Because whenever someone trades, those contributing to the pool get paid fees.

Outside of this, Uniswap offers another cool benefit, you can swap between any pair of tokens you want rather than trading in and out of ETH, which Uniswap handles on the backend. That means that rather than needing to believe that ETH is money, I can buy or sell whichever token that is listed on Uniswap against any other token.

How it works

In our usual style, we saunter over to Uniswap’s friendly, and incredibly pink, home on the interwebs.


And while it has documentation, frankly it’s more confusing that just throwing money at the service, so I do what I don’t recommend that you ever do, and just go for it!

First thing that I’ll do while I’m here is to add some liquidity, rather than just trading. To do that, I pool some Ether (ETH), and some Basic Attention Token (BAT), which I had floating around from a previous failed attempt to create BAT-backed DAI on MakerDAO. After doing that other traders can then either sell ETH to me to withdraw the token, or sell the token to me to withdraw ETH.

I cue up about 14.7 BAT, which works out to be 0.0192 ETH, somehow, and hit the big… pink… button.


As you notice, unlike an exchange I didn’t get to tell it how much I was willing to trade at, Uniswap uses a mathematical function based on the amount of assets (ETH + token) in each individual pool. Look we’re not going to get into it.

Wait? So I put my money in, but get no say over how it is spent, sounds like taxes.... Now you see why we call it a public good.

Now don’t get me wrong, there are benefits too, whenever someone swaps BAT for ETH, or vice versa, they pay a 0.30% fee. This fee is then distributed to the pool contributors based on their share of the pool by the amount of ETH they put in. My contribution worked out to be 0.0007%, which is unlikely to make me rich quite yet.

Well, I guess that I should probably wander around and see if there are any worthwhile trades to make. While I could trade literally any other listed ERC20 token pairs (plus ETH), for example ETH for DAI, or SNX for  MKR, that would be way too pedestrian for us.

I heard about a project selling overpriced shirts on Uniswap, so I look that up, and since I’ve still got some BAT left over I definitely want to be amongst the first people in the world to buy a (fraction of a) shirt with BAT.


That’s an expensive t-shirt. Oh well. One click, and another el-cheapo transaction is off to the Ethereum blockchain.

Few minutes later and that’s gone through. Now it’s  time to figure out what it is that I bought.


The website tells us that I am now the owner of 0.000203725816753208% of a shirt that apparently captures “a somewhat incoherent explosion of weird internet things” that powers Saint Fame.

I’ll be honest, I have no idea what that means either, but apparently people will need a whole token to buy one of these things. So simply by holding this minute fraction of a voucher for a shirt, I am depriving someone of this oddity. And I ain’t selling for anything less than 10x! (which probably won’t happen)

So in conclusion, you know who to reach out to if you want to complete the purchase of a t-shirt, and also Uniswap is super easy to use to trade more standard tokens. There’s also some features that make it potentially interesting to people looking to provide liquidity to pools, which may or may not make sense depending on their risk appetite. Bottom line though: don’t call it a DEX, or a private good...

[Note: This piece is intended to be a review and explainer of Uniswap. It is neither an endorsement of it or any other services mentioned in the story, nor is it meant to be financial advice.]

Want to be a crypto expert? Get the best of Decrypt straight to your inbox.

Get the biggest crypto news stories + weekly roundups and more!