@funkit/connect 9.20.0 → 9.21.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/{chunk-PFIXC5YK.js → chunk-36KVHK22.js} +5 -2
  3. package/dist/{chunk-6K4U3Z4Z.js → chunk-4YEAUICE.js} +5 -0
  4. package/dist/{chunk-NBECXHBY.js → chunk-67BKQQNG.js} +5 -2
  5. package/dist/clients/chunk-52NKHZS2.js +69 -0
  6. package/dist/clients/{chunk-CSONEKIF.js → chunk-KSSSSWR6.js} +1 -1
  7. package/dist/clients/{chunk-47AQXZQE.js → chunk-NCCAYPLO.js} +1 -1
  8. package/dist/clients/{chunk-JOM2J5WB.js → chunk-OWXKWC7I.js} +27 -16
  9. package/dist/clients/{chunk-UNCVGPTD.js → chunk-ZMVXBMON.js} +1 -1
  10. package/dist/clients/fanatics.css +2891 -2702
  11. package/dist/clients/fanatics.js +5 -5
  12. package/dist/clients/lighter.css +2891 -2702
  13. package/dist/clients/lighter.js +3 -3
  14. package/dist/clients/nado.d.ts +78 -0
  15. package/dist/clients/nado.js +107 -0
  16. package/dist/clients/polymarket/PolymarketDepositAccountDropdown.css +2900 -2708
  17. package/dist/clients/polymarket/PolymarketDepositAccountDropdown.js +5 -5
  18. package/dist/clients/polymarket/index.css +2900 -2708
  19. package/dist/clients/polymarket/index.js +5 -5
  20. package/dist/components/Box/Box.d.ts +21 -21
  21. package/dist/components/FunButton/FunButton.css.d.ts +1 -0
  22. package/dist/components/FunOptionBox/FunOptionBox.css.d.ts +1 -1
  23. package/dist/css/sprinkles.css.d.ts +33 -21
  24. package/dist/index.css +2900 -2708
  25. package/dist/index.js +176 -150
  26. package/dist/modals/WithdrawalModal/WithdrawalContent.d.ts +7 -0
  27. package/dist/providers/FunkitThemeProvider.d.ts +18 -0
  28. package/dist/themes/baseTheme.d.ts +3 -1
  29. package/dist/themes/baseTheme.js +1 -1
  30. package/dist/themes/darkTheme.js +2 -2
  31. package/dist/themes/lightTheme.js +2 -2
  32. package/dist/wallets/walletConnectors/index.js +32 -32
  33. package/package.json +2 -2
  34. package/dist/clients/chunk-JVTKIEOP.js +0 -69
@@ -1,14 +1,14 @@
1
1
  "use client";
