import { type MarketParams } from "@morpho-org/blue-sdk"; import { type Address } from "viem"; import { type MarketV1RepayWithdrawCollateralAction, type Metadata, type RequirementSignature, type Transaction } from "../../types"; /** Parameters for {@link marketV1RepayWithdrawCollateral}. */ export interface MarketV1RepayWithdrawCollateralParams { market: { readonly chainId: number; readonly marketParams: MarketParams; }; args: { /** Repay assets amount (0n when repaying by shares). */ assets: bigint; /** Repay shares amount (0n when repaying by assets). */ shares: bigint; /** ERC20 amount to transfer to GeneralAdapter1 (computed by entity). */ transferAmount: bigint; /** Amount of collateral to withdraw. */ withdrawAmount: bigint; /** Address whose debt is being repaid. */ onBehalf: Address; /** Receives withdrawn collateral and residual loan tokens in shares mode. */ receiver: Address; /** Maximum repay share price (in ray). Protects against share price manipulation. */ maxSharePrice: bigint; requirementSignature?: RequirementSignature; }; metadata?: Metadata; } /** * Prepares an atomic repay-and-withdraw-collateral transaction for a Morpho Blue market. * * Routed through bundler3. The bundle order is critical: * 1. ERC20 transfer (loan token to GeneralAdapter1) * 2. `morphoRepay` — reduces debt FIRST * 3. `morphoWithdrawCollateral` — then withdraws collateral * * If the order were reversed, Morpho would revert because the position would be * insolvent at the time of the withdraw. * * Supports two repay modes: * - **By assets** (`assets > 0, shares = 0`): repays an exact asset amount. * - **By shares** (`assets = 0, shares > 0`): repays exact shares (full repay). * * **Prerequisites:** * - ERC20 approval for loan token to GeneralAdapter1 (for the repay). * - GeneralAdapter1 must be authorized on Morpho (for the withdraw). * * @param params - Combined repay and withdraw collateral parameters. * @returns Deep-frozen transaction. */ export declare const marketV1RepayWithdrawCollateral: ({ market: { chainId, marketParams }, args: { assets, shares, transferAmount, withdrawAmount, onBehalf, receiver, maxSharePrice, requirementSignature, }, metadata, }: MarketV1RepayWithdrawCollateralParams) => Readonly>;