import type { DepositAccess, PolymarketPerpsTransferPending } from '../../providers/FunkitCheckoutContext/types'; import type { PerpsTransferDirection, PerpsTransferStatus } from './PolymarketPerpsTransferScreen'; /** * The *held* value of a chip/Max fill. pUSD has 6 on-chain decimals, so only * 6 decimals reproduce a balance exactly: capping at 2 rounded `196.867461` * *up* to `196.87`, which exceeded the real balance and tripped the * insufficient-balance guard. Trailing zeros are trimmed. The 2-decimal view * the user sees is {@link formatDisplayAmount}. */ export declare function formatAmountValue(value: number): string; /** * How the confirmed amount was chosen — `manual` typing, a percent chip * (`preset`), the Max chip, or an integrator-supplied `prefill` the user left * untouched. `null` until the amount is first set. */ export type PerpsTransferAmountSelection = 'manual' | 'preset' | 'max' | 'prefill'; export interface PerpsTransferFormProps { predictionsBalanceUsd: number; perpsBalanceUsd: number; /** Minimum pUSD to transfer *into* predictions (USD). */ predictionsMinTransferUsd?: number; /** Minimum pUSD to transfer *into* perps (USD). */ perpsMinTransferUsd?: number; initialDirection?: PerpsTransferDirection; /** Initial amount (plain USD string, up to 2 decimals). Omit for an empty field. */ initialAmountUsd?: string; status?: PerpsTransferStatus; /** * Integrator-supplied failure message. Shown in place of the generic notice * while `status` is `error`. */ errorMessage?: string | null; /** Whether a retained balance is waiting for a fresh authoritative value. */ isBalanceRefreshing?: boolean; /** * In-flight transfers reported by the integrator. While a deposit or * withdrawal is pending the button is disabled in a `pending` state. */ pendingTransfers?: PolymarketPerpsTransferPending; onTransfer: (params: { /** Exact string the user entered (validated numeric, ≤6 decimals). */ amountUsd: string; direction: PerpsTransferDirection; amountSelection: PerpsTransferAmountSelection | null; }) => void; access?: DepositAccess; } export interface PerpsTransferAccount { /** Localized account name ("Predictions" / "Perps"). */ label: string; balanceUsd: number; } /** Plain form state consumed by `PerpsTransferBody` and `PerpsTransferBottomBar`. */ export interface PerpsTransferForm { /** * The held amount (may contain separators) — what `onTransfer` forwards. * A chip/Max fill keeps up to 6 decimals here so no balance is stranded. */ amount: string; /** * What the input renders: `amount` verbatim while the user types, or a * 2-decimal cent-floored view of a chip/Max fill. Editing a fill replaces * the held value with the edited string, so the two converge on first edit. */ displayAmount: string; /** Validated setter — ignores input that isn't numeric with ≤2 decimals. */ setAmount: (next: string) => void; /** Fills the amount with the source balance at full 6-decimal precision. */ fillMaxAmount: () => void; /** * Fills the amount with a percentage of the source balance (100 behaves as * {@link fillMaxAmount}), floored at 6 decimals so the fill never exceeds * the real balance. */ fillPercentAmount: (percent: number) => void; swapDirection: () => void; canSwapDirection: boolean; /** The editable "From" account. */ source: PerpsTransferAccount; /** The read-only "To" account mirroring the source. */ destination: PerpsTransferAccount; /** Validation/error notice line; `null` when nothing should be shown. */ noticeText: string | null; /** * Status for the action button: `error` is remapped to a retry-able idle, * an in-flight transfer maps idle to `pending`, and a retained balance maps * idle to `loading` while its authoritative value is fetched. */ buttonStatus: PerpsTransferStatus; isTransferDisabled: boolean; /** Reports the entered amount + direction via the host's `onTransfer`. */ requestTransfer: () => void; } /** * Owns the Perps ⇄ Predictions transfer form state — amount, direction, and * the derived validation/notice/button values — so both the standalone * {@link PolymarketPerpsTransferScreen} (Dialog) and the in-modal * `PerpsTransferStep` (renders the body inline + portals the bottom bar) share * identical behavior. Returns plain values; `PerpsTransferBody` and * `PerpsTransferBottomBar` render them. */ export declare function usePerpsTransferForm({ predictionsBalanceUsd, perpsBalanceUsd, predictionsMinTransferUsd, perpsMinTransferUsd, initialDirection, initialAmountUsd, status, errorMessage, isBalanceRefreshing, pendingTransfers, onTransfer, access, }: PerpsTransferFormProps): PerpsTransferForm;