diff --git a/.changeset/light-sloths-draw.md b/.changeset/light-sloths-draw.md new file mode 100644 index 000000000..437720120 --- /dev/null +++ b/.changeset/light-sloths-draw.md @@ -0,0 +1,5 @@ +--- +'backend': patch +--- + +Update SDK and Balancer Maths dependencies diff --git a/modules/sor/sor-debug.test.ts b/modules/sor/sor-debug.test.ts index 60d138dff..7b292e55f 100644 --- a/modules/sor/sor-debug.test.ts +++ b/modules/sor/sor-debug.test.ts @@ -36,29 +36,23 @@ describe('sor debugging', () => { expect(parseFloat(swaps.returnAmount)).toBeGreaterThan(0); }, 5000000); - it('sor v3 sepolia eth->usdc', async () => { - const chain = Chain.MAINNET; + it('sor v3 sepolia usdc->usdt', async () => { + const chain = Chain.SEPOLIA; const chainId = Object.keys(chainIdToChain).find((key) => chainIdToChain[key] === chain) as string; initRequestScopedContext(); setRequestScopedContextValue('chainId', chainId); //only do once before starting to debug - // await PoolController().reloadPoolsV3(chain); + await PoolController().reloadPoolsV3(chain); const swaps = await sorService.getSorSwapPaths({ chain, - tokenIn: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', - tokenOut: '0x220e4201aa472262df2c24dd8069243cf4b76c12', + tokenIn: '0x94a9d9ac8a22534e3faca9f4e7f2e2cf85d5e4c8', // usdc-aave + tokenOut: '0xaa8e23fb1079ea71e0a56f48a2aa51851d8433d0', // usdt-aave swapType: 'EXACT_IN', - swapAmount: '100', - queryBatchSwap: false, + swapAmount: '1', useProtocolVersion: 3, - considerPoolsWithHooks: true, - // callDataInput: { - // receiver: '0xb5e6b895734409Df411a052195eb4EE7e40d8696', - // sender: '0xb5e6b895734409Df411a052195eb4EE7e40d8696', - // slippagePercentage: '0.1', - // }, + poolIds: ['0x1017d7b181ab63ceeb36d96c52a8056e02b7edd0'], // boosted pool stataUSDC/stataUSDT }); console.log(swaps.returnAmount); diff --git a/modules/sor/sorV2/lib/poolsV3/stable/stablePool.ts b/modules/sor/sorV2/lib/poolsV3/stable/stablePool.ts index 5ac5a8699..e5fdd4e92 100644 --- a/modules/sor/sorV2/lib/poolsV3/stable/stablePool.ts +++ b/modules/sor/sorV2/lib/poolsV3/stable/stablePool.ts @@ -255,14 +255,15 @@ export class StablePool implements BasePoolV3 { public getPoolState(): StableState { return { - poolType: 'Stable', + poolType: 'STABLE', + poolAddress: this.address, swapFee: this.swapFee, balancesLiveScaled18: this.tokens.map((t) => t.scale18), tokenRates: this.tokens.map((t) => t.rate), totalSupply: this.totalShares, amp: this.amp, tokens: this.tokens.map((t) => t.token.address), - scalingFactors: this.tokens.map((t) => t.scalar * WAD), + scalingFactors: this.tokens.map((t) => t.scalar), aggregateSwapFee: 0n, }; } diff --git a/modules/sor/sorV2/lib/poolsV3/weighted/weightedPool.ts b/modules/sor/sorV2/lib/poolsV3/weighted/weightedPool.ts index 48a5c39b1..2b853cad2 100644 --- a/modules/sor/sorV2/lib/poolsV3/weighted/weightedPool.ts +++ b/modules/sor/sorV2/lib/poolsV3/weighted/weightedPool.ts @@ -251,14 +251,15 @@ export class WeightedPoolV3 implements BasePoolV3 { public getPoolState(): WeightedState { return { - poolType: 'Weighted', + poolType: 'WEIGHTED', + poolAddress: this.address, swapFee: this.swapFee, balancesLiveScaled18: this.tokens.map((t) => t.scale18), tokenRates: this.tokens.map((_) => WAD), totalSupply: this.totalShares, weights: this.tokens.map((t) => t.weight), tokens: this.tokens.map((t) => t.token.address), - scalingFactors: this.tokens.map((t) => t.scalar * WAD), + scalingFactors: this.tokens.map((t) => t.scalar), aggregateSwapFee: 0n, }; } diff --git a/modules/sor/sorV2/sorPathService.ts b/modules/sor/sorV2/sorPathService.ts index 527c660aa..14428da08 100644 --- a/modules/sor/sorV2/sorPathService.ts +++ b/modules/sor/sorV2/sorPathService.ts @@ -34,6 +34,7 @@ import { SwapKind, ExactInQueryOutput, ExactOutQueryOutput, + VAULT, } from '@balancer/sdk'; import { PathWithAmount } from './lib/path'; import { calculatePriceImpact, getInputAmount, getOutputAmount } from './lib/utils/helpers'; @@ -271,6 +272,7 @@ class SorPathService implements SwapService { swapKind, expectedAmountOut: outputAmount, amountIn: inputAmount, + to: VAULT[parseInt(chainToIdMap[chain])], }, slippage: Slippage.fromPercentage(`${parseFloat(callDataInput.slippagePercentage)}`), deadline: callDataInput.deadline ? BigInt(callDataInput.deadline) : 999999999999999999n, @@ -290,6 +292,7 @@ class SorPathService implements SwapService { swapKind, expectedAmountIn: inputAmount, amountOut: outputAmount, + to: VAULT[parseInt(chainToIdMap[chain])], }, slippage: Slippage.fromPercentage(callDataInput.slippagePercentage as `${number}`), deadline: callDataInput.deadline ? BigInt(callDataInput.deadline) : 999999999999999999n, diff --git a/modules/subgraphs/blocks-subgraph/generated/blocks-subgraph-types.ts b/modules/subgraphs/blocks-subgraph/generated/blocks-subgraph-types.ts index 6a6ec11fb..a8e25e133 100644 --- a/modules/subgraphs/blocks-subgraph/generated/blocks-subgraph-types.ts +++ b/modules/subgraphs/blocks-subgraph/generated/blocks-subgraph-types.ts @@ -27,38 +27,20 @@ export enum Aggregation_Interval { export type Block = { __typename?: 'Block'; - /** address of the beneficiary to whom the mining rewards were given */ - author: Scalars['Bytes']; - /** the minimum gas fee a user must pay to include a transaction in the block */ - baseFeePerGas?: Maybe; - /** number of leading zeroes that are required in the resulting block hash for it to be considered valid - PoW only */ - difficulty: Scalars['BigInt']; - /** maximum gas allowed in this block */ - gasLimit: Scalars['BigInt']; - /** the actual amount of gas used in this block */ - gasUsed: Scalars['BigInt']; - /** the block hash */ - hash: Scalars['Bytes']; - /** the block hash */ + author?: Maybe; + difficulty?: Maybe; + gasLimit?: Maybe; + gasUsed?: Maybe; id: Scalars['ID']; - /** the block number */ number: Scalars['BigInt']; - /** hash of the parent block */ - parentHash: Scalars['Bytes']; - /** hash of the transaction receipts trie */ - receiptsRoot: Scalars['Bytes']; - /** the size of the block in bytes */ + parentHash?: Maybe; + receiptsRoot?: Maybe; size?: Maybe; - /** root hash for the global state after applying changes in this block */ - stateRoot: Scalars['Bytes']; - /** the block time */ + stateRoot?: Maybe; timestamp: Scalars['BigInt']; - /** the sum of the Ethash mining difficulty for all blocks up to some specific point in the blockchain */ - totalDifficulty: Scalars['BigInt']; - /** root hash of the transactions in the payload */ - transactionsRoot: Scalars['Bytes']; - /** hash of the uncle block */ - unclesHash: Scalars['Bytes']; + totalDifficulty?: Maybe; + transactionsRoot?: Maybe; + unclesHash?: Maybe; }; export type BlockChangedFilter = { @@ -69,24 +51,26 @@ export type Block_Filter = { /** Filter for the block changed event. */ _change_block?: InputMaybe; and?: InputMaybe>>; - author?: InputMaybe; - author_contains?: InputMaybe; - author_gt?: InputMaybe; - author_gte?: InputMaybe; - author_in?: InputMaybe>; - author_lt?: InputMaybe; - author_lte?: InputMaybe; - author_not?: InputMaybe; - author_not_contains?: InputMaybe; - author_not_in?: InputMaybe>; - baseFeePerGas?: InputMaybe; - baseFeePerGas_gt?: InputMaybe; - baseFeePerGas_gte?: InputMaybe; - baseFeePerGas_in?: InputMaybe>; - baseFeePerGas_lt?: InputMaybe; - baseFeePerGas_lte?: InputMaybe; - baseFeePerGas_not?: InputMaybe; - baseFeePerGas_not_in?: InputMaybe>; + author?: InputMaybe; + author_contains?: InputMaybe; + author_contains_nocase?: InputMaybe; + author_ends_with?: InputMaybe; + author_ends_with_nocase?: InputMaybe; + author_gt?: InputMaybe; + author_gte?: InputMaybe; + author_in?: InputMaybe>; + author_lt?: InputMaybe; + author_lte?: InputMaybe; + author_not?: InputMaybe; + author_not_contains?: InputMaybe; + author_not_contains_nocase?: InputMaybe; + author_not_ends_with?: InputMaybe; + author_not_ends_with_nocase?: InputMaybe; + author_not_in?: InputMaybe>; + author_not_starts_with?: InputMaybe; + author_not_starts_with_nocase?: InputMaybe; + author_starts_with?: InputMaybe; + author_starts_with_nocase?: InputMaybe; difficulty?: InputMaybe; difficulty_gt?: InputMaybe; difficulty_gte?: InputMaybe; @@ -111,16 +95,6 @@ export type Block_Filter = { gasUsed_lte?: InputMaybe; gasUsed_not?: InputMaybe; gasUsed_not_in?: InputMaybe>; - hash?: InputMaybe; - hash_contains?: InputMaybe; - hash_gt?: InputMaybe; - hash_gte?: InputMaybe; - hash_in?: InputMaybe>; - hash_lt?: InputMaybe; - hash_lte?: InputMaybe; - hash_not?: InputMaybe; - hash_not_contains?: InputMaybe; - hash_not_in?: InputMaybe>; id?: InputMaybe; id_gt?: InputMaybe; id_gte?: InputMaybe; @@ -138,26 +112,46 @@ export type Block_Filter = { number_not?: InputMaybe; number_not_in?: InputMaybe>; or?: InputMaybe>>; - parentHash?: InputMaybe; - parentHash_contains?: InputMaybe; - parentHash_gt?: InputMaybe; - parentHash_gte?: InputMaybe; - parentHash_in?: InputMaybe>; - parentHash_lt?: InputMaybe; - parentHash_lte?: InputMaybe; - parentHash_not?: InputMaybe; - parentHash_not_contains?: InputMaybe; - parentHash_not_in?: InputMaybe>; - receiptsRoot?: InputMaybe; - receiptsRoot_contains?: InputMaybe; - receiptsRoot_gt?: InputMaybe; - receiptsRoot_gte?: InputMaybe; - receiptsRoot_in?: InputMaybe>; - receiptsRoot_lt?: InputMaybe; - receiptsRoot_lte?: InputMaybe; - receiptsRoot_not?: InputMaybe; - receiptsRoot_not_contains?: InputMaybe; - receiptsRoot_not_in?: InputMaybe>; + parentHash?: InputMaybe; + parentHash_contains?: InputMaybe; + parentHash_contains_nocase?: InputMaybe; + parentHash_ends_with?: InputMaybe; + parentHash_ends_with_nocase?: InputMaybe; + parentHash_gt?: InputMaybe; + parentHash_gte?: InputMaybe; + parentHash_in?: InputMaybe>; + parentHash_lt?: InputMaybe; + parentHash_lte?: InputMaybe; + parentHash_not?: InputMaybe; + parentHash_not_contains?: InputMaybe; + parentHash_not_contains_nocase?: InputMaybe; + parentHash_not_ends_with?: InputMaybe; + parentHash_not_ends_with_nocase?: InputMaybe; + parentHash_not_in?: InputMaybe>; + parentHash_not_starts_with?: InputMaybe; + parentHash_not_starts_with_nocase?: InputMaybe; + parentHash_starts_with?: InputMaybe; + parentHash_starts_with_nocase?: InputMaybe; + receiptsRoot?: InputMaybe; + receiptsRoot_contains?: InputMaybe; + receiptsRoot_contains_nocase?: InputMaybe; + receiptsRoot_ends_with?: InputMaybe; + receiptsRoot_ends_with_nocase?: InputMaybe; + receiptsRoot_gt?: InputMaybe; + receiptsRoot_gte?: InputMaybe; + receiptsRoot_in?: InputMaybe>; + receiptsRoot_lt?: InputMaybe; + receiptsRoot_lte?: InputMaybe; + receiptsRoot_not?: InputMaybe; + receiptsRoot_not_contains?: InputMaybe; + receiptsRoot_not_contains_nocase?: InputMaybe; + receiptsRoot_not_ends_with?: InputMaybe; + receiptsRoot_not_ends_with_nocase?: InputMaybe; + receiptsRoot_not_in?: InputMaybe>; + receiptsRoot_not_starts_with?: InputMaybe; + receiptsRoot_not_starts_with_nocase?: InputMaybe; + receiptsRoot_starts_with?: InputMaybe; + receiptsRoot_starts_with_nocase?: InputMaybe; size?: InputMaybe; size_gt?: InputMaybe; size_gte?: InputMaybe; @@ -166,16 +160,26 @@ export type Block_Filter = { size_lte?: InputMaybe; size_not?: InputMaybe; size_not_in?: InputMaybe>; - stateRoot?: InputMaybe; - stateRoot_contains?: InputMaybe; - stateRoot_gt?: InputMaybe; - stateRoot_gte?: InputMaybe; - stateRoot_in?: InputMaybe>; - stateRoot_lt?: InputMaybe; - stateRoot_lte?: InputMaybe; - stateRoot_not?: InputMaybe; - stateRoot_not_contains?: InputMaybe; - stateRoot_not_in?: InputMaybe>; + stateRoot?: InputMaybe; + stateRoot_contains?: InputMaybe; + stateRoot_contains_nocase?: InputMaybe; + stateRoot_ends_with?: InputMaybe; + stateRoot_ends_with_nocase?: InputMaybe; + stateRoot_gt?: InputMaybe; + stateRoot_gte?: InputMaybe; + stateRoot_in?: InputMaybe>; + stateRoot_lt?: InputMaybe; + stateRoot_lte?: InputMaybe; + stateRoot_not?: InputMaybe; + stateRoot_not_contains?: InputMaybe; + stateRoot_not_contains_nocase?: InputMaybe; + stateRoot_not_ends_with?: InputMaybe; + stateRoot_not_ends_with_nocase?: InputMaybe; + stateRoot_not_in?: InputMaybe>; + stateRoot_not_starts_with?: InputMaybe; + stateRoot_not_starts_with_nocase?: InputMaybe; + stateRoot_starts_with?: InputMaybe; + stateRoot_starts_with_nocase?: InputMaybe; timestamp?: InputMaybe; timestamp_gt?: InputMaybe; timestamp_gte?: InputMaybe; @@ -192,26 +196,46 @@ export type Block_Filter = { totalDifficulty_lte?: InputMaybe; totalDifficulty_not?: InputMaybe; totalDifficulty_not_in?: InputMaybe>; - transactionsRoot?: InputMaybe; - transactionsRoot_contains?: InputMaybe; - transactionsRoot_gt?: InputMaybe; - transactionsRoot_gte?: InputMaybe; - transactionsRoot_in?: InputMaybe>; - transactionsRoot_lt?: InputMaybe; - transactionsRoot_lte?: InputMaybe; - transactionsRoot_not?: InputMaybe; - transactionsRoot_not_contains?: InputMaybe; - transactionsRoot_not_in?: InputMaybe>; - unclesHash?: InputMaybe; - unclesHash_contains?: InputMaybe; - unclesHash_gt?: InputMaybe; - unclesHash_gte?: InputMaybe; - unclesHash_in?: InputMaybe>; - unclesHash_lt?: InputMaybe; - unclesHash_lte?: InputMaybe; - unclesHash_not?: InputMaybe; - unclesHash_not_contains?: InputMaybe; - unclesHash_not_in?: InputMaybe>; + transactionsRoot?: InputMaybe; + transactionsRoot_contains?: InputMaybe; + transactionsRoot_contains_nocase?: InputMaybe; + transactionsRoot_ends_with?: InputMaybe; + transactionsRoot_ends_with_nocase?: InputMaybe; + transactionsRoot_gt?: InputMaybe; + transactionsRoot_gte?: InputMaybe; + transactionsRoot_in?: InputMaybe>; + transactionsRoot_lt?: InputMaybe; + transactionsRoot_lte?: InputMaybe; + transactionsRoot_not?: InputMaybe; + transactionsRoot_not_contains?: InputMaybe; + transactionsRoot_not_contains_nocase?: InputMaybe; + transactionsRoot_not_ends_with?: InputMaybe; + transactionsRoot_not_ends_with_nocase?: InputMaybe; + transactionsRoot_not_in?: InputMaybe>; + transactionsRoot_not_starts_with?: InputMaybe; + transactionsRoot_not_starts_with_nocase?: InputMaybe; + transactionsRoot_starts_with?: InputMaybe; + transactionsRoot_starts_with_nocase?: InputMaybe; + unclesHash?: InputMaybe; + unclesHash_contains?: InputMaybe; + unclesHash_contains_nocase?: InputMaybe; + unclesHash_ends_with?: InputMaybe; + unclesHash_ends_with_nocase?: InputMaybe; + unclesHash_gt?: InputMaybe; + unclesHash_gte?: InputMaybe; + unclesHash_in?: InputMaybe>; + unclesHash_lt?: InputMaybe; + unclesHash_lte?: InputMaybe; + unclesHash_not?: InputMaybe; + unclesHash_not_contains?: InputMaybe; + unclesHash_not_contains_nocase?: InputMaybe; + unclesHash_not_ends_with?: InputMaybe; + unclesHash_not_ends_with_nocase?: InputMaybe; + unclesHash_not_in?: InputMaybe>; + unclesHash_not_starts_with?: InputMaybe; + unclesHash_not_starts_with_nocase?: InputMaybe; + unclesHash_starts_with?: InputMaybe; + unclesHash_starts_with_nocase?: InputMaybe; }; export type Block_Height = { @@ -222,11 +246,9 @@ export type Block_Height = { export enum Block_OrderBy { Author = 'author', - BaseFeePerGas = 'baseFeePerGas', Difficulty = 'difficulty', GasLimit = 'gasLimit', GasUsed = 'gasUsed', - Hash = 'hash', Id = 'id', Number = 'number', ParentHash = 'parentHash', diff --git a/package.json b/package.json index cd9add127..781e14bd2 100644 --- a/package.json +++ b/package.json @@ -22,9 +22,9 @@ "@aws-sdk/client-cloudwatch": "^3.388.0", "@aws-sdk/client-secrets-manager": "^3.195.0", "@aws-sdk/client-sqs": "^3.137.0", - "@balancer-labs/balancer-maths": "^0.0.11", + "@balancer-labs/balancer-maths": "^0.0.19", "@balancer-labs/sdk": "github:beethovenxfi/balancer-sdk#beethovenx-master", - "@balancer/sdk": "0.22.2", + "@balancer/sdk": "^0.33.3", "@ethersproject/address": "^5.6.0", "@ethersproject/bignumber": "^5.6.0", "@ethersproject/constants": "^5.6.0", diff --git a/yarn.lock b/yarn.lock index 9b145566d..c1f8e5c75 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2513,10 +2513,10 @@ "@babel/helper-validator-identifier" "^7.19.1" to-fast-properties "^2.0.0" -"@balancer-labs/balancer-maths@^0.0.11": - version "0.0.11" - resolved "https://registry.yarnpkg.com/@balancer-labs/balancer-maths/-/balancer-maths-0.0.11.tgz#9e502a97f4ae7be98ca859f3a9888b93391f92cc" - integrity sha512-QHMqLMsG+owsPyrXjVJfq2IAWalnSpIkahnpsc73gDr95EenQGvexvuhMrrqoHkP9HQ2KyYdjv5u28+bGIvfQQ== +"@balancer-labs/balancer-maths@^0.0.19": + version "0.0.19" + resolved "https://registry.yarnpkg.com/@balancer-labs/balancer-maths/-/balancer-maths-0.0.19.tgz#d3b92c4b17caca67894806bd7768af1ea31cb956" + integrity sha512-x8t17q8fbXYZJSaidr4BWBg3O9jVnF6xoAsoMWWyUd6AnaxPyFnxAGs76+iQln4WEmC7S5G5uufWJ0OefvcqXQ== "@balancer-labs/sdk@github:beethovenxfi/balancer-sdk#beethovenx-master": version "0.1.1" @@ -2535,10 +2535,10 @@ graphology "^0.24.1" isomorphic-fetch "^2.2.1" -"@balancer/sdk@0.22.2": - version "0.22.2" - resolved "https://registry.yarnpkg.com/@balancer/sdk/-/sdk-0.22.2.tgz#d725cf8301948a5e28e4f4e4304e983d160ab8eb" - integrity sha512-IF/2Ar10/XSCQ7noGGLlGM8KLp1qx/y8IvnbVB7KpbW1SR2zDsQkxEWRTQiPqcj5e0s40ihHrklcDp8vlspDtA== +"@balancer/sdk@^0.33.3": + version "0.33.3" + resolved "https://registry.yarnpkg.com/@balancer/sdk/-/sdk-0.33.3.tgz#63af5c66caf92dd95372e3259e6ffd9b795c8294" + integrity sha512-K9VqcmvaRHb0xEZFJIvw+6A8yGr3E5kGGo1f1H3uePH1UiL6TrEgJPy277IqnFnFEnBmuZpTtVx6yuTCTRWcWg== dependencies: decimal.js-light "^2.5.1" lodash.clonedeep "^4.5.0"