import { BigNumberish } from 'ethers'; /** * The single-call requests a sponsored relay may carry — the four * `LendingPoolManager` requests, plus the stable asset's own `transfer` (P2P * Send) — encoded by the SDK so no application hand-builds calldata or * hand-maps the relay's `kind` for them. * * Every function here is PURE: addresses and ids in, `{ kind, call }` out. * Reading the chain (the shares a withdrawal is for) is the facade's job — * `kasu.calls` — and sending is the application's. * * Each call is `{ to, data }` and nothing else: no `value` (none of these * functions is payable), no `from` (the manager acts for `msg.sender`, the * lender's own account, which is why none of them takes a user argument). * `data` is ethers' ABI encoding, which is canonical by construction — the * relay re-encodes what it decodes and refuses anything that differs, so a * hand-tweaked blob never gets through, and an SDK-built one always matches. */ /** * The relay's name for each shape. Carried beside the call so the app posts * `kind` from the SDK, never from a table of its own — a request declaring the * wrong kind is refused (`invalid_calls`), so a hand-mapped table that drifts * turns into a lender who cannot withdraw. */ export declare const SPONSORED_CALL_KINDS: readonly ["withdrawal", "cancel_deposit", "cancel_withdrawal", "withdraw_at_expiry", "transfer"]; export type SponsoredCallKind = (typeof SPONSORED_CALL_KINDS)[number]; /** One encoded call and the relay `kind` that names its shape. */ export interface SponsoredCall { kind: SponsoredCallKind; /** * Exactly `{ to, data }` — structurally the flows' `BatchCall`. Post it as * the relay's single call; do not add keys to it. */ call: { to: string; data: string; }; } /** * The 4-byte selector of each kind's function, DERIVED from the generated * ABIs (`ILendingPoolManager`, and `IERC20Metadata` for `transfer`) — never * typed in by hand, so an ABI change moves it and the cross-check spec * against the relay's own pins goes red. */ export declare const SPONSORED_CALL_SELECTORS: Readonly>; /** * What an encoder throws for an input it will not encode. `code` names the * argument; the message names no party, so a wallet-rejection classifier can * never read it as something the lender did. Nothing has been sent when this * is thrown. */ export declare class SponsoredCallInputError extends Error { readonly code: string; constructor(code: string); } /** * `requestWithdrawal(poolId, trancheId, shares)` — `withdrawal`. * * `shares` are tranche SHARES, not assets: `kasu.calls.requestWithdrawal` * converts an asset amount (or `'max'`) into them exactly as * `UserLending.requestWithdrawalInAsset` / `requestWithdrawalMax` do. Zero * shares is refused here: the contract reverts on it * (`RequestWithdrawSharesAreZero`) and the relay refuses it before that. */ export declare function encodeRequestWithdrawalCall(lendingPoolManager: string, poolId: string, trancheId: string, shares: BigNumberish): SponsoredCall; /** `cancelDepositRequest(poolId, dNftId)` — `cancel_deposit`. */ export declare function encodeCancelDepositCall(lendingPoolManager: string, poolId: string, dNftId: BigNumberish): SponsoredCall; /** `cancelWithdrawalRequest(poolId, wNftId)` — `cancel_withdrawal`. */ export declare function encodeCancelWithdrawalCall(lendingPoolManager: string, poolId: string, wNftId: BigNumberish): SponsoredCall; /** * `requestFixedTermDepositWithdrawal(poolId, fixedTermDepositId)` — * `withdraw_at_expiry`. The contract function takes the pool and the LOCK id * only (no tranche): the manager forwards to the fixed-term contract on the * lender's behalf, which knows the lock's tranche. */ export declare function encodeWithdrawAtExpiryCall(lendingPoolManager: string, poolId: string, fixedTermDepositId: BigNumberish): SponsoredCall; /** * `stableAsset.transfer(to, amount)` — `transfer`: P2P Send of the chain's * stable asset from the sender's own account (`msg.sender`) to `to`. * * `amount` is in the token's BASE units (6 decimals for USDC), and must be * greater than zero. `to` must be a well-formed, non-zero address (a * mixed-case one with a valid EIP-55 checksum). That is * ALL this encoder judges, because it is all a pure function can know. * * The recipient POLICY is the relay's job and is deliberately not restated * here: it refuses the sender's own account, the stable asset, the * `LendingPoolManager`, the precompile range, any address with contract code * (read on chain at submission), a sender our identity store does not hold * as verified, and anything over the sender's daily count and amount caps. * A call this encoder accepts can therefore still be refused — the app maps * the relay's refusal codes to its own words. * * Pass `stableAsset` from the chain config (`CHAIN_CONFIGS[chain].stableAsset * .address`) — the relay compares `to` against its own configured token and * refuses any other contract. */ export declare function encodeStableTransfer(input: { stableAsset: string; to: string; amount: BigNumberish; }): SponsoredCall;