import { CurrencyType } from '@zkp2p/sdk'; import { D as CashClient, $ as EstimateInput, h as CashEstimate, Z as CashoutOptions, g as CashoutResult, Y as CashoutInput, T as TopUpResult, W as WithdrawResult, d as CashOrder } from './createCashClient-CZgoTClw.cjs'; import { WalletClient } from 'viem'; import '@relayprotocol/relay-sdk'; interface UseEstimateOptions { client: CashClient | null; /** Amount to convert, USDC base units. Estimate is skipped while null/0. */ amount: bigint | null | undefined; currency: CurrencyType | null | undefined; /** Optional payout platform for corridor pricing and pair-specific ETA sampling. */ platform?: string | null | undefined; /** Optional Relay source. Omit for the Base USDC default path. */ source?: EstimateInput['source'] | null | undefined; /** Disable to render the oracle rate before loading pair fill stats separately. */ includeEta?: boolean; /** Re-fetch interval (ms) so the displayed rate tracks the market. 0 = no auto-refresh. */ refreshIntervalMs?: number; } /** * Market-rate estimate for a screen-1 display. The figure is a `≈` estimate; * inspect `estimate.binding` for whether it binds at intent signal or, for * Alipay/CNY, deposit preparation. */ declare function useEstimate({ client, amount, currency, platform, source, includeEta, refreshIntervalMs, }: UseEstimateOptions): { estimate: CashEstimate | null; isLoading: boolean; error: Error | null; refresh: () => Promise; }; type PendingMutation = 'cashout' | 'withdraw' | 'topUp'; interface UseCashoutOptions { client: CashClient | null; /** A viem WalletClient with an account, on Base. */ signer: WalletClient | null | undefined; /** Source-chain signer for Relay source routing. Required when the source chain is not Base. */ sourceSigner?: WalletClient | null | undefined; onSourceProgress?: CashoutOptions['onSourceProgress']; onCashout?: (result: CashoutResult) => void; onError?: (error: Error) => void; } /** * Orchestrate a cash-out end to end on the maker side: * - `cashout(input)` → create the market-rate deposit, resolve its composite id. * - `topUp(depositId, amount)` → add USDC to a live order. * - `withdraw(depositId, amount?)` → the ONE unwind verb; partial with an * amount, full close without. The caller never chooses between * cancel/recover - expired intents are pruned automatically. */ declare function useCashout({ client, signer, sourceSigner, onSourceProgress, onCashout, onError, }: UseCashoutOptions): { cashout: (input: CashoutInput) => Promise; topUp: (depositId: string, amount: bigint) => Promise; withdraw: (depositId: string, amount?: bigint) => Promise; pending: PendingMutation | null; result: CashoutResult | null; error: Error | null; }; interface UseOrderOptions { client: CashClient | null; /** Composite deposit id (`escrow_onchainId`). The resumable anchor. */ depositId: string | null | undefined; /** Poll cadence while the order is in flight (ms). */ pollIntervalMs?: number; /** Disable automatic polling (manual `refresh()` only). */ paused?: boolean; } /** * Observe a cash-out order's lifecycle, keyed by `depositId`. * * Fully resumable: the order is reconstructed from on-chain data on every load, * so it survives a closed tab, a new device, or a wallet reconnect. Polls while * the order is in flight and stops once it reaches a terminal state. * `ORDER_NOT_FOUND` right after creation is indexer lag - polling continues. */ declare function useOrder({ client, depositId, pollIntervalMs, paused, }: UseOrderOptions): { order: CashOrder | null; isLoading: boolean; error: Error | null; refresh: () => Promise; }; interface UseOrdersOptions { client: CashClient | null; /** The connected user's address (the maker / depositor). */ owner: string | null | undefined; /** Max deposits to scan. */ limit?: number; /** Poll cadence (ms) while the feed is enabled. */ pollIntervalMs?: number; paused?: boolean; } /** * List the user's cash-out orders (the Transactions-feed pattern). Reads * deposits by depositor and derives real amounts + states from the indexer * aggregates. Polls while enabled so an empty or terminal feed can still * discover a newly indexed cash-out without a remount. */ declare function useOrders({ client, owner, limit, pollIntervalMs, paused, }: UseOrdersOptions): { orders: CashOrder[]; inFlightCount: number; totalCashedOut: bigint; isLoading: boolean; error: Error | null; refresh: () => Promise; }; export { type UseCashoutOptions, type UseEstimateOptions, type UseOrderOptions, type UseOrdersOptions, useCashout, useEstimate, useOrder, useOrders };