Concentrated Liquidity Pool Integration
2
Build the Redeemer Structure
pub type ExchangeActionRedeemer {
in_idx: Int, // 1 byte: pool or staking
action: ExchangeAction // 1 byte
}
pub type ExchangeAction {
CreatePool(CreatePoolParams)
// platform_fee_out_idx > 0 if platform_fee_X/Y > 0
ModifyLiquidity(Int, List<ModifyLiquidityParams>)
// (UTxOType, LicenseIdx)
WithdrawPlatformFee((Int, Int) ,List<WithdrawPlatformFeeParams>)
Swap(List<SwapParams>)
// platfrom_fee_out_idx
ClaimUndefined((Int, Int) ,List<ClaimUndefinedParams>)
DelegatePool
}
type SwapParams {
pool_in_idx: Int, // 1 byte
pool_out_idx: Int, // 1 byte
delta_amount: Int, // 32 byte (Int256)
}h'0103...' // Swap Action = 0358240103... // 36 bytes (<in_idx><action><pool_in_idx><pool_out_idx><delta_amount>)3
Create the Transaction
3
Output
type PoolDatum {
// Pool liquidity pair used for trading
token_X: TupleAsset,
token_Y: TupleAsset,
//
lp_fee_rate: Basis, // LP fee decided by pool creator
platform_fee_X: Int, // platform fee accumulated on each swap transaction collected in token X
platform_fee_Y: Int, // platform fee accumulated on each swap transaction collected in token Y
// to save costs, onchain will let offchain calculate sqrt price
sqrt_lower_price: PRational,
sqrt_upper_price: PRational,
// min X, min Y to avoid DDOS when ModifyLiquidity and Swap
min_x_change: Int,
min_y_change: Int,
circulating_lp_token: Int, // current lp token in circulation, changed when supply/withdraw liquidity
last_withdraw_epoch: Int // the last epoch when a withdrawal was made from the pool
}24_0(<<121_0([_
[_
h'9a614be30284aa88eb845da7657b5d0a235f1b95628b23c08050d502',
h'6655534441',
],
[_
h'834a15101873b4e1ddfaa830df46792913995d8738dcde34eda27905',
h'665553444d',
],
0,
0,
0,
121_0([_ 15811388300841898_3, 10000000000000000_3]),
121_0([_ 17320508075688772_3, 10000000000000000_3]),
1090866_2,
399256_2,
10000000_2,
65339_1,
])>>)Last updated