Skip to content

Commit

Permalink
Merge pull request #506 from balancer/avalanche-volume
Browse files Browse the repository at this point in the history
Add example for retrieving volume on Avalanche
  • Loading branch information
johngrantuk committed Aug 1, 2023
2 parents ca46dd6 + d97eaf2 commit ce471de
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
34 changes: 34 additions & 0 deletions balancer-js/examples/pools/volume/volume.avalanche.ts
Original file line number Diff line number Diff line change
@@ -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();
2 changes: 2 additions & 0 deletions balancer-js/src/lib/constants/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,8 @@ export const BALANCER_NETWORK_CONFIG: Record<Network, BalancerNetworkConfig> = {
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-avalanche-v2',
gaugesSubgraph:
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-gauges-avalanche',
blockNumberSubgraph:
'https://api.thegraph.com/subgraphs/name/iliaazhel/avalanche-blocks',
},
thirdParty: {
coingecko: {
Expand Down

0 comments on commit ce471de

Please sign in to comment.