@coinlist-co/react 0.5.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/{chunk-5E3P7AMH.js → chunk-AAER5LOL.js} +3 -1
  2. package/dist/chunk-AAER5LOL.js.map +1 -0
  3. package/dist/chunk-I5YTJ5SL.js +644 -0
  4. package/dist/chunk-I5YTJ5SL.js.map +1 -0
  5. package/dist/{chunk-N3WBC2VS.js → chunk-MKCOK3DF.js} +68 -57
  6. package/dist/chunk-MKCOK3DF.js.map +1 -0
  7. package/dist/chunk-Z2HAA2TI.js +768 -0
  8. package/dist/chunk-Z2HAA2TI.js.map +1 -0
  9. package/dist/client/index.cjs +3360 -556
  10. package/dist/client/index.cjs.map +1 -1
  11. package/dist/client/index.d.cts +921 -18
  12. package/dist/client/index.d.ts +921 -18
  13. package/dist/client/index.js +2275 -392
  14. package/dist/client/index.js.map +1 -1
  15. package/dist/collections-B84Vw55t.d.cts +28 -0
  16. package/dist/collections-BQbFJS3g.d.ts +28 -0
  17. package/dist/requirement-C2w45Q11.d.cts +969 -0
  18. package/dist/requirement-C2w45Q11.d.ts +969 -0
  19. package/dist/server/index.cjs +521 -37
  20. package/dist/server/index.cjs.map +1 -1
  21. package/dist/server/index.d.cts +116 -9
  22. package/dist/server/index.d.ts +116 -9
  23. package/dist/server/index.js +95 -28
  24. package/dist/server/index.js.map +1 -1
  25. package/dist/shared/index.cjs +1264 -42
  26. package/dist/shared/index.cjs.map +1 -1
  27. package/dist/shared/index.d.cts +644 -3
  28. package/dist/shared/index.d.ts +644 -3
  29. package/dist/shared/index.js +220 -5
  30. package/dist/shared/index.js.map +1 -1
  31. package/package.json +33 -30
  32. package/dist/chunk-5E3P7AMH.js.map +0 -1
  33. package/dist/chunk-CRACFEJ4.js +0 -17
  34. package/dist/chunk-CRACFEJ4.js.map +0 -1
  35. package/dist/chunk-N3WBC2VS.js.map +0 -1
  36. package/dist/chunk-V6WO67RO.js +0 -311
  37. package/dist/chunk-V6WO67RO.js.map +0 -1
  38. package/dist/client/styles.css +0 -2
  39. package/dist/requirement-BEO42QOr.d.cts +0 -387
  40. package/dist/requirement-BEO42QOr.d.ts +0 -387
@@ -1,4 +1,5 @@
1
1
  // src/shared/types/oauth-session.ts
2
+ var ClientCredentialsOAuth = (value) => value;
2
3
  var OAuthRefreshToken = (value) => value;
