Complete guide for integrating SAPI’s DLMM into your DeFi protocol
router::register_pool_with_custom_params(...) -> Object<Pool>
token_x:Object<Metadata>
- The first tokentoken_y:Object<Metadata>
- The second tokenactive_id:u32
- The active id of the pairbin_step:u32
- The bin step in basis point, used to calculate log(1 + binStep / 10_000)base_factor:u128
- The base factor derived from base fee and bin stepfilter_period:u64
- The period (in seconds) during which volatility changes are smootheddecay_period:u64
- The period (in seconds) over which accumulated volatility decaysreduction_factor:u32
- The factor (bps) applied to gradually reduce variable fees over timevariable_fee_control:u32
- The parameter controlling sensitivity of variable fee to volatilitymax_volatility_accum:u32
- The upper bound for accumulated volatility before cappingprotocol_share:u128
- The portion of swap fees (in bps) allocated to the protocolObject<Pool>
router::add_liquidity(...) -> (Object<AptosToken>, FungibleAsset, FungibleAsset)
pool_obj:Object<Pool>
- The pool objectasset_x:FungibleAsset
- The X token FAasset_y:FungibleAsset
- The Y token FAdelta_ids:vector<u32>
- The list of bin ids to add liquidityactive_id_desired:u32
- The active id that user wants to add liquidityid_slippage:u32
- The number of id that are allowed to slipdistribution_x:vector<u64>
- The distribution of tokenXdistribution_y:vector<u64>
- The distribution of tokenYamount_x_min:u64
- The min amount of token X added to liquidityamount_y_min:u64
- The min amount of token Y added to liquidityto:address
- The address of the recipient where postion NFT is transferredObject<AptosToken>
FungibleAsset
FungibleAsset
router::update_liquidity(...) -> (FungibleAsset, FungibleAsset)
lp:&signer
- Owner of the position NFTtoken:Object<AptosToken>
- The position NFT objectasset_x:FungibleAsset
- The X token FAasset_y:FungibleAsset
- The Y token FAdistribution_x:vector<u64>
- The distribution of tokenXdistribution_y:vector<u64>
- The distribution of tokenYamount_x_min:u64
- The min amount of token X added to liquidityamount_y_min:u64
- The min amount of token Y added to liquidityFungibleAsset
FungibleAsset
withdraw_liquidity(...) -> (FungibleAsset, FungibleAsset)
lp:&signer
- Owner of the position NFTtoken:Object<AptosToken>
- The position NFT objectwithdraw_percentages:vector<u64>
- Percentage per bin to withdrawwithdraw_token_x:bool
- Whether to withdraw token Xwithdraw_token_y:bool
- Whether to withdraw token Yamount_x_min:u64
- The min amount of token X expected to receiveamount_y_min:u64
- The min amount of token Y expected to receiveFungibleAsset
FungibleAsset
router::remove_liquidity(...) -> (FungibleAsset, FungibleAsset)
lp:&signer
- Owner of the position NFTtoken:Object<AptosToken>
- The position NFT objectwithdraw_percentages:vector<u64>
- Percentage per bin to withdrawamount_x_min:u64
- The min amount of token X expected to receiveamount_y_min:u64
- The min amount of token Y expected to receiveFungibleAsset
FungibleAsset
router::claim_fees(...) -> (FungibleAsset, FungibleAsset)
lp:&signer
- Owner of the position NFTtoken:Object<AptosToken>
- The position NFT objectFungibleAsset
FungibleAsset
claim_fees_multiple(...)
lp:&signer
- Owner of the position NFTtokens:vector<Object<AptosToken>>
- The array of position NFT/Token to withdraw liquidity fromreceivers:vector<address>
- The array of asset receiversswap_exact_x_for_y(...) -> FungibleAsset
pool_obj:Object<Pool>
- The Pool Object to swap inasset_x:FungibleAsset
- The asset X in to the poolamount_y_min:u64
- The minimum amount of token Y expected to receiveFungibleAsset
swap_exact_y_for_x(...) -> FungibleAsset
pool_obj:Object<Pool>
- The Pool Object to swap inasset_y:FungibleAsset
- The asset Y in to the poolamount_x_min:u64
- The minimum amount of token X expected to receiveFungibleAsset
swap_x_for_exact_y(...) -> (FungibleAsset, FungibleAsset)
pool_obj:Object<Pool>
- The Pool Object to swap inasset_x:FungibleAsset
- The asset X in to the poolamount_y_exact:u64
- The exact amount of token Y to receiveFungibleAsset
FungibleAsset
swap_y_for_exact_x(...) -> (FungibleAsset, FungibleAsset)
pool_obj:Object<Pool>
- The Pool Object to swap inasset_y:FungibleAsset
- The asset Y in to the poolamount_x_exact:u64
- The exact amount of token X to receiveFungibleAsset
FungibleAsset