From 1c0c016aae0bd5c1ce0b6e9b9f8e49c0f007fc96 Mon Sep 17 00:00:00 2001 From: johngrantuk Date: Mon, 29 Jul 2024 09:08:50 +0100 Subject: [PATCH 1/2] chore: Update to run with deploy6 (SDK@0.20.5). --- testData/README.md | 10 +++++++ testData/bun.lockb | Bin 65635 -> 65635 bytes testData/config.json | 14 +++++----- testData/package.json | 2 +- testData/src/getSwaps.ts | 2 +- .../testData/11155111-5955145-Weighted.json | 24 ++++++++-------- .../testData/11155111-5955146-Weighted.json | 12 ++++---- .../testData/11155111-6113328-Stable.json | 26 +++++++++--------- 8 files changed, 50 insertions(+), 40 deletions(-) diff --git a/testData/README.md b/testData/README.md index dd74356..72f7fa2 100644 --- a/testData/README.md +++ b/testData/README.md @@ -31,3 +31,13 @@ bun run index.ts ``` This project was created using `bun init` in bun v1.0.5. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime. + +## Updating deployment + +Dependency on `@balancer/sdk` for latest vault, etc so start by updating that. + +Run: `bun run build` to check for any breaking changes. + +Replace relevant pool addresses in `config.json`. Pools should have same tokens/balances so these can be left. + +Tests should pass. Any that fail is likely due to small changes (e.g. rounding) in SC maths. diff --git a/testData/bun.lockb b/testData/bun.lockb index b03b2d346596c73d3c3f54d67e670fd00a6de24c..1115f4e5acae4acc166cbd9e1595c358d3bdc219 100755 GIT binary patch delta 154 zcmV;L0A>HH Date: Mon, 29 Jul 2024 09:09:12 +0100 Subject: [PATCH 2/2] fix: Change BaseMath rounding to match latest SC. --- typescript/src/vault/basePoolMath.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/src/vault/basePoolMath.ts b/typescript/src/vault/basePoolMath.ts index b00df39..6f2a1e7 100644 --- a/typescript/src/vault/basePoolMath.ts +++ b/typescript/src/vault/basePoolMath.ts @@ -106,7 +106,7 @@ export function computeAddLiquiditySingleTokenExactOut( // Calculate the taxable amount, which is the difference // between the actual amount in and the non-taxable balance const nonTaxableBalance = MathSol.divDownFixed( - MathSol.mulUpFixed(newSupply, currentBalances[tokenInIndex]), + MathSol.mulDownFixed(newSupply, currentBalances[tokenInIndex]), totalSupply, ); @@ -209,7 +209,7 @@ export function computeRemoveLiquiditySingleTokenExactIn( const amountOut = currentBalances[tokenOutIndex] - newBalance; // Calculate the non-taxable balance proportionate to the BPT burnt. - const nonTaxableBalance = MathSol.divDownFixed( + const nonTaxableBalance = MathSol.divUpFixed( MathSol.mulUpFixed(newSupply, currentBalances[tokenOutIndex]), totalSupply, );