@funkit/connect 12.15.3 → 12.17.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 +80 -0
- package/dist/clients/axiom.d.ts +11 -3
- package/dist/clients/axiom.js +3 -1
- package/dist/clients/{chunk-7JYLS7IF.js → chunk-2L6IKKNH.js} +48 -32
- package/dist/clients/{chunk-6IH7AWFA.js → chunk-HANOVGPH.js} +1 -1
- package/dist/clients/{chunk-OB5GKTP2.js → chunk-LVR6RQMO.js} +1 -1
- package/dist/clients/chunk-R25GIAD5.js +59 -0
- package/dist/clients/{chunk-UZ3NA7HN.js → chunk-TWP5LFPX.js} +5 -5
- package/dist/clients/{chunk-BKK2BFIP.js → chunk-V4RIF2NR.js} +1 -1
- package/dist/clients/fanatics.js +2 -2
- package/dist/clients/internal/nado/withdrawalCallback.js +3 -3
- package/dist/clients/internal/nado/withdrawalErrors.js +2 -2
- package/dist/clients/internal/nado/withdrawalForm.js +4 -4
- package/dist/clients/internal/nado/withdrawalStatus.js +3 -3
- package/dist/clients/lighter.d.ts +29 -16
- package/dist/clients/lighter.js +149 -68
- package/dist/clients/mallard.js +2 -2
- package/dist/clients/nado.js +3 -3
- package/dist/consts/customers.d.ts +12 -1
- package/dist/domains/convert/assets.d.ts +22 -0
- package/dist/domains/convert/balances.d.ts +35 -0
- package/dist/domains/convert/errors.d.ts +38 -0
- package/dist/domains/convert/execution.d.ts +39 -0
- package/dist/domains/convert/inputAmount.d.ts +24 -0
- package/dist/domains/convert/quote.d.ts +24 -0
- package/dist/domains/convert/recipient.d.ts +21 -0
- package/dist/domains/convert/settlement.d.ts +47 -0
- package/dist/domains/convert/sourceWallet.d.ts +29 -0
- package/dist/domains/convert/submit.d.ts +46 -0
- package/dist/domains/convert/types.d.ts +165 -0
- package/dist/domains/nativeFeeReserve.d.ts +29 -0
- package/dist/domains/quote.d.ts +14 -1
- package/dist/hooks/queries/useWithdrawFops.d.ts +6 -0
- package/dist/hooks/queries/useWithdrawalQuote.d.ts +4 -1
- package/dist/hooks/statsig/index.d.ts +1 -1
- package/dist/hooks/track/WithdrawModalEvent.d.ts +1 -0
- package/dist/hooks/track/analytics/events.d.ts +59 -1
- package/dist/hooks/track/analytics/mappers.d.ts +5 -10
- package/dist/hooks/track/analytics/resolveIframeStepNavigation.d.ts +18 -0
- package/dist/hooks/track/analytics/useDepositAnalytics.d.ts +2 -2
- package/dist/hooks/track/analytics/useTrackSwappedIframeEvents.d.ts +5 -0
- package/dist/hooks/track/analytics/useWithdrawalAnalytics.d.ts +2 -2
- package/dist/hooks/track/useQuoteAttemptCounter.d.ts +2 -0
- package/dist/hooks/useConvertAssets.d.ts +9 -0
- package/dist/hooks/useConvertBalances.d.ts +44 -0
- package/dist/hooks/useConvertExecute.d.ts +77 -0
- package/dist/hooks/useConvertInputAmount.d.ts +26 -0
- package/dist/hooks/useConvertMaxAmount.d.ts +11 -0
- package/dist/hooks/useConvertQuote.d.ts +33 -0
- package/dist/hooks/useConvertTransactionStatus.d.ts +23 -0
- package/dist/hooks/useMaxSpendableAmount.d.ts +19 -0
- package/dist/hooks/usePrepareConvertSubmit.d.ts +22 -0
- package/dist/hooks/useStepQueryReadiness.d.ts +45 -15
- package/dist/hooks/useSwappedBuyingCrypto.d.ts +13 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2572 -1800
- package/dist/modals/CheckoutModal/SwappedIframe/swappedIframeReady.track.d.ts +8 -0
- package/dist/modals/CheckoutModal/stepTransition.d.ts +1 -2
- package/dist/modals/WithdrawalModal/LighterWithdrawal.d.ts +48 -15
- package/dist/modals/WithdrawalModal/WithdrawAmountInput.d.ts +3 -1
- package/dist/modals/WithdrawalModal/WithdrawalContent.d.ts +4 -1
- package/dist/modals/WithdrawalModal/useMaxWithdrawableAmount.d.ts +10 -0
- package/dist/modals/WithdrawalModal/withdrawalFormHelpers.d.ts +28 -8
- package/dist/providers/FunkitCheckoutContext/types.d.ts +7 -0
- package/dist/providers/FunkitQuoteContext.track.d.ts +23 -3
- package/dist/providers/FunkitStatsigWhnProvider.d.ts +0 -11
- package/dist/providers/SwappedProvider.d.ts +11 -2
- package/dist/utils/customer.d.ts +34 -4
- package/dist/wallets/walletConnectors/index.js +41 -41
- package/package.json +6 -6
- package/dist/clients/chunk-6EU6CXNH.js +0 -20
- package/dist/hooks/statsig/useExperimentV2.d.ts +0 -8
- package/dist/utils/statsig/client.d.ts +0 -4
package/dist/clients/lighter.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
+
LIGHTER_API_KEY_BY_CHAIN_ID,
|
|
3
4
|
useLighterAccountQuery,
|
|
4
5
|
useLighterAccountsQuery
|
|
5
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-R25GIAD5.js";
|
|
6
7
|
import {
|
|
7
8
|
useFunkitConfig
|
|
8
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-HANOVGPH.js";
|
|
9
10
|
import {
|
|
10
11
|
AsyncImage,
|
|
11
12
|
Box,
|
|
@@ -13,21 +14,24 @@ import {
|
|
|
13
14
|
} from "./chunk-RQALGV5U.js";
|
|
14
15
|
import {
|
|
15
16
|
useFunkitTranslation
|
|
16
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-LVR6RQMO.js";
|
|
17
18
|
import "./chunk-OODIKHYE.js";
|
|
18
19
|
import "./chunk-2W2P3OS6.js";
|
|
19
|
-
import "./chunk-
|
|
20
|
+
import "./chunk-2L6IKKNH.js";
|
|
20
21
|
import {
|
|
21
22
|
logger
|
|
22
23
|
} from "./chunk-AHYOV7AV.js";
|
|
23
24
|
|
|
24
25
|
// src/clients/lighter.tsx
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
import {
|
|
27
|
+
LIGHTER_CHAIN_ID as LIGHTER_CHAIN_ID2,
|
|
28
|
+
LIGHTER_RH_CHAIN_ID,
|
|
29
|
+
SOLANA_MAINNET_CHAIN_ID
|
|
30
|
+
} from "@funkit/chains";
|
|
31
|
+
import { useLogOnce as useLogOnce2 } from "@funkit/connect-core";
|
|
28
32
|
import i18next from "i18next";
|
|
29
33
|
import React7, { useMemo as useMemo3 } from "react";
|
|
30
|
-
import { arbitrum, base, bsc,
|
|
34
|
+
import { arbitrum, base, bsc, optimism } from "viem/chains";
|
|
31
35
|
|
|
32
36
|
// src/components/Icons/EvmWallet.tsx
|
|
33
37
|
import React from "react";
|
|
@@ -281,11 +285,12 @@ function SupportedChainList({
|
|
|
281
285
|
|
|
282
286
|
// src/clients/lighter.tsx
|
|
283
287
|
import {
|
|
284
|
-
LIGHTER_DEFAULT_SECURE_MIN_WITHDRAWAL_AMOUNTS as LIGHTER_DEFAULT_SECURE_MIN_WITHDRAWAL_AMOUNTS2,
|
|
285
288
|
LIGHTER_FAST_MAX_WITHDRAWAL_USD as LIGHTER_FAST_MAX_WITHDRAWAL_USD2,
|
|
286
|
-
|
|
289
|
+
LIGHTER_INSTANCES as LIGHTER_INSTANCES2,
|
|
290
|
+
lighterWithdrawBaseUnits as coreLighterWithdrawBaseUnits,
|
|
287
291
|
createLighterAdaptedWallet,
|
|
288
292
|
getLighterBaseSymbol as getLighterBaseSymbol3,
|
|
293
|
+
getLighterDefaultSecureMinWithdrawalAmounts,
|
|
289
294
|
trackLighterSecureWithdrawal,
|
|
290
295
|
useLighterWithdrawalDelaySeconds
|
|
291
296
|
} from "@funkit/connect-core/clients/lighter";
|
|
@@ -295,7 +300,11 @@ import {
|
|
|
295
300
|
DirectExecutionType,
|
|
296
301
|
createDirectExecution
|
|
297
302
|
} from "@funkit/api-base";
|
|
298
|
-
import {
|
|
303
|
+
import {
|
|
304
|
+
LIGHTER_CHAIN_ID,
|
|
305
|
+
LIGHTER_CHAIN_IDS,
|
|
306
|
+
toLighterChainId
|
|
307
|
+
} from "@funkit/chains";
|
|
299
308
|
import { formatAddress, formatCryptoAndStringify } from "@funkit/utils";
|
|
300
309
|
import { v4 as uuid } from "uuid";
|
|
301
310
|
import React6, {
|
|
@@ -341,12 +350,16 @@ function formatSecondsTranslated(seconds, t, specifyUnderMinute = false, omitSec
|
|
|
341
350
|
// src/modals/WithdrawalModal/LighterWithdrawal.tsx
|
|
342
351
|
import { useLogOnce } from "@funkit/connect-core";
|
|
343
352
|
import {
|
|
353
|
+
LIGHTER_INSTANCES,
|
|
344
354
|
LIGHTER_ROUTE_TYPE,
|
|
345
355
|
buildLighterL1WithdrawTransaction,
|
|
346
356
|
getLighterBaseSymbol,
|
|
347
|
-
|
|
357
|
+
getLighterSecureL1Address,
|
|
358
|
+
getLighterSecureL1Decimals,
|
|
348
359
|
isLighterWithdrawalRateLimitError,
|
|
349
360
|
lighterWithdrawBaseUnits,
|
|
361
|
+
resolveLighterAssetIndex,
|
|
362
|
+
resolveLighterSecureRouteType,
|
|
350
363
|
resolveLighterWithdrawalExplorerUrl,
|
|
351
364
|
truncateToDecimals,
|
|
352
365
|
useLighterFastUnstakedFeeTokens
|
|
@@ -361,9 +374,9 @@ import {
|
|
|
361
374
|
LIGHTER_UNSTAKED_FEE_TOKENS,
|
|
362
375
|
LIGHTER_USDC_SPOT_SYMBOL,
|
|
363
376
|
getLighterBaseSymbol as getLighterBaseSymbol2,
|
|
364
|
-
|
|
365
|
-
resolveLighterAssetIndex,
|
|
366
|
-
resolveLighterSecureRouteType
|
|
377
|
+
getLighterSecureL1Address as getLighterSecureL1Address2,
|
|
378
|
+
resolveLighterAssetIndex as resolveLighterAssetIndex2,
|
|
379
|
+
resolveLighterSecureRouteType as resolveLighterSecureRouteType2
|
|
367
380
|
} from "@funkit/connect-core/clients/lighter";
|
|
368
381
|
var LIGHTER_FAST_METHOD_ID = "lighter-fast";
|
|
369
382
|
var LIGHTER_SECURE_METHOD_ID = "lighter-secure";
|
|
@@ -373,14 +386,15 @@ import { LIGHTER_ROUTE_TYPE as LIGHTER_ROUTE_TYPE3 } from "@funkit/connect-core/
|
|
|
373
386
|
import {
|
|
374
387
|
LIGHTER_WITHDRAW_ABI,
|
|
375
388
|
buildLighterL1WithdrawTransaction as buildLighterL1WithdrawTransaction2,
|
|
376
|
-
isLighterWithdrawalRateLimitError as isLighterWithdrawalRateLimitError2
|
|
377
|
-
lighterWithdrawBaseUnits as lighterWithdrawBaseUnits2
|
|
389
|
+
isLighterWithdrawalRateLimitError as isLighterWithdrawalRateLimitError2
|
|
378
390
|
} from "@funkit/connect-core/clients/lighter";
|
|
379
391
|
var LIGHTER_USDC_PERPS_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
380
|
-
|
|
381
|
-
|
|
392
|
+
function lighterWithdrawBaseUnits2(assetIndex, amountTokenUnits, chainId = LIGHTER_CHAIN_ID2) {
|
|
393
|
+
return coreLighterWithdrawBaseUnits(assetIndex, amountTokenUnits, chainId);
|
|
394
|
+
}
|
|
395
|
+
function useLighterSecureDelayText(enabled, chainId) {
|
|
382
396
|
const { t } = useFunkitTranslation();
|
|
383
|
-
const seconds = useLighterWithdrawalDelaySeconds();
|
|
397
|
+
const seconds = useLighterWithdrawalDelaySeconds({ enabled, chainId });
|
|
384
398
|
if (seconds === void 0) {
|
|
385
399
|
return void 0;
|
|
386
400
|
}
|
|
@@ -394,7 +408,8 @@ function useLighterSecureDelayText() {
|
|
|
394
408
|
);
|
|
395
409
|
}
|
|
396
410
|
function buildSecureWithdrawalCallback({
|
|
397
|
-
exec
|
|
411
|
+
exec,
|
|
412
|
+
chainId
|
|
398
413
|
}) {
|
|
399
414
|
return async (param) => {
|
|
400
415
|
const { targetAssetAddress, destinationAddress } = param;
|
|
@@ -418,7 +433,10 @@ function buildSecureWithdrawalCallback({
|
|
|
418
433
|
return;
|
|
419
434
|
}
|
|
420
435
|
const withdrawalUSD = param.withdrawalUSD ?? "0";
|
|
436
|
+
const l1ChainId = LIGHTER_INSTANCES2[chainId].secureL1Chain.id;
|
|
421
437
|
logger.info("lighter:withdrawal:secure:start", {
|
|
438
|
+
chainId,
|
|
439
|
+
l1ChainId,
|
|
422
440
|
assetIndex,
|
|
423
441
|
routeType,
|
|
424
442
|
amountTokenUnits,
|
|
@@ -428,16 +446,19 @@ function buildSecureWithdrawalCallback({
|
|
|
428
446
|
const txHash = await exec({
|
|
429
447
|
amountTokenUnits,
|
|
430
448
|
assetIndex,
|
|
431
|
-
routeType
|
|
449
|
+
routeType,
|
|
450
|
+
chainId
|
|
432
451
|
});
|
|
433
452
|
logger.info("lighter:withdrawal:secure:submitted", {
|
|
453
|
+
chainId,
|
|
454
|
+
l1ChainId,
|
|
434
455
|
amountTokenUnits,
|
|
435
456
|
assetIndex,
|
|
436
457
|
routeType,
|
|
437
458
|
txHash
|
|
438
459
|
});
|
|
439
460
|
void trackLighterSecureWithdrawal({
|
|
440
|
-
apiKey:
|
|
461
|
+
apiKey: LIGHTER_API_KEY_BY_CHAIN_ID[chainId],
|
|
441
462
|
logger,
|
|
442
463
|
// Secure locks the destination to the connected wallet, so the L1
|
|
443
464
|
// recipient address doubles as the userId for tracking purposes.
|
|
@@ -445,14 +466,17 @@ function buildSecureWithdrawalCallback({
|
|
|
445
466
|
txHash,
|
|
446
467
|
recipientAddr: destinationAddress,
|
|
447
468
|
assetIndex,
|
|
448
|
-
|
|
469
|
+
l1TokenAddress: targetAssetAddress,
|
|
449
470
|
amountTokenUnits,
|
|
450
|
-
withdrawalUSD
|
|
471
|
+
withdrawalUSD,
|
|
472
|
+
chainId
|
|
451
473
|
});
|
|
452
474
|
return txHash;
|
|
453
475
|
};
|
|
454
476
|
}
|
|
455
477
|
function createLighterSecureWithdrawalConfig(config) {
|
|
478
|
+
const chainId = config.chainId ?? LIGHTER_CHAIN_ID2;
|
|
479
|
+
const { perpsCollateral, secureL1Chain } = LIGHTER_INSTANCES2[chainId];
|
|
456
480
|
return {
|
|
457
481
|
modalTitle: config.modalTitle ?? i18next.t("withdrawal.withdraw"),
|
|
458
482
|
disableConnectedWallet: config.disableConnectedWallet,
|
|
@@ -460,12 +484,14 @@ function createLighterSecureWithdrawalConfig(config) {
|
|
|
460
484
|
sourceTokens: config.sourceTokens,
|
|
461
485
|
withdrawalSourceTokenBalance: config.withdrawalSourceTokenBalance,
|
|
462
486
|
withdrawCallback: buildSecureWithdrawalCallback({
|
|
463
|
-
exec: config.sendLighterSecureWithdrawal
|
|
487
|
+
exec: config.sendLighterSecureWithdrawal,
|
|
488
|
+
chainId
|
|
464
489
|
}),
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
490
|
+
// The L1 is the source chain the modal shows and prices against.
|
|
491
|
+
sourceChainId: secureL1Chain.id.toString(),
|
|
492
|
+
sourceTokenSymbol: perpsCollateral.symbol,
|
|
493
|
+
defaultReceiveToken: perpsCollateral.symbol,
|
|
494
|
+
sourceTokenAddress: perpsCollateral.l1Address,
|
|
469
495
|
iconSrc: config.iconSrc ?? "https://sdk-cdn.fun.xyz/images/logos/lighter.png",
|
|
470
496
|
getMinWithdrawalUSD: () => 0,
|
|
471
497
|
getMinWithdrawalAmount: config.getMinWithdrawalAmount
|
|
@@ -474,24 +500,30 @@ function createLighterSecureWithdrawalConfig(config) {
|
|
|
474
500
|
function buildLighterSourceTokenOptions({
|
|
475
501
|
isSecure,
|
|
476
502
|
lighterAssets,
|
|
477
|
-
isUnifiedTradingMode = false
|
|
503
|
+
isUnifiedTradingMode = false,
|
|
504
|
+
chainId = LIGHTER_CHAIN_ID2
|
|
478
505
|
}) {
|
|
479
|
-
const
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
506
|
+
const instance = LIGHTER_INSTANCES2[chainId];
|
|
507
|
+
const collateral = instance.perpsCollateral.symbol;
|
|
508
|
+
const perpsOption = {
|
|
509
|
+
symbol: collateral,
|
|
510
|
+
label: isUnifiedTradingMode ? collateral : `${collateral} (Perps)`,
|
|
511
|
+
iconSrc: getTokenIconUrl(collateral)
|
|
483
512
|
};
|
|
484
513
|
if (!isSecure) {
|
|
485
|
-
return [
|
|
514
|
+
return [perpsOption];
|
|
486
515
|
}
|
|
516
|
+
const supportedSymbols = new Set(
|
|
517
|
+
Object.values(instance.secureAssets).map((asset) => asset.symbol)
|
|
518
|
+
);
|
|
487
519
|
const spotOptions = lighterAssets.filter(
|
|
488
|
-
(asset) => !(isUnifiedTradingMode && asset.symbol.toUpperCase() ===
|
|
520
|
+
(asset) => supportedSymbols.has(asset.symbol.toUpperCase()) && !(isUnifiedTradingMode && asset.symbol.toUpperCase() === collateral)
|
|
489
521
|
).map((asset) => {
|
|
490
|
-
if (asset.symbol.toUpperCase() ===
|
|
522
|
+
if (asset.symbol.toUpperCase() === collateral) {
|
|
491
523
|
return {
|
|
492
|
-
symbol:
|
|
493
|
-
label:
|
|
494
|
-
iconSrc: getTokenIconUrl(
|
|
524
|
+
symbol: `${collateral} (Spot)`,
|
|
525
|
+
label: `${collateral} (Spot)`,
|
|
526
|
+
iconSrc: getTokenIconUrl(collateral)
|
|
495
527
|
};
|
|
496
528
|
}
|
|
497
529
|
return {
|
|
@@ -500,7 +532,7 @@ function buildLighterSourceTokenOptions({
|
|
|
500
532
|
iconSrc: getTokenIconUrl(asset.symbol)
|
|
501
533
|
};
|
|
502
534
|
});
|
|
503
|
-
return [
|
|
535
|
+
return [perpsOption, ...spotOptions];
|
|
504
536
|
}
|
|
505
537
|
function buildLighterFastWalletWithdrawalConfig({
|
|
506
538
|
signerClient,
|
|
@@ -510,18 +542,20 @@ function buildLighterFastWalletWithdrawalConfig({
|
|
|
510
542
|
iconSrc,
|
|
511
543
|
onBeforeSign,
|
|
512
544
|
isUnifiedTradingMode,
|
|
513
|
-
withdrawalSourceTokenBalance
|
|
545
|
+
withdrawalSourceTokenBalance,
|
|
546
|
+
chainId
|
|
514
547
|
}) {
|
|
515
548
|
const adaptedWallet = createLighterAdaptedWallet({
|
|
516
549
|
signerClient,
|
|
517
550
|
accountIndex,
|
|
518
|
-
logger
|
|
551
|
+
logger,
|
|
552
|
+
chainId
|
|
519
553
|
});
|
|
520
554
|
const wallet = {
|
|
521
555
|
_type: "lighter",
|
|
522
556
|
adaptedWallet,
|
|
523
557
|
address: () => String(accountIndex),
|
|
524
|
-
getChainId: async () =>
|
|
558
|
+
getChainId: async () => chainId,
|
|
525
559
|
// biome-ignore lint/suspicious/noEmptyBlockStatements: no-op — Lighter has no EVM chain switching
|
|
526
560
|
switchChain: async () => {
|
|
527
561
|
},
|
|
@@ -537,12 +571,13 @@ function buildLighterFastWalletWithdrawalConfig({
|
|
|
537
571
|
disableConnectedWallet,
|
|
538
572
|
onBeforeSign,
|
|
539
573
|
wallet,
|
|
540
|
-
sourceChainId:
|
|
541
|
-
sourceTokenSymbol:
|
|
574
|
+
sourceChainId: String(chainId),
|
|
575
|
+
sourceTokenSymbol: LIGHTER_INSTANCES2[chainId].perpsCollateral.symbol,
|
|
542
576
|
sourceTokens: buildLighterSourceTokenOptions({
|
|
543
577
|
isSecure: false,
|
|
544
578
|
lighterAssets: [],
|
|
545
|
-
isUnifiedTradingMode
|
|
579
|
+
isUnifiedTradingMode,
|
|
580
|
+
chainId
|
|
546
581
|
}),
|
|
547
582
|
withdrawalSourceTokenBalance,
|
|
548
583
|
defaultReceiveToken: "USDC",
|
|
@@ -552,6 +587,17 @@ function buildLighterFastWalletWithdrawalConfig({
|
|
|
552
587
|
getMaxWithdrawalUSD: () => LIGHTER_FAST_MAX_WITHDRAWAL_USD2
|
|
553
588
|
};
|
|
554
589
|
}
|
|
590
|
+
var LIGHTER_SECURE_DISCLAIMER = {
|
|
591
|
+
// Until the live value loads, show the localized "60+ minutes" historical
|
|
592
|
+
// estimate. The "+" lives in the per-locale fallback string so it doesn't
|
|
593
|
+
// bleed into live values, which are exact.
|
|
594
|
+
[LIGHTER_CHAIN_ID2]: (t, delay) => t("withdrawal.secureDisclaimer", {
|
|
595
|
+
delay: delay ?? t("withdrawal.secureFallbackDelay")
|
|
596
|
+
}),
|
|
597
|
+
// Mainnet's estimate would overstate RH's much shorter bridge delay, so RH
|
|
598
|
+
// omits the delay until the live value loads.
|
|
599
|
+
[LIGHTER_RH_CHAIN_ID]: (t, delay) => delay ? t("withdrawal.secureDisclaimerRobinhood", { delay }) : t("withdrawal.secureDisclaimerRobinhoodNoDelay")
|
|
600
|
+
};
|
|
555
601
|
var LIGHTER_FAST_PREVIEW_CHAIN_IDS = [
|
|
556
602
|
arbitrum.id,
|
|
557
603
|
base.id,
|
|
@@ -559,14 +605,14 @@ var LIGHTER_FAST_PREVIEW_CHAIN_IDS = [
|
|
|
559
605
|
bsc.id,
|
|
560
606
|
SOLANA_MAINNET_CHAIN_ID
|
|
561
607
|
].map(String);
|
|
562
|
-
var LIGHTER_SECURE_PREVIEW_CHAIN_IDS = [mainnet2.id].map(String);
|
|
563
608
|
function buildLighterMultiMethodConfig({
|
|
564
609
|
config,
|
|
565
610
|
accountIndex,
|
|
566
611
|
t,
|
|
567
612
|
secureDelayText,
|
|
568
613
|
isUnifiedTradingMode,
|
|
569
|
-
assets
|
|
614
|
+
assets,
|
|
615
|
+
chainId
|
|
570
616
|
}) {
|
|
571
617
|
const fastConfig = buildLighterFastWalletWithdrawalConfig({
|
|
572
618
|
signerClient: config.signerClient,
|
|
@@ -576,14 +622,17 @@ function buildLighterMultiMethodConfig({
|
|
|
576
622
|
iconSrc: config.fastIconSrc,
|
|
577
623
|
onBeforeSign: config.onBeforeSign,
|
|
578
624
|
isUnifiedTradingMode,
|
|
579
|
-
withdrawalSourceTokenBalance: config.withdrawalSourceTokenBalance
|
|
625
|
+
withdrawalSourceTokenBalance: config.withdrawalSourceTokenBalance,
|
|
626
|
+
chainId
|
|
580
627
|
});
|
|
581
628
|
const secureConfig = createLighterSecureWithdrawalConfig({
|
|
582
629
|
accountIndex,
|
|
630
|
+
chainId,
|
|
583
631
|
sourceTokens: buildLighterSourceTokenOptions({
|
|
584
632
|
isSecure: true,
|
|
585
633
|
lighterAssets: assets,
|
|
586
|
-
isUnifiedTradingMode
|
|
634
|
+
isUnifiedTradingMode,
|
|
635
|
+
chainId
|
|
587
636
|
}),
|
|
588
637
|
withdrawalSourceTokenBalance: config.withdrawalSourceTokenBalance,
|
|
589
638
|
modalTitle: config.modalTitle,
|
|
@@ -596,13 +645,17 @@ function buildLighterMultiMethodConfig({
|
|
|
596
645
|
if (userMin !== void 0) {
|
|
597
646
|
return userMin;
|
|
598
647
|
}
|
|
599
|
-
return
|
|
648
|
+
return getLighterDefaultSecureMinWithdrawalAmounts(chainId)[getLighterBaseSymbol3(symbol).toUpperCase()] ?? 0;
|
|
600
649
|
}
|
|
601
650
|
});
|
|
602
651
|
const fast = {
|
|
603
652
|
id: LIGHTER_FAST_METHOD_ID,
|
|
604
653
|
keyText: t("withdrawal.methodFast"),
|
|
605
|
-
subtitleText: isUnifiedTradingMode ? t("withdrawal.fastDisclaimerUnified"
|
|
654
|
+
subtitleText: isUnifiedTradingMode ? t("withdrawal.fastDisclaimerUnified", {
|
|
655
|
+
symbol: LIGHTER_INSTANCES2[chainId].perpsCollateral.symbol
|
|
656
|
+
}) : t("withdrawal.fastDisclaimer", {
|
|
657
|
+
symbol: LIGHTER_INSTANCES2[chainId].perpsCollateral.symbol
|
|
658
|
+
}),
|
|
606
659
|
icon: /* @__PURE__ */ React7.createElement(EvmWallet, { size: 20 }),
|
|
607
660
|
valueIcon: /* @__PURE__ */ React7.createElement(SupportedChainList, { chainIdList: LIGHTER_FAST_PREVIEW_CHAIN_IDS }),
|
|
608
661
|
config: fastConfig
|
|
@@ -610,32 +663,39 @@ function buildLighterMultiMethodConfig({
|
|
|
610
663
|
const secure = {
|
|
611
664
|
id: LIGHTER_SECURE_METHOD_ID,
|
|
612
665
|
keyText: t("withdrawal.methodSecure"),
|
|
613
|
-
subtitleText: t
|
|
614
|
-
// Until the live value loads, show the localized "60+ minutes"
|
|
615
|
-
// historical estimate. The "+" lives in the per-locale fallback string
|
|
616
|
-
// so it doesn't bleed into live values, which are exact.
|
|
617
|
-
delay: secureDelayText ?? t("withdrawal.secureFallbackDelay")
|
|
618
|
-
}),
|
|
666
|
+
subtitleText: LIGHTER_SECURE_DISCLAIMER[chainId](t, secureDelayText),
|
|
619
667
|
icon: /* @__PURE__ */ React7.createElement(EvmWallet, { size: 20 }),
|
|
620
|
-
valueIcon: /* @__PURE__ */ React7.createElement(
|
|
668
|
+
valueIcon: /* @__PURE__ */ React7.createElement(
|
|
669
|
+
SupportedChainList,
|
|
670
|
+
{
|
|
671
|
+
chainIdList: [LIGHTER_INSTANCES2[chainId].secureL1Chain.id.toString()]
|
|
672
|
+
}
|
|
673
|
+
),
|
|
621
674
|
config: secureConfig
|
|
622
675
|
};
|
|
623
676
|
return {
|
|
624
677
|
modalTitle: config.modalTitle ?? t("withdrawal.withdraw"),
|
|
625
678
|
sectionTitle: t("withdrawal.sectionCrypto"),
|
|
626
|
-
methods: [fast, secure]
|
|
679
|
+
methods: LIGHTER_INSTANCES2[chainId].supportsSecure ? [fast, secure] : [fast]
|
|
627
680
|
};
|
|
628
681
|
}
|
|
629
682
|
function useLighterWithdrawalConfig(config) {
|
|
630
683
|
const { t } = useFunkitTranslation();
|
|
631
|
-
const
|
|
632
|
-
const
|
|
684
|
+
const chainId = config?.chainId ?? LIGHTER_CHAIN_ID2;
|
|
685
|
+
const { mainAccountIndex: accountIndex, isUnifiedTradingMode } = useLighterAccountsQuery({
|
|
686
|
+
address: config?.l1Address,
|
|
687
|
+
chainId
|
|
688
|
+
});
|
|
689
|
+
const secureDelayText = useLighterSecureDelayText(
|
|
690
|
+
LIGHTER_INSTANCES2[chainId].supportsSecure,
|
|
691
|
+
chainId
|
|
692
|
+
);
|
|
633
693
|
const { account } = useLighterAccountQuery(
|
|
634
694
|
// The query validates it as numeric, so the template-literal narrowing holds.
|
|
635
|
-
accountIndex ? { by: "index", value: accountIndex } : null
|
|
695
|
+
accountIndex ? { by: "index", value: accountIndex, chainId } : null
|
|
636
696
|
);
|
|
637
697
|
const assets = useMemo3(() => account?.assets ?? [], [account]);
|
|
638
|
-
|
|
698
|
+
const multiMethodConfig = useMemo3(() => {
|
|
639
699
|
if (!config || !accountIndex) {
|
|
640
700
|
return null;
|
|
641
701
|
}
|
|
@@ -645,9 +705,30 @@ function useLighterWithdrawalConfig(config) {
|
|
|
645
705
|
t,
|
|
646
706
|
secureDelayText,
|
|
647
707
|
isUnifiedTradingMode,
|
|
648
|
-
assets
|
|
708
|
+
assets,
|
|
709
|
+
chainId
|
|
649
710
|
});
|
|
650
|
-
}, [
|
|
711
|
+
}, [
|
|
712
|
+
config,
|
|
713
|
+
accountIndex,
|
|
714
|
+
t,
|
|
715
|
+
secureDelayText,
|
|
716
|
+
isUnifiedTradingMode,
|
|
717
|
+
assets,
|
|
718
|
+
chainId
|
|
719
|
+
]);
|
|
720
|
+
const methodIds = multiMethodConfig?.methods.map((method) => method.id);
|
|
721
|
+
useLogOnce2(
|
|
722
|
+
methodIds ? `${chainId}|${accountIndex}|${methodIds.join(",")}` : void 0,
|
|
723
|
+
() => {
|
|
724
|
+
logger.info("lighter:withdrawal:instance", {
|
|
725
|
+
chainId,
|
|
726
|
+
accountIndex,
|
|
727
|
+
methodIds
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
);
|
|
731
|
+
return multiMethodConfig;
|
|
651
732
|
}
|
|
652
733
|
export {
|
|
653
734
|
LIGHTER_ROUTE_TYPE3 as LIGHTER_ROUTE_TYPE,
|
package/dist/clients/mallard.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
useFunkitTranslation
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-LVR6RQMO.js";
|
|
5
5
|
import {
|
|
6
6
|
getAccount,
|
|
7
7
|
sendTransaction,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
useAccount,
|
|
15
15
|
useConfig
|
|
16
16
|
} from "./chunk-2W2P3OS6.js";
|
|
17
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-2L6IKKNH.js";
|
|
18
18
|
import {
|
|
19
19
|
logger
|
|
20
20
|
} from "./chunk-AHYOV7AV.js";
|
package/dist/clients/nado.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
createNadoWithdrawalCallback
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-BKK2BFIP.js";
|
|
4
|
+
} from "./chunk-TWP5LFPX.js";
|
|
6
5
|
import "./chunk-4DBUYTEE.js";
|
|
6
|
+
import "./chunk-V4RIF2NR.js";
|
|
7
7
|
import "./chunk-OODIKHYE.js";
|
|
8
8
|
import {
|
|
9
9
|
useAccount,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "./chunk-2W2P3OS6.js";
|
|
12
12
|
import {
|
|
13
13
|
i18n_default
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-2L6IKKNH.js";
|
|
15
15
|
import "./chunk-TKEBGMVW.js";
|
|
16
16
|
import {
|
|
17
17
|
logger
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type LighterChainId } from '@funkit/chains';
|
|
1
2
|
import type { FunkitCheckoutConfig } from '../providers/FunkitCheckoutContext';
|
|
2
3
|
export declare function isPolymarketCustomer(apiKey: string): boolean;
|
|
3
4
|
export declare function isOstiumCustomer(apiKey: string): apiKey is "SMbBD7DS9b3EPcyBVg4a8az1rRWR9xB068chHoUN";
|
|
@@ -8,7 +9,17 @@ export declare function isMonkeyTiltCustomer(apiKey: string): apiKey is "2SrxurU
|
|
|
8
9
|
export declare function isBasedCustomer(apiKey: string): apiKey is "clDebbfo9edXq1GydZ0CahSAfSimPj616lFa9p8e";
|
|
9
10
|
export declare function isAvantisCustomer(apiKey: string): apiKey is "6TUi99Tq3O9MWj1IFX8Pv6spmPXzcvhy9NvBoeW2";
|
|
10
11
|
export declare function isPerplCustomer(apiKey: string): apiKey is "wQDLu86Qab61vbtru7thf8Yj0xaeqVUH4ohoXESu";
|
|
11
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Each Lighter instance is its own Fun customer. A key only ever reaches its
|
|
14
|
+
* own instance: accounts and indexes differ per instance.
|
|
15
|
+
*/
|
|
16
|
+
export declare const LIGHTER_API_KEY_BY_CHAIN_ID: Record<LighterChainId, string>;
|
|
17
|
+
/** The Lighter instance a key belongs to; undefined for non-Lighter keys. */
|
|
18
|
+
export declare function resolveLighterCustomerChainId(apiKey: string): LighterChainId | undefined;
|
|
19
|
+
/** Either Lighter instance's key: shared Lighter UI applies to both. */
|
|
20
|
+
export declare function isLighterxyzCustomer(apiKey: string): boolean;
|
|
21
|
+
/** The key of Lighter's Robinhood instance (customer q1aj098ygl). */
|
|
22
|
+
export declare function isLighterRhCustomer(apiKey: string): boolean;
|
|
12
23
|
export declare function isFanaticsCustomer(apiKey: string): apiKey is "lI7amueGK94QtGa7sGGVf8n0XhIcn4sHFAZRu5Jj";
|
|
13
24
|
export declare function isAaveCustomer(apiKey: string): apiKey is "EWzSv8tWnQ7UcZ2IsDqFw1dYo3Df56FX6KBJ5ztS";
|
|
14
25
|
export declare function isNadoCustomer(apiKey: string): apiKey is "iFwbI36PWs6egzqjemCVz8PRmDwaANr51WtaARhV";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { GetSupportedAssetsResponse, SupportedAssetInfo } from '@funkit/api-base';
|
|
2
|
+
import type { Config } from '../../wagmi/hooks';
|
|
3
|
+
import type { ConvertAsset, ConvertResolvedAsset } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Looks a host-listed token up in the supported-assets list. Hosts key every
|
|
6
|
+
* native asset by the `NATIVE_TOKEN` placeholder, but the list keys Hypercore's
|
|
7
|
+
* under Relay's id, so a placeholder miss retries with the Relay key.
|
|
8
|
+
*/
|
|
9
|
+
export declare function findSupportedAsset(supportedAssets: GetSupportedAssetsResponse, chainId: string, address: string): SupportedAssetInfo | undefined;
|
|
10
|
+
/** Host icon, then the asset list's, then the symbol default. */
|
|
11
|
+
export declare function resolveConvertAssetIcon(asset: ConvertAsset, supportedAssetLogo: string | undefined): string;
|
|
12
|
+
/**
|
|
13
|
+
* Resolves decimals and an icon for every host-listed asset. The supported
|
|
14
|
+
* list answers synchronously; a token it lacks falls back to the SDK's usual
|
|
15
|
+
* decimals lookup (on-chain, then Relay), in parallel across misses. A token
|
|
16
|
+
* neither can resolve is left out, never given guessed decimals.
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolveConvertAssets({ assets, supportedAssets, wagmiConfig, }: {
|
|
19
|
+
assets: ConvertAsset[];
|
|
20
|
+
supportedAssets: GetSupportedAssetsResponse;
|
|
21
|
+
wagmiConfig: Config;
|
|
22
|
+
}): Promise<ConvertResolvedAsset[]>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ConvertAssetBalance, ConvertResolvedAsset, GetConvertBalances } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* One spelling per token address.
|
|
4
|
+
* - EVM: checksummed; the asset list is checksummed and hosts send lowercase.
|
|
5
|
+
* - Solana: as-is; base58 is case-sensitive.
|
|
6
|
+
* - Anything else (Hypercore's `0x` + 32-zero placeholder): lowercase.
|
|
7
|
+
*/
|
|
8
|
+
export declare function normalizeTokenAddress(chainId: string, tokenAddress: string): string;
|
|
9
|
+
/** The key one asset's balance is stored under. */
|
|
10
|
+
export declare function convertBalanceKey(chainId: string, address: string): string;
|
|
11
|
+
export type ConvertBalanceState = {
|
|
12
|
+
status: 'available';
|
|
13
|
+
baseUnits: string;
|
|
14
|
+
} | {
|
|
15
|
+
status: 'unavailable';
|
|
16
|
+
};
|
|
17
|
+
/** One entry per listed asset, keyed by {@link convertBalanceKey}. */
|
|
18
|
+
export type ConvertBalances = Record<string, ConvertBalanceState>;
|
|
19
|
+
/**
|
|
20
|
+
* Turns the host's asset balances into one state per listed asset. An asset
|
|
21
|
+
* the host left out, or returned malformed, is unavailable; it never becomes
|
|
22
|
+
* 0. Balances for assets that weren't requested are ignored.
|
|
23
|
+
*/
|
|
24
|
+
export declare function parseConvertBalances({ assets, assetBalances, }: {
|
|
25
|
+
assets: ConvertResolvedAsset[];
|
|
26
|
+
assetBalances: ConvertAssetBalance[];
|
|
27
|
+
}): ConvertBalances;
|
|
28
|
+
/**
|
|
29
|
+
* Calls the host getter and parses its result. A throw is logged and
|
|
30
|
+
* rethrown so the query keeps the last good read instead of replacing it.
|
|
31
|
+
*/
|
|
32
|
+
export declare function fetchConvertBalances({ assets, getBalances, }: {
|
|
33
|
+
assets: ConvertResolvedAsset[];
|
|
34
|
+
getBalances: GetConvertBalances;
|
|
35
|
+
}): Promise<ConvertBalances>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ConvertSubmitPreparation } from './submit';
|
|
2
|
+
import type { ConvertConfig, ConvertErrorResult } from './types';
|
|
3
|
+
/** Why the source leg failed, for copy and for whether to retry. */
|
|
4
|
+
export type ConvertSourceErrorReason = 'userRejected' | 'switchChain' | 'insufficientGas'
|
|
5
|
+
/** The transaction outlived its blockhash; it never landed, so re-sign. */
|
|
6
|
+
| 'blockhashExpired'
|
|
7
|
+
/** The wallet or RPC simulated the transaction and it would fail. */
|
|
8
|
+
| 'simulationFailed' | 'insufficientSol' | 'generic';
|
|
9
|
+
/**
|
|
10
|
+
* The shared wallet mapping, plus the Solana failures it doesn't know. Meant
|
|
11
|
+
* for failures before funds moved, after which the user can convert again.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getConvertSourceErrorReason(error: unknown): ConvertSourceErrorReason;
|
|
14
|
+
/** Every way a conversion can stop, from the pre-sign check to settlement. */
|
|
15
|
+
export type ConvertFailure = {
|
|
16
|
+
stage: 'preSign';
|
|
17
|
+
preparation: Extract<ConvertSubmitPreparation, {
|
|
18
|
+
status: 'blocked';
|
|
19
|
+
}>;
|
|
20
|
+
} | {
|
|
21
|
+
stage: 'source';
|
|
22
|
+
error: unknown;
|
|
23
|
+
}
|
|
24
|
+
/** Funds may have moved but the deposit could not be tracked. */
|
|
25
|
+
| {
|
|
26
|
+
stage: 'unknown';
|
|
27
|
+
error: unknown;
|
|
28
|
+
} | {
|
|
29
|
+
stage: 'settlement';
|
|
30
|
+
error: unknown;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* The host's `onError` payload for a failure, or `undefined` for a block the
|
|
34
|
+
* user fixes on screen (balance, fee reserve, missing quote), which the host
|
|
35
|
+
* never needs to hear about.
|
|
36
|
+
*/
|
|
37
|
+
export declare function toConvertErrorResult(failure: ConvertFailure): ConvertErrorResult | undefined;
|
|
38
|
+
export declare function reportConvertError(failure: ConvertFailure, onError: ConvertConfig['onError']): void;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ConvertQuote } from './quote';
|
|
2
|
+
import type { ConvertSourceWallet } from './types';
|
|
3
|
+
/** What a finished source leg leaves behind for settlement tracking. */
|
|
4
|
+
export interface ConvertSubmissionIds {
|
|
5
|
+
/** The deposit's chain-native id: an EVM hash or a base58 Solana signature. */
|
|
6
|
+
sourceTxId: string;
|
|
7
|
+
/** Relay's route id, when the quote carries one. */
|
|
8
|
+
requestId: string | undefined;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A source leg that failed. `submitted` says whether a transaction other than
|
|
12
|
+
* an approval was already sent: before that, nothing moved and the user can
|
|
13
|
+
* convert again; after it, the funds may be in flight and must be tracked.
|
|
14
|
+
*/
|
|
15
|
+
export declare class ConvertExecutionError extends Error {
|
|
16
|
+
readonly submitted: boolean;
|
|
17
|
+
readonly sourceTxId: string | undefined;
|
|
18
|
+
readonly error: unknown;
|
|
19
|
+
constructor({ error, submitted, sourceTxId, }: {
|
|
20
|
+
error: unknown;
|
|
21
|
+
submitted: boolean;
|
|
22
|
+
sourceTxId?: string;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export declare function getConvertRequestId(quote: ConvertQuote): string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Runs the quote's source steps through the host's wallet and resolves once
|
|
28
|
+
* the user has nothing left to sign, with the deposit's id. Settlement is
|
|
29
|
+
* tracked separately; a resolved source leg is not a finished conversion.
|
|
30
|
+
*
|
|
31
|
+
* Throws {@link ConvertExecutionError}, which says whether funds may have moved.
|
|
32
|
+
*/
|
|
33
|
+
export declare function executeConvertQuote({ quote, sourceChainId, sourceWallet, onStepMessage, }: {
|
|
34
|
+
quote: ConvertQuote;
|
|
35
|
+
sourceChainId: string;
|
|
36
|
+
sourceWallet: ConvertSourceWallet;
|
|
37
|
+
/** Relay's raw step text, for logs or an optional status line. */
|
|
38
|
+
onStepMessage?: (message: string) => void;
|
|
39
|
+
}): Promise<ConvertSubmissionIds>;
|