import { BigNumber, BigNumberish } from 'ethers'; /** * The money-path checks around an atomic, sponsored deposit batch — the * `approve + requestDepositWithKyc` pair `DepositFlow` hands its * `depositBatch` port. * * Two questions, both PURE: * * 1. Before anything is signed: is this batch exactly the deposit this run * asked for? (`validateDepositBatchCalls`) * 2. After it is mined: did THIS receipt deposit THIS amount, for THIS * lender, into THIS tranche? (`proveDepositInReceipt`) * * Neither knows a relay, a wallet vendor or a URL; the app's submitter calls * them. */ /** * ERC-4337 EntryPoint v0.7 — the contract a bundler calls `handleOps` on. The * proof reads the user operation's outcome from ITS events, and from no other * contract's. */ export declare const ENTRY_POINT_V07 = "0x0000000071727De22E5E9d8BAf0edAc6f37da032"; /** One call of a batch, as a submitter receives it. */ export interface DepositBatchCall { to: string; data: string; /** Native value. Absent or zero — neither call may send the native token. */ value?: BigNumberish; } /** What the run asked for. Every field is pinned on the batch. */ export interface DepositBatchExpectation { /** The ERC-20 the deposit is paid in — the approval's target. */ stableAsset: string; /** The contract approved AND called: the chain's `LendingPoolManager`. */ spender: string; poolId: string; trancheId: string; /** The run's amount, in BASE units — approved and deposited, exactly. */ amount: BigNumberish; /** * The run's fixed-term config (`'0'` = variable). REQUIRED: a batch that * locks the deposit into another term — or unlocks a fixed-term run into * variable — is a different deposit, and `DepositFlow` always carries the * value, so there is no consumer that genuinely lacks it. */ fixedTermConfigId: BigNumberish; } export interface ValidatedDepositBatch { /** The tranche the deposit goes into — what the receipt proof matches. */ tranche: string; /** The exact amount approved and deposited, in base units. */ amount: BigNumber; } /** * What `validateDepositBatchCalls` throws. `code` says which pin failed; the * message names no party, so a wallet-rejection classifier can never read it * as something the lender did. */ export declare class DepositBatchMismatchError extends Error { readonly code: string; constructor(code: string); } /** * Pin a deposit batch to the run that produced it — PURE; throws a * `DepositBatchMismatchError` on ANY deviation, before the lender's key signs * anything. * * The batch must be exactly two calls, in this order, with no native value: * * 0. `stableAsset.approve(spender, A)`; * 1. `spender.requestDepositWithKyc(poolId, trancheId, A, '0x', fixedTermConfigId, …)`; * * with `A` the run's own amount in BOTH — never more, never unlimited (house * rule: exact-amount approvals) — the run's own fixed-term config, each call * the canonical ABI encoding of its arguments, and no swap data. The deposit * data and KYC signature are not pinned here: they are signatures the * contract and the backend verify. * * This is the client's half; a relaying backend checks the same shape again. */ export declare function validateDepositBatchCalls(calls: readonly DepositBatchCall[], expected: DepositBatchExpectation): ValidatedDepositBatch; /** A mined log, as an ethers (or any) receipt carries it. */ export interface ReceiptLog { address: string; topics: readonly string[]; data: string; } /** The two receipt fields the proof reads. An ethers v5 receipt fits. */ export interface ReceiptLike { logs: readonly ReceiptLog[]; blockNumber: number; } export interface DepositProofExpectation { /** The lender — the user operation's `sender`, and the deposit's `user`. */ lender: string; tranche: string; /** The exact amount deposited, in base units. */ amount: BigNumberish; /** * The user operation hash, when the submitter knows it. With it, only * THAT operation counts; without it, the lender's ONLY operation in the * bundle does — two of them without a hash is `ambiguous-operation`. */ userOperationHash?: string | null; /** Defaults to `ENTRY_POINT_V07`. */ entryPoint?: string; /** * The strategy's pending pool. When supplied, a `DepositRequested` counts * only if THAT contract emitted it. */ pendingPool?: string; } export type DepositProof = /** This receipt shows this lender's deposit of this amount, in this tranche. */ { kind: 'deposited'; dNftId: BigNumber; blockNumber: number; } /** * The user operation ran and reverted — the account rolled both calls * back, nothing was deposited. `revertError` is the protocol error it * named, or `''`. */ | { kind: 'reverted'; revertError: string; } /** The receipt does not show this deposit. NEVER a success, never a failure. */ | { kind: 'unproven'; reason: 'no-user-operation' | 'ambiguous-operation' | 'no-deposit-requested' | 'malformed-receipt'; }; /** * Did THIS receipt deposit for THIS lender? — PURE. * * A sponsored batch lands as a bundler's `handleOps` transaction, and that * transaction's `status` is success even when the user operation inside it * reverted: the EntryPoint catches the revert, the account rolls back both * calls, nothing is deposited. So `status` decides NOTHING. What does: * * 1. The EntryPoint's `UserOperationEvent` for OUR operation — emitted BY * the EntryPoint, `sender` = lender, and `userOpHash` = the known hash * when there is one. * 2. Its `success` flag. `false` → `reverted`, naming the protocol error * from the matching `UserOperationRevertReason` when it decodes. * 3. A `DepositRequested` with `user` = lender, `tranche` = the run's and * `amount` = the run's, INSIDE our operation's execution: the logs after * the previous operation's event (or `BeforeExecution`, which precedes * the first) and before ours. A deposit from another operation in the * same bundle does not count, and neither does one emitted by a contract * that is not the pending pool, when the pending pool is known. * * Anything short of all three is `unproven`, which a consumer must treat as * PENDING — the money may have moved — and never as a failure. */ export declare function proveDepositInReceipt(receipt: ReceiptLike, expected: DepositProofExpectation): DepositProof; export interface UserOperationProofExpectation { /** The account that sent the operation — the lender's own wallet. */ sender: string; /** * The user operation hash, when the submitter knows it. With it, only * THAT operation counts; without it, the sender's ONLY operation in the * bundle does — two of them without a hash is `ambiguous-operation`. */ userOperationHash?: string | null; /** Defaults to `ENTRY_POINT_V07`. */ entryPoint?: string; } export type UserOperationProof = /** The sender's operation ran and SUCCEEDED: every call in it executed. */ { kind: 'executed'; blockNumber: number; } /** * The operation ran and reverted — the account rolled its calls back. * `revertError` is the protocol error it named, or `''`. */ | { kind: 'reverted'; revertError: string; } /** * The receipt does not show the operation — or, with no hash to go by, * shows TWO of the sender's and cannot tell which is ours. NEVER a * success, never a failure. */ | { kind: 'unproven'; reason: 'no-user-operation' | 'ambiguous-operation' | 'malformed-receipt'; }; /** * Did THIS receipt execute the sender's user operation? — PURE. The * single-call sibling of `proveDepositInReceipt`, for a sponsored * `requestWithdrawal`, a cancel or a fixed-term withdrawal: the same * EntryPoint `UserOperationEvent` from the same contract, for the same * sender (and hash, when known), read the same way — the `handleOps` * transaction's own `status` decides NOTHING, because it is a success even * when the operation inside it reverted. * * `executed` needs the operation's `success` flag. A single-call operation * that succeeded executed its one call; there is no event to match beyond * that, so pass the `userOperationHash` whenever the submitter reports one — * without it, the sender's ONLY operation in the bundle is the one read, and a * bundle holding two of theirs is `ambiguous-operation` (pending), never the * first one's verdict: with one succeeded and one reverted, "executed" would * tell the lender their request is queued when it is not. */ export declare function proveUserOperationInReceipt(receipt: ReceiptLike, expected: UserOperationProofExpectation): UserOperationProof;