import type { CheckoutQuoteResponse, SwappedSellOrderData, WithdrawalClient } from '@funkit/connect-core'; import type { ReactNode } from 'react'; import type { Address } from 'viem'; /** * A token in a withdrawal — the source the user sells, or the token Swapped * accepts on-chain. `decimals` only matters for the accepted token (skips an * on-chain read during execution). */ /** * One selectable withdrawal method. The user picks it on the method screen and * `config` is what the flow then runs — a concrete config, never one that * carries `methods` itself. */ export interface WithdrawalMethodOption { /** Stable id, also used for tracking. */ id: string; title: string; subtitle?: string; icon?: ReactNode; config: WithdrawalFlowConfig; } export interface WithdrawalToken { /** Numeric chain id as a string (web-aligned, e.g. `'8453'`). */ chainId: string; address: Address; /** Recorded against the on-chain movement + logs. */ symbol: string; /** Known token decimals — skips an on-chain read during execution. */ decimals?: number; } /** * One selectable source token. Present only when the host offers a choice; * with a single source, `WithdrawalFlowConfig.sourceToken` is enough. */ export interface WithdrawalSourceTokenOption { token: WithdrawalToken; /** Row label; defaults to the token symbol. */ label?: string; iconSrc?: string; } /** Which source token a balance / limit callback is being asked about. */ export interface WithdrawalSourceTokenParams { sourceToken: WithdrawalToken; } /** The withdrawal the user committed to, handed to a venue that submits it itself. */ export interface CustomWithdrawalSubmission { /** The quote the user approved, or `null` on a rail that never quoted. */ quote: CheckoutQuoteResponse | null; recipientAddress: Address; /** Which balance to debit — the user's pick when `sourceTokens` offers several. */ sourceToken: WithdrawalToken; destinationToken: WithdrawalToken; /** Source-token units, already net of `quoteInputFeeTokens`. */ amountTokenUnits: string; } /** * Data the managed withdrawal flow renders and executes against. Mirrors the * web `FunkitWithdrawalConfig` family where the concepts overlap. * * Two rails share this config: the Swapped fiat offramp, and the crypto * send-to-address rail. Fields marked "crypto rail" are ignored by the offramp. */ export interface WithdrawalFlowConfig { /** The token being withdrawn; the default pick when `sourceTokens` is set. */ sourceToken: WithdrawalToken; /** * Crypto rail: source tokens the user can pick between. Omit for a single * source — `sourceToken` is then the only option and no picker is shown. */ sourceTokens?: WithdrawalSourceTokenOption[]; /** * Crypto rail: spendable balance of a source token, in that token's units. * The integrator is authoritative — it knows about locks, pending orders and * borrow limits the SDK can't see on-chain. A plain value is read on render, * so keep it cheap and referentially stable; a promise is awaited once per * source token, with the balance held at zero until it settles. A throw or * a nonsense value is treated as a zero balance rather than breaking the form. */ withdrawalSourceTokenBalance?: (params: WithdrawalSourceTokenParams) => string | number | Promise; /** Crypto rail: minimum withdrawal in USD. Defaults to $0.01. */ getMinWithdrawalUSD?: (params: WithdrawalSourceTokenParams) => number; /** * Crypto rail: minimum as the user sees it — the source token's own units, * not base units. Takes priority over {@link getMinWithdrawalUSD}. */ getMinWithdrawalAmount?: (params: WithdrawalSourceTokenParams) => number; /** Crypto rail: maximum withdrawal in USD. Unlimited when omitted. */ getMaxWithdrawalUSD?: (params: WithdrawalSourceTokenParams) => number; /** * Ceiling in source-token units. Takes priority over `getMaxWithdrawalUSD`, * which needs a resolvable spot price and so goes unenforced for a source the * price API doesn't know (an L2 balance addressed by index, say). */ getMaxWithdrawalAmount?: (params: WithdrawalSourceTokenParams) => number; /** Crypto rail: token symbol to preselect as the destination. */ defaultReceiveToken?: string; /** * Crypto rail: hide the shortcut that fills the recipient field with the * connected wallet's own address. */ disableConnectedWallet?: boolean; /** * The token Swapped accepts on-chain (the leg the quote delivers), when it * differs from the source. Omit when Swapped accepts the source token; a * matching Statsig `swappedwithdrawalsourceoverrides` rule takes precedence. */ swappedAcceptedToken?: WithdrawalToken; /** * Host-provided signer that executes the on-chain leg (the host app owns the * keys — the SDK never touches key material). Implement the `WithdrawalClient` * interface over your wallet stack (viem, wagmi, WalletConnect, …). * * Omit it when there is no end-user signer to offer — Fun moves the funds * from the client's omnibus account, so the host holds no keys for this user. * The flow still renders and quotes (priced against the zero address), but it * cannot put a transfer on-chain itself: cash payout methods are withheld, * and submitting throws unless {@link submitWithdrawal} takes over. */ withdrawalWallet?: WithdrawalClient; /** * Replaces relay execution: the venue moves the funds itself and resolves with * the address it sent them to. The quote is priced for display and never * executed. A throw rejects the withdrawal, and its message reaches the user. */ submitWithdrawal?: (params: CustomWithdrawalSubmission) => Promise<{ depositAddress: Address; }>; /** Sheet title; defaults to 'Withdraw'. */ title?: string; /** * Replaces the single crypto row on the method screen with a choice of * methods, each running its own config. Built by a client module (see * `@funkit/connect-rn/clients/*`) so no venue is named here; the fields above * still describe the Swapped offramp. */ methods?: WithdrawalMethodOption[]; /** * Flat fee in source-token units taken from the amount **before** quoting, so * the quote prices what the venue will actually move. It changes the amount, * not the fee summary. */ quoteInputFeeTokens?: number; /** * Whether `quoteInputFeeTokens` is the real fee yet, or a not-yet-resolved * placeholder. Defaults to `true` (no fee to wait on). While `false`, the * crypto rail holds off quoting rather than pricing a fee that is about to * change under the user. */ quoteInputFeeSettled?: boolean; /** * A fee the venue bills as source-chain gas, in USD, added to the summary's * network cost. Leave it unset when the quote's own gas figure already carries * the fee, or the row counts it twice. */ extraSourceGasUsd?: number; /** * Spendable source balance in **USD**. The SDK caps the Swapped sell to it * (USD→EUR via live rates) and blocks cash methods below Swapped's minimum. * Pass a number or a callback resolved when the flow opens (e.g. an on-chain * `balanceOf`) — the first request is held until it settles. Omit to leave * the sell uncapped. */ sourceUsdBalance?: number | (() => number | Promise); } /** Lifecycle callbacks passed to `useFunkitCheckout`. */ export interface WithdrawalFlowCallbacks { onOpen?: () => void; onClose?: () => void; onCheckoutBlocked?: () => void; /** * Offramp only: the embed emitted a validated sell order (deposit address + * exact amount of the accepted token). Fired before the SDK executes — * observability / escape hatch for hosts that track orders themselves. */ onWithdrawalOrder?: (order: SwappedSellOrderData) => void; /** * The withdrawal was submitted. The first argument identifies it: the * provider order id on the offramp, and an SDK-minted submission id on the * crypto rail (which has no provider). * * The second is what to follow it by — the transaction hash, or the venue's * deposit address when {@link WithdrawalFlowConfig.submitWithdrawal} ran. */ onWithdrawalSubmitted?: (orderId: string, depositAddressOrHash: string) => void; /** * The withdrawal completed: Swapped confirmed the fiat payout, or the crypto * transfer reached a terminal on-chain state. */ onWithdrawalSuccess?: (data?: unknown) => void; /** Unrecoverable execution failure (user rejections are not errors). */ onWithdrawalError?: (error: { message: string; }) => void; } //# sourceMappingURL=withdrawalFlowConfig.d.ts.map