Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pool Refresh Functionality Broken After Upgrade to v1.1.6-beta.23 #582

Closed
AngeloCa opened this issue Jul 3, 2024 · 1 comment · Fixed by #583
Closed

Pool Refresh Functionality Broken After Upgrade to v1.1.6-beta.23 #582

AngeloCa opened this issue Jul 3, 2024 · 1 comment · Fixed by #583

Comments

@AngeloCa
Copy link

AngeloCa commented Jul 3, 2024

Description:

After upgrading the subgraphs endpoint from version v1.1.5 to v1.1.6-beta.23, this code snippet that refreshes a pool state periodically is no longer functioning as expected. Specifically, the example pool is never refreshed.

Code Snippet:

const balancerSDK = new BalancerSDK({ network: Network.MAINNET, rpcUrl: chainData.chainConfig.nodeEndpoint });
const pool = await balancerSDK.pools.find('0xb9debddf1d894c79d2b2d09f819ff9b856fca55200000000000000000000062a');
if (!pool) throw new Error('Pool not found');
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
  await balancerSDK.data.poolsOnChain.refresh(pool);
  const res = pool.calcSpotPrice('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0xcd5fe23c85820f7b72d0926fc9b05b43e359b7ee');
  console.log(`timestamp: ${Date.now()} | rate = ${res}`);
}

Expected Behavior:
The pool state should be refreshed every 5 seconds, and the spot price should be logged correctly.

Actual Behavior:
After upgrading to v1.1.6-beta.23, the pool state is never refreshed, and the spot price remains unchanged.

@AngeloCa AngeloCa changed the title Refresh method isn't working on v1.1.6-beta.23 Pool Refresh Functionality Broken After Upgrade to v1.1.6-beta.23 Jul 3, 2024
@johngrantuk
Copy link
Member

Released a fix in v1.1.6-beta.24.

Need to update your example a bit to use pool = await balancer.pools.refresh(pool.id);

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}`);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants