Skip to content
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

Draft
wants to merge 100 commits into
base: main
Choose a base branch
from

Conversation

mconcat
Copy link
Contributor

@mconcat mconcat commented Dec 13, 2024

No description provided.

pool/type.gno Show resolved Hide resolved
staker/staker.gno Outdated Show resolved Hide resolved
Copy link
Member

@r3v4s r3v4s left a 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

pool/pool.gno Outdated
@@ -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)

Copy link
Member

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(),
Copy link
Member

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)
Copy link
Member

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.

notJoon and others added 29 commits December 30, 2024 20:45
…-labs/gnoswap into mconcat/refactor-emission-part-1
…-labs/gnoswap into mconcat/refactor-emission-part-1
…-labs/gnoswap into mconcat/refactor-emission-part-1
…-labs/gnoswap into mconcat/refactor-emission-part-1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants