From b16b098064cef0b96cb0d979d773a105ec233fbf Mon Sep 17 00:00:00 2001 From: johngrantuk Date: Mon, 19 Aug 2024 08:47:27 +0100 Subject: [PATCH 1/3] chore: Update Readme with deprecation note. --- balancer-js/README.md | 13 +++++++++++++ balancer-js/examples/pools/spot-price.ts | 23 +++++++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/balancer-js/README.md b/balancer-js/README.md index 92c096487..cea21fe74 100644 --- a/balancer-js/README.md +++ b/balancer-js/README.md @@ -1,3 +1,16 @@ +# **Deprecation Notice** # + +This package/library is being deprecated in favor of our new and improved version located at [repo](https://github.com/balancer/b-sdk)/[package](https://www.npmjs.com/package/@balancer/sdk). + +We recommend migrating to the new repository to access the latest features (including V3 support), bug fixes, and security patches. For more information about this change, please check out the examples and documentation pages: + +* [Documentation Pages](https://docs-v3.balancer.fi/developer-reference/sdk/) +* [Examples](https://github.com/balancer/b-sdk/tree/main/examples) + +If you have any questions or need assistance with migrating to the new repository, feel free to reach out via the Dev channel on [Discord](https://discord.balancer.fi/). + +Thank you for your understanding, and we hope to see you in our new repository! + # Balancer Javascript SDK A JavaScript SDK which provides commonly used utilties for interacting with Balancer Protocol V2. diff --git a/balancer-js/examples/pools/spot-price.ts b/balancer-js/examples/pools/spot-price.ts index 4ed41add8..637b0e20d 100644 --- a/balancer-js/examples/pools/spot-price.ts +++ b/balancer-js/examples/pools/spot-price.ts @@ -16,6 +16,7 @@ import { const config: BalancerSdkConfig = { network: Network.MAINNET, rpcUrl: 'https://rpc.ankr.com/eth', + enableLogging: true }; const dai = '0x6b175474e89094c44da98b954eedeac495271d0f'; @@ -55,5 +56,23 @@ async function getSpotPriceMostLiquid() { console.log('spotPriceBalDai', spotPriceBalDai.toString()); } -getSpotPricePool(); -getSpotPriceMostLiquid(); +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(); From 6dad21ae2ca76b29d6e622445e815468b41ec0fb Mon Sep 17 00:00:00 2001 From: johngrantuk Date: Mon, 19 Aug 2024 08:48:20 +0100 Subject: [PATCH 2/3] chore: Update package for release 1.1.6. --- balancer-js/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/balancer-js/package.json b/balancer-js/package.json index a51e3cdf2..df3951921 100644 --- a/balancer-js/package.json +++ b/balancer-js/package.json @@ -1,6 +1,6 @@ { "name": "@balancer-labs/sdk", - "version": "1.1.6-beta.24", + "version": "1.1.6", "description": "JavaScript SDK for interacting with the Balancer Protocol V2", "license": "GPL-3.0-only", "homepage": "https://github.com/balancer-labs/balancer-sdk#readme", From 9b8bc88cc9fd8b8c868e05eedeb21a00d64489f9 Mon Sep 17 00:00:00 2001 From: johngrantuk Date: Mon, 19 Aug 2024 08:50:20 +0100 Subject: [PATCH 3/3] fix: Revert example change. --- balancer-js/examples/pools/spot-price.ts | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/balancer-js/examples/pools/spot-price.ts b/balancer-js/examples/pools/spot-price.ts index 637b0e20d..4ed41add8 100644 --- a/balancer-js/examples/pools/spot-price.ts +++ b/balancer-js/examples/pools/spot-price.ts @@ -16,7 +16,6 @@ import { const config: BalancerSdkConfig = { network: Network.MAINNET, rpcUrl: 'https://rpc.ankr.com/eth', - enableLogging: true }; const dai = '0x6b175474e89094c44da98b954eedeac495271d0f'; @@ -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();