@funkit/connect 11.0.0 → 11.2.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 +71 -0
- package/dist/clients/chunk-2576N7PQ.js +44 -0
- package/dist/clients/{chunk-II5CZTBC.js → chunk-3P2C436B.js} +3 -1
- package/dist/clients/chunk-63XTVHO3.js +19 -0
- package/dist/clients/chunk-6QCAWEAT.js +53 -0
- package/dist/clients/{chunk-6CYZKITE.js → chunk-6T6URLBM.js} +1 -1
- package/dist/clients/{chunk-LT4EWLDA.js → chunk-BPDLF2R6.js} +1 -0
- package/dist/clients/{chunk-JD2J5K6S.js → chunk-C45VNQXY.js} +161 -18
- package/dist/clients/chunk-DGBIV3ZS.js +36 -0
- package/dist/clients/{chunk-MGQLVTSH.js → chunk-FM7SFGAV.js} +27 -21
- package/dist/clients/{chunk-6PIIYPQK.js → chunk-IYCZWLAF.js} +5 -327
- package/dist/clients/{chunk-BNMZM23Q.js → chunk-JFDRLSYM.js} +3 -3
- package/dist/clients/chunk-PENJ5JGH.js +331 -0
- package/dist/clients/chunk-QQEGNLGD.js +40 -0
- package/dist/clients/chunk-SU3YSNMB.js +306 -0
- package/dist/clients/chunk-TZGKB6WY.js +160 -0
- package/dist/clients/{chunk-2FSEE3AW.js → chunk-UK64SY6N.js} +2 -89
- package/dist/clients/chunk-VIAEAD75.js +61 -0
- package/dist/clients/{chunk-L2KSNS7H.js → chunk-WZRW6WUM.js} +1 -1
- package/dist/clients/{chunk-C4SHJFOV.js → chunk-XJTRLB7W.js} +9 -9
- package/dist/clients/{chunk-YFHTV7DT.js → chunk-Y7WLUPTX.js} +1 -1
- package/dist/clients/chunk-YUZ3B2Q3.js +15 -0
- package/dist/clients/{chunk-2YWQL3AO.js → chunk-Z7HTQFEO.js} +26 -3
- package/dist/clients/fanatics.js +2 -1
- package/dist/clients/internal/nado/consts.d.ts +6 -0
- package/dist/clients/internal/nado/consts.js +5 -3
- package/dist/clients/internal/nado/encoding.d.ts +5 -2
- package/dist/clients/internal/nado/encoding.js +1 -1
- package/dist/clients/internal/nado/errors.d.ts +14 -1
- package/dist/clients/internal/nado/errors.js +7 -3
- package/dist/clients/internal/nado/fetch.js +2 -2
- package/dist/clients/internal/nado/gateway.d.ts +19 -20
- package/dist/clients/internal/nado/gateway.js +4 -6
- package/dist/clients/internal/nado/hooks.d.ts +8 -2
- package/dist/clients/internal/nado/hooks.js +10 -10
- package/dist/clients/internal/nado/indexer.js +4 -4
- package/dist/clients/internal/nado/typedData.js +4 -37
- package/dist/clients/internal/nado/withdrawalCallback.d.ts +20 -0
- package/dist/clients/internal/nado/withdrawalCallback.js +20 -0
- package/dist/clients/internal/nado/withdrawalConfig.d.ts +8 -3
- package/dist/clients/internal/nado/withdrawalConfig.js +7 -3
- package/dist/clients/internal/nado/withdrawalErrors.d.ts +14 -0
- package/dist/clients/internal/nado/withdrawalErrors.js +11 -0
- package/dist/clients/internal/nado/withdrawalForm.css +43 -35
- package/dist/clients/internal/nado/withdrawalForm.d.ts +9 -7
- package/dist/clients/internal/nado/withdrawalForm.js +81 -98
- package/dist/clients/internal/nado/withdrawalStatus.d.ts +41 -0
- package/dist/clients/internal/nado/withdrawalStatus.js +231 -0
- package/dist/clients/internal/nado/withdrawalTypes.d.ts +21 -7
- package/dist/clients/lighter.css +61 -53
- package/dist/clients/lighter.js +8 -7
- package/dist/clients/mallard.js +4 -3
- package/dist/clients/nado.d.ts +67 -0
- package/dist/clients/nado.js +73 -0
- package/dist/clients/polymarket/PolymarketDepositAccountDropdown.css +103 -95
- package/dist/clients/polymarket/PolymarketDepositAccountDropdown.js +9 -6
- package/dist/clients/polymarket/createPolymarketDepositConfig.js +3 -2
- package/dist/clients/polymarket/index.css +103 -95
- package/dist/clients/polymarket/index.js +9 -6
- package/dist/clients/polymarket/polymarket.js +2 -1
- package/dist/components/Dialog/Dialog.d.ts +3 -1
- package/dist/components/Dialog/DialogContent.css.d.ts +6 -0
- package/dist/components/FunCheckbox/FunCheckbox.d.ts +3 -1
- package/dist/components/FunTransactionSummary/PaymentFeesSummary.d.ts +2 -1
- package/dist/consts/customers.d.ts +1 -1
- package/dist/domains/nado.d.ts +11 -2
- package/dist/domains/quoteMode/types.d.ts +16 -0
- package/dist/domains/relay.d.ts +0 -3
- package/dist/hooks/track/analytics/events.d.ts +85 -0
- package/dist/hooks/track/analytics/mappers.d.ts +8 -0
- package/dist/hooks/track/analytics/useDepositAnalytics.d.ts +37 -0
- package/dist/hooks/track/useTrack.d.ts +3 -2
- package/dist/hooks/useFunkitTranslation.d.ts +5 -0
- package/dist/hooks/useTokenAndChainDropdown.d.ts +4 -1
- package/dist/index.css +43 -35
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4414 -3570
- package/dist/modals/CheckoutModal/InputAmount/InputAmount.d.ts +5 -1
- package/dist/modals/CheckoutModal/InputAmount/state.d.ts +13 -0
- package/dist/modals/CheckoutModal/InputAmount/useMeld.d.ts +4 -3
- package/dist/modals/CheckoutModal/InputAmount/utils.d.ts +9 -1
- package/dist/modals/CheckoutModal/MeldQuotes/MeldQuotes.d.ts +3 -1
- package/dist/modals/CheckoutModal/MeldRedirect/MeldRedirect.d.ts +4 -1
- package/dist/modals/CheckoutModal/SourceChange/useBottomBarCloseLabel.d.ts +7 -0
- package/dist/modals/WithdrawalModal/LockedReceiveDisplay.d.ts +22 -0
- package/dist/modals/WithdrawalModal/NadoWithdrawalSuccess.d.ts +20 -0
- package/dist/modals/WithdrawalModal/withdrawalFormHelpers.d.ts +18 -1
- package/dist/modals/WithdrawalModal/withdrawalHooks.d.ts +1 -1
- package/dist/providers/FunkitCheckoutContext/types.d.ts +4 -3
- package/dist/providers/FunkitStatsigProvider.d.ts +7 -0
- package/dist/providers/GeneralWalletProvider.d.ts +1 -0
- package/dist/utils/customer.d.ts +23 -230
- package/dist/utils/withdrawal.d.ts +11 -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 +4 -4
- package/dist/clients/chunk-SFDEST63.js +0 -18
- package/dist/clients/chunk-ZCCLJW6F.js +0 -99
- 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
|
@@ -11,15 +11,15 @@ import {
|
|
|
11
11
|
} from "./chunk-LUHEVXPD.js";
|
|
12
12
|
import {
|
|
13
13
|
useFunkitTranslation
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-YUZ3B2Q3.js";
|
|
15
15
|
import {
|
|
16
16
|
POLYMARKET_PERPS_ROUTING_ID,
|
|
17
17
|
POLYMARKET_PREDICTIONS_ROUTING_ID
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-Y7WLUPTX.js";
|
|
19
19
|
import {
|
|
20
20
|
POLYGON_USDCE,
|
|
21
21
|
PUSD_TOKEN
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-IYCZWLAF.js";
|
|
23
23
|
import {
|
|
24
24
|
logger
|
|
25
25
|
} from "./chunk-AHYOV7AV.js";
|
|
@@ -239,6 +239,12 @@ function BaseDropdownItem({
|
|
|
239
239
|
}
|
|
240
240
|
var BaseDropdownItem_default = BaseDropdownItem;
|
|
241
241
|
|
|
242
|
+
// src/components/Dropdown/BaseDropdown.css.ts
|
|
243
|
+
var BORDER_RADIUS = "dropdown";
|
|
244
|
+
var baseDropdownItemWrapperStyles = "_1nns6ys3 _1rsrm2f17";
|
|
245
|
+
var scrollGradientWrapperStyles = "_1nns6ys1";
|
|
246
|
+
var scrollableDropdownStyles = "_1nns6ys0";
|
|
247
|
+
|
|
242
248
|
// src/components/Icons/CaretDownIcon.tsx
|
|
243
249
|
import clsx2 from "clsx";
|
|
244
250
|
import React3 from "react";
|
|
@@ -573,12 +579,6 @@ import React9 from "react";
|
|
|
573
579
|
// src/components/Dropdown/BaseActiveDropdownItem.css.ts
|
|
574
580
|
var baseStyles = "_1dewiqw0";
|
|
575
581
|
|
|
576
|
-
// src/components/Dropdown/BaseDropdown.css.ts
|
|
577
|
-
var BORDER_RADIUS = "dropdown";
|
|
578
|
-
var baseDropdownItemWrapperStyles = "_1nns6ys3 _1rsrm2f17";
|
|
579
|
-
var scrollGradientWrapperStyles = "_1nns6ys1";
|
|
580
|
-
var scrollableDropdownStyles = "_1nns6ys0";
|
|
581
|
-
|
|
582
582
|
// src/components/Dropdown/BaseActiveDropdownItem.tsx
|
|
583
583
|
function BaseActiveDropdownItem({
|
|
584
584
|
iconComponent,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
VAULT_DEPOSITOR_ABI,
|
|
9
9
|
VAULT_DEPOSITOR_POLYGON,
|
|
10
10
|
createPerpsGenerateActionParams
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-IYCZWLAF.js";
|
|
12
12
|
|
|
13
13
|
// src/clients/polymarket/createPolymarketDepositConfig.ts
|
|
14
14
|
import { encodeFunctionData, erc20Abi, getAddress, maxUint256 } from "viem";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
i18n_default
|
|
4
|
+
} from "./chunk-C45VNQXY.js";
|
|
5
|
+
|
|
6
|
+
// src/hooks/useFunkitTranslation.ts
|
|
7
|
+
import { useTranslation } from "react-i18next";
|
|
8
|
+
var funkitI18nOptions = { i18n: i18n_default };
|
|
9
|
+
function useFunkitTranslation() {
|
|
10
|
+
return useTranslation(void 0, funkitI18nOptions);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
useFunkitTranslation
|
|
15
|
+
};
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
var NADO_ERROR_CODES = {
|
|
5
5
|
/** Amount would open a borrow with `spot_leverage: "false"`. */
|
|
6
6
|
SPOT_EXECUTE_EXCEEDS_BORROW_LIMIT: 2017,
|
|
7
|
-
/**
|
|
7
|
+
/** Gateway-level nonce rejection. A consumed `tx_nonce` reverts in the EVM
|
|
8
|
+
* instead — see `EVM_REVERT`. */
|
|
8
9
|
INVALID_NONCE: 2022,
|
|
9
10
|
/** Subaccount has never deposited, so it doesn't exist on Nado yet. */
|
|
10
11
|
NO_PRIOR_DEPOSIT: 2024,
|
|
@@ -13,7 +14,10 @@ var NADO_ERROR_CODES = {
|
|
|
13
14
|
/** Fast-withdrawal validator signatures not aggregated yet. */
|
|
14
15
|
NOT_ENOUGH_FAST_WITHDRAWAL_SIGNATURES: 3005,
|
|
15
16
|
/** Protocol 24h withdrawal limit exceeded. */
|
|
16
|
-
WITHDRAW_RISK: 4004
|
|
17
|
+
WITHDRAW_RISK: 4004,
|
|
18
|
+
/** Catch-all EVM revert — the reason lives in the message, not the code.
|
|
19
|
+
* A consumed `tx_nonce` lands here (see `parseNadoExpectedNonce`). */
|
|
20
|
+
EVM_REVERT: 4003
|
|
17
21
|
};
|
|
18
22
|
var NadoGatewayError = class extends Error {
|
|
19
23
|
constructor(message, options) {
|
|
@@ -24,6 +28,12 @@ var NadoGatewayError = class extends Error {
|
|
|
24
28
|
this.httpStatus = options.httpStatus;
|
|
25
29
|
}
|
|
26
30
|
};
|
|
31
|
+
var NadoWithdrawalUnconfirmedError = class extends Error {
|
|
32
|
+
constructor(message = "Nado withdrawal outcome could not be confirmed") {
|
|
33
|
+
super(message);
|
|
34
|
+
this.name = "NadoWithdrawalUnconfirmedError";
|
|
35
|
+
}
|
|
36
|
+
};
|
|
27
37
|
function isNadoTransportError(error) {
|
|
28
38
|
return error instanceof NadoGatewayError && error.kind === "transport";
|
|
29
39
|
}
|
|
@@ -36,11 +46,24 @@ function createNadoGatewayError(response, fallbackMessage) {
|
|
|
36
46
|
function isNadoErrorCode(error, code) {
|
|
37
47
|
return error instanceof NadoGatewayError && error.errorCode === code;
|
|
38
48
|
}
|
|
49
|
+
var NADO_EXPECTED_NONCE_PATTERN = /Invalid nonce: expected:\s*(\d+)/;
|
|
50
|
+
function parseNadoExpectedNonce(error) {
|
|
51
|
+
if (!(error instanceof NadoGatewayError) || error.errorCode !== NADO_ERROR_CODES.EVM_REVERT) {
|
|
52
|
+
return void 0;
|
|
53
|
+
}
|
|
54
|
+
const captured = error.message.match(NADO_EXPECTED_NONCE_PATTERN)?.[1];
|
|
55
|
+
if (captured === void 0) {
|
|
56
|
+
return void 0;
|
|
57
|
+
}
|
|
58
|
+
return BigInt(captured);
|
|
59
|
+
}
|
|
39
60
|
|
|
40
61
|
export {
|
|
41
62
|
NADO_ERROR_CODES,
|
|
42
63
|
NadoGatewayError,
|
|
64
|
+
NadoWithdrawalUnconfirmedError,
|
|
43
65
|
isNadoTransportError,
|
|
44
66
|
createNadoGatewayError,
|
|
45
|
-
isNadoErrorCode
|
|
67
|
+
isNadoErrorCode,
|
|
68
|
+
parseNadoExpectedNonce
|
|
46
69
|
};
|
package/dist/clients/fanatics.js
CHANGED
|
@@ -14,3 +14,9 @@ export declare const NADO_INDEXER_URL = "https://archive.prod.nado.xyz/v1";
|
|
|
14
14
|
* signatures over (orders verify against the product address instead).
|
|
15
15
|
*/
|
|
16
16
|
export declare const NADO_EIP712_VERIFYING_CONTRACT_ADDRESS: `0x${string}`;
|
|
17
|
+
/**
|
|
18
|
+
* Attribution-only action type — generates no on-chain action. It only splits
|
|
19
|
+
* the withdrawal UDA off from the deposit UDA so backend can tell them apart.
|
|
20
|
+
* Restricted to Nado customer keys by the api-server validator.
|
|
21
|
+
*/
|
|
22
|
+
export declare const NADO_WITHDRAWAL_ACTION_TYPE = "NADO_WITHDRAWAL";
|
|
@@ -3,11 +3,13 @@ import {
|
|
|
3
3
|
INK_CHAIN_ID,
|
|
4
4
|
NADO_EIP712_VERIFYING_CONTRACT_ADDRESS,
|
|
5
5
|
NADO_GATEWAY_URL,
|
|
6
|
-
NADO_INDEXER_URL
|
|
7
|
-
|
|
6
|
+
NADO_INDEXER_URL,
|
|
7
|
+
NADO_WITHDRAWAL_ACTION_TYPE
|
|
8
|
+
} from "../../chunk-3P2C436B.js";
|
|
8
9
|
export {
|
|
9
10
|
INK_CHAIN_ID,
|
|
10
11
|
NADO_EIP712_VERIFYING_CONTRACT_ADDRESS,
|
|
11
12
|
NADO_GATEWAY_URL,
|
|
12
|
-
NADO_INDEXER_URL
|
|
13
|
+
NADO_INDEXER_URL,
|
|
14
|
+
NADO_WITHDRAWAL_ACTION_TYPE
|
|
13
15
|
};
|
|
@@ -16,7 +16,10 @@ export declare function buildNadoSubaccountId(owner: Address, name?: string): He
|
|
|
16
16
|
* x18 query amount → raw base units. Floors — never rounds up — so a
|
|
17
17
|
* converted `max_withdrawable` can't exceed the true maximum. Same semantics
|
|
18
18
|
* as Nado's own frontend, which floors at submit (`BigNumber.ROUND_DOWN`).
|
|
19
|
+
*
|
|
20
|
+
* Takes a bigint so it cannot throw: parsing a gateway string stays at the one
|
|
21
|
+
* boundary that receives it (`safeBigInt`).
|
|
19
22
|
*/
|
|
20
|
-
export declare function x18ToRawBaseUnit(x18Amount:
|
|
23
|
+
export declare function x18ToRawBaseUnit(x18Amount: bigint, decimals: number): bigint;
|
|
21
24
|
/** x18-scaled query amount → human token units, floored at native decimals. */
|
|
22
|
-
export declare function x18ToTokenUnits(x18Amount:
|
|
25
|
+
export declare function x18ToTokenUnits(x18Amount: bigint, decimals: number): string;
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
export declare const NADO_ERROR_CODES: {
|
|
11
11
|
/** Amount would open a borrow with `spot_leverage: "false"`. */
|
|
12
12
|
readonly SPOT_EXECUTE_EXCEEDS_BORROW_LIMIT: 2017;
|
|
13
|
-
/**
|
|
13
|
+
/** Gateway-level nonce rejection. A consumed `tx_nonce` reverts in the EVM
|
|
14
|
+
* instead — see `EVM_REVERT`. */
|
|
14
15
|
readonly INVALID_NONCE: 2022;
|
|
15
16
|
/** Subaccount has never deposited, so it doesn't exist on Nado yet. */
|
|
16
17
|
readonly NO_PRIOR_DEPOSIT: 2024;
|
|
@@ -20,6 +21,9 @@ export declare const NADO_ERROR_CODES: {
|
|
|
20
21
|
readonly NOT_ENOUGH_FAST_WITHDRAWAL_SIGNATURES: 3005;
|
|
21
22
|
/** Protocol 24h withdrawal limit exceeded. */
|
|
22
23
|
readonly WITHDRAW_RISK: 4004;
|
|
24
|
+
/** Catch-all EVM revert — the reason lives in the message, not the code.
|
|
25
|
+
* A consumed `tx_nonce` lands here (see `parseNadoExpectedNonce`). */
|
|
26
|
+
readonly EVM_REVERT: 4003;
|
|
23
27
|
};
|
|
24
28
|
export type NadoErrorCode = (typeof NADO_ERROR_CODES)[keyof typeof NADO_ERROR_CODES];
|
|
25
29
|
/**
|
|
@@ -44,6 +48,14 @@ export declare class NadoGatewayError extends Error {
|
|
|
44
48
|
httpStatus?: number;
|
|
45
49
|
});
|
|
46
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* A submit went unanswered and its replay didn't settle the question — the
|
|
53
|
+
* withdrawal may or may not have landed. Distinct from a plain failure because
|
|
54
|
+
* the user must not be told to retry: a fresh nonce would withdraw twice.
|
|
55
|
+
*/
|
|
56
|
+
export declare class NadoWithdrawalUnconfirmedError extends Error {
|
|
57
|
+
constructor(message?: string);
|
|
58
|
+
}
|
|
47
59
|
/** Request never completed — safe to retry. Excludes timeouts: a retry after
|
|
48
60
|
* a 30s stall would hold the user another 30s. */
|
|
49
61
|
export declare function isNadoTransportError(error: unknown): boolean;
|
|
@@ -53,3 +65,4 @@ export declare function createNadoGatewayError(response: {
|
|
|
53
65
|
error_code?: number;
|
|
54
66
|
}, fallbackMessage: string): NadoGatewayError;
|
|
55
67
|
export declare function isNadoErrorCode(error: unknown, code: NadoErrorCode): boolean;
|
|
68
|
+
export declare function parseNadoExpectedNonce(error: unknown): bigint | undefined;
|
|
@@ -2,14 +2,18 @@
|
|
|
2
2
|
import {
|
|
3
3
|
NADO_ERROR_CODES,
|
|
4
4
|
NadoGatewayError,
|
|
5
|
+
NadoWithdrawalUnconfirmedError,
|
|
5
6
|
createNadoGatewayError,
|
|
6
7
|
isNadoErrorCode,
|
|
7
|
-
isNadoTransportError
|
|
8
|
-
|
|
8
|
+
isNadoTransportError,
|
|
9
|
+
parseNadoExpectedNonce
|
|
10
|
+
} from "../../chunk-Z7HTQFEO.js";
|
|
9
11
|
export {
|
|
10
12
|
NADO_ERROR_CODES,
|
|
11
13
|
NadoGatewayError,
|
|
14
|
+
NadoWithdrawalUnconfirmedError,
|
|
12
15
|
createNadoGatewayError,
|
|
13
16
|
isNadoErrorCode,
|
|
14
|
-
isNadoTransportError
|
|
17
|
+
isNadoTransportError,
|
|
18
|
+
parseNadoExpectedNonce
|
|
15
19
|
};
|
|
@@ -2,16 +2,24 @@
|
|
|
2
2
|
* Nado gateway client: the queries and the withdraw execute used by the
|
|
3
3
|
* withdrawal flow.
|
|
4
4
|
*
|
|
5
|
-
* Flow composition: `
|
|
6
|
-
*
|
|
5
|
+
* Flow composition: `max_withdrawable` / `fee_rates` feed the enter-amount
|
|
6
|
+
* screen → `nonces` immediately before signing → execute
|
|
7
7
|
* `withdraw_collateral_v2` with `sendTo` = the Fun deposit address → the
|
|
8
|
-
* indexer poll (indexer.ts) confirms sequencing, then checkout tracking
|
|
9
|
-
*
|
|
8
|
+
* indexer poll (indexer.ts) confirms sequencing, then checkout tracking takes
|
|
9
|
+
* over once funds arrive.
|
|
10
10
|
*
|
|
11
11
|
* @see {@link https://docs.nado.xyz/developer-resources/api/gateway | Nado gateway API}
|
|
12
12
|
*/
|
|
13
13
|
import type { Address, Hex } from 'viem';
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Largest withdrawal (x18) the subaccount can make, measured against prod:
|
|
16
|
+
* `(spot_leverage ? initial_health : min(spot, initial_health)) − sequencer_fee`
|
|
17
|
+
*
|
|
18
|
+
* - Already net of the fee: `max + fee` is debited, `max` is what arrives — so
|
|
19
|
+
* the screen adds it back (`withdrawalForm.ts`).
|
|
20
|
+
* - Health-bound, so no sum of spot balances can replace it: an open perp cuts
|
|
21
|
+
* the max without moving any balance.
|
|
22
|
+
*/
|
|
15
23
|
export declare function getNadoMaxWithdrawable(params: {
|
|
16
24
|
productId: number;
|
|
17
25
|
sender: Hex;
|
|
@@ -28,19 +36,6 @@ export interface NadoFeeRates {
|
|
|
28
36
|
withdraw_sequencer_fees: string[];
|
|
29
37
|
}
|
|
30
38
|
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
39
|
export interface ExecuteWithdrawCollateralV2Params {
|
|
45
40
|
/** Subaccount id per Nado's spec (see `buildNadoSubaccountId`). */
|
|
46
41
|
sender: Hex;
|
|
@@ -56,7 +51,11 @@ export interface ExecuteWithdrawCollateralV2Params {
|
|
|
56
51
|
}
|
|
57
52
|
/**
|
|
58
53
|
* Submit a signed `withdraw_collateral_v2`; resolves on gateway acceptance,
|
|
59
|
-
* on-chain settlement follows asynchronously.
|
|
60
|
-
*
|
|
54
|
+
* on-chain settlement follows asynchronously.
|
|
55
|
+
*
|
|
56
|
+
* A timeout means "no answer", not "didn't happen", so it replays the
|
|
57
|
+
* identical payload rather than surfacing an ambiguous failure. `tx_nonce` is
|
|
58
|
+
* a sequential counter, so the replay either fills the same slot or is
|
|
59
|
+
* rejected — it can never withdraw twice.
|
|
61
60
|
*/
|
|
62
61
|
export declare function executeNadoWithdrawCollateralV2(params: ExecuteWithdrawCollateralV2Params): Promise<void>;
|
|
@@ -3,17 +3,15 @@ import {
|
|
|
3
3
|
executeNadoWithdrawCollateralV2,
|
|
4
4
|
getNadoFeeRates,
|
|
5
5
|
getNadoMaxWithdrawable,
|
|
6
|
-
getNadoSubaccountInfo,
|
|
7
6
|
getNadoTxNonce
|
|
8
|
-
} from "../../chunk-
|
|
9
|
-
import "../../chunk-
|
|
10
|
-
import "../../chunk-
|
|
11
|
-
import "../../chunk-
|
|
7
|
+
} from "../../chunk-TZGKB6WY.js";
|
|
8
|
+
import "../../chunk-3P2C436B.js";
|
|
9
|
+
import "../../chunk-WZRW6WUM.js";
|
|
10
|
+
import "../../chunk-Z7HTQFEO.js";
|
|
12
11
|
import "../../chunk-AHYOV7AV.js";
|
|
13
12
|
export {
|
|
14
13
|
executeNadoWithdrawCollateralV2,
|
|
15
14
|
getNadoFeeRates,
|
|
16
15
|
getNadoMaxWithdrawable,
|
|
17
|
-
getNadoSubaccountInfo,
|
|
18
16
|
getNadoTxNonce
|
|
19
17
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* React-query hooks over the Nado gateway/indexer. Poll cadences are budgeted
|
|
3
3
|
* against Nado's IP rate limit (2400 query-weight/min): an open modal spends
|
|
4
|
-
* ~
|
|
4
|
+
* ~10 weight/min on the selected product's max; the indexer poll runs only
|
|
5
|
+
* while a settlement is pending.
|
|
5
6
|
*
|
|
6
7
|
* @see {@link https://docs.nado.xyz/developer-resources/api/rate-limits | Nado rate limits}
|
|
7
8
|
*/
|
|
@@ -13,12 +14,17 @@ import type { Hex } from 'viem';
|
|
|
13
14
|
* next scheduled poll is the retry).
|
|
14
15
|
*/
|
|
15
16
|
export declare function shouldRetryNadoQuery(failureCount: number, error: unknown): boolean;
|
|
16
|
-
export declare function useNadoSubaccountBalances(subaccount: Hex | undefined): import("@tanstack/react-query").UseQueryResult<import("./gateway").NadoSubaccountInfo, unknown>;
|
|
17
17
|
export declare function useNadoMaxWithdrawable(params: {
|
|
18
18
|
productId: number | undefined;
|
|
19
19
|
sender: Hex | undefined;
|
|
20
20
|
spotLeverage: boolean;
|
|
21
21
|
}): import("@tanstack/react-query").UseQueryResult<string, unknown>;
|
|
22
|
+
/**
|
|
23
|
+
* Drops every cached max — prefix match, since each product and borrow state
|
|
24
|
+
* holds its own entry — so a follow-up withdrawal sees the debited balance
|
|
25
|
+
* rather than waiting out the refetch interval.
|
|
26
|
+
*/
|
|
27
|
+
export declare function useInvalidateNadoMaxWithdrawable(): () => void;
|
|
22
28
|
export declare function useNadoFeeRates(sender: Hex | undefined): import("@tanstack/react-query").UseQueryResult<import("./gateway").NadoFeeRates, unknown>;
|
|
23
29
|
export interface NadoSettlementStatus {
|
|
24
30
|
/** True once the sequencer has recorded the withdrawal we signed. */
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
shouldRetryNadoQuery,
|
|
4
|
+
useInvalidateNadoMaxWithdrawable,
|
|
4
5
|
useNadoFeeRates,
|
|
5
6
|
useNadoMaxWithdrawable,
|
|
6
|
-
useNadoSettlementStatus
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import "../../chunk-
|
|
10
|
-
import "../../chunk-
|
|
11
|
-
import "../../chunk-
|
|
12
|
-
import "../../chunk-
|
|
13
|
-
import "../../chunk-2YWQL3AO.js";
|
|
7
|
+
useNadoSettlementStatus
|
|
8
|
+
} from "../../chunk-FM7SFGAV.js";
|
|
9
|
+
import "../../chunk-JFDRLSYM.js";
|
|
10
|
+
import "../../chunk-TZGKB6WY.js";
|
|
11
|
+
import "../../chunk-3P2C436B.js";
|
|
12
|
+
import "../../chunk-WZRW6WUM.js";
|
|
13
|
+
import "../../chunk-Z7HTQFEO.js";
|
|
14
14
|
import "../../chunk-AHYOV7AV.js";
|
|
15
15
|
export {
|
|
16
16
|
shouldRetryNadoQuery,
|
|
17
|
+
useInvalidateNadoMaxWithdrawable,
|
|
17
18
|
useNadoFeeRates,
|
|
18
19
|
useNadoMaxWithdrawable,
|
|
19
|
-
useNadoSettlementStatus
|
|
20
|
-
useNadoSubaccountBalances
|
|
20
|
+
useNadoSettlementStatus
|
|
21
21
|
};
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import {
|
|
3
3
|
findSettlementForNonce,
|
|
4
4
|
getNadoWithdrawalEvents
|
|
5
|
-
} from "../../chunk-
|
|
6
|
-
import "../../chunk-
|
|
7
|
-
import "../../chunk-
|
|
8
|
-
import "../../chunk-
|
|
5
|
+
} from "../../chunk-JFDRLSYM.js";
|
|
6
|
+
import "../../chunk-3P2C436B.js";
|
|
7
|
+
import "../../chunk-WZRW6WUM.js";
|
|
8
|
+
import "../../chunk-Z7HTQFEO.js";
|
|
9
9
|
import "../../chunk-AHYOV7AV.js";
|
|
10
10
|
export {
|
|
11
11
|
findSettlementForNonce,
|
|
@@ -1,42 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "../../chunk-
|
|
6
|
-
|
|
7
|
-
// src/clients/internal/nado/typedData.ts
|
|
8
|
-
var WITHDRAW_COLLATERAL_V2_TYPES = {
|
|
9
|
-
WithdrawCollateralV2: [
|
|
10
|
-
{ name: "sender", type: "bytes32" },
|
|
11
|
-
{ name: "productId", type: "uint32" },
|
|
12
|
-
{ name: "amount", type: "uint128" },
|
|
13
|
-
{ name: "nonce", type: "uint64" },
|
|
14
|
-
{ name: "sendTo", type: "address" },
|
|
15
|
-
// Reserved by Nado — must be signed as 0
|
|
16
|
-
{ name: "appendix", type: "uint128" }
|
|
17
|
-
]
|
|
18
|
-
};
|
|
19
|
-
function buildWithdrawCollateralV2TypedData(params) {
|
|
20
|
-
return {
|
|
21
|
-
domain: {
|
|
22
|
-
name: "Nado",
|
|
23
|
-
version: "0.0.1",
|
|
24
|
-
chainId: INK_CHAIN_ID,
|
|
25
|
-
verifyingContract: NADO_EIP712_VERIFYING_CONTRACT_ADDRESS
|
|
26
|
-
},
|
|
27
|
-
types: WITHDRAW_COLLATERAL_V2_TYPES,
|
|
28
|
-
primaryType: "WithdrawCollateralV2",
|
|
29
|
-
message: {
|
|
30
|
-
sender: params.sender,
|
|
31
|
-
productId: params.productId,
|
|
32
|
-
amount: params.amount,
|
|
33
|
-
nonce: params.nonce,
|
|
34
|
-
sendTo: params.sendTo,
|
|
35
|
-
appendix: 0n
|
|
36
|
-
// set to 0, Nado reserved
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}
|
|
3
|
+
WITHDRAW_COLLATERAL_V2_TYPES,
|
|
4
|
+
buildWithdrawCollateralV2TypedData
|
|
5
|
+
} from "../../chunk-2576N7PQ.js";
|
|
6
|
+
import "../../chunk-3P2C436B.js";
|
|
40
7
|
export {
|
|
41
8
|
WITHDRAW_COLLATERAL_V2_TYPES,
|
|
42
9
|
buildWithdrawCollateralV2TypedData
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Nado withdrawal money path: generate a Fun deposit address, sign Nado's
|
|
3
|
+
* gasless `withdraw_collateral_v2` with `sendTo` pointing at it, and submit.
|
|
4
|
+
*
|
|
5
|
+
* - Nado's signed `amount` is what lands at `sendTo`; the sequencer fee is a
|
|
6
|
+
* separate subaccount debit, so we sign the net the screen already quoted.
|
|
7
|
+
* - Re-submitting belongs to the gateway, which reuses the signed nonce. A
|
|
8
|
+
* retry from here would mint a fresh one and withdraw twice.
|
|
9
|
+
*/
|
|
10
|
+
import type { Address, Hex } from 'viem';
|
|
11
|
+
import type { WithdrawalParam } from '../../../providers/FunkitCheckoutContext/types';
|
|
12
|
+
import type { Config } from '../../../wagmi/hooks';
|
|
13
|
+
export interface NadoWithdrawalCallbackContext {
|
|
14
|
+
/** Connected wallet — Nado rejects linked signers on withdrawals. */
|
|
15
|
+
walletAddress: Address;
|
|
16
|
+
/** Packed id of the subaccount being debited. */
|
|
17
|
+
subaccount: Hex;
|
|
18
|
+
wagmiConfig: Config;
|
|
19
|
+
}
|
|
20
|
+
export declare function createNadoWithdrawalCallback({ walletAddress, subaccount, wagmiConfig, }: NadoWithdrawalCallbackContext): (param: WithdrawalParam) => Promise<string>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
createNadoWithdrawalCallback
|
|
4
|
+
} from "../../chunk-SU3YSNMB.js";
|
|
5
|
+
import "../../chunk-2576N7PQ.js";
|
|
6
|
+
import "../../chunk-VIAEAD75.js";
|
|
7
|
+
import "../../chunk-63XTVHO3.js";
|
|
8
|
+
import "../../chunk-DGBIV3ZS.js";
|
|
9
|
+
import "../../chunk-6T6URLBM.js";
|
|
10
|
+
import "../../chunk-TZGKB6WY.js";
|
|
11
|
+
import "../../chunk-3P2C436B.js";
|
|
12
|
+
import "../../chunk-WZRW6WUM.js";
|
|
13
|
+
import "../../chunk-Z7HTQFEO.js";
|
|
14
|
+
import "../../chunk-OODIKHYE.js";
|
|
15
|
+
import "../../chunk-C45VNQXY.js";
|
|
16
|
+
import "../../chunk-PENJ5JGH.js";
|
|
17
|
+
import "../../chunk-AHYOV7AV.js";
|
|
18
|
+
export {
|
|
19
|
+
createNadoWithdrawalCallback
|
|
20
|
+
};
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Nado withdrawal config type
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Nado withdrawal config: its type, its guard, and the subaccount id it's
|
|
3
|
+
* built around. All SDK-private (the `clients/internal/*` exports map blocks
|
|
4
|
+
* consumer imports) except the config type, which reaches integrators via the
|
|
5
|
+
* `clients/nado` re-export.
|
|
5
6
|
*/
|
|
7
|
+
import type { Address, Hex } from 'viem';
|
|
6
8
|
import type { CustomWithdrawalConfig, FunkitWithdrawalConfig } from '../../../providers/FunkitCheckoutContext';
|
|
7
9
|
import type { NadoWithdrawalCustomerConfig } from './withdrawalTypes';
|
|
8
10
|
export interface NadoWithdrawalConfig extends CustomWithdrawalConfig {
|
|
9
11
|
customerConfig: NadoWithdrawalCustomerConfig;
|
|
10
12
|
}
|
|
11
13
|
export declare function isNadoWithdrawalConfig(config: FunkitWithdrawalConfig | null | undefined): config is NadoWithdrawalConfig;
|
|
14
|
+
/** Packed subaccount id, or undefined when one can't be built — the caller
|
|
15
|
+
* disables the config rather than crashing the render. */
|
|
16
|
+
export declare function resolveNadoSubaccount(walletAddress: Address | undefined, subaccountName: string | undefined): Hex | undefined;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
-
isNadoWithdrawalConfig
|
|
4
|
-
|
|
3
|
+
isNadoWithdrawalConfig,
|
|
4
|
+
resolveNadoSubaccount
|
|
5
|
+
} from "../../chunk-QQEGNLGD.js";
|
|
6
|
+
import "../../chunk-DGBIV3ZS.js";
|
|
7
|
+
import "../../chunk-6T6URLBM.js";
|
|
5
8
|
import "../../chunk-AHYOV7AV.js";
|
|
6
9
|
export {
|
|
7
|
-
isNadoWithdrawalConfig
|
|
10
|
+
isNadoWithdrawalConfig,
|
|
11
|
+
resolveNadoSubaccount
|
|
8
12
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nado gateway failure → user-facing withdrawal message.
|
|
3
|
+
*
|
|
4
|
+
* - Lives apart from `errors.ts`, which stays flow-agnostic (the codes are
|
|
5
|
+
* shared across every Nado execute and query).
|
|
6
|
+
* - Messages are surfaced verbatim by `useWithdrawal`'s custom-callback path,
|
|
7
|
+
* so unmapped codes get the generic line and the raw Nado string is logged.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Whether the failure is one we have specific copy for. Shares the code set with
|
|
11
|
+
* {@link toNadoWithdrawalErrorMessage} so severity and messaging can't drift.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isExpectedNadoWithdrawalFailure(error: unknown): boolean;
|
|
14
|
+
export declare function toNadoWithdrawalErrorMessage(error: unknown): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
isExpectedNadoWithdrawalFailure,
|
|
4
|
+
toNadoWithdrawalErrorMessage
|
|
5
|
+
} from "../../chunk-VIAEAD75.js";
|
|
6
|
+
import "../../chunk-Z7HTQFEO.js";
|
|
7
|
+
import "../../chunk-C45VNQXY.js";
|
|
8
|
+
export {
|
|
9
|
+
isExpectedNadoWithdrawalFailure,
|
|
10
|
+
toNadoWithdrawalErrorMessage
|
|
11
|
+
};
|