import { type CheckoutQuoteResponse } from '@funkit/utils'; import { type Address, type Hex } from 'viem'; import type { WithdrawalClient } from '../interfaces/withdrawalClient'; import type { FunLogger } from '../utils/funLogger'; /** A token leg of a crypto withdrawal. */ export interface CryptoWithdrawalToken { /** Numeric chain id as a string, matching api-base's token shapes. */ chainId: string; address: Address; symbol: string; } /** A user-confirmed send-to-address withdrawal, ready to execute. */ export interface CryptoWithdrawalOrder { /** * Caller-minted idempotency key (the caller owns dedupe). Also the id * surfaced to hosts, standing in for the fiat rail's provider order id. */ submissionId: string; /** Where the funds land — the quote's `recipientAddress`. */ recipientAddress: Address; /** * Amount of the SOURCE token in human units, as the user typed it. Logged * for reconciliation only; the base-unit figure that actually moves comes * off the quote. */ sourceAmountHumanUnit: string; sourceToken: CryptoWithdrawalToken; destinationToken: CryptoWithdrawalToken; } /** * Retry safety, which callers MUST branch on: * - `MISSING_RELAY_QUOTE` — nothing was submitted; safe to re-quote and retry. * - `MISSING_TX_HASH` — relay reported the user actions completed, so funds may * already have moved. NEVER retry; surface for manual reconciliation. */ /** * Mint the id that dedupes a submission. Lives here so callers don't take on a * uuid dependency of their own. */ export declare function createWithdrawalSubmissionId(): string; export type CryptoWithdrawalErrorCode = 'MISSING_RELAY_QUOTE' | 'MISSING_TX_HASH'; /** Typed failure so callers can branch on retry safety without string matching. */ export declare class CryptoWithdrawalError extends Error { readonly code: CryptoWithdrawalErrorCode; constructor(code: CryptoWithdrawalErrorCode, message: string); } export interface ProcessCryptoWithdrawalOrderParams { order: CryptoWithdrawalOrder; /** * The quote the user approved on screen — executed as-is, never re-fetched, * so the fees they saw are the fees they pay. Callers keep it fresh by * re-quoting on their own interval. */ quote: CheckoutQuoteResponse; wallet: WithdrawalClient; apiKey: string; userId: string; logger: FunLogger; /** Relay step progress (raw step action text), for optional host display. */ onStepMessage?: (message: string) => void; } /** * Execute → record pipeline for a crypto send-to-address withdrawal. Unlike the * fiat rail it does not quote: it executes the EXACT_IN quote the user approved. * * - Callers own dedupe and re-entrancy; pre-record steps throw (see * {@link CryptoWithdrawalErrorCode} for retry safety). * - Recording never throws — the funds have already moved. * - Needs `ensureRelayClientInitialized` called first. */ export declare function processCryptoWithdrawalOrder({ order, quote, wallet, apiKey, userId, logger, onStepMessage, }: ProcessCryptoWithdrawalOrderParams): Promise<{ txHash: Hex; quote: CheckoutQuoteResponse; }>; //# sourceMappingURL=cryptoWithdrawal.d.ts.map