feat(clamm): implement XLS-99 Concentrated Liquidity AMM#6605
Open
RomThpt wants to merge 1 commit intoXRPLF:developfrom
Open
feat(clamm): implement XLS-99 Concentrated Liquidity AMM#6605RomThpt wants to merge 1 commit intoXRPLF:developfrom
RomThpt wants to merge 1 commit intoXRPLF:developfrom
Conversation
Implement a Concentrated Liquidity Automated Market Maker for the XRP Ledger, enabling LPs to concentrate capital within specific price ranges for up to 4000x capital efficiency improvement over XLS-30. Ledger entries: - CLAMM (0x008A): pool state with current tick, sqrt price, liquidity - CLAMMTick (0x008B): per-tick liquidity and fee growth data - CLAMMPosition (0x008C): LP position linked to NFToken (XLS-20) - CLAMMTickBitmap (0x008D): compressed bitmap for tick lookup Transactions: - CLAMMCreate (85): create pool with asset pair, fee tier, initial price - CLAMMDeposit (86): add liquidity within a price range, mint NFToken - CLAMMWithdraw (87): remove liquidity, burn NFToken on full withdrawal - CLAMMSwap (88): direct swap through a pool - CLAMMCollectFees (89): collect accumulated fees without removing liquidity - CLAMMVote (90): vote on trading fee parameters - CLAMMBid (91): bid for auction slot (discounted fees, MEV protection) - CLAMMDelete (92): remove empty pools from ledger - CLAMMClawback (93): issuer clawback of tokens from CLAMM positions RPCs: clamm_info, clamm_positions, clamm_ticks, clamm_quote Integration: - Payment engine routing through CLAMM pools (CLAMMLiquidity/CLAMMOffer) - NFToken position transfer with fee settlement - NFTokenBurn blocked for CLAMM positions - ValidCLAMM invariant checker Tests: unit tests, payment routing, tick bitmap, fuzz testing Spec: XRPLF/XRPL-Standards#498
|
This PR has conflicts, please resolve them in order for the PR to be reviewed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implement a Concentrated Liquidity Automated Market Maker (CLAMM) for the XRP Ledger, as specified in XLS-99. Unlike XLS-30 which distributes liquidity uniformly, CLAMM allows LPs to concentrate capital within specific price ranges for up to 4000x capital efficiency improvement.
Ledger Entries (4 new)
0x008A): Pool state -- current tick, sqrt price, active liquidity, fee tier, auction slot0x008B): Per-tick liquidity boundaries and fee growth tracking (sparse storage)0x008C): LP position linked to NFToken (XLS-20) -- tick range, liquidity, uncollected fees0x008D): Compressed 256-bit bitmap for efficient initialized tick lookupTransactions (9 new)
RPCs (4 new)
clamm_info: Pool information (by pool_id or asset/asset2/fee_tier)clamm_positions: Query positions by account or nftoken_idclamm_ticks: Query tick data within a rangeclamm_quote: Swap quote simulationKey Design Decisions
Amendment
Feature flag:
featureCLAMMTest Plan
CLAMM_test.cpp-- 4881 lines)CLAMMPayment_test.cpp)CLAMMBitmap_test.cpp)CLAMMFuzz_test.cpp)Related