AMMs for Decentralised Finance
2020-11-10

Overview


When reconstructing a new world of finance on a decentralized, blockchain based system such as that on Ethereum, it is essential to recognize that the blockchain world has an entirely different dynamic compared to the off-chain world.


Most notably, instead of experiencing the passage of time continuously, the on-chain ecosystem quantifies the elapse of time by blocks, which in turn results in latency issue and computational capacity limitation as it is restricted by block size. Due to these structural differences, designers of decentralized finance should have a completely different mindset than those from the centralized world. For example, it is no longer feasible for market makers to conduct market making activities on an on-chain order book-based DEXs due to the cost and technical infrastructure of blockchains.


In the traditional market, an order book format is used to record the interest of buyers and sellers in a particular financial instrument. In today's financial market, order book is extremely efficient due to the advancement of technology, which has made high-frequency trading into the reality leveraging ultra-fast fibre optic data centre, resulting optimal price discovery process always happen in the off-chain order book world. 


On the other hand, order books running on-chain are suboptimal due to blockchain latency and computational costs. Vitalik (2016) based on some ideas from Nick Johnson’s proposal suggested a simple approach for on-chain market makers, which we now call Automated Market Makers (AMMs). This gives birth to the decentralized exchange landscape today with AMM-based DEXs dominating the DeFi ecosystem.



According DeFi data service provider DeBank, only eight out of the 30 DEXs they track are built on order book. In comparison, more than 75% of the trading volumes came from the top 3 AMM based DEXs, namely Uniswap V2, Curve, and 1inch.



The sudden rise of DeFi this summer has presented DEXs with tremendous growth opportunities, and AMM based DEXs are most popular due to their lower barriers to entry for liquidity providers, better usability, and improved liquidity compared to the order book based DEXs.


Rising overall DEX volumes from the AMM based DEXs in June 2020 signify the fundamental needs of AMM based DEXs in the DeFi ecosystem. However, there are still various problems in the AMM based DEXs world. For example, when providing liquidity on AMM based DEXs, they have relatively lower capital utilization compared to the order book market-making structure. Another problem with AMM based DEXs, perhaps also the problem that has drawn AMMs most criticism, is the possibility of impermanent losses - the temporary loss of funds experienced by liquidity providers due to volatility in the target trading pair.


Although there is no one size fits all solution to the problem brought by the current AMM structure, we believe that the design of the current DEXs ecosystem can be improved in many ways.


The current problem in the AMM world


Existing AMM based DEXs such as Uniswap (Constant product AMM), Balancer (Constant mean AMM), and Curve (hybrid AMM) all adopt the constant function market makers (CFMMs) model.  The CFMM is defined by its trading function and its reserves. The term “constant function” means any trade that changes reserves need to ensure the product of those reserves remains unchanged (i.e. equal to a constant).


Though it is a large success for these decentralized exchanges satisfying relatively similar and theoretical properties under mild conditions, there are obvious flaws in the current AMM designs, including but are not limited to impermanent loss, wider slippage, and lower capital efficiency. 


Before we dive into the details of how liquidity works in the AMM world, we need to first do some housekeeping and address several concepts that will be mentioned repeatedly in the following.

There are generally two components and an optional incentivised component in the liquidity providers’ overall returns by parking their assets in an AMM liquidity pool. They are Impermanent Loss (IL), Trading Fee (Fee), and Incentives (Compensation). 



Market making in any type of financial markets carries risks. These risks would be generally reflected in the order book by the difference between the bid and ask prices, which we usually call market spread. In the AMM-based DEX ecosystem, these risks are reflected in the so-called impermanent losses, which can result in a significant reduction of the overall return for these liquidity providers.


There are various solutions to reduce or allegedly eliminate impermanent losses such as using options, or Bancor V2‘s price adjustment by a dynamic re-weighting of the token ratios; however, none of these solutions truly solve the IL problem. Furthermore, we believe that many industry players are searching solutions in a fruitless direction - you cannot solve the impermanent loss issue without first understanding and quantifying on-chain financial parameters in a systematic manner.


Impermanent lossDifficult to hedge)


Impermanent loss is the difference between what LP get when they hold outright and when LP get when they hold it in an AMM pool. Such differences exist because of volatility in the trading pair.


Given a liquidity pool consist of x asset and y asset, if the price P changes to P’, the market value of the pool becomes:



whereas the holding portfolio’s value changes to:



we get the following:




From the divergence loss function, we see impermanent loss happens whenever price changes and no matter which direction it changes. The loss is impermanent if the price return to the initial value. 


Slippage 


Price slippage refers to the difference between the effective exchange rate obtained by the trader and the actual market price.


The larger the pool’s liquidity, the smaller the slippage is. Due to the design of the market making mechanism, this has enabled the larger liquidity pools to benefit from the economies of scale.


Larger liquidity pools would rationally attract additional trading volumes with lower slippage. 


Capital efficiency


According to DeFi Pulse, there are more than $4.11 billion worth of crypto assets being locked in DEX protocols, roughly accounting for 1/3 of the TVL in DeFi. With such a massive amount of capital locked in DEXs, one of the most urgent problem seems to be: have these assets been properly utilized in the sense that they are adding meaningful value to the ecosystem, or have they simply been idling? 


Capital efficiency or capital utilization is an essential element of the financial market, where extremely low capital efficiency means suboptimal portfolio structure with assets not being well utilized to earn yields. The relationship between liquidity and trading volume is capital utilisation. 



We started to examine the current status of capital efficiency in the DeFi ecosystem using the top 100 trading pairs’ liquidity and trading volume data that we extracted from Uniswap V2 on October 28, 2020.



The analysis has shown that Uniswap liquidity pools generally have low capital efficiency with an average of 23% of total capital being utilized for trading purposes. Only 5 of the top 100 trading pairs had greater than 100% capital utilizations. These five trading pairs are OCEAN/ETH, ETH/HEX2T, NAMI/ETH, ETH/CRV, and KORE/ETH. 88% of these 100 trading pairs have capital efficiency lower than 40% while 56% of the 100 trading pairs have capital efficiency of less than 10%.



We have also selected Uniswap, DODO and CoFiX to conduct the overall capital utilization analysis to understand their own capital efficiency due to their popularity in the market or their unique design.



As the result shows, CoFiX has the highest capital utilization ratio out of the above 3 AMM based DEXs, the ratio is consistently climbing to a higher value since launch, indicating a significant market traction has been gained for the CoFiX Protocol. On the other hand, the capital utilization ratio for Uniswap continues to decline due to the cool down of DeFi sector from early September, 2020, and DODO maintains a roughly 20% of the ratio post launch.



Long tail assets


The AMM structure provides an extremely easy way for early stage projects to bootstrap liquidity without going through the tedious and usually expensive token listing process via centralized exchanges. Market makers on the centralized exchanges need to set up a sophisticated market making algorithms with large amount of assets sitting across different exchanges in order to provide liquidity in the market. Unlike with the order book structure, market participants in AMMs trade against a pool of assets rather than a specific counterparty and do not require a customized market making algorithms. It lowers the barriers to entry in bootstrapping liquidity in the AMM DEXs space, they are most welcomed by long tail assets where they can easily bootstrap the early stage liquidity for price discovery process.


Until October 26, 2020, there are 18,440 and 3,747 trading pairs on Uniswap V2 and V1, respectively. Meanwhile there are roughly around 800 trading pairs on Huobi Global Exchange and roughly around 1,100 trading pairs on Binance.



The low overlap of tokens on different platforms shows different exchanges meet users’ different needs . For Uniswap V2, there are 656 trading pairs (ETH as the quote-price) of which the daily trading volume is greater than 0 on October 26, 2020. Among them 51 trading pairs (ETH as the base-pairs) have been listed on Huobi Global Exchange. In terms of tokens, there are 74 tokens have been listed on both Uniswap V2 and Huobi Global Exchange. 


Because the number of trading pairs on Uniswap(18440) is greater than that on Huobi (795) and Binance(1137) ,and the degree of overlap is low, we think the trading pairs and tokens data suggests that decentralized exchanges such as Uniswap suits users’ different needs than centralized exchanges. 


AMM based DEXs are extending trading ecosystem to include a wide range of trading pairs such as low-liquidity and low-trading volume crypto assets.


The low overlap of tokens on different platforms shows different exchanges meet users’ different needs . For Uniswap V2, there are 656 trading pairs (ETH as the quote-price) of which the daily trading volume is greater than 0 on October 26, 2020. Among them 51 trading pairs (ETH as the base-pairs) have been listed on Huobi Global Exchange. In terms of tokens, there are 74 tokens have been listed on both Uniswap V2 and Huobi Global Exchange. 


