UNPKG

@funkit/connect

Version:

Funkit Connect SDK elevates DeFi apps via web2 sign-ins and one-click checkouts.

82 lines (81 loc) 3.84 kB
import type { TFunction } from 'i18next'; import React from 'react'; import type { Hex } from 'viem'; import type { CustomWithdrawalConfig, FunkitActiveWithdrawalItem, FunkitCheckoutConfig, WalletWithdrawalConfig } from '../../providers/FunkitCheckoutContext'; import { type WithdrawalFormData } from './useWithdrawal'; /** * WithdrawalContent only operates on concrete single-method withdrawal configs. * Multi-method configs are resolved in WithdrawalModal before reaching here. */ type FunkitWithdrawalConfig = WalletWithdrawalConfig | CustomWithdrawalConfig; interface WithdrawContentProps { onContinue: (withdrawal: WithdrawalFormData, txHash: Hex) => void; config: FunkitWithdrawalConfig; withdrawalItem: FunkitActiveWithdrawalItem | null; /** * Switch a Lighter Fast withdrawal to the Lighter Secure method. Wired by * {@link WithdrawalModal}; used by the over-$3M footer. */ onSwitchToSecure?: () => void; } /** * Converts a source-token amount string to its USD value using the given unit * price. Returns `undefined` when the price is not yet loaded so callers can * differentiate "still loading" from "actually $0". * * Exported for testing. */ export declare function toUsdValue(sourceAmount: string, sourceTokenUsdPrice: number | undefined): number | undefined; export declare function getWithdrawButtonText({ isWithdrawing, isValidAddress, isRecipientBlacklisted, isRecipientSameAsSource, withdrawalInputAmount, isWithdrawAmountValid, isWithdrawAmountTooHigh, isValidAddressAndChain, selectedToken, selectedChainId, selectedChainName, t, }: { isWithdrawing: boolean; isValidAddress: boolean; isRecipientBlacklisted: boolean; isRecipientSameAsSource: boolean; withdrawalInputAmount: string; isWithdrawAmountValid: boolean; isWithdrawAmountTooHigh: boolean; isValidAddressAndChain: boolean; selectedToken: string | undefined; selectedChainId: number | undefined; selectedChainName: string | undefined; t: TFunction; }): string; export declare function isValidWithdrawal({ config, checkoutConfig, withdrawalInputAmount, sourceTokenUsdPrice, recipientAddress, selectedChainId, sourceTokenBalance, selectedSourceToken, }: { config: FunkitWithdrawalConfig; checkoutConfig: FunkitCheckoutConfig | undefined; /** User-entered amount in source-token units (e.g. "0.5" for 0.5 ETH). */ withdrawalInputAmount: string; /** * USD price per unit of the source token. Hardcoded to 1 for stablecoin * sources; only Lighter Secure resolves a live spot price, and that path * uses `getMinWithdrawalAmount` (per-token) which takes priority over the * USD-min branch — so this field is only meaningfully consumed when it's 1. */ sourceTokenUsdPrice: number; sourceTokenBalance: string; recipientAddress: string; selectedChainId: number | undefined; selectedSourceToken: string | undefined; }): { isValidAddress: boolean; isValidAddressAndChain: boolean; isWithdrawAmountTooLow: boolean; isWithdrawAmountTooHigh: boolean; isWithdrawAmountAboveBalance: boolean; isWithdrawAmountValid: boolean; minWithdrawalDisplayValue: number; }; export declare const useFrozenSourceTokenBalance: ({ isWithdrawing, sourceTokenBalance, }: { isWithdrawing: boolean; sourceTokenBalance: string; }) => { displayedSourceTokenBalance: string; freezeDisplayedSourceTokenBalance(sourceTokenBalance: string): void; }; /** * Builds the source-token options list for the Lighter compound input dropdown. * Currently returns a single option per config; expands when Lighter exposes * multi-asset API support. */ export declare const WithdrawContent: ({ onContinue, config, withdrawalItem, onSwitchToSecure, }: WithdrawContentProps) => React.JSX.Element; export {};