@funkit/connect 10.3.0 → 10.5.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 +46 -0
- package/dist/clients/chunk-2YWQL3AO.js +46 -0
- package/dist/clients/chunk-A4WQS6QG.js +207 -0
- package/dist/clients/chunk-BNMZM23Q.js +42 -0
- package/dist/clients/{chunk-HOORQPSY.js → chunk-F6P4CN27.js} +24 -8
- package/dist/clients/chunk-FJ6GCMJ4.js +29 -0
- package/dist/clients/chunk-II5CZTBC.js +18 -0
- package/dist/clients/chunk-L2KSNS7H.js +112 -0
- package/dist/clients/chunk-OZ3KD24N.js +107 -0
- package/dist/clients/{chunk-3STGJU6Z.js → chunk-QHS5N7GP.js} +2 -2
- package/dist/clients/{chunk-RWCJ4XGX.js → chunk-WRS7AFM2.js} +31 -2
- package/dist/clients/fanatics.js +1 -1
- package/dist/clients/internal/nado/consts.d.ts +16 -0
- package/dist/clients/internal/nado/consts.js +13 -0
- package/dist/clients/internal/nado/encoding.d.ts +22 -0
- package/dist/clients/internal/nado/encoding.js +32 -0
- package/dist/clients/internal/nado/errors.d.ts +55 -0
- package/dist/clients/internal/nado/errors.js +15 -0
- package/dist/clients/internal/nado/fetch.d.ts +15 -0
- package/dist/clients/internal/nado/fetch.js +9 -0
- package/dist/clients/internal/nado/gateway.d.ts +83 -0
- package/dist/clients/internal/nado/gateway.js +23 -0
- package/dist/clients/internal/nado/hooks.d.ts +360 -0
- package/dist/clients/internal/nado/hooks.js +132 -0
- package/dist/clients/internal/nado/indexer.d.ts +43 -0
- package/dist/clients/internal/nado/indexer.js +13 -0
- package/dist/clients/internal/nado/products.d.ts +36 -0
- package/dist/clients/internal/nado/products.js +19 -0
- package/dist/clients/internal/nado/typedData.d.ts +80 -0
- package/dist/clients/internal/nado/typedData.js +43 -0
- package/dist/clients/internal/nado/withdrawalConfig.d.ts +11 -0
- package/dist/clients/internal/nado/withdrawalConfig.js +17 -0
- package/dist/clients/internal/nado/withdrawalTypes.d.ts +30 -0
- package/dist/clients/internal/nado/withdrawalTypes.js +1 -0
- package/dist/clients/lighter.d.ts +1 -0
- package/dist/clients/lighter.js +202 -57
- package/dist/clients/mallard.js +9 -24
- package/dist/clients/polymarket/PolymarketDepositAccountDropdown.js +3 -3
- package/dist/clients/polymarket/index.js +3 -3
- package/dist/components/ChainIcon/ChainIcon.d.ts +16 -0
- package/dist/components/FreeUsdcBanner/FreeUsdcBanner.d.ts +1 -1
- package/dist/components/FunAssetAvatar/FunAssetAvatar.d.ts +1 -2
- package/dist/hooks/useChainMetadata.d.ts +11 -0
- package/dist/hooks/useCheckoutDirectExecutionHistory.d.ts +2 -1
- package/dist/hooks/usePaymentMethodTabs.d.ts +8 -2
- package/dist/hooks/useSwappedIframeLifecycle.d.ts +5 -2
- package/dist/hooks/useSwappedPreload.d.ts +7 -11
- package/dist/hooks/useUserIpInfo.d.ts +1 -19
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3700 -3299
- package/dist/modals/CheckoutModal/SourceChange/SourceChange.d.ts +3 -0
- package/dist/modals/CheckoutModal/SwappedIframe/SwappedIframe.d.ts +4 -1
- package/dist/modals/CheckoutModal/SwappedIframe/SwappedIframeController.d.ts +3 -0
- package/dist/modals/CheckoutModal/isWithdrawalStep.d.ts +3 -2
- package/dist/modals/WithdrawalModal/LighterWithdrawal.d.ts +46 -2
- package/dist/modals/WithdrawalModal/useFiatWithdrawal.d.ts +1 -1
- package/dist/modals/WithdrawalModal/useWithdrawal.d.ts +3 -15
- package/dist/providers/FunkitCheckoutContext/types.d.ts +73 -14
- package/dist/providers/FunkitConfigContext.d.ts +11 -0
- package/dist/providers/GeneralWalletProvider.d.ts +1 -4
- package/dist/providers/SwappedProvider.d.ts +5 -3
- package/dist/utils/lighter.d.ts +68 -1
- package/dist/utils/purifyCheckoutHistoryItem.d.ts +2 -41
- package/dist/utils/swapped.d.ts +1 -1
- package/dist/utils/tokenIconUrl.d.ts +5 -0
- package/dist/utils/userInfo.d.ts +8 -0
- package/dist/utils/withdrawal.d.ts +2 -1
- package/dist/wagmi/actions.d.ts +1 -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 +33 -33
- 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 -2
- package/dist/hooks/useSkipSwappedPreload.d.ts +0 -7
- package/dist/wallets/walletConnectors/{chunk-W2LCLDPX.js → chunk-2VP2F6EK.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-IULPZP2Q.js → chunk-4T6ZSRJF.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-WAHGI5L7.js → chunk-6BW3HLBG.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-YO2K4MBH.js → chunk-CCQV2ZET.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-TKB2OY6G.js → chunk-CPI4TD43.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-OX37G4YT.js → chunk-F5XEEVG6.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-JPN6TWIT.js → chunk-HNRB7KJU.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-WKNQMP4A.js → chunk-HTHAK6XB.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-GUQM4QSL.js → chunk-MIQTHJ6X.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-4NV5BYRP.js → chunk-RB3HR4R2.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-SWFF3TWJ.js → chunk-RVOY537T.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-KI5Y2BBF.js → chunk-STVVP43G.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-OEEGYENV.js → chunk-UK7C2JXW.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-YQFGVZGR.js → chunk-VAPGUPHO.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-XCNHV3HS.js → chunk-VTM6EECM.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-NR2OGDHQ.js → chunk-X6CGV36L.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-AVDUNQUW.js → chunk-YEZM4CK4.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-KCRO2AGO.js → chunk-ZNX4EMPB.js} +3 -3
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
NADO_GATEWAY_URL
|
|
4
|
+
} from "./chunk-II5CZTBC.js";
|
|
5
|
+
import {
|
|
6
|
+
nadoFetch
|
|
7
|
+
} from "./chunk-L2KSNS7H.js";
|
|
8
|
+
import {
|
|
9
|
+
NadoGatewayError,
|
|
10
|
+
createNadoGatewayError,
|
|
11
|
+
isNadoTransportError
|
|
12
|
+
} from "./chunk-2YWQL3AO.js";
|
|
13
|
+
|
|
14
|
+
// src/clients/internal/nado/gateway.ts
|
|
15
|
+
function parseNadoGatewayResponse(response) {
|
|
16
|
+
if (response.status !== "success") {
|
|
17
|
+
throw createNadoGatewayError(response, "Nado gateway request failed");
|
|
18
|
+
}
|
|
19
|
+
return response.data;
|
|
20
|
+
}
|
|
21
|
+
async function nadoQuery(params, signal) {
|
|
22
|
+
const response = await nadoFetch({
|
|
23
|
+
uri: `${NADO_GATEWAY_URL}/query?${new URLSearchParams(params)}`,
|
|
24
|
+
method: "GET",
|
|
25
|
+
signal
|
|
26
|
+
});
|
|
27
|
+
const data = parseNadoGatewayResponse(response);
|
|
28
|
+
if (data === void 0) {
|
|
29
|
+
throw new NadoGatewayError("Nado returned success without data", {
|
|
30
|
+
kind: "api"
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
async function getNadoMaxWithdrawable(params, signal) {
|
|
36
|
+
const data = await nadoQuery(
|
|
37
|
+
{
|
|
38
|
+
type: "max_withdrawable",
|
|
39
|
+
product_id: params.productId.toString(),
|
|
40
|
+
sender: params.sender,
|
|
41
|
+
spot_leverage: params.spotLeverage ? "true" : "false"
|
|
42
|
+
},
|
|
43
|
+
signal
|
|
44
|
+
);
|
|
45
|
+
return data.max_withdrawable;
|
|
46
|
+
}
|
|
47
|
+
async function getNadoTxNonce(address) {
|
|
48
|
+
const query = () => nadoQuery({ type: "nonces", address });
|
|
49
|
+
let data;
|
|
50
|
+
try {
|
|
51
|
+
data = await query();
|
|
52
|
+
} catch (error) {
|
|
53
|
+
if (!isNadoTransportError(error)) {
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
data = await query();
|
|
57
|
+
}
|
|
58
|
+
return BigInt(data.tx_nonce);
|
|
59
|
+
}
|
|
60
|
+
async function getNadoFeeRates(sender, signal) {
|
|
61
|
+
return nadoQuery({ type: "fee_rates", sender }, signal);
|
|
62
|
+
}
|
|
63
|
+
async function getNadoSubaccountInfo(subaccount, signal) {
|
|
64
|
+
return nadoQuery(
|
|
65
|
+
{ type: "subaccount_info", subaccount },
|
|
66
|
+
signal
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
async function getNadoAllProducts(signal) {
|
|
70
|
+
return nadoQuery({ type: "all_products" }, signal);
|
|
71
|
+
}
|
|
72
|
+
async function getNadoSymbols(signal) {
|
|
73
|
+
return nadoQuery({ type: "symbols" }, signal);
|
|
74
|
+
}
|
|
75
|
+
async function executeNadoWithdrawCollateralV2(params) {
|
|
76
|
+
const response = await nadoFetch({
|
|
77
|
+
uri: `${NADO_GATEWAY_URL}/execute`,
|
|
78
|
+
method: "POST",
|
|
79
|
+
body: {
|
|
80
|
+
// spot_leverage sits INSIDE the execute object (sibling of tx/signature),
|
|
81
|
+
// matching @nadohq's EngineBaseClient — top-level is silently ignored.
|
|
82
|
+
withdraw_collateral_v2: {
|
|
83
|
+
tx: {
|
|
84
|
+
sender: params.sender,
|
|
85
|
+
productId: params.productId,
|
|
86
|
+
amount: params.amount.toString(),
|
|
87
|
+
nonce: params.nonce.toString(),
|
|
88
|
+
sendTo: params.sendTo,
|
|
89
|
+
appendix: "0"
|
|
90
|
+
},
|
|
91
|
+
signature: params.signature,
|
|
92
|
+
spot_leverage: params.spotLeverage
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
parseNadoGatewayResponse(response);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export {
|
|
100
|
+
getNadoMaxWithdrawable,
|
|
101
|
+
getNadoTxNonce,
|
|
102
|
+
getNadoFeeRates,
|
|
103
|
+
getNadoSubaccountInfo,
|
|
104
|
+
getNadoAllProducts,
|
|
105
|
+
getNadoSymbols,
|
|
106
|
+
executeNadoWithdrawCollateralV2
|
|
107
|
+
};
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
FunInput,
|
|
4
4
|
FunSkeletonBlock,
|
|
5
5
|
TooltipAnchorRefContext
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-WRS7AFM2.js";
|
|
7
7
|
import {
|
|
8
8
|
Box,
|
|
9
9
|
Text,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "./chunk-LUHEVXPD.js";
|
|
12
12
|
import {
|
|
13
13
|
useFunkitTranslation
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-F6P4CN27.js";
|
|
15
15
|
import {
|
|
16
16
|
POLYMARKET_PERPS_ROUTING_ID,
|
|
17
17
|
POLYMARKET_PREDICTIONS_ROUTING_ID
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-LUHEVXPD.js";
|
|
7
7
|
import {
|
|
8
8
|
useFunkitTranslation
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-F6P4CN27.js";
|
|
10
10
|
|
|
11
11
|
// src/providers/FunkitConfigContext.tsx
|
|
12
12
|
import {
|
|
@@ -46,6 +46,7 @@ var DEFAULT_UI_CUSTOMIZATIONS = {
|
|
|
46
46
|
simplifiedUi: false
|
|
47
47
|
},
|
|
48
48
|
confirmationScreen: {
|
|
49
|
+
autoExpandFeesSummary: false,
|
|
49
50
|
preferDestinationWhenSame: false,
|
|
50
51
|
showAmountSummaryAbovePaymentMethod: false,
|
|
51
52
|
showDisclaimerAsAlert: true,
|
|
@@ -79,7 +80,9 @@ var DEFAULT_UI_CUSTOMIZATIONS = {
|
|
|
79
80
|
transferCryptoScreen: {
|
|
80
81
|
showYouSendYouReceive: false
|
|
81
82
|
},
|
|
82
|
-
withdrawalScreen: {
|
|
83
|
+
withdrawalScreen: {
|
|
84
|
+
autoExpandFeesSummary: false
|
|
85
|
+
},
|
|
83
86
|
selectBrokerageScreen: {},
|
|
84
87
|
connectExchangeScreen: {},
|
|
85
88
|
customIcons: {},
|
|
@@ -1466,7 +1469,33 @@ var DecimalSpan = ({
|
|
|
1466
1469
|
children
|
|
1467
1470
|
);
|
|
1468
1471
|
|
|
1472
|
+
// src/providers/provideFunkitConnectChains.ts
|
|
1473
|
+
import { chainMetadataById } from "@funkit/chains";
|
|
1474
|
+
var groupChainsById = (chains) => {
|
|
1475
|
+
const chainsById = {};
|
|
1476
|
+
for (const chainItem of chains) {
|
|
1477
|
+
chainsById[chainItem.id] = chainItem;
|
|
1478
|
+
}
|
|
1479
|
+
return chainsById;
|
|
1480
|
+
};
|
|
1481
|
+
|
|
1482
|
+
// src/providers/FunkitConnectChainContext.tsx
|
|
1483
|
+
import React6, {
|
|
1484
|
+
createContext as createContext4,
|
|
1485
|
+
useContext as useContext4,
|
|
1486
|
+
useMemo as useMemo2
|
|
1487
|
+
} from "react";
|
|
1488
|
+
var FunkitConnectChainContext = createContext4(
|
|
1489
|
+
{
|
|
1490
|
+
chains: []
|
|
1491
|
+
}
|
|
1492
|
+
);
|
|
1493
|
+
var useFunkitConnectChains = () => useContext4(FunkitConnectChainContext).chains;
|
|
1494
|
+
var useFunkitConnectChainsById = () => groupChainsById(useFunkitConnectChains());
|
|
1495
|
+
|
|
1469
1496
|
export {
|
|
1497
|
+
chainMetadataById,
|
|
1498
|
+
useFunkitConnectChainsById,
|
|
1470
1499
|
useFunkitConfig,
|
|
1471
1500
|
TooltipAnchorRefContext,
|
|
1472
1501
|
FunSkeletonBlock,
|
package/dist/clients/fanatics.js
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nado deployment constants: prod endpoints and on-chain contract addresses.
|
|
3
|
+
*
|
|
4
|
+
* @see {@link https://docs.nado.xyz/developer-resources/api/endpoints | Nado API endpoints}
|
|
5
|
+
* @see {@link https://docs.nado.xyz/more/contracts | Nado contract addresses}
|
|
6
|
+
*/
|
|
7
|
+
/** Nado settles exclusively on Ink. */
|
|
8
|
+
export declare const INK_CHAIN_ID: 57073;
|
|
9
|
+
export declare const NADO_GATEWAY_URL = "https://gateway.prod.nado.xyz/v1";
|
|
10
|
+
export declare const NADO_INDEXER_URL = "https://archive.prod.nado.xyz/v1";
|
|
11
|
+
/**
|
|
12
|
+
* Nado's Endpoint contract on Ink. Never called by this flow — it's the
|
|
13
|
+
* EIP-712 domain `verifyingContract` both we and Nado's gateway hash
|
|
14
|
+
* signatures over (orders verify against the product address instead).
|
|
15
|
+
*/
|
|
16
|
+
export declare const NADO_EIP712_VERIFYING_CONTRACT_ADDRESS: `0x${string}`;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
INK_CHAIN_ID,
|
|
4
|
+
NADO_EIP712_VERIFYING_CONTRACT_ADDRESS,
|
|
5
|
+
NADO_GATEWAY_URL,
|
|
6
|
+
NADO_INDEXER_URL
|
|
7
|
+
} from "../../chunk-II5CZTBC.js";
|
|
8
|
+
export {
|
|
9
|
+
INK_CHAIN_ID,
|
|
10
|
+
NADO_EIP712_VERIFYING_CONTRACT_ADDRESS,
|
|
11
|
+
NADO_GATEWAY_URL,
|
|
12
|
+
NADO_INDEXER_URL
|
|
13
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nado wire encodings: bytes32 subaccount ids and x18 ↔ native-decimal
|
|
3
|
+
* amount scaling.
|
|
4
|
+
*
|
|
5
|
+
* @see {@link https://docs.nado.xyz/developer-resources/api/gateway/signing/examples | Nado signing examples}
|
|
6
|
+
* @see {@link https://docs.nado.xyz/developer-resources/api/gateway/queries#amounts-and-prices | Nado amounts & prices (x18 convention)}
|
|
7
|
+
*/
|
|
8
|
+
import { type Address, type Hex } from 'viem';
|
|
9
|
+
/**
|
|
10
|
+
* Nado subaccount id: 20-byte owner address ++ 12-byte ascii name,
|
|
11
|
+
* zero-padded right. Every wallet's primary subaccount is named `default`
|
|
12
|
+
* (auto-assigned on first interaction) — the empty name is a different subaccount.
|
|
13
|
+
*/
|
|
14
|
+
export declare function buildNadoSubaccountId(owner: Address, name?: string): Hex;
|
|
15
|
+
/**
|
|
16
|
+
* x18 query amount → raw base units. Floors — never rounds up — so a
|
|
17
|
+
* converted `max_withdrawable` can't exceed the true maximum. Same semantics
|
|
18
|
+
* as Nado's own frontend, which floors at submit (`BigNumber.ROUND_DOWN`).
|
|
19
|
+
*/
|
|
20
|
+
export declare function x18ToRawBaseUnit(x18Amount: string, decimals: number): bigint;
|
|
21
|
+
/** x18-scaled query amount → human token units, floored at native decimals. */
|
|
22
|
+
export declare function x18ToTokenUnits(x18Amount: string, decimals: number): string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/clients/internal/nado/encoding.ts
|
|
4
|
+
import {
|
|
5
|
+
concatHex,
|
|
6
|
+
formatUnits,
|
|
7
|
+
pad,
|
|
8
|
+
stringToHex
|
|
9
|
+
} from "viem";
|
|
10
|
+
var SUBACCOUNT_NAME_BYTES = 12;
|
|
11
|
+
var X18_DECIMALS = 18;
|
|
12
|
+
function buildNadoSubaccountId(owner, name = "default") {
|
|
13
|
+
const nameHex = stringToHex(name);
|
|
14
|
+
if ((nameHex.length - 2) / 2 > SUBACCOUNT_NAME_BYTES) {
|
|
15
|
+
throw new Error("Nado subaccount name must be 12 bytes or fewer");
|
|
16
|
+
}
|
|
17
|
+
return concatHex([
|
|
18
|
+
owner,
|
|
19
|
+
pad(nameHex, { dir: "right", size: SUBACCOUNT_NAME_BYTES })
|
|
20
|
+
]);
|
|
21
|
+
}
|
|
22
|
+
function x18ToRawBaseUnit(x18Amount, decimals) {
|
|
23
|
+
return BigInt(x18Amount) * 10n ** BigInt(decimals) / 10n ** BigInt(X18_DECIMALS);
|
|
24
|
+
}
|
|
25
|
+
function x18ToTokenUnits(x18Amount, decimals) {
|
|
26
|
+
return formatUnits(x18ToRawBaseUnit(x18Amount, decimals), decimals);
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
buildNadoSubaccountId,
|
|
30
|
+
x18ToRawBaseUnit,
|
|
31
|
+
x18ToTokenUnits
|
|
32
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nado gateway/indexer error type and the codes the SDK branches on.
|
|
3
|
+
*
|
|
4
|
+
* @see {@link https://docs.nado.xyz/developer-resources/api/errors | Nado error codes (full table)}
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Codes are shared across all Nado executes and queries, not just
|
|
8
|
+
* withdrawals — keep this module flow-agnostic.
|
|
9
|
+
*/
|
|
10
|
+
export declare const NADO_ERROR_CODES: {
|
|
11
|
+
/** Amount would open a borrow with `spot_leverage: "false"`. */
|
|
12
|
+
readonly SPOT_EXECUTE_EXCEEDS_BORROW_LIMIT: 2017;
|
|
13
|
+
/** Stale `tx_nonce` — refetch and retry once. */
|
|
14
|
+
readonly INVALID_NONCE: 2022;
|
|
15
|
+
/** Subaccount has never deposited, so it doesn't exist on Nado yet. */
|
|
16
|
+
readonly NO_PRIOR_DEPOSIT: 2024;
|
|
17
|
+
/** Withdrawal tx not found at the given submission index. */
|
|
18
|
+
readonly INVALID_WITHDRAWAL_IDX: 3004;
|
|
19
|
+
/** Fast-withdrawal validator signatures not aggregated yet. */
|
|
20
|
+
readonly NOT_ENOUGH_FAST_WITHDRAWAL_SIGNATURES: 3005;
|
|
21
|
+
/** Protocol 24h withdrawal limit exceeded. */
|
|
22
|
+
readonly WITHDRAW_RISK: 4004;
|
|
23
|
+
};
|
|
24
|
+
export type NadoErrorCode = (typeof NADO_ERROR_CODES)[keyof typeof NADO_ERROR_CODES];
|
|
25
|
+
/**
|
|
26
|
+
* Stamped at the throw site — retry logic must never infer the failure kind
|
|
27
|
+
* from which fields happen to be missing.
|
|
28
|
+
* - `api`: Nado answered `{status:'failure'}` (or a malformed success)
|
|
29
|
+
* - `http`: non-2xx response
|
|
30
|
+
* - `timeout`: our 30s backstop fired — the caller already waited
|
|
31
|
+
* - `transport`: request never completed (network drop, garbled body)
|
|
32
|
+
*/
|
|
33
|
+
export type NadoErrorKind = 'api' | 'http' | 'timeout' | 'transport';
|
|
34
|
+
/** A failed Nado gateway/indexer call, classified by `kind`. */
|
|
35
|
+
export declare class NadoGatewayError extends Error {
|
|
36
|
+
readonly kind: NadoErrorKind;
|
|
37
|
+
/** Nado's application error code — set only for `api`-kind failures. */
|
|
38
|
+
readonly errorCode: number | undefined;
|
|
39
|
+
/** HTTP status, kept for diagnostics (present on `http` and bad-JSON 2xx). */
|
|
40
|
+
readonly httpStatus: number | undefined;
|
|
41
|
+
constructor(message: string, options: {
|
|
42
|
+
kind: NadoErrorKind;
|
|
43
|
+
errorCode?: number;
|
|
44
|
+
httpStatus?: number;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/** Request never completed — safe to retry. Excludes timeouts: a retry after
|
|
48
|
+
* a 30s stall would hold the user another 30s. */
|
|
49
|
+
export declare function isNadoTransportError(error: unknown): boolean;
|
|
50
|
+
/** Maps a gateway/indexer failure response to a NadoGatewayError. */
|
|
51
|
+
export declare function createNadoGatewayError(response: {
|
|
52
|
+
error?: string;
|
|
53
|
+
error_code?: number;
|
|
54
|
+
}, fallbackMessage: string): NadoGatewayError;
|
|
55
|
+
export declare function isNadoErrorCode(error: unknown, code: NadoErrorCode): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
NADO_ERROR_CODES,
|
|
4
|
+
NadoGatewayError,
|
|
5
|
+
createNadoGatewayError,
|
|
6
|
+
isNadoErrorCode,
|
|
7
|
+
isNadoTransportError
|
|
8
|
+
} from "../../chunk-2YWQL3AO.js";
|
|
9
|
+
export {
|
|
10
|
+
NADO_ERROR_CODES,
|
|
11
|
+
NadoGatewayError,
|
|
12
|
+
createNadoGatewayError,
|
|
13
|
+
isNadoErrorCode,
|
|
14
|
+
isNadoTransportError
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native-fetch wrapper for Nado's gateway/indexer — outbound third-party
|
|
3
|
+
* calls that api-base's Fun-API-shaped `sendRequest` doesn't fit.
|
|
4
|
+
*/
|
|
5
|
+
export interface NadoFetchParams {
|
|
6
|
+
uri: string;
|
|
7
|
+
method: 'GET' | 'POST';
|
|
8
|
+
body?: object;
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Returns the parsed JSON body of a 2xx response; every other outcome throws
|
|
13
|
+
* NadoGatewayError. Emits one bounded log event per call.
|
|
14
|
+
*/
|
|
15
|
+
export declare function nadoFetch<T>(params: NadoFetchParams): Promise<T>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nado gateway client: the queries and the withdraw execute used by the
|
|
3
|
+
* withdrawal flow.
|
|
4
|
+
*
|
|
5
|
+
* Flow composition: `subaccount_info` / `max_withdrawable` / `fee_rates` feed
|
|
6
|
+
* the enter-amount screen → `nonces` immediately before signing → execute
|
|
7
|
+
* `withdraw_collateral_v2` with `sendTo` = the Fun deposit address → the
|
|
8
|
+
* indexer poll (indexer.ts) confirms sequencing, then checkout tracking
|
|
9
|
+
* takes over once funds arrive.
|
|
10
|
+
*
|
|
11
|
+
* @see {@link https://docs.nado.xyz/developer-resources/api/gateway | Nado gateway API}
|
|
12
|
+
*/
|
|
13
|
+
import type { Address, Hex } from 'viem';
|
|
14
|
+
/** Largest withdrawal (x18) that keeps the subaccount healthy. */
|
|
15
|
+
export declare function getNadoMaxWithdrawable(params: {
|
|
16
|
+
productId: number;
|
|
17
|
+
sender: Hex;
|
|
18
|
+
spotLeverage: boolean;
|
|
19
|
+
}, signal?: AbortSignal): Promise<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Current `tx_nonce` for the owner wallet — fetch immediately before signing.
|
|
22
|
+
* One manual retry on network failures only (imperative call site, no
|
|
23
|
+
* react-query retry layer above it).
|
|
24
|
+
*/
|
|
25
|
+
export declare function getNadoTxNonce(address: Address): Promise<bigint>;
|
|
26
|
+
export interface NadoFeeRates {
|
|
27
|
+
/** Withdraw sequencer fee per product (indexed by product_id), x18 token units. */
|
|
28
|
+
withdraw_sequencer_fees: string[];
|
|
29
|
+
}
|
|
30
|
+
export declare function getNadoFeeRates(sender: Hex, signal?: AbortSignal): Promise<NadoFeeRates>;
|
|
31
|
+
export interface NadoSpotBalance {
|
|
32
|
+
product_id: number;
|
|
33
|
+
/** x18-normalized; negative when the balance is a borrow. */
|
|
34
|
+
balance: {
|
|
35
|
+
amount: string;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export interface NadoSubaccountInfo {
|
|
39
|
+
/** False until the subaccount's first deposit lands on Nado. */
|
|
40
|
+
exists: boolean;
|
|
41
|
+
spot_balances: NadoSpotBalance[];
|
|
42
|
+
}
|
|
43
|
+
export declare function getNadoSubaccountInfo(subaccount: Hex, signal?: AbortSignal): Promise<NadoSubaccountInfo>;
|
|
44
|
+
export interface NadoSpotProduct {
|
|
45
|
+
product_id: number;
|
|
46
|
+
config: {
|
|
47
|
+
token: string;
|
|
48
|
+
/** Product-default withdraw sequencer fee, x18 token units. */
|
|
49
|
+
withdraw_fee_x18: string;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export declare function getNadoAllProducts(signal?: AbortSignal): Promise<{
|
|
53
|
+
spot_products: NadoSpotProduct[];
|
|
54
|
+
}>;
|
|
55
|
+
export interface NadoSymbolInfo {
|
|
56
|
+
type: 'spot' | 'perp';
|
|
57
|
+
product_id: number;
|
|
58
|
+
symbol: string;
|
|
59
|
+
trading_status: string;
|
|
60
|
+
}
|
|
61
|
+
/** Keyed by symbol. The quote asset (USDT0, product 0) is not included. */
|
|
62
|
+
export declare function getNadoSymbols(signal?: AbortSignal): Promise<{
|
|
63
|
+
symbols: Record<string, NadoSymbolInfo>;
|
|
64
|
+
}>;
|
|
65
|
+
export interface ExecuteWithdrawCollateralV2Params {
|
|
66
|
+
/** Subaccount id per Nado's spec (see `buildNadoSubaccountId`). */
|
|
67
|
+
sender: Hex;
|
|
68
|
+
productId: number;
|
|
69
|
+
/** Raw base units in the token's native decimals — not x18. */
|
|
70
|
+
amount: bigint;
|
|
71
|
+
nonce: bigint;
|
|
72
|
+
sendTo: Address;
|
|
73
|
+
signature: Hex;
|
|
74
|
+
/** Required so callers can't enable borrowing by omission — `false` fails
|
|
75
|
+
* the withdrawal instead of opening a borrow (Nado defaults absent to true). */
|
|
76
|
+
spotLeverage: boolean;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Submit a signed `withdraw_collateral_v2`; resolves on gateway acceptance,
|
|
80
|
+
* on-chain settlement follows asynchronously. Never retried — a retry could
|
|
81
|
+
* re-submit a consumed nonce and report failure for a successful withdrawal.
|
|
82
|
+
*/
|
|
83
|
+
export declare function executeNadoWithdrawCollateralV2(params: ExecuteWithdrawCollateralV2Params): Promise<void>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
executeNadoWithdrawCollateralV2,
|
|
4
|
+
getNadoAllProducts,
|
|
5
|
+
getNadoFeeRates,
|
|
6
|
+
getNadoMaxWithdrawable,
|
|
7
|
+
getNadoSubaccountInfo,
|
|
8
|
+
getNadoSymbols,
|
|
9
|
+
getNadoTxNonce
|
|
10
|
+
} from "../../chunk-OZ3KD24N.js";
|
|
11
|
+
import "../../chunk-II5CZTBC.js";
|
|
12
|
+
import "../../chunk-L2KSNS7H.js";
|
|
13
|
+
import "../../chunk-2YWQL3AO.js";
|
|
14
|
+
import "../../chunk-AHYOV7AV.js";
|
|
15
|
+
export {
|
|
16
|
+
executeNadoWithdrawCollateralV2,
|
|
17
|
+
getNadoAllProducts,
|
|
18
|
+
getNadoFeeRates,
|
|
19
|
+
getNadoMaxWithdrawable,
|
|
20
|
+
getNadoSubaccountInfo,
|
|
21
|
+
getNadoSymbols,
|
|
22
|
+
getNadoTxNonce
|
|
23
|
+
};
|