import { type Abi, type Address, type Hex, type StateOverride } from "viem"; import type { AddressOrAccount } from "../../entities/Account.js"; import type { EulerPlugin, PluginPrefetchData } from "../../plugins/types.js"; import type { IDeploymentService } from "../deploymentService/index.js"; import type { IABIService } from "../abiService/index.js"; import type { IEulerLabelsService } from "../eulerLabelsService/index.js"; import type { IIntrinsicApyService } from "../intrinsicApyService/index.js"; import type { IPriceService } from "../priceService/index.js"; import type { ProviderService } from "../providerService/index.js"; import type { IRewardsService } from "../rewardsService/index.js"; import { type IVaultMetaService, type VaultEntity } from "../vaults/vaultMetaService/index.js"; import type { IWalletService } from "../walletService/index.js"; import { type CowSwapTransactionPlanExecutionResult, type ExecuteCowSwapTransactionPlanArgs } from "./cowExecutor.js"; import { type ExecutePreparedTransactionPlanArgs, type ExecuteTransactionPlanArgs, type TransactionPlanExecutionResult } from "./execute.js"; import { type ExecuteMaterializedOptions, type FinalizedMaterializedExecution, type MaterializedExecution, type MaterializedExecutionResult, type MaterializedSignatureValue, type MaterializeExecutionArgs } from "./materializedExecution.js"; import type { BatchEntryDescription, BatchItemDescription, EncodeBorrowArgs, EncodeDepositArgs, EncodeDepositWithSwapFromWalletArgs, EncodeLiquidationArgs, EncodeMigrateSameAssetCollateralArgs, EncodeMigrateSameAssetDebtArgs, EncodeMigrationAuthorizationCallArgs, EncodeMintArgs, EncodeMultiplySameAssetArgs, EncodeMultiplyWithSwapArgs, EncodePermit2CallArgs, EncodePullDebtArgs, EncodeRedeemAndSwapArgs, EncodeRedeemArgs, EncodeRepayFromDepositArgs, EncodeRepayFromWalletArgs, EncodeRepayWithSwapArgs, EncodeSwapAndBorrowFromWalletArgs, EncodeSwapAndRepayFromWalletArgs, EncodeSwapCollateralArgs, EncodeSwapDebtArgs, EncodeSwapFromWalletArgs, EncodeTransferArgs, EncodeWithdrawAndSwapArgs, EncodeWithdrawArgs, EVCBatchEntry, EVCBatchItem, GetPermit2TypedDataArgs, PermitSingleTypedData, PlanBorrowArgs, PlanCancelClosePositionWithCowArgs, PlanCleanupArgs, PlanClosePositionWithCowArgs, PlanDepositArgs, PlanDepositWithSwapFromWalletArgs, PlanLiquidationArgs, PlanMigrateSameAssetCollateralArgs, PlanMigrateSameAssetDebtArgs, PlanMintArgs, PlanMultiplySameAssetArgs, PlanMultiplyWithSwapArgs, PlanOpenPositionWithCoWArgs, PlanPullDebtArgs, PlanRedeemAndSwapArgs, PlanRedeemArgs, PlanRepayFromDepositArgs, PlanRepayFromWalletArgs, PlanRepayWithSwapArgs, PlanSwapAndBorrowFromWalletArgs, PlanSwapAndRepayFromWalletArgs, PlanSwapCollateralArgs, PlanSwapCollateralWithCoWArgs, PlanSwapDebtArgs, PlanSwapFromWalletArgs, PlanTransferArgs, PlanWithdrawAndSwapArgs, PlanWithdrawArgs, ResolveRequiredApprovalsArgs, ResolveRequiredApprovalsWithWalletArgs, TransactionPlan, TransactionPlanItem, TransactionPlanPrepared } from "./executionServiceTypes.js"; import { type EstimateGasForTransactionPlanOptions, type SimulateBatchOptions, type SimulateBatchResult, type SimulationStateOverrideOptions } from "./simulate.js"; export interface IExecutionService { deriveStateOverrides(chainId: number, account: Address, transactionPlan: TransactionPlan, options?: SimulationStateOverrideOptions): Promise; simulateTransactionPlan(chainId: number, account: AddressOrAccount, transactionPlan: TransactionPlan, options?: SimulateBatchOptions & { prefetch?: PluginPrefetchData; }): Promise>; /** * Simulate an already prepared envelope without rerunning plugins or approval * resolution. * @see docs/simulations-and-state-overrides.md */ simulatePreparedTransactionPlan(prepared: TransactionPlanPrepared, options?: SimulateBatchOptions): Promise>; estimateGasForTransactionPlan(chainId: number, account: AddressOrAccount, transactionPlan: TransactionPlan, options?: EstimateGasForTransactionPlanOptions & { prefetch?: PluginPrefetchData; }): Promise; /** * Estimate gas for a {@link TransactionPlanPrepared} envelope. Plugins and * approval resolution have already run via {@link prepareTransactionPlan}, * so this skips the plugin pipeline (TOS / Keyring / Pyth) and uses the * envelope's chainId/account context directly. Use this from quote-sweep * gas estimation when an envelope is already in hand to avoid re-running * plugins per quote. */ estimateGasForPreparedTransactionPlan(prepared: TransactionPlanPrepared, options?: EstimateGasForTransactionPlanOptions): Promise; resolveRequiredApprovalsWithWallet(args: ResolveRequiredApprovalsWithWalletArgs): TransactionPlan; resolveRequiredApprovals(args: ResolveRequiredApprovalsArgs): Promise; /** * Run plugins and resolve required approvals up front, packaging the result * with its execution context so simulate/execute can be called repeatedly * without re-running plugins or refetching wallet allowances. * @see docs/simulations-and-state-overrides.md */ prepareTransactionPlan(args: { plan: TransactionPlan; chainId: number; account: AddressOrAccount; usePermit2?: boolean; unlimitedApproval?: boolean; prefetch?: PluginPrefetchData; }): Promise; /** * Run each plugin's processPlan in registration order. Lower-level than * prepare/simulate/estimate — callers usually want those. Exposed for * advanced flows that want to materialise the plugin-processed plan once * and feed it into multiple downstream calls. */ processPlanPlugins(plan: TransactionPlan, account: AddressOrAccount, chainId: number, prefetch?: PluginPrefetchData): Promise; /** * Resolve each plugin's prefetch payload for a given plan once. Pass the * returned record to subsequent prepare/simulate/estimate/execute calls so * plugins skip their own network I/O on each invocation. */ prefetchPluginDataForPlan(plan: TransactionPlan, account: AddressOrAccount, chainId: number): Promise; /** * Prepare and execute a raw plan. Callers that expose a review boundary * should prefer the materialized execution APIs. * @see docs/execution-service.md */ executeTransactionPlan(args: ExecuteTransactionPlanArgs): Promise; /** * Execute an already prepared envelope without rerunning plugins or approval * resolution. This still performs execution-time Permit2 composition. * @see docs/execution-service.md */ executePreparedTransactionPlan(args: ExecutePreparedTransactionPlanArgs): Promise; /** Deterministically compose a prepared plan using only explicit live inputs. */ materializeExecution(args: MaterializeExecutionArgs): MaterializedExecution; /** Purely insert the declared signatures into a new immutable request vector. */ finalizeMaterializedExecution(materialized: MaterializedExecution, signatures: readonly MaterializedSignatureValue[]): FinalizedMaterializedExecution; /** * Sign, finalize, and dispatch the exact materialized request vector. A * supplied FinalizedMaterializedExecution is trusted application input and * must already be authenticated against the application's accepted review * digest; the SDK does not authenticate it. * @see docs/execution-service.md */ executeMaterialized(materialized: MaterializedExecution | FinalizedMaterializedExecution, options: ExecuteMaterializedOptions): Promise; executeCowSwapTransactionPlan(args: ExecuteCowSwapTransactionPlanArgs): Promise; encodeBatch(items: EVCBatchItem[]): Hex; encodeDeposit(args: EncodeDepositArgs): EVCBatchItem[]; encodeMint(args: EncodeMintArgs): EVCBatchItem[]; encodeWithdraw(args: EncodeWithdrawArgs): EVCBatchItem[]; encodeRedeem(args: EncodeRedeemArgs): EVCBatchItem[]; encodeBorrow(args: EncodeBorrowArgs): EVCBatchItem[]; encodeLiquidation(args: EncodeLiquidationArgs): EVCBatchItem[]; encodePullDebt(args: EncodePullDebtArgs): EVCBatchItem[]; encodeRepayFromWallet(args: EncodeRepayFromWalletArgs): EVCBatchItem[]; encodeRepayFromDeposit(args: EncodeRepayFromDepositArgs): EVCBatchItem[]; encodeRepayWithSwap(args: EncodeRepayWithSwapArgs): EVCBatchItem[]; encodeDepositWithSwapFromWallet(args: EncodeDepositWithSwapFromWalletArgs): EVCBatchItem[]; encodeSwapFromWallet(args: EncodeSwapFromWalletArgs): EVCBatchItem[]; encodeSwapAndBorrowFromWallet(args: EncodeSwapAndBorrowFromWalletArgs): EVCBatchItem[]; encodeSwapAndRepayFromWallet(args: EncodeSwapAndRepayFromWalletArgs): EVCBatchItem[]; encodeWithdrawAndSwap(args: EncodeWithdrawAndSwapArgs): EVCBatchItem[]; encodeRedeemAndSwap(args: EncodeRedeemAndSwapArgs): EVCBatchItem[]; encodeSwapCollateral(args: EncodeSwapCollateralArgs): EVCBatchItem[]; encodeSwapDebt(args: EncodeSwapDebtArgs): EVCBatchItem[]; encodeMigrateSameAssetCollateral(args: EncodeMigrateSameAssetCollateralArgs): EVCBatchItem[]; encodeMigrateSameAssetDebt(args: EncodeMigrateSameAssetDebtArgs): EVCBatchItem[]; encodeTransfer(args: EncodeTransferArgs): EVCBatchItem[]; encodeMultiplyWithSwap(args: EncodeMultiplyWithSwapArgs): EVCBatchItem[]; encodeMultiplySameAsset(args: EncodeMultiplySameAssetArgs): EVCBatchItem[]; encodePermit2Call(args: EncodePermit2CallArgs): EVCBatchItem; encodeMigrationAuthorizationCall(args: EncodeMigrationAuthorizationCallArgs): EVCBatchItem; encodeEnableCollateral(chainId: number, account: Address, vault: Address): EVCBatchItem; encodeDisableCollateral(chainId: number, account: Address, vault: Address): EVCBatchItem; encodeEnableController(chainId: number, account: Address, vault: Address): EVCBatchItem; encodeDisableController(vault: Address, account: Address): EVCBatchItem; encodeTransferFromMax(vault: Address, from: Address, to: Address): EVCBatchItem; /** Transaction plan functions: build plan items (approvals + EVC batch) for each operation. See implementation JSDoc for argument details. */ planCleanup(args: PlanCleanupArgs): TransactionPlan; planDeposit(args: PlanDepositArgs): TransactionPlan; planMint(args: PlanMintArgs): TransactionPlan; planWithdraw(args: PlanWithdrawArgs): TransactionPlan; planRedeem(args: PlanRedeemArgs): TransactionPlan; planBorrow(args: PlanBorrowArgs): TransactionPlan; planLiquidation(args: PlanLiquidationArgs): TransactionPlan; planRepayFromWallet(args: PlanRepayFromWalletArgs): TransactionPlan; planRepayFromDeposit(args: PlanRepayFromDepositArgs): TransactionPlan; planRepayWithSwap(args: PlanRepayWithSwapArgs): TransactionPlan; planDepositWithSwapFromWallet(args: PlanDepositWithSwapFromWalletArgs): TransactionPlan; planSwapFromWallet(args: PlanSwapFromWalletArgs): TransactionPlan; planSwapAndBorrowFromWallet(args: PlanSwapAndBorrowFromWalletArgs): TransactionPlan; planSwapAndRepayFromWallet(args: PlanSwapAndRepayFromWalletArgs): TransactionPlan; planWithdrawAndSwap(args: PlanWithdrawAndSwapArgs): TransactionPlan; planRedeemAndSwap(args: PlanRedeemAndSwapArgs): TransactionPlan; planSwapCollateral(args: PlanSwapCollateralArgs): TransactionPlan; planSwapDebt(args: PlanSwapDebtArgs): TransactionPlan; planMigrateSameAssetCollateral(args: PlanMigrateSameAssetCollateralArgs): TransactionPlan; planMigrateSameAssetDebt(args: PlanMigrateSameAssetDebtArgs): TransactionPlan; planTransfer(args: PlanTransferArgs): TransactionPlan; planPullDebt(args: PlanPullDebtArgs): TransactionPlan; planMultiplyWithSwap(args: PlanMultiplyWithSwapArgs): TransactionPlan; planOpenPositionWithCoW(args: PlanOpenPositionWithCoWArgs): TransactionPlan; planClosePositionWithCow(args: PlanClosePositionWithCowArgs): TransactionPlan; planCancelClosePositionWithCow(args: PlanCancelClosePositionWithCowArgs): TransactionPlan; planSwapCollateralWithCoW(args: PlanSwapCollateralWithCoWArgs): TransactionPlan; planMultiplySameAsset(args: PlanMultiplySameAssetArgs): TransactionPlan; getPermit2TypedData(args: GetPermit2TypedDataArgs): PermitSingleTypedData; describeBatch(batch: readonly EVCBatchItem[], extraAbis?: Abi[]): BatchItemDescription[]; describeBatch(batch: readonly EVCBatchEntry[], extraAbis?: Abi[]): BatchEntryDescription[]; /** Merges multiple plans into one: required approvals are summed, adjacent EVC batches are concatenated, and operation groupings are preserved. */ mergePlans(plans: TransactionPlan[]): TransactionPlan; /** Converts EVC batch items into a transaction plan (single evcBatch, no required approvals). */ convertBatchItemsToPlan(items: EVCBatchItem[], operationName?: string): TransactionPlan; /** Appends a single batch item to the last EVC batch in the plan, creating one if needed. */ addBatchItemToPlan(plan: TransactionPlan, item: EVCBatchItem): TransactionPlan; } export type ProcessPlanPlugins = (plan: TransactionPlan, account: AddressOrAccount, chainId: number, prefetch?: PluginPrefetchData) => Promise; export type PrefetchPlanPlugins = (plan: TransactionPlan, account: AddressOrAccount, chainId: number) => Promise; export declare class ExecutionService implements IExecutionService { private deploymentService; private plugins; private walletService?; private providerService?; private vaultMetaService?; private priceService?; private rewardsService?; private intrinsicApyService?; private eulerLabelsService?; private abiService?; private processPlugins?; private prefetchPlugins?; constructor(deploymentService: IDeploymentService, walletService?: IWalletService, providerService?: ProviderService, vaultMetaService?: IVaultMetaService, priceService?: IPriceService, rewardsService?: IRewardsService, intrinsicApyService?: IIntrinsicApyService, eulerLabelsService?: IEulerLabelsService); setWalletService(walletService: IWalletService): void; setProviderService(providerService: ProviderService): void; setVaultMetaService(vaultMetaService: IVaultMetaService): void; setPriceService(priceService: IPriceService): void; setRewardsService(rewardsService: IRewardsService): void; setIntrinsicApyService(intrinsicApyService: IIntrinsicApyService): void; setEulerLabelsService(eulerLabelsService: IEulerLabelsService): void; setABIService(abiService: IABIService): void; setPlugins(plugins: EulerPlugin[]): void; setPluginProcessor(processPlugins: ProcessPlanPlugins): void; setPluginPrefetcher(prefetchPlugins: PrefetchPlanPlugins): void; /** Derive storage overrides needed to simulate the plan against the current account state. */ deriveStateOverrides(chainId: number, account: Address, transactionPlan: TransactionPlan, options?: SimulationStateOverrideOptions): Promise; /** * Simulate the full transaction plan, including approval resolution and * plugin-aware batch execution. * @see docs/simulations-and-state-overrides.md */ simulateTransactionPlan(chainId: number, account: AddressOrAccount, transactionPlan: TransactionPlan, options?: SimulateBatchOptions & { prefetch?: PluginPrefetchData; }): Promise>; /** * Simulate a {@link TransactionPlanPrepared} envelope. Plugins and approval * resolution have already run via {@link prepareTransactionPlan}, so this * skips the plugin pipeline and uses the envelope's chainId/account context * directly — no re-fetches of plugin-side data on each click. * @see docs/simulations-and-state-overrides.md */ simulatePreparedTransactionPlan(prepared: TransactionPlanPrepared, options?: SimulateBatchOptions): Promise>; /** * Run plugins and resolve required approvals up front, packaging the result * with its execution context. Simulate and execute can be called against the * returned envelope repeatedly without re-running plugins or refetching * wallet allowances. * @see docs/simulations-and-state-overrides.md */ prepareTransactionPlan(args: { plan: TransactionPlan; chainId: number; account: AddressOrAccount; usePermit2?: boolean; unlimitedApproval?: boolean; prefetch?: PluginPrefetchData; }): Promise; /** Estimate gas for the full transaction plan after applying the same simulation pipeline used for execution. */ estimateGasForTransactionPlan(chainId: number, account: AddressOrAccount, transactionPlan: TransactionPlan, options?: EstimateGasForTransactionPlanOptions & { prefetch?: PluginPrefetchData; }): Promise; /** * Estimate gas for a {@link TransactionPlanPrepared} envelope. Plugins and * approval resolution were already applied by {@link prepareTransactionPlan}, * so this skips the plugin pipeline (TOS / Keyring / Pyth) entirely — the * plan's batch items are used as-is. Net effect: per-call gas estimate * drops from "plugin pipeline + estimate" to just the estimate, mirroring * the simulatePreparedTransactionPlan / executePreparedTransactionPlan * pattern. */ estimateGasForPreparedTransactionPlan(prepared: TransactionPlanPrepared, options?: EstimateGasForTransactionPlanOptions): Promise; /** * Execute a transaction plan using caller-provided signing and send callbacks. * @see docs/execution-service.md */ executeTransactionPlan(args: ExecuteTransactionPlanArgs): Promise; /** * Execute a {@link TransactionPlanPrepared} envelope. Plugins and approval * resolution were already applied by {@link prepareTransactionPlan}, so * this skips both — no per-execute plugin re-runs or wallet re-fetch. * @see docs/execution-service.md */ executePreparedTransactionPlan(args: ExecutePreparedTransactionPlanArgs): Promise; /** * Compose a prepared plan without reads, clocks, or wallet prompts. Permit2 * nonces and deadlines and the reviewed EVC address are explicit inputs. */ materializeExecution(args: MaterializeExecutionArgs): MaterializedExecution; /** Insert signatures into declared slots without mutating the reviewed template. */ finalizeMaterializedExecution(materialized: MaterializedExecution, signatures: readonly MaterializedSignatureValue[]): FinalizedMaterializedExecution; /** * Collect declared signatures and dispatch the finalized bytes. Every hook is * awaited at its documented boundary; dispatch never re-encodes a request. A * supplied FinalizedMaterializedExecution is assumed to have been * authenticated by the application before this call. */ executeMaterialized(materialized: MaterializedExecution | FinalizedMaterializedExecution, options: ExecuteMaterializedOptions): Promise; executeCowSwapTransactionPlan(args: ExecuteCowSwapTransactionPlanArgs): Promise; private getSimulationContext; /** * Run each plugin's processPlan in registration order. Plugins receive the * plan as modified by previous plugins. Any plugin failure rejects the * pipeline so a required safety operation can never be silently omitted. * * `prefetch` carries form-level data each plugin pre-resolved via * {@link prefetchPluginDataForPlan} — passing it lets the plugin skip its * own network I/O (Hermes pulls, keyring hook reads, etc.). */ processPlanPlugins(plan: TransactionPlan, account: AddressOrAccount, chainId: number, prefetch?: PluginPrefetchData): Promise; /** * Resolve each plugin's prefetch payload for a given plan once, so per-quote * prepare/estimate/simulate calls can reuse the data instead of refetching. * Returns an open record keyed by plugin name — known SDK slots are typed * (`pyth`, `keyring`); external plugins populate their own keys. */ prefetchPluginDataForPlan(plan: TransactionPlan, account: AddressOrAccount, chainId: number): Promise; private getAccountOwner; private getCoreAddresses; /** * Encodes an array of EVC batch items into a single calldata hex for `EVC.batch()`. * * @param items - Array of batch items (targetContract, onBehalfOfAccount, value, data) to execute atomically * @returns Encoded calldata hex for the EVC batch call */ encodeBatch(items: EVCBatchItem[]): Hex; /** * Encodes EVC batch items for depositing underlying assets into a vault (mints shares to receiver). * * @param args - Deposit encoding arguments * @param args.chainId - Chain ID (used for EVC/permit2 addresses) * @param args.vault - Address of the vault to deposit into * @param args.amount - Amount of underlying assets to deposit * @param args.receiver - Sub-account address that receives the vault shares * @param args.owner - Address that owns the assets and authorizes the deposit (onBehalfOfAccount) * @param args.enableCollateral - If true, prepends enableCollateral( receiver, vault ) via EVC * @param args.permit2 - Optional Permit2 message + signature; if set, prepends a permit2 permit call so transferFrom can be used * @returns Array of EVC batch items (optional permit2, optional enableCollateral, deposit) */ encodeDeposit({ chainId, ...args }: EncodeDepositArgs): EVCBatchItem[]; /** * Encodes EVC batch items for minting vault shares by depositing underlying assets. * * @param args - Mint encoding arguments * @param args.chainId - Chain ID (used for EVC/permit2 addresses) * @param args.vault - Address of the vault to mint from * @param args.shares - Number of vault shares to mint * @param args.receiver - Sub-account address that receives the shares * @param args.owner - Address that owns the assets and authorizes the mint (onBehalfOfAccount) * @param args.enableCollateral - If true, prepends enableCollateral( receiver, vault ) via EVC * @param args.permit2 - Optional Permit2 message + signature for transferFrom * @returns Array of EVC batch items (optional permit2, optional enableCollateral, mint) */ encodeMint({ chainId, ...args }: EncodeMintArgs): EVCBatchItem[]; /** * Encodes EVC batch items for withdrawing underlying assets from a vault (burns shares). * * @param args - Withdraw encoding arguments * @param args.chainId - Chain ID (used for EVC when disabling collateral) * @param args.vault - Address of the vault to withdraw from * @param args.assets - Amount of underlying assets to withdraw * @param args.receiver - Address that receives the withdrawn underlying assets * @param args.owner - Sub-account address whose vault shares are withdrawn (onBehalfOfAccount) * @param args.disableCollateral - If true, appends disableCollateral( owner, vault ) via EVC before withdraw * @returns Array of EVC batch items (optional disableCollateral, withdraw) */ encodeWithdraw({ chainId, ...args }: EncodeWithdrawArgs): EVCBatchItem[]; /** * Encodes EVC batch items for redeeming vault shares for underlying assets. * * @param args - Redeem encoding arguments * @param args.chainId - Chain ID (used for EVC when disabling collateral) * @param args.vault - Address of the vault to redeem from * @param args.shares - Number of vault shares to redeem * @param args.receiver - Address that receives the underlying assets * @param args.owner - Sub-account address whose shares are redeemed (onBehalfOfAccount) * @param args.disableCollateral - If true, prepends disableCollateral( owner, vault ) via EVC * @returns Array of EVC batch items (optional disableCollateral, redeem) */ encodeRedeem({ chainId, ...args }: EncodeRedeemArgs): EVCBatchItem[]; /** * Encodes EVC batch items for borrowing from a liability vault, optionally depositing collateral in the same batch. * * @param args - Borrow encoding arguments * @param args.chainId - Chain ID (used for EVC and optional deposit) * @param args.vault - Address of the liability (borrow) vault to borrow from * @param args.amount - Amount of underlying assets to borrow * @param args.owner - Address that owns collateral assets when depositing (onBehalfOfAccount for deposit) * @param args.borrowAccount - Sub-account that takes the debt and receives collateral if any * @param args.receiver - Address that receives the borrowed assets * @param args.enableController - If true, enables this vault as controller for borrowAccount via EVC before borrow (default true) * @param args.currentController - If set and different from vault, disables it before enabling the new controller * @param args.collateralVault - Optional vault to deposit collateral into (same batch) * @param args.collateralAmount - Optional amount of collateral to deposit (requires collateralVault) * @param args.enableCollateral - When depositing collateral, whether to enable it for borrowAccount (default true) * @param args.collateralPermit2 - Optional Permit2 data for the collateral deposit * @returns Array of EVC batch items (optional deposit, optional disableController, optional enableController, borrow) */ encodeBorrow(args: EncodeBorrowArgs): EVCBatchItem[]; /** * Encodes EVC batch items for liquidating an undercollateralized account (repay debt, seize collateral). * * @param args - Liquidation encoding arguments * @param args.chainId - Chain ID (used for EVC enableController/enableCollateral) * @param args.vault - Address of the liability vault (debt is repaid to this vault) * @param args.violator - Sub-account address of the account being liquidated * @param args.collateral - Address of the collateral vault from which collateral is seized * @param args.repayAssets - Amount of liability asset the liquidator repays * @param args.minYieldBalance - Minimum yield balance the liquidator requires; liquidation can revert if not met * @param args.liquidatorSubAccountAddress - Sub-account that repays and receives seized collateral (onBehalfOfAccount) * @param args.enableController - If true, enables vault as controller for liquidator sub-account before liquidate (default true) * @param args.enableCollateral - If true, enables collateral vault for liquidator sub-account after liquidate (default true) * @returns Array of EVC batch items (optional enableController, liquidate, optional enableCollateral) */ encodeLiquidation({ chainId, ...args }: EncodeLiquidationArgs): EVCBatchItem[]; /** * Encodes EVC batch items for pulling debt from one sub-account to another on the same liability vault. * * @param args - Pull-debt encoding arguments * @param args.chainId - Chain ID (used for EVC when enabling controller) * @param args.vault - Address of the liability vault * @param args.amount - Amount of debt to pull * @param args.from - Sub-account address from which debt is pulled * @param args.to - Sub-account address that receives the debt (onBehalfOfAccount) * @param args.enableController - If true, enables vault as controller for `to` via EVC before pullDebt (default true) * @returns Array of EVC batch items (optional enableController, pullDebt) */ encodePullDebt({ chainId, ...args }: EncodePullDebtArgs): EVCBatchItem[]; /** * Encodes EVC batch items for a multiply/leverage operation when liability and long asset differ (swap required). * Order: optional permit2 → optional deposit + enable collateral → optional disableController → enableController → borrow → swap → verify/skim → optional enableCollateral on long vault. * * @param args - Multiply-with-swap encoding arguments * @param args.chainId - Chain ID (used for EVC and permit2) * @param args.collateralVault - Vault to deposit initial collateral into (can use 0n amount to skip) * @param args.collateralAmount - Amount of collateral to deposit (0n to skip) * @param args.liabilityVault - Vault to borrow from (liability) * @param args.liabilityAmount - Amount to borrow (sent to swapper) * @param args.longVault - Vault that receives the swapped assets (verify type must be skimMin) * @param args.owner - Address that owns collateral (onBehalfOfAccount for deposit) * @param args.receiver - Sub-account that holds the position (receives collateral, long and debt) * @param args.enableCollateral - When depositing collateral, whether to enable it for receiver (default true) * @param args.enableCollateralLong - Whether to enable long vault as collateral for receiver (default true) * @param args.currentController - If set and different from liabilityVault, disables it first * @param args.enableController - Whether to enable liability vault as controller for receiver (default true) * @param args.collateralPermit2 - Optional Permit2 data for collateral deposit * @param args.swapQuote - Quote with swap and verify (skimMin) steps; borrow is sent to swapQuote.swap.swapperAddress * @returns Array of EVC batch items */ encodeMultiplyWithSwap(args: EncodeMultiplyWithSwapArgs): EVCBatchItem[]; /** * Encodes EVC batch items for a multiply/leverage operation when liability and long asset are the same (no swap). * Order: optional permit2 → optional deposit + enable collateral → optional disableController → enableController → borrow to longVault → skim → enableCollateral on long vault. * * @param args - Multiply-same-asset encoding arguments * @param args.chainId - Chain ID (used for EVC and permit2) * @param args.collateralVault - Vault to deposit initial collateral into (can use 0n to skip) * @param args.collateralAmount - Amount of collateral to deposit (0n to skip) * @param args.liabilityVault - Vault to borrow from (same asset as longVault) * @param args.liabilityAmount - Amount to borrow (sent to longVault) * @param args.longVault - Vault that receives the borrowed assets (skim + enable collateral) * @param args.owner - Address that owns collateral (onBehalfOfAccount for deposit) * @param args.receiver - Sub-account that holds the position * @param args.enableCollateral - When depositing collateral, whether to enable it (default true) * @param args.enableCollateralLong - Whether to enable long vault as collateral (default true) * @param args.currentController - If set and different from liabilityVault, disables it first * @param args.enableController - Whether to enable liability vault as controller (default true) * @param args.collateralPermit2 - Optional Permit2 data for collateral deposit * @returns Array of EVC batch items */ encodeMultiplySameAsset(args: EncodeMultiplySameAssetArgs): EVCBatchItem[]; /** * Encodes EVC batch items for repaying debt using assets from the sender's wallet (transferFrom to vault then repay). * * @param args - Repay-from-wallet encoding arguments * @param args.chainId - Chain ID (used for permit2 when provided) * @param args.sender - Address that sends the liability asset and authorizes the repay (onBehalfOfAccount) * @param args.liabilityVault - Vault (liability) to repay debt to * @param args.liabilityAmount - Amount to repay (use maxUint256 with isMax for "repay all") * @param args.receiver - Sub-account whose debt is repaid * @param args.disableControllerOnMax - If true and isMax, appends disableController for receiver on liabilityVault (default true) * @param args.isMax - If true, repays max (amount is ignored and maxUint256 is passed to repay) * @param args.permit2 - Optional Permit2 message + signature so transferFrom can be used without prior approve * @returns Array of EVC batch items (optional permit2, repay, optional disableController) */ encodeRepayFromWallet(args: EncodeRepayFromWalletArgs): EVCBatchItem[]; /** * Encodes EVC batch items for repaying debt from a deposit (same-asset only). * Path 1: same asset and same vault → repayWithShares. * Path 2: same asset, different vault → withdraw to liability vault, skim, then repayWithShares. * * @param args - Repay-from-deposit encoding arguments * @param args.chainId - Chain ID used for EVC controller calls * @param args.liabilityVault - Vault (liability) to repay debt to * @param args.liabilityAsset - Underlying asset address of the liability vault * @param args.liabilityAmount - Amount of liability to repay (maxUint256 with isMax for full repay) * @param args.from - Sub-account address that holds the source deposit (withdraw/shares source) * @param args.receiver - Sub-account whose debt is repaid * @param args.fromVault - Vault to withdraw/source assets from (must be same asset as liability for this encoder) * @param args.fromAsset - Underlying asset of fromVault (must equal liabilityAsset) * @param args.disableControllerOnMax - When isMax, whether to disable controller for receiver (default true) * @param args.isMax - If true, repays full debt (amount used for withdraw sizing where applicable) * @returns Array of EVC batch items. Throws if fromAsset !== liabilityAsset. */ encodeRepayFromDeposit(args: EncodeRepayFromDepositArgs): EVCBatchItem[]; /** * Encodes EVC batch items for repaying debt by swapping collateral (withdraw from vaultIn → swap → verify/repay debtMax). * Swap quote must come from swapService.fetchRepayQuotes() or match the same structure (verify type debtMax). * * @param args - Repay-with-swap encoding arguments * @param args.chainId - Chain ID (used for EVC disableController when applicable) * @param args.swapQuote - Quote with vaultIn, accountIn, accountOut, receiver, swap and verify (debtMax) steps * @param args.maxWithdraw - Optional cap on withdraw amount (e.g. available collateral); if less than quote amountInMax, that value is used * @param args.isMax - If true, disables controller on max repay when disableControllerOnMax is true (default true) * @param args.disableControllerOnMax - When isMax, whether to append disableController for accountOut on receiver (default true) * @returns Array of EVC batch items (withdraw, swap, verify/repay, optional disableController) */ encodeRepayWithSwap(args: EncodeRepayWithSwapArgs): EVCBatchItem[]; /** * Encodes EVC batch items for depositing into a vault using tokens from the user's wallet, going through a swap. * The approval is given to SwapVerifier, then transferFromSender pulls tokens to Swapper, swap executes, and output is deposited. * * @param args - Deposit-with-swap-from-wallet encoding arguments * @param args.chainId - Chain ID (used for EVC and deployment addresses) * @param args.swapQuote - Quote with swap and verify steps (verify type skimMin or transferMin) * @param args.amount - Amount of input token to transfer from wallet to swapper * @param args.sender - Wallet address providing the tokens (onBehalfOfAccount for transferFromSender) * @param args.enableCollateral - If true, enables receiver vault as collateral for accountOut (default true) * @returns Array of EVC batch items (transferFromSender, swap, verify, optional enableCollateral) */ encodeDepositWithSwapFromWallet(args: EncodeDepositWithSwapFromWalletArgs): EVCBatchItem[]; /** * Encodes EVC batch items for swapping a token from the sender's wallet into another token * and transferring the output to `swapQuote.receiver`. * The approval is given to SwapVerifier, then transferFromSender pulls tokens to Swapper, * swap executes, and verifyAmountMinAndTransfer sends the output to the receiver wallet. * * @param args - Wallet-swap encoding arguments * @param args.chainId - Chain ID (unused, kept for encode API symmetry) * @param args.swapQuote - Quote with swap and verify steps (verify type transferMin) * @param args.amount - Amount of input token to transfer from wallet to swapper * @param args.sender - Wallet address providing the tokens (onBehalfOfAccount for transferFromSender) * @returns Array of EVC batch items (transferFromSender, swap, verify) */ encodeSwapFromWallet(args: EncodeSwapFromWalletArgs): EVCBatchItem[]; encodeSwapAndBorrowFromWallet(args: EncodeSwapAndBorrowFromWalletArgs): EVCBatchItem[]; encodeSwapAndRepayFromWallet(args: EncodeSwapAndRepayFromWalletArgs): EVCBatchItem[]; encodeWithdrawAndSwap(args: EncodeWithdrawAndSwapArgs): EVCBatchItem[]; encodeRedeemAndSwap(args: EncodeRedeemAndSwapArgs): EVCBatchItem[]; /** * Encodes EVC batch items for swapping collateral: withdraw from vaultIn → swap → verify/skim to receiver; optional enable/disable collateral. * Swap quote should come from swapService.fetchDepositQuote() or match the same structure (verify type skimMin). * * @param args - Swap-collateral encoding arguments * @param args.chainId - Chain ID (used for EVC enableCollateral/disableCollateral) * @param args.swapQuote - Quote with vaultIn, accountIn, accountOut, receiver, swap and verify (skimMin) steps * @param args.enableCollateral - If true, enables receiver vault as collateral for accountOut (default true) * @param args.disableCollateralOnMax - When isMax, whether to disable collateral for accountIn on vaultIn (default true) * @param args.isMax - If true, treats as full swap (can trigger disableCollateralOnMax) * @returns Array of EVC batch items (withdraw, swap, verify/skim, optional disableCollateral, optional enableCollateral) */ encodeSwapCollateral(args: EncodeSwapCollateralArgs): EVCBatchItem[]; /** * Encodes EVC batch items for swapping debt: enableController → borrow from vaultIn → swap → verify/repay (debtMax). * Swap quote should come from swapService.fetchRepayQuotes() or match the same structure (verify type debtMax). * * @param args - Swap-debt encoding arguments * @param args.chainId - Chain ID (used for EVC enableController/disableController) * @param args.swapQuote - Quote with vaultIn, accountIn, accountOut, receiver, swap and verify (debtMax) steps * @param args.enableController - If true, enables vaultIn as controller for accountOut before borrow (default true) * @param args.disableControllerOnMax - When isMax, whether to disable controller for accountIn on receiver (default true) * @param args.isMax - If true, treats as full debt swap (can trigger disableControllerOnMax) * @returns Array of EVC batch items (optional enableController, borrow, swap, verify/repay, optional disableController) */ encodeSwapDebt(args: EncodeSwapDebtArgs): EVCBatchItem[]; /** * Encodes EVC batch items for migrating a supplied/collateral position between two same-asset vaults. * Partial migration uses withdraw(amount, toVault, account) then skim(amount, account). * Max migration uses redeem(maxShares || maxUint256, toVault, account) then skim(maxUint256, account) * so the destination credits the full unaccounted asset balance returned by redeem. * * @param args - Same-asset collateral migration encoding arguments * @param args.chainId - Chain ID (used for EVC enable/disable collateral) * @param args.fromVault - Source vault holding the supplied shares * @param args.toVault - Destination vault with the same underlying asset * @param args.amount - Asset amount withdrawn and skimmed for a partial migration * @param args.account - Sub-account that owns the source shares and receives destination shares * @param args.isMax - If true, redeems shares and skims the full unaccounted destination balance * @param args.maxShares - Optional exact share amount for max migration; defaults to maxUint256 * @param args.enableCollateralTo - If true, enables the destination vault as collateral after skim * @param args.disableCollateralFrom - If true, disables the source vault as collateral after enabling the destination * @returns Array of EVC batch items */ encodeMigrateSameAssetCollateral(args: EncodeMigrateSameAssetCollateralArgs): EVCBatchItem[]; /** * Encodes EVC batch items for migrating a full debt position between two same-asset liability vaults. * Flow: enable new controller → borrow with interest cushion to old vault → skim → repay old debt with shares * → disable old controller → optionally sweep cushion to the new vault → optionally transfer remaining new-vault shares. * * @param args - Same-asset debt migration encoding arguments * @param args.chainId - Chain ID (used for EVC enable controller) * @param args.oldLiabilityVault - Existing debt vault to fully repay and disable * @param args.newLiabilityVault - New same-asset debt vault to borrow from * @param args.amount - Current debt amount before applying the 0.01% interest cushion * @param args.account - Sub-account that owns the debt position * @param args.enableController - If true, enables the new liability vault as controller first * @param args.disableController - If true, disables the old liability vault after repayment * @param args.sweepExcess - If true, redeems any old-vault cushion shares back to the new vault and skims them * @param args.transferRemainingSharesTo - If set, transfers all new-vault shares from the sub-account to this address * @returns Array of EVC batch items */ encodeMigrateSameAssetDebt(args: EncodeMigrateSameAssetDebtArgs): EVCBatchItem[]; /** * Encodes EVC batch items for transferring vault shares between sub-accounts. * * @param args - Transfer encoding arguments * @param args.chainId - Chain ID (used for EVC when enabling/disabling collateral) * @param args.vault - Address of the vault * @param args.from - Sub-account address sending the shares (onBehalfOfAccount) * @param args.to - Sub-account address receiving the shares * @param args.amount - Amount of vault shares to transfer * @param args.enableCollateralTo - If true, appends enableCollateral( to, vault ) via EVC after transfer * @param args.disableCollateralFrom - If true, prepends disableCollateral( from, vault ) via EVC before transfer * @returns Array of EVC batch items (optional disableCollateralFrom, transfer, optional enableCollateralTo) */ encodeTransfer({ chainId, ...args }: EncodeTransferArgs): EVCBatchItem[]; /** * Encodes a single EVC batch item that calls Permit2's `permit` with the given message and signature. * Used to authorize a token transfer for a subsequent contract call in the same batch. * * @param args - Permit2 call encoding arguments * @param args.chainId - Chain ID (used to resolve Permit2 contract address) * @param args.owner - Token owner that signed the permit (onBehalfOfAccount) * @param args.message - Permit2 PermitSingle message (details + spender + sigDeadline) * @param args.signature - Signature over the permit message * @returns Single EVC batch item (targetContract = Permit2, permit call) */ encodePermit2Call(args: EncodePermit2CallArgs): EVCBatchItem; /** * Insert an EIP-712 signature only at the versioned ABI path returned by * PositionMigrationService.prepareMigrationAuthorizationSlots. The path is * opaque application-authenticated metadata, not an independently trusted * SDK capability. */ encodeMigrationAuthorizationCall(args: EncodeMigrationAuthorizationCallArgs): EVCBatchItem; encodeEnableCollateral(chainId: number, account: Address, vault: Address): EVCBatchItem; encodeDisableCollateral(chainId: number, account: Address, vault: Address): EVCBatchItem; encodeEnableController(chainId: number, account: Address, vault: Address): EVCBatchItem; encodeDisableController(vault: Address, account: Address): EVCBatchItem; /** * Builds EIP-712 typed data for a Permit2 PermitSingle signature (token approval for a spender). * Use with signTypedData (e.g. wagmi) then pass the signed message to encodePermit2Call or plan flows. * * @param args - Permit2 typed data arguments * @param args.chainId - Chain ID (used to resolve Permit2 contract for domain) * @param args.token - Token address to approve * @param args.amount - Amount to approve (capped to maxUint160 in the message if larger) * @param args.spender - Address that will be allowed to transfer the token (e.g. vault or Permit2) * @param args.nonce - Unique nonce for this permit (e.g. from Permit2 nonce(owner, token, spender)) * @param args.sigDeadline - Signature deadline (defaults to now + 1 hour if omitted) * @param args.expiration - Permit expiration (defaults to now + 1 hour if omitted) * @returns EIP-712 typed data (domain, types, primaryType, message) for signing */ getPermit2TypedData(args: GetPermit2TypedDataArgs): PermitSingleTypedData; /** * Decodes EVC batch entries into human-readable function names and named arguments. * Tries known ABIs (EVC, eVault, Permit2, swapper, swapVerifier) to decode each item's data. * * @param batch - Array of EVC batch entries to decode. Operation entries are preserved with decoded child items. * @param extraAbis - Optional extra ABIs to try first when decoding unknown batch items. * @returns Array matching the input batch-entry shape, with raw items decoded. * @example * const batchItems = executionService.encodeDeposit({ ... }); * const described = executionService.describeBatch(batchItems); * console.log(described[0].functionName); // "deposit" * console.log(described[0].args); // { amount: 1000n, receiver: "0x..." } */ describeBatch(batch: readonly EVCBatchItem[], extraAbis?: Abi[]): BatchItemDescription[]; describeBatch(batch: readonly EVCBatchEntry[], extraAbis?: Abi[]): BatchEntryDescription[]; /** * Merges multiple transaction plans into a single plan. * Required approvals for the same (token, owner, spender) are summed. * Executable items are preserved in order; adjacent EVC batches are concatenated without flattening operation groupings. * Can be used to construct a transaction queue. * * @param plans - Array of transaction plans to merge * @returns Single plan: summed required approvals first, followed by executable items in order */ mergePlans(plans: TransactionPlan[]): TransactionPlan; /** * Appends a raw batch item to the last EVC batch in the plan, or creates one. * Mutates and returns the provided plan. */ addBatchItemToPlan(plan: TransactionPlan, item: EVCBatchItem): TransactionPlan; /** * Converts EVC batch items into a transaction plan. * Returns a plan with a single evcBatch containing the given items (no required approvals). * Returns an empty plan if items is empty. * * @param items - EVC batch items to wrap in a plan * @returns Transaction plan containing one evcBatch with the items */ convertBatchItemsToPlan(items: EVCBatchItem[], operationName?: string): TransactionPlan; encodeTransferFromMax(vault: Address, from: Address, to: Address): EVCBatchItem; /** * Appends post-full-repay cleanup calls owned by plan builders: * disable each active collateral used by the repaid borrow, transfer those collateral shares to the owner, * and, when a source deposit funded the repay, transfer any remaining source-vault shares to the owner. */ private appendMaxRepayCleanup; /** * Resolves RequiredApproval items in a transaction plan by filling in each item's `resolved` field. * Uses wallet allowances (and optional Permit2 state) to decide whether to add approve/permit2 steps. * Mutates the plan in place and returns it. * * @param args - Resolve-with-wallet arguments * @param args.plan - Transaction plan containing requiredApproval items (e.g. from planDeposit, planBorrow) * @param args.chainId - Chain ID (used to resolve Permit2 address when usePermit2 is true) * @param args.wallet - Wallet entity with token balances and allowances (assetForVault, assetForPermit2, etc.) * @param args.usePermit2 - If true, prefer Permit2 path (approve Permit2 + sign PermitSingle) when allowance is insufficient (default true) * @param args.unlimitedApproval - If true, direct approvals and Permit2 signed amounts use maxUint256/maxUint160 (default false). Token approvals to Permit2 use maxUint256. * @returns The same plan array with requiredApproval[].resolved populated (approve and/or permit2 data to sign) */ resolveRequiredApprovalsWithWallet(args: ResolveRequiredApprovalsWithWalletArgs): TransactionPlanItem[]; /** * Resolves RequiredApproval items in a transaction plan by fetching wallet data then filling in approvals. * Collects (token, spender) from plan's requiredApproval items, fetches wallet via WalletService, then calls resolveRequiredApprovalsWithWallet. * * @param args - Resolve arguments * @param args.plan - Transaction plan containing requiredApproval items * @param args.chainId - Chain ID (used for deployment and wallet fetch) * @param args.account - Account address (owner) used to fetch wallet and allowances * @param args.usePermit2 - If true, use Permit2 path when needed (default true) * @param args.unlimitedApproval - If true, use max amounts for approvals (default false) * @returns Promise of the plan with requiredApproval[].resolved populated */ resolveRequiredApprovals(args: ResolveRequiredApprovalsArgs): Promise; private buildCleanupBatchItems; /** * Builds a cleanup plan matching Lite's stale collateral/controller policy. * * Cleanup is derived from the provided account snapshot: * - no enabled controllers: disable all enabled collaterals * - enabled controllers but no active borrows: disable all collaterals, then controllers * - active borrows: disable only enabled collaterals with no supplied position * * If the sub-account snapshot is unavailable, no cleanup is planned. */ planCleanup(args: PlanCleanupArgs): TransactionPlan; /** * Builds a transaction plan for depositing assets into a vault. * Use `maxUint256` for `amount` to deposit all available assets from the wallet. * * @param args - Deposit plan arguments * @param args.vault - Address of the vault to deposit into * @param args.amount - Amount of underlying assets to deposit (use maxUint256 for "deposit all") * @param args.receiver - Sub-account address that will receive the vault shares (and count as collateral if enabled) * @param args.account - Account entity (owner + positions); used for chainId, owner, and collateral state * @param args.asset - Address of the underlying ERC20 asset being deposited (used for approval requirement) * @param args.enableCollateral - If true, enables this vault as collateral for `receiver` when not already enabled * @returns Array of transaction plan items (required approvals + EVC batch) */ planDeposit(args: PlanDepositArgs): TransactionPlanItem[]; /** * Builds a transaction plan for minting vault shares by depositing assets. * * @param args - Mint plan arguments * @param args.vault - Address of the vault to mint shares from * @param args.shares - Number of vault shares to mint * @param args.receiver - Sub-account address that will receive the shares (and count as collateral if enabled) * @param args.account - Account entity (owner + positions); used for chainId, owner, and collateral state * @param args.asset - Address of the underlying ERC20 asset (used for approval requirement) * @param args.enableCollateral - If true, enables this vault as collateral for `receiver` when not already enabled * @param args.sharesToAssetsExchangeRateWad - Optional exchange rate (WAD) to estimate asset amount for approval when minting by shares. Default 1. * @returns Array of transaction plan items (required approvals + EVC batch) */ planMint(args: PlanMintArgs): TransactionPlan; /** * Builds a transaction plan for withdrawing assets from a vault. * * @param args - Withdraw plan arguments * @param args.vault - Address of the vault to withdraw from * @param args.assets - Amount of underlying assets to withdraw * @param args.owner - Sub-account address whose vault shares are being withdrawn * @param args.receiver - Address that will receive the withdrawn underlying assets * @param args.account - Account entity; used for chainId and position/collateral state * @param args.disableCollateral - If true, disables this vault as collateral for `owner` when the position is fully withdrawn and was collateral * @returns Array of transaction plan items (EVC batch; no approvals needed for withdraw) */ planWithdraw(args: PlanWithdrawArgs): TransactionPlan; /** * Builds a transaction plan for redeeming vault shares for underlying assets. * Pass `shares` directly, or pass `assets` to derive shares from the account's populated vault state. * Use `maxUint256` for `shares` to redeem all available shares. * * @param args - Redeem plan arguments * @param args.vault - Address of the vault to redeem shares from * @param args.shares - Number of vault shares to redeem (use maxUint256 for "redeem all") * @param args.assets - Underlying asset amount used to calculate shares from the account vault snapshot * @param args.owner - Sub-account address whose shares are being redeemed * @param args.receiver - Address that will receive the underlying assets * @param args.account - Account entity; used for chainId and position/collateral state * @param args.disableCollateral - If true, disables this vault as collateral for `owner` when the position is fully redeemed and was collateral * @returns Array of transaction plan items (EVC batch; no approvals needed for redeem) */ planRedeem(args: PlanRedeemArgs): TransactionPlan; private resolveRedeemShares; /** * Builds a transaction plan for borrowing from a liability vault. * Use `maxUint256` for `collateral.amount` to deposit all available collateral asset from the wallet. * * @param args - Borrow plan arguments * @param args.vault - Address of the liability (borrow) vault to borrow from * @param args.amount - Amount of underlying assets to borrow * @param args.borrowAccount - Sub-account address that will take the debt (and hold collateral if any) * @param args.receiver - Address that will receive the borrowed assets * @param args.account - Account entity; used for chainId, owner, controller/collateral state * @param args.collateral - Optional: deposit collateral in the same batch; use maxUint256 for amount to deposit all available * @param args.collateral.vault - Collateral vault to deposit into * @param args.collateral.amount - Amount of collateral asset to deposit * @param args.collateral.asset - Underlying asset address of the collateral (for approval) * @returns Array of transaction plan items (optional approval + EVC batch) */ planBorrow(args: PlanBorrowArgs): TransactionPlan; /** * Builds a transaction plan for liquidating an undercollateralized account. * * @param args - Liquidation plan arguments * @param args.account - Liquidator's account entity; used for chainId, owner, and controller/collateral state on liquidator sub-account * @param args.liquidatorSubAccountAddress - Sub-account address that will repay debt and receive seized collateral * @param args.vault - Address of the liability vault (debt is repaid to this vault) * @param args.asset - Deprecated compatibility field; liquidation does not pull the liability asset from the wallet * @param args.violator - Sub-account address of the undercollateralized account being liquidated * @param args.collateral - Address of the collateral vault from which collateral is seized * @param args.repayAssets - Amount of liability asset the liquidator will repay (and receive collateral up to the liquidation incentive) * @param args.minYieldBalance - Minimum yield balance the liquidator requires; liquidation may revert if not met * @returns Array of transaction plan items (EVC batch only; liquidation does not require a wallet-token approval) */ planLiquidation(args: PlanLiquidationArgs): TransactionPlan; /** * Builds a transaction plan for repaying debt using assets from the wallet. * Use `maxUint256` for `liabilityAmount` to repay all available debt. * * @param args - Repay-from-wallet plan arguments * @param args.liabilityVault - Address of the liability vault (debt is repaid to this vault) * @param args.liabilityAmount - Amount of liability asset to repay (use maxUint256 for "repay all") * @param args.receiver - Sub-account address whose debt is being repaid * @param args.account - Account entity; used for chainId, owner, and position (to resolve liability asset) * @param args.cleanupOnMax - When true and liabilityAmount is maxUint256, the batch disables active collaterals on the repaid sub-account and transfers their shares to the owner account (default false) * @returns Array of transaction plan items (approval + EVC batch) */ planRepayFromWallet(args: PlanRepayFromWalletArgs): TransactionPlan; /** * Builds a transaction plan for repaying debt using assets from another vault deposit (same asset only). * Use `maxUint256` for `liabilityAmount` to perform a full repay. * Full repay can opt into cleanup. For different-vault full repays, cleanup only redeems * liability-vault shares left from the repay cushion when the account snapshot shows no pre-existing liability-vault deposit; * otherwise those shares are preserved in the liability vault instead of being migrated to the source vault. * Cleanup also disables active collaterals on the repaid sub-account, transfers those collateral shares to the owner * account, and transfers any remaining source-vault shares from the source sub-account to the owner account. * * @param args - Repay-from-deposit plan arguments * @param args.liabilityVault - Address of the liability vault (debt is repaid to this vault) * @param args.liabilityAmount - Amount of liability to repay (use maxUint256 for max repay) * @param args.receiver - Sub-account address whose debt is being repaid (and from whose deposit we may withdraw when fromAccount === receiver) * @param args.fromVault - Vault to withdraw assets from (must be same underlying asset as liability for this plan) * @param args.fromAccount - Sub-account that holds the deposit in `fromVault` * @param args.account - Account entity; used for chainId, owner, and positions (to resolve assets and eligibility) * @param args.cleanupOnMax - Whether max repay should append repay-cushion, collateral, and source-share cleanup (default false) * @returns Array of transaction plan items (EVC batch only). Throws if asset differs between fromVault and liabilityVault; use planRepayWithSwap for cross-asset. */ planRepayFromDeposit(args: PlanRepayFromDepositArgs): TransactionPlan; /** * Builds a transaction plan for repaying debt by swapping collateral (e.g. withdraw collateral → swap → repay). * Use when the repayment asset differs from the collateral asset. * * @param args - Repay-with-swap plan arguments * @param args.swapQuote - Quote from swap service (e.g. fetchRepayQuotes); defines vaultIn, accountIn, accountOut, receiver, swap and verify steps * @param args.account - Account entity; used for chainId and positions (to compute isMax and maxWithdraw) * @param args.cleanupOnMax - When true and the quote repays the full debt, the batch disables active collaterals on the repaid sub-account, transfers their shares to the owner account, and transfers remaining source-vault shares to the owner account (default false) * @returns Array of transaction plan items (EVC batch: withdraw, swap, verify/repay). Throws if positions not found or liability is zero. */ planRepayWithSwap(args: PlanRepayWithSwapArgs): TransactionPlan; planClosePositionWithCow(args: PlanClosePositionWithCowArgs): TransactionPlan; planCancelClosePositionWithCow(args: PlanCancelClosePositionWithCowArgs): TransactionPlan; /** * Builds a transaction plan for depositing into a vault using tokens from the user's wallet, going through a swap. * The approval is given to SwapVerifier (not the vault), then transferFromSender is used in the batch * to provide the tokens to the Swapper from the user's wallet. * * @param args - Deposit-with-swap-from-wallet plan arguments * @param args.swapQuote - Quote from swap service; defines swap and verify steps * @param args.amount - Amount of input token to transfer from wallet * @param args.tokenIn - Input token address (for approval to SwapVerifier) * @param args.account - Account entity; used for chainId, owner, and collateral state * @param args.enableCollateral - If true, enables receiver vault as collateral for accountOut * @returns Array of transaction plan items (approval to SwapVerifier + EVC batch) */ planDepositWithSwapFromWallet(args: PlanDepositWithSwapFromWalletArgs): TransactionPlan; /** * Builds a transaction plan for swapping a token from the sender's wallet into another * token and transferring the output to the quote receiver. * * @param args - Wallet-swap plan arguments * @param args.swapQuote - Quote from swap service; must use transferOutputToReceiver / transferMin verification * @param args.amount - Amount of input token to transfer from wallet * @param args.tokenIn - Input token address (for approval to SwapVerifier) * @param args.account - Account entity; used for chainId and owner * @returns Array of transaction plan items (approval to SwapVerifier + EVC batch) */ planSwapFromWallet(args: PlanSwapFromWalletArgs): TransactionPlan; planSwapAndBorrowFromWallet(args: PlanSwapAndBorrowFromWalletArgs): TransactionPlan; planSwapAndRepayFromWallet(args: PlanSwapAndRepayFromWalletArgs): TransactionPlan; planWithdrawAndSwap(args: PlanWithdrawAndSwapArgs): TransactionPlan; planRedeemAndSwap(args: PlanRedeemAndSwapArgs): TransactionPlan; /** * Builds a transaction plan for swapping collateral from one vault to another (withdraw → swap → deposit/skim). * * @param args - Swap-collateral plan arguments * @param args.swapQuote - Quote from swap service (e.g. fetchDepositQuote); defines vaultIn, accountIn, accountOut, receiver, swap and verify (skimMin) steps * @param args.account - Account entity; used for chainId and positions (to determine isMax and whether to enable collateral on destination) * @returns Array of transaction plan items (EVC batch: withdraw, swap, verify/skim, optional enable/disable collateral) */ planSwapCollateral(args: PlanSwapCollateralArgs): TransactionPlan; planSwapCollateralWithCoW(args: PlanSwapCollateralWithCoWArgs): TransactionPlan; /** * Builds a transaction plan for swapping debt from one liability vault to another (borrow from source → swap → repay to destination). * * @param args - Swap-debt plan arguments * @param args.swapQuote - Quote from swap service (e.g. fetchRepayQuotes for the new debt); defines vaultIn, accountIn, accountOut, swap and verify (debtMax) steps * @param args.account - Account entity; used for chainId and controller state (enableController, isMax, disableControllerOnMax) * @returns Array of transaction plan items (EVC batch: enableController, borrow, swap, verify/repay, optional disableController) */ planSwapDebt(args: PlanSwapDebtArgs): TransactionPlan; /** * Builds a transaction plan for migrating a supplied/collateral position between two same-asset vaults. * This is the no-swap path for moving shares from one vault to another vault with the same underlying asset. * * @param args - Same-asset collateral migration plan arguments * @param args.fromVault - Source vault holding the supplied shares * @param args.toVault - Destination vault with the same underlying asset * @param args.amount - Asset amount to withdraw and skim for a partial migration * @param args.positionAccount - Sub-account that owns the source shares and receives destination shares * @param args.fromAsset - Optional source underlying asset; defaults to the account position asset * @param args.toAsset - Destination underlying asset, used to verify this is a same-asset migration * @param args.isMax - If true, redeems shares and skims the full unaccounted destination balance * @param args.maxShares - Optional exact share amount for max migration * @param args.enableCollateralTo - Optional override for enabling destination collateral * @param args.disableCollateralFrom - Optional override for disabling source collateral * @returns Array of transaction plan items (EVC batch; no token approvals) */ planMigrateSameAssetCollateral(args: PlanMigrateSameAssetCollateralArgs): TransactionPlan; /** * Builds a transaction plan for migrating a full same-asset debt position from one liability vault to another. * This is the no-swap path for debt vault migration and repays the old vault with shares after borrowing * slightly more from the new vault to cover interest accrual. * * @param args - Same-asset debt migration plan arguments * @param args.oldLiabilityVault - Existing debt vault to fully repay and disable * @param args.newLiabilityVault - New same-asset debt vault to borrow from * @param args.liabilityAccount - Sub-account that owns the debt position * @param args.liabilityAmount - Current debt amount; defaults to the old-vault borrowed amount in account data * @param args.oldLiabilityAsset - Optional old liability asset; defaults to the old-vault account position asset * @param args.newLiabilityAsset - New liability underlying asset, used to verify this is a same-asset migration * @param args.sweepExcess - Whether to redeem and skim the migration cushion back into the new vault when the old vault has no pre-existing supplied shares; defaults to true only when the loaded old position exists and has no supplied shares * @param args.transferRemainingSharesToOwner - Whether to transfer all new-vault shares to the owner when liabilityAccount differs from owner; defaults to true only when the loaded target position exists and has no supplied shares * @returns Array of transaction plan items (EVC batch; no token approvals) */ planMigrateSameAssetDebt(args: PlanMigrateSameAssetDebtArgs): TransactionPlan; /** * Builds a transaction plan for transferring vault shares between sub-accounts. * * @param args - Transfer plan arguments * @param args.vault - Address of the vault * @param args.from - Sub-account address sending the shares * @param args.to - Sub-account address receiving the shares * @param args.amount - Amount of vault shares to transfer * @param args.account - Account entity; used for chainId and collateral state for from/to * @param args.enableCollateralTo - If true, enables the vault as collateral for `to` when not already enabled * @param args.disableCollateralFrom - If true, disables the vault as collateral for `from` when it was enabled * @returns Array of transaction plan items (EVC batch; no approvals needed) */ planTransfer(args: PlanTransferArgs): TransactionPlan; /** * Builds a transaction plan for pulling debt from one sub-account to another (same liability vault). * * @param args - Pull-debt plan arguments * @param args.vault - Address of the liability vault * @param args.amount - Amount of debt to pull * @param args.from - Sub-account address from which debt is pulled * @param args.to - Sub-account address that will receive the debt (and receive the borrowed assets if any) * @param args.account - Account entity; used for chainId and controller state (enableController for `to` if needed) * @returns Array of transaction plan items (EVC batch: optional enableController + pullDebt) */ planPullDebt(args: PlanPullDebtArgs): TransactionPlan; /** * Builds a transaction plan for a multiply/leverage position when liability and long asset differ (requires a swap). * Flow: optional collateral deposit → enable controller → borrow → swap → enable collateral on long vault. * * @param args - Multiply-with-swap plan arguments * @param args.collateralVault - Vault to deposit initial collateral into (optional; omit amount or use 0 to skip) * @param args.collateralAmount - Amount of collateral asset to deposit (0n to skip deposit) * @param args.collateralAsset - Underlying asset address of collateral (for approval when collateralAmount > 0) * @param args.swapQuote - Quote describing borrow vault (vaultIn), long vault (receiver), amounts, swap and verify (skimMin) steps; accountIn must equal accountOut * @param args.account - Account entity; used for chainId, owner, and collateral/controller state * @returns Array of transaction plan items (optional approval + EVC batch). Throws if swapQuote.accountIn !== swapQuote.accountOut. */ planMultiplyWithSwap(args: PlanMultiplyWithSwapArgs): TransactionPlan; planOpenPositionWithCoW(args: PlanOpenPositionWithCoWArgs): TransactionPlan; /** * Builds a transaction plan for a multiply/leverage position when liability and long asset are the same (no swap). * Flow: optional collateral deposit → enable controller → borrow to long vault → skim → enable collateral on long vault. * * @param args - Multiply-same-asset plan arguments * @param args.collateralVault - Vault to deposit initial collateral into (optional; use 0n for collateralAmount to skip) * @param args.collateralAmount - Amount of collateral asset to deposit (0n to skip) * @param args.collateralAsset - Underlying asset address of collateral (for approval when collateralAmount > 0) * @param args.liabilityVault - Liability vault to borrow from * @param args.liabilityAmount - Amount to borrow (same asset as long vault) * @param args.longVault - Vault to deposit borrowed assets into (same asset as liability) * @param args.receiver - Sub-account address that holds the position (collateral + debt) * @param args.account - Account entity; used for chainId, owner, and collateral/controller state * @returns Array of transaction plan items (optional approval + EVC batch) */ planMultiplySameAsset(args: PlanMultiplySameAssetArgs): TransactionPlan; } //# sourceMappingURL=executionService.d.ts.map