import { z } from "zod"; import type { SupportedChain, UnsignedTx } from "../../types/index.js"; /** * Distinctive description tag used whenever an approval is emitted at * maxUint256. Makes it easy to eyeball the Ledger preview text and also lets * tests assert the user-visible surfacing. */ export declare const UNLIMITED_APPROVAL_WARNING = "[WARNING: UNLIMITED APPROVAL \u2014 verify on Ledger device screen]"; /** * Shared ERC-20 approval builder. Every prepare_* tool that needs an allowance * before its main call routes through buildApprovalTx() so the USDT reset * pattern, the optional cap logic, and the description string stay in one * place. Previously each module hand-rolled its own `ensureApprovalTx` with * subtle divergences (some exact, some unlimited, some missing the USDT * reset). */ /** * Resolves the caller-supplied `approvalCap` to a concrete bigint and a * human-readable display string. * * Semantics: * undefined / "unlimited" → maxUint256 (traditional DeFi UX default) * "exact" → amountWei (approve only what's needed) * decimal string ("500") → parseUnits(cap, decimals), must be ≥ amountWei * * Callers decide the default for their tool by the value they pass: omit the * arg to get "unlimited", or hardcode "exact" (Aave / swap already do this). */ export declare function resolveApprovalCap(cap: string | undefined, amountWei: bigint, decimals: number): { approvalAmount: bigint; display: string; }; export interface BuildApprovalArgs { chain: SupportedChain; wallet: `0x${string}`; asset: `0x${string}`; spender: `0x${string}`; /** Amount the follow-up action will actually pull (required on-chain). */ amountWei: bigint; /** Amount to approve; resolved via resolveApprovalCap. */ approvalAmount: bigint; /** Display-only label for the cap (unlimited / exact amount / N capped). */ approvalDisplay: string; symbol: string; /** Spender label for descriptions, e.g. "Compound V3 cUSDCv3". */ spenderLabel: string; } /** * Build an approve tx (or a reset→approve chain for USDT-style tokens). * Returns null when no approval tx is needed. * * Three outcomes, in order: * 1. Current allowance already satisfies the action AND the cap — return * null. "Satisfies the cap" means: the user asked for "unlimited" (no * cap), OR the existing allowance is ≤ approvalAmount. In other words, * we only leave the allowance alone when doing so respects the caller's * intent. * 2. Current allowance satisfies the action BUT exceeds an explicit cap — * emit reset(0) → approve(cap). The user asked for a ceiling and we * enforce it even if it means an extra tx. This is the fix for the * silent-no-op footgun where a prior unlimited approval would defeat a * new `approvalCap: "500"` request. * 3. Current allowance is below what the action needs — emit approve(cap) * (or reset→approve for USDT-style tokens when allowance > 0). */ export declare function buildApprovalTx(a: BuildApprovalArgs): Promise; /** * Zod schema fragment for an optional `approvalCap` tool parameter. Share * across every prepare_* tool that emits an approval. */ export declare const approvalCapSchema: z.ZodOptional;