import { OptimalRoute, OptimalRate, OptimalSwap, OptimalSwapExchange } from '@paraswap/core'; import { DexExchangeBuildParam } from '../types'; import { Executors, Flag } from './types'; import { DepositWithdrawReturn } from '../dex/weth/types'; import { DexCallDataParams, ExecutorBytecodeBuilder, SingleSwapCallDataParams } from './ExecutorBytecodeBuilder'; export type Executor02SingleSwapCallDataParams = { routeIndex: number; swapIndex: number; wrapToSwapMap: { [key: number]: boolean; }; unwrapToSwapMap: { [key: number]: boolean; }; wrapToSwapExchangeMap: { [key: string]: boolean; }; swap: OptimalSwap; }; export type Executor02DexCallDataParams = { swapExchange: OptimalSwapExchange; }; /** * Class to build bytecode for Executor02 - simpleSwap with N DEXs (VERTICAL_BRANCH), multiSwaps (VERTICAL_BRANCH_HORIZONTAL_SEQUENCE) and megaswaps (NESTED_VERTICAL_BRANCH_HORIZONTAL_SEQUENCE) */ export declare class Executor02BytecodeBuilder extends ExecutorBytecodeBuilder { type: Executors; /** * Executor02 Flags: * switch (flag % 4): * case 0: don't instert fromAmount * case 1: sendEth equal to fromAmount * case 2: sendEth equal to fromAmount + insert fromAmount * case 3: insert fromAmount * switch (flag % 3): * case 0: don't check balance after swap * case 1: check eth balance after swap * case 2: check destToken balance after swap */ protected buildSimpleSwapFlags(priceRoute: OptimalRate, exchangeParams: DexExchangeBuildParam[], routeIndex: number, swapIndex: number, swapExchangeIndex: number, exchangeParamIndex: number, maybeWethCallData?: DepositWithdrawReturn): { dexFlag: Flag; approveFlag: Flag; }; /** * Executor02 Flags: * switch (flag % 4): * case 0: don't instert fromAmount * case 1: sendEth equal to fromAmount * case 2: sendEth equal to fromAmount + insert fromAmount * case 3: insert fromAmount * switch (flag % 3): * case 0: don't check balance after swap * case 1: check eth balance after swap * case 2: check destToken balance after swap */ protected buildMultiMegaSwapFlags(priceRoute: OptimalRate, exchangeParams: DexExchangeBuildParam[], routeIndex: number, swapIndex: number, swapExchangeIndex: number, exchangeParamIndex: number, maybeWethCallData?: DepositWithdrawReturn): { dexFlag: Flag; approveFlag: Flag; }; protected buildDexCallData(params: DexCallDataParams): string; private addMultiSwapMetadata; private packVerticalBranchingData; private packVerticalBranchingCallData; private buildVerticalBranchingCallData; /** * Where an ETH-dest final-hop branch leaves its output. Everything outside a * revertable group (root unwrap/send, threading flags, sibling accounting) * is computed from the primary's params, so the fallback block must end in * the same place the try block would. */ private ethDestOutcome; /** * Wrap an already-assembled per-exchange unit in a revertable fallback group * (specialDex 0xFF). The step's calldata payload is [28-byte padding] * [tryLen(4)][fallbackLen(4)][try-block][fallback-block]; the try-block is the * unit as it would have run inline, the fallback-block is the alternative's * unit. On-chain, Executor02 runs the try-block in a self-call and, on revert, * runs the fallback-block from the same input. * * Threading: when the group sits directly in a horizontal sequence * (insidePath = false) it must thread the running amount to the next step, so * it uses the vertical-branching wrapper's flag/destTokenPos semantics. When * it is a member of a split (insidePath = true), the vertical-branching * wrapper above it does the threading, so the group skips the balance check. */ private wrapInRevertableGroup; private buildSingleSwapExchangeCallData; private appendWrapEthCallData; private eachDexOnSwapNeedsWrapNative; private anyDexOnSwapNeedsWrapNative; private isLastExchangeWithNeedWrapNative; private getSwapExchangesWhichNeedWrapNative; private getSwapExchangesWhichDontNeedWrapNative; private anyDexOnSwapDoesntNeedWrapNative; private everyDexOnSwapNeedWrapNative; private everyDexOnSwapDoesntNeedWrapNative; private doesSwapNeedToApplyVerticalBranching; private buildVerticalBranchingFlag; protected buildSingleSwapCallData(params: SingleSwapCallDataParams): string; protected buildSingleRouteCallData(priceRoute: OptimalRate, exchangeParams: DexExchangeBuildParam[], route: OptimalRoute, routeIndex: number, flags: { approves: Flag[]; dexes: Flag[]; wrap: Flag; }, sender: string, maybeWethCallData?: DepositWithdrawReturn): string; private doesRouteNeedsRootWrapEth; private doesRouteNeedsRootUnwrapEth; getAddress(): string; buildByteCode(priceRoute: OptimalRate, exchangeParams: DexExchangeBuildParam[], sender: string, maybeWethCallData?: DepositWithdrawReturn): string; }