You can use the getPool()
function to retrieve the information on a given pool by its ID (which the user will already have set up in the config.ts
file by retrieving the information through the /pools/info endpoint).
Example
import { QueryChain } from "@firefly-exchange/library-sui/dist/src/spot";
import { SuiClient } from "@firefly-exchange/library-sui";
const client = new SuiClient({ url: "https://fullnode.mainnet.sui.io:443" });
/// Parameters:
/// - poolID : The id of the the pool ex: 0x3b585786b13af1d8ea067ab37101b6513a05d2f90cfe60e8b1d9e1b46a63c4fa
async function getPool(poolID: string){
let qc = new QueryChain(client);
let pool = await qc.getPool(poolID);
return pool
}
await getPool("0x3b585786b13af1d8ea067ab37101b6513a05d2f90cfe60e8b1d9e1b46a63c4fa");
Response
{
"id":"0x3b585786b13af1d8ea067ab37101b6513a05d2f90cfe60e8b1d9e1b46a63c4fa",
"name":"SUI-USDC",
"fee_rate":2000,
"coin_a":{
"address":"0x2::sui::SUI",
"balance":"2920832186732",
"decimals":9
},
"coin_b":{
"address":"0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC",
"balance":"1602739543",
"decimals":6
},
"current_sqrt_price":"806255037806392276",
"current_tick":-62608,
"liquidity":"4779040656988",
"is_paused":false,
"ticks_manager":{
"bitmap":{
"type":"0x2::table::Table<0x714a63a0dba6da4f017b42d5d0fb78867f18bcde904868e51d951a5a6f5b7f57::i32::I32, u256>",
"fields":{
"id":{
"id":"0x32704049294b30b159a9fcb817bb94c5e566b2e6bc7d9b4fd2bb1d21464c1bc4"
},
"size":"10"
}
},
"tick_spacing":40,
"ticks":{
"type":"0x2::table::Table<0x714a63a0dba6da4f017b42d5d0fb78867f18bcde904868e51d951a5a6f5b7f57::i32::I32, 0x3492c874c1e3b3e2984e8c41b589e642d4d0a5d6459e5a9cfc2d52fd7c89c267::tick::TickInfo>",
"fields":{
"id":{
"id":"0x693c650ba84b5ad1234ebe85a557555576cc7a164bb1df7a1c3a9192ed2cb528"
},
"size":"33"
}
}
},
"observations_manager":{
"observation_cardinality":"1",
"observation_cardinality_next":"1",
"observation_index":"0",
"observations":[
{
"type":"0x3492c874c1e3b3e2984e8c41b589e642d4d0a5d6459e5a9cfc2d52fd7c89c267::oracle::Observation",
"fields":{
"initialized":true,
"seconds_per_liquidity_cumulative":"842539141425776824674392472690972178710020",
"tick_cumulative":{
"type":"0x714a63a0dba6da4f017b42d5d0fb78867f18bcde904868e51d951a5a6f5b7f57::i64::I64",
"fields":{
"bits":"18446744017535442594"
}
},
"timestamp":"1730531463"
}
}
]
}
}