From b7b28c276e9bd21ac559abe45b96d5aec950f272 Mon Sep 17 00:00:00 2001 From: Alberto Gualis Date: Mon, 16 Sep 2024 18:19:13 +0200 Subject: [PATCH 1/7] feat: adapt V2 and V3 buildCall parameters in handlers --- lib/config/networks/sepolia.ts | 2 +- lib/debug-helpers.ts | 2 ++ .../pool/actions/LiquidityActionHelpers.ts | 11 +++++++++- .../UnbalancedAddLiquidity.handler.ts | 22 ++++++++++++++----- .../add-liquidity/useAddLiquiditySteps.tsx | 5 +++-- .../ProportionalRemoveLiquidity.handler.ts | 16 +++++++++----- .../SingleTokenRemoveLiquidity.handler.ts | 20 ++++++++++++----- 7 files changed, 58 insertions(+), 20 deletions(-) diff --git a/lib/config/networks/sepolia.ts b/lib/config/networks/sepolia.ts index 6a8c36c87..4811fa377 100644 --- a/lib/config/networks/sepolia.ts +++ b/lib/config/networks/sepolia.ts @@ -31,7 +31,7 @@ const networkConfig: NetworkConfig = { multicall2: '0xca11bde05977b3631167028862be2a173976ca11', balancer: { vaultV2: '0xBA12222222228d8Ba445958a75a0704d566BF2C8', - vaultV3: '0xD5584b37D1845fFeD958C2d94bC675603DdCce68', + vaultV3: '0x0EF1c156a7986F394d90eD1bEeA6483Cc435F542', relayerV6: '0x7852fB9d0895e6e8b3EedA553c03F6e2F9124dF9', minter: '0x1783Cd84b3d01854A96B4eD5843753C2CcbD574A', }, diff --git a/lib/debug-helpers.ts b/lib/debug-helpers.ts index a399cf86d..a1111c7df 100644 --- a/lib/debug-helpers.ts +++ b/lib/debug-helpers.ts @@ -36,6 +36,8 @@ export const vaultV3Address = sepoliaNetworkConfig.contracts.balancer.vaultV3 as export const poolId = '0x68e3266c9c8bbd44ad9dca5afbfe629022aee9fe000200000000000000000512' as const // Balancer Weighted wjAura and WETH +export const sepoliaRouter = '0x1c58cc548a23956469c7C528Bb3a846c842dfaF9' + /* Used to pretty print objects when debugging */ diff --git a/lib/modules/pool/actions/LiquidityActionHelpers.ts b/lib/modules/pool/actions/LiquidityActionHelpers.ts index c19b9ad49..5bbaa3188 100644 --- a/lib/modules/pool/actions/LiquidityActionHelpers.ts +++ b/lib/modules/pool/actions/LiquidityActionHelpers.ts @@ -232,7 +232,7 @@ export function toPoolStateWithBalances(pool: Pool): PoolStateWithBalances { * - is native and the wrapped native token is already in the array and * - is wrapped native and the native token is already in the array * - * @param {HumanAmoHumanTokenAmountWithAddressuntIn[]} humanAmountsIn - The array of human amounts to filter. + * @param {HumanAmoHumanTokenAmountWithAddress[]} humanAmountsIn - The array of human amounts to filter. * @param {Address} tokenAddress - The token address to compare against. * @param {GqlChain} chain - The chain type for comparison. * @return {HumanTokenAmountWithAddress[]} The filtered array of human amounts. @@ -309,3 +309,12 @@ export function injectNativeAsset( export function hasNoLiquidity(pool: Pool): boolean { return isZero(pool.dynamicData.totalShares) } + +// When the pool has version v2, it adds extra buildCall params (sender and recipient) that must be present only in V2 +export function adaptBuildCallParams(buildCallParams: T, isV3Pool: boolean, account: Address) { + // sender must be undefined for v3 pools + if (isV3Pool) return buildCallParams + + // sender and recipient must be defined only for v2 pools + return { ...buildCallParams, sender: account, recipient: account } +} diff --git a/lib/modules/pool/actions/add-liquidity/handlers/UnbalancedAddLiquidity.handler.ts b/lib/modules/pool/actions/add-liquidity/handlers/UnbalancedAddLiquidity.handler.ts index f71f483a1..dfb4dcf31 100644 --- a/lib/modules/pool/actions/add-liquidity/handlers/UnbalancedAddLiquidity.handler.ts +++ b/lib/modules/pool/actions/add-liquidity/handlers/UnbalancedAddLiquidity.handler.ts @@ -11,9 +11,13 @@ import { Slippage, } from '@balancer/sdk' import { Pool } from '../../../PoolProvider' -import { LiquidityActionHelpers, areEmptyAmounts } from '../../LiquidityActionHelpers' -import { SdkBuildAddLiquidityInput, SdkQueryAddLiquidityOutput } from '../add-liquidity.types' +import { + LiquidityActionHelpers, + adaptBuildCallParams, + areEmptyAmounts, +} from '../../LiquidityActionHelpers' import { AddLiquidityHandler } from './AddLiquidity.handler' +import { SdkBuildAddLiquidityInput, SdkQueryAddLiquidityOutput } from '../add-liquidity.types' /** * UnbalancedAddLiquidityHandler is a handler that implements the @@ -64,13 +68,19 @@ export class UnbalancedAddLiquidityHandler implements AddLiquidityHandler { }: SdkBuildAddLiquidityInput): Promise { const addLiquidity = new AddLiquidity() - const { callData, to, value } = addLiquidity.buildCall({ + const baseBuildCallParams = { ...queryOutput.sdkQueryOutput, slippage: Slippage.fromPercentage(`${Number(slippagePercent)}`), - sender: account, - recipient: account, wethIsEth: this.helpers.isNativeAssetIn(humanAmountsIn), - }) + } + + const buildCallParams = adaptBuildCallParams( + baseBuildCallParams, + this.helpers.isV3Pool(), + account + ) + + const { callData, to, value } = addLiquidity.buildCall(buildCallParams) return { account, diff --git a/lib/modules/pool/actions/add-liquidity/useAddLiquiditySteps.tsx b/lib/modules/pool/actions/add-liquidity/useAddLiquiditySteps.tsx index 74a46d7e8..248a5c589 100644 --- a/lib/modules/pool/actions/add-liquidity/useAddLiquiditySteps.tsx +++ b/lib/modules/pool/actions/add-liquidity/useAddLiquiditySteps.tsx @@ -3,11 +3,11 @@ import { useShouldSignRelayerApproval } from '@/lib/modules/relayer/signRelayerA import { useApproveRelayerStep } from '@/lib/modules/relayer/useApproveRelayerStep' import { useRelayerMode } from '@/lib/modules/relayer/useRelayerMode' import { useTokenApprovalSteps } from '@/lib/modules/tokens/approvals/useTokenApprovalSteps' -import { useContractAddress } from '@/lib/modules/web3/contracts/useContractAddress' import { useMemo } from 'react' import { usePool } from '../../PoolProvider' import { LiquidityActionHelpers } from '../LiquidityActionHelpers' import { AddLiquidityStepParams, useAddLiquidityStep } from './useAddLiquidityStep' +import { getVaultConfig } from '../../pool.helpers' import { useSignRelayerStep } from '@/lib/modules/transactions/transaction-steps/useSignRelayerStep' import { Address } from 'viem' import { isCowAmmPool } from '../../pool.helpers' @@ -21,10 +21,11 @@ export function useAddLiquiditySteps({ humanAmountsIn, simulationQuery, }: AddLiquidityStepsParams) { - const vaultAddress = useContractAddress('balancer.vaultV2') const { pool, chainId, chain } = usePool() + const { vaultAddress } = getVaultConfig(pool) const relayerMode = useRelayerMode(pool) const shouldSignRelayerApproval = useShouldSignRelayerApproval(chainId, relayerMode) + const { step: approveRelayerStep, isLoading: isLoadingRelayerApproval } = useApproveRelayerStep(chainId) const signRelayerStep = useSignRelayerStep(chain) diff --git a/lib/modules/pool/actions/remove-liquidity/handlers/ProportionalRemoveLiquidity.handler.ts b/lib/modules/pool/actions/remove-liquidity/handlers/ProportionalRemoveLiquidity.handler.ts index a0370fd47..ffd3ef5dd 100644 --- a/lib/modules/pool/actions/remove-liquidity/handlers/ProportionalRemoveLiquidity.handler.ts +++ b/lib/modules/pool/actions/remove-liquidity/handlers/ProportionalRemoveLiquidity.handler.ts @@ -10,7 +10,7 @@ import { import { Address, parseEther } from 'viem' import { BPT_DECIMALS } from '../../../pool.constants' import { Pool } from '../../../PoolProvider' -import { LiquidityActionHelpers } from '../../LiquidityActionHelpers' +import { LiquidityActionHelpers, adaptBuildCallParams } from '../../LiquidityActionHelpers' import { QueryRemoveLiquidityInput, SdkBuildRemoveLiquidityInput, @@ -50,13 +50,19 @@ export class ProportionalRemoveLiquidityHandler implements RemoveLiquidityHandle }: SdkBuildRemoveLiquidityInput): Promise { const removeLiquidity = new RemoveLiquidity() - const { callData, to, value } = removeLiquidity.buildCall({ + const baseBuildCallParams = { ...queryOutput.sdkQueryOutput, slippage: Slippage.fromPercentage(`${Number(slippagePercent)}`), - sender: account, - recipient: account, wethIsEth, - }) + } + + const buildCallParams = adaptBuildCallParams( + baseBuildCallParams, + this.helpers.isV3Pool(), + account + ) + + const { callData, to, value } = removeLiquidity.buildCall(buildCallParams) return { account, diff --git a/lib/modules/pool/actions/remove-liquidity/handlers/SingleTokenRemoveLiquidity.handler.ts b/lib/modules/pool/actions/remove-liquidity/handlers/SingleTokenRemoveLiquidity.handler.ts index 3ee78fee1..807f4f86a 100644 --- a/lib/modules/pool/actions/remove-liquidity/handlers/SingleTokenRemoveLiquidity.handler.ts +++ b/lib/modules/pool/actions/remove-liquidity/handlers/SingleTokenRemoveLiquidity.handler.ts @@ -12,7 +12,11 @@ import { import { Address, parseEther } from 'viem' import { BPT_DECIMALS } from '../../../pool.constants' import { Pool } from '../../../PoolProvider' -import { LiquidityActionHelpers, isEmptyHumanAmount } from '../../LiquidityActionHelpers' +import { + LiquidityActionHelpers, + adaptBuildCallParams, + isEmptyHumanAmount, +} from '../../LiquidityActionHelpers' import { SdkBuildRemoveLiquidityInput, SdkQueryRemoveLiquidityOutput, @@ -72,13 +76,19 @@ export class SingleTokenRemoveLiquidityHandler implements RemoveLiquidityHandler }: SdkBuildRemoveLiquidityInput): Promise { const removeLiquidity = new RemoveLiquidity() - const { callData, to, value } = removeLiquidity.buildCall({ + const baseBuildCallParams = { ...queryOutput.sdkQueryOutput, slippage: Slippage.fromPercentage(`${Number(slippagePercent)}`), - sender: account, - recipient: account, wethIsEth, - }) + } + + const buildCallParams = adaptBuildCallParams( + baseBuildCallParams, + this.helpers.isV3Pool(), + account + ) + + const { callData, to, value } = removeLiquidity.buildCall(buildCallParams) return { account, From a78b343fcbec75ec98c9eae7309b9aab60449a3f Mon Sep 17 00:00:00 2001 From: Alberto Gualis Date: Mon, 16 Sep 2024 18:39:58 +0200 Subject: [PATCH 2/7] chore: improve comment --- lib/modules/pool/actions/LiquidityActionHelpers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/modules/pool/actions/LiquidityActionHelpers.ts b/lib/modules/pool/actions/LiquidityActionHelpers.ts index 5bbaa3188..8f6674391 100644 --- a/lib/modules/pool/actions/LiquidityActionHelpers.ts +++ b/lib/modules/pool/actions/LiquidityActionHelpers.ts @@ -315,6 +315,6 @@ export function adaptBuildCallParams(buildCallParams: T, isV3Pool: boolean, a // sender must be undefined for v3 pools if (isV3Pool) return buildCallParams - // sender and recipient must be defined only for v2 pools + // sender and recipient must be defined only for v1 and v2 pools return { ...buildCallParams, sender: account, recipient: account } } From e8541b91e23c1ebe87692e164e56fc9a41cc024f Mon Sep 17 00:00:00 2001 From: Alberto Gualis Date: Mon, 16 Sep 2024 18:42:29 +0200 Subject: [PATCH 3/7] chore: improve comment2 --- lib/modules/pool/actions/LiquidityActionHelpers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/modules/pool/actions/LiquidityActionHelpers.ts b/lib/modules/pool/actions/LiquidityActionHelpers.ts index 8f6674391..f271cc6ed 100644 --- a/lib/modules/pool/actions/LiquidityActionHelpers.ts +++ b/lib/modules/pool/actions/LiquidityActionHelpers.ts @@ -310,7 +310,7 @@ export function hasNoLiquidity(pool: Pool): boolean { return isZero(pool.dynamicData.totalShares) } -// When the pool has version v2, it adds extra buildCall params (sender and recipient) that must be present only in V2 +// When the pool has version < v3, it adds extra buildCall params (sender and recipient) that must be present only in V1/V2 export function adaptBuildCallParams(buildCallParams: T, isV3Pool: boolean, account: Address) { // sender must be undefined for v3 pools if (isV3Pool) return buildCallParams From 174056376651db240023724ebe74469995f2ef2d Mon Sep 17 00:00:00 2001 From: Alberto Gualis Date: Tue, 17 Sep 2024 12:22:40 +0200 Subject: [PATCH 4/7] chore: add NEXT prefix to NEXT_PRIVATE_ALCHEMY_KEY for simpler local integration test setup (#1097) --- .github/workflows/checks.yml | 2 +- app/api/rpc/[chain]/route.ts | 4 ++-- test/anvil/anvil-setup.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 8dc816690..e257e157d 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -6,7 +6,7 @@ on: env: NEXT_PUBLIC_BALANCER_API_URL: https://api-v3.balancer.fi/graphql NEXT_PUBLIC_WALLET_CONNECT_ID: ${{ secrets.NEXT_PUBLIC_WALLET_CONNECT_ID }} - PRIVATE_ALCHEMY_KEY: ${{ secrets.PRIVATE_ALCHEMY_KEY }} + NEXT_PRIVATE_ALCHEMY_KEY: ${{ secrets.PRIVATE_ALCHEMY_KEY }} jobs: Build: diff --git a/app/api/rpc/[chain]/route.ts b/app/api/rpc/[chain]/route.ts index 9f31494d0..190a39ed3 100644 --- a/app/api/rpc/[chain]/route.ts +++ b/app/api/rpc/[chain]/route.ts @@ -6,7 +6,7 @@ type Params = { } } -const ALCHEMY_KEY = process.env.PRIVATE_ALCHEMY_KEY || '' +const ALCHEMY_KEY = process.env.NEXT_PRIVATE_ALCHEMY_KEY || '' const chainToRpcMap: Record = { [GqlChain.Mainnet]: `https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY}`, @@ -35,7 +35,7 @@ function getRpcUrl(chain: string) { export async function POST(request: Request, { params: { chain } }: Params) { if (!ALCHEMY_KEY) { - return new Response(JSON.stringify({ error: 'PRIVATE_ALCHEMY_KEY is missing' }), { + return new Response(JSON.stringify({ error: 'NEXT_PRIVATE_ALCHEMY_KEY is missing' }), { status: 500, }) } diff --git a/test/anvil/anvil-setup.ts b/test/anvil/anvil-setup.ts index baa6388e7..3b2030965 100644 --- a/test/anvil/anvil-setup.ts +++ b/test/anvil/anvil-setup.ts @@ -85,7 +85,7 @@ export function getTestRpcSetup(networkName: NetworksWithFork) { } export function getForkUrl(network: NetworkSetup, verbose = false): string { - const privateAlchemyKey = process.env['PRIVATE_ALCHEMY_KEY'] + const privateAlchemyKey = process.env['NEXT_PRIVATE_ALCHEMY_KEY'] if (privateAlchemyKey) { if (network.networkName === 'Ethereum') { return `https://eth-mainnet.g.alchemy.com/v2/${privateAlchemyKey}` From f344a6bf6f79525053913853b122b0943b44ed05 Mon Sep 17 00:00:00 2001 From: Alberto Gualis Date: Tue, 17 Sep 2024 12:39:21 +0200 Subject: [PATCH 5/7] chore: rename function --- lib/modules/pool/actions/LiquidityActionHelpers.ts | 4 ++-- .../add-liquidity/handlers/UnbalancedAddLiquidity.handler.ts | 4 ++-- .../handlers/ProportionalRemoveLiquidity.handler.ts | 4 ++-- .../handlers/SingleTokenRemoveLiquidity.handler.ts | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/modules/pool/actions/LiquidityActionHelpers.ts b/lib/modules/pool/actions/LiquidityActionHelpers.ts index f271cc6ed..00c2709be 100644 --- a/lib/modules/pool/actions/LiquidityActionHelpers.ts +++ b/lib/modules/pool/actions/LiquidityActionHelpers.ts @@ -232,7 +232,7 @@ export function toPoolStateWithBalances(pool: Pool): PoolStateWithBalances { * - is native and the wrapped native token is already in the array and * - is wrapped native and the native token is already in the array * - * @param {HumanAmoHumanTokenAmountWithAddress[]} humanAmountsIn - The array of human amounts to filter. + * @param {HumanTokenAmountWithAddress[]} humanAmountsIn - The array of human amounts to filter. * @param {Address} tokenAddress - The token address to compare against. * @param {GqlChain} chain - The chain type for comparison. * @return {HumanTokenAmountWithAddress[]} The filtered array of human amounts. @@ -311,7 +311,7 @@ export function hasNoLiquidity(pool: Pool): boolean { } // When the pool has version < v3, it adds extra buildCall params (sender and recipient) that must be present only in V1/V2 -export function adaptBuildCallParams(buildCallParams: T, isV3Pool: boolean, account: Address) { +export function formatBuildCallParams(buildCallParams: T, isV3Pool: boolean, account: Address) { // sender must be undefined for v3 pools if (isV3Pool) return buildCallParams diff --git a/lib/modules/pool/actions/add-liquidity/handlers/UnbalancedAddLiquidity.handler.ts b/lib/modules/pool/actions/add-liquidity/handlers/UnbalancedAddLiquidity.handler.ts index dfb4dcf31..c33ee4716 100644 --- a/lib/modules/pool/actions/add-liquidity/handlers/UnbalancedAddLiquidity.handler.ts +++ b/lib/modules/pool/actions/add-liquidity/handlers/UnbalancedAddLiquidity.handler.ts @@ -13,7 +13,7 @@ import { import { Pool } from '../../../PoolProvider' import { LiquidityActionHelpers, - adaptBuildCallParams, + formatBuildCallParams, areEmptyAmounts, } from '../../LiquidityActionHelpers' import { AddLiquidityHandler } from './AddLiquidity.handler' @@ -74,7 +74,7 @@ export class UnbalancedAddLiquidityHandler implements AddLiquidityHandler { wethIsEth: this.helpers.isNativeAssetIn(humanAmountsIn), } - const buildCallParams = adaptBuildCallParams( + const buildCallParams = formatBuildCallParams( baseBuildCallParams, this.helpers.isV3Pool(), account diff --git a/lib/modules/pool/actions/remove-liquidity/handlers/ProportionalRemoveLiquidity.handler.ts b/lib/modules/pool/actions/remove-liquidity/handlers/ProportionalRemoveLiquidity.handler.ts index ffd3ef5dd..b3e36e89e 100644 --- a/lib/modules/pool/actions/remove-liquidity/handlers/ProportionalRemoveLiquidity.handler.ts +++ b/lib/modules/pool/actions/remove-liquidity/handlers/ProportionalRemoveLiquidity.handler.ts @@ -10,7 +10,7 @@ import { import { Address, parseEther } from 'viem' import { BPT_DECIMALS } from '../../../pool.constants' import { Pool } from '../../../PoolProvider' -import { LiquidityActionHelpers, adaptBuildCallParams } from '../../LiquidityActionHelpers' +import { LiquidityActionHelpers, formatBuildCallParams } from '../../LiquidityActionHelpers' import { QueryRemoveLiquidityInput, SdkBuildRemoveLiquidityInput, @@ -56,7 +56,7 @@ export class ProportionalRemoveLiquidityHandler implements RemoveLiquidityHandle wethIsEth, } - const buildCallParams = adaptBuildCallParams( + const buildCallParams = formatBuildCallParams( baseBuildCallParams, this.helpers.isV3Pool(), account diff --git a/lib/modules/pool/actions/remove-liquidity/handlers/SingleTokenRemoveLiquidity.handler.ts b/lib/modules/pool/actions/remove-liquidity/handlers/SingleTokenRemoveLiquidity.handler.ts index 807f4f86a..a0c8736f7 100644 --- a/lib/modules/pool/actions/remove-liquidity/handlers/SingleTokenRemoveLiquidity.handler.ts +++ b/lib/modules/pool/actions/remove-liquidity/handlers/SingleTokenRemoveLiquidity.handler.ts @@ -14,7 +14,7 @@ import { BPT_DECIMALS } from '../../../pool.constants' import { Pool } from '../../../PoolProvider' import { LiquidityActionHelpers, - adaptBuildCallParams, + formatBuildCallParams, isEmptyHumanAmount, } from '../../LiquidityActionHelpers' import { @@ -82,7 +82,7 @@ export class SingleTokenRemoveLiquidityHandler implements RemoveLiquidityHandler wethIsEth, } - const buildCallParams = adaptBuildCallParams( + const buildCallParams = formatBuildCallParams( baseBuildCallParams, this.helpers.isV3Pool(), account From 274cc2c07e046a738f43368c5416b6bb1b1e77c2 Mon Sep 17 00:00:00 2001 From: Alberto Gualis Date: Tue, 17 Sep 2024 17:31:44 +0200 Subject: [PATCH 6/7] chore: add permit2 support in useTokenApprovalSteps --- lib/config/config.types.ts | 1 + lib/config/networks/sepolia.ts | 3 +- .../pool/actions/LiquidityActionHelpers.ts | 4 +- .../add-liquidity/useAddLiquiditySteps.tsx | 9 +- .../tokens/approvals/approval-rules.spec.ts | 5 + .../tokens/approvals/approval-rules.ts | 5 + .../approvals/useTokenApprovalSteps.tsx | 5 +- lib/modules/tokens/token.helpers.ts | 14 + .../web3/contracts/abi/balancerV3Abi.ts | 1403 +++++++++-------- 9 files changed, 816 insertions(+), 633 deletions(-) diff --git a/lib/config/config.types.ts b/lib/config/config.types.ts index d3097f1e1..71e273c2d 100644 --- a/lib/config/config.types.ts +++ b/lib/config/config.types.ts @@ -43,6 +43,7 @@ export interface ContractsConfig { feeDistributor?: Address veDelegationProxy?: Address veBAL?: Address + permit2?: Address } export interface PoolsConfig { issues: Partial> diff --git a/lib/config/networks/sepolia.ts b/lib/config/networks/sepolia.ts index 4811fa377..528a2efe6 100644 --- a/lib/config/networks/sepolia.ts +++ b/lib/config/networks/sepolia.ts @@ -31,11 +31,12 @@ const networkConfig: NetworkConfig = { multicall2: '0xca11bde05977b3631167028862be2a173976ca11', balancer: { vaultV2: '0xBA12222222228d8Ba445958a75a0704d566BF2C8', - vaultV3: '0x0EF1c156a7986F394d90eD1bEeA6483Cc435F542', + vaultV3: '0x7966FE92C59295EcE7FB5D9EfDB271967BFe2fbA', relayerV6: '0x7852fB9d0895e6e8b3EedA553c03F6e2F9124dF9', minter: '0x1783Cd84b3d01854A96B4eD5843753C2CcbD574A', }, veBAL: '0x150A72e4D4d81BbF045565E232c50Ed0931ad795', + permit2: '0x000000000022D473030F116dDEE9F6B43aC78BA3', }, pools: convertHexToLowerCase({ issues: {}, diff --git a/lib/modules/pool/actions/LiquidityActionHelpers.ts b/lib/modules/pool/actions/LiquidityActionHelpers.ts index 00c2709be..cfdc4a7d8 100644 --- a/lib/modules/pool/actions/LiquidityActionHelpers.ts +++ b/lib/modules/pool/actions/LiquidityActionHelpers.ts @@ -75,10 +75,12 @@ export class LiquidityActionHelpers { } public getAmountsToApprove( - humanAmountsIn: HumanTokenAmountWithAddress[] + humanAmountsIn: HumanTokenAmountWithAddress[], + isPermit2 = false ): TokenAmountToApprove[] { return this.toInputAmounts(humanAmountsIn).map(({ address, rawAmount }) => { return { + isPermit2, tokenAddress: address, requiredRawAmount: rawAmount, requestedRawAmount: rawAmount, //This amount will be probably replaced by MAX_BIGINT depending on the approval rules diff --git a/lib/modules/pool/actions/add-liquidity/useAddLiquiditySteps.tsx b/lib/modules/pool/actions/add-liquidity/useAddLiquiditySteps.tsx index 248a5c589..5363a6f92 100644 --- a/lib/modules/pool/actions/add-liquidity/useAddLiquiditySteps.tsx +++ b/lib/modules/pool/actions/add-liquidity/useAddLiquiditySteps.tsx @@ -7,10 +7,9 @@ import { useMemo } from 'react' import { usePool } from '../../PoolProvider' import { LiquidityActionHelpers } from '../LiquidityActionHelpers' import { AddLiquidityStepParams, useAddLiquidityStep } from './useAddLiquidityStep' -import { getVaultConfig } from '../../pool.helpers' +import { isV3Pool } from '../../pool.helpers' import { useSignRelayerStep } from '@/lib/modules/transactions/transaction-steps/useSignRelayerStep' -import { Address } from 'viem' -import { isCowAmmPool } from '../../pool.helpers' +import { getTokenSpenderAddress } from '@/lib/modules/tokens/token.helpers' type AddLiquidityStepsParams = AddLiquidityStepParams & { helpers: LiquidityActionHelpers @@ -22,7 +21,6 @@ export function useAddLiquiditySteps({ simulationQuery, }: AddLiquidityStepsParams) { const { pool, chainId, chain } = usePool() - const { vaultAddress } = getVaultConfig(pool) const relayerMode = useRelayerMode(pool) const shouldSignRelayerApproval = useShouldSignRelayerApproval(chainId, relayerMode) @@ -37,10 +35,11 @@ export function useAddLiquiditySteps({ const { isLoading: isLoadingTokenApprovalSteps, steps: tokenApprovalSteps } = useTokenApprovalSteps({ - spenderAddress: isCowAmmPool(pool.type) ? (pool.address as Address) : vaultAddress, + spenderAddress: getTokenSpenderAddress(pool), chain: pool.chain, approvalAmounts: inputAmounts, actionType: 'AddLiquidity', + isPermit2: isV3Pool(pool), }) const addLiquidityStep = useAddLiquidityStep({ diff --git a/lib/modules/tokens/approvals/approval-rules.spec.ts b/lib/modules/tokens/approvals/approval-rules.spec.ts index bb4dc207e..2d51073e5 100644 --- a/lib/modules/tokens/approvals/approval-rules.spec.ts +++ b/lib/modules/tokens/approvals/approval-rules.spec.ts @@ -52,11 +52,13 @@ describe('getRequiredTokenApprovals', () => { }) ).toEqual([ { + isPermit2: false, tokenAddress: wETHAddress, requiredRawAmount: 10000000000000000000n, requestedRawAmount: MAX_BIGINT, }, { + isPermit2: false, tokenAddress: wjAuraAddress, requiredRawAmount: 20000000000000000000n, requestedRawAmount: MAX_BIGINT, @@ -87,11 +89,13 @@ describe('getRequiredTokenApprovals', () => { requiredRawAmount: 0n, requestedRawAmount: 0n, tokenAddress: usdtAddress, + isPermit2: false, }, { tokenAddress: usdtAddress, requiredRawAmount: 10000000000000000000n, requestedRawAmount: MAX_BIGINT, + isPermit2: false, }, ]) }) @@ -116,6 +120,7 @@ describe('getRequiredTokenApprovals', () => { }) ).toEqual([ { + isPermit2: false, requiredRawAmount: 10000000000000000000n, requestedRawAmount: MAX_BIGINT, tokenAddress: usdtAddress, diff --git a/lib/modules/tokens/approvals/approval-rules.ts b/lib/modules/tokens/approvals/approval-rules.ts index 998db2233..cc8987ec0 100644 --- a/lib/modules/tokens/approvals/approval-rules.ts +++ b/lib/modules/tokens/approvals/approval-rules.ts @@ -10,6 +10,7 @@ export type TokenAmountToApprove = { tokenAddress: Address requiredRawAmount: bigint // actual amount that the transaction requires requestedRawAmount: bigint // amount that we are going to request (normally MAX_BIGINT) + isPermit2: boolean // whether the approval is for Permit2 or standard token approval } // This is a subtype of InputAmount as we only need rawAmount and address @@ -19,6 +20,7 @@ type TokenApprovalParams = { chainId: GqlChain | SupportedChainId | null rawAmounts: RawAmount[] allowanceFor: (tokenAddress: Address) => bigint + isPermit2?: boolean approveMaxBigInt?: boolean skipAllowanceCheck?: boolean } @@ -30,6 +32,7 @@ export function getRequiredTokenApprovals({ chainId, rawAmounts, allowanceFor, + isPermit2 = false, approveMaxBigInt = true, skipAllowanceCheck = false, }: TokenApprovalParams): TokenAmountToApprove[] { @@ -42,6 +45,7 @@ export function getRequiredTokenApprovals({ requiredRawAmount: rawAmount, // The transaction only requires requiredRawAmount but we will normally request MAX_BIGINT requestedRawAmount: approveMaxBigInt ? MAX_BIGINT : rawAmount, + isPermit2, } }) @@ -59,6 +63,7 @@ export function getRequiredTokenApprovals({ requiredRawAmount: 0n, requestedRawAmount: 0n, tokenAddress: t.tokenAddress, + isPermit2, } // Prepend approval for ZERO amount return [zeroTokenAmountToApprove, t] diff --git a/lib/modules/tokens/approvals/useTokenApprovalSteps.tsx b/lib/modules/tokens/approvals/useTokenApprovalSteps.tsx index 48294da53..0bf7eb358 100644 --- a/lib/modules/tokens/approvals/useTokenApprovalSteps.tsx +++ b/lib/modules/tokens/approvals/useTokenApprovalSteps.tsx @@ -20,11 +20,12 @@ export type Params = { chain: GqlChain approvalAmounts: RawAmount[] actionType: ApprovalAction + isPermit2?: boolean bptSymbol?: string //Edge-case for approving } /* - Generic hook to creates a Token Approval Step Config for different flows defined by the actionType property + Generic hook to create a Token Approval Step Config for different flows defined by the actionType property */ export function useTokenApprovalSteps({ spenderAddress, @@ -32,6 +33,7 @@ export function useTokenApprovalSteps({ approvalAmounts, actionType, bptSymbol, + isPermit2 = false, }: Params): { isLoading: boolean; steps: TransactionStep[] } { const { userAddress } = useUserAccount() const { getToken } = useTokens() @@ -58,6 +60,7 @@ export function useTokenApprovalSteps({ chainId: chain, rawAmounts: _approvalAmounts, allowanceFor: tokenAllowances.allowanceFor, + isPermit2, }) const steps = useMemo(() => { diff --git a/lib/modules/tokens/token.helpers.ts b/lib/modules/tokens/token.helpers.ts index 37abe8259..624ee784f 100644 --- a/lib/modules/tokens/token.helpers.ts +++ b/lib/modules/tokens/token.helpers.ts @@ -10,6 +10,7 @@ import { Address } from 'viem' import { HumanTokenAmountWithAddress, TokenBase } from './token.types' import { InputAmount } from '@balancer/sdk' import { Pool } from '../pool/PoolProvider' +import { getVaultConfig, isCowAmmPool, isV3Pool } from '../pool/pool.helpers' export function isNativeAsset(token: TokenBase | string, chain: GqlChain | SupportedChainId) { return nativeAssetFilter(chain)(token) @@ -130,3 +131,16 @@ export function getLeafTokens(poolTokens: PoolToken[]) { return leafTokens } + +export function getTokenSpenderAddress(pool: Pool): Address { + if (isCowAmmPool(pool.type)) return pool.address as Address + if (isV3Pool(pool)) { + const permit2Address = getNetworkConfig(pool.chain).contracts.permit2 + if (!permit2Address) { + throw new Error(`Permit2 feature is not yet available for this chain (${pool.chain}) `) + } + return permit2Address + } + const { vaultAddress } = getVaultConfig(pool) + return vaultAddress +} diff --git a/lib/modules/web3/contracts/abi/balancerV3Abi.ts b/lib/modules/web3/contracts/abi/balancerV3Abi.ts index 9aeb07c2b..143928409 100644 --- a/lib/modules/web3/contracts/abi/balancerV3Abi.ts +++ b/lib/modules/web3/contracts/abi/balancerV3Abi.ts @@ -3,239 +3,634 @@ export const balancerV3VaultAbi = [ { inputs: [ { - internalType: 'address', - name: 'token', + internalType: 'contract IVaultExtension', + name: 'vaultExtension', type: 'address', }, { - internalType: 'address', - name: 'owner', + internalType: 'contract IAuthorizer', + name: 'authorizer', + type: 'address', + }, + { + internalType: 'contract IProtocolFeeController', + name: 'protocolFeeController', type: 'address', }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + inputs: [{ internalType: 'address', name: 'target', type: 'address' }], + name: 'AddressEmptyCode', + type: 'error', + }, + { + inputs: [{ internalType: 'address', name: 'account', type: 'address' }], + name: 'AddressInsufficientBalance', + type: 'error', + }, + { inputs: [], name: 'AfterAddLiquidityHookFailed', type: 'error' }, + { inputs: [], name: 'AfterInitializeHookFailed', type: 'error' }, + { inputs: [], name: 'AfterRemoveLiquidityHookFailed', type: 'error' }, + { inputs: [], name: 'AfterSwapHookFailed', type: 'error' }, + { inputs: [], name: 'AllZeroInputs', type: 'error' }, + { inputs: [], name: 'AmountGivenZero', type: 'error' }, + { + inputs: [ + { internalType: 'contract IERC20', name: 'token', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + { internalType: 'uint256', name: 'limit', type: 'uint256' }, + ], + name: 'AmountInAboveMax', + type: 'error', + }, + { + inputs: [ + { internalType: 'contract IERC20', name: 'token', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + { internalType: 'uint256', name: 'limit', type: 'uint256' }, + ], + name: 'AmountOutBelowMin', + type: 'error', + }, + { inputs: [], name: 'BalanceNotSettled', type: 'error' }, + { inputs: [], name: 'BalanceOverflow', type: 'error' }, + { inputs: [], name: 'BeforeAddLiquidityHookFailed', type: 'error' }, + { inputs: [], name: 'BeforeInitializeHookFailed', type: 'error' }, + { inputs: [], name: 'BeforeRemoveLiquidityHookFailed', type: 'error' }, + { inputs: [], name: 'BeforeSwapHookFailed', type: 'error' }, + { + inputs: [ + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + { internalType: 'uint256', name: 'limit', type: 'uint256' }, + ], + name: 'BptAmountInAboveMax', + type: 'error', + }, + { + inputs: [ + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + { internalType: 'uint256', name: 'limit', type: 'uint256' }, + ], + name: 'BptAmountOutBelowMin', + type: 'error', + }, + { inputs: [], name: 'CannotReceiveEth', type: 'error' }, + { inputs: [], name: 'CannotSwapSameToken', type: 'error' }, + { inputs: [], name: 'DoesNotSupportAddLiquidityCustom', type: 'error' }, + { inputs: [], name: 'DoesNotSupportDonation', type: 'error' }, + { inputs: [], name: 'DoesNotSupportRemoveLiquidityCustom', type: 'error' }, + { inputs: [], name: 'DoesNotSupportUnbalancedLiquidity', type: 'error' }, + { inputs: [], name: 'DynamicSwapFeeHookFailed', type: 'error' }, + { + inputs: [ + { internalType: 'address', name: 'spender', type: 'address' }, + { internalType: 'uint256', name: 'allowance', type: 'uint256' }, + { internalType: 'uint256', name: 'needed', type: 'uint256' }, + ], + name: 'ERC20InsufficientAllowance', + type: 'error', + }, + { + inputs: [ + { internalType: 'address', name: 'sender', type: 'address' }, + { internalType: 'uint256', name: 'balance', type: 'uint256' }, + { internalType: 'uint256', name: 'needed', type: 'uint256' }, + ], + name: 'ERC20InsufficientBalance', + type: 'error', + }, + { + inputs: [{ internalType: 'address', name: 'approver', type: 'address' }], + name: 'ERC20InvalidApprover', + type: 'error', + }, + { + inputs: [{ internalType: 'address', name: 'receiver', type: 'address' }], + name: 'ERC20InvalidReceiver', + type: 'error', + }, + { + inputs: [{ internalType: 'address', name: 'sender', type: 'address' }], + name: 'ERC20InvalidSender', + type: 'error', + }, + { + inputs: [{ internalType: 'address', name: 'spender', type: 'address' }], + name: 'ERC20InvalidSpender', + type: 'error', + }, + { inputs: [], name: 'FailedInnerCall', type: 'error' }, + { inputs: [], name: 'FeePrecisionTooHigh', type: 'error' }, + { + inputs: [ + { internalType: 'contract IERC20', name: 'token', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + { internalType: 'uint256', name: 'limit', type: 'uint256' }, + ], + name: 'HookAdjustedAmountInAboveMax', + type: 'error', + }, + { + inputs: [ + { internalType: 'contract IERC20', name: 'token', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + { internalType: 'uint256', name: 'limit', type: 'uint256' }, + ], + name: 'HookAdjustedAmountOutBelowMin', + type: 'error', + }, + { + inputs: [ + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + { internalType: 'uint256', name: 'limit', type: 'uint256' }, + ], + name: 'HookAdjustedSwapLimit', + type: 'error', + }, + { + inputs: [ { internalType: 'address', - name: 'spender', + name: 'poolHooksContract', type: 'address', }, + { internalType: 'address', name: 'pool', type: 'address' }, + { internalType: 'address', name: 'poolFactory', type: 'address' }, ], - name: 'allowance', - outputs: [ + name: 'HookRegistrationFailed', + type: 'error', + }, + { inputs: [], name: 'InputLengthMismatch', type: 'error' }, + { inputs: [], name: 'InvalidAddLiquidityKind', type: 'error' }, + { inputs: [], name: 'InvalidRemoveLiquidityKind', type: 'error' }, + { inputs: [], name: 'InvalidToken', type: 'error' }, + { inputs: [], name: 'InvalidTokenConfiguration', type: 'error' }, + { inputs: [], name: 'InvalidTokenType', type: 'error' }, + { + inputs: [ + { + internalType: 'uint256', + name: 'invariantRatio', + type: 'uint256', + }, { internalType: 'uint256', - name: '', + name: 'maxInvariantRatio', type: 'uint256', }, ], - stateMutability: 'view', - type: 'function', + name: 'InvariantRatioAboveMax', + type: 'error', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'invariantRatio', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'minInvariantRatio', + type: 'uint256', + }, + ], + name: 'InvariantRatioBelowMin', + type: 'error', + }, + { inputs: [], name: 'MaxTokens', type: 'error' }, + { inputs: [], name: 'MinTokens', type: 'error' }, + { inputs: [], name: 'MultipleNonZeroInputs', type: 'error' }, + { inputs: [], name: 'NotEnoughBufferShares', type: 'error' }, + { inputs: [], name: 'NotStaticCall', type: 'error' }, + { inputs: [], name: 'NotVaultDelegateCall', type: 'error' }, + { inputs: [], name: 'OperationNotSupported', type: 'error' }, + { inputs: [], name: 'PauseBufferPeriodDurationTooLarge', type: 'error' }, + { + inputs: [{ internalType: 'address', name: 'pool', type: 'address' }], + name: 'PoolAlreadyInitialized', + type: 'error', + }, + { + inputs: [{ internalType: 'address', name: 'pool', type: 'address' }], + name: 'PoolAlreadyRegistered', + type: 'error', + }, + { + inputs: [{ internalType: 'address', name: 'pool', type: 'address' }], + name: 'PoolInRecoveryMode', + type: 'error', + }, + { + inputs: [{ internalType: 'address', name: 'pool', type: 'address' }], + name: 'PoolNotInRecoveryMode', + type: 'error', + }, + { + inputs: [{ internalType: 'address', name: 'pool', type: 'address' }], + name: 'PoolNotInitialized', + type: 'error', + }, + { + inputs: [{ internalType: 'address', name: 'pool', type: 'address' }], + name: 'PoolNotPaused', + type: 'error', + }, + { + inputs: [{ internalType: 'address', name: 'pool', type: 'address' }], + name: 'PoolNotRegistered', + type: 'error', + }, + { + inputs: [{ internalType: 'address', name: 'pool', type: 'address' }], + name: 'PoolPauseWindowExpired', + type: 'error', + }, + { + inputs: [{ internalType: 'address', name: 'pool', type: 'address' }], + name: 'PoolPaused', + type: 'error', + }, + { inputs: [], name: 'ProtocolFeesExceedTotalCollected', type: 'error' }, + { inputs: [], name: 'QueriesDisabled', type: 'error' }, + { inputs: [], name: 'QuoteResultSpoofed', type: 'error' }, + { inputs: [], name: 'ReentrancyGuardReentrantCall', type: 'error' }, + { inputs: [], name: 'RouterNotTrusted', type: 'error' }, + { + inputs: [{ internalType: 'uint256', name: 'value', type: 'uint256' }], + name: 'SafeCastOverflowedUintToInt', + type: 'error', + }, + { + inputs: [{ internalType: 'address', name: 'token', type: 'address' }], + name: 'SafeERC20FailedOperation', + type: 'error', + }, + { + inputs: [{ internalType: 'address', name: 'sender', type: 'address' }], + name: 'SenderIsNotVault', + type: 'error', + }, + { inputs: [], name: 'SwapFeePercentageTooHigh', type: 'error' }, + { inputs: [], name: 'SwapFeePercentageTooLow', type: 'error' }, + { + inputs: [ + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + { internalType: 'uint256', name: 'limit', type: 'uint256' }, + ], + name: 'SwapLimit', + type: 'error', + }, + { + inputs: [{ internalType: 'contract IERC20', name: 'token', type: 'address' }], + name: 'TokenAlreadyRegistered', + type: 'error', + }, + { + inputs: [{ internalType: 'contract IERC20', name: 'token', type: 'address' }], + name: 'TokenNotRegistered', + type: 'error', + }, + { + inputs: [ + { internalType: 'address', name: 'pool', type: 'address' }, + { internalType: 'address', name: 'expectedToken', type: 'address' }, + { internalType: 'address', name: 'actualToken', type: 'address' }, + ], + name: 'TokensMismatch', + type: 'error', + }, + { + inputs: [ + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + { internalType: 'uint256', name: 'limit', type: 'uint256' }, + ], + name: 'TotalSupplyTooLow', + type: 'error', + }, + { inputs: [], name: 'TradeAmountTooSmall', type: 'error' }, + { inputs: [], name: 'UserDataNotSupported', type: 'error' }, + { inputs: [], name: 'VaultBuffersArePaused', type: 'error' }, + { inputs: [], name: 'VaultIsNotUnlocked', type: 'error' }, + { inputs: [], name: 'VaultNotPaused', type: 'error' }, + { inputs: [], name: 'VaultPauseWindowDurationTooLarge', type: 'error' }, + { inputs: [], name: 'VaultPauseWindowExpired', type: 'error' }, + { inputs: [], name: 'VaultPaused', type: 'error' }, + { + inputs: [{ internalType: 'address', name: 'wrappedToken', type: 'address' }], + name: 'WrapAmountTooSmall', + type: 'error', + }, + { inputs: [], name: 'WrongProtocolFeeControllerDeployment', type: 'error' }, + { + inputs: [{ internalType: 'address', name: 'wrappedToken', type: 'address' }], + name: 'WrongUnderlyingAmount', + type: 'error', + }, + { inputs: [], name: 'WrongVaultAdminDeployment', type: 'error' }, + { inputs: [], name: 'WrongVaultExtensionDeployment', type: 'error' }, + { + inputs: [{ internalType: 'address', name: 'wrappedToken', type: 'address' }], + name: 'WrongWrappedAmount', + type: 'error', + }, + { + inputs: [{ internalType: 'address', name: 'token', type: 'address' }], + name: 'WrongWrappedTokenAsset', + type: 'error', }, + { inputs: [], name: 'ZeroDivision', type: 'error' }, { + anonymous: false, inputs: [ { + indexed: true, + internalType: 'address', + name: 'pool', + type: 'address', + }, + { + indexed: true, internalType: 'address', name: 'owner', type: 'address', }, { + indexed: true, internalType: 'address', name: 'spender', type: 'address', }, { + indexed: false, internalType: 'uint256', - name: 'amount', + name: 'value', type: 'uint256', }, ], - name: 'approve', - outputs: [ + name: 'Approval', + type: 'event', + }, + { + anonymous: false, + inputs: [ { - internalType: 'bool', - name: '', - type: 'bool', + indexed: true, + internalType: 'contract IAuthorizer', + name: 'newAuthorizer', + type: 'address', }, ], - stateMutability: 'nonpayable', - type: 'function', + name: 'AuthorizerChanged', + type: 'event', }, { + anonymous: false, inputs: [ { - internalType: 'address', - name: 'token', + indexed: true, + internalType: 'contract IERC4626', + name: 'wrappedToken', type: 'address', }, { + indexed: true, internalType: 'address', - name: 'account', + name: 'sharesOwner', type: 'address', }, - ], - name: 'balanceOf', - outputs: [ { + indexed: false, + internalType: 'uint256', + name: 'amountWrapped', + type: 'uint256', + }, + { + indexed: false, internalType: 'uint256', - name: '', + name: 'amountUnderlying', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'issuedShares', type: 'uint256', }, ], - stateMutability: 'view', - type: 'function', + name: 'LiquidityAddedToBuffer', + type: 'event', }, { + anonymous: false, inputs: [ { + indexed: true, + internalType: 'contract IERC4626', + name: 'wrappedToken', + type: 'address', + }, + { + indexed: true, internalType: 'address', - name: 'pool', + name: 'sharesOwner', type: 'address', }, { - components: [ - { - internalType: 'enum SwapKind', - name: 'kind', - type: 'uint8', - }, - { - internalType: 'uint256', - name: 'amountGivenScaled18', - type: 'uint256', - }, - { - internalType: 'uint256[]', - name: 'balancesScaled18', - type: 'uint256[]', - }, - { - internalType: 'uint256', - name: 'indexIn', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'indexOut', - type: 'uint256', - }, - { - internalType: 'address', - name: 'router', - type: 'address', - }, - { - internalType: 'bytes', - name: 'userData', - type: 'bytes', - }, - ], - internalType: 'struct IBasePool.PoolSwapParams', - name: 'swapParams', - type: 'tuple', + indexed: false, + internalType: 'uint256', + name: 'amountWrapped', + type: 'uint256', }, - ], - name: 'computeDynamicSwapFee', - outputs: [ { - internalType: 'bool', - name: '', - type: 'bool', + indexed: false, + internalType: 'uint256', + name: 'amountUnderlying', + type: 'uint256', }, { + indexed: false, internalType: 'uint256', - name: '', + name: 'removedShares', type: 'uint256', }, ], - stateMutability: 'view', - type: 'function', + name: 'LiquidityRemovedFromBuffer', + type: 'event', }, { + anonymous: false, inputs: [ { + indexed: true, internalType: 'address', name: 'pool', type: 'address', }, { - internalType: 'contract IERC20', - name: 'token', + indexed: true, + internalType: 'address', + name: 'liquidityProvider', type: 'address', }, - ], - name: 'getAggregateProtocolSwapFeeAmount', - outputs: [ { - internalType: 'uint256', - name: '', - type: 'uint256', + indexed: false, + internalType: 'int256[]', + name: 'deltas', + type: 'int256[]', }, ], - stateMutability: 'view', - type: 'function', + name: 'PoolBalanceChanged', + type: 'event', }, { + anonymous: false, inputs: [ { + indexed: true, internalType: 'address', name: 'pool', type: 'address', }, + ], + name: 'PoolInitialized', + type: 'event', + }, + { + anonymous: false, + inputs: [ { - internalType: 'contract IERC20', - name: 'token', + indexed: true, + internalType: 'address', + name: 'pool', type: 'address', }, - ], - name: 'getAggregateProtocolYieldFeeAmount', - outputs: [ { - internalType: 'uint256', - name: '', - type: 'uint256', + indexed: false, + internalType: 'bool', + name: 'paused', + type: 'bool', }, ], - stateMutability: 'view', - type: 'function', + name: 'PoolPausedStateChanged', + type: 'event', }, { + anonymous: false, inputs: [ { + indexed: true, internalType: 'address', name: 'pool', type: 'address', }, - ], - name: 'getBptRate', - outputs: [ { - internalType: 'uint256', - name: 'rate', - type: 'uint256', + indexed: false, + internalType: 'bool', + name: 'recoveryMode', + type: 'bool', }, ], - stateMutability: 'view', - type: 'function', + name: 'PoolRecoveryModeStateChanged', + type: 'event', }, { + anonymous: false, inputs: [ { + indexed: true, internalType: 'address', name: 'pool', type: 'address', }, - ], - name: 'getHooksConfig', - outputs: [ + { + indexed: true, + internalType: 'address', + name: 'factory', + type: 'address', + }, { components: [ { - internalType: 'bool', - name: 'shouldCallBeforeInitialize', - type: 'bool', + internalType: 'contract IERC20', + name: 'token', + type: 'address', }, { - internalType: 'bool', - name: 'shouldCallAfterInitialize', - type: 'bool', + internalType: 'enum TokenType', + name: 'tokenType', + type: 'uint8', + }, + { + internalType: 'contract IRateProvider', + name: 'rateProvider', + type: 'address', + }, + { + internalType: 'bool', + name: 'paysYieldFees', + type: 'bool', + }, + ], + indexed: false, + internalType: 'struct TokenConfig[]', + name: 'tokenConfig', + type: 'tuple[]', + }, + { + indexed: false, + internalType: 'uint256', + name: 'swapFeePercentage', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint32', + name: 'pauseWindowEndTime', + type: 'uint32', + }, + { + components: [ + { + internalType: 'address', + name: 'pauseManager', + type: 'address', + }, + { + internalType: 'address', + name: 'swapFeeManager', + type: 'address', + }, + { + internalType: 'address', + name: 'poolCreator', + type: 'address', + }, + ], + indexed: false, + internalType: 'struct PoolRoleAccounts', + name: 'roleAccounts', + type: 'tuple', + }, + { + components: [ + { + internalType: 'bool', + name: 'enableHookAdjustedAmounts', + type: 'bool', + }, + { + internalType: 'bool', + name: 'shouldCallBeforeInitialize', + type: 'bool', + }, + { + internalType: 'bool', + name: 'shouldCallAfterInitialize', + type: 'bool', }, { internalType: 'bool', @@ -278,717 +673,475 @@ export const balancerV3VaultAbi = [ type: 'address', }, ], + indexed: false, internalType: 'struct HooksConfig', - name: '', + name: 'hooksConfig', type: 'tuple', }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'getNonzeroDeltaCount', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'pool', - type: 'address', - }, - ], - name: 'getPoolConfig', - outputs: [ { components: [ - { - internalType: 'uint24', - name: 'staticSwapFeePercentageUnscaled', - type: 'uint24', - }, - { - internalType: 'uint24', - name: 'aggregateProtocolSwapFeePercentageUnscaled', - type: 'uint24', - }, - { - internalType: 'uint24', - name: 'aggregateProtocolYieldFeePercentageUnscaled', - type: 'uint24', - }, - { - internalType: 'uint24', - name: 'tokenDecimalDiffs', - type: 'uint24', - }, - { - internalType: 'uint32', - name: 'pauseWindowEndTime', - type: 'uint32', - }, - { - internalType: 'bool', - name: 'isPoolRegistered', - type: 'bool', - }, { internalType: 'bool', - name: 'isPoolInitialized', - type: 'bool', - }, - { - internalType: 'bool', - name: 'isPoolPaused', - type: 'bool', - }, - { - internalType: 'bool', - name: 'isPoolInRecoveryMode', + name: 'disableUnbalancedLiquidity', type: 'bool', }, { internalType: 'bool', - name: 'disableUnbalancedLiquidity', + name: 'enableAddLiquidityCustom', type: 'bool', }, { internalType: 'bool', - name: 'enableAddLiquidityCustom', + name: 'enableRemoveLiquidityCustom', type: 'bool', }, { internalType: 'bool', - name: 'enableRemoveLiquidityCustom', + name: 'enableDonation', type: 'bool', }, ], - internalType: 'struct PoolConfig', - name: '', + indexed: false, + internalType: 'struct LiquidityManagement', + name: 'liquidityManagement', type: 'tuple', }, ], - stateMutability: 'view', - type: 'function', + name: 'PoolRegistered', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'contract IProtocolFeeController', + name: 'newProtocolFeeController', + type: 'address', + }, + ], + name: 'ProtocolFeeControllerChanged', + type: 'event', }, { + anonymous: false, inputs: [ { + indexed: true, internalType: 'address', name: 'pool', type: 'address', }, - ], - name: 'getPoolPausedState', - outputs: [ { - internalType: 'bool', - name: '', - type: 'bool', + indexed: true, + internalType: 'contract IERC20', + name: 'tokenIn', + type: 'address', }, { - internalType: 'uint32', - name: '', - type: 'uint32', + indexed: true, + internalType: 'contract IERC20', + name: 'tokenOut', + type: 'address', }, { - internalType: 'uint32', - name: '', - type: 'uint32', + indexed: false, + internalType: 'uint256', + name: 'amountIn', + type: 'uint256', }, { - internalType: 'address', - name: '', + indexed: false, + internalType: 'uint256', + name: 'amountOut', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'swapFeePercentage', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'swapFeeAmount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'contract IERC20', + name: 'swapFeeToken', type: 'address', }, ], - stateMutability: 'view', - type: 'function', + name: 'Swap', + type: 'event', }, { + anonymous: false, inputs: [ { + indexed: true, internalType: 'address', name: 'pool', type: 'address', }, - ], - name: 'getPoolRoleAccounts', - outputs: [ { - components: [ - { - internalType: 'address', - name: 'pauseManager', - type: 'address', - }, - { - internalType: 'address', - name: 'swapFeeManager', - type: 'address', - }, - { - internalType: 'address', - name: 'poolCreator', - type: 'address', - }, - ], - internalType: 'struct PoolRoleAccounts', - name: '', - type: 'tuple', + indexed: false, + internalType: 'uint256', + name: 'swapFeePercentage', + type: 'uint256', }, ], - stateMutability: 'view', - type: 'function', + name: 'SwapFeePercentageChanged', + type: 'event', }, { + anonymous: false, inputs: [ { + indexed: true, internalType: 'address', name: 'pool', type: 'address', }, - ], - name: 'getPoolTokenInfo', - outputs: [ { - components: [ - { - internalType: 'contract IERC20', - name: 'token', - type: 'address', - }, - { - internalType: 'enum TokenType', - name: 'tokenType', - type: 'uint8', - }, - { - internalType: 'contract IRateProvider', - name: 'rateProvider', - type: 'address', - }, - { - internalType: 'bool', - name: 'paysYieldFees', - type: 'bool', - }, - ], - internalType: 'struct TokenConfig[]', - name: 'tokenConfig', - type: 'tuple[]', + indexed: true, + internalType: 'address', + name: 'from', + type: 'address', }, { - internalType: 'uint256[]', - name: 'balancesRaw', - type: 'uint256[]', + indexed: true, + internalType: 'address', + name: 'to', + type: 'address', }, { - internalType: 'uint256[]', - name: 'scalingFactors', - type: 'uint256[]', + indexed: false, + internalType: 'uint256', + name: 'value', + type: 'uint256', }, ], - stateMutability: 'view', - type: 'function', + name: 'Transfer', + type: 'event', }, { + anonymous: false, inputs: [ { - internalType: 'address', - name: 'pool', + indexed: true, + internalType: 'contract IERC4626', + name: 'wrappedToken', type: 'address', }, - ], - name: 'getPoolTokens', - outputs: [ - { - internalType: 'contract IERC20[]', - name: '', - type: 'address[]', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ { + indexed: true, internalType: 'contract IERC20', - name: 'token', + name: 'underlyingToken', type: 'address', }, - ], - name: 'getReservesOf', - outputs: [ { + indexed: false, + internalType: 'uint256', + name: 'burnedShares', + type: 'uint256', + }, + { + indexed: false, internalType: 'uint256', - name: '', + name: 'withdrawnUnderlying', type: 'uint256', }, ], - stateMutability: 'view', - type: 'function', + name: 'Unwrap', + type: 'event', }, { + anonymous: false, inputs: [ { - internalType: 'address', - name: 'pool', - type: 'address', - }, - ], - name: 'getStaticSwapFeePercentage', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', + indexed: false, + internalType: 'bool', + name: 'paused', + type: 'bool', }, ], - stateMutability: 'view', - type: 'function', + name: 'VaultPausedStateChanged', + type: 'event', }, { + anonymous: false, inputs: [ { + indexed: true, internalType: 'contract IERC20', - name: 'token', + name: 'underlyingToken', type: 'address', }, - ], - name: 'getTokenDelta', - outputs: [ { - internalType: 'int256', - name: '', - type: 'int256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'getVaultAdmin', - outputs: [ - { - internalType: 'address', - name: '', - type: 'address', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'pool', - type: 'address', - }, - { - internalType: 'address', - name: 'to', - type: 'address', - }, - { - internalType: 'contract IERC20[]', - name: 'tokens', - type: 'address[]', - }, - { - internalType: 'uint256[]', - name: 'exactAmountsIn', - type: 'uint256[]', + indexed: true, + internalType: 'contract IERC4626', + name: 'wrappedToken', + type: 'address', }, { + indexed: false, internalType: 'uint256', - name: 'minBptAmountOut', + name: 'depositedUnderlying', type: 'uint256', }, { - internalType: 'bytes', - name: 'userData', - type: 'bytes', - }, - ], - name: 'initialize', - outputs: [ - { + indexed: false, internalType: 'uint256', - name: 'bptAmountOut', + name: 'mintedShares', type: 'uint256', }, ], - stateMutability: 'nonpayable', - type: 'function', + name: 'Wrap', + type: 'event', }, + { stateMutability: 'payable', type: 'fallback' }, { inputs: [ { - internalType: 'address', - name: 'pool', - type: 'address', + components: [ + { internalType: 'address', name: 'pool', type: 'address' }, + { internalType: 'address', name: 'to', type: 'address' }, + { + internalType: 'uint256[]', + name: 'maxAmountsIn', + type: 'uint256[]', + }, + { + internalType: 'uint256', + name: 'minBptAmountOut', + type: 'uint256', + }, + { + internalType: 'enum AddLiquidityKind', + name: 'kind', + type: 'uint8', + }, + { internalType: 'bytes', name: 'userData', type: 'bytes' }, + ], + internalType: 'struct AddLiquidityParams', + name: 'params', + type: 'tuple', }, ], - name: 'isPoolInRecoveryMode', + name: 'addLiquidity', outputs: [ - { - internalType: 'bool', - name: '', - type: 'bool', - }, + { internalType: 'uint256[]', name: 'amountsIn', type: 'uint256[]' }, + { internalType: 'uint256', name: 'bptAmountOut', type: 'uint256' }, + { internalType: 'bytes', name: 'returnData', type: 'bytes' }, ], - stateMutability: 'view', + stateMutability: 'nonpayable', type: 'function', }, { inputs: [ { - internalType: 'address', - name: 'pool', - type: 'address', + components: [ + { + internalType: 'enum SwapKind', + name: 'kind', + type: 'uint8', + }, + { + internalType: 'enum WrappingDirection', + name: 'direction', + type: 'uint8', + }, + { + internalType: 'contract IERC4626', + name: 'wrappedToken', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amountGivenRaw', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'limitRaw', + type: 'uint256', + }, + { internalType: 'bytes', name: 'userData', type: 'bytes' }, + ], + internalType: 'struct BufferWrapOrUnwrapParams', + name: 'params', + type: 'tuple', }, ], - name: 'isPoolInitialized', + name: 'erc4626BufferWrapOrUnwrap', outputs: [ { - internalType: 'bool', - name: '', - type: 'bool', + internalType: 'uint256', + name: 'amountCalculatedRaw', + type: 'uint256', }, + { internalType: 'uint256', name: 'amountInRaw', type: 'uint256' }, + { internalType: 'uint256', name: 'amountOutRaw', type: 'uint256' }, ], - stateMutability: 'view', + stateMutability: 'nonpayable', type: 'function', }, { - inputs: [ - { - internalType: 'address', - name: 'pool', - type: 'address', - }, - ], - name: 'isPoolPaused', - outputs: [ - { - internalType: 'bool', - name: '', - type: 'bool', - }, - ], + inputs: [], + name: 'getAuthorizer', + outputs: [{ internalType: 'contract IAuthorizer', name: '', type: 'address' }], stateMutability: 'view', type: 'function', }, { inputs: [ - { - internalType: 'address', - name: 'pool', - type: 'address', - }, + { internalType: 'address', name: 'pool', type: 'address' }, + { internalType: 'contract IERC20', name: 'token', type: 'address' }, ], - name: 'isPoolRegistered', + name: 'getPoolTokenCountAndIndexOfToken', outputs: [ - { - internalType: 'bool', - name: '', - type: 'bool', - }, + { internalType: 'uint256', name: '', type: 'uint256' }, + { internalType: 'uint256', name: '', type: 'uint256' }, ], stateMutability: 'view', type: 'function', }, { inputs: [], - name: 'isQueryDisabled', - outputs: [ - { - internalType: 'bool', - name: '', - type: 'bool', - }, - ], + name: 'getVaultExtension', + outputs: [{ internalType: 'address', name: '', type: 'address' }], stateMutability: 'view', type: 'function', }, { inputs: [], - name: 'isUnlocked', - outputs: [ - { - internalType: 'bool', - name: '', - type: 'bool', - }, - ], + name: 'reentrancyGuardEntered', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], stateMutability: 'view', type: 'function', }, { inputs: [ { - internalType: 'bytes', - name: 'data', - type: 'bytes', + components: [ + { internalType: 'address', name: 'pool', type: 'address' }, + { internalType: 'address', name: 'from', type: 'address' }, + { + internalType: 'uint256', + name: 'maxBptAmountIn', + type: 'uint256', + }, + { + internalType: 'uint256[]', + name: 'minAmountsOut', + type: 'uint256[]', + }, + { + internalType: 'enum RemoveLiquidityKind', + name: 'kind', + type: 'uint8', + }, + { internalType: 'bytes', name: 'userData', type: 'bytes' }, + ], + internalType: 'struct RemoveLiquidityParams', + name: 'params', + type: 'tuple', }, ], - name: 'quote', + name: 'removeLiquidity', outputs: [ + { internalType: 'uint256', name: 'bptAmountIn', type: 'uint256' }, { - internalType: 'bytes', - name: 'result', - type: 'bytes', + internalType: 'uint256[]', + name: 'amountsOut', + type: 'uint256[]', }, + { internalType: 'bytes', name: 'returnData', type: 'bytes' }, ], - stateMutability: 'payable', + stateMutability: 'nonpayable', type: 'function', }, { inputs: [ - { - internalType: 'bytes', - name: 'data', - type: 'bytes', - }, + { internalType: 'contract IERC20', name: 'token', type: 'address' }, + { internalType: 'address', name: 'to', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, ], - name: 'quoteAndRevert', + name: 'sendTo', outputs: [], - stateMutability: 'payable', + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'contract IERC20', name: 'token', type: 'address' }, + { internalType: 'uint256', name: 'amountHint', type: 'uint256' }, + ], + name: 'settle', + outputs: [{ internalType: 'uint256', name: 'credit', type: 'uint256' }], + stateMutability: 'nonpayable', type: 'function', }, { inputs: [ - { - internalType: 'address', - name: 'pool', - type: 'address', - }, { components: [ { - internalType: 'contract IERC20', - name: 'token', - type: 'address', - }, - { - internalType: 'enum TokenType', - name: 'tokenType', + internalType: 'enum SwapKind', + name: 'kind', type: 'uint8', }, + { internalType: 'address', name: 'pool', type: 'address' }, { - internalType: 'contract IRateProvider', - name: 'rateProvider', - type: 'address', - }, - { - internalType: 'bool', - name: 'paysYieldFees', - type: 'bool', - }, - ], - internalType: 'struct TokenConfig[]', - name: 'tokenConfig', - type: 'tuple[]', - }, - { - internalType: 'uint256', - name: 'swapFeePercentage', - type: 'uint256', - }, - { - internalType: 'uint32', - name: 'pauseWindowEndTime', - type: 'uint32', - }, - { - components: [ - { - internalType: 'address', - name: 'pauseManager', + internalType: 'contract IERC20', + name: 'tokenIn', type: 'address', }, { - internalType: 'address', - name: 'swapFeeManager', + internalType: 'contract IERC20', + name: 'tokenOut', type: 'address', }, { - internalType: 'address', - name: 'poolCreator', - type: 'address', - }, - ], - internalType: 'struct PoolRoleAccounts', - name: 'roleAccounts', - type: 'tuple', - }, - { - internalType: 'address', - name: 'poolHooksContract', - type: 'address', - }, - { - components: [ - { - internalType: 'bool', - name: 'disableUnbalancedLiquidity', - type: 'bool', - }, - { - internalType: 'bool', - name: 'enableAddLiquidityCustom', - type: 'bool', + internalType: 'uint256', + name: 'amountGivenRaw', + type: 'uint256', }, { - internalType: 'bool', - name: 'enableRemoveLiquidityCustom', - type: 'bool', + internalType: 'uint256', + name: 'limitRaw', + type: 'uint256', }, + { internalType: 'bytes', name: 'userData', type: 'bytes' }, ], - internalType: 'struct LiquidityManagement', - name: 'liquidityManagement', + internalType: 'struct SwapParams', + name: 'params', type: 'tuple', }, ], - name: 'registerPool', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'pool', - type: 'address', - }, - { - internalType: 'address', - name: 'from', - type: 'address', - }, - { - internalType: 'uint256', - name: 'exactBptAmountIn', - type: 'uint256', - }, - ], - name: 'removeLiquidityRecovery', - outputs: [ - { - internalType: 'uint256[]', - name: 'amountsOut', - type: 'uint256[]', - }, - ], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'token', - type: 'address', - }, - ], - name: 'totalSupply', + name: 'swap', outputs: [ { internalType: 'uint256', - name: '', + name: 'amountCalculated', type: 'uint256', }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'owner', - type: 'address', - }, - { - internalType: 'address', - name: 'to', - type: 'address', - }, - { - internalType: 'uint256', - name: 'amount', - type: 'uint256', - }, - ], - name: 'transfer', - outputs: [ - { - internalType: 'bool', - name: '', - type: 'bool', - }, + { internalType: 'uint256', name: 'amountIn', type: 'uint256' }, + { internalType: 'uint256', name: 'amountOut', type: 'uint256' }, ], stateMutability: 'nonpayable', type: 'function', }, { - inputs: [ - { - internalType: 'address', - name: 'spender', - type: 'address', - }, - { - internalType: 'address', - name: 'from', - type: 'address', - }, - { - internalType: 'address', - name: 'to', - type: 'address', - }, - { - internalType: 'uint256', - name: 'amount', - type: 'uint256', - }, - ], - name: 'transferFrom', - outputs: [ - { - internalType: 'bool', - name: '', - type: 'bool', - }, - ], + inputs: [{ internalType: 'bytes', name: 'data', type: 'bytes' }], + name: 'unlock', + outputs: [{ internalType: 'bytes', name: 'result', type: 'bytes' }], stateMutability: 'nonpayable', type: 'function', }, - { - inputs: [], - name: 'vault', - outputs: [ - { - internalType: 'contract IVault', - name: '', - type: 'address', - }, - ], - stateMutability: 'view', - type: 'function', - }, + { stateMutability: 'payable', type: 'receive' }, ] as const From b61a78e716fa32f809a5c22252085f32bee3459b Mon Sep 17 00:00:00 2001 From: Alberto Gualis Date: Tue, 17 Sep 2024 17:52:52 +0200 Subject: [PATCH 7/7] chore: undo v3 contract changes --- lib/config/networks/sepolia.ts | 2 +- .../web3/contracts/abi/balancerV3Abi.ts | 1405 ++++++++--------- 2 files changed, 627 insertions(+), 780 deletions(-) diff --git a/lib/config/networks/sepolia.ts b/lib/config/networks/sepolia.ts index 528a2efe6..97805ca46 100644 --- a/lib/config/networks/sepolia.ts +++ b/lib/config/networks/sepolia.ts @@ -31,7 +31,7 @@ const networkConfig: NetworkConfig = { multicall2: '0xca11bde05977b3631167028862be2a173976ca11', balancer: { vaultV2: '0xBA12222222228d8Ba445958a75a0704d566BF2C8', - vaultV3: '0x7966FE92C59295EcE7FB5D9EfDB271967BFe2fbA', + vaultV3: '0x0EF1c156a7986F394d90eD1bEeA6483Cc435F542', relayerV6: '0x7852fB9d0895e6e8b3EedA553c03F6e2F9124dF9', minter: '0x1783Cd84b3d01854A96B4eD5843753C2CcbD574A', }, diff --git a/lib/modules/web3/contracts/abi/balancerV3Abi.ts b/lib/modules/web3/contracts/abi/balancerV3Abi.ts index 143928409..9aeb07c2b 100644 --- a/lib/modules/web3/contracts/abi/balancerV3Abi.ts +++ b/lib/modules/web3/contracts/abi/balancerV3Abi.ts @@ -3,634 +3,239 @@ export const balancerV3VaultAbi = [ { inputs: [ { - internalType: 'contract IVaultExtension', - name: 'vaultExtension', - type: 'address', - }, - { - internalType: 'contract IAuthorizer', - name: 'authorizer', + internalType: 'address', + name: 'token', type: 'address', }, { - internalType: 'contract IProtocolFeeController', - name: 'protocolFeeController', + internalType: 'address', + name: 'owner', type: 'address', }, - ], - stateMutability: 'nonpayable', - type: 'constructor', - }, - { - inputs: [{ internalType: 'address', name: 'target', type: 'address' }], - name: 'AddressEmptyCode', - type: 'error', - }, - { - inputs: [{ internalType: 'address', name: 'account', type: 'address' }], - name: 'AddressInsufficientBalance', - type: 'error', - }, - { inputs: [], name: 'AfterAddLiquidityHookFailed', type: 'error' }, - { inputs: [], name: 'AfterInitializeHookFailed', type: 'error' }, - { inputs: [], name: 'AfterRemoveLiquidityHookFailed', type: 'error' }, - { inputs: [], name: 'AfterSwapHookFailed', type: 'error' }, - { inputs: [], name: 'AllZeroInputs', type: 'error' }, - { inputs: [], name: 'AmountGivenZero', type: 'error' }, - { - inputs: [ - { internalType: 'contract IERC20', name: 'token', type: 'address' }, - { internalType: 'uint256', name: 'amount', type: 'uint256' }, - { internalType: 'uint256', name: 'limit', type: 'uint256' }, - ], - name: 'AmountInAboveMax', - type: 'error', - }, - { - inputs: [ - { internalType: 'contract IERC20', name: 'token', type: 'address' }, - { internalType: 'uint256', name: 'amount', type: 'uint256' }, - { internalType: 'uint256', name: 'limit', type: 'uint256' }, - ], - name: 'AmountOutBelowMin', - type: 'error', - }, - { inputs: [], name: 'BalanceNotSettled', type: 'error' }, - { inputs: [], name: 'BalanceOverflow', type: 'error' }, - { inputs: [], name: 'BeforeAddLiquidityHookFailed', type: 'error' }, - { inputs: [], name: 'BeforeInitializeHookFailed', type: 'error' }, - { inputs: [], name: 'BeforeRemoveLiquidityHookFailed', type: 'error' }, - { inputs: [], name: 'BeforeSwapHookFailed', type: 'error' }, - { - inputs: [ - { internalType: 'uint256', name: 'amount', type: 'uint256' }, - { internalType: 'uint256', name: 'limit', type: 'uint256' }, - ], - name: 'BptAmountInAboveMax', - type: 'error', - }, - { - inputs: [ - { internalType: 'uint256', name: 'amount', type: 'uint256' }, - { internalType: 'uint256', name: 'limit', type: 'uint256' }, - ], - name: 'BptAmountOutBelowMin', - type: 'error', - }, - { inputs: [], name: 'CannotReceiveEth', type: 'error' }, - { inputs: [], name: 'CannotSwapSameToken', type: 'error' }, - { inputs: [], name: 'DoesNotSupportAddLiquidityCustom', type: 'error' }, - { inputs: [], name: 'DoesNotSupportDonation', type: 'error' }, - { inputs: [], name: 'DoesNotSupportRemoveLiquidityCustom', type: 'error' }, - { inputs: [], name: 'DoesNotSupportUnbalancedLiquidity', type: 'error' }, - { inputs: [], name: 'DynamicSwapFeeHookFailed', type: 'error' }, - { - inputs: [ - { internalType: 'address', name: 'spender', type: 'address' }, - { internalType: 'uint256', name: 'allowance', type: 'uint256' }, - { internalType: 'uint256', name: 'needed', type: 'uint256' }, - ], - name: 'ERC20InsufficientAllowance', - type: 'error', - }, - { - inputs: [ - { internalType: 'address', name: 'sender', type: 'address' }, - { internalType: 'uint256', name: 'balance', type: 'uint256' }, - { internalType: 'uint256', name: 'needed', type: 'uint256' }, - ], - name: 'ERC20InsufficientBalance', - type: 'error', - }, - { - inputs: [{ internalType: 'address', name: 'approver', type: 'address' }], - name: 'ERC20InvalidApprover', - type: 'error', - }, - { - inputs: [{ internalType: 'address', name: 'receiver', type: 'address' }], - name: 'ERC20InvalidReceiver', - type: 'error', - }, - { - inputs: [{ internalType: 'address', name: 'sender', type: 'address' }], - name: 'ERC20InvalidSender', - type: 'error', - }, - { - inputs: [{ internalType: 'address', name: 'spender', type: 'address' }], - name: 'ERC20InvalidSpender', - type: 'error', - }, - { inputs: [], name: 'FailedInnerCall', type: 'error' }, - { inputs: [], name: 'FeePrecisionTooHigh', type: 'error' }, - { - inputs: [ - { internalType: 'contract IERC20', name: 'token', type: 'address' }, - { internalType: 'uint256', name: 'amount', type: 'uint256' }, - { internalType: 'uint256', name: 'limit', type: 'uint256' }, - ], - name: 'HookAdjustedAmountInAboveMax', - type: 'error', - }, - { - inputs: [ - { internalType: 'contract IERC20', name: 'token', type: 'address' }, - { internalType: 'uint256', name: 'amount', type: 'uint256' }, - { internalType: 'uint256', name: 'limit', type: 'uint256' }, - ], - name: 'HookAdjustedAmountOutBelowMin', - type: 'error', - }, - { - inputs: [ - { internalType: 'uint256', name: 'amount', type: 'uint256' }, - { internalType: 'uint256', name: 'limit', type: 'uint256' }, - ], - name: 'HookAdjustedSwapLimit', - type: 'error', - }, - { - inputs: [ { internalType: 'address', - name: 'poolHooksContract', + name: 'spender', type: 'address', }, - { internalType: 'address', name: 'pool', type: 'address' }, - { internalType: 'address', name: 'poolFactory', type: 'address' }, - ], - name: 'HookRegistrationFailed', - type: 'error', - }, - { inputs: [], name: 'InputLengthMismatch', type: 'error' }, - { inputs: [], name: 'InvalidAddLiquidityKind', type: 'error' }, - { inputs: [], name: 'InvalidRemoveLiquidityKind', type: 'error' }, - { inputs: [], name: 'InvalidToken', type: 'error' }, - { inputs: [], name: 'InvalidTokenConfiguration', type: 'error' }, - { inputs: [], name: 'InvalidTokenType', type: 'error' }, - { - inputs: [ - { - internalType: 'uint256', - name: 'invariantRatio', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'maxInvariantRatio', - type: 'uint256', - }, ], - name: 'InvariantRatioAboveMax', - type: 'error', - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'invariantRatio', - type: 'uint256', - }, + name: 'allowance', + outputs: [ { internalType: 'uint256', - name: 'minInvariantRatio', + name: '', type: 'uint256', }, ], - name: 'InvariantRatioBelowMin', - type: 'error', - }, - { inputs: [], name: 'MaxTokens', type: 'error' }, - { inputs: [], name: 'MinTokens', type: 'error' }, - { inputs: [], name: 'MultipleNonZeroInputs', type: 'error' }, - { inputs: [], name: 'NotEnoughBufferShares', type: 'error' }, - { inputs: [], name: 'NotStaticCall', type: 'error' }, - { inputs: [], name: 'NotVaultDelegateCall', type: 'error' }, - { inputs: [], name: 'OperationNotSupported', type: 'error' }, - { inputs: [], name: 'PauseBufferPeriodDurationTooLarge', type: 'error' }, - { - inputs: [{ internalType: 'address', name: 'pool', type: 'address' }], - name: 'PoolAlreadyInitialized', - type: 'error', - }, - { - inputs: [{ internalType: 'address', name: 'pool', type: 'address' }], - name: 'PoolAlreadyRegistered', - type: 'error', - }, - { - inputs: [{ internalType: 'address', name: 'pool', type: 'address' }], - name: 'PoolInRecoveryMode', - type: 'error', - }, - { - inputs: [{ internalType: 'address', name: 'pool', type: 'address' }], - name: 'PoolNotInRecoveryMode', - type: 'error', - }, - { - inputs: [{ internalType: 'address', name: 'pool', type: 'address' }], - name: 'PoolNotInitialized', - type: 'error', - }, - { - inputs: [{ internalType: 'address', name: 'pool', type: 'address' }], - name: 'PoolNotPaused', - type: 'error', - }, - { - inputs: [{ internalType: 'address', name: 'pool', type: 'address' }], - name: 'PoolNotRegistered', - type: 'error', - }, - { - inputs: [{ internalType: 'address', name: 'pool', type: 'address' }], - name: 'PoolPauseWindowExpired', - type: 'error', - }, - { - inputs: [{ internalType: 'address', name: 'pool', type: 'address' }], - name: 'PoolPaused', - type: 'error', - }, - { inputs: [], name: 'ProtocolFeesExceedTotalCollected', type: 'error' }, - { inputs: [], name: 'QueriesDisabled', type: 'error' }, - { inputs: [], name: 'QuoteResultSpoofed', type: 'error' }, - { inputs: [], name: 'ReentrancyGuardReentrantCall', type: 'error' }, - { inputs: [], name: 'RouterNotTrusted', type: 'error' }, - { - inputs: [{ internalType: 'uint256', name: 'value', type: 'uint256' }], - name: 'SafeCastOverflowedUintToInt', - type: 'error', - }, - { - inputs: [{ internalType: 'address', name: 'token', type: 'address' }], - name: 'SafeERC20FailedOperation', - type: 'error', - }, - { - inputs: [{ internalType: 'address', name: 'sender', type: 'address' }], - name: 'SenderIsNotVault', - type: 'error', - }, - { inputs: [], name: 'SwapFeePercentageTooHigh', type: 'error' }, - { inputs: [], name: 'SwapFeePercentageTooLow', type: 'error' }, - { - inputs: [ - { internalType: 'uint256', name: 'amount', type: 'uint256' }, - { internalType: 'uint256', name: 'limit', type: 'uint256' }, - ], - name: 'SwapLimit', - type: 'error', - }, - { - inputs: [{ internalType: 'contract IERC20', name: 'token', type: 'address' }], - name: 'TokenAlreadyRegistered', - type: 'error', - }, - { - inputs: [{ internalType: 'contract IERC20', name: 'token', type: 'address' }], - name: 'TokenNotRegistered', - type: 'error', - }, - { - inputs: [ - { internalType: 'address', name: 'pool', type: 'address' }, - { internalType: 'address', name: 'expectedToken', type: 'address' }, - { internalType: 'address', name: 'actualToken', type: 'address' }, - ], - name: 'TokensMismatch', - type: 'error', - }, - { - inputs: [ - { internalType: 'uint256', name: 'amount', type: 'uint256' }, - { internalType: 'uint256', name: 'limit', type: 'uint256' }, - ], - name: 'TotalSupplyTooLow', - type: 'error', - }, - { inputs: [], name: 'TradeAmountTooSmall', type: 'error' }, - { inputs: [], name: 'UserDataNotSupported', type: 'error' }, - { inputs: [], name: 'VaultBuffersArePaused', type: 'error' }, - { inputs: [], name: 'VaultIsNotUnlocked', type: 'error' }, - { inputs: [], name: 'VaultNotPaused', type: 'error' }, - { inputs: [], name: 'VaultPauseWindowDurationTooLarge', type: 'error' }, - { inputs: [], name: 'VaultPauseWindowExpired', type: 'error' }, - { inputs: [], name: 'VaultPaused', type: 'error' }, - { - inputs: [{ internalType: 'address', name: 'wrappedToken', type: 'address' }], - name: 'WrapAmountTooSmall', - type: 'error', - }, - { inputs: [], name: 'WrongProtocolFeeControllerDeployment', type: 'error' }, - { - inputs: [{ internalType: 'address', name: 'wrappedToken', type: 'address' }], - name: 'WrongUnderlyingAmount', - type: 'error', - }, - { inputs: [], name: 'WrongVaultAdminDeployment', type: 'error' }, - { inputs: [], name: 'WrongVaultExtensionDeployment', type: 'error' }, - { - inputs: [{ internalType: 'address', name: 'wrappedToken', type: 'address' }], - name: 'WrongWrappedAmount', - type: 'error', - }, - { - inputs: [{ internalType: 'address', name: 'token', type: 'address' }], - name: 'WrongWrappedTokenAsset', - type: 'error', + stateMutability: 'view', + type: 'function', }, - { inputs: [], name: 'ZeroDivision', type: 'error' }, { - anonymous: false, inputs: [ { - indexed: true, - internalType: 'address', - name: 'pool', - type: 'address', - }, - { - indexed: true, internalType: 'address', name: 'owner', type: 'address', }, { - indexed: true, internalType: 'address', name: 'spender', type: 'address', }, { - indexed: false, internalType: 'uint256', - name: 'value', + name: 'amount', type: 'uint256', }, ], - name: 'Approval', - type: 'event', - }, - { - anonymous: false, - inputs: [ + name: 'approve', + outputs: [ { - indexed: true, - internalType: 'contract IAuthorizer', - name: 'newAuthorizer', - type: 'address', + internalType: 'bool', + name: '', + type: 'bool', }, ], - name: 'AuthorizerChanged', - type: 'event', + stateMutability: 'nonpayable', + type: 'function', }, { - anonymous: false, inputs: [ { - indexed: true, - internalType: 'contract IERC4626', - name: 'wrappedToken', + internalType: 'address', + name: 'token', type: 'address', }, { - indexed: true, internalType: 'address', - name: 'sharesOwner', + name: 'account', type: 'address', }, + ], + name: 'balanceOf', + outputs: [ { - indexed: false, - internalType: 'uint256', - name: 'amountWrapped', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'amountUnderlying', - type: 'uint256', - }, - { - indexed: false, internalType: 'uint256', - name: 'issuedShares', + name: '', type: 'uint256', }, ], - name: 'LiquidityAddedToBuffer', - type: 'event', + stateMutability: 'view', + type: 'function', }, { - anonymous: false, inputs: [ { - indexed: true, - internalType: 'contract IERC4626', - name: 'wrappedToken', - type: 'address', - }, - { - indexed: true, internalType: 'address', - name: 'sharesOwner', + name: 'pool', type: 'address', }, { - indexed: false, - internalType: 'uint256', - name: 'amountWrapped', - type: 'uint256', + components: [ + { + internalType: 'enum SwapKind', + name: 'kind', + type: 'uint8', + }, + { + internalType: 'uint256', + name: 'amountGivenScaled18', + type: 'uint256', + }, + { + internalType: 'uint256[]', + name: 'balancesScaled18', + type: 'uint256[]', + }, + { + internalType: 'uint256', + name: 'indexIn', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'indexOut', + type: 'uint256', + }, + { + internalType: 'address', + name: 'router', + type: 'address', + }, + { + internalType: 'bytes', + name: 'userData', + type: 'bytes', + }, + ], + internalType: 'struct IBasePool.PoolSwapParams', + name: 'swapParams', + type: 'tuple', }, + ], + name: 'computeDynamicSwapFee', + outputs: [ { - indexed: false, - internalType: 'uint256', - name: 'amountUnderlying', - type: 'uint256', + internalType: 'bool', + name: '', + type: 'bool', }, { - indexed: false, internalType: 'uint256', - name: 'removedShares', + name: '', type: 'uint256', }, ], - name: 'LiquidityRemovedFromBuffer', - type: 'event', + stateMutability: 'view', + type: 'function', }, { - anonymous: false, inputs: [ { - indexed: true, internalType: 'address', name: 'pool', type: 'address', }, { - indexed: true, - internalType: 'address', - name: 'liquidityProvider', + internalType: 'contract IERC20', + name: 'token', type: 'address', }, + ], + name: 'getAggregateProtocolSwapFeeAmount', + outputs: [ { - indexed: false, - internalType: 'int256[]', - name: 'deltas', - type: 'int256[]', + internalType: 'uint256', + name: '', + type: 'uint256', }, ], - name: 'PoolBalanceChanged', - type: 'event', + stateMutability: 'view', + type: 'function', }, { - anonymous: false, inputs: [ { - indexed: true, internalType: 'address', name: 'pool', type: 'address', }, - ], - name: 'PoolInitialized', - type: 'event', - }, - { - anonymous: false, - inputs: [ { - indexed: true, - internalType: 'address', - name: 'pool', + internalType: 'contract IERC20', + name: 'token', type: 'address', }, + ], + name: 'getAggregateProtocolYieldFeeAmount', + outputs: [ { - indexed: false, - internalType: 'bool', - name: 'paused', - type: 'bool', + internalType: 'uint256', + name: '', + type: 'uint256', }, ], - name: 'PoolPausedStateChanged', - type: 'event', + stateMutability: 'view', + type: 'function', }, { - anonymous: false, inputs: [ { - indexed: true, internalType: 'address', name: 'pool', type: 'address', }, + ], + name: 'getBptRate', + outputs: [ { - indexed: false, - internalType: 'bool', - name: 'recoveryMode', - type: 'bool', + internalType: 'uint256', + name: 'rate', + type: 'uint256', }, ], - name: 'PoolRecoveryModeStateChanged', - type: 'event', + stateMutability: 'view', + type: 'function', }, { - anonymous: false, inputs: [ { - indexed: true, internalType: 'address', name: 'pool', type: 'address', }, - { - indexed: true, - internalType: 'address', - name: 'factory', - type: 'address', - }, + ], + name: 'getHooksConfig', + outputs: [ { components: [ { - internalType: 'contract IERC20', - name: 'token', - type: 'address', - }, - { - internalType: 'enum TokenType', - name: 'tokenType', - type: 'uint8', + internalType: 'bool', + name: 'shouldCallBeforeInitialize', + type: 'bool', }, { - internalType: 'contract IRateProvider', - name: 'rateProvider', - type: 'address', - }, - { - internalType: 'bool', - name: 'paysYieldFees', - type: 'bool', - }, - ], - indexed: false, - internalType: 'struct TokenConfig[]', - name: 'tokenConfig', - type: 'tuple[]', - }, - { - indexed: false, - internalType: 'uint256', - name: 'swapFeePercentage', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint32', - name: 'pauseWindowEndTime', - type: 'uint32', - }, - { - components: [ - { - internalType: 'address', - name: 'pauseManager', - type: 'address', - }, - { - internalType: 'address', - name: 'swapFeeManager', - type: 'address', - }, - { - internalType: 'address', - name: 'poolCreator', - type: 'address', - }, - ], - indexed: false, - internalType: 'struct PoolRoleAccounts', - name: 'roleAccounts', - type: 'tuple', - }, - { - components: [ - { - internalType: 'bool', - name: 'enableHookAdjustedAmounts', - type: 'bool', - }, - { - internalType: 'bool', - name: 'shouldCallBeforeInitialize', - type: 'bool', - }, - { - internalType: 'bool', - name: 'shouldCallAfterInitialize', - type: 'bool', + internalType: 'bool', + name: 'shouldCallAfterInitialize', + type: 'bool', }, { internalType: 'bool', @@ -673,475 +278,717 @@ export const balancerV3VaultAbi = [ type: 'address', }, ], - indexed: false, internalType: 'struct HooksConfig', - name: 'hooksConfig', + name: '', type: 'tuple', }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getNonzeroDeltaCount', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'pool', + type: 'address', + }, + ], + name: 'getPoolConfig', + outputs: [ { components: [ + { + internalType: 'uint24', + name: 'staticSwapFeePercentageUnscaled', + type: 'uint24', + }, + { + internalType: 'uint24', + name: 'aggregateProtocolSwapFeePercentageUnscaled', + type: 'uint24', + }, + { + internalType: 'uint24', + name: 'aggregateProtocolYieldFeePercentageUnscaled', + type: 'uint24', + }, + { + internalType: 'uint24', + name: 'tokenDecimalDiffs', + type: 'uint24', + }, + { + internalType: 'uint32', + name: 'pauseWindowEndTime', + type: 'uint32', + }, { internalType: 'bool', - name: 'disableUnbalancedLiquidity', + name: 'isPoolRegistered', type: 'bool', }, { internalType: 'bool', - name: 'enableAddLiquidityCustom', + name: 'isPoolInitialized', type: 'bool', }, { internalType: 'bool', - name: 'enableRemoveLiquidityCustom', + name: 'isPoolPaused', + type: 'bool', + }, + { + internalType: 'bool', + name: 'isPoolInRecoveryMode', + type: 'bool', + }, + { + internalType: 'bool', + name: 'disableUnbalancedLiquidity', type: 'bool', }, { internalType: 'bool', - name: 'enableDonation', + name: 'enableAddLiquidityCustom', + type: 'bool', + }, + { + internalType: 'bool', + name: 'enableRemoveLiquidityCustom', type: 'bool', }, ], - indexed: false, - internalType: 'struct LiquidityManagement', - name: 'liquidityManagement', + internalType: 'struct PoolConfig', + name: '', type: 'tuple', }, ], - name: 'PoolRegistered', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'contract IProtocolFeeController', - name: 'newProtocolFeeController', - type: 'address', - }, - ], - name: 'ProtocolFeeControllerChanged', - type: 'event', + stateMutability: 'view', + type: 'function', }, { - anonymous: false, inputs: [ { - indexed: true, internalType: 'address', name: 'pool', type: 'address', }, + ], + name: 'getPoolPausedState', + outputs: [ { - indexed: true, - internalType: 'contract IERC20', - name: 'tokenIn', - type: 'address', - }, - { - indexed: true, - internalType: 'contract IERC20', - name: 'tokenOut', - type: 'address', - }, - { - indexed: false, - internalType: 'uint256', - name: 'amountIn', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'amountOut', - type: 'uint256', + internalType: 'bool', + name: '', + type: 'bool', }, { - indexed: false, - internalType: 'uint256', - name: 'swapFeePercentage', - type: 'uint256', + internalType: 'uint32', + name: '', + type: 'uint32', }, { - indexed: false, - internalType: 'uint256', - name: 'swapFeeAmount', - type: 'uint256', + internalType: 'uint32', + name: '', + type: 'uint32', }, { - indexed: false, - internalType: 'contract IERC20', - name: 'swapFeeToken', + internalType: 'address', + name: '', type: 'address', }, ], - name: 'Swap', - type: 'event', + stateMutability: 'view', + type: 'function', }, { - anonymous: false, inputs: [ { - indexed: true, internalType: 'address', name: 'pool', type: 'address', }, + ], + name: 'getPoolRoleAccounts', + outputs: [ { - indexed: false, - internalType: 'uint256', - name: 'swapFeePercentage', - type: 'uint256', + components: [ + { + internalType: 'address', + name: 'pauseManager', + type: 'address', + }, + { + internalType: 'address', + name: 'swapFeeManager', + type: 'address', + }, + { + internalType: 'address', + name: 'poolCreator', + type: 'address', + }, + ], + internalType: 'struct PoolRoleAccounts', + name: '', + type: 'tuple', }, ], - name: 'SwapFeePercentageChanged', - type: 'event', + stateMutability: 'view', + type: 'function', }, { - anonymous: false, inputs: [ { - indexed: true, internalType: 'address', name: 'pool', type: 'address', }, + ], + name: 'getPoolTokenInfo', + outputs: [ { - indexed: true, - internalType: 'address', - name: 'from', - type: 'address', + components: [ + { + internalType: 'contract IERC20', + name: 'token', + type: 'address', + }, + { + internalType: 'enum TokenType', + name: 'tokenType', + type: 'uint8', + }, + { + internalType: 'contract IRateProvider', + name: 'rateProvider', + type: 'address', + }, + { + internalType: 'bool', + name: 'paysYieldFees', + type: 'bool', + }, + ], + internalType: 'struct TokenConfig[]', + name: 'tokenConfig', + type: 'tuple[]', }, { - indexed: true, - internalType: 'address', - name: 'to', - type: 'address', + internalType: 'uint256[]', + name: 'balancesRaw', + type: 'uint256[]', }, { - indexed: false, - internalType: 'uint256', - name: 'value', - type: 'uint256', + internalType: 'uint256[]', + name: 'scalingFactors', + type: 'uint256[]', }, ], - name: 'Transfer', - type: 'event', + stateMutability: 'view', + type: 'function', }, { - anonymous: false, inputs: [ { - indexed: true, - internalType: 'contract IERC4626', - name: 'wrappedToken', + internalType: 'address', + name: 'pool', type: 'address', }, + ], + name: 'getPoolTokens', + outputs: [ { - indexed: true, - internalType: 'contract IERC20', - name: 'underlyingToken', - type: 'address', + internalType: 'contract IERC20[]', + name: '', + type: 'address[]', }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ { - indexed: false, - internalType: 'uint256', - name: 'burnedShares', - type: 'uint256', + internalType: 'contract IERC20', + name: 'token', + type: 'address', }, + ], + name: 'getReservesOf', + outputs: [ { - indexed: false, internalType: 'uint256', - name: 'withdrawnUnderlying', + name: '', type: 'uint256', }, ], - name: 'Unwrap', - type: 'event', + stateMutability: 'view', + type: 'function', }, { - anonymous: false, inputs: [ { - indexed: false, - internalType: 'bool', - name: 'paused', - type: 'bool', + internalType: 'address', + name: 'pool', + type: 'address', + }, + ], + name: 'getStaticSwapFeePercentage', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', }, ], - name: 'VaultPausedStateChanged', - type: 'event', + stateMutability: 'view', + type: 'function', }, { - anonymous: false, inputs: [ { - indexed: true, internalType: 'contract IERC20', - name: 'underlyingToken', + name: 'token', type: 'address', }, + ], + name: 'getTokenDelta', + outputs: [ { - indexed: true, - internalType: 'contract IERC4626', - name: 'wrappedToken', - type: 'address', + internalType: 'int256', + name: '', + type: 'int256', }, - { - indexed: false, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getVaultAdmin', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'pool', + type: 'address', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'contract IERC20[]', + name: 'tokens', + type: 'address[]', + }, + { + internalType: 'uint256[]', + name: 'exactAmountsIn', + type: 'uint256[]', + }, + { internalType: 'uint256', - name: 'depositedUnderlying', + name: 'minBptAmountOut', type: 'uint256', }, { - indexed: false, + internalType: 'bytes', + name: 'userData', + type: 'bytes', + }, + ], + name: 'initialize', + outputs: [ + { internalType: 'uint256', - name: 'mintedShares', + name: 'bptAmountOut', type: 'uint256', }, ], - name: 'Wrap', - type: 'event', + stateMutability: 'nonpayable', + type: 'function', }, - { stateMutability: 'payable', type: 'fallback' }, { inputs: [ { - components: [ - { internalType: 'address', name: 'pool', type: 'address' }, - { internalType: 'address', name: 'to', type: 'address' }, - { - internalType: 'uint256[]', - name: 'maxAmountsIn', - type: 'uint256[]', - }, - { - internalType: 'uint256', - name: 'minBptAmountOut', - type: 'uint256', - }, - { - internalType: 'enum AddLiquidityKind', - name: 'kind', - type: 'uint8', - }, - { internalType: 'bytes', name: 'userData', type: 'bytes' }, - ], - internalType: 'struct AddLiquidityParams', - name: 'params', - type: 'tuple', + internalType: 'address', + name: 'pool', + type: 'address', }, ], - name: 'addLiquidity', + name: 'isPoolInRecoveryMode', outputs: [ - { internalType: 'uint256[]', name: 'amountsIn', type: 'uint256[]' }, - { internalType: 'uint256', name: 'bptAmountOut', type: 'uint256' }, - { internalType: 'bytes', name: 'returnData', type: 'bytes' }, + { + internalType: 'bool', + name: '', + type: 'bool', + }, ], - stateMutability: 'nonpayable', + stateMutability: 'view', type: 'function', }, { inputs: [ { - components: [ - { - internalType: 'enum SwapKind', - name: 'kind', - type: 'uint8', - }, - { - internalType: 'enum WrappingDirection', - name: 'direction', - type: 'uint8', - }, - { - internalType: 'contract IERC4626', - name: 'wrappedToken', - type: 'address', - }, - { - internalType: 'uint256', - name: 'amountGivenRaw', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'limitRaw', - type: 'uint256', - }, - { internalType: 'bytes', name: 'userData', type: 'bytes' }, - ], - internalType: 'struct BufferWrapOrUnwrapParams', - name: 'params', - type: 'tuple', + internalType: 'address', + name: 'pool', + type: 'address', }, ], - name: 'erc4626BufferWrapOrUnwrap', + name: 'isPoolInitialized', outputs: [ { - internalType: 'uint256', - name: 'amountCalculatedRaw', - type: 'uint256', + internalType: 'bool', + name: '', + type: 'bool', }, - { internalType: 'uint256', name: 'amountInRaw', type: 'uint256' }, - { internalType: 'uint256', name: 'amountOutRaw', type: 'uint256' }, ], - stateMutability: 'nonpayable', + stateMutability: 'view', type: 'function', }, { - inputs: [], - name: 'getAuthorizer', - outputs: [{ internalType: 'contract IAuthorizer', name: '', type: 'address' }], + inputs: [ + { + internalType: 'address', + name: 'pool', + type: 'address', + }, + ], + name: 'isPoolPaused', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], stateMutability: 'view', type: 'function', }, { inputs: [ - { internalType: 'address', name: 'pool', type: 'address' }, - { internalType: 'contract IERC20', name: 'token', type: 'address' }, + { + internalType: 'address', + name: 'pool', + type: 'address', + }, ], - name: 'getPoolTokenCountAndIndexOfToken', + name: 'isPoolRegistered', outputs: [ - { internalType: 'uint256', name: '', type: 'uint256' }, - { internalType: 'uint256', name: '', type: 'uint256' }, + { + internalType: 'bool', + name: '', + type: 'bool', + }, ], stateMutability: 'view', type: 'function', }, { inputs: [], - name: 'getVaultExtension', - outputs: [{ internalType: 'address', name: '', type: 'address' }], + name: 'isQueryDisabled', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], stateMutability: 'view', type: 'function', }, { inputs: [], - name: 'reentrancyGuardEntered', - outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + name: 'isUnlocked', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], stateMutability: 'view', type: 'function', }, { inputs: [ { - components: [ - { internalType: 'address', name: 'pool', type: 'address' }, - { internalType: 'address', name: 'from', type: 'address' }, - { - internalType: 'uint256', - name: 'maxBptAmountIn', - type: 'uint256', - }, - { - internalType: 'uint256[]', - name: 'minAmountsOut', - type: 'uint256[]', - }, - { - internalType: 'enum RemoveLiquidityKind', - name: 'kind', - type: 'uint8', - }, - { internalType: 'bytes', name: 'userData', type: 'bytes' }, - ], - internalType: 'struct RemoveLiquidityParams', - name: 'params', - type: 'tuple', + internalType: 'bytes', + name: 'data', + type: 'bytes', }, ], - name: 'removeLiquidity', + name: 'quote', outputs: [ - { internalType: 'uint256', name: 'bptAmountIn', type: 'uint256' }, { - internalType: 'uint256[]', - name: 'amountsOut', - type: 'uint256[]', + internalType: 'bytes', + name: 'result', + type: 'bytes', }, - { internalType: 'bytes', name: 'returnData', type: 'bytes' }, ], - stateMutability: 'nonpayable', + stateMutability: 'payable', type: 'function', }, { inputs: [ - { internalType: 'contract IERC20', name: 'token', type: 'address' }, - { internalType: 'address', name: 'to', type: 'address' }, - { internalType: 'uint256', name: 'amount', type: 'uint256' }, + { + internalType: 'bytes', + name: 'data', + type: 'bytes', + }, ], - name: 'sendTo', + name: 'quoteAndRevert', outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { internalType: 'contract IERC20', name: 'token', type: 'address' }, - { internalType: 'uint256', name: 'amountHint', type: 'uint256' }, - ], - name: 'settle', - outputs: [{ internalType: 'uint256', name: 'credit', type: 'uint256' }], - stateMutability: 'nonpayable', + stateMutability: 'payable', type: 'function', }, { inputs: [ + { + internalType: 'address', + name: 'pool', + type: 'address', + }, { components: [ { - internalType: 'enum SwapKind', - name: 'kind', + internalType: 'contract IERC20', + name: 'token', + type: 'address', + }, + { + internalType: 'enum TokenType', + name: 'tokenType', type: 'uint8', }, - { internalType: 'address', name: 'pool', type: 'address' }, { - internalType: 'contract IERC20', - name: 'tokenIn', + internalType: 'contract IRateProvider', + name: 'rateProvider', type: 'address', }, { - internalType: 'contract IERC20', - name: 'tokenOut', + internalType: 'bool', + name: 'paysYieldFees', + type: 'bool', + }, + ], + internalType: 'struct TokenConfig[]', + name: 'tokenConfig', + type: 'tuple[]', + }, + { + internalType: 'uint256', + name: 'swapFeePercentage', + type: 'uint256', + }, + { + internalType: 'uint32', + name: 'pauseWindowEndTime', + type: 'uint32', + }, + { + components: [ + { + internalType: 'address', + name: 'pauseManager', type: 'address', }, { - internalType: 'uint256', - name: 'amountGivenRaw', - type: 'uint256', + internalType: 'address', + name: 'swapFeeManager', + type: 'address', }, { - internalType: 'uint256', - name: 'limitRaw', - type: 'uint256', + internalType: 'address', + name: 'poolCreator', + type: 'address', }, - { internalType: 'bytes', name: 'userData', type: 'bytes' }, ], - internalType: 'struct SwapParams', - name: 'params', + internalType: 'struct PoolRoleAccounts', + name: 'roleAccounts', type: 'tuple', }, + { + internalType: 'address', + name: 'poolHooksContract', + type: 'address', + }, + { + components: [ + { + internalType: 'bool', + name: 'disableUnbalancedLiquidity', + type: 'bool', + }, + { + internalType: 'bool', + name: 'enableAddLiquidityCustom', + type: 'bool', + }, + { + internalType: 'bool', + name: 'enableRemoveLiquidityCustom', + type: 'bool', + }, + ], + internalType: 'struct LiquidityManagement', + name: 'liquidityManagement', + type: 'tuple', + }, + ], + name: 'registerPool', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'pool', + type: 'address', + }, + { + internalType: 'address', + name: 'from', + type: 'address', + }, + { + internalType: 'uint256', + name: 'exactBptAmountIn', + type: 'uint256', + }, + ], + name: 'removeLiquidityRecovery', + outputs: [ + { + internalType: 'uint256[]', + name: 'amountsOut', + type: 'uint256[]', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'token', + type: 'address', + }, ], - name: 'swap', + name: 'totalSupply', outputs: [ { internalType: 'uint256', - name: 'amountCalculated', + name: '', type: 'uint256', }, - { internalType: 'uint256', name: 'amountIn', type: 'uint256' }, - { internalType: 'uint256', name: 'amountOut', type: 'uint256' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'transfer', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, ], stateMutability: 'nonpayable', type: 'function', }, { - inputs: [{ internalType: 'bytes', name: 'data', type: 'bytes' }], - name: 'unlock', - outputs: [{ internalType: 'bytes', name: 'result', type: 'bytes' }], + inputs: [ + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'address', + name: 'from', + type: 'address', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'transferFrom', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], stateMutability: 'nonpayable', type: 'function', }, - { stateMutability: 'payable', type: 'receive' }, + { + inputs: [], + name: 'vault', + outputs: [ + { + internalType: 'contract IVault', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, ] as const