import type { Address } from "@morpho-org/blue-sdk"; import type { Client } from "viem"; import { type PermitRequirementSignature, type Requirement } from "../../../types/index.js"; /** Parameters for {@link encodeErc20Permit}. */ interface EncodeErc20PermitParams { token: Address; spender: Address; amount: bigint; chainId: number; nonce: bigint; supportDeployless?: boolean; } /** * Builds an EIP-2612 permit `Requirement` that, once signed, lets a supported SDK spender pull * `amount` of `token`. * * Reads token metadata via `fetchToken`. The returned `Requirement.sign()` produces the EIP-712 * signature, verifies it against the connected account, and returns a `RequirementSignature` * the bundler action helpers can consume. Deadline defaults to two hours from `Time.timestamp()`. * * @param viemClient - Connected viem `Client` whose `chain.id` matches `params.chainId`. * @param params - Permit encoding parameters. * @param params.token - ERC-20 token address (must support EIP-2612). * @param params.spender - Permit spender. Must be GeneralAdapter1 or MidnightBundles for the chain. * @param params.amount - Permit allowance amount. * @param params.chainId - Target chain id. * @param params.nonce - The user's current EIP-2612 nonce on `token`. * @param params.supportDeployless - Whether `fetchToken` should use deployless multicall. * @returns A `Requirement` whose `sign(client, userAddress)` produces the deep-frozen signature. * @throws {ChainIdMismatchError} when `viemClient.chain?.id !== params.chainId`. * @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not GeneralAdapter1 or * MidnightBundles for `chainId`. * @throws {MissingClientPropertyError} from `sign()` when the client has no `account.address`. * @throws {AddressMismatchError} from `sign()` when the client account differs from `userAddress`. * @throws {InvalidSignatureError} from `sign()` when EIP-712 verification fails. * @example * ```ts * import { createWalletClient, http } from "viem"; * import { mainnet } from "viem/chains"; * import { encodeErc20Permit } from "@morpho-org/morpho-sdk"; * * const client = createWalletClient({ chain: mainnet, transport: http() }); * const requirement = await encodeErc20Permit(client, { * token: USDC, // Must implement standard ERC-2612. DAI is routed through Permit2 by requirement helpers. * spender: generalAdapter1, * amount: 1_000_000n, * chainId: 1, * nonce: 0n, * }); * // requirement satisfies Requirement * ``` */ export declare const encodeErc20Permit: (viemClient: Client, params: EncodeErc20PermitParams) => Promise>; export {};