velodrome-finance / sugar

Sugar makes Velodrome devs life sweeter 🍭
Other
47 stars 26 forks source link

fix: use liquidity at current tick #59

Closed pedrovalido closed 7 months ago

pedrovalido commented 7 months ago

Updating CL gauge liquidity to expose the gauge liquidity at the current tick.

ethzoomer commented 7 months ago

Deployed here but it reverts when trying to fetch any CL pool data: 0x5009F9C2dD46a18a6a274b40CC36D2B6302F9575

pedrovalido commented 7 months ago

Deployed here: https://optimistic.etherscan.io/address/0xFA27F33a25555A241E35271a7509b43e216D56eE

pedrovalido commented 7 months ago

@stas the active liquidity being fetched is the stakedLiquidityNet at the current tick. There are a few cases where the stakedLiquidityNet at the current tick is 0. You also mentioned: "If the APR is too volatile, we add the immediate +/- 1 tick liquidity, if not we keep it like this." So, wdyt about:

active_liquidity: avg(currentTick.stakedLiquidityNet, currentTickMinus1.stakedLiquidityNet, currentTickPlus1.stakedLiquidityNet) Will add this change shortly

stas commented 7 months ago

@stas the active liquidity being fetched is the stakedLiquidityNet at the current tick. There are a few cases where the stakedLiquidityNet at the current tick is 0.

I think that's fine. Let's not add the immediate ticks for now, as we're trying to figure out still how volatile is the APR in the current tick.

Will add this change shortly

Let's consider this for later. For now the active tick liquidity seems fine imho.

pedrovalido commented 7 months ago

@ethzoomer reverted the change of the immediate ticks. Feel free to merge if everything looks good

pedrovalido commented 7 months ago

Pushed the change for the issue mentioned above: When the tick spacing is not 1, we return the weighted average of the closest ticks' staked liquidity net. To give an example, if the tick spacing is 100 and the current tick is 70, we return the sum between 30% of ticks(0) and 70% of ticks(100).

pedrovalido commented 7 months ago

The new changes with the weighted average of the closest ticks is deployed here https://optimistic.etherscan.io/address/0xe510f1d0d96865be9684e1b9faac5069cc231ada

ethzoomer commented 7 months ago

I believe this can be closed now that the UI is using staked0/staked1 for the active staked liquidity around the current tick cc @pedrovalido