import { Address, Hex } from "viem"; //#region src/onchain/utils/trace.d.ts /** * A single frame from Ethereum's `debug_traceTransaction` callTracer output. * Recursive: each frame may contain nested sub-calls. */ export interface CallTrace { from: Address; to: Address; input: Hex; output: Hex; value: Hex; /** "CALL", "DELEGATECALL", "STATICCALL", "CREATE", etc. */ type: string; /** Present when the call reverted (e.g. "execution reverted"). */ error?: string; /** ABI-encoded revert data, if available. */ revertReason?: Hex; calls?: CallTrace[]; } /** * Selector of `CreditManagerV3.execute(bytes)` (`0x09c5eabe`). * * This is the authoritative marker of an adapter performing an external * protocol call: the adapter calls the credit manager's `execute(bytes)`, which * forwards the calldata to the credit account, which in turn CALLs the target * (protocol) contract. Adapter approvals use a different selector * (`execute(address,bytes)` on the credit account), so matching on this * selector isolates the real protocol call. */ export declare const EXECUTE_BYTES_SELECTOR: "0x09c5eabe"; /** * Finds the shallowest non-reverted `CreditManager.execute(bytes)` call in a * trace subtree (breadth-first), or `undefined` if none exists. * * "Shallowest" matters for account migration: a migrate adapter nests the * entire target `openCreditAccount` multicall - including that account's own * `execute(bytes)` calls - inside its subtree. The shallowest match is the * adapter's own protocol call, not a nested one. */ export declare function findExecuteBytes(node: CallTrace): CallTrace | undefined; /** * Finds the first non-reverted CALL in a subtree whose `input` exactly matches * `input` (case-insensitive). Used to locate the leaf CALL to the target * contract: `execute(bytes)` forwards the calldata unchanged through the credit * account proxy DELEGATECALL down to the final CALL to the protocol contract. */ export declare function findCallWithInput(node: CallTrace, input: Hex): CallTrace | undefined; /** * Resolves the external protocol call performed by an adapter-level call trace. * * Locates the shallowest `CreditManager.execute(bytes)`, decodes the forwarded * calldata, then finds the leaf CALL whose input matches that calldata to * recover the target (protocol) contract address. Returns `undefined` when the * subtree does not actually reach an external protocol CALL (e.g. the * facade-internal `depositPhantomToken` / `withdrawPhantomToken` accounting * calls, which forward calldata but make no external CALL). * * @param node - direct child node of the upper-level facade call trace */ export declare function resolveProtocolCall(node: CallTrace): { contract: Address; calldata: Hex; } | undefined; /** * Finds the first non-reverted CALL to `target` anywhere in a trace subtree. */ export declare function findCallTo(node: CallTrace, target: Address): CallTrace | undefined; /** * DFS walk of the call trace tree, collecting non-reverted CALL entries * to the given address. * Does not recurse into children of matched nodes */ export declare function collectTraces(node: CallTrace, target: Address): CallTrace[]; //#endregion