3
4
  var OAuthSession = {
4
5
  fromDto: (dto) => {
@@ -14,7 +15,8 @@ var OAuthSession = {
14
15
  };
15
16
 
16
17
  export {
18
+ ClientCredentialsOAuth,
17
19
  OAuthRefreshToken,
18
20
  OAuthSession
19
21
  };
20
- //# sourceMappingURL=chunk-5E3P7AMH.js.map
22
+ //# sourceMappingURL=chunk-AAER5LOL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/shared/types/oauth-session.ts"],"sourcesContent":["import type { OAuthSessionDto } from '@/shared/types/dto/oauth-session';\nimport type { Newtype } from '@/shared/types/newtype';\n\nexport type ClientCredentialsOAuth = Newtype<\n OAuthAccessToken,\n 'ClientCredentialsOAuth'\n>;\nexport const ClientCredentialsOAuth = (value: OAuthAccessToken) =>\n value as ClientCredentialsOAuth;\n\nexport type OAuthAccessToken = {\n value: string;\n expiresAt: Date;\n};\n\nexport type OAuthRefreshToken = Newtype<string, 'OAuthRefreshToken'>;\nexport const OAuthRefreshToken = (value: string) => value as OAuthRefreshToken;\n\nexport type OAuthSession = {\n accessToken: OAuthAccessToken;\n refreshToken?: OAuthRefreshToken;\n};\n\nexport const OAuthSession = {\n fromDto: (dto: OAuthSessionDto): OAuthSession => {\n const expiresAt = new Date(Date.now() + dto.expires_in * 1000);\n return {\n accessToken: {\n value: dto.access_token,\n expiresAt,\n },\n ...(dto.refresh_token != null && dto.refresh_token !== ''\n ? { refreshToken: OAuthRefreshToken(dto.refresh_token) }\n : undefined),\n };\n },\n};\n"],"mappings":";AAOO,IAAM,yBAAyB,CAAC,UACrC;AAQK,IAAM,oBAAoB,CAAC,UAAkB;AAO7C,IAAM,eAAe;AAAA,EAC1B,SAAS,CAAC,QAAuC;AAC/C,UAAM,YAAY,IAAI,KAAK,KAAK,IAAI,IAAI,IAAI,aAAa,GAAI;AAC7D,WAAO;AAAA,MACL,aAAa;AAAA,QACX,OAAO,IAAI;AAAA,QACX;AAAA,MACF;AAAA,MACA,GAAI,IAAI,iBAAiB,QAAQ,IAAI,kBAAkB,KACnD,EAAE,cAAc,kBAAkB,IAAI,aAAa,EAAE,IACrD;AAAA,IACN;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,644 @@
1
+ import {
2
+ AssetDecimals,
3
+ BlockchainAmount,
4
+ Bps,
5
+ EvmContractAddress,
6
+ MAX_UINT_256,
7
+ StablecoinSymbol,
8
+ arrayBufferToBase64Url,
9
+ assertUint256,
10
+ generateSecureRandomBase64Url,
11
+ sha256
12
+ } from "./chunk-Z2HAA2TI.js";
13
+
14
+ // src/shared/core/blockchain/abis/erc20.ts
15
+ var ERC20_ABI = [
16
+ {
17
+ type: "function",
18
+ name: "allowance",
19
+ inputs: [
20
+ { name: "owner", type: "address" },
21
+ { name: "spender", type: "address" }
22
+ ],
23
+ outputs: [{ name: "", type: "uint256" }],
24
+ stateMutability: "view"
25
+ },
26
+ {
27
+ type: "function",
28
+ name: "approve",
29
+ inputs: [
30
+ { name: "spender", type: "address" },
31
+ { name: "amount", type: "uint256" }
32
+ ],
33
+ outputs: [{ name: "", type: "bool" }],
34
+ stateMutability: "nonpayable"
35
+ },
36
+ {
37
+ type: "function",
38
+ name: "balanceOf",
39
+ inputs: [{ name: "account", type: "address" }],
40
+ outputs: [{ name: "", type: "uint256" }],
41
+ stateMutability: "view"
42
+ },
43
+ {
44
+ type: "function",
45
+ name: "decimals",
46
+ inputs: [],
47
+ outputs: [{ name: "", type: "uint8" }],
48
+ stateMutability: "view"
49
+ },
50
+ {
51
+ type: "function",
52
+ name: "name",
53
+ inputs: [],
54
+ outputs: [{ name: "", type: "string" }],
55
+ stateMutability: "view"
56
+ },
57
+ {
58
+ type: "function",
59
+ name: "symbol",
60
+ inputs: [],
61
+ outputs: [{ name: "", type: "string" }],
62
+ stateMutability: "view"
63
+ },
64
+ {
65
+ type: "function",
66
+ name: "totalSupply",
67
+ inputs: [],
68
+ outputs: [{ name: "", type: "uint256" }],
69
+ stateMutability: "view"
70
+ },
71
+ {
72
+ type: "function",
73
+ name: "transfer",
74
+ inputs: [
75
+ { name: "recipient", type: "address" },
76
+ { name: "amount", type: "uint256" }
77
+ ],
78
+ outputs: [{ name: "", type: "bool" }],
79
+ stateMutability: "nonpayable"
80
+ },
81
+ {
82
+ type: "function",
83
+ name: "transferFrom",
84
+ inputs: [
85
+ { name: "sender", type: "address" },
86
+ { name: "recipient", type: "address" },
87
+ { name: "amount", type: "uint256" }
88
+ ],
89
+ outputs: [{ name: "", type: "bool" }],
90
+ stateMutability: "nonpayable"
91
+ },
92
+ {
93
+ type: "event",
94
+ name: "Approval",
95
+ inputs: [
96
+ { name: "owner", type: "address", indexed: true },
97
+ { name: "spender", type: "address", indexed: true },
98
+ { name: "value", type: "uint256", indexed: false }
99
+ ],
100
+ anonymous: false
101
+ },
102
+ {
103
+ type: "event",
104
+ name: "Transfer",
105
+ inputs: [
106
+ { name: "from", type: "address", indexed: true },
107
+ { name: "to", type: "address", indexed: true },
108
+ { name: "value", type: "uint256", indexed: false }
109
+ ],
110
+ anonymous: false
111
+ }
112
+ ];
113
+
114
+ // src/shared/core/blockchain/abis/superstate-swap.ts
115
+ var SUPERSTATE_SWAP_ABI = [
116
+ {
117
+ type: "function",
118
+ name: "authorized",
119
+ inputs: [{ name: "user", type: "address", internalType: "address" }],
120
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
121
+ stateMutability: "view"
122
+ },
123
+ {
124
+ type: "function",
125
+ name: "stopped",
126
+ inputs: [],
127
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
128
+ stateMutability: "view"
129
+ },
130
+ {
131
+ type: "function",
132
+ name: "SWAP_LEVEL",
133
+ inputs: [],
134
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
135
+ stateMutability: "view"
136
+ },
137
+ {
138
+ type: "function",
139
+ name: "preview",
140
+ inputs: [
141
+ { name: "token", type: "address", internalType: "address" },
142
+ { name: "amount", type: "uint256", internalType: "uint256" }
143
+ ],
144
+ outputs: [
145
+ {
146
+ name: "",
147
+ type: "tuple",
148
+ internalType: "struct Preview",
149
+ components: [
150
+ { name: "input", type: "uint256", internalType: "uint256" },
151
+ { name: "fee", type: "uint256", internalType: "uint256" },
152
+ { name: "output", type: "uint256", internalType: "uint256" }
153
+ ]
154
+ }
155
+ ],
156
+ stateMutability: "view"
157
+ },
158
+ {
159
+ type: "function",
160
+ name: "swap",
161
+ inputs: [
162
+ { name: "token", type: "address", internalType: "address" },
163
+ { name: "amount", type: "uint256", internalType: "uint256" },
164
+ { name: "slip", type: "uint256", internalType: "uint256" }
165
+ ],
166
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
167
+ stateMutability: "nonpayable"
168
+ },
169
+ {
170
+ type: "function",
171
+ name: "tokenBalance",
172
+ inputs: [{ name: "token", type: "address", internalType: "address" }],
173
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
174
+ stateMutability: "view"
175
+ },
176
+ {
177
+ type: "function",
178
+ name: "outputToken",
179
+ inputs: [],
180
+ outputs: [{ name: "", type: "address", internalType: "address" }],
181
+ stateMutability: "view"
182
+ },
183
+ {
184
+ type: "function",
185
+ name: "outputTokenBalance",
186
+ inputs: [],
187
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
188
+ stateMutability: "view"
189
+ },
190
+ {
191
+ type: "function",
192
+ name: "totals",
193
+ inputs: [{ name: "token", type: "address", internalType: "address" }],
194
+ outputs: [
195
+ {
196
+ name: "",
197
+ type: "tuple",
198
+ internalType: "struct SwapTotal",
199
+ components: [
200
+ { name: "inputSum", type: "uint256", internalType: "uint256" },
201
+ { name: "feeSum", type: "uint256", internalType: "uint256" },
202
+ { name: "outputSum", type: "uint256", internalType: "uint256" },
203
+ { name: "count", type: "uint256", internalType: "uint256" }
204
+ ]
205
+ }
206
+ ],
207
+ stateMutability: "view"
208
+ },
209
+ {
210
+ type: "function",
211
+ name: "totals",
212
+ inputs: [
213
+ { name: "user", type: "address", internalType: "address" },
214
+ { name: "token", type: "address", internalType: "address" }
215
+ ],
216
+ outputs: [
217
+ {
218
+ name: "",
219
+ type: "tuple",
220
+ internalType: "struct SwapTotal",
221
+ components: [
222
+ { name: "inputSum", type: "uint256", internalType: "uint256" },
223
+ { name: "feeSum", type: "uint256", internalType: "uint256" },
224
+ { name: "outputSum", type: "uint256", internalType: "uint256" },
225
+ { name: "count", type: "uint256", internalType: "uint256" }
226
+ ]
227
+ }
228
+ ],
229
+ stateMutability: "view"
230
+ },
231
+ {
232
+ type: "function",
233
+ name: "transfer",
234
+ inputs: [
235
+ { name: "to", type: "address", internalType: "address" },
236
+ { name: "amount", type: "uint256", internalType: "uint256" }
237
+ ],
238
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
239
+ stateMutability: "nonpayable"
240
+ },
241
+ {
242
+ type: "function",
243
+ name: "transfer",
244
+ inputs: [
245
+ { name: "to", type: "address", internalType: "address" },
246
+ { name: "token", type: "address", internalType: "address" },
247
+ { name: "amount", type: "uint256", internalType: "uint256" }
248
+ ],
249
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
250
+ stateMutability: "nonpayable"
251
+ },
252
+ {
253
+ type: "function",
254
+ name: "setBps",
255
+ inputs: [{ name: "points", type: "uint256", internalType: "uint256" }],
256
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
257
+ stateMutability: "nonpayable"
258
+ },
259
+ {
260
+ type: "event",
261
+ name: "Swapped",
262
+ inputs: [
263
+ { name: "user", type: "address", indexed: true, internalType: "address" },
264
+ {
265
+ name: "inputToken",
266
+ type: "address",
267
+ indexed: true,
268
+ internalType: "address"
269
+ },
270
+ {
271
+ name: "outputToken",
272
+ type: "address",
273
+ indexed: true,
274
+ internalType: "address"
275
+ },
276
+ {
277
+ name: "inputAmount",
278
+ type: "uint256",
279
+ indexed: false,
280
+ internalType: "uint256"
281
+ },
282
+ {
283
+ name: "outputAmount",
284
+ type: "uint256",
285
+ indexed: false,
286
+ internalType: "uint256"
287
+ }
288
+ ],
289
+ anonymous: false
290
+ },
291
+ {
292
+ type: "event",
293
+ name: "Transferred",
294
+ inputs: [
295
+ { name: "to", type: "address", indexed: true, internalType: "address" },
296
+ {
297
+ name: "token",
298
+ type: "address",
299
+ indexed: true,
300
+ internalType: "address"
301
+ },
302
+ {
303
+ name: "amount",
304
+ type: "uint256",
305
+ indexed: false,
306
+ internalType: "uint256"
307
+ }
308
+ ],
309
+ anonymous: false
310
+ },
311
+ {
312
+ type: "error",
313
+ name: "InvalidAddress",
314
+ inputs: []
315
+ },
316
+ {
317
+ type: "error",
318
+ name: "InsufficientAmount",
319
+ inputs: []
320
+ },
321
+ {
322
+ type: "error",
323
+ name: "InvalidAmount",
324
+ inputs: []
325
+ },
326
+ {
327
+ type: "error",
328
+ name: "SwapFailed",
329
+ inputs: [
330
+ { name: "user", type: "address", internalType: "address" },
331
+ { name: "token", type: "address", internalType: "address" }
332
+ ]
333
+ }
334
+ ];
335
+
336
+ // src/shared/core/blockchain/bps.ts
337
+ var BPS_DENOM = Bps(10000n);
338
+ function applyBps(amount, bps) {
339
+ return assertUint256(amount * bps / BPS_DENOM);
340
+ }
341
+
342
+ // src/shared/core/blockchain/swap/math.ts
343
+ function computePrice({
344
+ inputTokenAmount,
345
+ outputTokenAmount
346
+ }) {
347
+ if (outputTokenAmount.raw === 0n) return null;
348
+ const scale = 10n ** BigInt(outputTokenAmount.decimals);
349
+ const raw = assertUint256(
350
+ inputTokenAmount.raw * scale / outputTokenAmount.raw
351
+ );
352
+ return BlockchainAmount({ raw, decimals: inputTokenAmount.decimals });
353
+ }
354
+ function computeSlip(amount, slippage) {
355
+ const retained = Bps(assertUint256(BPS_DENOM - slippage));
356
+ const slipRaw = applyBps(amount.raw, retained);
357
+ return BlockchainAmount({ raw: slipRaw, decimals: amount.decimals });
358
+ }
359
+
360
+ // src/shared/core/blockchain/swap/status.ts
361
+ function isStopped(status) {
362
+ return (status.stopped & status.swapLevel) !== 0n;
363
+ }
364
+
365
+ // src/shared/core/blockchain/swap/swapped-event.ts
366
+ import { parseEventLogs } from "viem";
367
+ function decodeSwappedOutputAmount(receipt, outputDecimals) {
368
+ try {
369
+ const [swapped] = parseEventLogs({
370
+ abi: SUPERSTATE_SWAP_ABI,
371
+ eventName: "Swapped",
372
+ logs: receipt.logs
373
+ });
374
+ if (!swapped) return null;
375
+ const raw = swapped.args.outputAmount;
376
+ if (raw < 0n || raw > MAX_UINT_256) return null;
377
+ return BlockchainAmount({ raw, decimals: outputDecimals });
378
+ } catch {
379
+ return null;
380
+ }
381
+ }
382
+
383
+ // src/shared/types/oauth.ts
384
+ var AuthorizationCode = (value) => value;
385
+ var CodeVerifier = (value) => value;
386
+ var CodeChallenge = (value) => value;
387
+ var PKCEState = (value) => value;
388
+ var RedirectUri = (value) => value;
389
+ var ClientId = (value) => value;
390
+ var ClientSecret = (value) => value;
391
+
392
+ // src/shared/pkce.ts
393
+ async function generatePKCEParams(config) {
394
+ const state = generateSecureRandomBase64Url(32);
395
+ const codeVerifier = generateSecureRandomBase64Url(32);
396
+ const codeChallengeRaw = await sha256(codeVerifier);
397
+ const codeChallenge = arrayBufferToBase64Url(codeChallengeRaw, false);
398
+ return {
399
+ clientId: config.clientId,
400
+ responseType: "code",
401
+ redirectUri: config.redirectUri,
402
+ codeChallenge: CodeChallenge(codeChallenge),
403
+ codeChallengeMethod: "S256",
404
+ state: PKCEState(state),
405
+ codeVerifier: CodeVerifier(codeVerifier)
406
+ };
407
+ }
408
+
409
+ // src/shared/types/blockchain/ui.ts
410
+ var FormattedAmountUi = (value) => value;
411
+ var FormattedPercentUi = (value) => value;
412
+ var TxExplorerUrl = (value) => value;
413
+ var ShortenedWalletAddress = (value) => value;
414
+ var FormattedAmountAssetUi = (value) => value;
415
+ var AssetIconUrl = (value) => value;
416
+
417
+ // src/shared/core/blockchain/formatters.ts
418
+ import { formatUnits } from "viem";
419
+ function shortenAddress(address) {
420
+ const short = address.length > 10 ? `${address.slice(0, 6)}\u2026${address.slice(-4)}` : address;
421
+ return ShortenedWalletAddress(short);
422
+ }
423
+ function formatAmount(amount, locale, options) {
424
+ const decimal = formatRawAmount(amount);
425
+ let [integerPart, fractionPart = ""] = decimal.split(".");
426
+ const maxFractionDigits = options?.maxFractionDigits;
427
+ const minFractionDigits = maxFractionDigits !== void 0 ? Math.min(maxFractionDigits, amount.decimals) : Math.min(2, amount.decimals);
428
+ if (maxFractionDigits !== void 0 && fractionPart.length > maxFractionDigits) {
429
+ ({ integerPart, fractionPart } = roundFractionHalfUp(
430
+ integerPart,
431
+ fractionPart,
432
+ maxFractionDigits
433
+ ));
434
+ }
435
+ const fraction = minFractionDigits === 0 ? "" : fractionPart.padEnd(minFractionDigits, "0");
436
+ const integerFormatted = BigInt(integerPart).toLocaleString(locale);
437
+ if (minFractionDigits === 0 && fraction === "") {
438
+ return FormattedAmountUi(integerFormatted);
439
+ }
440
+ const decimalSeparator = new Intl.NumberFormat(locale).formatToParts(1.1).find((p) => p.type === "decimal")?.value ?? ".";
441
+ return FormattedAmountUi(`${integerFormatted}${decimalSeparator}${fraction}`);
442
+ }
443
+ function roundFractionHalfUp(integerPart, fractionPart, maxFractionDigits) {
444
+ if (fractionPart.length <= maxFractionDigits) {
445
+ return { integerPart, fractionPart };
446
+ }
447
+ if (maxFractionDigits === 0) {
448
+ const roundUp = fractionPart[0] >= "5";
449
+ const integer = BigInt(integerPart) + (roundUp ? 1n : 0n);
450
+ return { integerPart: integer.toString(), fractionPart: "" };
451
+ }
452
+ const trimmed = fractionPart.slice(0, maxFractionDigits);
453
+ if (fractionPart[maxFractionDigits] < "5") {
454
+ return { integerPart, fractionPart: trimmed };
455
+ }
456
+ const digits = trimmed.split("").map((digit) => Number.parseInt(digit, 10));
457
+ let carry = 1;
458
+ for (let i = digits.length - 1; i >= 0 && carry > 0; i -= 1) {
459
+ const sum = digits[i] + carry;
460
+ if (sum === 10) {
461
+ digits[i] = 0;
462
+ carry = 1;
463
+ } else {
464
+ digits[i] = sum;
465
+ carry = 0;
466
+ }
467
+ }
468
+ return {
469
+ integerPart: carry > 0 ? (BigInt(integerPart) + 1n).toString() : integerPart,
470
+ fractionPart: digits.join("")
471
+ };
472
+ }
473
+ function formatRawAmount(amount) {
474
+ return formatUnits(amount.raw, amount.decimals);
475
+ }
476
+ function formatCompactAmount(amount, locale) {
477
+ const value = Number(formatRawAmount(amount));
478
+ const formatted = new Intl.NumberFormat(locale, {
479
+ notation: "compact",
480
+ maximumFractionDigits: 2
481
+ }).format(value);
482
+ return FormattedAmountUi(formatted);
483
+ }
484
+ function formatBpsAsPercent(bps, locale) {
485
+ const whole = bps / 100n;
486
+ const fraction = bps % 100n;
487
+ const wholeFormatted = whole.toLocaleString(locale);
488
+ const decimalSeparator = new Intl.NumberFormat(locale).formatToParts(1.1).find((p) => p.type === "decimal")?.value ?? ".";
489
+ if (fraction === 0n) {
490
+ return FormattedPercentUi(`${wholeFormatted}%`);
491
+ }
492
+ const fractionFormatted = fraction.toString().padStart(2, "0").replace(/0+$/, "");
493
+ return FormattedPercentUi(
494
+ `${wholeFormatted}${decimalSeparator}${fractionFormatted}%`
495
+ );
496
+ }
497
+ function usdAmount(amount) {
498
+ return FormattedAmountAssetUi(`$${amount}`);
499
+ }
500
+ function assetAmount(amount, symbol) {
501
+ return FormattedAmountAssetUi(`${amount} ${symbol}`);
502
+ }
503
+ var NA_AMOUNT_ASSET_UI = FormattedAmountAssetUi("-");
504
+ var USD_FRACTION_DIGITS = AssetDecimals(2);
505
+ function formattedUsdPrice(amount, locale) {
506
+ if (!amount) return NA_AMOUNT_ASSET_UI;
507
+ return usdAmount(
508
+ formatAmount(amount, locale, { maxFractionDigits: USD_FRACTION_DIGITS })
509
+ );
510
+ }
511
+ function formattedPricePerShare(quote, locale) {
512
+ if (!quote) return NA_AMOUNT_ASSET_UI;
513
+ return formattedUsdPrice(computePrice(quote), locale);
514
+ }
515
+
516
+ // src/shared/core/blockchain/swap/constants.ts
517
+ var SUPERSTATE_TOS_URL = "https://superstate.com/terms";
518
+ var SWAP_POLL_INTERVAL_MS = 15e3;
519
+ var DEFAULT_AMOUNT_TO_COMPUTE_PRICE = 1000000n;
520
+ var SLIPPAGE_OPTIONS_BPS = [25n, 50n, 100n, 200n, 500n].map(
521
+ (n) => Bps(n)
522
+ );
523
+ var DEFAULT_SLIPPAGE_BPS = Bps(50n);
524
+ var SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA = EvmContractAddress("0x84f8e9a6C9Cc12fe911259372EfCa5582C4ae557");
525
+
526
+ // src/shared/core/blockchain/swap/quote.ts
527
+ var SwapQuote = {
528
+ /**
529
+ * Assembles a {@link SwapQuote} from a raw contract {@link SwapPreview}. The
530
+ * input and fee are denominated in the input token; the output in the output
531
+ * token.
532
+ */
533
+ fromPreview: (preview, inputDecimals, outputDecimals) => ({
534
+ inputTokenAmount: BlockchainAmount({
535
+ raw: preview.inputAmount,
536
+ decimals: inputDecimals
537
+ }),
538
+ fee: BlockchainAmount({ raw: preview.fee, decimals: inputDecimals }),
539
+ outputTokenAmount: BlockchainAmount({
540
+ raw: preview.outputAmount,
541
+ decimals: outputDecimals
542
+ })
543
+ })
544
+ };
545
+
546
+ // src/shared/core/blockchain/token-registry.ts
547
+ var USDC_SYMBOL = StablecoinSymbol("USDC");
548
+ var USDC = {
549
+ name: "USD Coin",
550
+ symbol: USDC_SYMBOL,
551
+ decimals: AssetDecimals(6)
552
+ };
553
+ var USDT_SYMBOL = StablecoinSymbol("USDT");
554
+ var USDT = {
555
+ name: "Tether USD",
556
+ symbol: USDT_SYMBOL,
557
+ decimals: AssetDecimals(6)
558
+ };
559
+ var USDC_ADDRESSES = {
560
+ ethereum_mainnet: EvmContractAddress(
561
+ "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
562
+ ),
563
+ ethereum_sepolia: EvmContractAddress(
564
+ "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"
565
+ )
566
+ };
567
+ var USDT_ADDRESSES = {
568
+ ethereum_mainnet: EvmContractAddress(
569
+ "0xdac17f958d2ee523a2206206994597c13d831ec7"
570
+ ),
571
+ ethereum_sepolia: EvmContractAddress(
572
+ "0x7169D38820dfd117C3FA1f22a697dBA58d90BA06"
573
+ )
574
+ };
575
+ var TOKEN_REGISTRY = {
576
+ erc20: (symbol) => {
577
+ switch (symbol) {
578
+ case "USDC":
579
+ return USDC;
580
+ case "USDT":
581
+ return USDT;
582
+ default:
583
+ throw new Error(`Unknown asset symbol: ${symbol}`);
584
+ }
585
+ },
586
+ contractAddress: (symbol, chain) => {
587
+ switch (symbol) {
588
+ case "USDC":
589
+ return USDC_ADDRESSES[chain];
590
+ case "USDT":
591
+ return USDT_ADDRESSES[chain];
592
+ default:
593
+ throw new Error(`Unknown asset symbol: ${symbol}`);
594
+ }
595
+ }
596
+ };
597
+
598
+ export {
599
+ ERC20_ABI,
600
+ SUPERSTATE_SWAP_ABI,
601
+ BPS_DENOM,
602
+ applyBps,
603
+ computePrice,
604
+ computeSlip,
605
+ isStopped,
606
+ decodeSwappedOutputAmount,
607
+ AuthorizationCode,
608
+ CodeVerifier,
609
+ CodeChallenge,
610
+ PKCEState,
611
+ RedirectUri,
612
+ ClientId,
613
+ ClientSecret,
614
+ generatePKCEParams,
615
+ FormattedAmountUi,
616
+ FormattedPercentUi,
617
+ TxExplorerUrl,
618
+ ShortenedWalletAddress,
619
+ FormattedAmountAssetUi,
620
+ AssetIconUrl,
621
+ shortenAddress,
622
+ formatAmount,
623
+ formatRawAmount,
624
+ formatCompactAmount,
625
+ formatBpsAsPercent,
626
+ usdAmount,
627
+ assetAmount,
628
+ NA_AMOUNT_ASSET_UI,
629
+ formattedUsdPrice,
630
+ formattedPricePerShare,
631
+ SUPERSTATE_TOS_URL,
632
+ SWAP_POLL_INTERVAL_MS,
633
+ DEFAULT_AMOUNT_TO_COMPUTE_PRICE,
634
+ SLIPPAGE_OPTIONS_BPS,
635
+ DEFAULT_SLIPPAGE_BPS,
636
+ SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA,
637
+ SwapQuote,
638
+ USDC_SYMBOL,
639
+ USDC,
640
+ USDT_SYMBOL,
641
+ USDT,
642
+ TOKEN_REGISTRY
643
+ };
644
+ //# sourceMappingURL=chunk-I5YTJ5SL.js.map