feat: LP token for Stableswap pool #314
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 201d9014a8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Then claim fees for the user from the LP token | ||
| if (claimed0 > 0 || claimed1 > 0) { | ||
| StableswapLPToken(payable(lpToken)).claimFeesFor(msg.sender); |
There was a problem hiding this comment.
Always claim user fees even when no new Core fees
Because claimFees only calls claimFeesFor when claimed0 or claimed1 from Core collection is non‑zero, a user who has pending fees already accumulated in the LP token will get no payout if no new Core fees were collected in that call. This means claimFees silently does nothing in the common case where fees were accumulated earlier and the pool has since stopped accruing, despite the interface promising “claims accumulated fees for the caller.” Consider invoking claimFeesFor unconditionally (or based on pending fees) so users can claim existing balances even when Core returns zero.
Useful? React with 👍 / 👎.
…mize pending fees storage
…tion for LP token management
…StableswapLPPositions
…g in _autoCompoundFees
…swapLPToken and updating deposit logic to auto-initialize pools
- Optimize PoolMetadata struct - Extract LPTokenMathLib for reusable LP token calculations * calculateMint() with MINIMUM_LIQUIDITY burn logic * calculateBurn() for proportional liquidity removal * Safe add/remove liquidity operations with overflow protection - Optimize _autoCompoundFees() to accept pre-computed parameters * Pass sqrtRatio, tickLower, tickUpper as parameters * Eliminate redundant CORE.poolState() and tick range queries - Add poolMetadata() getter for interface compatibility * Private _poolMetadata mapping with public getter * Dynamically compute initialized flag - Remove redundant overflow checks
…TransferTarget function for LP token transfers
Fee Distribution System
On every deposit/withdraw, fees are auto-compounded:
SWAP_PROTOCOL_FEE_X64% deducted and sent to protocol'ssavedBalancespendingFeesand included in the next compound attemptResult: LP token value grows over time as fees compound into liquidity. Protocol takes a fixed percentage; LPs keep the rest (including any temporarily unpairable amounts).
StableswapLPPositions Gas Report
Deployment: 3,548,031 gas / 16,605 bytes
Core Functions
depositwithdrawwithdrawProtocolFeesView Functions
getProtocolFeesgetPendingFeestotalSupplytotalLiquiditySWAP_PROTOCOL_FEE_X64ERC6909 Metadata
namesymboldecimalsERC6909 Token Operations
balanceOfallowanceisOperatorapprovesetOperatortransfertransferFrom