-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
When swapping on a uniswap v3 exchange, the cache variable is initialized with total_supply, i.e. total liquidity in the pool across all positions. This value, via SwapState, is then used to calculate swap amounts in/out.
We encountered this trying to replicate historical data. Replacing total_supply with liquidity-at-tick (calculated as the liquidity at the largest tick to the left of current price, by way of a cumulative sum of net liquidity) leads to successful replication of historical data.
Also, self.liquidity is not defined on initialization of uniswap v3 exchanges. It seems to be defined only after the first swap() call, so you can't actually replace self.total_supply with self.liquidity in the line referenced above.
Metadata
Metadata
Assignees
Labels
No labels