@agg-build/hooks 1.0.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/README.md +403 -0
- package/dist/chunk-CDPQERUC.mjs +3601 -0
- package/dist/deposit.d.mts +184 -0
- package/dist/deposit.d.ts +184 -0
- package/dist/deposit.js +1563 -0
- package/dist/deposit.mjs +628 -0
- package/dist/index.d.mts +4640 -0
- package/dist/index.d.ts +4640 -0
- package/dist/index.js +5568 -0
- package/dist/index.mjs +2010 -0
- package/dist/use-sync-balances-D1Jdkck9.d.mts +246 -0
- package/dist/use-sync-balances-D1Jdkck9.d.ts +246 -0
- package/package.json +102 -0
package/dist/deposit.js
ADDED
|
@@ -0,0 +1,1563 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
var __export = (target, all) => {
|
|
24
|
+
for (var name in all)
|
|
25
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
26
|
+
};
|
|
27
|
+
var __copyProps = (to, from, except, desc) => {
|
|
28
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
29
|
+
for (let key of __getOwnPropNames(from))
|
|
30
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
31
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
32
|
+
}
|
|
33
|
+
return to;
|
|
34
|
+
};
|
|
35
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
|
+
var __async = (__this, __arguments, generator) => {
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
var fulfilled = (value) => {
|
|
39
|
+
try {
|
|
40
|
+
step(generator.next(value));
|
|
41
|
+
} catch (e) {
|
|
42
|
+
reject(e);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var rejected = (value) => {
|
|
46
|
+
try {
|
|
47
|
+
step(generator.throw(value));
|
|
48
|
+
} catch (e) {
|
|
49
|
+
reject(e);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
53
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// src/deposit/index.ts
|
|
58
|
+
var deposit_exports = {};
|
|
59
|
+
__export(deposit_exports, {
|
|
60
|
+
DEFAULT_SOLANA_RPC_ENDPOINT: () => DEFAULT_SOLANA_RPC_ENDPOINT,
|
|
61
|
+
SVM_CHAIN_IDS: () => SVM_CHAIN_IDS,
|
|
62
|
+
normalizeWalletError: () => normalizeWalletError,
|
|
63
|
+
useDepositAddresses: () => useDepositAddresses,
|
|
64
|
+
useDepositFlow: () => useDepositFlow,
|
|
65
|
+
useSyncBalances: () => useSyncBalances,
|
|
66
|
+
useWalletSendToken: () => useWalletSendToken,
|
|
67
|
+
useWalletTokenBalance: () => useWalletTokenBalance,
|
|
68
|
+
useWalletTransactionStatus: () => useWalletTransactionStatus
|
|
69
|
+
});
|
|
70
|
+
module.exports = __toCommonJS(deposit_exports);
|
|
71
|
+
|
|
72
|
+
// src/deposit/normalize-wallet-error.ts
|
|
73
|
+
function normalizeWalletError(error, supportedChains) {
|
|
74
|
+
var _a, _b;
|
|
75
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
76
|
+
const lower = message.toLowerCase();
|
|
77
|
+
if (lower.includes("user rejected") || lower.includes("user denied") || lower.includes("rejected the request") || lower.includes("denied transaction signature")) {
|
|
78
|
+
return { message: "Wallet request rejected.", tone: "error" };
|
|
79
|
+
}
|
|
80
|
+
const chainMismatch = message.includes("does not match the target chain") || message.includes("Expected Chain ID:");
|
|
81
|
+
if (chainMismatch) {
|
|
82
|
+
const match = message.match(/Expected Chain ID:\s*(\d+)/i);
|
|
83
|
+
const targetChainId = match ? Number(match[1]) : void 0;
|
|
84
|
+
const targetChainName = (_b = (_a = supportedChains == null ? void 0 : supportedChains.find((chain) => chain.chainId === targetChainId)) == null ? void 0 : _a.name) != null ? _b : targetChainId ? `chain ${targetChainId}` : "the selected chain";
|
|
85
|
+
return {
|
|
86
|
+
message: `Wallet chain does not match. Please switch your wallet to ${targetChainName}.`,
|
|
87
|
+
tone: "warning"
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return { message, tone: "error" };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// src/deposit/use-wallet-token-balance.ts
|
|
94
|
+
var import_react3 = require("react");
|
|
95
|
+
var import_react_query = require("@tanstack/react-query");
|
|
96
|
+
var import_viem = require("viem");
|
|
97
|
+
var import_wagmi = require("wagmi");
|
|
98
|
+
var import_wallet_adapter_react = require("@solana/wallet-adapter-react");
|
|
99
|
+
var import_web3 = require("@solana/web3.js");
|
|
100
|
+
|
|
101
|
+
// ../common/src/utils/auth.ts
|
|
102
|
+
function getWalletAddressFromUserProfile(user) {
|
|
103
|
+
var _a, _b, _c, _d, _e;
|
|
104
|
+
const oauthWallet = (_b = (_a = user == null ? void 0 : user.accounts) == null ? void 0 : _a.find(
|
|
105
|
+
(a) => a.type === "oauth" /* oauth */ && String(a.provider).toLowerCase() === "wallet"
|
|
106
|
+
)) != null ? _b : null;
|
|
107
|
+
if (oauthWallet == null ? void 0 : oauthWallet.providerAccountId) return oauthWallet.providerAccountId;
|
|
108
|
+
const siweAccount = (_d = (_c = user == null ? void 0 : user.accounts) == null ? void 0 : _c.find((a) => a.type === "siwe" /* siwe */)) != null ? _d : null;
|
|
109
|
+
return (_e = siweAccount == null ? void 0 : siweAccount.providerAccountId) != null ? _e : void 0;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// src/core/providers/contexts.ts
|
|
113
|
+
var import_react = require("react");
|
|
114
|
+
|
|
115
|
+
// src/core/ui-config/labels.ts
|
|
116
|
+
var enUsLabels = {
|
|
117
|
+
common: {
|
|
118
|
+
close: "Close",
|
|
119
|
+
loading: "Loading",
|
|
120
|
+
retry: "Retry",
|
|
121
|
+
errorPrefix: "Error",
|
|
122
|
+
tabsAria: "Tabs",
|
|
123
|
+
hiddenTabsAria: "Hidden tabs",
|
|
124
|
+
selectAria: "Select",
|
|
125
|
+
lineChartAria: "Line chart",
|
|
126
|
+
candlestickChartAria: "Candlestick chart",
|
|
127
|
+
lineChartSeriesSwitchAria: "Chart series switch",
|
|
128
|
+
lineChartSeriesOptionAria: (seriesLabel) => `Show ${seriesLabel} series`,
|
|
129
|
+
chartTypeSwitchAria: "Chart type switch",
|
|
130
|
+
lineChartType: "Line",
|
|
131
|
+
candlestickChartType: "Candlestick"
|
|
132
|
+
},
|
|
133
|
+
venues: {
|
|
134
|
+
polymarket: "Polymarket",
|
|
135
|
+
kalshi: "Kalshi",
|
|
136
|
+
opinion: "Opinion",
|
|
137
|
+
predict: "Predict",
|
|
138
|
+
limitless: "Limitless",
|
|
139
|
+
probable: "Probable",
|
|
140
|
+
myriad: "Myriad",
|
|
141
|
+
hyperliquid: "Hyperliquid"
|
|
142
|
+
},
|
|
143
|
+
auth: {
|
|
144
|
+
connect: (connectorName) => connectorName ? `Sign in with ${connectorName}` : "Sign in",
|
|
145
|
+
signIn: "Sign in",
|
|
146
|
+
signingIn: "Signing in...",
|
|
147
|
+
signInStatement: "Sign in to AGG",
|
|
148
|
+
emailAddress: "Email address",
|
|
149
|
+
continue: "Continue",
|
|
150
|
+
emailUnavailable: "Email sign-in is currently unavailable.",
|
|
151
|
+
signInWithMethod: (methodLabel) => `Sign in with ${methodLabel}`,
|
|
152
|
+
socialWalletNotice: "A wallet will automatically be created for you when signing up with a social account.",
|
|
153
|
+
learnMore: "Learn more",
|
|
154
|
+
dividerOr: "OR",
|
|
155
|
+
connectWallet: "Connect wallet",
|
|
156
|
+
terms: "Terms",
|
|
157
|
+
privacyPolicy: "Privacy Policy",
|
|
158
|
+
legalNoticePrefix: "By signing in, you agree to our",
|
|
159
|
+
legalNoticeSeparator: "&",
|
|
160
|
+
deposit: "Deposit",
|
|
161
|
+
depositGeoBlocked: "Deposits are not available in your region.",
|
|
162
|
+
balances: "Balances",
|
|
163
|
+
viewAll: "View All",
|
|
164
|
+
loadingBalances: "Loading balances...",
|
|
165
|
+
myProfile: "My Profile",
|
|
166
|
+
withdraw: "Withdraw",
|
|
167
|
+
disconnect: "Disconnect",
|
|
168
|
+
claimWinnings: "Claim Now",
|
|
169
|
+
claimableWinningsBadge: (count) => `${count} claimable winning${count === 1 ? "" : "s"}`,
|
|
170
|
+
claimableWinningsTooltip: (count) => `${count} position${count === 1 ? "" : "s"} ready to claim`,
|
|
171
|
+
walletMenuFor: (profileLabel) => `Profile menu for ${profileLabel}`
|
|
172
|
+
},
|
|
173
|
+
deposit: {
|
|
174
|
+
title: "Deposit",
|
|
175
|
+
back: "Go back",
|
|
176
|
+
balancePrefix: "Balance:",
|
|
177
|
+
balanceLabel: "Balance",
|
|
178
|
+
done: "Done",
|
|
179
|
+
methods: {
|
|
180
|
+
walletTitle: (walletLabel) => `Use your wallet (${walletLabel})`,
|
|
181
|
+
walletDescription: "Deposit instantly from your connected wallet",
|
|
182
|
+
cryptoTitle: "Send crypto",
|
|
183
|
+
cryptoDescription: "Transfer from any wallet or exchange",
|
|
184
|
+
cardTitle: "Deposit with card",
|
|
185
|
+
cardDescription: "Buy crypto instantly with your card"
|
|
186
|
+
},
|
|
187
|
+
walletFlow: {
|
|
188
|
+
title: "Use your wallet",
|
|
189
|
+
tokenLabel: "Token",
|
|
190
|
+
networkLabel: "Network",
|
|
191
|
+
amountLabel: "Amount",
|
|
192
|
+
max: "Max",
|
|
193
|
+
feePrefix: "Fee ~",
|
|
194
|
+
confirm: "Confirm Deposit"
|
|
195
|
+
},
|
|
196
|
+
sendCrypto: {
|
|
197
|
+
title: "Send crypto",
|
|
198
|
+
tokenLabel: "Supported token",
|
|
199
|
+
networkLabel: "Supported network",
|
|
200
|
+
depositAddressLabel: "Your deposit address",
|
|
201
|
+
copy: "Copy",
|
|
202
|
+
copied: "Copied!",
|
|
203
|
+
minDepositPrefix: "Min deposit",
|
|
204
|
+
warning: "Send only the selected token on the selected network. Wrong token or network may results in permanently lost funds.",
|
|
205
|
+
qrPlaceholder: "QR code placeholder",
|
|
206
|
+
addressLoadingTitle: "Preparing your deposit address...",
|
|
207
|
+
addressLoadingDescription: "We're generating your address, this usually takes a few seconds."
|
|
208
|
+
},
|
|
209
|
+
cardFlow: {
|
|
210
|
+
title: "Buy crypto",
|
|
211
|
+
amountLabel: "Amount",
|
|
212
|
+
currencyLabel: "Currency",
|
|
213
|
+
tokenLabel: "Token",
|
|
214
|
+
networkLabel: "Network",
|
|
215
|
+
destinationWalletLabel: "Destination wallet",
|
|
216
|
+
getQuotes: "Get Quotes",
|
|
217
|
+
minRequired: (amount) => `Min required: ${amount}`,
|
|
218
|
+
minAmountError: (amount) => `Enter at least ${amount} to continue`,
|
|
219
|
+
selectProviderTitle: "Select provider",
|
|
220
|
+
feeLabel: "Fee",
|
|
221
|
+
providerBadges: {
|
|
222
|
+
best: "BEST",
|
|
223
|
+
lowKyc: "LOW KYC"
|
|
224
|
+
},
|
|
225
|
+
successTitle: "Purchase complete",
|
|
226
|
+
successDescription: "Your USDC has been successfully added to your balance.",
|
|
227
|
+
pendingTitle: (provider) => `Complete your payment on ${provider}`,
|
|
228
|
+
pendingDescription: "Once your transaction is finished, your balance may take a few minutes to update. The deposit will appear in your activity once it's successful.",
|
|
229
|
+
viewActivity: "View Activity",
|
|
230
|
+
chooseAnotherProvider: "Choose another provider",
|
|
231
|
+
summary: {
|
|
232
|
+
provider: "Provider",
|
|
233
|
+
fees: "Fees"
|
|
234
|
+
},
|
|
235
|
+
loadingQuotes: "Finding the best rates...",
|
|
236
|
+
errorLoadingQuotesTitle: "Failed to load quotes",
|
|
237
|
+
errorLoadingQuotesDescription: "Please try again.",
|
|
238
|
+
retry: "Retry",
|
|
239
|
+
noQuotes: "No quotes available for this configuration.",
|
|
240
|
+
widgetTitle: "Complete Purchase"
|
|
241
|
+
},
|
|
242
|
+
processingTitle: "Processing deposit",
|
|
243
|
+
processingSteps: {
|
|
244
|
+
submitting: "Waiting for wallet confirmation",
|
|
245
|
+
submitted: "Wallet confirmed",
|
|
246
|
+
confirming: "Processing transaction\u2026",
|
|
247
|
+
updatingBalance: "Updating balance",
|
|
248
|
+
fundsAvailable: "Funds available"
|
|
249
|
+
},
|
|
250
|
+
successTitle: "Deposit complete",
|
|
251
|
+
successDescription: "Your USDC has been successfully added to your balance.",
|
|
252
|
+
summary: {
|
|
253
|
+
amountReceived: "Amount received",
|
|
254
|
+
network: "Network",
|
|
255
|
+
fromWallet: "From wallet",
|
|
256
|
+
gasFee: "Gas fee"
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
withdraw: {
|
|
260
|
+
title: "Withdraw",
|
|
261
|
+
back: "Go back",
|
|
262
|
+
done: "Done",
|
|
263
|
+
balancePrefix: "Balance:",
|
|
264
|
+
methods: {
|
|
265
|
+
cardTitle: "Withdraw with card",
|
|
266
|
+
cardDescription: "Withdraw funds to your card"
|
|
267
|
+
},
|
|
268
|
+
cardFlow: {
|
|
269
|
+
title: "Sell crypto",
|
|
270
|
+
amountLabel: "Amount",
|
|
271
|
+
currencyLabel: "Currency",
|
|
272
|
+
tokenLabel: "Token",
|
|
273
|
+
networkLabel: "Network",
|
|
274
|
+
destinationWalletLabel: "Destination wallet",
|
|
275
|
+
getQuotes: "Get Quotes",
|
|
276
|
+
selectProviderTitle: "Select provider",
|
|
277
|
+
feeLabel: "Fee",
|
|
278
|
+
providerBadges: {
|
|
279
|
+
best: "BEST",
|
|
280
|
+
lowKyc: "LOW KYC"
|
|
281
|
+
},
|
|
282
|
+
successTitle: "Withdrawal complete",
|
|
283
|
+
successDescription: "Your USDC has been successfully sent to your wallet.",
|
|
284
|
+
summary: {
|
|
285
|
+
provider: "Provider",
|
|
286
|
+
toWallet: "To wallet",
|
|
287
|
+
fees: "Fees"
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
summary: {
|
|
291
|
+
amountReceived: "Amount received",
|
|
292
|
+
network: "Network"
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
markets: {
|
|
296
|
+
emptyNoOpen: "No open markets available.",
|
|
297
|
+
emptyResolved: "This event has been resolved."
|
|
298
|
+
},
|
|
299
|
+
home: {
|
|
300
|
+
trending: "Trending",
|
|
301
|
+
topMarkets: "Top Markets",
|
|
302
|
+
newMarkets: "New Markets",
|
|
303
|
+
categoryTabsAria: "Home page category tabs"
|
|
304
|
+
},
|
|
305
|
+
userProfile: {
|
|
306
|
+
activity: {
|
|
307
|
+
depositType: "Deposit",
|
|
308
|
+
withdrawalType: "Withdraw",
|
|
309
|
+
depositTitles: {
|
|
310
|
+
connectedWallet: "Deposit from connected wallet",
|
|
311
|
+
externalWallet: "Deposit from external wallet",
|
|
312
|
+
card: "Deposit with card"
|
|
313
|
+
},
|
|
314
|
+
withdrawalTitle: (tokenSymbol) => `Withdraw ${tokenSymbol}`
|
|
315
|
+
},
|
|
316
|
+
positions: {
|
|
317
|
+
totalTradedHeader: "Total traded",
|
|
318
|
+
amountWonHeader: "Amount won",
|
|
319
|
+
claimHeader: "Claim",
|
|
320
|
+
claim: "Claim",
|
|
321
|
+
claimed: "Claimed",
|
|
322
|
+
pending: "Pending",
|
|
323
|
+
won: "Won",
|
|
324
|
+
lost: "Lost",
|
|
325
|
+
resolved: "Resolved",
|
|
326
|
+
marketClosed: "Market closed",
|
|
327
|
+
closed: "Closed"
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
eventList: {
|
|
331
|
+
matchedTab: "Matched",
|
|
332
|
+
loading: (title) => `Loading ${title}`,
|
|
333
|
+
tabsAria: (title) => `${title} tabs`,
|
|
334
|
+
emptyAria: "No events found",
|
|
335
|
+
emptyTitle: "No Events Found",
|
|
336
|
+
emptyDescription: "We couldn't find any events matching your filters.\nTry adjusting them or check back later.",
|
|
337
|
+
empty: "No events found for this tab.",
|
|
338
|
+
errorTitle: "Something went wrong",
|
|
339
|
+
errorDescription: "We're having trouble loading data right now.\nTry refreshing or check back later.",
|
|
340
|
+
viewResolved: "View resolved",
|
|
341
|
+
hideResolved: "Hide resolved"
|
|
342
|
+
},
|
|
343
|
+
search: {
|
|
344
|
+
placeholder: "Search...",
|
|
345
|
+
inputAria: "Search markets",
|
|
346
|
+
resultsAria: "Search results",
|
|
347
|
+
resultAria: (title) => `View ${title}`,
|
|
348
|
+
resultsSummary: (countLabel, query) => `${countLabel} search results for "${query}"`,
|
|
349
|
+
seeAllResults: "See all results",
|
|
350
|
+
loadingResults: "Loading search results",
|
|
351
|
+
noResultsTitle: "No markets found",
|
|
352
|
+
noResultsDescription: "Check your spelling or try a broader search term."
|
|
353
|
+
},
|
|
354
|
+
eventItem: {
|
|
355
|
+
loading: "Loading market tile",
|
|
356
|
+
unavailableAria: "Market tile unavailable",
|
|
357
|
+
unavailableTitle: "Market unavailable",
|
|
358
|
+
unavailableDescription: "We could not load this market right now.",
|
|
359
|
+
arbitrage: "Arbitrage",
|
|
360
|
+
priceGap: "Price Gap",
|
|
361
|
+
volumeSuffix: "Vol.",
|
|
362
|
+
marketSingular: "Market",
|
|
363
|
+
marketPlural: "Markets",
|
|
364
|
+
venueSingular: "Venue",
|
|
365
|
+
venuePlural: "Venues"
|
|
366
|
+
},
|
|
367
|
+
eventItemDetails: {
|
|
368
|
+
loading: "Loading market details",
|
|
369
|
+
unavailableAria: "Market details unavailable",
|
|
370
|
+
unavailableTitle: "Market details unavailable",
|
|
371
|
+
unavailableDescription: "We could not load this market right now.",
|
|
372
|
+
notFoundAria: "Event not found",
|
|
373
|
+
notFoundTitle: "Event Not Found",
|
|
374
|
+
notFoundDescription: "We couldn't find this event or it may no longer exist.",
|
|
375
|
+
chartUnavailableAria: "Chart unavailable",
|
|
376
|
+
chartUnavailableTitle: "Chart Unavailable",
|
|
377
|
+
chartUnavailableDescription: "We couldn't load live chart data for this event.",
|
|
378
|
+
historicalLineChartAria: (title) => `${title} historical line chart`,
|
|
379
|
+
outcomeSelectorAria: "Outcome selector",
|
|
380
|
+
yes: "Yes",
|
|
381
|
+
no: "No",
|
|
382
|
+
allTimeRange: "All",
|
|
383
|
+
volumeSuffix: "Vol.",
|
|
384
|
+
marketSelectPlaceholder: "Select market",
|
|
385
|
+
marketSelectSearchPlaceholder: "Search markets...",
|
|
386
|
+
marketSelectEmpty: "No markets found"
|
|
387
|
+
},
|
|
388
|
+
settlementSummary: {
|
|
389
|
+
title: "Settlement",
|
|
390
|
+
readFullDetails: "Read full details",
|
|
391
|
+
showLess: "Show less"
|
|
392
|
+
},
|
|
393
|
+
marketDetails: {
|
|
394
|
+
loading: "Loading market details",
|
|
395
|
+
unavailableAria: "Market details unavailable",
|
|
396
|
+
unavailableTitle: "Market details unavailable",
|
|
397
|
+
unavailableDescription: "We could not load this market right now.",
|
|
398
|
+
notFoundAria: "Market not found",
|
|
399
|
+
notFoundTitle: "Market Not Found",
|
|
400
|
+
notFoundDescription: "We couldn't find this market or it may no longer exist.",
|
|
401
|
+
chartUnavailableAria: "Chart unavailable",
|
|
402
|
+
chartUnavailableTitle: "Chart Unavailable",
|
|
403
|
+
chartUnavailableDescription: "We couldn't load live chart data for this market.",
|
|
404
|
+
orderBookEmptyAria: "No orders yet",
|
|
405
|
+
orderBookEmptyTitle: "No orders yet",
|
|
406
|
+
orderBookEmptyDescription: "Be the first to set the price on this market.",
|
|
407
|
+
orderBookResolvedAria: "Market resolved",
|
|
408
|
+
orderBookResolvedTitle: "Market Resolved",
|
|
409
|
+
orderBookResolvedDescription: "This market has been resolved and is no longer trading.",
|
|
410
|
+
orderBookUnavailableAria: "Orderbook unavailable",
|
|
411
|
+
orderBookUnavailableTitle: "Orderbook Unavailable",
|
|
412
|
+
orderBookUnavailableDescription: "We couldn't load live order data for this market.",
|
|
413
|
+
marketOutcomesAria: "Market outcomes",
|
|
414
|
+
tabsAria: "Market details tabs",
|
|
415
|
+
toggleOpenDetailsAria: (title) => `Open details for ${title}`,
|
|
416
|
+
toggleCloseDetailsAria: (title) => `Close details for ${title}`,
|
|
417
|
+
loadingOrderbookAria: "Loading orderbook",
|
|
418
|
+
loadingOrderbookLabel: "Loading orderbook...",
|
|
419
|
+
asks: "Asks",
|
|
420
|
+
bids: "Bids",
|
|
421
|
+
spread: "Spread",
|
|
422
|
+
midPrice: "Mid",
|
|
423
|
+
tradePrefix: "Trade",
|
|
424
|
+
priceColumn: "Price",
|
|
425
|
+
sharesColumn: "Shares",
|
|
426
|
+
totalColumn: "Total",
|
|
427
|
+
lastPrice: "Last",
|
|
428
|
+
graphAria: (title) => `${title} price history`,
|
|
429
|
+
outcomeSelectorAria: "Outcome selector",
|
|
430
|
+
showOutcomeAria: (label) => `Show ${label} outcome`,
|
|
431
|
+
viewResolved: "View resolved",
|
|
432
|
+
hideResolved: "Hide resolved",
|
|
433
|
+
volumeUnavailable: "Volume unavailable",
|
|
434
|
+
tabs: {
|
|
435
|
+
orderBook: "Order Book",
|
|
436
|
+
graph: "Graph",
|
|
437
|
+
other: "Other"
|
|
438
|
+
},
|
|
439
|
+
meta: {
|
|
440
|
+
status: "Status",
|
|
441
|
+
created: "Created",
|
|
442
|
+
opens: "Opens",
|
|
443
|
+
closes: "Closes",
|
|
444
|
+
markets: "Markets",
|
|
445
|
+
unknown: "Unknown",
|
|
446
|
+
venueSingular: "Venue",
|
|
447
|
+
venuePlural: "Venues",
|
|
448
|
+
volumeSuffix: "Vol."
|
|
449
|
+
}
|
|
450
|
+
},
|
|
451
|
+
trading: {
|
|
452
|
+
settlementSection: "Settlement",
|
|
453
|
+
settlementDifferencesTitle: "Key differences across venues",
|
|
454
|
+
settlementLoading: "Loading settlement",
|
|
455
|
+
settlementDetailsAria: (venueLabel) => `${venueLabel} settlement details`,
|
|
456
|
+
settlementShowMoreAria: (ctaLabel, venueLabel) => `${ctaLabel} for ${venueLabel}`,
|
|
457
|
+
settlementDescriptionLabel: "Description",
|
|
458
|
+
settlementRulesPrimaryLabel: "Resolution rules",
|
|
459
|
+
settlementRulesSecondaryLabel: "Additional rules",
|
|
460
|
+
disclaimer: "By trading, you agree to the Terms of Use of each exchange.",
|
|
461
|
+
geoBlockTermsLink: "Terms of Use",
|
|
462
|
+
geoBlockGenericMessage: "Trading is not available in your region. See ",
|
|
463
|
+
geoBlockVenueMessage: (venueLabel) => `Trading on ${venueLabel} is not available in your region. See `,
|
|
464
|
+
geoBlockMessageSuffix: " for more information.",
|
|
465
|
+
geoBlockModalAriaLabel: "Geo-restricted location",
|
|
466
|
+
geoBlockModalTitle: "Trading is not available in your current location",
|
|
467
|
+
geoBlockModalDescription: "You appear to be located in a restricted jurisdiction. You can still browse markets in view-only mode or return when you're in a supported region.",
|
|
468
|
+
geoBlockModalConfirm: "Confirm",
|
|
469
|
+
averagePrice: (value) => `${(value * 100).toLocaleString("en-US", {
|
|
470
|
+
minimumFractionDigits: 0,
|
|
471
|
+
maximumFractionDigits: 2
|
|
472
|
+
})}\xA2 avg. price`,
|
|
473
|
+
balance: (value) => `Balance ${value}`,
|
|
474
|
+
shares: (value) => `${value.toLocaleString("en-US", {
|
|
475
|
+
minimumFractionDigits: Number.isInteger(value) ? 0 : 2,
|
|
476
|
+
maximumFractionDigits: 6
|
|
477
|
+
})} shares`,
|
|
478
|
+
slippage: (value) => `Slippage: ${value}%`,
|
|
479
|
+
editSlippage: (value) => `Edit ${value}`,
|
|
480
|
+
collapseSlippage: (value) => `Collapse ${value}`,
|
|
481
|
+
resetSlippage: "Auto",
|
|
482
|
+
slippageWarning: (value) => `Slippage below ${value}% may prevent your order from executing.`,
|
|
483
|
+
slippageLow: (value) => `Slippage below ${value}% may prevent your order from executing.`,
|
|
484
|
+
slippageHigh: (value) => `Slippage above ${value}% increases the chance of an unfavorable trade.`,
|
|
485
|
+
showAdditionalVenues: (count) => `Show ${count} more venue${count === 1 ? "" : "s"}`,
|
|
486
|
+
hideAdditionalVenues: "Hide additional venues",
|
|
487
|
+
quoteExpired: "Quote expired. Please refresh.",
|
|
488
|
+
orderSubmitted: "Order submitted",
|
|
489
|
+
orderPending: "Your order is being processed...",
|
|
490
|
+
orderFailed: "Order failed. Please try again.",
|
|
491
|
+
orderDisabledEventResolved: "This event has been resolved.",
|
|
492
|
+
orderDisabledEventClosed: "This event is no longer accepting orders.",
|
|
493
|
+
orderDisabledEventPaused: "Trading is temporarily paused for this event.",
|
|
494
|
+
orderDisabledEventUnopened: "Trading has not opened yet for this event.",
|
|
495
|
+
orderDisabledEventUnavailable: "Trading is currently unavailable.",
|
|
496
|
+
orderDisabledMarketResolved: "This market has been resolved.",
|
|
497
|
+
orderDisabledMarketClosed: "This market is no longer accepting orders.",
|
|
498
|
+
orderDisabledMarketPaused: "Trading is temporarily paused for this market.",
|
|
499
|
+
orderDisabledMarketUnopened: "Trading has not opened yet for this market.",
|
|
500
|
+
orderDisabledMarketUnavailable: "Trading is currently unavailable for this market.",
|
|
501
|
+
orderDisabledNoMarket: "Select a market to place an order.",
|
|
502
|
+
orderDisabledNoOutcome: "Select an outcome to place an order.",
|
|
503
|
+
orderDisabledNoEvent: "No event selected.",
|
|
504
|
+
insufficientBalance: "Insufficient balance",
|
|
505
|
+
refreshQuote: "Refresh Quote",
|
|
506
|
+
confirmOrder: "Confirm Order",
|
|
507
|
+
withdrawSubmitted: "Withdrawal submitted",
|
|
508
|
+
withdrawProcessing: "Your withdrawal is being processed...",
|
|
509
|
+
estimatedCost: (value) => `Est. cost ${value}`,
|
|
510
|
+
partialFill: (filledSize, requestedSize) => `Only ${filledSize} of ${requestedSize} shares available at this price.`,
|
|
511
|
+
insufficientLiquidity: "Not enough liquidity available for this order size.",
|
|
512
|
+
noMarketSelected: "Select a market to place an order.",
|
|
513
|
+
noOrderbooks: "No live orderbooks are available for this market right now.",
|
|
514
|
+
quoteUnavailable: "Quote temporarily unavailable. Please try again.",
|
|
515
|
+
selectedVenueUnavailable: "The venue you selected is no longer available on this route. Review the updated options and try again.",
|
|
516
|
+
engineUnavailable: "The routing engine is temporarily unavailable. Please try again in a moment.",
|
|
517
|
+
insufficientInputAmount: "Trade amount is too small to cover bridging and execution costs. Increase your spend or deposit funds on the destination chain.",
|
|
518
|
+
minOrderSizeViolated: "Order size is below the venue minimum. Increase your spend.",
|
|
519
|
+
minimumOrderAmount: (amount) => `Minimum order is $${amount}`,
|
|
520
|
+
insufficientPosition: (totalShares) => `You only have ${totalShares} shares available to sell.`,
|
|
521
|
+
insufficientPositionGeneric: "You don't have enough shares to sell.",
|
|
522
|
+
insufficientSellDepth: "Not enough bid liquidity on the matched venues for this sell amount.",
|
|
523
|
+
noBidsAboveMinPrice: "No venue bids above the minimum price.",
|
|
524
|
+
signInRequired: "Sign in to get a routed quote",
|
|
525
|
+
kycRequired: "Verify to trade Kalshi",
|
|
526
|
+
kycNotVerifiedTooltip: "You have not been verified yet",
|
|
527
|
+
kycVerifyModalTitle: "Verify Your Identity",
|
|
528
|
+
kycVerifyModalDescription: "To start trading on Kalshi, you'll need to complete identity verification through dFlow. It only takes a few minutes and helps us stay compliant with regulations.",
|
|
529
|
+
kycStartVerification: "Start Verification",
|
|
530
|
+
kycDoItLater: "Do It Later",
|
|
531
|
+
kycSuccessTitle: "Verification successful",
|
|
532
|
+
kycSuccessDescription: "Your identity has been confirmed and you now have full access to trade on Kalshi markets.",
|
|
533
|
+
kycSuccessDone: "Done",
|
|
534
|
+
outcome: (label) => `Outcome: ${label}`,
|
|
535
|
+
smartRouting: "Smart Routing",
|
|
536
|
+
orderSplitting: "Order Splitting",
|
|
537
|
+
splitOrderDescription: "We split your order for the best price:",
|
|
538
|
+
viewAllRoutes: (count) => `View all (${count})`,
|
|
539
|
+
hideRoutes: "Hide routes",
|
|
540
|
+
venueUnavailableInRegion: "Unavailable in your region",
|
|
541
|
+
toWin: (tab) => tab === "buy" ? "To win" : "Payout",
|
|
542
|
+
buyingOutcome: (label) => `Buying ${label}`,
|
|
543
|
+
sellingOutcome: (label) => `Selling ${label}`,
|
|
544
|
+
findingBestRoute: "Finding the best route...",
|
|
545
|
+
submittingOrderProgress: "Submitting order...",
|
|
546
|
+
orderSubmittedProgress: (orderId) => `Order #${orderId.replace(/^#/, "")} submitted`,
|
|
547
|
+
executingOnVenue: (venueLabel) => `Executing on ${venueLabel}...`,
|
|
548
|
+
confirmTransactionInWallet: "Confirm the transaction in your wallet",
|
|
549
|
+
executionConfirmed: "Execution confirmed",
|
|
550
|
+
orderSuccessTitle: "Order placed",
|
|
551
|
+
orderSuccessDescription: "Your order has been submitted successfully.",
|
|
552
|
+
orderFailureTitle: "Order failed",
|
|
553
|
+
orderFailureDescription: (message) => message || "Something went wrong. Please try again.",
|
|
554
|
+
orderDone: "Done",
|
|
555
|
+
orderNewTrade: "New Trade",
|
|
556
|
+
orderShare: "Share",
|
|
557
|
+
orderRetry: "Try again",
|
|
558
|
+
orderContinue: "Continue",
|
|
559
|
+
orderDismiss: "Dismiss",
|
|
560
|
+
orderRetryVenue: (venueLabel) => `Retry ${venueLabel}`,
|
|
561
|
+
orderPartialFillStatus: (venueLabel) => `${venueLabel} order partially filled`,
|
|
562
|
+
orderVenueUnavailableStatus: (venueLabel) => `${venueLabel} unavailable, your funds have not been charged.`,
|
|
563
|
+
orderMarketResolvedStatus: (venueLabel) => `Market resolved on ${venueLabel} and is no longer accepting orders.`,
|
|
564
|
+
orderSummaryShares: "Shares",
|
|
565
|
+
orderSummaryAvgPrice: "Avg. price",
|
|
566
|
+
orderSummaryEstCost: "Est. cost",
|
|
567
|
+
orderSummaryVenue: "Venue",
|
|
568
|
+
orderComplete: "Order complete",
|
|
569
|
+
orderFilledAtPrice: (venueLabel, priceLabel) => `${venueLabel} order filled at ${priceLabel}`,
|
|
570
|
+
orderFilledAtPriceWithAmount: (venueLabel, priceLabel, amountLabel) => `${venueLabel} order filled at ${priceLabel} (${amountLabel})`,
|
|
571
|
+
orderPartiallyFilledAtPriceWithAmount: (venueLabel, priceLabel, amountLabel) => `${venueLabel} order partially filled at ${priceLabel} (${amountLabel})`,
|
|
572
|
+
orderSkip: "Skip",
|
|
573
|
+
orderRetryRemaining: "Retry remaining",
|
|
574
|
+
resolvedEarningsTitle: "Your Earnings",
|
|
575
|
+
resolvedSharesLabel: "Shares",
|
|
576
|
+
resolvedTotalPayoutLabel: "Total payout",
|
|
577
|
+
claimWinnings: "Claim Winnings",
|
|
578
|
+
boughtOutcomeAtPrice: (label, priceLabel) => `Bought ${label} at ${priceLabel}`,
|
|
579
|
+
soldOutcomeAtPrice: (label, priceLabel) => `Sold ${label} at ${priceLabel}`,
|
|
580
|
+
potentialReturnBonus: (value) => `+${value} Better Payout`,
|
|
581
|
+
withSmartRouting: "with Smart Routing",
|
|
582
|
+
buy: "Buy",
|
|
583
|
+
sell: "Sell",
|
|
584
|
+
amount: (side) => `${side === "buy" ? "Amount" : "Shares"}`
|
|
585
|
+
},
|
|
586
|
+
onboarding: {
|
|
587
|
+
modal: {
|
|
588
|
+
title: "Onboarding",
|
|
589
|
+
stepHowItWorks: "How it works",
|
|
590
|
+
stepProfileSetup: "Set up your profile",
|
|
591
|
+
stepConnectAccounts: "Connect accounts"
|
|
592
|
+
},
|
|
593
|
+
howItWorks: {
|
|
594
|
+
title: "How it works",
|
|
595
|
+
continue: "Continue",
|
|
596
|
+
features: {
|
|
597
|
+
createAccount: {
|
|
598
|
+
title: "Create Your Account",
|
|
599
|
+
description: "Add a few basic details to set up your account and personalize your experience on the platform."
|
|
600
|
+
},
|
|
601
|
+
linkAccounts: {
|
|
602
|
+
title: "Link Trading Accounts",
|
|
603
|
+
description: "Connect supported exchanges to unlock additional markets and liquidity. Trade across decentralized markets in one interface."
|
|
604
|
+
},
|
|
605
|
+
bestPrices: {
|
|
606
|
+
title: "Best Prices Always",
|
|
607
|
+
description: "Our real-time aggregated orderbook lets you shop lines across exchanges and automatically splits predictions to optimize trades."
|
|
608
|
+
},
|
|
609
|
+
stayInControl: {
|
|
610
|
+
title: "You Stay in Control",
|
|
611
|
+
description: "All trades are executed on the original platform. We never custody funds or move money on your behalf."
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
},
|
|
615
|
+
profileSetup: {
|
|
616
|
+
title: "Set up your profile",
|
|
617
|
+
uploadProfilePictureAria: "Upload profile picture",
|
|
618
|
+
profilePreviewAlt: "Profile preview",
|
|
619
|
+
usernameLabel: "Username",
|
|
620
|
+
usernamePlaceholder: "e.g. CryptoJohn",
|
|
621
|
+
continue: "Continue"
|
|
622
|
+
},
|
|
623
|
+
connectAccounts: {
|
|
624
|
+
title: "Connect Accounts",
|
|
625
|
+
connect: "Connect",
|
|
626
|
+
connectAccount: "Connect Account",
|
|
627
|
+
continue: "Continue",
|
|
628
|
+
onchainTitle: "Onchain exchanges",
|
|
629
|
+
onchainMobileTitle: (additionalVenueCount) => `Polymarket +${additionalVenueCount} venues`,
|
|
630
|
+
onchainDescription: "Trade multiple venues with one signature.",
|
|
631
|
+
onchainMobileDescription: "Trade multiple exchanges with one signature",
|
|
632
|
+
kalshiTitle: "US regulated exchanges",
|
|
633
|
+
kalshiMobileTitle: "Kalshi",
|
|
634
|
+
kalshiDescription: "Trade on regulated markets via Kalshi.",
|
|
635
|
+
kalshiMobileDescription: "Connect your Kalshi account"
|
|
636
|
+
},
|
|
637
|
+
connectOnchainModal: {
|
|
638
|
+
ariaLabel: "Connect Onchain Exchanges",
|
|
639
|
+
title: "Connect Onchain Exchanges",
|
|
640
|
+
description: "Sign in with your wallet to trade across supported\nonchain prediction markets.",
|
|
641
|
+
supportedVenuesLabel: "Supported venues:",
|
|
642
|
+
connect: "Sign In with Wallet",
|
|
643
|
+
cancel: "Cancel",
|
|
644
|
+
fallbackError: "Signature declined. Please try again."
|
|
645
|
+
},
|
|
646
|
+
connectKalshiModal: {
|
|
647
|
+
ariaLabel: "Connect Kalshi Account",
|
|
648
|
+
title: "Connect Kalshi Account",
|
|
649
|
+
description: "You'll generate an API key in Kalshi profile and add it to connect your account. These keys are used only to execute trades on your behalf.",
|
|
650
|
+
stepOne: {
|
|
651
|
+
label: "Step 1",
|
|
652
|
+
title: "Generate a Read/Write API Key in Kalshi",
|
|
653
|
+
instructions: {
|
|
654
|
+
signIn: "1. Sign in to your Kalshi account.",
|
|
655
|
+
goToProfilePrefix: "2. Go to your",
|
|
656
|
+
profileText: "Profile",
|
|
657
|
+
goToProfileSeparator: ":",
|
|
658
|
+
profileUrl: "https://kalshi.com/account/profile",
|
|
659
|
+
clickCreateKeyPrefix: "3. Click",
|
|
660
|
+
createKeyText: "Create Key",
|
|
661
|
+
clickCreateKeySuffix: ".",
|
|
662
|
+
selectPermissionsPrefix: "4. Select",
|
|
663
|
+
readWriteText: "Read/Write",
|
|
664
|
+
selectPermissionsSuffix: " permissions.",
|
|
665
|
+
createKey: "5. Create the key."
|
|
666
|
+
},
|
|
667
|
+
footerLineOne: "Kalshi will display your API Key ID and Private Key.",
|
|
668
|
+
footerLineTwo: "You'll need both for the next step."
|
|
669
|
+
},
|
|
670
|
+
stepTwo: {
|
|
671
|
+
label: "Step 2",
|
|
672
|
+
title: "Paste Your Kalshi API Credentials",
|
|
673
|
+
description: "These credentials are encrypted and used only to execute trades on your behalf. We can't access your funds directly.",
|
|
674
|
+
apiKeyIdLabel: "API Key ID",
|
|
675
|
+
apiKeyIdPlaceholder: "a3f9c1b2-7d4e-4c91-9f2a-8b6e1d3c5a77",
|
|
676
|
+
privateKeyLabel: "Private Key",
|
|
677
|
+
privateKeyPlaceholder: "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASC..."
|
|
678
|
+
},
|
|
679
|
+
help: {
|
|
680
|
+
label: "Having trouble?",
|
|
681
|
+
docsLinkLabel: "View Kalshi docs",
|
|
682
|
+
tutorialLinkLabel: "Watch tutorial video"
|
|
683
|
+
},
|
|
684
|
+
actions: {
|
|
685
|
+
cancel: "Cancel",
|
|
686
|
+
verifyConnection: "Verify Connection"
|
|
687
|
+
},
|
|
688
|
+
fallbackError: "Verification failed. Please check your credentials and try again."
|
|
689
|
+
}
|
|
690
|
+
},
|
|
691
|
+
eventMarketPage: {
|
|
692
|
+
unavailableAria: "Event market page unavailable",
|
|
693
|
+
unavailableTitle: "Something went wrong",
|
|
694
|
+
unavailableDescription: "We're having trouble loading this event right now.\nTry refreshing or check back later.",
|
|
695
|
+
loadingSettlementQuestion: "Loading settlement",
|
|
696
|
+
loadingSettlementDifferencesTitle: "Loading settlement",
|
|
697
|
+
loadingSettlementPlaceholder: "Loading",
|
|
698
|
+
tradingResolvedBadge: "Resolved",
|
|
699
|
+
tradingResolvedTitle: "Market resolved",
|
|
700
|
+
tradingResolvedDescription: "Trading has ended for this event. You can review the final result.",
|
|
701
|
+
tradingClosedBadge: "Closed",
|
|
702
|
+
tradingClosedTitle: "Trading closed",
|
|
703
|
+
tradingClosedDescription: "This event is no longer accepting new orders.",
|
|
704
|
+
tradingPausedBadge: "Paused",
|
|
705
|
+
tradingPausedTitle: "Trading paused",
|
|
706
|
+
tradingPausedDescription: "Trading is temporarily unavailable for this event.",
|
|
707
|
+
tradingUnopenedBadge: "Upcoming",
|
|
708
|
+
tradingUnopenedTitle: "Trading not open yet",
|
|
709
|
+
tradingUnopenedDescription: "This event is listed, but trading has not opened yet.",
|
|
710
|
+
tradingUnavailableBadge: "Unavailable",
|
|
711
|
+
tradingUnavailableTitle: "Trading unavailable",
|
|
712
|
+
tradingUnavailableDescription: "Trading is currently unavailable for this event.",
|
|
713
|
+
resolvedAt: (dateLabel) => `Resolved ${dateLabel}`,
|
|
714
|
+
closedAt: (dateLabel) => `Closed ${dateLabel}`,
|
|
715
|
+
opensAt: (dateLabel) => `Opens ${dateLabel}`,
|
|
716
|
+
winningOutcome: (label) => `Winning outcome: ${label}`,
|
|
717
|
+
resolvedOutcome: (label) => `Resolved: ${label}`,
|
|
718
|
+
marketDetailsAriaByDate: (dateLabel) => `Market details for ${dateLabel}`,
|
|
719
|
+
marketDetailsAriaByQuestion: (question) => `Market details for ${question}`
|
|
720
|
+
},
|
|
721
|
+
header: {
|
|
722
|
+
bannerAria: "Site header",
|
|
723
|
+
logoAria: "Home"
|
|
724
|
+
}
|
|
725
|
+
};
|
|
726
|
+
var defaultAggUiLabelsByLocale = {
|
|
727
|
+
"en-US": enUsLabels,
|
|
728
|
+
en: enUsLabels
|
|
729
|
+
};
|
|
730
|
+
var resolveAggUiLabels = (locale) => {
|
|
731
|
+
var _a;
|
|
732
|
+
if (defaultAggUiLabelsByLocale[locale]) {
|
|
733
|
+
return defaultAggUiLabelsByLocale[locale];
|
|
734
|
+
}
|
|
735
|
+
const baseLocale = locale.split("-")[0];
|
|
736
|
+
return (_a = defaultAggUiLabelsByLocale[baseLocale]) != null ? _a : enUsLabels;
|
|
737
|
+
};
|
|
738
|
+
|
|
739
|
+
// src/core/ui-config/utils.ts
|
|
740
|
+
var DEFAULT_LOCALE = "en-US";
|
|
741
|
+
var createFormatters = (locale) => {
|
|
742
|
+
const number = new Intl.NumberFormat(locale, {
|
|
743
|
+
maximumFractionDigits: 2
|
|
744
|
+
});
|
|
745
|
+
const percent = new Intl.NumberFormat(locale, {
|
|
746
|
+
style: "percent",
|
|
747
|
+
minimumFractionDigits: 0,
|
|
748
|
+
maximumFractionDigits: 0
|
|
749
|
+
});
|
|
750
|
+
const currency = new Intl.NumberFormat(locale, {
|
|
751
|
+
style: "currency",
|
|
752
|
+
currency: "USD",
|
|
753
|
+
maximumFractionDigits: 2
|
|
754
|
+
});
|
|
755
|
+
const compactCurrency = new Intl.NumberFormat(locale, {
|
|
756
|
+
style: "currency",
|
|
757
|
+
currency: "USD",
|
|
758
|
+
notation: "compact",
|
|
759
|
+
maximumFractionDigits: 0
|
|
760
|
+
});
|
|
761
|
+
const date = new Intl.DateTimeFormat(locale, {
|
|
762
|
+
month: "long",
|
|
763
|
+
day: "numeric",
|
|
764
|
+
year: "numeric"
|
|
765
|
+
});
|
|
766
|
+
return {
|
|
767
|
+
formatNumber: (value) => number.format(value),
|
|
768
|
+
formatPercent: (value) => percent.format(value),
|
|
769
|
+
formatCurrency: (value) => currency.format(value),
|
|
770
|
+
formatCompactCurrency: (value) => compactCurrency.format(value),
|
|
771
|
+
formatDate: (value) => date.format(value)
|
|
772
|
+
};
|
|
773
|
+
};
|
|
774
|
+
var defaultFormatters = createFormatters(DEFAULT_LOCALE);
|
|
775
|
+
var defaultAggUiSearchConfig = {
|
|
776
|
+
value: "",
|
|
777
|
+
result: null,
|
|
778
|
+
isShowingAllResults: false
|
|
779
|
+
};
|
|
780
|
+
var defaultAggUiConfig = {
|
|
781
|
+
enableLogs: false,
|
|
782
|
+
enableWebsocketsLogs: false,
|
|
783
|
+
general: {
|
|
784
|
+
locale: DEFAULT_LOCALE,
|
|
785
|
+
theme: "light",
|
|
786
|
+
rootClassName: "",
|
|
787
|
+
labels: resolveAggUiLabels(DEFAULT_LOCALE)
|
|
788
|
+
},
|
|
789
|
+
features: {
|
|
790
|
+
enableAnimations: true,
|
|
791
|
+
enableLiveUpdates: true,
|
|
792
|
+
enableGradients: false
|
|
793
|
+
},
|
|
794
|
+
market: {
|
|
795
|
+
arbitrageThreshold: 0
|
|
796
|
+
},
|
|
797
|
+
chart: {
|
|
798
|
+
defaultChartTimeRange: "1D",
|
|
799
|
+
selectedChartTimeRange: "1D",
|
|
800
|
+
setSelectedChartTimeRange: () => {
|
|
801
|
+
}
|
|
802
|
+
},
|
|
803
|
+
formatting: defaultFormatters,
|
|
804
|
+
search: defaultAggUiSearchConfig
|
|
805
|
+
};
|
|
806
|
+
|
|
807
|
+
// src/core/providers/contexts.ts
|
|
808
|
+
var AggClientContext = (0, import_react.createContext)(null);
|
|
809
|
+
var AggUiContext = (0, import_react.createContext)(defaultAggUiConfig);
|
|
810
|
+
var AggLabelsContext = (0, import_react.createContext)(defaultAggUiConfig.general.labels);
|
|
811
|
+
var AggAuthContext = (0, import_react.createContext)(null);
|
|
812
|
+
var AggBalanceContext = (0, import_react.createContext)(null);
|
|
813
|
+
|
|
814
|
+
// src/execution/query-keys.ts
|
|
815
|
+
var executionKeys = {
|
|
816
|
+
all: () => ["execution"],
|
|
817
|
+
balances: () => ["execution", "balances"],
|
|
818
|
+
positions: (cursor, limit, status) => ["execution", "positions", cursor != null ? cursor : null, limit != null ? limit : null, status != null ? status : null],
|
|
819
|
+
positionsPrefix: () => ["execution", "positions"],
|
|
820
|
+
claimableClosedPositionsCount: () => ["execution", "positions", "claimable-count"],
|
|
821
|
+
orders: (status, cursor, limit) => ["execution", "orders", status != null ? status : null, cursor != null ? cursor : null, limit != null ? limit : null],
|
|
822
|
+
ordersPrefix: () => ["execution", "orders"],
|
|
823
|
+
depositAddresses: () => ["execution", "deposit-addresses"]
|
|
824
|
+
};
|
|
825
|
+
|
|
826
|
+
// src/execution/balance-invalidation.ts
|
|
827
|
+
var balanceQueryKeys = {
|
|
828
|
+
execution: () => executionKeys.balances(),
|
|
829
|
+
// Kept as an alias for backward compatibility with existing callers.
|
|
830
|
+
// The balance provider now uses the same canonical execution balances key.
|
|
831
|
+
provider: () => executionKeys.balances(),
|
|
832
|
+
venue: (venuesKey) => ["venue-balances", venuesKey],
|
|
833
|
+
venuePrefix: () => ["venue-balances"]
|
|
834
|
+
};
|
|
835
|
+
var invalidateBalanceQueries = (queryClient, options) => {
|
|
836
|
+
var _a;
|
|
837
|
+
const refetchType = (_a = options == null ? void 0 : options.refetchType) != null ? _a : "active";
|
|
838
|
+
const executionKey = balanceQueryKeys.execution();
|
|
839
|
+
const providerKey = balanceQueryKeys.provider();
|
|
840
|
+
queryClient.invalidateQueries({
|
|
841
|
+
queryKey: executionKey,
|
|
842
|
+
refetchType
|
|
843
|
+
});
|
|
844
|
+
const isProviderKeyDistinct = providerKey.length !== executionKey.length || providerKey.some((segment, index) => segment !== executionKey[index]);
|
|
845
|
+
if (isProviderKeyDistinct) {
|
|
846
|
+
queryClient.invalidateQueries({
|
|
847
|
+
queryKey: providerKey,
|
|
848
|
+
refetchType
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
queryClient.invalidateQueries({
|
|
852
|
+
queryKey: balanceQueryKeys.venuePrefix(),
|
|
853
|
+
refetchType
|
|
854
|
+
});
|
|
855
|
+
};
|
|
856
|
+
|
|
857
|
+
// src/core/providers/hooks.ts
|
|
858
|
+
var import_react2 = require("react");
|
|
859
|
+
var useAggClient = () => {
|
|
860
|
+
const client = (0, import_react2.useContext)(AggClientContext);
|
|
861
|
+
if (!client) {
|
|
862
|
+
throw new Error("useAggClient must be used within an <AggProvider>");
|
|
863
|
+
}
|
|
864
|
+
return client;
|
|
865
|
+
};
|
|
866
|
+
var useAggUiConfig = () => {
|
|
867
|
+
return (0, import_react2.useContext)(AggUiContext);
|
|
868
|
+
};
|
|
869
|
+
var useAggAuthContext = () => {
|
|
870
|
+
const context = (0, import_react2.useContext)(AggAuthContext);
|
|
871
|
+
if (!context) {
|
|
872
|
+
throw new Error("useAggAuthContext must be used within an <AggProvider>");
|
|
873
|
+
}
|
|
874
|
+
return context;
|
|
875
|
+
};
|
|
876
|
+
var useAggAuthState = useAggAuthContext;
|
|
877
|
+
var useAggBalanceContext = () => {
|
|
878
|
+
const context = (0, import_react2.useContext)(AggBalanceContext);
|
|
879
|
+
if (!context) {
|
|
880
|
+
throw new Error("useAggBalanceContext must be used within an <AggProvider>");
|
|
881
|
+
}
|
|
882
|
+
return context;
|
|
883
|
+
};
|
|
884
|
+
var useAggBalanceState = useAggBalanceContext;
|
|
885
|
+
|
|
886
|
+
// src/deposit/constants.ts
|
|
887
|
+
var DEFAULT_SOLANA_RPC_ENDPOINT = "https://solana-rpc.publicnode.com";
|
|
888
|
+
var SVM_CHAIN_IDS = /* @__PURE__ */ new Set([792703809]);
|
|
889
|
+
|
|
890
|
+
// src/deposit/use-wallet-token-balance.ts
|
|
891
|
+
var ERC20_BALANCE_OF_ABI = [
|
|
892
|
+
{
|
|
893
|
+
name: "balanceOf",
|
|
894
|
+
type: "function",
|
|
895
|
+
stateMutability: "view",
|
|
896
|
+
inputs: [{ name: "account", type: "address" }],
|
|
897
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
898
|
+
}
|
|
899
|
+
];
|
|
900
|
+
function getPhantomProvider() {
|
|
901
|
+
var _a, _b;
|
|
902
|
+
if (typeof window === "undefined") return void 0;
|
|
903
|
+
const w = window;
|
|
904
|
+
return (_b = (_a = w.phantom) == null ? void 0 : _a.solana) != null ? _b : w.solana;
|
|
905
|
+
}
|
|
906
|
+
function useWalletTokenBalance({
|
|
907
|
+
isOpen = true,
|
|
908
|
+
chainId,
|
|
909
|
+
tokenAddress,
|
|
910
|
+
decimals,
|
|
911
|
+
svmAddress
|
|
912
|
+
}) {
|
|
913
|
+
var _a, _b, _c;
|
|
914
|
+
const { solanaRpcUrl } = useAggUiConfig();
|
|
915
|
+
const rpcEndpoint = solanaRpcUrl != null ? solanaRpcUrl : DEFAULT_SOLANA_RPC_ENDPOINT;
|
|
916
|
+
const isSvm = chainId !== void 0 && SVM_CHAIN_IDS.has(chainId);
|
|
917
|
+
const { address: evmAddress } = (0, import_wagmi.useAccount)();
|
|
918
|
+
const evmEnabled = isOpen && !isSvm && !!chainId && !!tokenAddress && !!evmAddress && decimals !== void 0;
|
|
919
|
+
const { data: rawEvmBalance, isLoading: evmLoading } = (0, import_wagmi.useReadContract)({
|
|
920
|
+
address: tokenAddress,
|
|
921
|
+
chainId,
|
|
922
|
+
abi: ERC20_BALANCE_OF_ABI,
|
|
923
|
+
functionName: "balanceOf",
|
|
924
|
+
args: evmAddress ? [evmAddress] : void 0,
|
|
925
|
+
query: { enabled: evmEnabled, staleTime: 0, refetchOnMount: true }
|
|
926
|
+
});
|
|
927
|
+
const { publicKey: adapterPublicKey } = (0, import_wallet_adapter_react.useWallet)();
|
|
928
|
+
const [phantomAddress, setPhantomAddress] = (0, import_react3.useState)(void 0);
|
|
929
|
+
(0, import_react3.useEffect)(() => {
|
|
930
|
+
var _a2;
|
|
931
|
+
if (!isSvm) return;
|
|
932
|
+
const provider = getPhantomProvider();
|
|
933
|
+
if (!provider) return;
|
|
934
|
+
const existing = (_a2 = provider.publicKey) == null ? void 0 : _a2.toBase58();
|
|
935
|
+
if (existing) {
|
|
936
|
+
setPhantomAddress(existing);
|
|
937
|
+
return;
|
|
938
|
+
}
|
|
939
|
+
provider.connect({ onlyIfTrusted: true }).then((res) => setPhantomAddress(res.publicKey.toString())).catch(() => {
|
|
940
|
+
});
|
|
941
|
+
}, [isSvm]);
|
|
942
|
+
const resolvedSvmAddress = (_b = (_a = adapterPublicKey == null ? void 0 : adapterPublicKey.toBase58()) != null ? _a : phantomAddress) != null ? _b : svmAddress;
|
|
943
|
+
const connection = (0, import_react3.useMemo)(() => new import_web3.Connection(rpcEndpoint), [rpcEndpoint]);
|
|
944
|
+
const svmEnabled = isOpen && isSvm && !!resolvedSvmAddress && !!tokenAddress;
|
|
945
|
+
const svmQuery = (0, import_react_query.useQuery)({
|
|
946
|
+
queryKey: ["svm-token-balance", resolvedSvmAddress != null ? resolvedSvmAddress : null, tokenAddress != null ? tokenAddress : null, isOpen],
|
|
947
|
+
enabled: svmEnabled,
|
|
948
|
+
staleTime: 0,
|
|
949
|
+
queryFn: () => __async(null, null, function* () {
|
|
950
|
+
var _a2;
|
|
951
|
+
if (!resolvedSvmAddress || !tokenAddress) return 0;
|
|
952
|
+
const owner = new import_web3.PublicKey(resolvedSvmAddress);
|
|
953
|
+
const mint = new import_web3.PublicKey(tokenAddress);
|
|
954
|
+
const accounts = yield connection.getTokenAccountsByOwner(owner, { mint });
|
|
955
|
+
if (accounts.value.length === 0) return 0;
|
|
956
|
+
const first = accounts.value[0];
|
|
957
|
+
if (!first) return 0;
|
|
958
|
+
const balance = yield connection.getTokenAccountBalance(first.pubkey);
|
|
959
|
+
return (_a2 = balance.value.uiAmount) != null ? _a2 : 0;
|
|
960
|
+
})
|
|
961
|
+
});
|
|
962
|
+
if (isSvm) {
|
|
963
|
+
const awaitingSelection2 = isOpen && !!chainId && !tokenAddress;
|
|
964
|
+
return {
|
|
965
|
+
balance: (_c = svmQuery.data) != null ? _c : 0,
|
|
966
|
+
isLoading: awaitingSelection2 || svmQuery.isLoading || svmQuery.isFetching
|
|
967
|
+
};
|
|
968
|
+
}
|
|
969
|
+
const evmBalance = rawEvmBalance !== void 0 && decimals !== void 0 ? Number((0, import_viem.formatUnits)(rawEvmBalance, decimals)) : 0;
|
|
970
|
+
const awaitingSelection = isOpen && !!chainId && !tokenAddress;
|
|
971
|
+
return { balance: evmBalance, isLoading: awaitingSelection || evmLoading };
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
// src/deposit/use-wallet-send-token.ts
|
|
975
|
+
var import_react4 = require("react");
|
|
976
|
+
var import_viem2 = require("viem");
|
|
977
|
+
var import_wagmi2 = require("wagmi");
|
|
978
|
+
var import_wallet_adapter_react2 = require("@solana/wallet-adapter-react");
|
|
979
|
+
var import_web32 = require("@solana/web3.js");
|
|
980
|
+
function getPhantomProvider2() {
|
|
981
|
+
var _a, _b;
|
|
982
|
+
if (typeof window === "undefined") return void 0;
|
|
983
|
+
const w = window;
|
|
984
|
+
return (_b = (_a = w.phantom) == null ? void 0 : _a.solana) != null ? _b : w.solana;
|
|
985
|
+
}
|
|
986
|
+
var ERC20_TRANSFER_ABI = [
|
|
987
|
+
{
|
|
988
|
+
constant: false,
|
|
989
|
+
inputs: [
|
|
990
|
+
{ name: "to", type: "address" },
|
|
991
|
+
{ name: "amount", type: "uint256" }
|
|
992
|
+
],
|
|
993
|
+
name: "transfer",
|
|
994
|
+
outputs: [{ name: "", type: "bool" }],
|
|
995
|
+
type: "function"
|
|
996
|
+
}
|
|
997
|
+
];
|
|
998
|
+
function useWalletSendToken() {
|
|
999
|
+
const { solanaRpcUrl } = useAggUiConfig();
|
|
1000
|
+
const rpcEndpoint = solanaRpcUrl != null ? solanaRpcUrl : DEFAULT_SOLANA_RPC_ENDPOINT;
|
|
1001
|
+
const { writeContractAsync } = (0, import_wagmi2.useWriteContract)();
|
|
1002
|
+
const { publicKey, sendTransaction } = (0, import_wallet_adapter_react2.useWallet)();
|
|
1003
|
+
return (0, import_react4.useCallback)(
|
|
1004
|
+
(params) => __async(null, null, function* () {
|
|
1005
|
+
var _a, _b;
|
|
1006
|
+
const isSvm = SVM_CHAIN_IDS.has(params.chainId);
|
|
1007
|
+
if (!isSvm) {
|
|
1008
|
+
const tokenAddress = params.token.address;
|
|
1009
|
+
if (!tokenAddress) {
|
|
1010
|
+
throw new Error("Missing ERC-20 token address for EVM transfer");
|
|
1011
|
+
}
|
|
1012
|
+
const value = (0, import_viem2.parseUnits)(params.amount || "0", params.token.decimals);
|
|
1013
|
+
const txHash = yield writeContractAsync({
|
|
1014
|
+
chainId: params.chainId,
|
|
1015
|
+
address: tokenAddress,
|
|
1016
|
+
abi: ERC20_TRANSFER_ABI,
|
|
1017
|
+
functionName: "transfer",
|
|
1018
|
+
args: [params.to, value]
|
|
1019
|
+
});
|
|
1020
|
+
return { txId: txHash };
|
|
1021
|
+
}
|
|
1022
|
+
if (!params.token.address) {
|
|
1023
|
+
throw new Error("Missing SPL token mint address for Solana transfer");
|
|
1024
|
+
}
|
|
1025
|
+
const phantom = getPhantomProvider2();
|
|
1026
|
+
let ownerBase58 = publicKey == null ? void 0 : publicKey.toBase58();
|
|
1027
|
+
if (!ownerBase58 && phantom) {
|
|
1028
|
+
try {
|
|
1029
|
+
const res = yield phantom.connect();
|
|
1030
|
+
ownerBase58 = res.publicKey.toString();
|
|
1031
|
+
} catch (err) {
|
|
1032
|
+
throw new Error(
|
|
1033
|
+
`Failed to connect Phantom: ${err instanceof Error ? err.message : String(err)}`
|
|
1034
|
+
);
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
if (!ownerBase58) {
|
|
1038
|
+
throw new Error("No Solana wallet connected");
|
|
1039
|
+
}
|
|
1040
|
+
const sendConnection = new import_web32.Connection(rpcEndpoint, "confirmed");
|
|
1041
|
+
const TOKEN_PROGRAM_ID = new import_web32.PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
|
|
1042
|
+
const ASSOCIATED_TOKEN_PROGRAM_ID = new import_web32.PublicKey(
|
|
1043
|
+
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
1044
|
+
);
|
|
1045
|
+
const owner = new import_web32.PublicKey(ownerBase58);
|
|
1046
|
+
const mint = new import_web32.PublicKey(params.token.address);
|
|
1047
|
+
const destinationOwner = new import_web32.PublicKey(params.to);
|
|
1048
|
+
const getAta = (walletPk, mintPk) => {
|
|
1049
|
+
const [ata] = import_web32.PublicKey.findProgramAddressSync(
|
|
1050
|
+
[walletPk.toBuffer(), TOKEN_PROGRAM_ID.toBuffer(), mintPk.toBuffer()],
|
|
1051
|
+
ASSOCIATED_TOKEN_PROGRAM_ID
|
|
1052
|
+
);
|
|
1053
|
+
return ata;
|
|
1054
|
+
};
|
|
1055
|
+
const sourceAta = getAta(owner, mint);
|
|
1056
|
+
const destinationAta = getAta(destinationOwner, mint);
|
|
1057
|
+
const tx = new import_web32.Transaction();
|
|
1058
|
+
let destinationTokenAccountSigner = null;
|
|
1059
|
+
const destinationOwnerInfo = yield sendConnection.getAccountInfo(destinationOwner);
|
|
1060
|
+
const destinationInfo = yield sendConnection.getAccountInfo(destinationAta);
|
|
1061
|
+
let destinationTokenAccount = destinationAta;
|
|
1062
|
+
if (!destinationInfo) {
|
|
1063
|
+
const rentExemptLamports = yield sendConnection.getMinimumBalanceForRentExemption(165);
|
|
1064
|
+
const payerLamports = yield sendConnection.getBalance(owner, "confirmed");
|
|
1065
|
+
const feeBufferLamports = 1e4;
|
|
1066
|
+
const requiredLamports = rentExemptLamports + feeBufferLamports;
|
|
1067
|
+
if (payerLamports < requiredLamports) {
|
|
1068
|
+
const requiredSol = (requiredLamports / 1e9).toFixed(6);
|
|
1069
|
+
const currentSol = (payerLamports / 1e9).toFixed(6);
|
|
1070
|
+
throw new Error(
|
|
1071
|
+
`This Solana deposit needs about ${requiredSol} SOL to create the destination token account, but the connected wallet only has ${currentSol} SOL available.`
|
|
1072
|
+
);
|
|
1073
|
+
}
|
|
1074
|
+
const canCreateAta = (_b = (_a = destinationOwnerInfo == null ? void 0 : destinationOwnerInfo.owner) == null ? void 0 : _a.equals(import_web32.SystemProgram.programId)) != null ? _b : false;
|
|
1075
|
+
if (canCreateAta) {
|
|
1076
|
+
const createIx = new import_web32.TransactionInstruction({
|
|
1077
|
+
programId: ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
1078
|
+
keys: [
|
|
1079
|
+
{ pubkey: owner, isSigner: true, isWritable: true },
|
|
1080
|
+
{ pubkey: destinationAta, isSigner: false, isWritable: true },
|
|
1081
|
+
{ pubkey: destinationOwner, isSigner: false, isWritable: false },
|
|
1082
|
+
{ pubkey: mint, isSigner: false, isWritable: false },
|
|
1083
|
+
{ pubkey: import_web32.SystemProgram.programId, isSigner: false, isWritable: false },
|
|
1084
|
+
{ pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false }
|
|
1085
|
+
],
|
|
1086
|
+
data: Buffer.alloc(0)
|
|
1087
|
+
});
|
|
1088
|
+
tx.add(createIx);
|
|
1089
|
+
} else {
|
|
1090
|
+
destinationTokenAccountSigner = import_web32.Keypair.generate();
|
|
1091
|
+
destinationTokenAccount = destinationTokenAccountSigner.publicKey;
|
|
1092
|
+
tx.add(
|
|
1093
|
+
import_web32.SystemProgram.createAccount({
|
|
1094
|
+
fromPubkey: owner,
|
|
1095
|
+
newAccountPubkey: destinationTokenAccount,
|
|
1096
|
+
lamports: rentExemptLamports,
|
|
1097
|
+
space: 165,
|
|
1098
|
+
programId: TOKEN_PROGRAM_ID
|
|
1099
|
+
})
|
|
1100
|
+
);
|
|
1101
|
+
const initAccountData = Buffer.concat([
|
|
1102
|
+
Buffer.from([18]),
|
|
1103
|
+
// InitializeAccount3
|
|
1104
|
+
destinationOwner.toBuffer()
|
|
1105
|
+
]);
|
|
1106
|
+
tx.add(
|
|
1107
|
+
new import_web32.TransactionInstruction({
|
|
1108
|
+
programId: TOKEN_PROGRAM_ID,
|
|
1109
|
+
keys: [
|
|
1110
|
+
{ pubkey: destinationTokenAccount, isSigner: false, isWritable: true },
|
|
1111
|
+
{ pubkey: mint, isSigner: false, isWritable: false }
|
|
1112
|
+
],
|
|
1113
|
+
data: initAccountData
|
|
1114
|
+
})
|
|
1115
|
+
);
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
let factor = BigInt(1);
|
|
1119
|
+
for (let i = 0; i < params.token.decimals; i += 1) {
|
|
1120
|
+
factor *= BigInt(10);
|
|
1121
|
+
}
|
|
1122
|
+
const amountRaw = BigInt(Math.trunc(Number(params.amount || "0") * Number(factor)));
|
|
1123
|
+
const data = new Uint8Array(10);
|
|
1124
|
+
data[0] = 12;
|
|
1125
|
+
let remaining = amountRaw;
|
|
1126
|
+
const mask = BigInt(255);
|
|
1127
|
+
for (let i = 0; i < 8; i += 1) {
|
|
1128
|
+
data[1 + i] = Number(remaining & mask);
|
|
1129
|
+
remaining >>= BigInt(8);
|
|
1130
|
+
}
|
|
1131
|
+
data[9] = params.token.decimals;
|
|
1132
|
+
const transferIx = new import_web32.TransactionInstruction({
|
|
1133
|
+
programId: TOKEN_PROGRAM_ID,
|
|
1134
|
+
keys: [
|
|
1135
|
+
{ pubkey: sourceAta, isSigner: false, isWritable: true },
|
|
1136
|
+
{ pubkey: mint, isSigner: false, isWritable: false },
|
|
1137
|
+
{ pubkey: destinationTokenAccount, isSigner: false, isWritable: true },
|
|
1138
|
+
{ pubkey: owner, isSigner: true, isWritable: false }
|
|
1139
|
+
],
|
|
1140
|
+
data: Buffer.from(data)
|
|
1141
|
+
});
|
|
1142
|
+
tx.add(transferIx);
|
|
1143
|
+
tx.feePayer = owner;
|
|
1144
|
+
const { blockhash } = yield sendConnection.getLatestBlockhash("confirmed");
|
|
1145
|
+
tx.recentBlockhash = blockhash;
|
|
1146
|
+
if (destinationTokenAccountSigner) {
|
|
1147
|
+
tx.partialSign(destinationTokenAccountSigner);
|
|
1148
|
+
}
|
|
1149
|
+
let signature;
|
|
1150
|
+
if (publicKey && sendTransaction) {
|
|
1151
|
+
signature = yield sendTransaction(tx, sendConnection);
|
|
1152
|
+
} else if (phantom) {
|
|
1153
|
+
const res = yield phantom.signAndSendTransaction(tx);
|
|
1154
|
+
signature = res.signature;
|
|
1155
|
+
} else {
|
|
1156
|
+
throw new Error("No Solana signer available");
|
|
1157
|
+
}
|
|
1158
|
+
return { txId: signature };
|
|
1159
|
+
}),
|
|
1160
|
+
[publicKey, rpcEndpoint, sendTransaction, writeContractAsync]
|
|
1161
|
+
);
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
// src/deposit/use-wallet-transaction-status.ts
|
|
1165
|
+
var import_react5 = require("react");
|
|
1166
|
+
var import_react_query2 = require("@tanstack/react-query");
|
|
1167
|
+
var import_viem3 = require("viem");
|
|
1168
|
+
var import_web33 = require("@solana/web3.js");
|
|
1169
|
+
var import_wagmi3 = require("wagmi");
|
|
1170
|
+
function useWalletTransactionStatus({
|
|
1171
|
+
chainId,
|
|
1172
|
+
txId
|
|
1173
|
+
}) {
|
|
1174
|
+
var _a;
|
|
1175
|
+
const { solanaRpcUrl } = useAggUiConfig();
|
|
1176
|
+
const rpcEndpoint = solanaRpcUrl != null ? solanaRpcUrl : DEFAULT_SOLANA_RPC_ENDPOINT;
|
|
1177
|
+
const isSvm = chainId !== void 0 && SVM_CHAIN_IDS.has(chainId);
|
|
1178
|
+
const evmHash = !isSvm && txId ? txId : void 0;
|
|
1179
|
+
const evmReceipt = (0, import_wagmi3.useWaitForTransactionReceipt)({
|
|
1180
|
+
chainId,
|
|
1181
|
+
hash: evmHash,
|
|
1182
|
+
query: {
|
|
1183
|
+
enabled: !!evmHash && !!chainId,
|
|
1184
|
+
refetchInterval: 2e3
|
|
1185
|
+
}
|
|
1186
|
+
});
|
|
1187
|
+
const connection = (0, import_react5.useMemo)(() => new import_web33.Connection(rpcEndpoint, "confirmed"), [rpcEndpoint]);
|
|
1188
|
+
const svmQuery = (0, import_react_query2.useQuery)({
|
|
1189
|
+
queryKey: ["wallet-transaction-status", chainId != null ? chainId : null, txId != null ? txId : null],
|
|
1190
|
+
enabled: isSvm && !!txId,
|
|
1191
|
+
refetchInterval: (query) => query.state.data === "settled" || query.state.data === "error" ? false : 2e3,
|
|
1192
|
+
queryFn: () => __async(null, null, function* () {
|
|
1193
|
+
if (!txId) return "submitted";
|
|
1194
|
+
const [status] = (yield connection.getSignatureStatuses([txId], { searchTransactionHistory: true })).value;
|
|
1195
|
+
if (!status) return "submitted";
|
|
1196
|
+
if (status.err) return "error";
|
|
1197
|
+
if (status.confirmationStatus === "confirmed" || status.confirmationStatus === "finalized") {
|
|
1198
|
+
return "settled";
|
|
1199
|
+
}
|
|
1200
|
+
return "confirming";
|
|
1201
|
+
})
|
|
1202
|
+
});
|
|
1203
|
+
if (isSvm) {
|
|
1204
|
+
return { status: txId ? (_a = svmQuery.data) != null ? _a : "submitted" : null, gasFee: "" };
|
|
1205
|
+
}
|
|
1206
|
+
if (!txId) {
|
|
1207
|
+
return { status: null, gasFee: "" };
|
|
1208
|
+
}
|
|
1209
|
+
if (evmReceipt.isError) {
|
|
1210
|
+
return { status: "error", gasFee: "" };
|
|
1211
|
+
}
|
|
1212
|
+
if (!evmReceipt.data) {
|
|
1213
|
+
return { status: evmReceipt.isPending ? "confirming" : "submitted", gasFee: "" };
|
|
1214
|
+
}
|
|
1215
|
+
const effectiveGasPrice = evmReceipt.data.effectiveGasPrice;
|
|
1216
|
+
const gasFeeWei = effectiveGasPrice * evmReceipt.data.gasUsed;
|
|
1217
|
+
const gasFeeEth = Number((0, import_viem3.formatEther)(gasFeeWei));
|
|
1218
|
+
const gasFee = gasFeeEth > 0 ? `${gasFeeEth.toFixed(6)} ETH` : "";
|
|
1219
|
+
return { status: "settled", gasFee };
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
// src/deposit/use-deposit-flow.ts
|
|
1223
|
+
var import_react7 = require("react");
|
|
1224
|
+
var import_wagmi4 = require("wagmi");
|
|
1225
|
+
var import_wallet_adapter_react3 = require("@solana/wallet-adapter-react");
|
|
1226
|
+
|
|
1227
|
+
// src/execution/use-deposit-addresses.ts
|
|
1228
|
+
var import_react6 = require("react");
|
|
1229
|
+
var import_react_query3 = require("@tanstack/react-query");
|
|
1230
|
+
var SVM_CHAIN_IDS2 = /* @__PURE__ */ new Set([792703809]);
|
|
1231
|
+
function getDepositAddress(chainId, data) {
|
|
1232
|
+
return chainId !== void 0 && SVM_CHAIN_IDS2.has(chainId) ? data.svmAddress : data.evmAddress;
|
|
1233
|
+
}
|
|
1234
|
+
function useDepositAddresses(options) {
|
|
1235
|
+
var _a;
|
|
1236
|
+
const client = useAggClient();
|
|
1237
|
+
const {
|
|
1238
|
+
enabled = true,
|
|
1239
|
+
poll = true,
|
|
1240
|
+
refetchIntervalMs = 5e3,
|
|
1241
|
+
timeoutMs = 6e4
|
|
1242
|
+
} = options != null ? options : {};
|
|
1243
|
+
const [isTimedOut, setIsTimedOut] = (0, import_react6.useState)(false);
|
|
1244
|
+
const timeoutRef = (0, import_react6.useRef)(null);
|
|
1245
|
+
(0, import_react6.useEffect)(() => {
|
|
1246
|
+
if (!enabled || !poll) return void 0;
|
|
1247
|
+
setIsTimedOut(false);
|
|
1248
|
+
timeoutRef.current = setTimeout(() => setIsTimedOut(true), timeoutMs);
|
|
1249
|
+
return () => {
|
|
1250
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
1251
|
+
};
|
|
1252
|
+
}, [enabled, poll, timeoutMs]);
|
|
1253
|
+
const query = (0, import_react_query3.useQuery)({
|
|
1254
|
+
queryKey: executionKeys.depositAddresses(),
|
|
1255
|
+
queryFn: () => client.getDepositAddresses(),
|
|
1256
|
+
enabled,
|
|
1257
|
+
staleTime: 6e4,
|
|
1258
|
+
gcTime: 5 * 6e4,
|
|
1259
|
+
retry: 1,
|
|
1260
|
+
refetchInterval: (q) => {
|
|
1261
|
+
if (!poll || isTimedOut) return false;
|
|
1262
|
+
const data = q.state.data;
|
|
1263
|
+
if ((data == null ? void 0 : data.ready) === true) return false;
|
|
1264
|
+
return refetchIntervalMs;
|
|
1265
|
+
}
|
|
1266
|
+
});
|
|
1267
|
+
const isReady = ((_a = query.data) == null ? void 0 : _a.ready) === true;
|
|
1268
|
+
const readyData = isReady ? query.data : void 0;
|
|
1269
|
+
const evmAddress = (0, import_react6.useMemo)(() => readyData == null ? void 0 : readyData.evmAddress, [readyData]);
|
|
1270
|
+
const svmAddress = (0, import_react6.useMemo)(() => readyData == null ? void 0 : readyData.svmAddress, [readyData]);
|
|
1271
|
+
const supportedChains = (0, import_react6.useMemo)(() => readyData == null ? void 0 : readyData.supportedChains, [readyData]);
|
|
1272
|
+
return __spreadProps(__spreadValues({}, query), {
|
|
1273
|
+
isReady,
|
|
1274
|
+
isTimedOut,
|
|
1275
|
+
evmAddress,
|
|
1276
|
+
svmAddress,
|
|
1277
|
+
supportedChains,
|
|
1278
|
+
depositAddresses: query.data,
|
|
1279
|
+
/** Resolve the correct address (EVM or SVM) for a given chainId. */
|
|
1280
|
+
getAddress: (chainId) => readyData ? getDepositAddress(chainId, readyData) : void 0
|
|
1281
|
+
});
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
// src/execution/use-sync-balances.ts
|
|
1285
|
+
var import_react_query4 = require("@tanstack/react-query");
|
|
1286
|
+
function useSyncBalances(options) {
|
|
1287
|
+
const client = useAggClient();
|
|
1288
|
+
const queryClient = (0, import_react_query4.useQueryClient)();
|
|
1289
|
+
return (0, import_react_query4.useMutation)({
|
|
1290
|
+
mutationFn: () => client.syncManagedBalances(),
|
|
1291
|
+
onSuccess: () => {
|
|
1292
|
+
var _a;
|
|
1293
|
+
invalidateBalanceQueries(queryClient);
|
|
1294
|
+
(_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options);
|
|
1295
|
+
},
|
|
1296
|
+
onError: options == null ? void 0 : options.onError
|
|
1297
|
+
});
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
// src/use-ramp-quotes.ts
|
|
1301
|
+
var import_react_query5 = require("@tanstack/react-query");
|
|
1302
|
+
function useRampQuotes() {
|
|
1303
|
+
const client = useAggClient();
|
|
1304
|
+
return (0, import_react_query5.useMutation)({
|
|
1305
|
+
mutationFn: (params) => __async(null, null, function* () {
|
|
1306
|
+
return client.getRampQuotes(params);
|
|
1307
|
+
})
|
|
1308
|
+
});
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
// src/use-ramp-session.ts
|
|
1312
|
+
var import_react_query6 = require("@tanstack/react-query");
|
|
1313
|
+
function useRampSession() {
|
|
1314
|
+
const client = useAggClient();
|
|
1315
|
+
return (0, import_react_query6.useMutation)({
|
|
1316
|
+
mutationFn: (params) => __async(null, null, function* () {
|
|
1317
|
+
return client.createRampSession(params);
|
|
1318
|
+
})
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
// src/deposit/use-deposit-flow.ts
|
|
1323
|
+
function useDepositFlow(options) {
|
|
1324
|
+
var _a, _b;
|
|
1325
|
+
const { open, onOpenChange } = options;
|
|
1326
|
+
const { user } = useAggAuthState();
|
|
1327
|
+
const { walletActions } = useAggUiConfig();
|
|
1328
|
+
const { totalBalance } = useAggBalanceState();
|
|
1329
|
+
const deposit = useDepositAddresses({ enabled: !!user });
|
|
1330
|
+
const { supportedChains } = deposit;
|
|
1331
|
+
const { mutate: syncBalancesMutate } = useSyncBalances();
|
|
1332
|
+
const defaultSendToken = useWalletSendToken();
|
|
1333
|
+
const sendToken = (_a = walletActions == null ? void 0 : walletActions.sendToken) != null ? _a : defaultSendToken;
|
|
1334
|
+
const { mutateAsync: getRampQuotes } = useRampQuotes();
|
|
1335
|
+
const { mutateAsync: createRampSession } = useRampSession();
|
|
1336
|
+
const [depositAmount, setDepositAmount] = (0, import_react7.useState)("");
|
|
1337
|
+
const [cardAmount, setCardAmount] = (0, import_react7.useState)("");
|
|
1338
|
+
const [cardNetwork, setCardNetwork] = (0, import_react7.useState)("solana");
|
|
1339
|
+
const [walletModalChainId, setWalletModalChainId] = (0, import_react7.useState)(null);
|
|
1340
|
+
const [walletModalTokenSymbol, setWalletModalTokenSymbol] = (0, import_react7.useState)(null);
|
|
1341
|
+
const [walletTransaction, setWalletTransaction] = (0, import_react7.useState)(null);
|
|
1342
|
+
const [walletTransactionError, setWalletTransactionError] = (0, import_react7.useState)(null);
|
|
1343
|
+
const [walletTransactionErrorTone, setWalletTransactionErrorTone] = (0, import_react7.useState)(
|
|
1344
|
+
"error"
|
|
1345
|
+
);
|
|
1346
|
+
const [pendingCardPurchaseSummary, setPendingCardPurchaseSummary] = (0, import_react7.useState)(null);
|
|
1347
|
+
const rampRedirectHandled = (0, import_react7.useRef)(false);
|
|
1348
|
+
(0, import_react7.useEffect)(() => {
|
|
1349
|
+
var _a2, _b2;
|
|
1350
|
+
if (rampRedirectHandled.current) return;
|
|
1351
|
+
if (typeof window === "undefined") return;
|
|
1352
|
+
const url = new URL(window.location.href);
|
|
1353
|
+
const cryptoAmount = url.searchParams.get("cryptoAmount");
|
|
1354
|
+
const cryptoCurrency = url.searchParams.get("cryptoCurrency");
|
|
1355
|
+
if (!cryptoAmount) return;
|
|
1356
|
+
rampRedirectHandled.current = true;
|
|
1357
|
+
const network = (_a2 = url.searchParams.get("network")) != null ? _a2 : "";
|
|
1358
|
+
const totalFee = (_b2 = url.searchParams.get("totalFeeInFiat")) != null ? _b2 : "";
|
|
1359
|
+
setPendingCardPurchaseSummary({
|
|
1360
|
+
amountReceived: `+${cryptoAmount} ${cryptoCurrency != null ? cryptoCurrency : "USDC"}`,
|
|
1361
|
+
network: network.charAt(0).toUpperCase() + network.slice(1),
|
|
1362
|
+
fees: totalFee ? `$${totalFee}` : ""
|
|
1363
|
+
});
|
|
1364
|
+
onOpenChange(true);
|
|
1365
|
+
}, []);
|
|
1366
|
+
const { chainId: connectedChainId, address: connectedAddress } = (0, import_wagmi4.useAccount)();
|
|
1367
|
+
const { switchChainAsync } = (0, import_wagmi4.useSwitchChain)();
|
|
1368
|
+
const { publicKey: solanaPublicKey } = (0, import_wallet_adapter_react3.useWallet)();
|
|
1369
|
+
const balanceChainId = walletModalChainId ? Number(walletModalChainId) : connectedChainId;
|
|
1370
|
+
const selectedChainTokens = (0, import_react7.useMemo)(() => {
|
|
1371
|
+
var _a2;
|
|
1372
|
+
if (!supportedChains || !balanceChainId) return [];
|
|
1373
|
+
const chain = supportedChains.find((c) => c.chainId === balanceChainId);
|
|
1374
|
+
return (_a2 = chain == null ? void 0 : chain.tokens) != null ? _a2 : [];
|
|
1375
|
+
}, [supportedChains, balanceChainId]);
|
|
1376
|
+
const selectedTokenMeta = (0, import_react7.useMemo)(() => {
|
|
1377
|
+
if (!walletModalTokenSymbol) return void 0;
|
|
1378
|
+
const match = selectedChainTokens.find((t) => t.symbol === walletModalTokenSymbol);
|
|
1379
|
+
return match ? { address: match.address, decimals: match.decimals } : void 0;
|
|
1380
|
+
}, [selectedChainTokens, walletModalTokenSymbol]);
|
|
1381
|
+
const authSvmAddress = (0, import_react7.useMemo)(() => {
|
|
1382
|
+
var _a2;
|
|
1383
|
+
const wallets = user == null ? void 0 : user.wallets;
|
|
1384
|
+
return (_a2 = wallets == null ? void 0 : wallets.find((w) => w.chain === "solana" || w.chain === "svm")) == null ? void 0 : _a2.address;
|
|
1385
|
+
}, [user]);
|
|
1386
|
+
const isSvmBalanceChain = balanceChainId !== void 0 && SVM_CHAIN_IDS.has(balanceChainId);
|
|
1387
|
+
const walletAddress = (0, import_react7.useMemo)(() => {
|
|
1388
|
+
var _a2, _b2, _c;
|
|
1389
|
+
if (isSvmBalanceChain) {
|
|
1390
|
+
return (_b2 = (_a2 = solanaPublicKey == null ? void 0 : solanaPublicKey.toBase58()) != null ? _a2 : authSvmAddress) != null ? _b2 : "";
|
|
1391
|
+
}
|
|
1392
|
+
return (_c = connectedAddress != null ? connectedAddress : getWalletAddressFromUserProfile(user)) != null ? _c : "";
|
|
1393
|
+
}, [authSvmAddress, connectedAddress, isSvmBalanceChain, solanaPublicKey, user]);
|
|
1394
|
+
const walletLabel = (0, import_react7.useMemo)(() => {
|
|
1395
|
+
return walletAddress ? `${walletAddress.slice(0, 6)}...${walletAddress.slice(-4)}` : "\u2014";
|
|
1396
|
+
}, [walletAddress]);
|
|
1397
|
+
const { balance: walletBalance, isLoading: isWalletBalanceLoading } = useWalletTokenBalance({
|
|
1398
|
+
isOpen: open,
|
|
1399
|
+
chainId: balanceChainId,
|
|
1400
|
+
tokenAddress: selectedTokenMeta == null ? void 0 : selectedTokenMeta.address,
|
|
1401
|
+
decimals: selectedTokenMeta == null ? void 0 : selectedTokenMeta.decimals,
|
|
1402
|
+
svmAddress: authSvmAddress
|
|
1403
|
+
});
|
|
1404
|
+
const { status: observedWalletTransactionStatus, gasFee: walletTransactionGasFee } = useWalletTransactionStatus({
|
|
1405
|
+
chainId: walletTransaction == null ? void 0 : walletTransaction.chainId,
|
|
1406
|
+
txId: (_b = walletTransaction == null ? void 0 : walletTransaction.txId) != null ? _b : null
|
|
1407
|
+
});
|
|
1408
|
+
const walletTransactionStatus = walletTransactionError ? "error" : walletTransaction ? observedWalletTransactionStatus != null ? observedWalletTransactionStatus : "submitted" : void 0;
|
|
1409
|
+
const syncedDepositTxIdRef = (0, import_react7.useRef)(null);
|
|
1410
|
+
(0, import_react7.useEffect)(() => {
|
|
1411
|
+
if (walletTransactionStatus !== "settled" || !(walletTransaction == null ? void 0 : walletTransaction.txId)) return;
|
|
1412
|
+
if (syncedDepositTxIdRef.current === walletTransaction.txId) return;
|
|
1413
|
+
syncedDepositTxIdRef.current = walletTransaction.txId;
|
|
1414
|
+
syncBalancesMutate();
|
|
1415
|
+
}, [syncBalancesMutate, walletTransaction == null ? void 0 : walletTransaction.txId, walletTransactionStatus]);
|
|
1416
|
+
const handleDepositModalOpenChange = (0, import_react7.useCallback)(
|
|
1417
|
+
(isOpen) => {
|
|
1418
|
+
if (!isOpen) {
|
|
1419
|
+
setDepositAmount("");
|
|
1420
|
+
setCardAmount("");
|
|
1421
|
+
setCardNetwork("solana");
|
|
1422
|
+
setWalletModalChainId(null);
|
|
1423
|
+
setWalletModalTokenSymbol(null);
|
|
1424
|
+
setWalletTransaction(null);
|
|
1425
|
+
setWalletTransactionError(null);
|
|
1426
|
+
setWalletTransactionErrorTone("error");
|
|
1427
|
+
setPendingCardPurchaseSummary(null);
|
|
1428
|
+
syncedDepositTxIdRef.current = null;
|
|
1429
|
+
}
|
|
1430
|
+
onOpenChange(isOpen);
|
|
1431
|
+
},
|
|
1432
|
+
[onOpenChange]
|
|
1433
|
+
);
|
|
1434
|
+
const handleConfirmWalletDeposit = (0, import_react7.useCallback)(
|
|
1435
|
+
(params) => __async(null, null, function* () {
|
|
1436
|
+
var _a2, _b2, _c;
|
|
1437
|
+
const { address, amount, chainId, token } = params;
|
|
1438
|
+
const chain = (_a2 = supportedChains == null ? void 0 : supportedChains.find((c) => c.chainId === chainId)) != null ? _a2 : null;
|
|
1439
|
+
const tokenMeta = (_b2 = chain == null ? void 0 : chain.tokens.find((t) => t.symbol === token)) != null ? _b2 : null;
|
|
1440
|
+
try {
|
|
1441
|
+
setWalletTransactionError(null);
|
|
1442
|
+
setWalletTransactionErrorTone("error");
|
|
1443
|
+
const isEvmTarget = !SVM_CHAIN_IDS.has(chainId);
|
|
1444
|
+
if (isEvmTarget && connectedChainId && connectedChainId !== chainId) {
|
|
1445
|
+
yield switchChainAsync({ chainId });
|
|
1446
|
+
}
|
|
1447
|
+
const { txId } = yield sendToken({
|
|
1448
|
+
chainId,
|
|
1449
|
+
token: {
|
|
1450
|
+
symbol: token,
|
|
1451
|
+
address: tokenMeta == null ? void 0 : tokenMeta.address,
|
|
1452
|
+
decimals: (_c = tokenMeta == null ? void 0 : tokenMeta.decimals) != null ? _c : 6
|
|
1453
|
+
},
|
|
1454
|
+
to: address,
|
|
1455
|
+
amount
|
|
1456
|
+
});
|
|
1457
|
+
setWalletTransaction({ chainId, txId });
|
|
1458
|
+
} catch (err) {
|
|
1459
|
+
setWalletTransaction(null);
|
|
1460
|
+
const normalizedError = normalizeWalletError(err, supportedChains);
|
|
1461
|
+
setWalletTransactionError(normalizedError.message);
|
|
1462
|
+
setWalletTransactionErrorTone(normalizedError.tone);
|
|
1463
|
+
throw err;
|
|
1464
|
+
}
|
|
1465
|
+
}),
|
|
1466
|
+
[connectedChainId, sendToken, supportedChains, switchChainAsync]
|
|
1467
|
+
);
|
|
1468
|
+
const handleGetCardQuotes = (0, import_react7.useCallback)(
|
|
1469
|
+
(params) => __async(null, null, function* () {
|
|
1470
|
+
const quotes = yield getRampQuotes(params);
|
|
1471
|
+
return quotes.map(
|
|
1472
|
+
(q, i) => ({
|
|
1473
|
+
id: q.serviceProvider,
|
|
1474
|
+
name: q.serviceProvider,
|
|
1475
|
+
quote: `~ ${q.destinationAmount.toFixed(2)} USDC`,
|
|
1476
|
+
fee: `$${q.totalFee.toFixed(2)}`,
|
|
1477
|
+
badge: i === 0 ? "best" : q.lowKyc ? "low-kyc" : void 0
|
|
1478
|
+
})
|
|
1479
|
+
);
|
|
1480
|
+
}),
|
|
1481
|
+
[getRampQuotes]
|
|
1482
|
+
);
|
|
1483
|
+
const handleCreateCardSession = (0, import_react7.useCallback)(
|
|
1484
|
+
(params) => __async(null, null, function* () {
|
|
1485
|
+
if (!params.walletAddress) {
|
|
1486
|
+
throw new Error("Deposit address not available for the selected network");
|
|
1487
|
+
}
|
|
1488
|
+
const session = yield createRampSession(params);
|
|
1489
|
+
return {
|
|
1490
|
+
id: session.id,
|
|
1491
|
+
widgetUrl: session.widgetUrl,
|
|
1492
|
+
serviceProviderWidgetUrl: session.serviceProviderWidgetUrl
|
|
1493
|
+
};
|
|
1494
|
+
}),
|
|
1495
|
+
[createRampSession]
|
|
1496
|
+
);
|
|
1497
|
+
const cardRedirectUrl = typeof window !== "undefined" ? `${window.location.origin}/profile?tab=activity` : void 0;
|
|
1498
|
+
return {
|
|
1499
|
+
open,
|
|
1500
|
+
onOpenChange: handleDepositModalOpenChange,
|
|
1501
|
+
pendingCardPurchaseSummary,
|
|
1502
|
+
walletFlow: {
|
|
1503
|
+
balance: totalBalance != null ? totalBalance : 0,
|
|
1504
|
+
walletLabel,
|
|
1505
|
+
walletBalance,
|
|
1506
|
+
isWalletBalanceLoading,
|
|
1507
|
+
amount: depositAmount,
|
|
1508
|
+
formErrorMessage: walletTransaction ? void 0 : walletTransactionError != null ? walletTransactionError : void 0,
|
|
1509
|
+
formErrorTone: walletTransactionErrorTone,
|
|
1510
|
+
transactionStatus: walletTransactionStatus,
|
|
1511
|
+
transactionErrorMessage: walletTransactionError != null ? walletTransactionError : void 0,
|
|
1512
|
+
successSummary: {
|
|
1513
|
+
fromWallet: walletLabel,
|
|
1514
|
+
gasFee: walletTransactionGasFee
|
|
1515
|
+
}
|
|
1516
|
+
},
|
|
1517
|
+
onWalletAmountChange: setDepositAmount,
|
|
1518
|
+
onWalletMax: (0, import_react7.useCallback)(() => setDepositAmount(String(walletBalance)), [walletBalance]),
|
|
1519
|
+
onConfirmWalletDeposit: handleConfirmWalletDeposit,
|
|
1520
|
+
onWalletNetworkChange: setWalletModalChainId,
|
|
1521
|
+
onWalletTokenChange: setWalletModalTokenSymbol,
|
|
1522
|
+
initialWalletChainId: connectedChainId ? String(connectedChainId) : void 0,
|
|
1523
|
+
connectedWalletKind: connectedChainId && !solanaPublicKey ? "evm" : solanaPublicKey && !connectedChainId ? "solana" : void 0,
|
|
1524
|
+
sendCryptoConfig: { minDeposit: "$1", feeEstimate: "~$0.01", eta: "~30s" },
|
|
1525
|
+
onDoneSendCrypto: (0, import_react7.useCallback)(
|
|
1526
|
+
() => handleDepositModalOpenChange(false),
|
|
1527
|
+
[handleDepositModalOpenChange]
|
|
1528
|
+
),
|
|
1529
|
+
cardFlow: {
|
|
1530
|
+
amount: cardAmount,
|
|
1531
|
+
currency: "USD",
|
|
1532
|
+
tokenOptions: [{ value: "USDC", label: "USDC" }],
|
|
1533
|
+
selectedToken: "USDC",
|
|
1534
|
+
selectedNetwork: cardNetwork,
|
|
1535
|
+
providers: [],
|
|
1536
|
+
purchaseSummary: { amountReceived: "", network: "", fees: "" },
|
|
1537
|
+
minAmount: 11
|
|
1538
|
+
},
|
|
1539
|
+
onCardAmountChange: setCardAmount,
|
|
1540
|
+
onCardNetworkChange: setCardNetwork,
|
|
1541
|
+
onDoneCardPurchase: (0, import_react7.useCallback)(() => {
|
|
1542
|
+
syncBalancesMutate();
|
|
1543
|
+
if (typeof window !== "undefined") {
|
|
1544
|
+
window.history.replaceState({}, "", window.location.pathname);
|
|
1545
|
+
}
|
|
1546
|
+
}, [syncBalancesMutate]),
|
|
1547
|
+
cardRedirectUrl,
|
|
1548
|
+
onGetCardQuotes: handleGetCardQuotes,
|
|
1549
|
+
onCreateCardSession: handleCreateCardSession
|
|
1550
|
+
};
|
|
1551
|
+
}
|
|
1552
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1553
|
+
0 && (module.exports = {
|
|
1554
|
+
DEFAULT_SOLANA_RPC_ENDPOINT,
|
|
1555
|
+
SVM_CHAIN_IDS,
|
|
1556
|
+
normalizeWalletError,
|
|
1557
|
+
useDepositAddresses,
|
|
1558
|
+
useDepositFlow,
|
|
1559
|
+
useSyncBalances,
|
|
1560
|
+
useWalletSendToken,
|
|
1561
|
+
useWalletTokenBalance,
|
|
1562
|
+
useWalletTransactionStatus
|
|
1563
|
+
});
|