Because the number of trading pairs on Uniswap(18440) is greater than that on Huobi (795) and Binance(1137) ,and the degree of overlap is low, we think the trading pairs and tokens data suggests that decentralized exchanges such as Uniswap suits users’ different needs than centralized exchanges. 


AMM based DEXs are extending trading ecosystem to include a wide range of trading pairs such as low-liquidity and low-trading volume crypto assets.


The stable trading pairs


The trend-stable series


The divergence loss function as explained above shows how price changes affect liquidity providers’ value. To maximize returns, liquidity providers want to see their pool’s assets x and y maintain at a stable exchange rate (like USDT/USDC) or oscillates back and forth around a mean value. 


Unfortunately, most of the trading pairs display a long memory characteristic, which leads them to persistently adhere to an upward or downward trend. We call trading pairs that demonstrate this behavior trend-stable series. 



Testing methods


Trading pair prices can form a series of data points indexed in time order, which we call time series data. Time-series data can be classified into three different categories - mean reversion1 process, geometric random walk2, and trending series3 (trend-stable series). We found most trading pairs on Huobi Global exchanges are trend-stable series.


We perform statistical analysis on the trading pairs data that we collected to show trading pair trends. The testing method includes an estimation of a Hurst Exponent H proposed by H. E. Hurst (1951)4


Hurst Exponent measures long term memory5 of a time series and it is used to classify the tendency of time series either to regress strongly to the mean or to cluster in a certain direction. 



The values of Hurst Exponent range between 0 and 1. Based on H, a time series can be classified into three categories.


a) 0 < H < 0.5 indicate an anti-persistent series with a “mean-reverting” characteristic, which means that the value of the series would persistently revert to its mean over time. The strength of “mean-reverting” increases as H approaches 0.

b) H = 0.5 indicate a random series.

c) 1 > H > 0.5 indicate a trend reinforcing series, meaning that the direction of the next value is more likely to be the same as the current value. The larger the H value is, the stronger trend.


Those series with an upward or downward trend would have a Hurst Exponent between 0.5 and 1.


1: Mean reversion is a theory used in finance that suggests that asset prices and historical returns eventually will revert to the long-run mean or average level of the entire dataset.

2: In mathematics, a random walk is a mathematical object, known as a stochastic or random process, that describes a path that consists of a succession of random steps on some mathematical space such as the integers.

3: A price series that continues to continually close either higher or lower (on average over a defined number of periods) is said to be trending

4: Hurst, H. E. (1951). Long-term storage capacity of reservoirs. Transactions of the American Society of Civil Engineers, 116, 770-799.

5. Long term memory relates to the rate of decay of statistical dependence of two points with increasing time interval or spatial distance between the points. A phenomenon is usually considered to have long-range dependence if the dependence decays more slowly than an exponential decay, typically a power-like decay.


Data analysis


Historical data of all trading pairs were obtained from Huobi Global Exchange, and each trading pair was collected at four different intervals which are 30 minutes, 60 minutes, 4 hours, and 1 day.


Each trading pair has a minimum of 100 sets of price data and a maximum of 2,000 because of the different listing dates and time intervals. 


We then subject these prices to the following formula which produce the H value. 



where R – rescaled range of variation, S – standard deviation, c – constant, n – number of sample elements, H – the Hurst exponent. Thus we have 2,864 Hurst Exponent values related to corresponding 2864 data sets which were shown in the below figure.



The chart above has demonstrated some interesting results.


As most of the trading pairs have an upward or downward trend, they are not suitable for liquidity providers to provide liquidity on AMM based DEXs because the exchange of x and y asset are not mean-reverting. 



The frequency distribution histogram is plotted vertically as a chart with bars that represent numbers of H values within certain ranges (bins) of values.


Through the graph of frequency distributions in H values with four different lengths of time period, we find the larger the length of time period, the broader the shape of the distribution is.  


Except for one day’s data sample, all the 30 minutes, 60 minutes and 4 hours data sample have a large part of the observations clustered around a central value which locate between 0.5 and 0.6. 



From the perspective of liquidity providers, due to the strength of “mean-reverting” increases as H approaches 0 and the facts that 0.5 < H <1 indicates persistent behaviour, most of the trading pairs on the exchange have no characteristic of mean reversion and are not suited for LPs to park their assets in the liquidity pool due to potential large impermanent loss.


Liquidity providers’ return analysis


