@funkit/connect 10.2.1 → 10.4.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/{chunk-36KVHK22.js → chunk-L67HP4HQ.js} +1 -1
- package/dist/clients/chunk-2YWQL3AO.js +46 -0
- package/dist/clients/chunk-APQYFP6X.js +207 -0
- package/dist/clients/chunk-BNMZM23Q.js +42 -0
- package/dist/clients/chunk-HOORQPSY.js +4660 -0
- package/dist/clients/chunk-II5CZTBC.js +18 -0
- package/dist/clients/chunk-KNHO756P.js +28 -0
- package/dist/clients/chunk-L2KSNS7H.js +112 -0
- package/dist/clients/{chunk-ZAXSDMDU.js → chunk-M6C7MBQN.js} +2 -2
- package/dist/clients/chunk-OZ3KD24N.js +107 -0
- package/dist/clients/{chunk-E3USJY7A.js → chunk-RCMAGKMG.js} +35 -4
- 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/lighter.css +12 -1
- package/dist/clients/lighter.js +118 -42
- package/dist/clients/mallard.js +9 -24
- package/dist/clients/polymarket/PolymarketDepositAccountDropdown.css +12 -1
- package/dist/clients/polymarket/PolymarketDepositAccountDropdown.js +3 -3
- package/dist/clients/polymarket/index.css +12 -1
- package/dist/clients/polymarket/index.js +3 -3
- package/dist/components/ChainIcon/ChainIcon.d.ts +16 -0
- package/dist/components/Dialog/Dialog.d.ts +1 -1
- package/dist/components/Dialog/hooks.d.ts +1 -2
- package/dist/components/FreeUsdcBanner/FreeUsdcBanner.d.ts +1 -1
- package/dist/components/FunAssetAvatar/FunAssetAvatar.d.ts +1 -2
- package/dist/components/FunInput/FunInput.d.ts +2 -0
- package/dist/components/FunkitTrans.d.ts +14 -0
- package/dist/hooks/useChainMetadata.d.ts +11 -0
- package/dist/hooks/useFunkitTranslation.d.ts +3 -1
- package/dist/hooks/usePaymentMethodTabs.d.ts +10 -1
- package/dist/hooks/useSwappedIframeLifecycle.d.ts +5 -2
- package/dist/hooks/useSwappedPreload.d.ts +8 -3
- package/dist/hooks/useUserIpInfo.d.ts +1 -19
- package/dist/index.css +12 -1
- package/dist/index.js +15902 -15844
- package/dist/modals/CheckoutModal/InputAmount/InputAmount.css.d.ts +1 -0
- package/dist/modals/CheckoutModal/SourceChange/FormOfPaymentsList.d.ts +6 -2
- package/dist/modals/CheckoutModal/SourceChange/SourceChange.d.ts +29 -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/Withdrawal/WithdrawalComplete.d.ts +15 -1
- package/dist/modals/CheckoutModal/Withdrawal/WithdrawalEnterAmount.d.ts +12 -1
- package/dist/modals/CheckoutModal/isWithdrawalStep.d.ts +25 -0
- package/dist/modals/WithdrawalModal/WithdrawalContent.d.ts +15 -1
- package/dist/modals/WithdrawalModal/WithdrawalMethodSelect.d.ts +5 -1
- package/dist/providers/FunkitCheckoutContext/index.d.ts +15 -1
- package/dist/providers/FunkitCheckoutContext/types.d.ts +34 -5
- package/dist/providers/FunkitConfigContext.d.ts +4 -0
- package/dist/providers/FunkitI18nProvider.d.ts +6 -2
- package/dist/providers/SwappedProvider.d.ts +5 -3
- package/dist/themes/darkTheme.js +1 -1
- package/dist/utils/tokenIconUrl.d.ts +5 -0
- 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 +59 -59
- 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 +7 -5
- package/dist/clients/chunk-STLOQEN7.js +0 -11
- package/dist/components/FunInput/FunTextAreaInput.css.d.ts +0 -1
- package/dist/components/FunInput/FunTextAreaInput.d.ts +0 -3
- package/dist/components/Icons/AcornsIcon.d.ts +0 -4
- package/dist/components/Icons/AlpacaIcon.d.ts +0 -4
- package/dist/components/Icons/BitFlyerIcon.d.ts +0 -4
- package/dist/components/Icons/BitfinexIcon.d.ts +0 -4
- package/dist/components/Icons/BitstampIcon.d.ts +0 -4
- package/dist/components/Icons/BrokerageIcon.d.ts +0 -4
- package/dist/components/Icons/CexloIcon.d.ts +0 -4
- package/dist/components/Icons/CoinlistIcon.d.ts +0 -4
- package/dist/components/Icons/CryptoComIcon.d.ts +0 -4
- package/dist/components/Icons/CryptoIcon.d.ts +0 -2
- package/dist/components/Icons/DeviceConfirmationIcon.d.ts +0 -2
- package/dist/components/Icons/EmailConfirmationIcon.d.ts +0 -2
- package/dist/components/Icons/EtoroIcon.d.ts +0 -4
- package/dist/components/Icons/EtradeIcon.d.ts +0 -4
- package/dist/components/Icons/HuobiIcon.d.ts +0 -4
- package/dist/components/Icons/KucoinIcon.d.ts +0 -4
- package/dist/components/Icons/LightningBoltIcon.d.ts +0 -4
- package/dist/components/Icons/LockIcon.d.ts +0 -4
- package/dist/components/Icons/MailIcon.d.ts +0 -6
- package/dist/components/Icons/New/LinkExternalIcon.d.ts +0 -4
- package/dist/components/Icons/New/MessageIcon.d.ts +0 -2
- package/dist/components/Icons/OkcoinIcon.d.ts +0 -4
- package/dist/components/Icons/OkxIcon.d.ts +0 -4
- package/dist/components/Icons/PublicIcon.d.ts +0 -4
- package/dist/components/Icons/RobinhoodIcon.d.ts +0 -4
- package/dist/components/Icons/SocialMediaIcons.d.ts +0 -13
- package/dist/components/Icons/SocialsIcon.d.ts +0 -2
- package/dist/components/Icons/StashIcon.d.ts +0 -4
- package/dist/components/Icons/WeBullIcon.d.ts +0 -4
- package/dist/components/Icons/WhitelistIcon.d.ts +0 -2
- package/dist/hooks/useIsUsUser.d.ts +0 -1
- package/dist/utils/privyHelper.d.ts +0 -3
- package/dist/utils/safeJSON.d.ts +0 -5
- package/dist/utils/tokenTransfer/disabledList.d.ts +0 -1
- package/dist/wallets/walletConnectors/{chunk-RB3HR4R2.js → chunk-4NV5BYRP.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-YEZM4CK4.js → chunk-AVDUNQUW.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-MIQTHJ6X.js → chunk-GUQM4QSL.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-4T6ZSRJF.js → chunk-IULPZP2Q.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-HNRB7KJU.js → chunk-JPN6TWIT.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-ZNX4EMPB.js → chunk-KCRO2AGO.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-STVVP43G.js → chunk-KI5Y2BBF.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-X6CGV36L.js → chunk-NR2OGDHQ.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-UK7C2JXW.js → chunk-OEEGYENV.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-F5XEEVG6.js → chunk-OX37G4YT.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-RVOY537T.js → chunk-SWFF3TWJ.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-CPI4TD43.js → chunk-TKB2OY6G.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-2VP2F6EK.js → chunk-W2LCLDPX.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-6BW3HLBG.js → chunk-WAHGI5L7.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-HTHAK6XB.js → chunk-WKNQMP4A.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-VTM6EECM.js → chunk-XCNHV3HS.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-CCQV2ZET.js → chunk-YO2K4MBH.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-VAPGUPHO.js → chunk-YQFGVZGR.js} +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# @funkit/connect
|
|
2
2
|
|
|
3
|
+
## 10.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- b2dadf3: Add `uiCustomizations.confirmationScreen.autoExpandFeesSummary` and `uiCustomizations.withdrawalScreen.autoExpandFeesSummary` config flags to auto-expand the transaction fee breakdown on the deposit and withdrawal screens.
|
|
8
|
+
- 446bc6b: Add the Nado network layer under the SDK-private `clients/internal/nado/` directory: gateway/indexer client, live product list, and react-query hooks for the withdrawal flow.
|
|
9
|
+
- a7215d9: Add the Nado protocol core (subaccount encoding, x18 amount conversions, and the `withdraw_collateral_v2` EIP-712 typed-data builder) under the SDK-private `clients/internal/` directory, which is blocked from consumer imports via a `null` exports-map entry.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- ce3422f: fix(connect): preserve cashier formFactor when entering the withdraw tab (fixes React #185 render loop)
|
|
14
|
+
- ce3422f: fix(connect): keep the cashier withdraw tab after "New deposit"
|
|
15
|
+
- 5aedc00: feat(connect): add explicit formFactor:'cashier' checkout discriminant (requires withdrawalConfig)
|
|
16
|
+
- 0755d6b: Automatically fall back to CDN-derived chain icons when local chain metadata is missing
|
|
17
|
+
- 96f35d1: Gate the Free USDC banner per direction — the banner self-gates on `depositEnabled`/`withdrawalEnabled` so deposits show it while withdrawals stay off after subsidy shutoff.
|
|
18
|
+
- 1aaec91: Split the Swapped iframe context into independent deposit and withdrawal slots so both flows can co-exist without clobbering each other.
|
|
19
|
+
- 7d52158: Automatically fall back to CDN-derived token icons when the asset is missing from the SDK's bundled logos
|
|
20
|
+
- dad6cb2: Move the duplicated Moonpay→ipapi IP-country lookup into a shared `useUserIpInfo` hook in `@funkit/connect-core`; web and RN keep thin wrappers injecting their `logger`, `enabled` gate, and `staleTime`. Public API and web behavior unchanged.
|
|
21
|
+
- Updated dependencies [0755d6b]
|
|
22
|
+
- Updated dependencies [96f35d1]
|
|
23
|
+
- Updated dependencies [dad6cb2]
|
|
24
|
+
- @funkit/connect-core@2.1.0
|
|
25
|
+
|
|
26
|
+
## 10.3.0
|
|
27
|
+
|
|
28
|
+
### Minor Changes
|
|
29
|
+
|
|
30
|
+
- 6d44b6d: Fix react-i18next context takeover: FunkitProvider no longer wraps host children in an I18nextProvider; funkit components bind funkit's private i18n instance explicitly.
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- 3a15d08: fix(connect): protect checkout amount input font-size from host page overrides
|
|
35
|
+
- 4363863: fix(connect): allow custom dark inputBackground
|
|
36
|
+
- 4363863: refactor(connect): read cashier withdrawComplete config from seeded modal state
|
|
37
|
+
- 4363863: fix(connect): harden Swapped preload against tab-switch race
|
|
38
|
+
- 4363863: feat(connect): wire cashier withdraw tab to enter-amount step
|
|
39
|
+
- 4363863: fix(connect): complete cashier withdrawal flow
|
|
40
|
+
- 4363863: feat(connect): fill cashier withdrawal enter-amount step
|
|
41
|
+
- 4363863: feat(connect): cashier withdrawal convert/revert lifecycle
|
|
42
|
+
- 0d78595: Remove dead code: unused internal hooks/utils (`useIsUsUser`, `privyHelper`, `safeJSON`, `tokenTransfer/disabledList` shim), the unused `FunTextAreaInput` component, and 30 story-only icon components. Internal-only removals — nothing was reachable through the package's public exports.
|
|
43
|
+
- 659bf2d: Extract the cashier withdrawal-step condition into a pure isWithdrawalStep helper
|
|
44
|
+
- 4363863: feat(connect): support cashier flow without swapped withdrawals
|
|
45
|
+
- 8e03a99: Remove 40 unused translation keys from all locale files. Every removed key was verified to have zero references across the entire monorepo (not just connect src). The 21 other keys flagged by `find-unused-i18n-keys.mjs` are false positives with verified usages (ternary-selected keys, usages in `@funkit/connect-core`, and typed `labelKey` props) and were kept.
|
|
46
|
+
- 4363863: feat(connect): hide fops list sections in cashier withdraw tab
|
|
47
|
+
- 4363863: feat(connect): update cashier tab wordings
|
|
48
|
+
|
|
3
49
|
## 10.2.1
|
|
4
50
|
|
|
5
51
|
### Patch Changes
|
|
@@ -85,7 +85,7 @@ var darkTheme = ({
|
|
|
85
85
|
alwaysVisibleLabelBackgroundHover: "transparent",
|
|
86
86
|
// input
|
|
87
87
|
inputLabel: customColors?.primaryText ?? "#FFF",
|
|
88
|
-
inputBackground: "#000000",
|
|
88
|
+
inputBackground: customColors?.inputBackground ?? "#000000",
|
|
89
89
|
inputBackgroundHover: customColors?.offBackground ?? "#1F1F1F",
|
|
90
90
|
inputBorderBase: "#333333",
|
|
91
91
|
inputBorderHover: "#525252",
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/clients/internal/nado/errors.ts
|
|
4
|
+
var NADO_ERROR_CODES = {
|
|
5
|
+
/** Amount would open a borrow with `spot_leverage: "false"`. */
|
|
6
|
+
SPOT_EXECUTE_EXCEEDS_BORROW_LIMIT: 2017,
|
|
7
|
+
/** Stale `tx_nonce` — refetch and retry once. */
|
|
8
|
+
INVALID_NONCE: 2022,
|
|
9
|
+
/** Subaccount has never deposited, so it doesn't exist on Nado yet. */
|
|
10
|
+
NO_PRIOR_DEPOSIT: 2024,
|
|
11
|
+
/** Withdrawal tx not found at the given submission index. */
|
|
12
|
+
INVALID_WITHDRAWAL_IDX: 3004,
|
|
13
|
+
/** Fast-withdrawal validator signatures not aggregated yet. */
|
|
14
|
+
NOT_ENOUGH_FAST_WITHDRAWAL_SIGNATURES: 3005,
|
|
15
|
+
/** Protocol 24h withdrawal limit exceeded. */
|
|
16
|
+
WITHDRAW_RISK: 4004
|
|
17
|
+
};
|
|
18
|
+
var NadoGatewayError = class extends Error {
|
|
19
|
+
constructor(message, options) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.name = "NadoGatewayError";
|
|
22
|
+
this.kind = options.kind;
|
|
23
|
+
this.errorCode = options.errorCode;
|
|
24
|
+
this.httpStatus = options.httpStatus;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
function isNadoTransportError(error) {
|
|
28
|
+
return error instanceof NadoGatewayError && error.kind === "transport";
|
|
29
|
+
}
|
|
30
|
+
function createNadoGatewayError(response, fallbackMessage) {
|
|
31
|
+
return new NadoGatewayError(response.error ?? fallbackMessage, {
|
|
32
|
+
kind: "api",
|
|
33
|
+
errorCode: response.error_code
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function isNadoErrorCode(error, code) {
|
|
37
|
+
return error instanceof NadoGatewayError && error.errorCode === code;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
NADO_ERROR_CODES,
|
|
42
|
+
NadoGatewayError,
|
|
43
|
+
isNadoTransportError,
|
|
44
|
+
createNadoGatewayError,
|
|
45
|
+
isNadoErrorCode
|
|
46
|
+
};
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
getNadoAllProducts,
|
|
4
|
+
getNadoSymbols
|
|
5
|
+
} from "./chunk-OZ3KD24N.js";
|
|
6
|
+
import {
|
|
7
|
+
INK_CHAIN_ID
|
|
8
|
+
} from "./chunk-II5CZTBC.js";
|
|
9
|
+
import {
|
|
10
|
+
multicall
|
|
11
|
+
} from "./chunk-KNHO756P.js";
|
|
12
|
+
import {
|
|
13
|
+
logger
|
|
14
|
+
} from "./chunk-AHYOV7AV.js";
|
|
15
|
+
|
|
16
|
+
// src/clients/internal/nado/products.ts
|
|
17
|
+
import { erc20Abi, getAddress, isAddress } from "viem";
|
|
18
|
+
var NADO_XSTOCK_WITHDRAWALS_ENABLED = false;
|
|
19
|
+
var XSTOCK_SYMBOL_PATTERN = /^w\w+x$/;
|
|
20
|
+
var NADO_SUPPORTED_PRODUCTS = [
|
|
21
|
+
{
|
|
22
|
+
productId: 0,
|
|
23
|
+
symbol: "USDT0",
|
|
24
|
+
tokenAddress: getAddress("0x0200C29006150606B650577BBE7B6248F58470c1"),
|
|
25
|
+
decimals: 6,
|
|
26
|
+
isXstock: false,
|
|
27
|
+
isTradable: true,
|
|
28
|
+
withdrawFeeX18: "1000000000000000000"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
productId: 1,
|
|
32
|
+
symbol: "KBTC",
|
|
33
|
+
tokenAddress: getAddress("0x73E0C0d45E048D25Fc26Fa3159b0aA04BfA4Db98"),
|
|
34
|
+
decimals: 8,
|
|
35
|
+
isXstock: false,
|
|
36
|
+
isTradable: true,
|
|
37
|
+
withdrawFeeX18: "10000000000000"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
productId: 3,
|
|
41
|
+
symbol: "WETH",
|
|
42
|
+
tokenAddress: getAddress("0x4200000000000000000000000000000000000006"),
|
|
43
|
+
decimals: 18,
|
|
44
|
+
isXstock: false,
|
|
45
|
+
isTradable: true,
|
|
46
|
+
withdrawFeeX18: "300000000000000"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
productId: 5,
|
|
50
|
+
symbol: "USDC",
|
|
51
|
+
tokenAddress: getAddress("0x2D270e6886d130D724215A266106e6832161EAEd"),
|
|
52
|
+
decimals: 6,
|
|
53
|
+
isXstock: false,
|
|
54
|
+
isTradable: true,
|
|
55
|
+
withdrawFeeX18: "1000000000000000000"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
productId: 115,
|
|
59
|
+
symbol: "wQQQx",
|
|
60
|
+
tokenAddress: getAddress("0x4C1AE29c159838fC1b224636E28E086EB69101f7"),
|
|
61
|
+
decimals: 18,
|
|
62
|
+
isXstock: true,
|
|
63
|
+
isTradable: true,
|
|
64
|
+
withdrawFeeX18: "2000000000000000"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
productId: 117,
|
|
68
|
+
symbol: "wSPYx",
|
|
69
|
+
tokenAddress: getAddress("0xe7e553cd128f0011777323a0b44a7b96ea1cb540"),
|
|
70
|
+
decimals: 18,
|
|
71
|
+
isXstock: true,
|
|
72
|
+
isTradable: true,
|
|
73
|
+
withdrawFeeX18: "2000000000000000"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
productId: 143,
|
|
77
|
+
symbol: "wAAPLx",
|
|
78
|
+
tokenAddress: getAddress("0x943bf64d566c32a2bcd41ac92fb63c111cc9de8f"),
|
|
79
|
+
decimals: 18,
|
|
80
|
+
isXstock: true,
|
|
81
|
+
isTradable: true,
|
|
82
|
+
withdrawFeeX18: "2000000000000000"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
productId: 145,
|
|
86
|
+
symbol: "wAMZNx",
|
|
87
|
+
tokenAddress: getAddress("0x910cabde3eba7fc1ce64fd14bd680b9f60fa0f90"),
|
|
88
|
+
decimals: 18,
|
|
89
|
+
isXstock: true,
|
|
90
|
+
isTradable: false,
|
|
91
|
+
withdrawFeeX18: "2000000000000000"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
productId: 147,
|
|
95
|
+
symbol: "wGOOGLx",
|
|
96
|
+
tokenAddress: getAddress("0xf8c5308f80e459bb53d9ebe689854d9cbb2caa6f"),
|
|
97
|
+
decimals: 18,
|
|
98
|
+
isXstock: true,
|
|
99
|
+
isTradable: true,
|
|
100
|
+
withdrawFeeX18: "2000000000000000"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
productId: 149,
|
|
104
|
+
symbol: "wMETAx",
|
|
105
|
+
tokenAddress: getAddress("0xe840946ffebcd66b7c4e95095effafadfa0d0e56"),
|
|
106
|
+
decimals: 18,
|
|
107
|
+
isXstock: true,
|
|
108
|
+
isTradable: true,
|
|
109
|
+
withdrawFeeX18: "2000000000000000"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
productId: 151,
|
|
113
|
+
symbol: "wMSFTx",
|
|
114
|
+
tokenAddress: getAddress("0x166fbe68274b6a47e025f4ba17388c539f1fa1d0"),
|
|
115
|
+
decimals: 18,
|
|
116
|
+
isXstock: true,
|
|
117
|
+
isTradable: false,
|
|
118
|
+
withdrawFeeX18: "2000000000000000"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
productId: 153,
|
|
122
|
+
symbol: "wNVDAx",
|
|
123
|
+
tokenAddress: getAddress("0xa8ddb5cd96b5222afe198316e9a57caa642850d5"),
|
|
124
|
+
decimals: 18,
|
|
125
|
+
isXstock: true,
|
|
126
|
+
isTradable: true,
|
|
127
|
+
withdrawFeeX18: "2000000000000000"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
productId: 155,
|
|
131
|
+
symbol: "wTSLAx",
|
|
132
|
+
tokenAddress: getAddress("0xc3FdBe3A68EE5dE461D30415a8165cf9Aefe1171"),
|
|
133
|
+
decimals: 18,
|
|
134
|
+
isXstock: true,
|
|
135
|
+
isTradable: true,
|
|
136
|
+
withdrawFeeX18: "2000000000000000"
|
|
137
|
+
}
|
|
138
|
+
];
|
|
139
|
+
var SUPPORTED_BY_PRODUCT_ID = new Map(
|
|
140
|
+
NADO_SUPPORTED_PRODUCTS.map((p) => [p.productId, p])
|
|
141
|
+
);
|
|
142
|
+
function isWithdrawableNadoProduct(product) {
|
|
143
|
+
return !product.isXstock || NADO_XSTOCK_WITHDRAWALS_ENABLED;
|
|
144
|
+
}
|
|
145
|
+
async function fetchNadoProducts(wagmiConfig, signal) {
|
|
146
|
+
const [{ spot_products }, { symbols }] = await Promise.all([
|
|
147
|
+
getNadoAllProducts(signal),
|
|
148
|
+
getNadoSymbols(signal)
|
|
149
|
+
]);
|
|
150
|
+
const symbolByProductId = new Map(
|
|
151
|
+
Object.values(symbols).filter((s) => s.type === "spot").map((s) => [s.product_id, s])
|
|
152
|
+
);
|
|
153
|
+
const supported = spot_products.flatMap((product) => {
|
|
154
|
+
const fallback = SUPPORTED_BY_PRODUCT_ID.get(product.product_id);
|
|
155
|
+
if (!fallback) {
|
|
156
|
+
return [];
|
|
157
|
+
}
|
|
158
|
+
if (!isAddress(product.config.token)) {
|
|
159
|
+
logger.warn("nado:products_invalid_token", {
|
|
160
|
+
productId: product.product_id,
|
|
161
|
+
token: product.config.token
|
|
162
|
+
});
|
|
163
|
+
return [];
|
|
164
|
+
}
|
|
165
|
+
return [{ product, fallback }];
|
|
166
|
+
});
|
|
167
|
+
if (supported.length === 0) {
|
|
168
|
+
logger.warn("nado:products_fallback", { message: "empty_join" });
|
|
169
|
+
return NADO_SUPPORTED_PRODUCTS;
|
|
170
|
+
}
|
|
171
|
+
const decimalResults = await multicall(wagmiConfig, {
|
|
172
|
+
chainId: INK_CHAIN_ID,
|
|
173
|
+
allowFailure: true,
|
|
174
|
+
contracts: supported.map(({ product }) => ({
|
|
175
|
+
address: getAddress(product.config.token),
|
|
176
|
+
abi: erc20Abi,
|
|
177
|
+
functionName: "decimals"
|
|
178
|
+
}))
|
|
179
|
+
}).catch((error) => {
|
|
180
|
+
logger.warn("nado:products_decimals_multicall_failed", {
|
|
181
|
+
errorMessage: error instanceof Error ? error.message : String(error)
|
|
182
|
+
});
|
|
183
|
+
return void 0;
|
|
184
|
+
});
|
|
185
|
+
return supported.map(({ product, fallback }, i) => {
|
|
186
|
+
const symbolInfo = symbolByProductId.get(product.product_id);
|
|
187
|
+
const decimals = decimalResults?.[i];
|
|
188
|
+
return {
|
|
189
|
+
productId: product.product_id,
|
|
190
|
+
symbol: symbolInfo?.symbol ?? fallback.symbol,
|
|
191
|
+
tokenAddress: getAddress(product.config.token),
|
|
192
|
+
decimals: decimals?.status === "success" ? decimals.result : fallback.decimals,
|
|
193
|
+
isXstock: symbolInfo ? XSTOCK_SYMBOL_PATTERN.test(symbolInfo.symbol) : fallback.isXstock,
|
|
194
|
+
// Withdrawals don't depend on market status (post_only/soft_reduce_only
|
|
195
|
+
// are routine weekend states) — only fully disabled products are out
|
|
196
|
+
isTradable: symbolInfo ? symbolInfo.trading_status !== "not_tradable" : fallback.isTradable,
|
|
197
|
+
withdrawFeeX18: product.config.withdraw_fee_x18 ?? fallback.withdrawFeeX18
|
|
198
|
+
};
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export {
|
|
203
|
+
NADO_XSTOCK_WITHDRAWALS_ENABLED,
|
|
204
|
+
NADO_SUPPORTED_PRODUCTS,
|
|
205
|
+
isWithdrawableNadoProduct,
|
|
206
|
+
fetchNadoProducts
|
|
207
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
NADO_INDEXER_URL
|
|
4
|
+
} from "./chunk-II5CZTBC.js";
|
|
5
|
+
import {
|
|
6
|
+
nadoFetch
|
|
7
|
+
} from "./chunk-L2KSNS7H.js";
|
|
8
|
+
import {
|
|
9
|
+
createNadoGatewayError
|
|
10
|
+
} from "./chunk-2YWQL3AO.js";
|
|
11
|
+
|
|
12
|
+
// src/clients/internal/nado/indexer.ts
|
|
13
|
+
async function getNadoWithdrawalEvents(params, signal) {
|
|
14
|
+
const response = await nadoFetch({
|
|
15
|
+
uri: NADO_INDEXER_URL,
|
|
16
|
+
method: "POST",
|
|
17
|
+
body: {
|
|
18
|
+
events: {
|
|
19
|
+
subaccounts: [params.subaccount],
|
|
20
|
+
// v2 is a distinct indexer event type — our executes are all v2
|
|
21
|
+
event_types: ["withdraw_collateral", "withdraw_collateral_v2"],
|
|
22
|
+
limit: { raw: params.limit ?? 10 }
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
signal
|
|
26
|
+
});
|
|
27
|
+
if ("status" in response && response.status === "failure") {
|
|
28
|
+
throw createNadoGatewayError(response, "Nado indexer request failed");
|
|
29
|
+
}
|
|
30
|
+
return response;
|
|
31
|
+
}
|
|
32
|
+
function findSettlementForNonce(txs, nonce) {
|
|
33
|
+
return txs.find((entry) => {
|
|
34
|
+
const payload = entry.tx.withdraw_collateral_v2 ?? entry.tx.withdraw_collateral;
|
|
35
|
+
return payload !== void 0 && BigInt(payload.nonce) === nonce;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export {
|
|
40
|
+
getNadoWithdrawalEvents,
|
|
41
|
+
findSettlementForNonce
|
|
42
|
+
};
|