Cover photo

Brief History of Defi Trading

Automated market maker

Automated market makers (AMM) are decentralized exchanges that pool liquidity from users and price the assets within the pool using algorithms. Initially, it begins with X * Y = K formula where K is a constant, X and Y are the 2 respective assets. When someone wants to trade Qx amount of token X for token Y, he/she will receive Qy tokens such that the following equation is satisfied: (X + Qx) * (Y - Qy) = K = X * Y.

The paper can be found here.

However, AMM has evolved drastically over time. Basically, AMMs today are partitioned into smaller pools so that they can maximize trading fees and minimize potential losses. And there are a variety of strategies employed to design these AMMs such as Uniswap V3, Balancer, Curve.

Then came decentralized orderbooks which employ traditional strategies as today's market makers. The liquidity required for the orderbook can also be provided by AMMs such as the Serum orderbook on Solana. This is much more difficult to design as a smart contract compared to traditional AMMs due to limitation of blocktime and gas fees, especially on older blockchains like Ethereum, Polygon, Binance chain etc.

Trading in Modern Defi

Today, traders no longer use Decentralized Exchanges as it is. Users of Defi today use aggregators to perform their trades on-chain. For example, on Ethereum, users use Cowswap to perform their trades. Cowswap is an adoption of Gnosis Protocol v2 which offers trading with MEV protection on top of aggregation across both AMMs and traders.

This is achieved through the following:

  1. Transactions are first submitted and auction separately from the Ethereum chain.

  2. If there are matching orders amongst the transactions, they can be matched directly. Remaining liquidity can be bundled and then trade against all the existing AMMs to ensure the best price possible.

This prevents a myriad of issues. Sandwiching attack is not possible on these trades as transactions are not visible in the mempool and submitted in a bundle by the solvers. Gas fees can also be amortized across the trades and users need not pay transaction fees if the transaction does not go through (transactions are submitted to solvers as opposed to Ethereum nodes). How each individual AMMs/Orderbook works will not matter as it will simply pick the best price for the traders. And this does leads to an interesting result, AMMs/Orderbook liquidity optimization no longer matters, isolated DEX that can offer the best price will get the profits (provided they are not making a loss).

Oracle driven AMMs

Newer models of AMMs on high performing blockchains today employ different strategies to maximize yield & performance. AMMs today explore options on following oracle prices as opposed to relying on market forces to stabilize their price. While liquidity management within the AMM is still important to ensure that the pool doesn't lose money/have sufficient funds during volatility, the focus here is to provide the most competitive price (and also possibly perform the arbitrage themselves). This is evident within Solana ecosystem as there are performant enough oracles like Pyth Network which is able to fetch/aggregate the trading price of other cryptocurrencies fast enough from various data sources.

Examples of such AMMs are Lifinity and DeltaFi, especially Lifinity which dominates all other AMMs during aggregation when dealing with trading small amounts of liquidity. But their depth of liquidity is still small and larger trades will still involve the early market leading DEX-es.

Leading aggregator on Solana (Jupiter) using Lifinity for best trades
Leading aggregator on Solana (Jupiter) using Lifinity for best trades

Beyond Single Chain

As more blockchains begin to have their own ecosystem, cross-chain swaps become a topic to explore. There are several existing cross-chain DEX-es that truly facilitate swaps (not Sushiswap kind of cross-chain where the DEX is available on different chains, but you still cannot cross those assets) across different chains such as Stargate and Thorchain. These are blockchains that enables swap between different blockchains/networks directly without dealing with bridges and their associated fees.

Stargate with a TVL of 4 billion USD in just a few weeks
Stargate with a TVL of 4 billion USD in just a few weeks

This can be achieved through an intermediary exchange of asset to their native token and back to the target asset. You can read more here.

Active Liquidity

Moving on, DEX-es today still do not fully utilize their liquidity well enough. Most DEX-es still use dual asset liquidity pools regardless of how much they optimize themselves. In reality, the same asset can be used to provision for multiple liquidity pools and earning trading fees from all of that. Such an example is Balancer in which liquidity is provided as a single asset, and then provision as modules to various pools such as the traditional dual-token liquidity pools or stablecoin pools. However, in this model, liquidity is ultimately still not shared amongst the different pools and depositors cannot truly maximize their gains.

Compossable Finance offers another model known as just-in-time liquidity, where liquidity is provision only during the time of the swap. After the swap, the liquidity is removed and returned to the provider. There are people who have attempted this concept on existing AMM like Uniswap V3 and could be very well profitable. Active liquidity allows the user to not only provision liquidity for multiple DEX-es simultaneously, it also allows user to provision liquidity for multiple assets at the same time. Of course, this is accompanied by the risk where the impermanent loss is amplified across the different pools (but of course this can be mitigated by only providing liquidity to only stablecoin pairs or when the trade favors the stablecoin asset).

And rewards can be further optimized by trading with derivative assets that compound yield such as liquid staking, vault shares or even sOhm derivatives if you are feeling degenerate.