@funkit/connect 11.2.0 → 11.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 +100 -0
- package/dist/clients/{chunk-SU3YSNMB.js → chunk-3Y5EIONT.js} +3 -9
- package/dist/clients/chunk-6EU6CXNH.js +20 -0
- package/dist/clients/{chunk-DGBIV3ZS.js → chunk-B7UU2ETA.js} +0 -13
- package/dist/clients/{chunk-QQEGNLGD.js → chunk-EQFVPSR2.js} +1 -1
- package/dist/clients/internal/nado/withdrawalCallback.js +2 -2
- package/dist/clients/internal/nado/withdrawalConfig.d.ts +2 -0
- package/dist/clients/internal/nado/withdrawalConfig.js +2 -2
- package/dist/clients/internal/nado/withdrawalForm.js +13 -58
- package/dist/clients/lighter.d.ts +4 -61
- package/dist/clients/lighter.js +66 -338
- package/dist/clients/nado.d.ts +2 -0
- package/dist/clients/nado.js +7 -6
- package/dist/clients/polymarket/PolymarketDepositAccountDropdown.js +1 -1
- package/dist/clients/polymarket/createPolymarketDepositConfig.d.ts +6 -0
- package/dist/clients/polymarket/index.js +1 -1
- package/dist/components/FunCheckoutHistory/FunCheckoutHistoryContent.d.ts +3 -1
- package/dist/components/FunCheckoutHistory/PendingSuccessScreen.d.ts +3 -1
- package/dist/domains/checkout.d.ts +8 -2
- package/dist/hooks/track/analytics/claimAnalyticsEvent.d.ts +5 -0
- package/dist/hooks/track/analytics/events.d.ts +176 -9
- package/dist/hooks/track/analytics/mappers.d.ts +15 -0
- package/dist/hooks/track/analytics/quote.d.ts +12 -0
- package/dist/hooks/track/analytics/resolveExecutionProgressContext.d.ts +40 -0
- package/dist/hooks/track/analytics/useDepositAnalytics.d.ts +71 -3
- package/dist/hooks/track/analytics/useTrackExecutionProgressEvents.d.ts +17 -0
- package/dist/hooks/track/analytics/useWithdrawalAnalytics.d.ts +18 -0
- package/dist/hooks/track/useTrackV2.d.ts +2 -0
- package/dist/hooks/useAssetPrice.d.ts +1 -6
- package/dist/hooks/useIsBlacklistedWithdrawalAddress.d.ts +4 -1
- package/dist/index.js +2214 -1094
- package/dist/modals/CheckoutModal/ConfirmationStep/useCheckoutConfirmation.d.ts +2 -1
- package/dist/modals/CheckoutModal/ConfirmationStep/useQuoteRefresh.d.ts +5 -1
- package/dist/modals/CheckoutModal/ConfirmationStep/useTrackDepositQuoteEvents.d.ts +20 -0
- package/dist/modals/CheckoutModal/MeldQuotes/useMeldQuotes.d.ts +1 -1
- package/dist/modals/CheckoutModal/SourceChange/useTrackSourceChangeEvents.d.ts +10 -0
- package/dist/modals/CheckoutModal/TransferToken/useTrackDepositNotificationEvents.d.ts +6 -0
- package/dist/modals/CheckoutModal/TransferToken/useTransferTokenTracking.d.ts +9 -3
- package/dist/modals/PolymarketPerpsTransfer/recordPerpsTransfer.d.ts +40 -0
- package/dist/modals/PolymarketPerpsTransfer/useRecordPerpsTransfer.d.ts +24 -0
- package/dist/modals/WithdrawalModal/LighterWithdrawal.d.ts +14 -92
- package/dist/modals/WithdrawalModal/WithdrawAmountInput.d.ts +3 -1
- package/dist/modals/WithdrawalModal/useTrackWithdrawalEvents.d.ts +1 -0
- package/dist/providers/FunkitCheckoutContext/index.d.ts +10 -2
- package/dist/providers/FunkitCheckoutContext/types.d.ts +17 -2
- package/dist/providers/FunkitStatsigProvider.d.ts +1 -1
- package/dist/utils/customer.d.ts +24 -276
- package/dist/utils/lighter.d.ts +1 -83
- package/dist/utils/signature.d.ts +1 -2
- package/dist/utils/withdrawal.d.ts +1 -21
- package/dist/wallets/walletConnectors/index.js +10 -10
- package/package.json +4 -5
- package/dist/clients/chunk-6QCAWEAT.js +0 -53
package/dist/clients/lighter.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
import {
|
|
12
12
|
useLighterAccountQuery,
|
|
13
13
|
useLighterAccountsQuery
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-6EU6CXNH.js";
|
|
15
15
|
import {
|
|
16
16
|
useFunkitConfig
|
|
17
17
|
} from "./chunk-UK64SY6N.js";
|
|
@@ -28,19 +28,11 @@ import {
|
|
|
28
28
|
} from "./chunk-AHYOV7AV.js";
|
|
29
29
|
|
|
30
30
|
// src/clients/lighter.tsx
|
|
31
|
-
import {
|
|
32
|
-
|
|
33
|
-
LIGHTERXYZ_API_KEY,
|
|
34
|
-
createDirectExecution as createDirectExecution2
|
|
35
|
-
} from "@funkit/api-base";
|
|
36
|
-
import { LIGHTER_CHAIN_ID, SOLANA_MAINNET_CHAIN_ID } from "@funkit/chains";
|
|
31
|
+
import { LIGHTERXYZ_API_KEY } from "@funkit/api-base";
|
|
32
|
+
import { SOLANA_MAINNET_CHAIN_ID } from "@funkit/chains";
|
|
37
33
|
import { RELAY_LIGHTER_CHAIN_ID as RELAY_LIGHTER_CHAIN_ID2 } from "@funkit/fun-relay";
|
|
38
|
-
import { retry } from "@lifeomic/attempt";
|
|
39
|
-
import { useQuery as useQuery2 } from "@tanstack/react-query";
|
|
40
34
|
import i18next from "i18next";
|
|
41
35
|
import React4, { useMemo as useMemo2 } from "react";
|
|
42
|
-
import { v4 as uuid2 } from "uuid";
|
|
43
|
-
import { pad as pad2, parseUnits as parseUnits3, toHex } from "viem";
|
|
44
36
|
import { arbitrum, base, bsc, mainnet as mainnet2, optimism } from "viem/chains";
|
|
45
37
|
|
|
46
38
|
// src/components/ChainIcon/ChainIcon.tsx
|
|
@@ -156,6 +148,17 @@ var EvmWallet = ({ size = 20 }) => /* @__PURE__ */ React2.createElement(
|
|
|
156
148
|
)
|
|
157
149
|
);
|
|
158
150
|
|
|
151
|
+
// src/clients/lighter.tsx
|
|
152
|
+
import {
|
|
153
|
+
LIGHTER_DEFAULT_SECURE_MIN_WITHDRAWAL_AMOUNTS as LIGHTER_DEFAULT_SECURE_MIN_WITHDRAWAL_AMOUNTS2,
|
|
154
|
+
LIGHTER_FAST_MAX_WITHDRAWAL_USD as LIGHTER_FAST_MAX_WITHDRAWAL_USD2,
|
|
155
|
+
LIGHTER_USDC_SPOT_SYMBOL as LIGHTER_USDC_SPOT_SYMBOL2,
|
|
156
|
+
getLighterBaseSymbol as getLighterBaseSymbol3,
|
|
157
|
+
createLighterAdaptedWallet,
|
|
158
|
+
trackLighterSecureWithdrawal,
|
|
159
|
+
useLighterWithdrawalDelaySeconds
|
|
160
|
+
} from "@funkit/connect-core/clients/lighter";
|
|
161
|
+
|
|
159
162
|
// src/modals/WithdrawalModal/LighterWithdrawal.tsx
|
|
160
163
|
import {
|
|
161
164
|
DirectExecutionType,
|
|
@@ -172,68 +175,9 @@ import React3, {
|
|
|
172
175
|
useState
|
|
173
176
|
} from "react";
|
|
174
177
|
import { createPortal } from "react-dom";
|
|
175
|
-
import { numberToHex, pad, parseUnits
|
|
178
|
+
import { numberToHex, pad, parseUnits } from "viem";
|
|
176
179
|
import { mainnet } from "viem/chains";
|
|
177
180
|
|
|
178
|
-
// src/utils/lighter.ts
|
|
179
|
-
import {
|
|
180
|
-
encodeFunctionData,
|
|
181
|
-
getAddress,
|
|
182
|
-
parseUnits
|
|
183
|
-
} from "viem";
|
|
184
|
-
var LIGHTER_DEPOSIT_ADDRESS = getAddress(
|
|
185
|
-
"0x3b4d794a66304f130a4db8f2551b0070dfcf5ca7"
|
|
186
|
-
);
|
|
187
|
-
var LIGHTER_SLOW_DEPOSIT_TIME_ESTIMATE_SECONDS = 60 * 2;
|
|
188
|
-
var LIGHTER_DELAYED_AUTO_TRIGGER_CUTOFF = 60 * 5;
|
|
189
|
-
var LIGHTER_USDC_ASSET_INDEX = 3;
|
|
190
|
-
var LIGHTER_WITHDRAW_ABI = [
|
|
191
|
-
{
|
|
192
|
-
type: "function",
|
|
193
|
-
name: "withdraw",
|
|
194
|
-
stateMutability: "nonpayable",
|
|
195
|
-
inputs: [
|
|
196
|
-
{ name: "accountIndex", type: "uint48" },
|
|
197
|
-
{ name: "assetIndex", type: "uint16" },
|
|
198
|
-
{ name: "routeType", type: "uint8" },
|
|
199
|
-
{ name: "amount", type: "uint64" }
|
|
200
|
-
],
|
|
201
|
-
outputs: []
|
|
202
|
-
}
|
|
203
|
-
];
|
|
204
|
-
function truncateToDecimals(amount, decimals) {
|
|
205
|
-
const [whole = "0", frac = ""] = amount.split(".");
|
|
206
|
-
if (frac.length <= decimals) {
|
|
207
|
-
return amount;
|
|
208
|
-
}
|
|
209
|
-
const truncated = frac.slice(0, decimals);
|
|
210
|
-
return truncated ? `${whole}.${truncated}` : whole;
|
|
211
|
-
}
|
|
212
|
-
function lighterWithdrawBaseUnits(assetIndex, amountTokenUnits) {
|
|
213
|
-
const decimals = assetIndex === LIGHTER_USDC_ASSET_INDEX ? 6 : 8;
|
|
214
|
-
return parseUnits(truncateToDecimals(amountTokenUnits, decimals), decimals);
|
|
215
|
-
}
|
|
216
|
-
function buildLighterL1WithdrawTransaction(params) {
|
|
217
|
-
const { accountIndex, assetIndex, routeType, amountBaseUnit } = params;
|
|
218
|
-
const data = encodeFunctionData({
|
|
219
|
-
abi: LIGHTER_WITHDRAW_ABI,
|
|
220
|
-
functionName: "withdraw",
|
|
221
|
-
args: [accountIndex, assetIndex, routeType, amountBaseUnit]
|
|
222
|
-
});
|
|
223
|
-
return { to: LIGHTER_DEPOSIT_ADDRESS, data, value: 0n };
|
|
224
|
-
}
|
|
225
|
-
function isLighterWithdrawalRateLimitError(error) {
|
|
226
|
-
if (error && typeof error === "object" && "code" in error) {
|
|
227
|
-
const code = error.code;
|
|
228
|
-
if (code === 23004 || code === 23005) {
|
|
229
|
-
return true;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
const raw = error instanceof Error ? error.message : typeof error === "string" ? error : error && typeof error === "object" && "message" in error ? String(error.message) : "";
|
|
233
|
-
const message = raw.toLowerCase();
|
|
234
|
-
return message.includes("23004") || message.includes("23005") || message.includes("rate limit") || message.includes("ratelimit");
|
|
235
|
-
}
|
|
236
|
-
|
|
237
181
|
// src/utils/tokenIconUrl.ts
|
|
238
182
|
var getLocalTokenIconUrl = (symbol) => {
|
|
239
183
|
return ASSET_LOGO_SRCS[symbol.toUpperCase()] || `https://sdk-cdn.fun.xyz/images/${encodeURIComponent(symbol.toLowerCase())}.svg`;
|
|
@@ -264,52 +208,52 @@ function formatSecondsTranslated(seconds, t, specifyUnderMinute = false, omitSec
|
|
|
264
208
|
}
|
|
265
209
|
|
|
266
210
|
// src/modals/WithdrawalModal/LighterWithdrawal.tsx
|
|
211
|
+
import {
|
|
212
|
+
LIGHTER_ROUTE_TYPE,
|
|
213
|
+
LIGHTER_STAKING_POOL_INDEX,
|
|
214
|
+
buildLighterL1WithdrawTransaction,
|
|
215
|
+
findLighterStakingShare,
|
|
216
|
+
getLighterBaseSymbol,
|
|
217
|
+
isLighterWithdrawalRateLimitError,
|
|
218
|
+
lighterWithdrawBaseUnits,
|
|
219
|
+
resolveLighterSharePrice,
|
|
220
|
+
resolveLighterUnstakedFeeTokens,
|
|
221
|
+
resolveLighterWithdrawalExplorerUrl,
|
|
222
|
+
truncateToDecimals
|
|
223
|
+
} from "@funkit/connect-core/clients/lighter";
|
|
224
|
+
import {
|
|
225
|
+
LIGHTER_DEFAULT_SECURE_MIN_WITHDRAWAL_AMOUNTS,
|
|
226
|
+
LIGHTER_FAST_MAX_WITHDRAWAL_USD,
|
|
227
|
+
LIGHTER_ROUTE_TYPE as LIGHTER_ROUTE_TYPE2,
|
|
228
|
+
LIGHTER_SECURE_ASSETS_BY_INDEX,
|
|
229
|
+
LIGHTER_STAKING_POOL_INDEX as LIGHTER_STAKING_POOL_INDEX2,
|
|
230
|
+
LIGHTER_STAKING_THRESHOLD_LIT,
|
|
231
|
+
LIGHTER_UNSTAKED_FEE_TOKENS,
|
|
232
|
+
LIGHTER_USDC_SPOT_SYMBOL,
|
|
233
|
+
getLighterBaseSymbol as getLighterBaseSymbol2,
|
|
234
|
+
getLighterSecureMainnetAddress,
|
|
235
|
+
resolveLighterAssetIndex,
|
|
236
|
+
resolveLighterSecureRouteType,
|
|
237
|
+
resolveLighterSharePrice as resolveLighterSharePrice2,
|
|
238
|
+
resolveLighterUnstakedFeeTokens as resolveLighterUnstakedFeeTokens2
|
|
239
|
+
} from "@funkit/connect-core/clients/lighter";
|
|
267
240
|
var LIGHTER_FAST_METHOD_ID = "lighter-fast";
|
|
268
241
|
var LIGHTER_SECURE_METHOD_ID = "lighter-secure";
|
|
269
|
-
var LIGHTER_USDC_SPOT_SYMBOL = "USDC (Spot)";
|
|
270
|
-
var LIGHTER_ROUTE_TYPE = {
|
|
271
|
-
PERPS: 0,
|
|
272
|
-
SPOT: 1
|
|
273
|
-
};
|
|
274
|
-
function getLighterBaseSymbol(symbol) {
|
|
275
|
-
return symbol.replace(/\s*\((?:spot|perps)\)\s*$/i, "");
|
|
276
|
-
}
|
|
277
|
-
var LIGHTER_FAST_MAX_WITHDRAWAL_USD = 3e6;
|
|
278
242
|
|
|
279
243
|
// src/clients/lighter.tsx
|
|
244
|
+
import { LIGHTER_ROUTE_TYPE as LIGHTER_ROUTE_TYPE3 } from "@funkit/connect-core/clients/lighter";
|
|
245
|
+
import {
|
|
246
|
+
LIGHTER_WITHDRAW_ABI,
|
|
247
|
+
buildLighterL1WithdrawTransaction as buildLighterL1WithdrawTransaction2,
|
|
248
|
+
isLighterWithdrawalRateLimitError as isLighterWithdrawalRateLimitError2,
|
|
249
|
+
lighterWithdrawBaseUnits as lighterWithdrawBaseUnits2
|
|
250
|
+
} from "@funkit/connect-core/clients/lighter";
|
|
280
251
|
var LIGHTER_USDC_PERPS_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
281
252
|
var MAINNET_USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
|
|
282
|
-
var LIGHTER_SECURE_ASSETS_BY_INDEX = {
|
|
283
|
-
1: { symbol: "ETH", decimals: 18 },
|
|
284
|
-
2: { symbol: "LIT", decimals: 18 },
|
|
285
|
-
3: { symbol: "USDC", decimals: 6 },
|
|
286
|
-
5: { symbol: "LINK", decimals: 18 },
|
|
287
|
-
6: { symbol: "UNI", decimals: 18 },
|
|
288
|
-
7: { symbol: "AAVE", decimals: 18 },
|
|
289
|
-
8: { symbol: "SKY", decimals: 18 },
|
|
290
|
-
9: { symbol: "LDO", decimals: 18 },
|
|
291
|
-
10: { symbol: "AZTEC", decimals: 18 }
|
|
292
|
-
};
|
|
293
|
-
var LIGHTER_API_BASE = "https://mainnet.zklighter.elliot.ai";
|
|
294
|
-
async function getLighterWithdrawalDelay() {
|
|
295
|
-
const response = await fetch(`${LIGHTER_API_BASE}/api/v1/withdrawalDelay`);
|
|
296
|
-
if (!response.ok) {
|
|
297
|
-
throw new Error(
|
|
298
|
-
`Failed to fetch Lighter withdrawal delay: ${response.statusText}`
|
|
299
|
-
);
|
|
300
|
-
}
|
|
301
|
-
return response.json();
|
|
302
|
-
}
|
|
303
253
|
function useLighterSecureDelayText() {
|
|
304
254
|
const { t } = useFunkitTranslation();
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
queryFn: getLighterWithdrawalDelay,
|
|
308
|
-
staleTime: 6e4,
|
|
309
|
-
retry: 2
|
|
310
|
-
});
|
|
311
|
-
const seconds = query.data?.seconds;
|
|
312
|
-
if (seconds === void 0 || !Number.isFinite(seconds) || seconds <= 0) {
|
|
255
|
+
const seconds = useLighterWithdrawalDelaySeconds();
|
|
256
|
+
if (seconds === void 0) {
|
|
313
257
|
return void 0;
|
|
314
258
|
}
|
|
315
259
|
return formatSecondsTranslated(
|
|
@@ -321,212 +265,6 @@ function useLighterSecureDelayText() {
|
|
|
321
265
|
true
|
|
322
266
|
);
|
|
323
267
|
}
|
|
324
|
-
var LIGHTER_TX_STATUS = {
|
|
325
|
-
PENDING: 0,
|
|
326
|
-
QUEUED: 1,
|
|
327
|
-
COMMITTED: 2,
|
|
328
|
-
EXECUTED: 3,
|
|
329
|
-
FAILED: 4,
|
|
330
|
-
REJECTED: 5
|
|
331
|
-
};
|
|
332
|
-
function coerceLighterStatus(status) {
|
|
333
|
-
if (typeof status === "number") {
|
|
334
|
-
return status;
|
|
335
|
-
}
|
|
336
|
-
switch (status) {
|
|
337
|
-
case "confirmed":
|
|
338
|
-
return LIGHTER_TX_STATUS.EXECUTED;
|
|
339
|
-
case "failed":
|
|
340
|
-
return LIGHTER_TX_STATUS.FAILED;
|
|
341
|
-
default:
|
|
342
|
-
return LIGHTER_TX_STATUS.PENDING;
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
var LighterTerminalError = class extends Error {
|
|
346
|
-
};
|
|
347
|
-
async function pollLighterTransaction(txHash, options) {
|
|
348
|
-
const { pollIntervalMs, maxAttempts, waitFor } = options;
|
|
349
|
-
return retry(
|
|
350
|
-
async () => {
|
|
351
|
-
const resp = await fetch(
|
|
352
|
-
`${LIGHTER_API_BASE}/api/v1/tx?by=hash&value=${txHash}`
|
|
353
|
-
);
|
|
354
|
-
if (!resp.ok) {
|
|
355
|
-
throw new Error(`Lighter API error ${resp.status} for tx ${txHash}`);
|
|
356
|
-
}
|
|
357
|
-
const tx = await resp.json();
|
|
358
|
-
if (!tx.hash) {
|
|
359
|
-
throw new Error(`Lighter tx ${txHash} not found yet`);
|
|
360
|
-
}
|
|
361
|
-
const status = coerceLighterStatus(tx.status ?? LIGHTER_TX_STATUS.PENDING);
|
|
362
|
-
if (status === LIGHTER_TX_STATUS.FAILED || status === LIGHTER_TX_STATUS.REJECTED) {
|
|
363
|
-
const label = status === LIGHTER_TX_STATUS.FAILED ? "failed" : "rejected";
|
|
364
|
-
throw new LighterTerminalError(
|
|
365
|
-
`Lighter transaction ${label}: ${tx.message ?? "unknown error"}`
|
|
366
|
-
);
|
|
367
|
-
}
|
|
368
|
-
if (waitFor === "findable") {
|
|
369
|
-
return tx;
|
|
370
|
-
}
|
|
371
|
-
if (status === LIGHTER_TX_STATUS.COMMITTED || status === LIGHTER_TX_STATUS.EXECUTED) {
|
|
372
|
-
return tx;
|
|
373
|
-
}
|
|
374
|
-
throw new Error(
|
|
375
|
-
`Lighter transaction ${txHash} did not reach '${waitFor}' after ${maxAttempts} attempts`
|
|
376
|
-
);
|
|
377
|
-
},
|
|
378
|
-
{
|
|
379
|
-
maxAttempts,
|
|
380
|
-
delay: pollIntervalMs,
|
|
381
|
-
factor: 1,
|
|
382
|
-
jitter: false,
|
|
383
|
-
handleError: (err, context) => {
|
|
384
|
-
if (err instanceof LighterTerminalError) {
|
|
385
|
-
context.abort();
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
);
|
|
390
|
-
}
|
|
391
|
-
function createLighterAdaptedWallet({
|
|
392
|
-
signerClient,
|
|
393
|
-
accountIndex
|
|
394
|
-
}) {
|
|
395
|
-
async function handleSendTransactionStep(_chainId, stepItem) {
|
|
396
|
-
const action = stepItem.data?.action;
|
|
397
|
-
if (!action || action.type !== "transfer") {
|
|
398
|
-
throw new Error(
|
|
399
|
-
`Unsupported Lighter action: ${action?.type ?? "undefined"}`
|
|
400
|
-
);
|
|
401
|
-
}
|
|
402
|
-
const p = action.parameters;
|
|
403
|
-
logger.info("lighter:wallet:transfer", p);
|
|
404
|
-
const [, txHash, error] = await signerClient.transfer({
|
|
405
|
-
toAccountIndex: p.toAccountIndex,
|
|
406
|
-
assetIndex: p.assetIndex,
|
|
407
|
-
fromRouteType: p.fromRouteType,
|
|
408
|
-
toRouteType: p.toRouteType,
|
|
409
|
-
amount: p.amount,
|
|
410
|
-
usdcFee: p.usdcFee,
|
|
411
|
-
memo: p.memo
|
|
412
|
-
});
|
|
413
|
-
if (error) {
|
|
414
|
-
throw new Error(`Lighter transfer failed: ${error}`);
|
|
415
|
-
}
|
|
416
|
-
if (!txHash) {
|
|
417
|
-
throw new Error("Lighter transfer returned no transaction hash");
|
|
418
|
-
}
|
|
419
|
-
logger.info("lighter:wallet:transfer:done", { txHash });
|
|
420
|
-
return txHash;
|
|
421
|
-
}
|
|
422
|
-
return {
|
|
423
|
-
vmType: "lvm",
|
|
424
|
-
getChainId: async () => Number(RELAY_LIGHTER_CHAIN_ID2),
|
|
425
|
-
address: async () => accountIndex.toString(),
|
|
426
|
-
handleSignMessageStep: async () => {
|
|
427
|
-
throw new Error("Message signing not implemented for Lighter");
|
|
428
|
-
},
|
|
429
|
-
handleSendTransactionStep,
|
|
430
|
-
handleConfirmTransactionStep: async (txHash) => {
|
|
431
|
-
const tx = await pollLighterTransaction(txHash, {
|
|
432
|
-
pollIntervalMs: 2e3,
|
|
433
|
-
maxAttempts: 60,
|
|
434
|
-
waitFor: "findable"
|
|
435
|
-
});
|
|
436
|
-
return {
|
|
437
|
-
txHash: tx.hash,
|
|
438
|
-
blockHeight: tx.block_height ?? 0,
|
|
439
|
-
status: tx.status
|
|
440
|
-
};
|
|
441
|
-
},
|
|
442
|
-
// biome-ignore lint/suspicious/noEmptyBlockStatements: Lighter is single-chain — no switching needed
|
|
443
|
-
switchChain: async () => {
|
|
444
|
-
}
|
|
445
|
-
};
|
|
446
|
-
}
|
|
447
|
-
var LIGHTER_DEFAULT_SECURE_MIN_WITHDRAWAL_AMOUNTS = {
|
|
448
|
-
USDC: 1,
|
|
449
|
-
ETH: 1e-3,
|
|
450
|
-
LIT: 1,
|
|
451
|
-
LINK: 0.1,
|
|
452
|
-
UNI: 0.2,
|
|
453
|
-
AAVE: 0.01,
|
|
454
|
-
SKY: 20,
|
|
455
|
-
LDO: 2,
|
|
456
|
-
AZTEC: 100
|
|
457
|
-
};
|
|
458
|
-
async function trackLighterSecureWithdrawal({
|
|
459
|
-
apiKey,
|
|
460
|
-
userId,
|
|
461
|
-
txHash,
|
|
462
|
-
recipientAddr,
|
|
463
|
-
assetIndex,
|
|
464
|
-
mainnetTokenAddress,
|
|
465
|
-
amountTokenUnits,
|
|
466
|
-
withdrawalUSD
|
|
467
|
-
}) {
|
|
468
|
-
const assetMeta = LIGHTER_SECURE_ASSETS_BY_INDEX[assetIndex];
|
|
469
|
-
if (!assetMeta) {
|
|
470
|
-
logger.error(
|
|
471
|
-
"lighter:withdrawal:secure:tracking:unknownAssetIndex",
|
|
472
|
-
new Error(`Unknown Lighter Secure asset index: ${assetIndex}`),
|
|
473
|
-
{ assetIndex, txHash }
|
|
474
|
-
);
|
|
475
|
-
return;
|
|
476
|
-
}
|
|
477
|
-
const { symbol, decimals } = assetMeta;
|
|
478
|
-
const estTotalUsd = Number(withdrawalUSD);
|
|
479
|
-
const safeAmount = truncateToDecimals(amountTokenUnits, decimals);
|
|
480
|
-
const baseUnitAmount = parseUnits3(safeAmount, decimals).toString();
|
|
481
|
-
const fromTokenAddress = pad2(toHex(assetIndex), { size: 20 });
|
|
482
|
-
await createDirectExecution2({
|
|
483
|
-
apiKey,
|
|
484
|
-
logger,
|
|
485
|
-
// Lighter L2 tx hashes are not 0x-prefixed EVM hashes — they're the L2's
|
|
486
|
-
// own format. We cast here for convenience to satisfy the DE row type;
|
|
487
|
-
// the backend stores the literal string and we never use it as an EVM hash.
|
|
488
|
-
txHash,
|
|
489
|
-
type: DirectExecutionType2.EXTERNALLY_FULFILLED,
|
|
490
|
-
userId,
|
|
491
|
-
recipientAddr,
|
|
492
|
-
fromChainId: LIGHTER_CHAIN_ID.toString(),
|
|
493
|
-
fromTokenAddress,
|
|
494
|
-
toChainId: mainnet2.id.toString(),
|
|
495
|
-
toTokenAddress: mainnetTokenAddress,
|
|
496
|
-
fromAmountBaseUnit: baseUnitAmount,
|
|
497
|
-
toAmountBaseUnit: baseUnitAmount,
|
|
498
|
-
estTotalUsd,
|
|
499
|
-
// Secure withdrawals come out of the user's Lighter account balance; the
|
|
500
|
-
// L1 owner of that account is the recipient (Secure locks to connected wallet).
|
|
501
|
-
sourceOfFund: `balance|lighter-secure|${recipientAddr}`,
|
|
502
|
-
clientMetadata: {
|
|
503
|
-
id: uuid2(),
|
|
504
|
-
startTimestampMs: Date.now(),
|
|
505
|
-
finalDollarValue: estTotalUsd,
|
|
506
|
-
latestQuote: null,
|
|
507
|
-
depositAddress: null,
|
|
508
|
-
initSettings: {
|
|
509
|
-
config: {
|
|
510
|
-
targetAsset: mainnetTokenAddress,
|
|
511
|
-
targetChain: mainnet2.id.toString(),
|
|
512
|
-
targetAssetTicker: symbol
|
|
513
|
-
}
|
|
514
|
-
},
|
|
515
|
-
selectedSourceAssetInfo: {
|
|
516
|
-
address: fromTokenAddress,
|
|
517
|
-
symbol,
|
|
518
|
-
chainId: LIGHTER_CHAIN_ID.toString(),
|
|
519
|
-
iconSrc: null
|
|
520
|
-
},
|
|
521
|
-
selectedPaymentMethodInfo: {
|
|
522
|
-
paymentMethod: "LIGHTER_SECURE_WITHDRAWAL",
|
|
523
|
-
title: "",
|
|
524
|
-
description: ""
|
|
525
|
-
},
|
|
526
|
-
isWithdrawal: true
|
|
527
|
-
}
|
|
528
|
-
});
|
|
529
|
-
}
|
|
530
268
|
function buildSecureWithdrawalCallback({
|
|
531
269
|
exec
|
|
532
270
|
}) {
|
|
@@ -572,6 +310,7 @@ function buildSecureWithdrawalCallback({
|
|
|
572
310
|
});
|
|
573
311
|
void trackLighterSecureWithdrawal({
|
|
574
312
|
apiKey: LIGHTERXYZ_API_KEY,
|
|
313
|
+
logger,
|
|
575
314
|
// Secure locks the destination to the connected wallet, so the L1
|
|
576
315
|
// recipient address doubles as the userId for tracking purposes.
|
|
577
316
|
userId: destinationAddress,
|
|
@@ -581,13 +320,6 @@ function buildSecureWithdrawalCallback({
|
|
|
581
320
|
mainnetTokenAddress: targetAssetAddress,
|
|
582
321
|
amountTokenUnits,
|
|
583
322
|
withdrawalUSD
|
|
584
|
-
}).catch((err) => {
|
|
585
|
-
logger.warn("lighter:withdrawal:secure:trackingFailed", {
|
|
586
|
-
error: err instanceof Error ? err.message : String(err),
|
|
587
|
-
txHash,
|
|
588
|
-
assetIndex,
|
|
589
|
-
amountTokenUnits
|
|
590
|
-
});
|
|
591
323
|
});
|
|
592
324
|
return txHash;
|
|
593
325
|
};
|
|
@@ -629,8 +361,8 @@ function buildLighterSourceTokenOptions({
|
|
|
629
361
|
).map((asset) => {
|
|
630
362
|
if (asset.symbol.toUpperCase() === "USDC") {
|
|
631
363
|
return {
|
|
632
|
-
symbol:
|
|
633
|
-
label:
|
|
364
|
+
symbol: LIGHTER_USDC_SPOT_SYMBOL2,
|
|
365
|
+
label: LIGHTER_USDC_SPOT_SYMBOL2,
|
|
634
366
|
iconSrc: getTokenIconUrl("USDC")
|
|
635
367
|
};
|
|
636
368
|
}
|
|
@@ -654,7 +386,8 @@ function buildLighterFastWalletWithdrawalConfig({
|
|
|
654
386
|
}) {
|
|
655
387
|
const adaptedWallet = createLighterAdaptedWallet({
|
|
656
388
|
signerClient,
|
|
657
|
-
accountIndex
|
|
389
|
+
accountIndex,
|
|
390
|
+
logger
|
|
658
391
|
});
|
|
659
392
|
const wallet = {
|
|
660
393
|
_type: "lighter",
|
|
@@ -688,7 +421,7 @@ function buildLighterFastWalletWithdrawalConfig({
|
|
|
688
421
|
sourceTokenAddress: LIGHTER_USDC_PERPS_ADDRESS,
|
|
689
422
|
iconSrc: iconSrc ?? "https://sdk-cdn.fun.xyz/images/logos/lighter.png",
|
|
690
423
|
getMinWithdrawalUSD: () => 4,
|
|
691
|
-
getMaxWithdrawalUSD: () =>
|
|
424
|
+
getMaxWithdrawalUSD: () => LIGHTER_FAST_MAX_WITHDRAWAL_USD2
|
|
692
425
|
};
|
|
693
426
|
}
|
|
694
427
|
function ChainIconStack({ chainIds }) {
|
|
@@ -746,7 +479,7 @@ function buildLighterMultiMethodConfig({
|
|
|
746
479
|
if (userMin !== void 0) {
|
|
747
480
|
return userMin;
|
|
748
481
|
}
|
|
749
|
-
return
|
|
482
|
+
return LIGHTER_DEFAULT_SECURE_MIN_WITHDRAWAL_AMOUNTS2[getLighterBaseSymbol3(symbol).toUpperCase()] ?? 0;
|
|
750
483
|
}
|
|
751
484
|
});
|
|
752
485
|
const fast = {
|
|
@@ -778,13 +511,10 @@ function buildLighterMultiMethodConfig({
|
|
|
778
511
|
}
|
|
779
512
|
function useLighterWithdrawalConfig(config) {
|
|
780
513
|
const { t } = useFunkitTranslation();
|
|
781
|
-
const { mainAccountIndex, isUnifiedTradingMode } = useLighterAccountsQuery({
|
|
782
|
-
address: config?.l1Address
|
|
783
|
-
});
|
|
784
|
-
const accountIndex = mainAccountIndex && /^\d+$/.test(mainAccountIndex) ? mainAccountIndex : void 0;
|
|
514
|
+
const { mainAccountIndex: accountIndex, isUnifiedTradingMode } = useLighterAccountsQuery({ address: config?.l1Address });
|
|
785
515
|
const secureDelayText = useLighterSecureDelayText();
|
|
786
516
|
const { account } = useLighterAccountQuery(
|
|
787
|
-
//
|
|
517
|
+
// The query validates it as numeric, so the template-literal narrowing holds.
|
|
788
518
|
accountIndex ? { by: "index", value: accountIndex } : null
|
|
789
519
|
);
|
|
790
520
|
const assets = useMemo2(() => account?.assets ?? [], [account]);
|
|
@@ -803,14 +533,12 @@ function useLighterWithdrawalConfig(config) {
|
|
|
803
533
|
}, [config, accountIndex, t, secureDelayText, isUnifiedTradingMode, assets]);
|
|
804
534
|
}
|
|
805
535
|
export {
|
|
806
|
-
|
|
807
|
-
LIGHTER_ROUTE_TYPE,
|
|
536
|
+
LIGHTER_ROUTE_TYPE3 as LIGHTER_ROUTE_TYPE,
|
|
808
537
|
LIGHTER_WITHDRAW_ABI,
|
|
809
|
-
buildLighterL1WithdrawTransaction,
|
|
538
|
+
buildLighterL1WithdrawTransaction2 as buildLighterL1WithdrawTransaction,
|
|
810
539
|
buildLighterSourceTokenOptions,
|
|
811
540
|
createLighterSecureWithdrawalConfig,
|
|
812
|
-
isLighterWithdrawalRateLimitError,
|
|
813
|
-
lighterWithdrawBaseUnits,
|
|
814
|
-
trackLighterSecureWithdrawal,
|
|
541
|
+
isLighterWithdrawalRateLimitError2 as isLighterWithdrawalRateLimitError,
|
|
542
|
+
lighterWithdrawBaseUnits2 as lighterWithdrawBaseUnits,
|
|
815
543
|
useLighterWithdrawalConfig
|
|
816
544
|
};
|
package/dist/clients/nado.d.ts
CHANGED
|
@@ -52,6 +52,8 @@ export interface NadoWithdrawalOptions {
|
|
|
52
52
|
* sequencer fee, which Nado charges per asset, not per dollar.
|
|
53
53
|
*/
|
|
54
54
|
getMinWithdrawalAmount?: (symbol: string) => number;
|
|
55
|
+
/** Initial state of the borrow (spot leverage) toggle */
|
|
56
|
+
defaultSpotLeverage?: boolean;
|
|
55
57
|
}
|
|
56
58
|
/**
|
|
57
59
|
* Withdrawal config for a Nado subaccount, or `null` while one can't be built —
|
package/dist/clients/nado.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
resolveNadoSubaccount
|
|
4
|
-
} from "./chunk-QQEGNLGD.js";
|
|
5
2
|
import {
|
|
6
3
|
createNadoWithdrawalCallback
|
|
7
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-3Y5EIONT.js";
|
|
8
5
|
import "./chunk-2576N7PQ.js";
|
|
9
6
|
import "./chunk-VIAEAD75.js";
|
|
10
7
|
import "./chunk-63XTVHO3.js";
|
|
11
|
-
import
|
|
8
|
+
import {
|
|
9
|
+
resolveNadoSubaccount
|
|
10
|
+
} from "./chunk-EQFVPSR2.js";
|
|
11
|
+
import "./chunk-B7UU2ETA.js";
|
|
12
12
|
import "./chunk-6T6URLBM.js";
|
|
13
13
|
import "./chunk-TZGKB6WY.js";
|
|
14
14
|
import {
|
|
@@ -65,7 +65,8 @@ function useNadoWithdrawalConfig(options) {
|
|
|
65
65
|
getMaxWithdrawalUSD: options.getMaxWithdrawalUSD,
|
|
66
66
|
getMinWithdrawalAmount: options.getMinWithdrawalAmount,
|
|
67
67
|
withdrawCallback,
|
|
68
|
-
customerConfig: { customerName: "nado", walletAddress, subaccount }
|
|
68
|
+
customerConfig: { customerName: "nado", walletAddress, subaccount },
|
|
69
|
+
defaultSpotLeverage: options.defaultSpotLeverage
|
|
69
70
|
};
|
|
70
71
|
}
|
|
71
72
|
export {
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
import "../chunk-BPDLF2R6.js";
|
|
6
6
|
import "../chunk-5MY7WMEJ.js";
|
|
7
7
|
import "../chunk-FNB7OPJI.js";
|
|
8
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-6EU6CXNH.js";
|
|
9
9
|
import "../chunk-UK64SY6N.js";
|
|
10
10
|
import "../chunk-LUHEVXPD.js";
|
|
11
11
|
import "../chunk-YUZ3B2Q3.js";
|
|
@@ -23,6 +23,12 @@ export declare function createPredictionsGenerateActionParams(config: Polymarket
|
|
|
23
23
|
* Both accounts share it, so each transfer direction is symmetrical.
|
|
24
24
|
*/
|
|
25
25
|
export type PolymarketAccount = PolymarketTransferAccount;
|
|
26
|
+
/**
|
|
27
|
+
* Re-exported so an integrator can type a `transfer` implementation without
|
|
28
|
+
* reaching outside this entry point — returning the rail's id is what lets a
|
|
29
|
+
* transfer record be joined to Polymarket's side of the same transfer.
|
|
30
|
+
*/
|
|
31
|
+
export type { PolymarketTransferResult } from '../../providers/FunkitCheckoutContext/types';
|
|
26
32
|
export interface CreatePolymarketDepositConfigParams {
|
|
27
33
|
/** Predictions account (the user's predictions proxy). */
|
|
28
34
|
predictions: PolymarketAccount;
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
import "../chunk-BPDLF2R6.js";
|
|
6
6
|
import "../chunk-5MY7WMEJ.js";
|
|
7
7
|
import "../chunk-FNB7OPJI.js";
|
|
8
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-6EU6CXNH.js";
|
|
9
9
|
import "../chunk-UK64SY6N.js";
|
|
10
10
|
import "../chunk-LUHEVXPD.js";
|
|
11
11
|
import "../chunk-YUZ3B2Q3.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { NotificationItem } from '../../modals/CheckoutModal/TransferToken/types';
|
|
2
3
|
import { HistoryContentPages } from '../../utils/checkoutHistory';
|
|
3
4
|
interface FunCheckoutHistoryContentProps {
|
|
4
5
|
depositAddress: `0x${string}`;
|
|
@@ -11,6 +12,7 @@ interface FunCheckoutHistoryContentProps {
|
|
|
11
12
|
/** Element ID to be used to mount the CTA action bar */
|
|
12
13
|
bottomBarId: string;
|
|
13
14
|
isActiveCheckout: boolean;
|
|
15
|
+
onHistoryItemChange?: (item: NotificationItem) => void;
|
|
14
16
|
}
|
|
15
|
-
export declare function FunCheckoutHistoryContent({ bottomBarId, currentPage, depositAddress, isActiveCheckout, onAnimationComplete, onClose, onHelp, }: FunCheckoutHistoryContentProps): React.JSX.Element;
|
|
17
|
+
export declare function FunCheckoutHistoryContent({ bottomBarId, currentPage, depositAddress, isActiveCheckout, onAnimationComplete, onClose, onHelp, onHistoryItemChange, }: FunCheckoutHistoryContentProps): React.JSX.Element;
|
|
16
18
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { TextConfigSteps } from '../../components/TransactionStatus/TransactionStatus';
|
|
3
3
|
import type { FunkitCheckoutQuoteResult } from '../../domains/quote';
|
|
4
|
+
import type { NotificationItem } from '../../modals/CheckoutModal/TransferToken/types';
|
|
4
5
|
export interface PendingSuccessScreenProps {
|
|
5
6
|
bottomBarId: string;
|
|
6
7
|
onClose: () => void;
|
|
@@ -9,5 +10,6 @@ export interface PendingSuccessScreenProps {
|
|
|
9
10
|
quote?: FunkitCheckoutQuoteResult | null;
|
|
10
11
|
isWithdrawal?: boolean;
|
|
11
12
|
hideYouReceive: boolean;
|
|
13
|
+
onHistoryItemChange?: (item: NotificationItem) => void;
|
|
12
14
|
}
|
|
13
|
-
export declare const PendingSuccessScreen: ({ bottomBarId, onClose, onAction, customTextConfigSteps, quote, isWithdrawal, hideYouReceive, }: PendingSuccessScreenProps) => React.JSX.Element | null;
|
|
15
|
+
export declare const PendingSuccessScreen: ({ bottomBarId, onClose, onAction, customTextConfigSteps, quote, isWithdrawal, hideYouReceive, onHistoryItemChange, }: PendingSuccessScreenProps) => React.JSX.Element | null;
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FunAddress } from '@funkit/api-base';
|
|
2
2
|
import { CheckoutRefundState, CheckoutState } from '@funkit/api-base';
|
|
3
3
|
import type { GeneralWalletContextProps } from '../providers/GeneralWalletProvider';
|
|
4
|
-
|
|
4
|
+
/** Web's entry to the shared screen: resolves the kill switch and logger. */
|
|
5
|
+
export declare const hasRisk: (apiKey: string, walletAddress: GeneralWalletContextProps["walletAddress"], customRecipient?: FunAddress,
|
|
6
|
+
/** Internal decimal chain ids: the wallet pays on the source chain, the recipient receives on the target chain. */
|
|
7
|
+
chainIds?: {
|
|
8
|
+
sourceChainId?: string;
|
|
9
|
+
targetChainId?: string;
|
|
10
|
+
}) => Promise<boolean>;
|
|
5
11
|
export type CheckoutStatus = 'failed' | 'expired' | 'processing' | 'completed';
|
|
6
12
|
type CheckoutStateBooleans = {
|
|
7
13
|
isProcessing: boolean;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AnalyticsEvent } from './events';
|
|
2
|
+
/** Claim one analytics event per stable record key, persisted across sessions. */
|
|
3
|
+
export declare function claimAnalyticsEvent(event: AnalyticsEvent,
|
|
4
|
+
/** Based on the event, this could be checkoutId, depositAddr, txHash, etc */
|
|
5
|
+
claimKey: string): boolean;
|