@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
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orchestrates the Nado enter-amount screen: joins subaccount balances onto the
|
|
3
|
+
* source tokens declared on the config, tracks the borrow toggle, and exposes
|
|
4
|
+
* the sequencer fee + max-withdrawable in token units.
|
|
5
|
+
*
|
|
6
|
+
* - One-way dependency: never imports from `modals/`; WithdrawalContent maps
|
|
7
|
+
* these outputs onto its own props.
|
|
8
|
+
* - Every react-query call is a no-op (zero traffic) when the config isn't Nado.
|
|
9
|
+
*/
|
|
10
|
+
import type { FunkitWithdrawalConfig } from '../../../providers/FunkitCheckoutContext';
|
|
11
|
+
import type { NadoWithdrawalCustomerData } from './withdrawalTypes';
|
|
12
|
+
/** Structurally matches the shared flow's `clientAmountToggle` (no modals import). */
|
|
13
|
+
export interface NadoAmountToggle {
|
|
14
|
+
label: string;
|
|
15
|
+
checked: boolean;
|
|
16
|
+
onChange(enabled: boolean): void;
|
|
17
|
+
}
|
|
18
|
+
export interface UseNadoWithdrawalFormResult {
|
|
19
|
+
isNado: boolean;
|
|
20
|
+
/** Borrow (spot leverage) checkbox, assembled here so shared code holds no Nado state. */
|
|
21
|
+
amountToggle: NadoAmountToggle | undefined;
|
|
22
|
+
/** Max withdrawable for the selection in token units (accounts for the borrow toggle). */
|
|
23
|
+
maxWithdrawableTokenUnits: string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Balance the screen shows and the Max button fills: the spot balance, or the
|
|
26
|
+
* borrow-aware max_withdrawable once borrowing is on (which can exceed spot).
|
|
27
|
+
*/
|
|
28
|
+
withdrawableBalanceTokenUnits: string;
|
|
29
|
+
/** Sequencer fee in the selected product's token units; hard 0 outside Nado. */
|
|
30
|
+
sequencerFeeTokenAmount: number;
|
|
31
|
+
/** USD price of the selected source token (stables short-circuit to 1); undefined while loading. */
|
|
32
|
+
sourceTokenUsdPrice: number | undefined;
|
|
33
|
+
/** Submit-time customerData for the withdrawal callback; logs the decision. Undefined outside Nado. */
|
|
34
|
+
buildSubmitCustomerData(): NadoWithdrawalCustomerData | undefined;
|
|
35
|
+
}
|
|
36
|
+
export declare function useNadoWithdrawalForm(config: FunkitWithdrawalConfig | null,
|
|
37
|
+
/**
|
|
38
|
+
* The shared active dropdown item, by symbol. The product id is derived from
|
|
39
|
+
* it — tracking a second copy here would leave two selections to keep in sync.
|
|
40
|
+
*/
|
|
41
|
+
selectedSourceToken: string | undefined): UseNadoWithdrawalFormResult;
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
isNadoWithdrawalConfig
|
|
4
|
+
} from "../../chunk-SFDEST63.js";
|
|
5
|
+
import {
|
|
6
|
+
x18ToTokenUnits
|
|
7
|
+
} from "../../chunk-6CYZKITE.js";
|
|
8
|
+
import {
|
|
9
|
+
useNadoFeeRates,
|
|
10
|
+
useNadoMaxWithdrawable,
|
|
11
|
+
useNadoSubaccountBalances
|
|
12
|
+
} from "../../chunk-MGQLVTSH.js";
|
|
13
|
+
import "../../chunk-ZCCLJW6F.js";
|
|
14
|
+
import "../../chunk-BNMZM23Q.js";
|
|
15
|
+
import "../../chunk-II5CZTBC.js";
|
|
16
|
+
import "../../chunk-L2KSNS7H.js";
|
|
17
|
+
import "../../chunk-2YWQL3AO.js";
|
|
18
|
+
import {
|
|
19
|
+
useGeneralWallet
|
|
20
|
+
} from "../../chunk-LT4EWLDA.js";
|
|
21
|
+
import "../../chunk-5MY7WMEJ.js";
|
|
22
|
+
import {
|
|
23
|
+
useFunkitConfig
|
|
24
|
+
} from "../../chunk-2FSEE3AW.js";
|
|
25
|
+
import "../../chunk-UPZNKPYU.js";
|
|
26
|
+
import {
|
|
27
|
+
useFunkitTranslation
|
|
28
|
+
} from "../../chunk-JD2J5K6S.js";
|
|
29
|
+
import {
|
|
30
|
+
logger
|
|
31
|
+
} from "../../chunk-AHYOV7AV.js";
|
|
32
|
+
|
|
33
|
+
// src/clients/internal/nado/withdrawalForm.ts
|
|
34
|
+
import { useEffect, useMemo, useState } from "react";
|
|
35
|
+
|
|
36
|
+
// src/hooks/useAssetPrice.ts
|
|
37
|
+
import {
|
|
38
|
+
getAssetPriceInfo
|
|
39
|
+
} from "@funkit/api-base";
|
|
40
|
+
import {
|
|
41
|
+
convertFunToRelayTokenAddress,
|
|
42
|
+
getRelayAssetPriceInfo
|
|
43
|
+
} from "@funkit/fun-relay";
|
|
44
|
+
import { skipToken, useQuery } from "@tanstack/react-query";
|
|
45
|
+
|
|
46
|
+
// src/hooks/useIsStablecoin.ts
|
|
47
|
+
import { useCallback } from "react";
|
|
48
|
+
|
|
49
|
+
// src/hooks/statsig/useDynamicConfig.ts
|
|
50
|
+
import {
|
|
51
|
+
useDynamicConfig as useCoreDynamicConfig
|
|
52
|
+
} from "@funkit/connect-core";
|
|
53
|
+
|
|
54
|
+
// src/hooks/useUserIpInfo.ts
|
|
55
|
+
import { useUserIpInfo as useCoreUserIpInfo } from "@funkit/connect-core";
|
|
56
|
+
|
|
57
|
+
// src/utils/safeBigInt.ts
|
|
58
|
+
function safeBigInt(value, fallback) {
|
|
59
|
+
if (typeof value === "bigint") {
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
if (typeof value === "number") {
|
|
63
|
+
return Number.isFinite(value) && Number.isInteger(value) ? BigInt(value) : fallback;
|
|
64
|
+
}
|
|
65
|
+
if (typeof value === "string" && /^-?\d+$/.test(value)) {
|
|
66
|
+
return BigInt(value);
|
|
67
|
+
}
|
|
68
|
+
return fallback;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// src/hooks/useUserIpInfo.ts
|
|
72
|
+
function useUserIpInfo() {
|
|
73
|
+
const { isUserLoggedIn } = useGeneralWallet();
|
|
74
|
+
return useCoreUserIpInfo({ logger, enabled: isUserLoggedIn });
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// src/hooks/statsig/useDynamicConfig.ts
|
|
78
|
+
var useDynamicConfig = (name, options) => {
|
|
79
|
+
const { userIpInfo } = useUserIpInfo();
|
|
80
|
+
return useCoreDynamicConfig(name, {
|
|
81
|
+
bypassCountryCode: options?.bypassCountryCode,
|
|
82
|
+
countryCode: userIpInfo?.alpha2
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// src/hooks/useIsStablecoin.ts
|
|
87
|
+
var useIsStablecoin = () => {
|
|
88
|
+
const stablecoinSymbols = useDynamicConfig("stablecoinsymbols");
|
|
89
|
+
return useCallback(
|
|
90
|
+
(symbol) => stablecoinSymbols.some(
|
|
91
|
+
(s) => symbol.toLowerCase().includes(s.toLowerCase())
|
|
92
|
+
),
|
|
93
|
+
[stablecoinSymbols]
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// src/hooks/useAssetPrice.ts
|
|
98
|
+
async function getFormattedRelayAssetPriceInfo({
|
|
99
|
+
chainId,
|
|
100
|
+
assetTokenAddress
|
|
101
|
+
}) {
|
|
102
|
+
try {
|
|
103
|
+
const relayResponse = await getRelayAssetPriceInfo({
|
|
104
|
+
chainId,
|
|
105
|
+
address: convertFunToRelayTokenAddress(
|
|
106
|
+
assetTokenAddress,
|
|
107
|
+
Number(chainId)
|
|
108
|
+
)
|
|
109
|
+
});
|
|
110
|
+
return {
|
|
111
|
+
unitPrice: relayResponse.price,
|
|
112
|
+
amount: 1,
|
|
113
|
+
total: 1
|
|
114
|
+
};
|
|
115
|
+
} catch (error) {
|
|
116
|
+
logger.error("Unable to fetch token price from Relay", error);
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
async function getAssetPriceInfoWithFallback({
|
|
121
|
+
apiKey,
|
|
122
|
+
chainId,
|
|
123
|
+
assetTokenAddress
|
|
124
|
+
}) {
|
|
125
|
+
try {
|
|
126
|
+
return await getAssetPriceInfo({
|
|
127
|
+
apiKey,
|
|
128
|
+
assetTokenAddress,
|
|
129
|
+
chainId,
|
|
130
|
+
logger
|
|
131
|
+
});
|
|
132
|
+
} catch (primaryError) {
|
|
133
|
+
logger.warn(
|
|
134
|
+
"Unable to fetch token price from Primary provider, trying fallback",
|
|
135
|
+
{ primaryError }
|
|
136
|
+
);
|
|
137
|
+
return await getFormattedRelayAssetPriceInfo({ chainId, assetTokenAddress });
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function useAssetAddressPrice({
|
|
141
|
+
chainId,
|
|
142
|
+
assetTokenAddress,
|
|
143
|
+
amount = 1,
|
|
144
|
+
refetchInterval = 1e4,
|
|
145
|
+
symbol,
|
|
146
|
+
enabled = true
|
|
147
|
+
}) {
|
|
148
|
+
const { apiKey } = useFunkitConfig();
|
|
149
|
+
const isStablecoin = useIsStablecoin();
|
|
150
|
+
const { data, error, isLoading } = useQuery({
|
|
151
|
+
queryKey: ["getAssetPriceInfo", chainId, assetTokenAddress],
|
|
152
|
+
queryFn: enabled && chainId && assetTokenAddress ? () => getAssetPriceInfoWithFallback({
|
|
153
|
+
apiKey,
|
|
154
|
+
chainId,
|
|
155
|
+
assetTokenAddress
|
|
156
|
+
}) : skipToken,
|
|
157
|
+
refetchInterval
|
|
158
|
+
});
|
|
159
|
+
const unitPrice = symbol && isStablecoin(symbol) ? 1 : data?.unitPrice;
|
|
160
|
+
return {
|
|
161
|
+
error,
|
|
162
|
+
isLoading,
|
|
163
|
+
price: unitPrice !== void 0 ? unitPrice * amount : void 0
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// src/clients/internal/nado/withdrawalForm.ts
|
|
168
|
+
var PRICE_REFRESH_MS = 6e4;
|
|
169
|
+
function isNadoSourceToken(option) {
|
|
170
|
+
return option.customData?.type === "nado" && option.asset?.decimals !== void 0;
|
|
171
|
+
}
|
|
172
|
+
function useNadoWithdrawalForm(config, selectedSourceToken) {
|
|
173
|
+
const nadoConfig = isNadoWithdrawalConfig(config) ? config : void 0;
|
|
174
|
+
const isNado = !!nadoConfig;
|
|
175
|
+
const subaccount = nadoConfig?.customerConfig.subaccount;
|
|
176
|
+
const [spotLeverage, setSpotLeverage] = useState(false);
|
|
177
|
+
useEffect(() => {
|
|
178
|
+
setSpotLeverage(false);
|
|
179
|
+
}, [subaccount]);
|
|
180
|
+
const { data: subaccountInfo } = useNadoSubaccountBalances(subaccount);
|
|
181
|
+
const { data: feeRates } = useNadoFeeRates(subaccount);
|
|
182
|
+
const balanceX18ByProductId = useMemo(
|
|
183
|
+
() => new Map(
|
|
184
|
+
(subaccountInfo?.spot_balances ?? []).map((b) => [
|
|
185
|
+
b.product_id,
|
|
186
|
+
b.balance.amount
|
|
187
|
+
])
|
|
188
|
+
),
|
|
189
|
+
[subaccountInfo]
|
|
190
|
+
);
|
|
191
|
+
const sourceOptions = useMemo(
|
|
192
|
+
() => (nadoConfig?.sourceTokens ?? []).filter(isNadoSourceToken).map(({ asset, customData, symbol, iconSrc }) => {
|
|
193
|
+
const balanceX18 = safeBigInt(
|
|
194
|
+
balanceX18ByProductId.get(customData.productId),
|
|
195
|
+
0n
|
|
196
|
+
);
|
|
197
|
+
return {
|
|
198
|
+
productId: customData.productId,
|
|
199
|
+
symbol,
|
|
200
|
+
balanceTokenUnits: x18ToTokenUnits(
|
|
201
|
+
(balanceX18 > 0n ? balanceX18 : 0n).toString(),
|
|
202
|
+
asset.decimals
|
|
203
|
+
),
|
|
204
|
+
decimals: asset.decimals,
|
|
205
|
+
tokenAddress: asset.tokenAddress,
|
|
206
|
+
tokenChainId: asset.tokenChainId,
|
|
207
|
+
iconSrc
|
|
208
|
+
};
|
|
209
|
+
}),
|
|
210
|
+
[nadoConfig?.sourceTokens, balanceX18ByProductId]
|
|
211
|
+
);
|
|
212
|
+
const selectedOption = sourceOptions.find(
|
|
213
|
+
(option) => option.symbol === selectedSourceToken
|
|
214
|
+
);
|
|
215
|
+
const selectedProductId = selectedOption?.productId;
|
|
216
|
+
useEffect(() => {
|
|
217
|
+
if (selectedProductId === void 0) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
logger.info("nado:withdrawal:sourceSelected", {
|
|
221
|
+
productId: selectedProductId,
|
|
222
|
+
symbol: selectedSourceToken
|
|
223
|
+
});
|
|
224
|
+
}, [selectedProductId, selectedSourceToken]);
|
|
225
|
+
const { price: sourceTokenUsdPrice } = useAssetAddressPrice({
|
|
226
|
+
chainId: selectedOption?.tokenChainId,
|
|
227
|
+
assetTokenAddress: selectedOption?.tokenAddress,
|
|
228
|
+
symbol: selectedOption?.symbol,
|
|
229
|
+
refetchInterval: PRICE_REFRESH_MS,
|
|
230
|
+
enabled: isNado
|
|
231
|
+
});
|
|
232
|
+
const { data: maxWithdrawableX18 } = useNadoMaxWithdrawable({
|
|
233
|
+
productId: selectedOption?.productId,
|
|
234
|
+
sender: subaccount,
|
|
235
|
+
spotLeverage
|
|
236
|
+
});
|
|
237
|
+
const maxWithdrawableTokenUnits = selectedOption && maxWithdrawableX18 !== void 0 ? x18ToTokenUnits(maxWithdrawableX18, selectedOption.decimals) : void 0;
|
|
238
|
+
const withdrawableBalanceTokenUnits = spotLeverage ? maxWithdrawableTokenUnits ?? selectedOption?.balanceTokenUnits ?? "0" : selectedOption?.balanceTokenUnits ?? "0";
|
|
239
|
+
const sequencerFeeTokenAmount = useMemo(() => {
|
|
240
|
+
if (!isNado || !selectedOption) {
|
|
241
|
+
return 0;
|
|
242
|
+
}
|
|
243
|
+
const feeX18 = feeRates?.withdraw_sequencer_fees?.[selectedOption.productId];
|
|
244
|
+
if (feeX18 === void 0) {
|
|
245
|
+
return 0;
|
|
246
|
+
}
|
|
247
|
+
return Number(x18ToTokenUnits(feeX18, selectedOption.decimals));
|
|
248
|
+
}, [isNado, selectedOption, feeRates]);
|
|
249
|
+
const { t } = useFunkitTranslation();
|
|
250
|
+
const amountToggle = isNado ? {
|
|
251
|
+
label: t("withdrawal.enableBorrowing"),
|
|
252
|
+
checked: spotLeverage,
|
|
253
|
+
onChange: setSpotLeverage
|
|
254
|
+
} : void 0;
|
|
255
|
+
const buildSubmitCustomerData = () => {
|
|
256
|
+
if (!isNado || !selectedOption) {
|
|
257
|
+
return void 0;
|
|
258
|
+
}
|
|
259
|
+
logger.info("nado:withdrawal:submit", {
|
|
260
|
+
productId: selectedOption.productId,
|
|
261
|
+
spotLeverage,
|
|
262
|
+
sequencerFeeTokenAmount
|
|
263
|
+
});
|
|
264
|
+
return {
|
|
265
|
+
customerName: "nado",
|
|
266
|
+
productId: selectedOption.productId,
|
|
267
|
+
spotLeverage,
|
|
268
|
+
sequencerFeeTokenAmount
|
|
269
|
+
};
|
|
270
|
+
};
|
|
271
|
+
return {
|
|
272
|
+
isNado,
|
|
273
|
+
amountToggle,
|
|
274
|
+
maxWithdrawableTokenUnits,
|
|
275
|
+
withdrawableBalanceTokenUnits,
|
|
276
|
+
sequencerFeeTokenAmount,
|
|
277
|
+
sourceTokenUsdPrice,
|
|
278
|
+
buildSubmitCustomerData
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
export {
|
|
282
|
+
useNadoWithdrawalForm
|
|
283
|
+
};
|
|
@@ -8,13 +8,18 @@
|
|
|
8
8
|
import type { Address, Hex } from 'viem';
|
|
9
9
|
/**
|
|
10
10
|
* Nado per-submission form selections threaded to the withdrawal callback (the
|
|
11
|
-
* static config can't know them).
|
|
12
|
-
*
|
|
11
|
+
* static config can't know them).
|
|
12
|
+
* - `spotLeverage` must be explicit — Nado treats an absent value as borrowing,
|
|
13
|
+
* so `false` fails instead of opening a borrow.
|
|
14
|
+
* - `sequencerFeeTokenAmount` pins the fee the screen displayed, so the callback
|
|
15
|
+
* signs the same net amount instead of re-reading a possibly-refreshed cache.
|
|
13
16
|
*/
|
|
14
17
|
export interface NadoWithdrawalCustomerData {
|
|
15
18
|
customerName: 'nado';
|
|
16
19
|
productId: number;
|
|
17
20
|
spotLeverage: boolean;
|
|
21
|
+
/** Sequencer fee in the product's token units, as shown at submit. */
|
|
22
|
+
sequencerFeeTokenAmount: number;
|
|
18
23
|
}
|
|
19
24
|
/**
|
|
20
25
|
* Nado config-level identity — the hook's **output**, not integrator input.
|
package/dist/clients/lighter.css
CHANGED
|
@@ -14712,7 +14712,7 @@
|
|
|
14712
14712
|
border-radius: 50%;
|
|
14713
14713
|
}
|
|
14714
14714
|
|
|
14715
|
-
/* vanilla-extract-css-ns:src/components/Dialog/Dialog.css.ts.vanilla.css?source=
|
|
14715
|
+
/* vanilla-extract-css-ns:src/components/Dialog/Dialog.css.ts.vanilla.css?source=Ll8xcjhmNTcxIHsKICBib3R0b206IC0yMDBweDsKICBsZWZ0OiAtMjAwcHg7CiAgcGFkZGluZzogMjAwcHg7CiAgcmlnaHQ6IC0yMDBweDsKICB0b3A6IC0yMDBweDsKICB0cmFuc2Zvcm06IHRyYW5zbGF0ZVooMCk7CiAgei1pbmRleDogdmFyKC0tcmstbW9kYWxaSW5kZXgpOwp9Cjp3aGVyZSguXzFyOGY1NzEpIDp3aGVyZShhdWRpbywgY2FudmFzLCBlbWJlZCwgaWZyYW1lLCBpbWcsIG9iamVjdCwgc3ZnLCB2aWRlbykgewogIGRpc3BsYXk6IGJsb2NrOwogIHZlcnRpY2FsLWFsaWduOiBtaWRkbGU7Cn0KLl8xcjhmNTczIHsKICBtYXgtd2lkdGg6IDEwMHZ3Owp9Ci5fMXI4ZjU3NCB7CiAgZGlzcGxheTogZmxleDsKICBhbGlnbi1pdGVtczogY2VudGVyOwogIGp1c3RpZnktY29udGVudDogc3BhY2UtYmV0d2VlbjsKICB3aWR0aDogMTAwJTsKICBmbGV4LXNocmluazogMDsKICBtaW4taGVpZ2h0OiB2YXIoLS1yay1kaW1lbnNpb25zLW1vZGFsVG9wQmFySGVpZ2h0KTsKfQouXzFyOGY1NzYgewogIHBvc2l0aW9uOiBhYnNvbHV0ZTsKICBsZWZ0OiAwOwogIHJpZ2h0OiAwOwogIHotaW5kZXg6IDE7Cn0KLl8xcjhmNTc3IHsKICBwb3NpdGlvbjogcmVsYXRpdmU7CiAgei1pbmRleDogMjsKfQouXzFyOGY1NzkgewogIGJvdHRvbTogMDsKICBsZWZ0OiAwOwogIHJpZ2h0OiAwOwogIHRvcDogMDsKICB6LWluZGV4OiAtMTsKfQouXzFyOGY1N2EgewogIGFsaWduLWl0ZW1zOiBjZW50ZXI7Cn0KLl8xcjhmNTdiIHsKICBhbGlnbi1pdGVtczogZmxleC1lbmQ7Cn0 */
|
|
14716
14716
|
[data-rk] ._1r8f571 {
|
|
14717
14717
|
bottom: -200px;
|
|
14718
14718
|
left: -200px;
|
|
@@ -14722,6 +14722,10 @@
|
|
|
14722
14722
|
transform: translateZ(0);
|
|
14723
14723
|
z-index: var(--rk-modalZIndex);
|
|
14724
14724
|
}
|
|
14725
|
+
[data-rk] :where(._1r8f571) :where(audio, canvas, embed, iframe, img, object, svg, video) {
|
|
14726
|
+
display: block;
|
|
14727
|
+
vertical-align: middle;
|
|
14728
|
+
}
|
|
14725
14729
|
[data-rk] ._1r8f573 {
|
|
14726
14730
|
max-width: 100vw;
|
|
14727
14731
|
}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* caller provides the actual on-chain implementation.
|
|
15
15
|
*/
|
|
16
16
|
import { type Address } from 'viem';
|
|
17
|
-
import type { CustomWithdrawalConfig, LighterRouteType, MultiMethodWithdrawalConfig } from '../providers/FunkitCheckoutContext/types';
|
|
17
|
+
import type { CustomWithdrawalConfig, LighterRouteType, MultiMethodWithdrawalConfig, SourceTokenOption, WithdrawalSourceTokenBalanceParams } from '../providers/FunkitCheckoutContext/types';
|
|
18
18
|
export { LIGHTER_ROUTE_TYPE } from '../modals/WithdrawalModal/LighterWithdrawal';
|
|
19
19
|
export type { LighterRouteType } from '../providers/FunkitCheckoutContext/types';
|
|
20
20
|
export { LIGHTER_WITHDRAW_ABI, buildLighterL1WithdrawTransaction, isLighterWithdrawalRateLimitError, lighterWithdrawBaseUnits, } from '../utils/lighter';
|
|
@@ -55,6 +55,12 @@ export interface LighterWithdrawalConfig {
|
|
|
55
55
|
/** Pre-built Lighter signer. */
|
|
56
56
|
signerClient: LighterSigner;
|
|
57
57
|
sendLighterSecureWithdrawal: LighterSecureWithdrawalExec;
|
|
58
|
+
/**
|
|
59
|
+
* Withdrawable balance for the selected source token, applied to both methods.
|
|
60
|
+
* Lighter's own accounting — it must account for what the SDK cannot see
|
|
61
|
+
* (margin requirements, locked collateral), so the integrator owns it.
|
|
62
|
+
*/
|
|
63
|
+
withdrawalSourceTokenBalance?: (params: WithdrawalSourceTokenBalanceParams) => string | number;
|
|
58
64
|
/**
|
|
59
65
|
* Returns the minimum Secure withdrawal amount in token units for the given symbol.
|
|
60
66
|
* Spot USDC is passed as `USDC (Spot)` (perps collateral is plain `USDC`);
|
|
@@ -104,6 +110,9 @@ export interface LighterSecureWithdrawalConfig {
|
|
|
104
110
|
modalTitle?: string;
|
|
105
111
|
disableConnectedWallet?: boolean;
|
|
106
112
|
iconSrc?: string;
|
|
113
|
+
/** Selectable source tokens, built from the account's live asset list. */
|
|
114
|
+
sourceTokens?: SourceTokenOption[];
|
|
115
|
+
withdrawalSourceTokenBalance?: (params: WithdrawalSourceTokenBalanceParams) => string | number;
|
|
107
116
|
/**
|
|
108
117
|
* Submit the Secure withdrawal on Lighter's L2. Funds bridge directly to
|
|
109
118
|
* Ethereum mainnet. No relay/swap — the token withdrawn is the token received.
|
|
@@ -156,6 +165,25 @@ export declare function trackLighterSecureWithdrawal({ apiKey, userId, txHash, r
|
|
|
156
165
|
}): Promise<void>;
|
|
157
166
|
/** Single-method config for Lighter's Secure withdrawal (bridge to Ethereum). */
|
|
158
167
|
export declare function createLighterSecureWithdrawalConfig(config: LighterSecureWithdrawalConfig): CustomWithdrawalConfig;
|
|
168
|
+
/**
|
|
169
|
+
* Builds the source-token options list for the Lighter compound input dropdown.
|
|
170
|
+
*
|
|
171
|
+
* - Fast path: only USDC (Perps).
|
|
172
|
+
* - Secure path: USDC (Perps) (from total_asset_value) + USDC (Spot) when the
|
|
173
|
+
* account carries a spot USDC asset + every non-USDC asset on the account.
|
|
174
|
+
*
|
|
175
|
+
* Unified Trading accounts (`isUnifiedTradingMode`) have a single USDC balance
|
|
176
|
+
* — no spot/perps split — so the perps entry is labeled plain `USDC` and the
|
|
177
|
+
* `USDC (Spot)` entry is hidden on both paths.
|
|
178
|
+
*/
|
|
179
|
+
export declare function buildLighterSourceTokenOptions({ isSecure, lighterAssets, isUnifiedTradingMode, }: {
|
|
180
|
+
/** Secure lists every spot asset alongside perps; Fast is perps-only. */
|
|
181
|
+
isSecure: boolean;
|
|
182
|
+
lighterAssets: {
|
|
183
|
+
symbol: string;
|
|
184
|
+
}[];
|
|
185
|
+
isUnifiedTradingMode?: boolean;
|
|
186
|
+
}): SourceTokenOption[];
|
|
159
187
|
/**
|
|
160
188
|
* The single React entry point for Lighter withdrawals. Returns a
|
|
161
189
|
* `MultiMethodWithdrawalConfig` ready to hand to the withdrawal modal, or
|