@funkit/connect 11.0.0 → 11.1.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 +19 -0
- package/dist/clients/{chunk-JD2J5K6S.js → chunk-2QYQNTOI.js} +153 -18
- package/dist/clients/chunk-63XTVHO3.js +19 -0
- package/dist/clients/{chunk-6CYZKITE.js → chunk-6T6URLBM.js} +1 -1
- package/dist/clients/chunk-A44M6EAG.js +160 -0
- package/dist/clients/chunk-A6OXZWCN.js +40 -0
- package/dist/clients/{chunk-LT4EWLDA.js → chunk-BPDLF2R6.js} +1 -0
- package/dist/clients/{chunk-2FSEE3AW.js → chunk-C53FRCUM.js} +2 -89
- package/dist/clients/{chunk-6PIIYPQK.js → chunk-EJKHMZW3.js} +4 -327
- package/dist/clients/chunk-FAYBQQNB.js +15 -0
- package/dist/clients/chunk-NAVU6W7V.js +89 -0
- package/dist/clients/{chunk-BNMZM23Q.js → chunk-OJZNF6EM.js} +2 -2
- package/dist/clients/chunk-PENJ5JGH.js +331 -0
- package/dist/clients/{chunk-C4SHJFOV.js → chunk-QIMCURVA.js} +9 -9
- package/dist/clients/{chunk-YFHTV7DT.js → chunk-SH3MHRHX.js} +1 -1
- package/dist/clients/chunk-SO756ELD.js +35 -0
- package/dist/clients/{chunk-MGQLVTSH.js → chunk-SYFHMTUO.js} +27 -21
- package/dist/clients/chunk-WVM4ZJD2.js +61 -0
- package/dist/clients/{chunk-L2KSNS7H.js → chunk-WZRW6WUM.js} +1 -1
- package/dist/clients/chunk-YMGRBJAS.js +302 -0
- package/dist/clients/chunk-YZSO4EMO.js +44 -0
- package/dist/clients/{chunk-2YWQL3AO.js → chunk-Z7HTQFEO.js} +26 -3
- package/dist/clients/fanatics.js +2 -1
- 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 +3 -5
- package/dist/clients/internal/nado/hooks.d.ts +8 -2
- package/dist/clients/internal/nado/hooks.js +9 -9
- package/dist/clients/internal/nado/indexer.js +3 -3
- 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.d.ts +6 -7
- package/dist/clients/internal/nado/withdrawalForm.js +75 -96
- 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 +18 -18
- package/dist/clients/lighter.js +7 -4
- 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 +60 -60
- package/dist/clients/polymarket/PolymarketDepositAccountDropdown.js +9 -6
- package/dist/clients/polymarket/createPolymarketDepositConfig.js +3 -2
- package/dist/clients/polymarket/index.css +60 -60
- package/dist/clients/polymarket/index.js +9 -6
- package/dist/clients/polymarket/polymarket.js +2 -1
- package/dist/consts/customers.d.ts +1 -1
- package/dist/hooks/track/analytics/events.d.ts +57 -0
- package/dist/hooks/track/analytics/mappers.d.ts +6 -0
- package/dist/hooks/track/analytics/useDepositAnalytics.d.ts +20 -0
- package/dist/hooks/track/useTrack.d.ts +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3044 -2602
- package/dist/modals/WithdrawalModal/NadoWithdrawalSuccess.d.ts +20 -0
- package/dist/providers/FunkitCheckoutContext/types.d.ts +0 -1
- package/dist/providers/GeneralWalletProvider.d.ts +1 -0
- package/dist/wallets/walletConnectors/index.js +41 -41
- package/package.json +3 -3
- package/dist/clients/chunk-SFDEST63.js +0 -18
- package/dist/clients/chunk-ZCCLJW6F.js +0 -99
|
@@ -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-YZSO4EMO.js";
|
|
6
|
+
import "../../chunk-II5CZTBC.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-YMGRBJAS.js";
|
|
5
|
+
import "../../chunk-YZSO4EMO.js";
|
|
6
|
+
import "../../chunk-WVM4ZJD2.js";
|
|
7
|
+
import "../../chunk-63XTVHO3.js";
|
|
8
|
+
import "../../chunk-SO756ELD.js";
|
|
9
|
+
import "../../chunk-6T6URLBM.js";
|
|
10
|
+
import "../../chunk-A44M6EAG.js";
|
|
11
|
+
import "../../chunk-II5CZTBC.js";
|
|
12
|
+
import "../../chunk-WZRW6WUM.js";
|
|
13
|
+
import "../../chunk-Z7HTQFEO.js";
|
|
14
|
+
import "../../chunk-OODIKHYE.js";
|
|
15
|
+
import "../../chunk-2QYQNTOI.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 the
|
|
3
|
+
* config is built around. All SDK-private (the `clients/internal/*` exports map
|
|
4
|
+
* blocks consumer imports) except the config type, which reaches integrators
|
|
5
|
+
* via the `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-A6OXZWCN.js";
|
|
6
|
+
import "../../chunk-SO756ELD.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-WVM4ZJD2.js";
|
|
6
|
+
import "../../chunk-Z7HTQFEO.js";
|
|
7
|
+
import "../../chunk-2QYQNTOI.js";
|
|
8
|
+
export {
|
|
9
|
+
isExpectedNadoWithdrawalFailure,
|
|
10
|
+
toNadoWithdrawalErrorMessage
|
|
11
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Orchestrates the Nado enter-amount screen:
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Orchestrates the Nado enter-amount screen: maps the selected symbol to a Nado
|
|
3
|
+
* product, tracks the borrow toggle, and exposes the withdrawable amount +
|
|
4
|
+
* sequencer fee in token units.
|
|
5
5
|
*
|
|
6
6
|
* - One-way dependency: never imports from `modals/`; WithdrawalContent maps
|
|
7
7
|
* these outputs onto its own props.
|
|
@@ -19,11 +19,10 @@ export interface UseNadoWithdrawalFormResult {
|
|
|
19
19
|
isNado: boolean;
|
|
20
20
|
/** Borrow (spot leverage) checkbox, assembled here so shared code holds no Nado state. */
|
|
21
21
|
amountToggle: NadoAmountToggle | undefined;
|
|
22
|
-
/** Max withdrawable for the selection in token units (accounts for the borrow toggle). */
|
|
23
|
-
maxWithdrawableTokenUnits: string | undefined;
|
|
24
22
|
/**
|
|
25
|
-
* Balance the screen shows and the Max button fills:
|
|
26
|
-
*
|
|
23
|
+
* Balance the screen shows and the Max button fills: Nado's own
|
|
24
|
+
* `max_withdrawable` with the fee added back. Borrowing can lift it above the
|
|
25
|
+
* spot balance.
|
|
27
26
|
*/
|
|
28
27
|
withdrawableBalanceTokenUnits: string;
|
|
29
28
|
/** Sequencer fee in the selected product's token units; hard 0 outside Nado. */
|
|
@@ -1,37 +1,44 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useNadoFeeRates,
|
|
4
|
+
useNadoMaxWithdrawable
|
|
5
|
+
} from "../../chunk-SYFHMTUO.js";
|
|
6
|
+
import "../../chunk-OJZNF6EM.js";
|
|
7
|
+
import {
|
|
8
|
+
safeBigInt
|
|
9
|
+
} from "../../chunk-63XTVHO3.js";
|
|
2
10
|
import {
|
|
3
11
|
isNadoWithdrawalConfig
|
|
4
|
-
} from "../../chunk-
|
|
12
|
+
} from "../../chunk-A6OXZWCN.js";
|
|
13
|
+
import "../../chunk-SO756ELD.js";
|
|
5
14
|
import {
|
|
15
|
+
x18ToRawBaseUnit,
|
|
6
16
|
x18ToTokenUnits
|
|
7
|
-
} from "../../chunk-
|
|
8
|
-
import
|
|
9
|
-
useNadoFeeRates,
|
|
10
|
-
useNadoMaxWithdrawable,
|
|
11
|
-
useNadoSubaccountBalances
|
|
12
|
-
} from "../../chunk-MGQLVTSH.js";
|
|
13
|
-
import "../../chunk-ZCCLJW6F.js";
|
|
14
|
-
import "../../chunk-BNMZM23Q.js";
|
|
17
|
+
} from "../../chunk-6T6URLBM.js";
|
|
18
|
+
import "../../chunk-A44M6EAG.js";
|
|
15
19
|
import "../../chunk-II5CZTBC.js";
|
|
16
|
-
import "../../chunk-
|
|
17
|
-
import "../../chunk-
|
|
20
|
+
import "../../chunk-WZRW6WUM.js";
|
|
21
|
+
import "../../chunk-Z7HTQFEO.js";
|
|
18
22
|
import {
|
|
19
23
|
useGeneralWallet
|
|
20
|
-
} from "../../chunk-
|
|
24
|
+
} from "../../chunk-BPDLF2R6.js";
|
|
21
25
|
import "../../chunk-5MY7WMEJ.js";
|
|
26
|
+
import "../../chunk-NAVU6W7V.js";
|
|
22
27
|
import {
|
|
23
28
|
useFunkitConfig
|
|
24
|
-
} from "../../chunk-
|
|
25
|
-
import "../../chunk-UPZNKPYU.js";
|
|
29
|
+
} from "../../chunk-C53FRCUM.js";
|
|
26
30
|
import {
|
|
27
31
|
useFunkitTranslation
|
|
28
|
-
} from "../../chunk-
|
|
32
|
+
} from "../../chunk-FAYBQQNB.js";
|
|
33
|
+
import "../../chunk-UPZNKPYU.js";
|
|
34
|
+
import "../../chunk-2QYQNTOI.js";
|
|
29
35
|
import {
|
|
30
36
|
logger
|
|
31
37
|
} from "../../chunk-AHYOV7AV.js";
|
|
32
38
|
|
|
33
39
|
// src/clients/internal/nado/withdrawalForm.ts
|
|
34
40
|
import { useEffect, useMemo, useState } from "react";
|
|
41
|
+
import { formatUnits } from "viem";
|
|
35
42
|
|
|
36
43
|
// src/hooks/useAssetPrice.ts
|
|
37
44
|
import {
|
|
@@ -53,22 +60,6 @@ import {
|
|
|
53
60
|
|
|
54
61
|
// src/hooks/useUserIpInfo.ts
|
|
55
62
|
import { useUserIpInfo as useCoreUserIpInfo } from "@funkit/connect-core";
|
|
56
|
-
|
|
57
|
-
// src/utils/safeBigInt.ts
|
|
58
|
-
function safeBigInt(value, fallback) {
|
|
59
|
-
if (typeof value === "bigint") {
|
|
60
|
-
return value;
|
|
61
|
-
}
|
|
62
|
-
if (typeof value === "number") {
|
|
63
|
-
return Number.isFinite(value) && Number.isInteger(value) ? BigInt(value) : fallback;
|
|
64
|
-
}
|
|
65
|
-
if (typeof value === "string" && /^-?\d+$/.test(value)) {
|
|
66
|
-
return BigInt(value);
|
|
67
|
-
}
|
|
68
|
-
return fallback;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// src/hooks/useUserIpInfo.ts
|
|
72
63
|
function useUserIpInfo() {
|
|
73
64
|
const { isUserLoggedIn } = useGeneralWallet();
|
|
74
65
|
return useCoreUserIpInfo({ logger, enabled: isUserLoggedIn });
|
|
@@ -167,61 +158,61 @@ function useAssetAddressPrice({
|
|
|
167
158
|
// src/clients/internal/nado/withdrawalForm.ts
|
|
168
159
|
var PRICE_REFRESH_MS = 6e4;
|
|
169
160
|
function isNadoSourceToken(option) {
|
|
170
|
-
|
|
161
|
+
const decimals = option.asset?.decimals;
|
|
162
|
+
return option.customData?.type === "nado" && typeof decimals === "number" && Number.isInteger(decimals) && decimals >= 0;
|
|
163
|
+
}
|
|
164
|
+
function getMaxEnterableAmount({
|
|
165
|
+
maxWithdrawableX18,
|
|
166
|
+
sequencerFee,
|
|
167
|
+
decimals
|
|
168
|
+
}) {
|
|
169
|
+
const max = safeBigInt(maxWithdrawableX18, 0n);
|
|
170
|
+
if (max <= 0n || decimals === void 0) {
|
|
171
|
+
return "0";
|
|
172
|
+
}
|
|
173
|
+
const maxRaw = x18ToRawBaseUnit(max, decimals);
|
|
174
|
+
const feeRaw = x18ToRawBaseUnit(sequencerFee, decimals);
|
|
175
|
+
return formatUnits(maxRaw + feeRaw, decimals);
|
|
176
|
+
}
|
|
177
|
+
function getSequencerFee(feeRates, option) {
|
|
178
|
+
if (!option) {
|
|
179
|
+
return { x18: 0n, tokenAmount: 0 };
|
|
180
|
+
}
|
|
181
|
+
const x18 = safeBigInt(
|
|
182
|
+
feeRates?.withdraw_sequencer_fees?.[option.productId],
|
|
183
|
+
0n
|
|
184
|
+
);
|
|
185
|
+
return { x18, tokenAmount: Number(x18ToTokenUnits(x18, option.decimals)) };
|
|
171
186
|
}
|
|
172
187
|
function useNadoWithdrawalForm(config, selectedSourceToken) {
|
|
173
188
|
const nadoConfig = isNadoWithdrawalConfig(config) ? config : void 0;
|
|
174
189
|
const isNado = !!nadoConfig;
|
|
175
190
|
const subaccount = nadoConfig?.customerConfig.subaccount;
|
|
191
|
+
const { t } = useFunkitTranslation();
|
|
176
192
|
const [spotLeverage, setSpotLeverage] = useState(false);
|
|
193
|
+
const { data: feeRates } = useNadoFeeRates(subaccount);
|
|
177
194
|
useEffect(() => {
|
|
178
195
|
setSpotLeverage(false);
|
|
179
196
|
}, [subaccount]);
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
b.product_id,
|
|
186
|
-
b.balance.amount
|
|
187
|
-
])
|
|
188
|
-
),
|
|
189
|
-
[subaccountInfo]
|
|
190
|
-
);
|
|
197
|
+
const amountToggle = {
|
|
198
|
+
label: t("withdrawal.enableBorrowing"),
|
|
199
|
+
checked: spotLeverage,
|
|
200
|
+
onChange: setSpotLeverage
|
|
201
|
+
};
|
|
191
202
|
const sourceOptions = useMemo(
|
|
192
|
-
() => (nadoConfig?.sourceTokens ?? []).filter(isNadoSourceToken).map(({ asset, customData, symbol, iconSrc }) => {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
(balanceX18 > 0n ? balanceX18 : 0n).toString(),
|
|
202
|
-
asset.decimals
|
|
203
|
-
),
|
|
204
|
-
decimals: asset.decimals,
|
|
205
|
-
tokenAddress: asset.tokenAddress,
|
|
206
|
-
tokenChainId: asset.tokenChainId,
|
|
207
|
-
iconSrc
|
|
208
|
-
};
|
|
209
|
-
}),
|
|
210
|
-
[nadoConfig?.sourceTokens, balanceX18ByProductId]
|
|
203
|
+
() => (nadoConfig?.sourceTokens ?? []).filter(isNadoSourceToken).map(({ asset, customData, symbol, iconSrc }) => ({
|
|
204
|
+
productId: customData.productId,
|
|
205
|
+
symbol,
|
|
206
|
+
decimals: asset.decimals,
|
|
207
|
+
tokenAddress: asset.tokenAddress,
|
|
208
|
+
tokenChainId: asset.tokenChainId,
|
|
209
|
+
iconSrc
|
|
210
|
+
})),
|
|
211
|
+
[nadoConfig?.sourceTokens]
|
|
211
212
|
);
|
|
212
213
|
const selectedOption = sourceOptions.find(
|
|
213
214
|
(option) => option.symbol === selectedSourceToken
|
|
214
215
|
);
|
|
215
|
-
const selectedProductId = selectedOption?.productId;
|
|
216
|
-
useEffect(() => {
|
|
217
|
-
if (selectedProductId === void 0) {
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
logger.info("nado:withdrawal:sourceSelected", {
|
|
221
|
-
productId: selectedProductId,
|
|
222
|
-
symbol: selectedSourceToken
|
|
223
|
-
});
|
|
224
|
-
}, [selectedProductId, selectedSourceToken]);
|
|
225
216
|
const { price: sourceTokenUsdPrice } = useAssetAddressPrice({
|
|
226
217
|
chainId: selectedOption?.tokenChainId,
|
|
227
218
|
assetTokenAddress: selectedOption?.tokenAddress,
|
|
@@ -234,24 +225,12 @@ function useNadoWithdrawalForm(config, selectedSourceToken) {
|
|
|
234
225
|
sender: subaccount,
|
|
235
226
|
spotLeverage
|
|
236
227
|
});
|
|
237
|
-
const
|
|
238
|
-
const withdrawableBalanceTokenUnits =
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
const feeX18 = feeRates?.withdraw_sequencer_fees?.[selectedOption.productId];
|
|
244
|
-
if (feeX18 === void 0) {
|
|
245
|
-
return 0;
|
|
246
|
-
}
|
|
247
|
-
return Number(x18ToTokenUnits(feeX18, selectedOption.decimals));
|
|
248
|
-
}, [isNado, selectedOption, feeRates]);
|
|
249
|
-
const { t } = useFunkitTranslation();
|
|
250
|
-
const amountToggle = isNado ? {
|
|
251
|
-
label: t("withdrawal.enableBorrowing"),
|
|
252
|
-
checked: spotLeverage,
|
|
253
|
-
onChange: setSpotLeverage
|
|
254
|
-
} : void 0;
|
|
228
|
+
const sequencerFee = getSequencerFee(feeRates, selectedOption);
|
|
229
|
+
const withdrawableBalanceTokenUnits = getMaxEnterableAmount({
|
|
230
|
+
maxWithdrawableX18,
|
|
231
|
+
sequencerFee: sequencerFee.x18,
|
|
232
|
+
decimals: selectedOption?.decimals
|
|
233
|
+
});
|
|
255
234
|
const buildSubmitCustomerData = () => {
|
|
256
235
|
if (!isNado || !selectedOption) {
|
|
257
236
|
return void 0;
|
|
@@ -259,21 +238,21 @@ function useNadoWithdrawalForm(config, selectedSourceToken) {
|
|
|
259
238
|
logger.info("nado:withdrawal:submit", {
|
|
260
239
|
productId: selectedOption.productId,
|
|
261
240
|
spotLeverage,
|
|
262
|
-
sequencerFeeTokenAmount
|
|
241
|
+
sequencerFeeTokenAmount: sequencerFee.tokenAmount,
|
|
242
|
+
selectedSourceToken: selectedOption
|
|
263
243
|
});
|
|
264
244
|
return {
|
|
265
245
|
customerName: "nado",
|
|
266
|
-
productId: selectedOption.productId,
|
|
267
246
|
spotLeverage,
|
|
268
|
-
sequencerFeeTokenAmount
|
|
247
|
+
sequencerFeeTokenAmount: sequencerFee.tokenAmount,
|
|
248
|
+
selectedSourceToken: selectedOption
|
|
269
249
|
};
|
|
270
250
|
};
|
|
271
251
|
return {
|
|
272
252
|
isNado,
|
|
273
|
-
amountToggle,
|
|
274
|
-
maxWithdrawableTokenUnits,
|
|
253
|
+
amountToggle: isNado ? amountToggle : void 0,
|
|
275
254
|
withdrawableBalanceTokenUnits,
|
|
276
|
-
sequencerFeeTokenAmount,
|
|
255
|
+
sequencerFeeTokenAmount: sequencerFee.tokenAmount,
|
|
277
256
|
sourceTokenUsdPrice,
|
|
278
257
|
buildSubmitCustomerData
|
|
279
258
|
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Follows a submitted Nado withdrawal through to the user's wallet.
|
|
3
|
+
*
|
|
4
|
+
* Nado sends to a Fun deposit address (UDA), and the eoa scanner records the
|
|
5
|
+
* arrival as a direct execution against the owner wallet rather than against the
|
|
6
|
+
* address, so this finds that DE in the wallet's recent list and follows its
|
|
7
|
+
* relay status.
|
|
8
|
+
*/
|
|
9
|
+
import { type MergedMultiStepDirectExecution } from '@funkit/connect-core';
|
|
10
|
+
import { type Address } from 'viem';
|
|
11
|
+
export type NadoWithdrawalStatus = 'pending' | 'completed' | 'failed';
|
|
12
|
+
/** The destination-chain transaction that delivered the funds. */
|
|
13
|
+
export interface NadoWithdrawalCompletionTx {
|
|
14
|
+
chainId: string;
|
|
15
|
+
txHash: string;
|
|
16
|
+
/** Set when the destination isn't served by the default explorer. */
|
|
17
|
+
customRedirectUrl: string | undefined;
|
|
18
|
+
}
|
|
19
|
+
export interface NadoWithdrawalTracking {
|
|
20
|
+
status: NadoWithdrawalStatus;
|
|
21
|
+
/** Only once delivered — a failed withdrawal has no completion. */
|
|
22
|
+
completionTx: NadoWithdrawalCompletionTx | undefined;
|
|
23
|
+
}
|
|
24
|
+
export declare function useNadoWithdrawalStatus({ depositAddress, pollIntervalMs, }: {
|
|
25
|
+
/** UDA the sequencer was told to send to. */
|
|
26
|
+
depositAddress: Address | undefined;
|
|
27
|
+
pollIntervalMs: number;
|
|
28
|
+
}): NadoWithdrawalTracking;
|
|
29
|
+
/**
|
|
30
|
+
* Ours is the direct execution at this UDA that appeared after we started
|
|
31
|
+
* watching.
|
|
32
|
+
*
|
|
33
|
+
* - The scanner stamps the address it saw the transfer at into `sourceOfFund`
|
|
34
|
+
* (`eoa_scanner|eoa|0x…`), the only field on a DE carrying the full UDA —
|
|
35
|
+
* `clientMetadata.depositAddress` comes back null.
|
|
36
|
+
* - `knownTxHashes` excludes earlier withdrawals that reused the same UDA. With
|
|
37
|
+
* one withdrawal in flight per destination that identifies ours exactly; two
|
|
38
|
+
* concurrent ones to the same destination can't be told apart by any field a
|
|
39
|
+
* DE carries.
|
|
40
|
+
*/
|
|
41
|
+
export declare function findDirectExecutionForDepositAddress(directExecutions: MergedMultiStepDirectExecution[] | undefined, depositAddress: Address | undefined, knownTxHashes: ReadonlySet<string>): MergedMultiStepDirectExecution | undefined;
|