feat: add DCL liquidity management module - #1
Open
Kampouse wants to merge 1 commit into
Open
Conversation
Adds dcl-liquidity.ts with concentrated liquidity position management
for the CLMM contract (dclv2.ref-labs.near).
All methods tested on NEAR mainnet:
- depositTokenToCLMM(): ft_transfer_call('Deposit') to store tokens
in CLMM internal balance before adding liquidity
- addLiquidity(): batch_add_liquidity direct call with pool_id,
amount_x/y, left_point, right_point, min_amount_x/y
- removeLiquidity(): remove_liquidity with lpt_id, amount, liquidate_type
- amount='0' harvests fees only (position stays open)
- amount=full closes position + claims principal
- getLiquidityPositions(): nft_tokens_for_owner enumeration to find
all LP NFT positions for an account
- openPosition(): convenience function combining storage registration,
token deposit, and batch_add_liquidity in a single transaction set
Fee tiers documented as 1% (fee=100) with point_delta=200 requiring
bin-aligned tick values (multiples of 200).
Author
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
Adds
dcl-liquidity.tswith concentrated liquidity position management for the CLMM contract (dclv2.ref-labs.near).All methods are tested on NEAR mainnet with real transactions:
depositTokenToCLMM()ft_transfer_call(msg: "Deposit")addLiquidity()batch_add_liquiditydirect callremoveLiquidity()remove_liquidity(amount="0" = fee harvest)getLiquidityPositions()nft_tokens_for_owner(view)openPosition()What this enables
remove_liquidity(amount="0")claims accrued fees without closing the positionremove_liquidity(amount=full)with auto-fee-claimKey discoveries (documented)
ft_transfer_call("Deposit")beforebatch_add_liquiditycan use themremove_liquiditywithamount: "0"— no separate harvest method existsnft_tokens_for_owner, notlist_active_orderspoint_delta, e.g. 200 for 1% fee pools)Files added
src/dcl-swap/dcl-liquidity.ts— 348 lines, full liquidity managementsrc/index.ts— export addedChecklist
refDCLSwapViewFunction,DCLSwapGetStorageBalance, etc.)