Retrieve clmm pools
1. Retrieve all pools
Method: sdk.Pool.getPoolsWithPage()
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
Method: sdk.Pool.getPoolsWithPage()
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 = [
'0x0128aade80123e3f6c5c0eac1a2dee2512bbdc92c9c1b386b0fd66e6cddfaa72',
'0xd2e4df21b920fba945aa8ad148069a196f0680879c40118beabc3046e2cd8d24',
]
// 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 })
}
3. Retrieve one pool
Method: sdk.Pool.getPool()
Params:
poolID
:pool addressforceRefresh
: if refresh in cache.
Example
async function retrieveOnePool() {
const pool = await TestnetSDK.Pool.getPool('0xd2e4df21b920fba945aa8ad148069a196f0680879c40118beabc3046e2cd8d24')
console.log({ pool })
}
4. Retrieve one pool by coin types and fee rate
Method: sdk.Pool.getPoolByCoins()
Params:
coinTypes
:coin types array.feeRate(Option)
: fee rate number.
Example
async function getPoolByCoins() {
const coinA = '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC'
const coinB = '0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI'
const pools = await sdk.Pool.getPoolByCoins([coinA, coinB])
console.log('find pools by cointypes', pools)
}
Last updated