From 372ce31bc2abe2eb1ef24132a59b24b6bc539df8 Mon Sep 17 00:00:00 2001 From: Tim Robinson Date: Tue, 1 Aug 2023 19:32:30 +1000 Subject: [PATCH] Add example for retrieving volume on Avalanche --- .../examples/pools/volume/volume.avalanche.ts | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 balancer-js/examples/pools/volume/volume.avalanche.ts diff --git a/balancer-js/examples/pools/volume/volume.avalanche.ts b/balancer-js/examples/pools/volume/volume.avalanche.ts new file mode 100644 index 000000000..c2ee73a88 --- /dev/null +++ b/balancer-js/examples/pools/volume/volume.avalanche.ts @@ -0,0 +1,34 @@ +/** + * Display APRs for pool ids hardcoded under `const ids` + * + * Run command: + * yarn example ./examples/pools/volume/volume.avalanche.ts + */ +import { BalancerSDK } from '@balancer-labs/sdk'; + +const sdk = new BalancerSDK({ + network: 43114, + rpcUrl: 'https://avalanche.public-rpc.com', +}); + +const { pools } = sdk; + +const main = async () => { + const pool = await pools.find( + '0xa1d14d922a575232066520eda11e27760946c991000000000000000000000012' + ); + + if (pool) { + const volume = await pools.volume(pool); + console.table([ + { + id: pool.id, + type: pool.poolType, + totalVolume: pool.totalSwapVolume, + volume, + }, + ]); + } +}; + +main();