/** * Lighter-specific withdrawal helpers, hooks, and display components. * * Extracted from WithdrawalContent.tsx to keep Lighter-specific logic isolated. */ import { type LighterAccountIndex } from '@funkit/api-base'; import { type LighterChainId } from '@funkit/chains'; import type { TFunction } from 'i18next'; import React from 'react'; import { type Address, type Hex } from 'viem'; import { type CheckoutConfirmationError } from '../../domains/checkoutErrors'; import type { CustomWithdrawalConfig, LighterRouteType, TokenInfo, WalletWithdrawalConfig } from '../../providers/FunkitCheckoutContext'; /** Stable method ids for the Fast / Secure options (used for tracking + switching). */ export declare const LIGHTER_FAST_METHOD_ID = "lighter-fast"; export declare const LIGHTER_SECURE_METHOD_ID = "lighter-secure"; export { LIGHTER_DEFAULT_SECURE_MIN_WITHDRAWAL_AMOUNTS, LIGHTER_FAST_MAX_WITHDRAWAL_USD, LIGHTER_ROUTE_TYPE, LIGHTER_SECURE_ASSETS_BY_INDEX, LIGHTER_STAKING_POOL_INDEX, LIGHTER_STAKING_THRESHOLD_LIT, LIGHTER_UNSTAKED_FEE_TOKENS, LIGHTER_USDC_SPOT_SYMBOL, getLighterBaseSymbol, getLighterSecureL1Address, resolveLighterAssetIndex, resolveLighterSecureRouteType, } from '@funkit/connect-core/clients/lighter'; /** * The selected source token as identified on Lighter's own L2, rather than by * its mainnet bridge address — two Secure selections can share one mainnet * address (USDC perps and USDC spot both bridge mainnet USDC), so the bridge * address can't name which balance is meant. * * Follows `RELAY_LIGHTER_FUN_ADDRESS_MAP`: the asset index left-padded into an * address (`0x…01` = ETH spot, `0x…03` = USDC spot). `undefined` when the index * hasn't resolved yet, so callers keep their existing value rather than pointing * at asset 0. */ export declare function resolveLighterSourceAsset({ assetIndex, routeType, chainId, }: { assetIndex: number | undefined; routeType: LighterRouteType; /** Lighter instance the withdrawal draws from. */ chainId: LighterChainId; }): TokenInfo | undefined; export declare function resolveLighterConfirmedTarget({ isLighterSecure, l1TokenAddress, selectedSourceToken, withdrawalInputAmount, l1ChainId, }: { isLighterSecure: boolean; /** The L1 token the withdrawal lands as. */ l1TokenAddress: Address | undefined; selectedSourceToken: string; withdrawalInputAmount: string; l1ChainId: number; }): { asset: TokenInfo; ticker: string; amount: number; } | undefined; /** * Footer shown beneath the CTA when a Lighter Fast amount exceeds the $3M cap. * Renders as the `description` of a FunNotification, which supplies the shared * notification typography; offers an inline link to switch to the Secure method. */ export declare function LighterFastMaxExceededMessage({ onSwitchToSecure, }: { onSwitchToSecure: () => void; }): React.JSX.Element; /** * Fetches the Lighter account for the data the SDK still derives itself: * `assets`, to resolve the L2 asset index of a Secure selection. Withdrawable * balances are the integrator's to supply (`withdrawalSourceTokenBalance`), so * nothing here computes them. */ export declare function useLighterWithdrawalBalances({ accountIndex, }: { accountIndex: LighterAccountIndex | undefined; }): { assets: import("@funkit/connect-core").LighterAsset[]; isLoading: boolean; }; type FunkitWithdrawalConfig = WalletWithdrawalConfig | CustomWithdrawalConfig; /** * Lighter Fast withdrawal: perps collateral, routed through Fun + Relay. Its * source chain is the key's Lighter instance (`chainId`); Secure's is the L1. * See buildLighterFastWalletWithdrawalConfig. */ export declare function isLighterFastWithdrawal(chainId: LighterChainId | undefined, config: Pick): boolean; /** The fixed Fast source chip for the key's instance; `undefined` off Fast. */ export declare function getLighterFastSourceChip(apiKey: string, config: Pick, t: TFunction): { label: string; tooltip: string; } | undefined; /** * Lighter Secure withdrawal: an L1 withdrawal from the key's Lighter instance * (`chainId`), for instances that offer Secure. */ export declare function isLighterSecureWithdrawal(chainId: LighterChainId | undefined, config: Pick | null | undefined): boolean; /** The key's Lighter instance when `config` is its Secure withdrawal. */ export declare function getLighterSecureWithdrawalChainId(apiKey: string, config: Pick | null | undefined): LighterChainId | undefined; /** A Fast source names the instance; a Secure source names its L1. */ export declare function resolveLighterWithdrawalInstance(sourceChainId: string): LighterChainId | undefined; /** * Detects Lighter Secure withdrawal on the instance's L1, auto-fills the * recipient address with the connected wallet, and fetches the Lighter account * so per-asset balances are available to the withdrawal form. */ export declare function useLighterWithdrawal(config: FunkitWithdrawalConfig, setRecipientAddress: (addr: string) => void, selectedSourceToken: string): { lighterChainId: 3586256 | 548123634 | undefined; isLighterSecure: boolean; skipsRecipientScreening: boolean; isLighterFast: boolean; isUnifiedTradingMode: boolean; connectedAddress: `0x${string}` | undefined; lighterSecureL1Address: `0x${string}` | undefined; lighterSecureAsset: { assetIndex: number; routeType: LighterRouteType; } | undefined; lighterSourceCustomData: { type: 'lighter'; routeType: LighterRouteType; } | undefined; lighterSourceAsset: TokenInfo | undefined; lighterFastUnstakedFee: number; isLighterFastUnstakedFeeFetched: boolean; invalidateLighterAccount: () => void; }; /** * Lighter Secure L1 on-chain withdrawal fallback. * * When the gasless L2 withdraw is rate-limited (error 23004), the user can * withdraw directly on-chain via `zkLighter.withdraw`. This is a distinct, * gas-paying, wallet-signed path — offered explicitly, never automatic. * * Availability latches on the first rate-limit error (the transient * `withdrawalError` auto-clears after ~10s) and resets when the user edits the * amount or source token, so a fresh attempt can retry the L2 path. */ export declare function useLighterL1Fallback({ isLighterSecure, chainId, withdrawalError, connectedAddress, resetKey, }: { isLighterSecure: boolean; chainId: LighterChainId | undefined; withdrawalError: CheckoutConfirmationError | null; connectedAddress: Address | undefined; /** Changes when the user edits amount/token — resets the latched offer. */ resetKey: string; }): { isL1FallbackAvailable: boolean; submitL1Withdrawal: ({ assetIndex, routeType, amountTokenUnits, recipientAddr, tokenSymbol, mainnetTokenAddress, withdrawalUSD, onConfirmed, }: { assetIndex: number; routeType: LighterRouteType; amountTokenUnits: string; /** Connected wallet — L1 owner of the Lighter account (tracking userId). */ recipientAddr: Address; /** Source-token symbol (may carry a ` (Spot)` suffix) — for tracking. */ tokenSymbol: string; /** Mainnet ERC-20 the withdrawal lands as. */ mainnetTokenAddress: Address; /** USD value (token amount × spot) — for tracking attribution. */ withdrawalUSD: string; onConfirmed: (txHash: Hex) => void; }) => Promise; isSubmittingL1: boolean; l1FallbackError: CheckoutConfirmationError | null; }; /** * Lighter Secure: recipient address, locked to the connected wallet. A * read-only `FunInput` (not a `
`) keeps it focusable and announced by * screen readers; the hover tooltip explains the lock. */ export declare function LighterSecureAddressDisplay({ address }: { address: string; }): React.JSX.Element; /** * Lighter Secure: display-only receive token + chain. Both are locked — the * token always matches the source asset, and the destination chain is always * the instance's L1. Each field surfaces a hover tooltip explaining the lock. */ export declare function LighterSecureReceiveDisplay({ sourceTokenSymbol: rawSourceTokenSymbol, chainId, }: { sourceTokenSymbol: string; chainId: LighterChainId; }): React.JSX.Element; /** * Lighter Secure: receive amount value (1:1 — same token, no swap). */ export declare function LighterSecureReceiveAmountValue({ amount, tokenSymbol: rawTokenSymbol, }: { amount: string; tokenSymbol: string; }): React.JSX.Element; /** * Lighter Secure: immediate success screen (no loading spinner). * * Unlike the standard `PendingSuccessScreen` that polls for relay status, * Lighter Secure calls Lighter's API directly and runs outside of the * FunKit relay system. This component shows an immediate success state. */ export declare function LighterSecureWithdrawalSuccess({ onClose, onNewWithdrawal, amount, tokenSymbol: rawTokenSymbol, txHash, chainId, }: { onClose: () => void; onNewWithdrawal: () => void; amount: string; tokenSymbol: string; txHash: string; chainId: LighterChainId; }): React.JSX.Element;