
Uniswap, decentralized exchange of assets
A technical introduction in Automated Market Makers
Uniswap is an interesting decentralized application that appears to have found a product-market fit in the blockchain ecosystem. In a decentralized marketplace of goods and services, you need efficient ways of swapping assets in a decentralized way. Not being able to, creates friction, as users need to go back and forth to centralized entities, while at the same time diminishing one of the core properties of the blockchain of having no counterparty risk and decentralization in the process.
Benefits
Centralized exchanges can get hacked, expect unexpected losses, collect huge chunks of personal data, freeze user assets, potentially trade against their customers, get into legal issues as they are at the mercy of the authorities of where they operate, sell the user data or surveil customers in other manners.
Essentially, Uniswap allows users that have a wallet loaded with tokenized crypto assets to exchange these other crypto assets, fully on-chain, through the use of smart contracts. Uniswap is currently active on Ethereum, Polygon, Arbitrum and Optimism, indicating a clear focus on the Ethereum blockchain and its Layer-2 solutions.The contracts aim to eliminate rent-seeking middlemen and allow for decentralized, efficient, reliable, and predictable execution of orders.
No order books
A challenge for a decentralized trade is that in conventional exchanges, order books fill a buy and sell side to which orders can get matched. Order matching is done based on a predefined set of parameters by a centralized order matching algorithm. From the aggregated list of individual buy and sell orders, buyers and sellers will get their bids matched or place their bids.
Constant product
Uniswap sidesteps the concept of a limit book entirely, where market makers and other liquidity providers don't provide exact price points of where they are providing liquidity. Instead, this is handled on a protocol level. Assets are provided in two pools of liquidity to the protocol through smart contracts. These pools can be utilized where a deterministic algorithm known as an Automated Market Maker (AMM) makes markets and quotes prices to the user. based on a set of parameters of the AMM. These parameters include the depth of the liquidity pool, invariant, and curve of the liquidity pool. In the case of Uniswap, the goal of the liquidity curve is to keep the product of the two pools constant with the formula x*y = k where x and y are two different assets and k is the product of the two.
The constant, often represented by x, means that there is a constant balance of assets that functions as the price determination of the two tokens in a liquidity pool. For example, consider an AMM with a liquidity pool that contains Ether (ETH) and Aave (Aave). Every time ETH is bought with Aave, the price of ETH goes up as there is less ETH in the pool than before the purchase. Simultaneously, the price of Aave goes down as there is more Aave in the total pool. The total pool stays constant (x*y) but x and y individually change in price. Only when new liquidity providers join in will the pool expand in size. Visually, the prices of tokens in an AMM pool follow a curve determined by the formula.
Hotbed of innovation
The innovation away from orderbook based centralized exchanges towards decentralized exchanges has been greatly helped by this relatively simple idea and allows secure end-to-end transactions with cheap fees that are easy to understand, even for low liquidity tokens. This is not to say that AMMs like Uniswap and all of the 277 spin-off forks are not without criticism and further innovation is moving the space forward. Both within Uniswap’s protocol and others, development is focusing on aspects like less slippage, impermanent loss solutions, higher capital efficiency, other formula curves, concentrated liquidity, single-sided liquidity, or even creating decentralized clearing houses that do not use liquidity pools formulas but game theory and variable fees to balance out pools. Additionally, traditional finance order books are still being revisited as well for viability by several projects.
Fourstack is a user and investor in some of these initiatives for the mentioned benefits in this article. The need for efficient decentralized swapping protocols is evident and a key pillar for a well-functioning blockchain ecosystem. While the future is uncertain, Uniswap is a clear market leader in constant product AMMs because of the first mover advantages, its open nature to create any two-sided pool you want, and 100% of the protocol fees go to the liquidity providers of the pool and none to the token UNI itself. We will go more in-depth about the trade-offs that different models have and their implications in the future.
Being on the forefront of tokenized decentralized exchanging of crypto assets is important and worthwhile. Currently, the vast majority of swaps are crypto-to-crypto exchanges but with the increased adoption of Real World Assets (RWA’s), the use cases of such protocols multiply dramatically.