-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(staker): add in-range staked liquidity tracker #438
base: main
Are you sure you want to change the base?
Conversation
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just little two things
@@ -611,6 +611,8 @@ func tickTransition(step StepComputations, zeroForOne bool, state SwapState, poo | |||
newState.liquidity = liquidityMathAddDelta(state.liquidity, liquidityNet) | |||
} | |||
|
|||
pool.tickCrossHook(GetPoolPath(pool.token0Path, pool.token1Path, pool.fee), step.tickNext, zeroForOne) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you stack tickNext at this point, you're stacking the value before the change. If you want to stack the history of the change with tickTransition, it's better to record the updated tick in newState.tick.
pool, ok := stakerPoolInfo[poolPath] | ||
if !ok { | ||
pool = StakerPoolInfo{ | ||
totalStakedLiquidity: u256.Zero(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The StakerPoolInfo type declaration is commented out.
} | ||
//pool.totalStakedLiquidity = liquidityMathAddDelta(pool.totalStakedLiquidity, liquidity) | ||
if pn.PositionIsInRange(tokenId) { | ||
pool.totalStakedLiquidityInRange = liquidityMathAddDelta(pool.totalStakedLiquidityInRange, liquidity) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to calculate the reward correctly, we need to distinguish when tokenId is inrange and when it is not.
Currently, the history of tokenIds records all tokenIds in deposits
. I would recommend that we consider an additional ledger, depositTokenId[poolPath][tokenId], that manages all tokenId leases deposited in poolPath, and an additional ledger, inRangeTokenIdList[poolPath][tokenId], that manages inRagneTokenIds.
In some cases, it may not be an inRange, so you will need a global ledger and an inRange ledger.
No description provided.