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

8 update to deploy6 #31

Merged
merged 2 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions testData/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Binary file modified testData/bun.lockb
Binary file not shown.
14 changes: 7 additions & 7 deletions testData/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"testName": "Weighted",
"chainId": "11155111",
"blockNumber": "5955145",
"poolAddress": "0x7cf221fa36584f59a4f7fd7b946b8571c78e3692",
"poolAddress": "0x03bf996c7bd45b3386cb41875761d45e27eab284",
"poolType": "Weighted",
"swaps": [
{
Expand Down Expand Up @@ -48,12 +48,12 @@
"removes": [
{
"kind": "Proportional",
"bpt": "0x7cf221fa36584f59a4f7fd7b946b8571c78e3692",
"bpt": "0x03bf996c7bd45b3386cb41875761d45e27eab284",
"bptInRaw": "1000000000000000"
},
{
"kind": "SingleTokenExactIn",
"bpt": "0x7cf221fa36584f59a4f7fd7b946b8571c78e3692",
"bpt": "0x03bf996c7bd45b3386cb41875761d45e27eab284",
"bptInRaw": "10000000000000",
"token": "0xb19382073c7a0addbb56ac6af1808fa49e377b75"
},
Expand All @@ -69,7 +69,7 @@
"testName": "Weighted",
"chainId": "11155111",
"blockNumber": "5955146",
"poolAddress": "0x7cf221fa36584f59a4f7fd7b946b8571c78e3692",
"poolAddress": "0x03bf996c7bd45b3386cb41875761d45e27eab284",
"poolType": "Weighted",
"swaps": [
{
Expand All @@ -90,7 +90,7 @@
"testName": "Stable",
"chainId": "11155111",
"blockNumber": "6113328",
"poolAddress": "0x90a46864cb1f042060554592038367e9c97e17f3",
"poolAddress": "0x302b75a27e5e157f93c679dd7a25fdfcdbc1473c",
"poolType": "Stable",
"swaps": [
{
Expand Down Expand Up @@ -134,12 +134,12 @@
"removes": [
{
"kind": "Proportional",
"bpt": "0x90a46864cb1f042060554592038367e9c97e17f3",
"bpt": "0x302b75a27e5e157f93c679dd7a25fdfcdbc1473c",
"bptInRaw": "1000000000000000000"
},
{
"kind": "SingleTokenExactIn",
"bpt": "0x90a46864cb1f042060554592038367e9c97e17f3",
"bpt": "0x302b75a27e5e157f93c679dd7a25fdfcdbc1473c",
"bptInRaw": "1000000000000000000",
"token": "0x8a88124522dbbf1e56352ba3de1d9f78c143751e"
},
Expand Down
2 changes: 1 addition & 1 deletion testData/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"typescript": "^5.0.0"
},
"dependencies": {
"@balancer/sdk": "^0.18.0",
"@balancer/sdk": "^0.20.5",
"viem": "^2.16.5"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion testData/src/getSwaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async function querySwap(
decimals: 18,
}, // tokenOut
],
vaultVersion: 3 as const,
protocolVersion: 3,
inputAmountRaw:
swap.swapKind === SwapKind.GivenIn
? BigInt(swap.amountRaw)
Expand Down
24 changes: 12 additions & 12 deletions testData/testData/11155111-5955145-Weighted.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"amountRaw": "1000000000000000",
"tokenIn": "0x7b79995e5f793a07bc00c21412e50ecae098e7f9",
"tokenOut": "0xb19382073c7a0addbb56ac6af1808fa49e377b75",
"outputRaw": "659999999999999997"
"outputRaw": "749999999999999997"
},
{
"swapKind": 1,
"amountRaw": "2000000000000000",
"tokenIn": "0x7b79995e5f793a07bc00c21412e50ecae098e7f9",
"tokenOut": "0xb19382073c7a0addbb56ac6af1808fa49e377b75",
"outputRaw": "2526263131567"
"outputRaw": "2200880352142"
}
],
"adds": [
Expand All @@ -22,12 +22,12 @@
"1000000000000000",
"1000000000000000"
],
"bptOutRaw": "13449916717103480"
"bptOutRaw": "14353025157871904"
},
{
"kind": "SingleToken",
"inputAmountsRaw": [
"710703280082",
"667614172704",
"0"
],
"bptOutRaw": "10000000000000"
Expand All @@ -37,16 +37,16 @@
{
"kind": "Proportional",
"amountsOutRaw": [
"35355339059328",
"28284271247462464"
"31622776601684",
"31622776601684425"
],
"bptInRaw": "1000000000000000"
},
{
"kind": "SingleTokenExactIn",
"amountsOutRaw": [
"0",
"562837197824497"
"600814755431991"
],
"bptInRaw": "10000000000000"
},
Expand All @@ -56,14 +56,14 @@
"0",
"1000000000000000000"
],
"bptInRaw": "19042597768006160"
"bptInRaw": "17622950036847618"
}
],
"pool": {
"chainId": "11155111",
"blockNumber": "5955145",
"poolType": "Weighted",
"poolAddress": "0x7cf221fa36584f59a4f7fd7b946b8571c78e3692",
"poolAddress": "0x03bf996c7bd45b3386cb41875761d45e27eab284",
"tokens": [
"0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9",
"0xb19382073c7A0aDdbb56Ac6AF1808Fa49e377B75"
Expand All @@ -76,11 +76,11 @@
"500000000000000000",
"500000000000000000"
],
"swapFee": "10000000000000000",
"totalSupply": "141421356237306671",
"swapFee": "100000000000000000",
"totalSupply": "158113883008415798",
"balancesLiveScaled18": [
"5000000000000000",
"4000000000000000000"
"5000000000000000000"
],
"tokenRates": [
"1000000000000000000",
Expand Down
12 changes: 6 additions & 6 deletions testData/testData/11155111-5955146-Weighted.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
"amountRaw": "700000000000000",
"tokenIn": "0x7b79995e5f793a07bc00c21412e50ecae098e7f9",
"tokenOut": "0xb19382073c7a0addbb56ac6af1808fa49e377b75",
"outputRaw": "486315789473684210"
"outputRaw": "552631578947368420"
},
{
"swapKind": 1,
"amountRaw": "300000000000000",
"tokenIn": "0x7b79995e5f793a07bc00c21412e50ecae098e7f9",
"tokenOut": "0xb19382073c7a0addbb56ac6af1808fa49e377b75",
"outputRaw": "378778408382"
"outputRaw": "330019801190"
}
],
"pool": {
"chainId": "11155111",
"blockNumber": "5955146",
"poolType": "Weighted",
"poolAddress": "0x7cf221fa36584f59a4f7fd7b946b8571c78e3692",
"poolAddress": "0x03bf996c7bd45b3386cb41875761d45e27eab284",
"tokens": [
"0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9",
"0xb19382073c7A0aDdbb56Ac6AF1808Fa49e377B75"
Expand All @@ -32,11 +32,11 @@
"500000000000000000",
"500000000000000000"
],
"swapFee": "10000000000000000",
"totalSupply": "141421356237306671",
"swapFee": "100000000000000000",
"totalSupply": "158113883008415798",
"balancesLiveScaled18": [
"5000000000000000",
"4000000000000000000"
"5000000000000000000"
],
"tokenRates": [
"1000000000000000000",
Expand Down
26 changes: 13 additions & 13 deletions testData/testData/11155111-6113328-Stable.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"amountRaw": "1000000000000000",
"tokenIn": "0x8a88124522dbbf1e56352ba3de1d9f78c143751e",
"tokenOut": "0xde46e43f46ff74a23a65ebb0580cbe3dfe684a17",
"outputRaw": "494999999999999873581"
"outputRaw": "494999999999999872727"
},
{
"swapKind": 1,
"amountRaw": "2000000000000000",
"tokenIn": "0x8a88124522dbbf1e56352ba3de1d9f78c143751e",
"tokenOut": "0xde46e43f46ff74a23a65ebb0580cbe3dfe684a17",
"outputRaw": "2106"
"outputRaw": "2132"
}
],
"adds": [
Expand All @@ -22,7 +22,7 @@
"1000000000000000",
"1000000000000000"
],
"bptOutRaw": "155373339454198795190224130"
"bptOutRaw": "155907863911003536972201225"
},
{
"kind": "SingleToken",
Expand All @@ -37,15 +37,15 @@
{
"kind": "Proportional",
"amountsOutRaw": [
"476994",
"476994620324528499"
"474180",
"474180334846679499"
],
"bptInRaw": "1000000000000000000"
},
{
"kind": "SingleTokenExactIn",
"amountsOutRaw": [
"969137",
"969600",
"0"
],
"bptInRaw": "1000000000000000000"
Expand All @@ -56,14 +56,14 @@
"1000000",
"0"
],
"bptInRaw": "1031871475203360365"
"bptInRaw": "1031378931593220589"
}
],
"pool": {
"chainId": "11155111",
"blockNumber": "6113328",
"poolType": "Stable",
"poolAddress": "0x90a46864cb1f042060554592038367e9c97e17f3",
"poolAddress": "0x302b75a27e5e157f93c679dd7a25fdfcdbc1473c",
"tokens": [
"0x8A88124522dbBF1E56352ba3DE1d9F78C143751e",
"0xDE46e43F46ff74A23a65EBb0580cbe3dFE684a17"
Expand All @@ -73,14 +73,14 @@
"1000000000000000000"
],
"swapFee": "10000000000000000",
"totalSupply": "1048229851439035843046",
"totalSupply": "1054451151293881721519",
"balancesLiveScaled18": [
"514790820812959778500",
"536527062318691819000"
"518892950064978587500",
"547641471206153917000"
],
"tokenRates": [
"1029581641625919557",
"1073054124637383638"
"1037785900129957175",
"1095282942412307834"
],
"amp": "1000000"
}
Expand Down
4 changes: 2 additions & 2 deletions typescript/src/vault/basePoolMath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);

Expand Down Expand Up @@ -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,
);
Expand Down
Loading