Understand the historical performance of Uniswap V3 pool in one article

The success of any Uniswap LP position depends on two basic components:

  • Impermanent loss: The risk of loss due to the difference between the price of our deposited funds and the price when we close the position
  • Fees incurred by transactions supported by the pool


The goal of DeFi is to help users understand and simulate the impact of these two components, and to help estimate possible outcomes.

The impermanence loss can be explained clearly by mathematics. Here are several visualization methods to support users in simulating the impact of price changes on investment.

Understand the historical performance of Uniswap V3 pool in one article

On the contrary, the fees incurred are highly uncertain; we cannot create an accurate model to determine the amount of fees a pool will incur in the future, but we can help our users support simulations based on historical data of LP positions to support their Analysis and decision-making.

DeFi has expanded its tools to allow users to calculate the historical performance of Uniswap LP strategies based on a new method.

Understand the historical performance of Uniswap V3 pool in one article

New method of Uniswap V3 pool backtest

Uniswap LP strategy is highly differentiated. Each investor can choose his own range of active liquidity, and each person charges different fees.

In order to back-test the strategy, we need to collect data and calculate the specific conditions of the test strategy.

Extract historical data of a specific Uniswap V3 tool

To support our analysis, we need to collect historical data on the Uniswap V3 pool. To this end, we use TheGraph PoolHourData subgraph to solve this problem.

As stated in the Uniswap V3 white paper, for each pool, the Uniswap contract tracks the total amount of fees (fg) that can be obtained for 1 unit of unbounded liquidity deposited when the contract is first initialized. Unbounded liquidity can be easily described as a strategy that provides liquidity for the entire price range (MinLimit = 0, MaxLimit = ∞).

We can calculate the fees earned by 1 unit of unlimited liquidity over a period of time as follows:

F_Unb = fg(t) – fg(t-1)

Determine the location to test

In order to determine the historical cost of the LP position, we need to first calculate the amount of liquidity provided by the LP. Liquidity is a function of strategy (minimum limit and maximum limit) and initial investment.

Liquidity = LiquidityFunction(MinLimit, MaxLimit, investment)

In our calculations, we also need to determine the liquidity that the same investment will generate if we choose an unbounded strategy.

LiquidityUnb = LiquidityFunction(0, ∞, investment)

Historical cost calculation

At the beginning of each time period, LP can:

a) Provide liquidity for the entire range. In this case, the earned fees are easy to determine:

MyFeeUnb = F_unb * LiquidityUnb

b) Provide concentrated liquidity within a specific scope. In this case, the cost is determined by the time spent by the price within the active liquidity range and the multiplier.

MyFee = MyFeeUnb * multiplier * time spent in range

But the multiplier can be expressed as:

Multiplier = Liquidity/ LiquidityUnb

Therefore, the former can be rewritten as:

MyFee = F_Unb * Liquidity * Time spent in range

Finally, the historical cost is calculated as the income earned by MyFee during each analysis period.

This sounds good, but does it really work?

This theory is very interesting (some points), but is it really effective?

We have backtested more than 500 currently open backtesters in Uniswap v3, and the results are as follows

Understand the historical performance of Uniswap V3 pool in one article

When the position is active for approximately 100%, the backtest is very accurate, and when the time within the distance is low, the accuracy will decrease.

This is because we need to apply an approximation when calculating the time spent in the range parameter. Using TheGraph’s hourly data, we cannot accurately determine the time the price spends in this range, but can only be an approximate value.

in conclusion

This new feature will allow fast and reliable backtesting directly in our simulator.

Past performance does not guarantee future results, but they represent an important basis for analysis and support our LP strategy definition.

Posted by:CoinYuppie,Reprinted with attribution to:https://coinyuppie.com/understand-the-historical-performance-of-uniswap-v3-pool-in-one-article/
Coinyuppie is an open information publishing platform, all information provided is not related to the views and positions of coinyuppie, and does not constitute any investment and financial advice. Users are expected to carefully screen and prevent risks.

Like (1)
Donate Buy me a coffee Buy me a coffee
Previous 2021-11-04 02:40
Next 2021-11-04 02:44

Related articles