The return for an liquidity provider is an important element to understand in this market, as the return analysis is part of the decision making process for liquidity providers to consider when deciding which protocol should they choose to pool their assets.


As Uniswap is the leading AMM based DEX without an external oracle, on the other hand, DoDo and CoFiX are AMM based DEXs with an external oracle, Chainlink and NEST Protocol respectively. These three protocols have been chosen to be discussed in this sector to conduct return analysis. We compare LP’s returns with a sensitive test by Trading Fee, Compensation, and IL in terms of ETH/USDT pool or single side asset exposure.


The returns of DEX liquidity providers consist of three parts, namely Impermanent Loss (IL), Trading Fee (Fee), and Incentives (Compensation). 



For those who provide liquidity to Uniswap ETH/USDT pool on Nov.10, 2020, the expected ROI within 20% of price change is from 12.5% to 19% without considering the market movement of Ethereum. Liquidity providers cannot anticipate the market movement and thus are unable to hedge the market exposure to lock in a fixed return.


DODO’s ETH/USDC pool allows single side exposure for liquidity providers. The charts above show an unbalanced APY structure for two sets of LPs. USDC LPs can get an effective APY from 5.8% to 12.3% depending on the market value of the DODO governance token. However, ETH LPs only get 3.0% to 4.4% in the same condition, or -17.0% effectively if the price of ETH devaluates for 20%.


Though DODO has tried to eliminate impermanent loss by correcting AMM generated prices with market price provided by Chainlink, it faces an unbalanced return for LPs. In addition, it also faces the oracle problem, as outlined in our Price Oracle - A Must-Have Infrastructure research report.



CoFiX also provides single side assets exposure option backed with NEST protocol price oracle. Although there is no front end showing the estimated APY so far, we can estimate the current APY for ETH/USDT pool is roughly around 60.2% based on the historical data post launch (Oct.21, 2020)


The market making risks in the CoFiX protocol can be hedged in the centralised exchange with a customized script. This opens the door to attract a large inflow of the institutional money into the DeFi space.



Uniswap is one of the early AMM based DEXs mover in the DeFi space, its current liquidity pool value is more than 100x than DODO and CoFiX. However, CoFiX protocol has launched on October 12, 2020, and quickly gains market traction as indicated by the rising TVL value,


Uniswap may not be the best choice for liquidity providers to park their assets due to potential impermanent loss.


The chart above shows that both DODO and CoFiX can maintain a positive APY for liquidity providers (please note CoFiX LPs need to hedge their LP positions using script). The liquidity providers may lose their initial investment when UNI token devaluates by 12.45% or more.



On the other side, both DODO token and CoFi token are not listed on any top tier centralized exchanges, which means that their liquidity remains at a relatively low level, and it can be difficult to liquidate the incentivised rewards on the secondary market due to limited liquidity.



The Future, Computational Finance - DeFi 2.0 


DeFi, by definition, is to combine the decentralization nature of the blockchain technology with traditional finance to create the next generation financial services experience. DeFi is building on top of the permission-less blockchain technology to democratize finance in a fair, open, and decentralized way.


Although there have been some notable innovations such as AMMs and price oracles over the past two years, the DeFi space has given extremely limited attention to risks. One of the most important components which form the basis of finance is risk management. Black Thursday was a stress test to the DeFi financial system, and it sounded a timely alarm for the industry participants - there are many different systemic risks presented in DeFi which can potentially crash the entire industry, one of the most unconsidered risk is the inability to calculate risks in the current DeFi sector.


As we continue building DeFi money legos and introduce various components from traditional finance to the new ecosystem, DeFi’s compostability nature can compound risks exponentially. When the market collapses, these unquantified risks can potentially crash the DeFi ecosystem.


We hope to see the next generation of DeFi can bring computable components to the ecosystem, enabling quantifiable financial parameters in every aspect to enhance market efficiency. Computable financial parameters can only bring net positive benefits to the ecosystem, creating ripple effects in the DeFi space on how we think and understand risks.


As such, we believe the next iteration of DeFi is the transition towards computable finance (CoFi), where every financial parameter can be quantified to assist market participants in forming informed decisions. We strongly believe that the computational risks can be the game-changer in DeFi. Computational Finance or CoFi is the next iteration to set the foundation for DeFi 2.0.


Disclosure: Huobi DeFi Labs has provided financial support to CoFiX, a community driven DeFi protocol that’s built on the NEST oracle.