Bringing Cryptocurrencies to Life: Uniswap

By Niklas Spille-Scheich | Cryptonic | 24 Mar 2019

"Use this magical internet money of ours", they said, "you can use it in every place you visit in this world" (as long as it provides internet access). That's a great vision of what Cryptocurrencies might achieve in real life one day.

Cryptocurrencies introduced an issue they may eventually solve back to the internet, though: "What Crypto am I going to use today?". SpankChain resolved this for the merchant side by creating a simple interface swapping cryptocurrencies from different blockchains to a dollar-pegged Ethereum token.

Adding a piece to the puzzle, I will shed a light Uniswap today: enabling users to easily swap Ethereum-based tokens amongst each other.



Now that's an exchange for simple-minded people like me (and solid enough for the Ethereum foundation to hand out a grant); I'm quite sure you understand what's happening here even with the german locale displayed for me. Connect MetaMask, select what token you wish to swap to whatever token, enter Input or Output, hit the "Swap" button. Done.

Further simplification can be achieved by specialized API calls, a merchant may pre-load his favorite token to the output side of things, the user will only need to select which token he'd like to pay with: This brings us to the next front-end level, Uniswap allows for Swap&Send in one transaction. Add a layer of ENS for even more simply validating you're sending your Crypto to the right address.


How does this magical thing work?

Uniswap provides a collection of ETH<->ERC20 exchange contracts, one contract for each token listed (seen the image above? It's just as easy to add your token to the Uniswap pool). This is handled by a factory contract which serves as public registry of contracts available to the Uniswap pool.

Each exchange contract is filled with ETH and its associated ERC20 token by Liquidity Providers contributing to the liquidity pool. This works a little different than Buying/Selling on other exchanges, each individual user's contribution is tracked by a proportional share of pool tokens which can be burned to withdraw liquidity.

Using a "constant product market making formula", verified and audited, Uniswap automatically adjusts the rate offered by the amount an incoming trade will affect the liquidity pool. Taking a small liquidity provider fee (0.3%) out of each trade, which is added to the overall reserve, the pool size increases with every transaction processed. Want to swap one ERC20 token for another? Here you go, the individual exchange contracts will use ETH as intermediary to find the rate to offer for your BNTY-BAT trade.

Adding features on this, Uniswap supports custom pool contracts interacting with the public exchange contracts. These external contracts may integrate whatever function you may want to provide: fund management, alternate pricing mechanisms, removed liquidity provider fees, complex interdimensional FOMO-based ponzi schemes - if it can be displayed in contract code, you can do it.

Heads Up: Custom pool contracts are not subject to Uniswap's verified and audited open-source safety mechanisms. Participate in ponzi schemes at your own risk.

You want to dive into the technical side? Have a look at the Uniswap documentation on GitHub ;)

How does pooling work?

The first provider of liquidity sets the initial exchange rate by depositing what they consider equivalent value amounts of ETH and their ERC20 token, all liquidity added later on will use the current exchange rate. Whenever the ETH<->ERC20 ratio is off, this is will be handled by arbitrage traders at the expense of the initial liquidity provider. All future liquidity provided uses Uniswap's automatically provided exchange rate. Simple as that.

Opportunities & Conclusion

If this exchange rate is bad, there is an arbitrage opportunity that will lead to a net gain for the person doing a trade to bring the exchange rate to an equilibrium.

Mind you, simple-minded people like me, simply adding to the liquidity pool makes you participate in every deal, no matter if the trader nets a gain or loss. No matter if other people got scammed by a "make $500 by midnight"-scheme. Proportional to your share of liquidity provided to a specific ERC20 pool, you get pool tokens to remove liquidity in both ETH and ERC20 as you wish; if you think the rate you will receive is bad there's an opportunity to do an arbitrage trade before removing your liquidity from the pool. While your liquidity is provided to the pool, you won't be able to spend either ETH or ERC20 tokens and you won't be able to trade it.

Using the powers of well-written APIs, it may become feasible to create easy-to-use interfaces for using whatever Cryptocurrency you've got at hand to pay for someone's services who will have just as little hassle converting things back to his favorite Crypto. Thinking that's you or someone you know? There's a great opportunity being amongst people creating this easy-to-use interface. Thinking more complex, it is possible to add liquidity to the pool while you're not using it and automate the removal of liquidity from the pool the moment you hit a merchant's "Buy" button.

These are things to come but providing the simple way of swapping token-to-token and coins-between-blockchains in combination with fiat on- and off-ramps is much needed to bring cryptocurrencies to the masses while fostering diversity apart from a few tech giants dominating the space with their one-and-only blockchain technology. I'm not keen on wasting my time figuring out which route to take through a variety of exchanges when I want to spend the tips I've earned here (yes, Publish0x does pay out and this amounts to some 1,500 US-Dollars worth of tips at the time of writing this article). Two clicks are fine to get a payment process done to avoid accidental payments to be initiated, just keep it simple :)

How do you rate this article?



Niklas Spille-Scheich
Niklas Spille-Scheich Verified Member

Mined some Bitcoin for fun in 2011 and hit format c: before giving that laptop away. Got triple copies of my seed words placed all over the world. Unite 3 of my closest friends to recover access to my crypto assets.


I am way too busy to feed a blog with clickbait so you'll find some general advice on here. Don't forget to Do Your Own Research!

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.