import type { Address } from "@morpho-org/blue-sdk"; import { type ERC20ApprovalAction, type Transaction } from "../../types/index.js"; /** * Computes classic ERC-20 approval transactions for a supported SDK spender, given the existing * allowance. * * The spender is validated by {@link encodeErc20Approval}. Supported spenders are the chain's * GeneralAdapter1, Permit2, Midnight, MidnightBundles, and VaultExitBundlesV1 addresses when * configured. * * Returns an empty array when the allowance already covers `spendAmount`. When the token is in * `APPROVE_ONLY_ONCE_TOKENS` (e.g. USDT) and the existing allowance is non-zero, prepends a * `approve(spender, 0)` reset transaction to satisfy those tokens' allowance-must-be-zero rule * before re-approving. * * @param params.address - ERC-20 token address. * @param params.chainId - The chain the transaction targets, used to resolve supported spenders * and token approval caps. * @param params.args.spendAmount - The amount the bundle will actually pull. * @param params.args.approvalAmount - The amount to approve (often equal to `spendAmount`, but * may be `MAX_UINT_160` for Permit2 prerequisites). * @param params.args.spender - Address that will be granted the approval. Must be GeneralAdapter1, * Permit2, Midnight, MidnightBundles, or VaultExitBundlesV1 for `chainId`. * @param params.allowances - The user's current allowance of `address` for `spender`. * @returns Up to two deep-frozen `Transaction` entries: an optional reset * followed by the new approval. Empty when no approval is needed. * @throws {ApprovalAmountLessThanSpendAmountError} when `approvalAmount < spendAmount`. * @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not a supported SDK spender for `chainId`. * @example * ```ts * import { getRequirementsApproval } from "@morpho-org/morpho-sdk"; * * const txs = getRequirementsApproval({ * address: USDC, * chainId: 1, * args: { approvalAmount: 1_000_000n, spendAmount: 1_000_000n, spender: generalAdapter1 }, * allowances: 0n, * }); * // txs satisfies Readonly>[] * ``` */ export declare const getRequirementsApproval: (params: { address: Address; chainId: number; args: { approvalAmount: bigint; spendAmount: bigint; spender: Address; }; allowances: bigint; }) => Readonly>[];