Retrieve clmm pools
1. Retrieve all pools
use sdk.Pool.getPoolsWithPage()
method
Function input params
assignPools: An array of pool IDs to get. If you want to retrieve all pools, just pass an empty array.
Example
async function retrievelAllPools() {
// If you want to get all pools, just pass one empty array.
const pools = await TestnetSDK.Pool.getPoolsWithPage([])
console.log(`pool length: ${pools.length}`)
}
// retrievelAllPools()
//pool length: 82
2. Batch retrieval of pools
use sdk.Pool.getPoolsWithPage()
method
Function input params
assignPools: An array of pool IDs to get. If you want to retrieve all pools, just pass an empty array, otherwise pass an array not null.
Example
async function batchRetrievalPools(){
const betch_pool_addresses = [
'0xbed3136f15b0ea649fb94bcdf9d3728fb82ba1c3e189bf6062d78ff547850054',
'0x74dcb8625ddd023e2ef7faf1ae299e3bc4cb4c337d991a5326751034676acdae',
]
// if pool addresses not empty, you will get the pool list of the addresses.
const betch_pools = await TestnetSDK.Pool.getPoolsWithPage(betch_pool_addresses)
console.log({ betch_pools })
}
//batchRetrievalPools()
/*
{
betch_pools: [
{
poolAddress: '0xbed3136f15b0ea649fb94bcdf9d3728fb82ba1c3e189bf6062d78ff547850054',
poolType: '0x0868b71c0cba55bf0faf6c40df8c179c67a4d0ba0e79965b68b3d72d7dfbf666::pool::Pool<0x26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc::usdt::USDT, 0x26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc::cetus::CETUS>',
coinTypeA: '0x26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc::usdt::USDT',
coinTypeB: '0x26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc::cetus::CETUS',
coinAmountA: '301095941257',
coinAmountB: '7744151970817830',
current_sqrt_price: '2958038090622808503233',
current_tick_index: 101552,
fee_growth_global_a: '105486819403232',
fee_growth_global_b: '5375007645466054573',
fee_protocol_coin_a: '57258995',
fee_protocol_coin_b: '2345233787348',
fee_rate: '2500',
is_pause: false,
liquidity: '48272892630439',
position_manager: [Object],
rewarder_infos: [Array],
rewarder_last_updated_time: '1690775362',
tickSpacing: 60,
ticks_handle: '0x7ac1074ec3dc1bcbffc4fdaa366464a9402f17a36a2bfd81afa0ee97230dcf95',
uri: 'https://bq7bkvdje7gvgmv66hrxdy7wx5h5ggtrrnmt66rdkkehb64rvz3q.arweave.net/DD4VVGknzVMyvvHjceP2v0_TGnGLWT96I1KIcPuRrnc',
index: 47,
name: 'USDT-CETUS[60]'
},
{
poolAddress: '0x74dcb8625ddd023e2ef7faf1ae299e3bc4cb4c337d991a5326751034676acdae',
poolType: '0x0868b71c0cba55bf0faf6c40df8c179c67a4d0ba0e79965b68b3d72d7dfbf666::pool::Pool<0x26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc::usdc::USDC, 0x26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc::eth::ETH>',
coinTypeA: '0x26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc::usdc::USDC',
coinTypeB: '0x26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc::eth::ETH',
coinAmountA: '3322014941305',
coinAmountB: '9107325795',
current_sqrt_price: '28528838400056161926',
current_tick_index: 8720,
fee_growth_global_a: '1379094722374781659889726',
fee_growth_global_b: '172841952761357607431',
fee_protocol_coin_a: '3320806164020',
fee_protocol_coin_b: '61436182',
fee_rate: '2500',
is_pause: false,
liquidity: '1818716850',
position_manager: [Object],
rewarder_infos: [Array],
rewarder_last_updated_time: '1690775362',
tickSpacing: 60,
ticks_handle: '0xba76b336b750760b26a524f8c56e8b74a6f247739e15c423cba1d2171dfaf5f1',
uri: 'https://bq7bkvdje7gvgmv66hrxdy7wx5h5ggtrrnmt66rdkkehb64rvz3q.arweave.net/DD4VVGknzVMyvvHjceP2v0_TGnGLWT96I1KIcPuRrnc',
index: 8,
name: 'USDC-ETH[60]'
}
]
}
*/
3. Retrieve one pool
use sdk.Pool.getPool()
method
Function input params
poolID:pool address
forceRefresh: if refresh in cache.
Example
async function retrieveOnePool() {
const pool = await TestnetSDK.Pool.getPool('0xbed3136f15b0ea649fb94bcdf9d3728fb82ba1c3e189bf6062d78ff547850054')
console.log({ pool })
}
//retrieveOnePool()
/*{
pool: {
poolAddress: '0xbed3136f15b0ea649fb94bcdf9d3728fb82ba1c3e189bf6062d78ff547850054',
poolType: '0x0868b71c0cba55bf0faf6c40df8c179c67a4d0ba0e79965b68b3d72d7dfbf666::pool::Pool<0x26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc::usdt::USDT, 0x26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc::cetus::CETUS>',
coinTypeA: '0x26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc::usdt::USDT',
coinTypeB: '0x26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc::cetus::CETUS',
coinAmountA: '301095941257',
coinAmountB: '7744151970817830',
current_sqrt_price: '2958038090622808503233',
current_tick_index: 101552,
fee_growth_global_a: '105486819403232',
fee_growth_global_b: '5375007645466054573',
fee_protocol_coin_a: '57258995',
fee_protocol_coin_b: '2345233787348',
fee_rate: '2500',
is_pause: false,
liquidity: '48272892630439',
position_manager: {
positions_handle: '0x5cb2c58574b34cd13dbd177bef53ab52b814131d0b684cf2b53f1d5d31d2d9f5',
size: '4'
},
rewarder_infos: [ [Object] ],
rewarder_last_updated_time: '1690775362',
tickSpacing: 60,
ticks_handle: '0x7ac1074ec3dc1bcbffc4fdaa366464a9402f17a36a2bfd81afa0ee97230dcf95',
uri: 'https://bq7bkvdje7gvgmv66hrxdy7wx5h5ggtrrnmt66rdkkehb64rvz3q.arweave.net/DD4VVGknzVMyvvHjceP2v0_TGnGLWT96I1KIcPuRrnc',
index: 47,
name: 'USDT-CETUS[60]'
}
}
*/
4. Retrieve one pool by coin types and fee rate
use sdk.Pool.
getPoolByCoins()
method
Function input params
coinTypes:coin types array.
feeRate(Option): fee rate number.
Example
async function getPoolByCoins() {
const coinA = '0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN'
const coinB = '0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN'
const pools = await sdk.Pool.getPoolByCoins([coinA, coinB])
console.log('find pools by cointypes', pools)
}
//getPoolByCoins()
/*[
{
poolAddress: '0xc8d7a1503dc2f9f5b05449a87d8733593e2f0f3e7bffd90541252782e4d2ca20',
poolType: '0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35689b2fb::pool::Pool<0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN, 0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN>',
coinTypeA: '0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN',
coinTypeB: '0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN',
coinAmountA: '28955507725676',
coinAmountB: '10709774839936',
current_sqrt_price: '18450710277837054194',
current_tick_index: 4,
fee_growth_global_a: '68356588248388',
fee_growth_global_b: '68640314597926',
fee_protocol_coin_a: '252354404',
fee_protocol_coin_b: '181369214',
fee_rate: '100',
is_pause: false,
liquidity: '272265400952922972',
position_manager: {
positions_handle: '0x305866847f16ec900dc066e54664e4b0acd60115649de73586e544e2750658ae',
size: '4382'
},
rewarder_infos: [ [Object], [Object], [Object] ],
rewarder_last_updated_time: '1724747641',
tickSpacing: 2,
ticks_handle: '0x471d30a44388756ae2aae81e2ed313e7cce31b767b688936abd6930eeecd93e2',
uri: 'https://reb6vnedll4q6tlu63cmk7iu3y252525bgh3zf7tq5onis572pfq.arweave.net/iQPqtINa-Q9NdPbExX0U3jXdd10Jj7yX84dc1Eu_08s',
index: 1,
name: 'COIN-COIN[2]'
},
{
poolAddress: '0x737fa000d04878cdbc6a039e7741408c77cff4a573776aba7ec3bfc585d012d5',
poolType: '0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35689b2fb::pool::Pool<0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN, 0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN>',
coinTypeA: '0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN',
coinTypeB: '0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN',
coinAmountA: '18390698',
coinAmountB: '19254697',
current_sqrt_price: '18452109549321419309',
current_tick_index: 5,
fee_growth_global_a: '7218122745989279',
fee_growth_global_b: '7253325707896047',
fee_protocol_coin_a: '295931',
fee_protocol_coin_b: '181754',
fee_rate: '10000',
is_pause: false,
liquidity: '1662852544',
position_manager: {
positions_handle: '0x25d083bc89bbb45e38ca987da3733a6b4797d9ab79f5eeecbf7f50d988664082',
size: '5'
},
rewarder_infos: [],
rewarder_last_updated_time: '1721198005',
tickSpacing: 200,
ticks_handle: '0xcaf5d0883df638a6ee03393a8d6635ef8d38b2a0b8b19801f77fcfd5ff925955',
uri: 'https://bq7bkvdje7gvgmv66hrxdy7wx5h5ggtrrnmt66rdkkehb64rvz3q.arweave.net/DD4VVGknzVMyvvHjceP2v0_TGnGLWT96I1KIcPuRrnc',
index: 221,
name: 'COIN-COIN[200]'
}
]
*/
Last updated