@funkit/connect 10.5.0 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +62 -0
- package/dist/clients/chunk-2FSEE3AW.js +277 -0
- package/dist/clients/chunk-5MY7WMEJ.js +20 -0
- package/dist/clients/chunk-6CYZKITE.js +33 -0
- package/dist/clients/{chunk-QHS5N7GP.js → chunk-C4SHJFOV.js} +2 -2
- package/dist/clients/{chunk-WRS7AFM2.js → chunk-FNB7OPJI.js} +12 -199
- package/dist/clients/{chunk-2NBYHUIW.js → chunk-HZP4DXIZ.js} +1 -0
- package/dist/clients/{chunk-F6P4CN27.js → chunk-JD2J5K6S.js} +16 -8
- package/dist/clients/chunk-LT4EWLDA.js +30 -0
- package/dist/clients/chunk-MGQLVTSH.js +100 -0
- package/dist/clients/{chunk-FJ6GCMJ4.js → chunk-OODIKHYE.js} +3 -1
- package/dist/clients/chunk-SFDEST63.js +18 -0
- package/dist/clients/{chunk-OZ3KD24N.js → chunk-ZCCLJW6F.js} +0 -8
- package/dist/clients/fanatics.js +5 -6
- package/dist/clients/internal/nado/encoding.js +4 -25
- package/dist/clients/internal/nado/gateway.d.ts +0 -21
- package/dist/clients/internal/nado/gateway.js +1 -5
- package/dist/clients/internal/nado/hooks.d.ts +0 -158
- package/dist/clients/internal/nado/hooks.js +10 -121
- package/dist/clients/internal/nado/withdrawalConfig.js +3 -12
- package/dist/clients/internal/nado/withdrawalForm.css +17529 -0
- package/dist/clients/internal/nado/withdrawalForm.d.ts +41 -0
- package/dist/clients/internal/nado/withdrawalForm.js +283 -0
- package/dist/clients/internal/nado/withdrawalTypes.d.ts +7 -2
- package/dist/clients/lighter.css +5 -1
- package/dist/clients/lighter.d.ts +29 -1
- package/dist/clients/lighter.js +105 -100
- package/dist/clients/mallard.js +24 -3
- package/dist/clients/polymarket/PolymarketDepositAccountDropdown.css +5 -1
- package/dist/clients/polymarket/PolymarketDepositAccountDropdown.js +6 -3
- package/dist/clients/polymarket/index.css +5 -1
- package/dist/clients/polymarket/index.js +6 -3
- package/dist/components/BottomLinks/BottomLinks.d.ts +3 -1
- package/dist/consts/meld.d.ts +1 -1
- package/dist/domains/swapped.d.ts +1 -10
- package/dist/hooks/queries/useSwappedDefaultCurrency.d.ts +3 -3
- package/dist/hooks/queries/useWithdrawFops.d.ts +0 -1
- package/dist/hooks/track/useTrack.d.ts +1 -0
- package/dist/hooks/useTokenAndChainDropdown.d.ts +8 -1
- package/dist/index.css +5 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2325 -1552
- package/dist/modals/CheckoutModal/ConfirmationStep/CheckoutPrimaryInfo.d.ts +1 -2
- package/dist/modals/CheckoutModal/InputAmount/useCheckoutAmountLimits.d.ts +6 -9
- package/dist/modals/WithdrawalModal/LighterWithdrawal.d.ts +54 -48
- package/dist/modals/WithdrawalModal/WithdrawAmountInput.d.ts +5 -9
- package/dist/modals/WithdrawalModal/WithdrawalContent.d.ts +1 -61
- package/dist/modals/WithdrawalModal/withdrawalFormHelpers.d.ts +53 -0
- package/dist/modals/WithdrawalModal/withdrawalHooks.d.ts +38 -0
- package/dist/providers/FunkitCheckoutContext/types.d.ts +61 -4
- package/dist/providers/FunkitConfigContext.d.ts +2 -2
- package/dist/utils/consts.d.ts +1 -1
- package/dist/utils/customer.d.ts +367 -3
- package/dist/utils/withdrawal.d.ts +19 -6
- package/dist/wagmi/actions.d.ts +1 -1
- package/dist/wallets/Wallet.d.ts +21 -1
- package/dist/wallets/walletConnectors/bifrostWallet/bifrostWallet.js +2 -2
- package/dist/wallets/walletConnectors/bitgetWallet/bitgetWallet.js +2 -2
- package/dist/wallets/walletConnectors/bybitWallet/bybitWallet.js +2 -2
- package/dist/wallets/walletConnectors/clvWallet/clvWallet.js +2 -2
- package/dist/wallets/walletConnectors/coin98Wallet/coin98Wallet.js +2 -2
- package/dist/wallets/walletConnectors/coreWallet/coreWallet.js +2 -2
- package/dist/wallets/walletConnectors/foxWallet/foxWallet.js +2 -2
- package/dist/wallets/walletConnectors/frontierWallet/frontierWallet.js +2 -2
- package/dist/wallets/walletConnectors/gateWallet/gateWallet.js +2 -2
- package/dist/wallets/walletConnectors/index.js +34 -34
- package/dist/wallets/walletConnectors/metaMaskWallet/metaMaskWallet.js +2 -2
- package/dist/wallets/walletConnectors/okxWallet/okxWallet.js +2 -2
- package/dist/wallets/walletConnectors/rainbowWallet/rainbowWallet.js +2 -2
- package/dist/wallets/walletConnectors/roninWallet/roninWallet.js +2 -2
- package/dist/wallets/walletConnectors/safepalWallet/safepalWallet.js +2 -2
- package/dist/wallets/walletConnectors/subWallet/subWallet.js +2 -2
- package/dist/wallets/walletConnectors/tokenPocketWallet/tokenPocketWallet.js +2 -2
- package/dist/wallets/walletConnectors/trustWallet/trustWallet.js +2 -2
- package/dist/wallets/walletConnectors/zerionWallet/zerionWallet.js +2 -2
- package/package.json +3 -3
- package/dist/clients/chunk-A4WQS6QG.js +0 -207
- package/dist/clients/internal/nado/products.d.ts +0 -36
- package/dist/clients/internal/nado/products.js +0 -19
- package/dist/wallets/walletConnectors/{chunk-RB3HR4R2.js → chunk-4NV5BYRP.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-YEZM4CK4.js → chunk-AVDUNQUW.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-MIQTHJ6X.js → chunk-GUQM4QSL.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-4T6ZSRJF.js → chunk-IULPZP2Q.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-HNRB7KJU.js → chunk-JPN6TWIT.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-ZNX4EMPB.js → chunk-KCRO2AGO.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-STVVP43G.js → chunk-KI5Y2BBF.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-X6CGV36L.js → chunk-NR2OGDHQ.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-UK7C2JXW.js → chunk-OEEGYENV.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-F5XEEVG6.js → chunk-OX37G4YT.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-RVOY537T.js → chunk-SWFF3TWJ.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-CPI4TD43.js → chunk-TKB2OY6G.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-2VP2F6EK.js → chunk-W2LCLDPX.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-6BW3HLBG.js → chunk-WAHGI5L7.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-HTHAK6XB.js → chunk-WKNQMP4A.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-VTM6EECM.js → chunk-XCNHV3HS.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-CCQV2ZET.js → chunk-YO2K4MBH.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-VAPGUPHO.js → chunk-YQFGVZGR.js} +3 -3
|
@@ -3,7 +3,6 @@ import type { QuoteDisplayAmounts } from '../../../domains/quoteMode';
|
|
|
3
3
|
import type { FunkitCheckoutConfig } from '../../../providers/FunkitCheckoutContext';
|
|
4
4
|
interface CheckoutPrimaryInfoProps {
|
|
5
5
|
showLeftAlignedDollarValueWithLabel: boolean;
|
|
6
|
-
showTokenAmount: boolean;
|
|
7
6
|
config: FunkitCheckoutConfig;
|
|
8
7
|
usdAmount?: number;
|
|
9
8
|
isLoading?: boolean;
|
|
@@ -12,5 +11,5 @@ interface CheckoutPrimaryInfoProps {
|
|
|
12
11
|
/** In EXACT_IN mode, the fiat value the user entered on InputAmount (avoids skeleton flash) */
|
|
13
12
|
inputFiatAmount?: number | null;
|
|
14
13
|
}
|
|
15
|
-
export declare function CheckoutPrimaryInfo({ showLeftAlignedDollarValueWithLabel,
|
|
14
|
+
export declare function CheckoutPrimaryInfo({ showLeftAlignedDollarValueWithLabel, usdAmount, config, isLoading, displayAmounts, inputFiatAmount, }: CheckoutPrimaryInfoProps): React.JSX.Element;
|
|
16
15
|
export {};
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type CheckoutAmountLimitsUsd } from '@funkit/connect-core';
|
|
2
|
+
import type { PaymentMethod } from '../../../domains/paymentMethods';
|
|
2
3
|
import type { FunkitCheckoutConfig } from '../../../providers/FunkitCheckoutContext';
|
|
3
|
-
export
|
|
4
|
-
minUsd: number | undefined;
|
|
5
|
-
maxUsd: number;
|
|
6
|
-
}
|
|
4
|
+
export type { CheckoutAmountLimitsUsd };
|
|
7
5
|
/**
|
|
8
6
|
* Resolves the min/max USD bounds for the amount input based on the active
|
|
9
|
-
* payment method
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* max-checkout dynamic config.
|
|
7
|
+
* payment method. Fetches the inputs (min-transfer floor, brokerage limits,
|
|
8
|
+
* global max) and delegates the per-method rules to
|
|
9
|
+
* `getCheckoutAmountLimitsUsd` in `@funkit/connect-core`.
|
|
13
10
|
*/
|
|
14
11
|
export declare const useCheckoutAmountLimits: ({ checkoutConfig, paymentMethod, }: {
|
|
15
12
|
checkoutConfig: FunkitCheckoutConfig;
|
|
@@ -7,9 +7,8 @@ import { type LighterAccountIndex } from '@funkit/api-base';
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import { type Address, type Hex } from 'viem';
|
|
9
9
|
import { type CheckoutConfirmationError } from '../../domains/checkoutErrors';
|
|
10
|
-
import type { CustomWithdrawalConfig, LighterRouteType, WalletWithdrawalConfig } from '../../providers/FunkitCheckoutContext';
|
|
11
|
-
import type { LighterShare } from '../../utils/customer';
|
|
12
|
-
import type { SourceTokenOption } from './WithdrawAmountInput';
|
|
10
|
+
import type { CustomWithdrawalConfig, LighterRouteType, TokenInfo, WalletWithdrawalConfig } from '../../providers/FunkitCheckoutContext';
|
|
11
|
+
import type { LighterAsset, LighterPoolInfo, LighterShare } from '../../utils/customer';
|
|
13
12
|
/** Stable method ids for the Fast / Secure options (used for tracking + switching). */
|
|
14
13
|
export declare const LIGHTER_FAST_METHOD_ID = "lighter-fast";
|
|
15
14
|
export declare const LIGHTER_SECURE_METHOD_ID = "lighter-secure";
|
|
@@ -39,6 +38,21 @@ export declare function getLighterBaseSymbol(symbol: string): string;
|
|
|
39
38
|
* including the `USDC (Spot)` pseudo-symbol — is a spot asset (route 1).
|
|
40
39
|
*/
|
|
41
40
|
export declare function resolveLighterSecureRouteType(selectedSourceToken: string): LighterRouteType;
|
|
41
|
+
/**
|
|
42
|
+
* The selected source token as identified on Lighter's own L2, rather than by
|
|
43
|
+
* its mainnet bridge address — two Secure selections can share one mainnet
|
|
44
|
+
* address (USDC perps and USDC spot both bridge mainnet USDC), so the bridge
|
|
45
|
+
* address can't name which balance is meant.
|
|
46
|
+
*
|
|
47
|
+
* Follows `RELAY_LIGHTER_FUN_ADDRESS_MAP`: the asset index left-padded into an
|
|
48
|
+
* address (`0x…01` = ETH spot, `0x…03` = USDC spot). `undefined` when the index
|
|
49
|
+
* hasn't resolved yet, so callers keep their existing value rather than pointing
|
|
50
|
+
* at asset 0.
|
|
51
|
+
*/
|
|
52
|
+
export declare function resolveLighterSourceAsset({ assetIndex, routeType, }: {
|
|
53
|
+
assetIndex: number | undefined;
|
|
54
|
+
routeType: LighterRouteType;
|
|
55
|
+
}): TokenInfo | undefined;
|
|
42
56
|
/**
|
|
43
57
|
* Mainnet ERC-20 address for a Lighter Secure source token symbol, or undefined
|
|
44
58
|
* if the symbol isn't a known Secure asset.
|
|
@@ -59,46 +73,60 @@ export declare const LIGHTER_FAST_MAX_WITHDRAWAL_USD = 3000000;
|
|
|
59
73
|
export declare function LighterFastMaxExceededMessage({ onSwitchToSecure, }: {
|
|
60
74
|
onSwitchToSecure: () => void;
|
|
61
75
|
}): React.JSX.Element;
|
|
62
|
-
/** Free (withdrawable) balance for a single Lighter asset: balance - locked. */
|
|
63
|
-
export declare function freeBalance(balance: string, lockedBalance: string): string;
|
|
64
76
|
/**
|
|
65
77
|
* Lighter Fast charges an "unstaked" fee — a flat deduction taken off the
|
|
66
78
|
* withdrawal amount before quoting — for users who aren't sufficiently staked
|
|
67
79
|
* in Lighter's staking pool. Sufficiently-staked users pay nothing.
|
|
68
80
|
*
|
|
69
|
-
* "Sufficiently staked" = the
|
|
70
|
-
*
|
|
71
|
-
* hardcoded here (previously read from
|
|
72
|
-
* it's currently the only public pool
|
|
73
|
-
* Non-stakers report `shares: []`.
|
|
81
|
+
* "Sufficiently staked" = the *current* LIT value of the user's staking-pool
|
|
82
|
+
* share is at or above the threshold. The pool is LIT-denominated and
|
|
83
|
+
* identified by its index, hardcoded here (previously read from
|
|
84
|
+
* `systemConfig.staking_pool_index`) since it's currently the only public pool
|
|
85
|
+
* a withdrawing user holds a share in. Non-stakers report `shares: []`.
|
|
74
86
|
*/
|
|
75
87
|
export declare const LIGHTER_STAKING_POOL_INDEX = 281474976624800;
|
|
76
88
|
export declare const LIGHTER_UNSTAKED_FEE_TOKENS = 3;
|
|
77
|
-
export declare const
|
|
89
|
+
export declare const LIGHTER_STAKING_THRESHOLD_LIT = 100;
|
|
90
|
+
/**
|
|
91
|
+
* LIT per share unit for the staking pool: its LIT balance over total shares.
|
|
92
|
+
*
|
|
93
|
+
* `undefined` when the pool account is unavailable or reports no shares — the
|
|
94
|
+
* fee gate then degrades to the entry principal rather than guessing.
|
|
95
|
+
*/
|
|
96
|
+
export declare function resolveLighterSharePrice(poolAccount: {
|
|
97
|
+
assets?: LighterAsset[];
|
|
98
|
+
pool_info?: LighterPoolInfo;
|
|
99
|
+
} | undefined): number | undefined;
|
|
78
100
|
/**
|
|
79
101
|
* Resolves the Lighter Fast unstaked fee (in source tokens, i.e. USDC) for a
|
|
80
|
-
* user.
|
|
81
|
-
*
|
|
82
|
-
*
|
|
102
|
+
* user. A non-staker (`shares: []`, or no staking-pool share) pays the fee.
|
|
103
|
+
*
|
|
104
|
+
* Gated on the share's *current* LIT value (`shares_amount × sharePrice` — the
|
|
105
|
+
* "Your Stake" figure in Lighter's UI), not `principal_amount`, which is the
|
|
106
|
+
* entry deposit and never grows with accrued yield. Gating on the principal
|
|
107
|
+
* charged stakers whose position had appreciated past the minimum from below.
|
|
108
|
+
*
|
|
109
|
+
* Falls back to the principal when `sharePrice` is unavailable — never worse
|
|
110
|
+
* than the previous behaviour, and avoids waiving the fee for everyone when
|
|
111
|
+
* the pool account fails to load.
|
|
83
112
|
*/
|
|
84
|
-
export declare function resolveLighterUnstakedFeeTokens(shares: LighterShare[]): number;
|
|
113
|
+
export declare function resolveLighterUnstakedFeeTokens(shares: LighterShare[], sharePrice?: number): number;
|
|
85
114
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
115
|
+
* Share price for the staking pool, read off the pool's own account. Kept a
|
|
116
|
+
* separate query from the user's account: a user's `shares[]` carries entry
|
|
117
|
+
* state only, so current value is unobtainable without the pool's NAV.
|
|
89
118
|
*/
|
|
90
|
-
export declare function
|
|
119
|
+
export declare function useLighterStakingSharePrice(enabled: boolean): number | undefined;
|
|
91
120
|
/**
|
|
92
|
-
* Fetches
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
121
|
+
* Fetches the Lighter account for the data the SDK still derives itself:
|
|
122
|
+
* `shares` for the unstaked-fee gate, and `assets` to resolve the L2 asset index
|
|
123
|
+
* of a Secure selection. Withdrawable balances are the integrator's to supply
|
|
124
|
+
* (`withdrawalSourceTokenBalance`), so nothing here computes them.
|
|
96
125
|
*/
|
|
97
126
|
export declare function useLighterWithdrawalBalances({ accountIndex, }: {
|
|
98
127
|
accountIndex: LighterAccountIndex | undefined;
|
|
99
128
|
}): {
|
|
100
|
-
|
|
101
|
-
assets: import("../../utils/customer").LighterAsset[];
|
|
129
|
+
assets: LighterAsset[];
|
|
102
130
|
shares: LighterShare[];
|
|
103
131
|
isLoading: boolean;
|
|
104
132
|
};
|
|
@@ -114,20 +142,6 @@ export declare function resolveLighterAssetIndex(lighterAssets: {
|
|
|
114
142
|
symbol: string;
|
|
115
143
|
asset_id: number;
|
|
116
144
|
}[], selectedSourceToken: string): number | undefined;
|
|
117
|
-
/**
|
|
118
|
-
* Builds the source-token options list for the Lighter compound input dropdown.
|
|
119
|
-
*
|
|
120
|
-
* - Fast path: only USDC (Perps).
|
|
121
|
-
* - Secure path: USDC (Perps) (from total_asset_value) + USDC (Spot) when the
|
|
122
|
-
* account carries a spot USDC asset + every non-USDC asset on the account.
|
|
123
|
-
*
|
|
124
|
-
* Unified Trading accounts (`isUnifiedTradingMode`) have a single USDC balance
|
|
125
|
-
* — no spot/perps split — so the perps entry is labeled plain `USDC` and the
|
|
126
|
-
* `USDC (Spot)` entry is hidden on both paths.
|
|
127
|
-
*/
|
|
128
|
-
export declare function buildLighterSourceTokenOptions(config: FunkitWithdrawalConfig, lighterAssets: {
|
|
129
|
-
symbol: string;
|
|
130
|
-
}[], isUnifiedTradingMode?: boolean): SourceTokenOption[];
|
|
131
145
|
/**
|
|
132
146
|
* Detects Lighter Secure withdrawal (mainnet source chain), auto-fills the
|
|
133
147
|
* recipient address with the connected wallet, and fetches the Lighter account
|
|
@@ -138,8 +152,7 @@ export declare function useLighterWithdrawal(config: FunkitWithdrawalConfig, set
|
|
|
138
152
|
isLighterFast: boolean;
|
|
139
153
|
isUnifiedTradingMode: boolean;
|
|
140
154
|
connectedAddress: `0x${string}` | undefined;
|
|
141
|
-
|
|
142
|
-
lighterAssets: import("../../utils/customer").LighterAsset[];
|
|
155
|
+
lighterAssets: LighterAsset[];
|
|
143
156
|
lighterFastUnstakedFee: number;
|
|
144
157
|
invalidateLighterAccount: () => void;
|
|
145
158
|
};
|
|
@@ -179,13 +192,6 @@ export declare function useLighterL1Fallback({ isLighterSecure, withdrawalError,
|
|
|
179
192
|
isSubmittingL1: boolean;
|
|
180
193
|
l1FallbackError: CheckoutConfirmationError | null;
|
|
181
194
|
};
|
|
182
|
-
/**
|
|
183
|
-
* Resolves the source-token dropdown options for a Lighter customer.
|
|
184
|
-
* Returns `undefined` for non-Lighter customers (no dropdown needed).
|
|
185
|
-
*/
|
|
186
|
-
export declare function useLighterSourceTokenOptions(config: FunkitWithdrawalConfig, apiKey: string, lighterAssets: {
|
|
187
|
-
symbol: string;
|
|
188
|
-
}[], isUnifiedTradingMode?: boolean): SourceTokenOption[] | undefined;
|
|
189
195
|
/**
|
|
190
196
|
* Lighter Secure: recipient address, locked to the connected wallet. A
|
|
191
197
|
* read-only `FunInput` (not a `<div>`) keeps it focusable and announced by
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { FunkitWithdrawalConfig, MultiMethodWithdrawalConfig } from '../../providers/FunkitCheckoutContext';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/** Display label (may differ from symbol, e.g. "USDC (Perps)") */
|
|
6
|
-
label: string;
|
|
7
|
-
iconSrc?: string;
|
|
8
|
-
}
|
|
3
|
+
import type { SourceTokenOption } from '../../providers/FunkitCheckoutContext';
|
|
4
|
+
export type { SourceTokenOption };
|
|
9
5
|
export declare function WithdrawAmountInput({ withdrawalInputAmount, setWithdrawalInputAmount, sourceTokenBalance, isWithdrawAmountTooLow, isWithdrawAmountTooHigh, isWithdrawAmountAboveBalance, isWithdrawAmountValid, minWithdrawalDisplayValue, config, sourceTokenOptions, onSourceTokenChange, selectedSourceToken, sourceTokenUsdPrice, }: {
|
|
10
6
|
config: Exclude<FunkitWithdrawalConfig, MultiMethodWithdrawalConfig>;
|
|
11
7
|
sourceTokenBalance: string;
|
|
@@ -24,9 +20,9 @@ export declare function WithdrawAmountInput({ withdrawalInputAmount, setWithdraw
|
|
|
24
20
|
isWithdrawAmountAboveBalance: boolean;
|
|
25
21
|
isWithdrawAmountValid: boolean;
|
|
26
22
|
/**
|
|
27
|
-
* Minimum-withdrawal value
|
|
28
|
-
* config provides `getMinWithdrawalAmount
|
|
29
|
-
*
|
|
23
|
+
* Minimum-withdrawal value for display. Carries no unit of its own — token
|
|
24
|
+
* units when the config provides `getMinWithdrawalAmount`, USD otherwise — so
|
|
25
|
+
* the component re-derives which one it got (see `isMinInTokenUnits`).
|
|
30
26
|
*/
|
|
31
27
|
minWithdrawalDisplayValue: number;
|
|
32
28
|
sourceTokenOptions?: SourceTokenOption[];
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { TFunction } from 'i18next';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import type { Hex } from 'viem';
|
|
4
3
|
import { type ModalBottomBarIdType } from '../../components/Dialog/Dialog';
|
|
5
|
-
import type { CustomWithdrawalConfig, FunkitActiveWithdrawalItem,
|
|
4
|
+
import type { CustomWithdrawalConfig, FunkitActiveWithdrawalItem, WalletWithdrawalConfig } from '../../providers/FunkitCheckoutContext';
|
|
6
5
|
import { type WithdrawalFormData } from './useWithdrawal';
|
|
7
6
|
/**
|
|
8
7
|
* WithdrawalContent only operates on concrete single-method withdrawal configs.
|
|
@@ -32,64 +31,5 @@ interface WithdrawContentProps {
|
|
|
32
31
|
*/
|
|
33
32
|
disableSubmit?: boolean;
|
|
34
33
|
}
|
|
35
|
-
/**
|
|
36
|
-
* Converts a source-token amount string to its USD value using the given unit
|
|
37
|
-
* price. Returns `undefined` when the price is not yet loaded so callers can
|
|
38
|
-
* differentiate "still loading" from "actually $0".
|
|
39
|
-
*
|
|
40
|
-
* Exported for testing.
|
|
41
|
-
*/
|
|
42
|
-
export declare function toUsdValue(sourceAmount: string, sourceTokenUsdPrice: number | undefined): number | undefined;
|
|
43
|
-
export declare function getWithdrawButtonText({ isWithdrawing, isValidAddress, isRecipientBlacklisted, isRecipientSameAsSource, withdrawalInputAmount, isWithdrawAmountValid, isWithdrawAmountTooHigh, isValidAddressAndChain, selectedToken, selectedChainId, selectedChainName, t, }: {
|
|
44
|
-
isWithdrawing: boolean;
|
|
45
|
-
isValidAddress: boolean;
|
|
46
|
-
isRecipientBlacklisted: boolean;
|
|
47
|
-
isRecipientSameAsSource: boolean;
|
|
48
|
-
withdrawalInputAmount: string;
|
|
49
|
-
isWithdrawAmountValid: boolean;
|
|
50
|
-
isWithdrawAmountTooHigh: boolean;
|
|
51
|
-
isValidAddressAndChain: boolean;
|
|
52
|
-
selectedToken: string | undefined;
|
|
53
|
-
selectedChainId: number | undefined;
|
|
54
|
-
selectedChainName: string | undefined;
|
|
55
|
-
t: TFunction;
|
|
56
|
-
}): string;
|
|
57
|
-
export declare function isValidWithdrawal({ config, checkoutConfig, withdrawalInputAmount, sourceTokenUsdPrice, recipientAddress, selectedChainId, sourceTokenBalance, selectedSourceToken, }: {
|
|
58
|
-
config: FunkitWithdrawalConfig;
|
|
59
|
-
checkoutConfig: FunkitCheckoutConfig | undefined;
|
|
60
|
-
/** User-entered amount in source-token units (e.g. "0.5" for 0.5 ETH). */
|
|
61
|
-
withdrawalInputAmount: string;
|
|
62
|
-
/**
|
|
63
|
-
* USD price per unit of the source token. Hardcoded to 1 for stablecoin
|
|
64
|
-
* sources; only Lighter Secure resolves a live spot price, and that path
|
|
65
|
-
* uses `getMinWithdrawalAmount` (per-token) which takes priority over the
|
|
66
|
-
* USD-min branch — so this field is only meaningfully consumed when it's 1.
|
|
67
|
-
*/
|
|
68
|
-
sourceTokenUsdPrice: number;
|
|
69
|
-
sourceTokenBalance: string;
|
|
70
|
-
recipientAddress: string;
|
|
71
|
-
selectedChainId: number | undefined;
|
|
72
|
-
selectedSourceToken: string | undefined;
|
|
73
|
-
}): {
|
|
74
|
-
isValidAddress: boolean;
|
|
75
|
-
isValidAddressAndChain: boolean;
|
|
76
|
-
isWithdrawAmountTooLow: boolean;
|
|
77
|
-
isWithdrawAmountTooHigh: boolean;
|
|
78
|
-
isWithdrawAmountAboveBalance: boolean;
|
|
79
|
-
isWithdrawAmountValid: boolean;
|
|
80
|
-
minWithdrawalDisplayValue: number;
|
|
81
|
-
};
|
|
82
|
-
export declare const useFrozenSourceTokenBalance: ({ isWithdrawing, sourceTokenBalance, }: {
|
|
83
|
-
isWithdrawing: boolean;
|
|
84
|
-
sourceTokenBalance: string;
|
|
85
|
-
}) => {
|
|
86
|
-
displayedSourceTokenBalance: string;
|
|
87
|
-
freezeDisplayedSourceTokenBalance(sourceTokenBalance: string): void;
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* Builds the source-token options list for the Lighter compound input dropdown.
|
|
91
|
-
* Currently returns a single option per config; expands when Lighter exposes
|
|
92
|
-
* multi-asset API support.
|
|
93
|
-
*/
|
|
94
34
|
export declare const WithdrawContent: ({ onContinue, config, withdrawalItem, onSwitchToSecure, bottomBarId, disableSubmit, }: WithdrawContentProps) => React.JSX.Element;
|
|
95
35
|
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { TFunction } from 'i18next';
|
|
2
|
+
import type { FunkitCheckoutQuoteResult } from '../../domains/quote';
|
|
3
|
+
import type { CustomWithdrawalConfig, FunkitCheckoutConfig, WalletWithdrawalConfig } from '../../providers/FunkitCheckoutContext';
|
|
4
|
+
type FunkitWithdrawalConfig = WalletWithdrawalConfig | CustomWithdrawalConfig;
|
|
5
|
+
export declare function getWithdrawButtonText({ isWithdrawing, isValidAddress, isRecipientBlacklisted, isRecipientSameAsSource, withdrawalInputAmount, isWithdrawAmountValid, isWithdrawAmountTooHigh, isValidAddressAndChain, selectedToken, selectedChainId, selectedChainName, t, }: {
|
|
6
|
+
isWithdrawing: boolean;
|
|
7
|
+
isValidAddress: boolean;
|
|
8
|
+
isRecipientBlacklisted: boolean;
|
|
9
|
+
isRecipientSameAsSource: boolean;
|
|
10
|
+
withdrawalInputAmount: string;
|
|
11
|
+
isWithdrawAmountValid: boolean;
|
|
12
|
+
isWithdrawAmountTooHigh: boolean;
|
|
13
|
+
isValidAddressAndChain: boolean;
|
|
14
|
+
selectedToken: string | undefined;
|
|
15
|
+
selectedChainId: number | undefined;
|
|
16
|
+
selectedChainName: string | undefined;
|
|
17
|
+
t: TFunction;
|
|
18
|
+
}): string;
|
|
19
|
+
export declare function isValidWithdrawal({ config, checkoutConfig, withdrawalInputAmount, sourceTokenUsdPrice, recipientAddress, selectedChainId, sourceTokenBalance, selectedSourceToken, }: {
|
|
20
|
+
config: FunkitWithdrawalConfig;
|
|
21
|
+
checkoutConfig: FunkitCheckoutConfig | undefined;
|
|
22
|
+
/** User-entered amount in source-token units (e.g. "0.5" for 0.5 ETH). */
|
|
23
|
+
withdrawalInputAmount: string;
|
|
24
|
+
/**
|
|
25
|
+
* USD price per unit of the source token. Hardcoded to 1 for stablecoin
|
|
26
|
+
* sources; only Lighter Secure resolves a live spot price, and that path
|
|
27
|
+
* uses `getMinWithdrawalAmount` (per-token) which takes priority over the
|
|
28
|
+
* USD-min branch — so this field is only meaningfully consumed when it's 1.
|
|
29
|
+
*/
|
|
30
|
+
sourceTokenUsdPrice: number;
|
|
31
|
+
sourceTokenBalance: string;
|
|
32
|
+
recipientAddress: string;
|
|
33
|
+
selectedChainId: number | undefined;
|
|
34
|
+
selectedSourceToken: string | undefined;
|
|
35
|
+
}): {
|
|
36
|
+
isWithdrawAmountTooLow: boolean;
|
|
37
|
+
isWithdrawAmountTooHigh: boolean;
|
|
38
|
+
isWithdrawAmountAboveBalance: boolean;
|
|
39
|
+
isWithdrawAmountValid: boolean;
|
|
40
|
+
minWithdrawalDisplayValue: number;
|
|
41
|
+
isValidAddress: boolean;
|
|
42
|
+
isValidAddressAndChain: boolean;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Converts a source-token amount string to its USD value using the given unit
|
|
46
|
+
* price. Returns `undefined` when the price is not yet loaded so callers can
|
|
47
|
+
* differentiate "still loading" from "actually $0".
|
|
48
|
+
*
|
|
49
|
+
* Exported for testing.
|
|
50
|
+
*/
|
|
51
|
+
export declare function toUsdValue(sourceAmount: string, sourceTokenUsdPrice: number | undefined): number | undefined;
|
|
52
|
+
export declare function getRelayOutputCurrencyAmount(quote: FunkitCheckoutQuoteResult, fallback: number | undefined): number;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { CustomWithdrawalConfig, WalletWithdrawalConfig } from '../../providers/FunkitCheckoutContext';
|
|
2
|
+
type FunkitWithdrawalConfig = WalletWithdrawalConfig | CustomWithdrawalConfig;
|
|
3
|
+
export declare function useWithdrawalAssets(config: FunkitWithdrawalConfig): {
|
|
4
|
+
assets: import("../CheckoutModal/TransferToken/TransferToken").TokenTransferSourceChainsAndAssets;
|
|
5
|
+
selectedChainId: number | undefined;
|
|
6
|
+
handleChainChange: (chainId?: number, autoUpdate?: boolean) => void;
|
|
7
|
+
selectedToken: string | undefined;
|
|
8
|
+
selectedChainName: string | undefined;
|
|
9
|
+
handleTokenChange: (token: string, chainId?: number, autoUpdate?: boolean) => void;
|
|
10
|
+
chainIdSortOrder: number[];
|
|
11
|
+
popularTokenSymbols: string[];
|
|
12
|
+
priorityTokenSymbols: string[];
|
|
13
|
+
isLoadingAssets: boolean;
|
|
14
|
+
addressBySymbolByChainId: Record<number, Record<string, string>>;
|
|
15
|
+
};
|
|
16
|
+
export declare const useFrozenSourceTokenBalance: ({ isWithdrawing, sourceTokenBalance, }: {
|
|
17
|
+
isWithdrawing: boolean;
|
|
18
|
+
sourceTokenBalance: string;
|
|
19
|
+
}) => {
|
|
20
|
+
displayedSourceTokenBalance: string;
|
|
21
|
+
freezeDisplayedSourceTokenBalance(sourceTokenBalance: string): void;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* The withdrawal form's warning logs. Effect bodies and dependency arrays are
|
|
25
|
+
* unchanged from WithdrawalContent; the refs that dedupe them move along too.
|
|
26
|
+
*/
|
|
27
|
+
export declare function useWithdrawalLogging({ targetAssetFetchError, quoteErrorObject, isRisky, isRecipientBlacklisted, selectedChainId, selectedToken, recipientAddress, debouncedInputAmount, debouncedInputAmountUsd, }: {
|
|
28
|
+
targetAssetFetchError: unknown;
|
|
29
|
+
quoteErrorObject: unknown;
|
|
30
|
+
isRisky: boolean | undefined;
|
|
31
|
+
isRecipientBlacklisted: boolean;
|
|
32
|
+
selectedChainId: number | undefined;
|
|
33
|
+
selectedToken: string | undefined;
|
|
34
|
+
recipientAddress: string;
|
|
35
|
+
debouncedInputAmount: string;
|
|
36
|
+
debouncedInputAmountUsd: number | undefined;
|
|
37
|
+
}): void;
|
|
38
|
+
export {};
|
|
@@ -136,7 +136,7 @@ export interface FunkitCheckoutConfig extends Omit<ApiFunkitCheckoutConfig, 'gen
|
|
|
136
136
|
/** Title of the item being checked out. e.g. Staked Ether, XYZ Option, Solar Bond ABC **/
|
|
137
137
|
checkoutItemTitle: string;
|
|
138
138
|
/** amount of source token. it is not baseUnit **/
|
|
139
|
-
withdrawalSourceTokenBalance?: () => string | number;
|
|
139
|
+
withdrawalSourceTokenBalance?: (params: WithdrawalSourceTokenBalanceParams) => string | number;
|
|
140
140
|
/** @deprecated isDefiMode has been removed. This field is ignored. */
|
|
141
141
|
isDefiMode?: boolean;
|
|
142
142
|
/** The step at which the checkout process should start */
|
|
@@ -187,6 +187,31 @@ export interface FunkitCheckoutConfig extends Omit<ApiFunkitCheckoutConfig, 'gen
|
|
|
187
187
|
*/
|
|
188
188
|
addToWalletToken?: AddToWalletToken;
|
|
189
189
|
}
|
|
190
|
+
/** One entry in the withdrawal source-token dropdown. */
|
|
191
|
+
export interface SourceTokenOption {
|
|
192
|
+
/** Selection key. May be a pseudo-symbol where one token has variants. */
|
|
193
|
+
symbol: string;
|
|
194
|
+
/** Display label (may differ from symbol, e.g. "USDC (Perps)") */
|
|
195
|
+
label: string;
|
|
196
|
+
iconSrc?: string;
|
|
197
|
+
/**
|
|
198
|
+
* This option's own asset identity, passed to
|
|
199
|
+
* {@link WithdrawalConfigBase.withdrawalSourceTokenBalance} when selected.
|
|
200
|
+
* Omit only when every option shares the config's source token — otherwise the
|
|
201
|
+
* balance is requested for the wrong asset. `decimals` is required by flows
|
|
202
|
+
* that scale a signed amount from this option.
|
|
203
|
+
*/
|
|
204
|
+
asset?: TokenInfo & {
|
|
205
|
+
decimals?: number;
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* Flow-specific identity for this option, forwarded to
|
|
209
|
+
* {@link WithdrawalConfigBase.withdrawalSourceTokenBalance} when selected.
|
|
210
|
+
* Carries the venue's own key for the asset where {@link asset} can't express
|
|
211
|
+
* it — Nado addresses balances by product id, not by token address.
|
|
212
|
+
*/
|
|
213
|
+
customData?: WithdrawalSourceCustomData;
|
|
214
|
+
}
|
|
190
215
|
export interface WithdrawalConfigBase {
|
|
191
216
|
/** Title to show in the checkout modal. Defaults to "Checkout" **/
|
|
192
217
|
modalTitle: string;
|
|
@@ -195,6 +220,12 @@ export interface WithdrawalConfigBase {
|
|
|
195
220
|
/** Icon to show in the checkout modal (50px x 50px). If not specified, no icon will be shown. **/
|
|
196
221
|
iconSrc?: null | string;
|
|
197
222
|
sourceTokenSymbol: string;
|
|
223
|
+
/**
|
|
224
|
+
* Selectable source tokens, when the flow has more than one. Omit for
|
|
225
|
+
* single-source flows — {@link sourceTokenSymbol} is then the only option.
|
|
226
|
+
* {@link withdrawalSourceTokenBalance} is called with whichever is selected.
|
|
227
|
+
*/
|
|
228
|
+
sourceTokens?: SourceTokenOption[];
|
|
198
229
|
/** source chain id to withdraw **/
|
|
199
230
|
sourceChainId: string;
|
|
200
231
|
/** source token id to withdraw **/
|
|
@@ -217,11 +248,13 @@ export interface WithdrawalConfigBase {
|
|
|
217
248
|
*/
|
|
218
249
|
getMaxWithdrawalUSD?: (asset: TokenInfo) => number;
|
|
219
250
|
/**
|
|
220
|
-
* Returns the current withdrawable balance for
|
|
251
|
+
* Returns the current withdrawable balance for `sourceAsset`. Takes precedence
|
|
252
|
+
* over any balance the SDK derives itself, so it must account for whatever the
|
|
253
|
+
* SDK cannot see (margin requirements, locked collateral).
|
|
221
254
|
* Called on every render — use a ref-backed stable callback so the value
|
|
222
255
|
* stays live without triggering unnecessary re-renders.
|
|
223
256
|
*/
|
|
224
|
-
withdrawalSourceTokenBalance?: () => string | number;
|
|
257
|
+
withdrawalSourceTokenBalance?: (params: WithdrawalSourceTokenBalanceParams) => string | number;
|
|
225
258
|
/**
|
|
226
259
|
* Optional async hook fired when the user commits to the withdrawal — after
|
|
227
260
|
* the withdraw CTA, but before any nonce fetch, wallet signature, or tx
|
|
@@ -312,6 +345,28 @@ export type WithdrawalCustomerData = LighterWithdrawalCustomerData | NadoWithdra
|
|
|
312
345
|
*/
|
|
313
346
|
export type WithdrawalCustomerConfig = NadoWithdrawalCustomerConfig;
|
|
314
347
|
export type { NadoWithdrawalCustomerConfig, NadoWithdrawalCustomerData };
|
|
348
|
+
/**
|
|
349
|
+
* Flow-specific descriptor for the selected source token, discriminated by
|
|
350
|
+
* `type`. Needed where {@link TokenInfo} alone can't name the balance:
|
|
351
|
+
* - Lighter exposes USDC twice, as perps collateral and as a spot asset, and
|
|
352
|
+
* both bridge to the same mainnet address (`routeType` matches
|
|
353
|
+
* {@link LighterWithdrawalCustomerData.routeType}).
|
|
354
|
+
* - Nado keys every subaccount query on a product id, not a token address.
|
|
355
|
+
*/
|
|
356
|
+
export type WithdrawalSourceCustomData = {
|
|
357
|
+
type: 'lighter';
|
|
358
|
+
routeType: LighterRouteType;
|
|
359
|
+
} | {
|
|
360
|
+
type: 'nado';
|
|
361
|
+
/** Nado's own key for the asset — every subaccount query is keyed on it. */
|
|
362
|
+
productId: number;
|
|
363
|
+
};
|
|
364
|
+
/** Argument of {@link WithdrawalConfigBase.withdrawalSourceTokenBalance}. */
|
|
365
|
+
export interface WithdrawalSourceTokenBalanceParams {
|
|
366
|
+
sourceAsset: TokenInfo;
|
|
367
|
+
/** Absent for flows whose source token needs no further disambiguation. */
|
|
368
|
+
customData?: WithdrawalSourceCustomData;
|
|
369
|
+
}
|
|
315
370
|
export interface WithdrawalParam {
|
|
316
371
|
quoteId: string;
|
|
317
372
|
funQuote: unknown;
|
|
@@ -523,5 +578,7 @@ export interface FunkitActiveWithdrawalItem {
|
|
|
523
578
|
id: string;
|
|
524
579
|
/** Final settings the withdrawal was init-ed with **/
|
|
525
580
|
initSettings: Partial<UseFunkitCheckoutPropsWithFullConfig>;
|
|
526
|
-
|
|
581
|
+
/** Absent when the integrator wired no callback — never defaulted to `0`, so
|
|
582
|
+
* the flow can tell "unknown" from "nothing withdrawable". */
|
|
583
|
+
withdrawalSourceTokenBalance?: (params: WithdrawalSourceTokenBalanceParams) => string | number;
|
|
527
584
|
}
|
|
@@ -126,7 +126,7 @@ export interface FunkitUiCustomizationsConfig {
|
|
|
126
126
|
* - "chainDependent": show price impact and additionally show gas as well for eth-mainnet
|
|
127
127
|
*/
|
|
128
128
|
showTransactionDigest?: 'none' | 'chainDependent';
|
|
129
|
-
/**
|
|
129
|
+
/** @deprecated The token amount below the USD equivalent has been removed. This field is ignored. */
|
|
130
130
|
showTokenAmount?: boolean;
|
|
131
131
|
/** Instead of showing the dollar value centered, show it left-aligned with "Deposit" label - defaults to false */
|
|
132
132
|
showLeftAlignedDollarValueWithLabel?: boolean;
|
|
@@ -247,7 +247,7 @@ export interface FunkitUiCustomizationsConfig {
|
|
|
247
247
|
*/
|
|
248
248
|
type RequiredExceptCustomComponents<T> = Required<Omit<T & {}, `${string}Component`>>;
|
|
249
249
|
export type FunkitUiCustomizationsConfigInternal = Required<FunkitUiCustomizationsConfig> & {
|
|
250
|
-
confirmationScreen: FunkitUiCustomizationsConfig['confirmationScreen'] & Required<Omit<FunkitUiCustomizationsConfig['confirmationScreen'] & {}, 'destinationConfig' | 'selectedRouteConfig'>>;
|
|
250
|
+
confirmationScreen: FunkitUiCustomizationsConfig['confirmationScreen'] & Required<Omit<FunkitUiCustomizationsConfig['confirmationScreen'] & {}, 'destinationConfig' | 'selectedRouteConfig' | 'showTokenAmount'>>;
|
|
251
251
|
inputAmountScreen: Required<FunkitUiCustomizationsConfig['inputAmountScreen'] & {}>;
|
|
252
252
|
selectAssetScreen: RequiredExceptCustomComponents<FunkitUiCustomizationsConfig['selectAssetScreen']>;
|
|
253
253
|
transferCryptoScreen: RequiredExceptCustomComponents<FunkitUiCustomizationsConfig['transferCryptoScreen']>;
|
package/dist/utils/consts.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
export { MAX_BTC_LIGHTNING_AMOUNT_USD } from '@funkit/connect-core';
|
|
1
2
|
export declare const MIN_CHECKOUT_AMOUNT_USD = 1;
|
|
2
|
-
export declare const MAX_BTC_LIGHTNING_AMOUNT_USD = 10000;
|
|
3
3
|
export declare const LOW_BALANCE = "Low Balance";
|
|
4
4
|
export declare const CONTACT_US_LINK = "https://intercom.help/funxyz/en/articles/10732578-contact-us";
|
|
5
5
|
export declare const DEFAULT_CHECKOUT_HISTORY_DETAIL_TITLE = "Your Purchase";
|