Skip to content

Commit

Permalink
fix: Revert example change.
Browse files Browse the repository at this point in the history
  • Loading branch information
johngrantuk committed Aug 19, 2024
1 parent 6dad21a commit 9b8bc88
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions balancer-js/examples/pools/spot-price.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
const config: BalancerSdkConfig = {
network: Network.MAINNET,
rpcUrl: 'https://rpc.ankr.com/eth',
enableLogging: true
};

const dai = '0x6b175474e89094c44da98b954eedeac495271d0f';
Expand Down Expand Up @@ -56,23 +55,5 @@ async function getSpotPriceMostLiquid() {
console.log('spotPriceBalDai', spotPriceBalDai.toString());
}

async function test() {
let pool = await balancer.pools.find('0xb9debddf1d894c79d2b2d09f819ff9b856fca55200000000000000000000062a');
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));

// Every 5 seconds, log rate weWETH / WETH
// eslint-disable-next-line no-constant-condition
while (true) {
await sleep(5_000);
// Refresh pool
if (!pool) throw new Error('Pool not found');
pool = await balancer.pools.refresh(pool.id);
if (!pool) throw new Error('Pool not found');
const res = pool.calcSpotPrice('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0xcd5fe23c85820f7b72d0926fc9b05b43e359b7ee');
console.log(`timestamp: ${Date.now()} | rate = ${res}`);
}
}

test();
// getSpotPricePool();
// getSpotPriceMostLiquid();
getSpotPricePool();
getSpotPriceMostLiquid();

0 comments on commit 9b8bc88

Please sign in to comment.