/** * Contract error handling — thin, decoder-aware helpers. * * `formatContractError` turns whatever ethers throws into a single readable * `Error` with the contract's custom-error name (e.g. `AbsoluteCapExceeded`) * when the ABI knows it. * * The decoding leans on: * 1. `error.revert` — already parsed by ethers when the contract's ABI * contains the error definition (the common case). * 2. `iface.parseError(data)` — fallback when ethers couldn't parse it * itself but we still have the raw data. * 3. `describeRevertData(data)`: ecosystem-wide dictionary covering * custom errors raised by NESTED contracts (adapter, market, token), * plus the Error(string) / Panic(uint256) built-ins. * 4. `error.shortMessage` / `error.reason` / `error.message`: generic * fallbacks, keeping the raw selector greppable. */ import type { ethers } from "ethers"; /** * Format any contract-call error into a single, readable `Error`. * * @param method Caller-supplied label (e.g. function name) prepended to * the message. * @param error Whatever was thrown by ethers (untyped on purpose — * ethers' error shape varies). * @param iface Optional contract `Interface` used as a fallback decoder * when ethers couldn't parse the error itself. */ export declare function formatContractError(method: string, error: unknown, iface?: ethers.Interface): Error; /** * Send a contract write and forward any revert through `formatContractError`. * Pass any tx overrides as the final argument, ethers handles them natively. * * When the send fails WITHOUT revert bytes (ethers' "missing revert data": * some RPCs refuse to return them on estimateGas), the call is replayed as * an eth_call (staticCall, same sender via the contract's runner), which * reverts WITH the bytes, so the decoder can still name the reason. Best * effort: if the replay does not produce data either, the original error * is formatted as before. * * @example * await executeContractMethod(vaultContract, "deposit", amount, onBehalf); * await executeContractMethod(factory, "createVaultV2", owner, asset, salt, { gasLimit: 500_000n }); */ export declare function executeContractMethod(contract: ethers.Contract, method: string, ...args: unknown[]): Promise; /** * Read a contract view/pure method and forward any error through * `formatContractError`. */ export declare function callContractMethod(contract: ethers.Contract, method: string, ...args: unknown[]): Promise;