2
2
  import {
3
3
  AsyncImage
4
- } from "./chunk-47AQXZQE.js";
4
+ } from "./chunk-NCCAYPLO.js";
5
5
  import {
6
6
  useFunkitConfig
7
- } from "./chunk-UNCVGPTD.js";
7
+ } from "./chunk-ZMVXBMON.js";
8
8
  import {
9
9
  Box,
10
10
  useFunkitTranslation
11
- } from "./chunk-JVTKIEOP.js";
11
+ } from "./chunk-52NKHZS2.js";
12
12
  import {
13
13
  logger
14
14
  } from "./chunk-UUHGOBKZ.js";
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Nado deposit routed through the Ink VaultDepositooor.
3
+ *
4
+ * Each deposit is a 2-action batch:
5
+ * 1. approve(collateralToken, VAULT_DEPOSITOR, maxUint256) — covers the live balance pull
6
+ * 2. VAULT_DEPOSITOR.deposit(collateralToken, NADO_ENDPOINT, calldata, 0)
7
+ *
8
+ * No zero-first approve reset: USDT0 on Ink (TetherTokenOFTExtension) inherits
9
+ * OpenZeppelin's plain approve — verified on the Ink explorer, no legacy
10
+ * non-zero->non-zero revert — and the other collaterals are standard OZ tokens.
11
+ *
12
+ * The Endpoint calldata carries AMOUNT_PLACEHOLDER where the uint128 amount
13
+ * goes; the VaultDepositooor injects its caller's LIVE collateral balance over
14
+ * the placeholder before calling the Endpoint. That makes the deposit robust
15
+ * to bridge fee drift: whatever actually arrived is what gets deposited, with
16
+ * no under-funded revert and no dust stranded on the EOA. The selector is the
17
+ * canonical uint128 one (0x221f0939, registered for the Endpoint on the Ink
18
+ * VaultDepositooor) while the head encodes the amount slot as uint256 so the
19
+ * 32-byte placeholder word fits — uint128 and uint256 head-encode identically.
20
+ *
21
+ * `subaccount` packs the recipient address (high 20 bytes) with the
22
+ * subaccount name "default" (right-padded to the remaining 12 bytes) into a
23
+ * single bytes32 word. `productId` is per-collateral and is looked up by the
24
+ * integrator from the Nado SpotEngine allowlist.
25
+ *
26
+ * Spec: https://www.notion.so/the-fun-group/37bfc3b2a002816bac41c920902e03c2
27
+ */
28
+ import { type Address, type Hex } from 'viem';
29
+ import type { FunkitCheckoutActionParams } from '../providers/FunkitCheckoutContext/types';
30
+ /** Nado Endpoint on Ink mainnet (chain 57073). */
31
+ export declare const NADO_ENDPOINT_ADDRESS: `0x${string}`;
32
+ /** VaultDepositooor on Ink — fresh CREATE3 deploy (differs from the canonical
33
+ * address on other chains). The Nado Endpoint is registered on it with
34
+ * selector 0x221f0939 and no decimal conversion. Mirrors
35
+ * VAULT_DEPOSITOR_ADDRESSES[INK] in fun-backend's packages/types. */
36
+ export declare const INK_VAULT_DEPOSITOR_ADDRESS: `0x${string}`;
37
+ /** Sentinel value Nado treats as "no referral". */
38
+ export declare const NADO_NO_REFERRAL_CODE = "-1";
39
+ /** Default subaccount name used by the Nado UI/SDK. */
40
+ export declare const NADO_DEFAULT_SUBACCOUNT_NAME = "default";
41
+ /**
42
+ * Build a Nado `bytes32` subaccount from an owner address and subaccount
43
+ * name. Layout: `[owner (20 bytes)] [name (right-padded to 12 bytes)]`.
44
+ *
45
+ * Throws if `name` encodes to more than 12 bytes — without this, `pad()`
46
+ * surfaces viem's opaque `SizeExceedsPaddingSizeError`.
47
+ */
48
+ export declare function buildNadoSubaccount(owner: Address, name?: string): Hex;
49
+ export interface NadoDepositActionsConfig {
50
+ /** Address credited on Nado (typically the connected wallet). */
51
+ recipientAddress: Address | undefined;
52
+ /** Collateral ERC20 on Ink being deposited (USDT0, kBTC, WETH, USDC, ...). */
53
+ collateralTokenAddress: Address;
54
+ /** Nado SpotEngine productId for the collateral token. */
55
+ productId: number;
56
+ /** Optional subaccount name. Defaults to "default". */
57
+ subaccountName?: string;
58
+ /** Optional referral code. Defaults to the no-referral sentinel "-1". */
59
+ referralCode?: string;
60
+ }
61
+ /**
62
+ * Builds the 2-action batch (approve + deposit) for a Nado collateral
63
+ * deposit routed through the Endpoint.
64
+ *
65
+ * Usage:
66
+ * ```ts
67
+ * const checkoutConfig: FunkitCheckoutConfig = {
68
+ * // ...
69
+ * generateActionsParams: () => async (amount, output) =>
70
+ * createNadoDepositActions({
71
+ * recipientAddress: walletAddress,
72
+ * collateralTokenAddress: output.targetAsset,
73
+ * productId: NADO_PRODUCT_ID_BY_TOKEN[output.targetAsset],
74
+ * }),
75
+ * }
76
+ * ```
77
+ */
78
+ export declare function createNadoDepositActions(config: NadoDepositActionsConfig): FunkitCheckoutActionParams[];
@@ -0,0 +1,107 @@
1
+ "use client";
2
+
3
+ // src/clients/nado.tsx
4
+ import {
5
+ concat,
6
+ encodeAbiParameters,
7
+ erc20Abi,
8
+ getAddress,
9
+ maxUint256,
10
+ pad,
11
+ stringToHex,
12
+ toFunctionSelector
13
+ } from "viem";
14
+ var NADO_ENDPOINT_ADDRESS = getAddress(
15
+ "0x05ec92d78ed421f3d3ada77ffde167106565974e"
16
+ );
17
+ var INK_VAULT_DEPOSITOR_ADDRESS = getAddress(
18
+ "0xDB9d579B0DCbf566E372C73A2e374c44B161E1Ee"
19
+ );
20
+ var AMOUNT_PLACEHOLDER = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffdeadbeefn;
21
+ var VAULT_DEPOSITOR_ABI = [
22
+ {
23
+ name: "deposit",
24
+ type: "function",
25
+ stateMutability: "nonpayable",
26
+ inputs: [
27
+ { name: "token", type: "address" },
28
+ { name: "vault", type: "address" },
29
+ { name: "callData", type: "bytes" },
30
+ { name: "minAmountOut", type: "uint256" }
31
+ ],
32
+ outputs: []
33
+ }
34
+ ];
35
+ var NADO_NO_REFERRAL_CODE = "-1";
36
+ var NADO_DEFAULT_SUBACCOUNT_NAME = "default";
37
+ var NADO_SUBACCOUNT_NAME_MAX_BYTES = 12;
38
+ function buildNadoSubaccount(owner, name = NADO_DEFAULT_SUBACCOUNT_NAME) {
39
+ const nameHex = stringToHex(name);
40
+ const nameByteLength = (nameHex.length - 2) / 2;
41
+ if (nameByteLength > NADO_SUBACCOUNT_NAME_MAX_BYTES) {
42
+ throw new Error(
43
+ `Nado subaccount name must encode to \u2264 ${NADO_SUBACCOUNT_NAME_MAX_BYTES} bytes (got ${nameByteLength}: "${name}")`
44
+ );
45
+ }
46
+ return concat([
47
+ owner,
48
+ pad(nameHex, { dir: "right", size: NADO_SUBACCOUNT_NAME_MAX_BYTES })
49
+ ]);
50
+ }
51
+ function createNadoDepositActions(config) {
52
+ const {
53
+ recipientAddress,
54
+ collateralTokenAddress,
55
+ productId,
56
+ subaccountName,
57
+ referralCode = NADO_NO_REFERRAL_CODE
58
+ } = config;
59
+ if (!recipientAddress) {
60
+ throw new Error("Please connect your wallet before starting a Nado deposit");
61
+ }
62
+ const collateral = getAddress(collateralTokenAddress);
63
+ const subaccount = buildNadoSubaccount(recipientAddress, subaccountName);
64
+ const depositCalldata = concat([
65
+ toFunctionSelector(
66
+ "depositCollateralWithReferral(bytes32,uint32,uint128,string)"
67
+ ),
68
+ encodeAbiParameters(
69
+ [
70
+ { type: "bytes32" },
71
+ { type: "uint32" },
72
+ { type: "uint256" },
73
+ { type: "string" }
74
+ ],
75
+ [subaccount, productId, AMOUNT_PLACEHOLDER, referralCode]
76
+ )
77
+ ]);
78
+ return [
79
+ // MAX approve so the pull covers whatever balance actually arrived (the
80
+ // amount is only known at execution); the spender is Fun's own audited
81
+ // VaultDepositooor. No zero-first reset needed: Ink USDT0 uses plain OZ
82
+ // approve (verified), unlike legacy mainnet USDT.
83
+ {
84
+ contractAbi: erc20Abi,
85
+ contractAddress: collateral,
86
+ functionName: "approve",
87
+ functionArgs: [INK_VAULT_DEPOSITOR_ADDRESS, maxUint256]
88
+ },
89
+ // VaultDepositooor pulls the live balance, injects it over the
90
+ // placeholder, and calls the Endpoint. minAmountOut is 0 because the
91
+ // collateral passes through 1:1 (no vault rate to bound).
92
+ {
93
+ contractAbi: VAULT_DEPOSITOR_ABI,
94
+ contractAddress: INK_VAULT_DEPOSITOR_ADDRESS,
95
+ functionName: "deposit",
96
+ functionArgs: [collateral, NADO_ENDPOINT_ADDRESS, depositCalldata, 0n]
97
+ }
98
+ ];
99
+ }
100
+ export {
101
+ INK_VAULT_DEPOSITOR_ADDRESS,
102
+ NADO_DEFAULT_SUBACCOUNT_NAME,
103
+ NADO_ENDPOINT_ADDRESS,
104
+ NADO_NO_REFERRAL_CODE,
105
+ buildNadoSubaccount,
106
+ createNadoDepositActions
107
+ };