import { Interface } from '@ethersproject/abi'; import { DeepReadonly } from 'ts-essentials'; import { AdapterExchangeParam, Address, DexExchangeParam, ExchangePrices, ExchangeTxInfo, Log, Logger, PoolLiquidity, PoolPrices, PreprocessTransactionOptions, SimpleExchangeParam, Token, TxInfo } from '../../types'; import { Network, SwapSide } from '../../constants'; import { StablePool } from './pools/stable/StablePool'; import { WeightedPool } from './pools/weighted/WeightedPool'; import { PhantomStablePool } from './pools/phantom-stable/PhantomStablePool'; import { LinearPool } from './pools/linear/LinearPool'; import { Gyro3Pool } from './pools/gyro/Gyro3Pool'; import { GyroEPool } from './pools/gyro/GyroEPool'; import { StatefulEventSubscriber } from '../../stateful-event-subscriber'; import { Context, IDex } from '../../dex/idex'; import { IDexHelper } from '../../dex-helper'; import { BalancerV2BatchSwapParam, BalancerPoolTypes, BalancerV2Data, BalancerV2DirectParam, FallbackPool, OptimizedBalancerV2Data, PoolState, PoolStateCache, PoolStateMap, SubgraphPoolBase, BalancerV2DirectParamV6, BalancerV2DirectParamV6Swap, BalancerV2SwapParam } from './types'; import { SimpleExchange } from '../simple-exchange'; import { NumberAsString, OptimalSwapExchange } from '@paraswap/core'; export declare class BalancerV2EventPool extends StatefulEventSubscriber { protected network: number; vaultAddress: Address; protected apiNetworkName: string; protected dexHelper: IDexHelper; protected fallbackPools: FallbackPool[]; vaultInterface: Interface; handlers: { [event: string]: (event: any, pool: PoolState, log: Log) => PoolState; }; pools: { [type: string]: WeightedPool | StablePool | LinearPool | PhantomStablePool | Gyro3Pool | GyroEPool; }; allPools: SubgraphPoolBase[]; vaultDecoder: (log: Log) => any; buySupportedPoolTypes: Set; eventSupportedPoolTypes: BalancerPoolTypes[]; eventRemovedPools: string[]; constructor(parentName: string, network: number, vaultAddress: Address, apiNetworkName: string, dexHelper: IDexHelper, logger: Logger, fallbackPools?: FallbackPool[]); protected processLog(state: DeepReadonly, log: Readonly): DeepReadonly | null; fetchAllApiPools(): Promise; private buildPoolsFromFallback; generateState(blockNumber: number): Promise>; handleSwap(event: any, pool: PoolState, log: Log): PoolState; handlePoolBalanceChanged(event: any, pool: PoolState, log: Log): PoolState; isSupportedPool(poolType: string): boolean; getPricesPool(from: Token, to: Token, subgraphPool: SubgraphPoolBase, poolState: PoolState, amounts: bigint[], unitVolume: bigint, side: SwapSide): { unit: bigint; prices: bigint[]; } | null; getOnChainState(subgraphPoolBase: SubgraphPoolBase[], blockNumber: number): Promise; } export declare class BalancerV2 extends SimpleExchange implements IDex { protected network: Network; dexHelper: IDexHelper; vaultAddress: Address; protected subgraphURL: string; protected apiNetworkName: string; protected adapters: import("../../types").AdapterMappings; protected fallbackPools: FallbackPool[]; eventPools: BalancerV2EventPool; readonly hasConstantPriceLargeAmounts = false; readonly isFeeOnTransferSupported = false; readonly needWrapNative = true; readonly directSwapIface: Interface; readonly balancerVaultInterface: Interface; static dexKeysWithNetwork: { key: string; networks: Network[]; }[]; logger: Logger; nonEventPoolStateCache: PoolStateCache; eventDisabledPoolsTimer?: NodeJS.Timeout; eventDisabledPools: Address[]; constructor(network: Network, dexKey: string, dexHelper: IDexHelper, vaultAddress?: Address, subgraphURL?: string, apiNetworkName?: string, adapters?: import("../../types").AdapterMappings, fallbackPools?: FallbackPool[]); setupEventPools(blockNumber: number): Promise; fetchEventDisabledPools(): Promise; initializePricing(blockNumber: number): Promise; releaseResources(): void; getPoolsWithTokenPair(from: Token, to: Token): SubgraphPoolBase[]; getAdapters(side: SwapSide): { name: string; index: number; }[] | null; getPoolIdentifiers(from: Token, to: Token, side: SwapSide, blockNumber: number): Promise; /** * Returns cached poolState if blockNumber matches cached value. Resets if not. */ private getNonEventPoolStateCache; /** * Update poolState cache. * If same blockNumber as current cache then update with new pool state. * If different blockNumber overwrite cache with latest. */ private updateNonEventPoolStateCache; getPricesVolume(from: Token, to: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise>; getCalldataGasCost(poolPrices: PoolPrices): number | number[]; getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: OptimizedBalancerV2Data, side: SwapSide): AdapterExchangeParam; getBalancerV2SwapParam(srcToken: string, destToken: string, data: OptimizedBalancerV2Data, side: SwapSide, recipient: string, sender: string): BalancerV2SwapParam; getBalancerV2BatchSwapParam(srcToken: string, destToken: string, data: OptimizedBalancerV2Data, side: SwapSide, recipient: string, sender: string, shouldWalkAssetsBackward?: boolean): BalancerV2BatchSwapParam; static getDirectFunctionName(): string[]; preProcessTransaction(optimalSwapExchange: OptimalSwapExchange, srcToken: Token, _0: Token, _1: SwapSide, options: PreprocessTransactionOptions): Promise<[OptimalSwapExchange, ExchangeTxInfo]>; getDirectParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, expectedAmount: NumberAsString, data: OptimizedBalancerV2Data, side: SwapSide, permit: string, uuid: string, feePercent: NumberAsString, deadline: NumberAsString, partner: string, beneficiary: string, contractMethod: string): TxInfo; getDirectParamV6(srcToken: Address, destToken: Address, fromAmount: NumberAsString, toAmount: NumberAsString, quotedAmount: NumberAsString, data: OptimizedBalancerV2Data, side: SwapSide, permit: string, uuid: string, partnerAndFee: string, beneficiary: string, blockNumber: number, contractMethod: string): { encoder: (params: BalancerV2DirectParamV6, partnerAndFee: string, permit: string, balancerParams: string) => string; params: BalancerV2DirectParamV6Swap; networkFee: string; }; private encodeBeneficiaryAndApproveFlag; private encodeBalancerV2SwapParam; private encodeBalancerV2BatchSwapParam; static getDirectFunctionNameV6(): string[]; getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: OptimizedBalancerV2Data, side: SwapSide): Promise; getDexParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, recipient: Address, data: OptimizedBalancerV2Data, side: SwapSide, context: Context, executor: Address): DexExchangeParam; updatePoolState(): Promise; getTopPoolsForToken(_tokenAddress: Address, count: number): Promise; private get poolAddressMap(); private get poolIdMap(); }