zelos-alpha / demeter

Better backtest toolkit for Uniswap v3 and Aave.
https://medium.com/zelos-research
MIT License
39 stars 9 forks source link

How accurate calculation can be? (uniswap v3 pool) #9

Closed youbrain closed 7 months ago

youbrain commented 7 months ago

How accurate can be the calculation of the commission earned by the uniswap v3 pool? (back test on historical data)

When I run the backtest and compare the result with the results of my real pool, the difference in eth is less than 0.06 percent, but in usdt the difference is 0.428%. Is it possible to get 1 in 1 exact data?, and if not, how to get closer to these values? What is acceptable difference ?

32ethers commented 7 months ago

Backtesting runs at minute intervals, which introduces some errors, but also brings some benefits.

Another potential source of error is when the pool is very small, leading to the virtual liquidity of users dominating a significant portion of the total liquidity in the backtesting.

The third scenario is when the current price is at the edge of a position. There might be slight errors when it moves out or in the range.

Finally, could you share your code so that we can help you review it for any other potential sources of error? Just like this issue