@coinlist-co/react 0.10.1 → 0.11.1-rc.10770e8
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 +32 -0
- package/dist/chunk-7CTH4KPU.js +2399 -0
- package/dist/chunk-7CTH4KPU.js.map +1 -0
- package/dist/{chunk-AQVCOWOV.js → chunk-LSPZETDH.js} +249 -317
- package/dist/chunk-LSPZETDH.js.map +1 -0
- package/dist/chunk-UZUQALFY.js +279 -0
- package/dist/chunk-UZUQALFY.js.map +1 -0
- package/dist/client/index.cjs +13430 -3308
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +5486 -899
- package/dist/client/index.d.ts +5486 -899
- package/dist/client/index.js +11025 -2388
- package/dist/client/index.js.map +1 -1
- package/dist/collections-BBI_XydI.d.cts +116 -0
- package/dist/collections-BrX9rRWc.d.ts +116 -0
- package/dist/config-CMl1bR3F.d.cts +2959 -0
- package/dist/config-CMl1bR3F.d.ts +2959 -0
- package/dist/server/index.cjs +1768 -511
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +266 -162
- package/dist/server/index.d.ts +266 -162
- package/dist/server/index.js +235 -169
- package/dist/server/index.js.map +1 -1
- package/dist/shared/index.cjs +2423 -926
- package/dist/shared/index.cjs.map +1 -1
- package/dist/shared/index.d.cts +325 -132
- package/dist/shared/index.d.ts +325 -132
- package/dist/shared/index.js +112 -28
- package/package.json +12 -8
- package/dist/chunk-AQVCOWOV.js.map +0 -1
- package/dist/chunk-TBU3EBNM.js +0 -442
- package/dist/chunk-TBU3EBNM.js.map +0 -1
- package/dist/chunk-UOHD7US2.js +0 -855
- package/dist/chunk-UOHD7US2.js.map +0 -1
- package/dist/collections-Bv1Oxzu_.d.ts +0 -28
- package/dist/collections-DDyxbOPZ.d.cts +0 -28
- package/dist/requirement-oVZA1INj.d.cts +0 -1040
- package/dist/requirement-oVZA1INj.d.ts +0 -1040
|
@@ -2,16 +2,57 @@ import {
|
|
|
2
2
|
AssetDecimals,
|
|
3
3
|
BlockchainAmount,
|
|
4
4
|
Bps,
|
|
5
|
+
DecimalString,
|
|
5
6
|
EvmContractAddress,
|
|
7
|
+
InvariantError,
|
|
6
8
|
MAX_UINT_256,
|
|
9
|
+
MathError,
|
|
10
|
+
NA_AMOUNT_ASSET_UI,
|
|
7
11
|
StablecoinSymbol,
|
|
8
12
|
arrayBufferToBase64Url,
|
|
9
13
|
assertUint256,
|
|
14
|
+
fetchOfferDetails,
|
|
15
|
+
fetchOffers,
|
|
16
|
+
fetchOffersPage,
|
|
17
|
+
formattedUsdPrice,
|
|
10
18
|
generateSecureRandomBase64Url,
|
|
19
|
+
internalLogger,
|
|
11
20
|
sha256
|
|
12
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-7CTH4KPU.js";
|
|
22
|
+
|
|
23
|
+
// src/shared/types/oauth.ts
|
|
24
|
+
var AuthorizationCode = (value) => value;
|
|
25
|
+
var CodeVerifier = (value) => value;
|
|
26
|
+
var CodeChallenge = (value) => value;
|
|
27
|
+
var PKCEState = (value) => value;
|
|
28
|
+
var RedirectUri = (value) => value;
|
|
29
|
+
var ClientId = (value) => value;
|
|
30
|
+
var ClientSecret = (value) => value;
|
|
31
|
+
|
|
32
|
+
// src/shared/core/auth/pkce.ts
|
|
33
|
+
async function generatePKCEParams(config) {
|
|
34
|
+
const state = generateSecureRandomBase64Url(32);
|
|
35
|
+
const codeVerifier = generateSecureRandomBase64Url(32);
|
|
36
|
+
const codeChallengeRaw = await sha256(codeVerifier);
|
|
37
|
+
const codeChallenge = arrayBufferToBase64Url(codeChallengeRaw, false);
|
|
38
|
+
return {
|
|
39
|
+
clientId: config.clientId,
|
|
40
|
+
responseType: "code",
|
|
41
|
+
redirectUri: config.redirectUri,
|
|
42
|
+
codeChallenge: CodeChallenge(codeChallenge),
|
|
43
|
+
codeChallengeMethod: "S256",
|
|
44
|
+
state: PKCEState(state),
|
|
45
|
+
codeVerifier: CodeVerifier(codeVerifier)
|
|
46
|
+
};
|
|
47
|
+
}
|
|
13
48
|
|
|
14
|
-
// src/shared/core/blockchain/
|
|
49
|
+
// src/shared/core/blockchain/bps.ts
|
|
50
|
+
var BPS_DENOM = Bps(10000n);
|
|
51
|
+
function applyBps(amount, bps) {
|
|
52
|
+
return assertUint256(amount * bps / BPS_DENOM);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// src/shared/core/blockchain/erc20/abi.ts
|
|
15
56
|
var ERC20_ABI = [
|
|
16
57
|
{
|
|
17
58
|
type: "function",
|
|
@@ -111,7 +152,128 @@ var ERC20_ABI = [
|
|
|
111
152
|
}
|
|
112
153
|
];
|
|
113
154
|
|
|
114
|
-
// src/shared/core/blockchain/
|
|
155
|
+
// src/shared/core/blockchain/token-registry.ts
|
|
156
|
+
var USDC_SYMBOL = StablecoinSymbol("USDC");
|
|
157
|
+
var USDC = {
|
|
158
|
+
name: "USD Coin",
|
|
159
|
+
symbol: USDC_SYMBOL,
|
|
160
|
+
decimals: AssetDecimals(6)
|
|
161
|
+
};
|
|
162
|
+
var USDT_SYMBOL = StablecoinSymbol("USDT");
|
|
163
|
+
var USDT = {
|
|
164
|
+
name: "Tether USD",
|
|
165
|
+
symbol: USDT_SYMBOL,
|
|
166
|
+
decimals: AssetDecimals(6)
|
|
167
|
+
};
|
|
168
|
+
var USDC_ADDRESSES = {
|
|
169
|
+
ethereum_mainnet: EvmContractAddress(
|
|
170
|
+
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
|
|
171
|
+
),
|
|
172
|
+
ethereum_sepolia: EvmContractAddress(
|
|
173
|
+
"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"
|
|
174
|
+
),
|
|
175
|
+
base_mainnet: EvmContractAddress(
|
|
176
|
+
"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
|
|
177
|
+
),
|
|
178
|
+
base_sepolia: EvmContractAddress(
|
|
179
|
+
"0x036CbD53842c5426634e7929541eC2318f3dCF7e"
|
|
180
|
+
)
|
|
181
|
+
};
|
|
182
|
+
var USDT_ADDRESSES = {
|
|
183
|
+
ethereum_mainnet: EvmContractAddress(
|
|
184
|
+
"0xdac17f958d2ee523a2206206994597c13d831ec7"
|
|
185
|
+
),
|
|
186
|
+
ethereum_sepolia: EvmContractAddress(
|
|
187
|
+
"0x7169D38820dfd117C3FA1f22a697dBA58d90BA06"
|
|
188
|
+
),
|
|
189
|
+
base_mainnet: EvmContractAddress(
|
|
190
|
+
"0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2"
|
|
191
|
+
),
|
|
192
|
+
base_sepolia: null
|
|
193
|
+
};
|
|
194
|
+
var TOKEN_REGISTRY = {
|
|
195
|
+
erc20: (symbol) => {
|
|
196
|
+
switch (symbol) {
|
|
197
|
+
case "USDC":
|
|
198
|
+
return USDC;
|
|
199
|
+
case "USDT":
|
|
200
|
+
return USDT;
|
|
201
|
+
default:
|
|
202
|
+
throw new InvariantError(`Unknown asset symbol: ${symbol}`);
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
/**
|
|
206
|
+
* USDC's contract on `chain`. USDC is deployed on every chain the SDK
|
|
207
|
+
* models, so the table is total and the answer is never `null`.
|
|
208
|
+
*/
|
|
209
|
+
usdcAddress: (chain) => USDC_ADDRESSES[chain],
|
|
210
|
+
/**
|
|
211
|
+
* USDT's contract on `chain`, or `null` where Tether publishes none —
|
|
212
|
+
* Base Sepolia today. The honest answer, never a fake address a balance
|
|
213
|
+
* read would call.
|
|
214
|
+
*/
|
|
215
|
+
usdtAddress: (chain) => USDT_ADDRESSES[chain]
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
// src/shared/core/checkout/ondo/constants.ts
|
|
219
|
+
var ONDO_SWAP_CONTRACT_ADDRESSES = {
|
|
220
|
+
ethereum_sepolia: EvmContractAddress(
|
|
221
|
+
"0x7014019ed51Edab984a71D30F2707D2dB2316A7A"
|
|
222
|
+
)
|
|
223
|
+
};
|
|
224
|
+
function ondoSwapContractAddress(chain) {
|
|
225
|
+
return ONDO_SWAP_CONTRACT_ADDRESSES[chain] ?? null;
|
|
226
|
+
}
|
|
227
|
+
var ONDO_POLL_INTERVAL_MS = 15e3;
|
|
228
|
+
var ONDO_QUOTE_EXPIRY_THRESHOLD_MS = 5e3;
|
|
229
|
+
var DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE = DecimalString("1000");
|
|
230
|
+
var ONDO_SETTLEMENT_ASSET = USDC_SYMBOL;
|
|
231
|
+
var DEFAULT_ONDO_SELL_TOKENS_TO_COMPUTE_PRICE = 1;
|
|
232
|
+
var ONDO_SUPPORTED_INPUT_ASSETS = [
|
|
233
|
+
USDC_SYMBOL
|
|
234
|
+
];
|
|
235
|
+
|
|
236
|
+
// src/shared/core/checkout/ondo/math.ts
|
|
237
|
+
function computeOndoBuyPrice(transaction) {
|
|
238
|
+
const { notionalValue, receiveOutputAmount } = transaction;
|
|
239
|
+
return pricePerShare({
|
|
240
|
+
usd: notionalValue,
|
|
241
|
+
shares: receiveOutputAmount
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
function computeOndoSellPrice(transaction) {
|
|
245
|
+
const { expected, spendInputAmount } = transaction;
|
|
246
|
+
return pricePerShare({
|
|
247
|
+
usd: grossProceeds(expected),
|
|
248
|
+
shares: spendInputAmount
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
function grossProceeds(expected) {
|
|
252
|
+
const raw = expected.quantity.raw + expected.fee.raw;
|
|
253
|
+
if (raw > MAX_UINT_256) {
|
|
254
|
+
throw new MathError(`Ondo sell proceeds: out of uint256 bounds (${raw})`);
|
|
255
|
+
}
|
|
256
|
+
return BlockchainAmount.add(expected.quantity, expected.fee);
|
|
257
|
+
}
|
|
258
|
+
function pricePerShare({
|
|
259
|
+
usd,
|
|
260
|
+
shares
|
|
261
|
+
}) {
|
|
262
|
+
const price = BlockchainAmount.div(usd, shares);
|
|
263
|
+
return BlockchainAmount({
|
|
264
|
+
raw: assertPriceFits(price.raw),
|
|
265
|
+
decimals: price.decimals
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
function assertPriceFits(raw) {
|
|
269
|
+
try {
|
|
270
|
+
return assertUint256(raw);
|
|
271
|
+
} catch {
|
|
272
|
+
throw new MathError(`Ondo price: out of uint256 bounds (${raw})`);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// src/shared/core/checkout/superstate/blockchain/abi.ts
|
|
115
277
|
var SUPERSTATE_SWAP_ABI = [
|
|
116
278
|
{
|
|
117
279
|
type: "function",
|
|
@@ -333,65 +495,7 @@ var SUPERSTATE_SWAP_ABI = [
|
|
|
333
495
|
}
|
|
334
496
|
];
|
|
335
497
|
|
|
336
|
-
// src/shared/core/blockchain/
|
|
337
|
-
var BPS_DENOM = Bps(10000n);
|
|
338
|
-
function applyBps(amount, bps) {
|
|
339
|
-
return assertUint256(amount * bps / BPS_DENOM);
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
// src/shared/types/blockchain/ui.ts
|
|
343
|
-
var FormattedAmountUi = (value) => value;
|
|
344
|
-
var FormattedPercentUi = (value) => value;
|
|
345
|
-
var TxExplorerUrl = (value) => value;
|
|
346
|
-
var ShortenedWalletAddress = (value) => value;
|
|
347
|
-
var FormattedAmountAssetUi = (value) => value;
|
|
348
|
-
var AssetIconUrl = (value) => value;
|
|
349
|
-
|
|
350
|
-
// src/shared/core/blockchain/chain.ts
|
|
351
|
-
function getChainId(chain) {
|
|
352
|
-
switch (chain) {
|
|
353
|
-
case "ethereum_mainnet":
|
|
354
|
-
return 1;
|
|
355
|
-
case "ethereum_sepolia":
|
|
356
|
-
return 11155111;
|
|
357
|
-
default: {
|
|
358
|
-
const _exhaustive = chain;
|
|
359
|
-
return _exhaustive;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
function getNetworkName(chain) {
|
|
364
|
-
switch (chain) {
|
|
365
|
-
case "ethereum_mainnet":
|
|
366
|
-
return "Ethereum";
|
|
367
|
-
case "ethereum_sepolia":
|
|
368
|
-
return "Ethereum Sepolia";
|
|
369
|
-
default: {
|
|
370
|
-
const _exhaustive = chain;
|
|
371
|
-
return _exhaustive;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
function txExplorerUrl(chain, txHash) {
|
|
376
|
-
return TxExplorerUrl(`${explorerBaseUrl(chain)}/tx/${txHash}`);
|
|
377
|
-
}
|
|
378
|
-
function explorerBaseUrl(chain) {
|
|
379
|
-
switch (chain) {
|
|
380
|
-
case "ethereum_mainnet":
|
|
381
|
-
return "https://etherscan.io";
|
|
382
|
-
case "ethereum_sepolia":
|
|
383
|
-
return "https://sepolia.etherscan.io";
|
|
384
|
-
default: {
|
|
385
|
-
const _exhaustive = chain;
|
|
386
|
-
return _exhaustive;
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
// src/shared/core/blockchain/formatters.ts
|
|
392
|
-
import { formatUnits } from "viem";
|
|
393
|
-
|
|
394
|
-
// src/shared/core/blockchain/swap/math.ts
|
|
498
|
+
// src/shared/core/checkout/superstate/blockchain/math.ts
|
|
395
499
|
function computePrice({
|
|
396
500
|
inputTokenAmount,
|
|
397
501
|
outputTokenAmount
|
|
@@ -409,149 +513,7 @@ function computeSlip(amount, slippage) {
|
|
|
409
513
|
return BlockchainAmount({ raw: slipRaw, decimals: amount.decimals });
|
|
410
514
|
}
|
|
411
515
|
|
|
412
|
-
// src/shared/core/blockchain/
|
|
413
|
-
function shortenAddress(address) {
|
|
414
|
-
const short = address.length > 10 ? `${address.slice(0, 6)}\u2026${address.slice(-4)}` : address;
|
|
415
|
-
return ShortenedWalletAddress(short);
|
|
416
|
-
}
|
|
417
|
-
function formatAmount(amount, locale, options) {
|
|
418
|
-
const decimal = formatRawAmount(amount);
|
|
419
|
-
let [integerPart, fractionPart = ""] = decimal.split(".");
|
|
420
|
-
const maxFractionDigits = options?.maxFractionDigits;
|
|
421
|
-
const minFractionDigits = maxFractionDigits !== void 0 ? Math.min(maxFractionDigits, amount.decimals) : Math.min(2, amount.decimals);
|
|
422
|
-
if (maxFractionDigits !== void 0 && fractionPart.length > maxFractionDigits) {
|
|
423
|
-
({ integerPart, fractionPart } = roundFractionHalfUp(
|
|
424
|
-
integerPart,
|
|
425
|
-
fractionPart,
|
|
426
|
-
maxFractionDigits
|
|
427
|
-
));
|
|
428
|
-
}
|
|
429
|
-
const fraction = minFractionDigits === 0 ? "" : fractionPart.padEnd(minFractionDigits, "0");
|
|
430
|
-
const integerFormatted = BigInt(integerPart).toLocaleString(locale);
|
|
431
|
-
if (minFractionDigits === 0 && fraction === "") {
|
|
432
|
-
return FormattedAmountUi(integerFormatted);
|
|
433
|
-
}
|
|
434
|
-
const decimalSeparator = new Intl.NumberFormat(locale).formatToParts(1.1).find((p) => p.type === "decimal")?.value ?? ".";
|
|
435
|
-
return FormattedAmountUi(`${integerFormatted}${decimalSeparator}${fraction}`);
|
|
436
|
-
}
|
|
437
|
-
function roundFractionHalfUp(integerPart, fractionPart, maxFractionDigits) {
|
|
438
|
-
if (fractionPart.length <= maxFractionDigits) {
|
|
439
|
-
return { integerPart, fractionPart };
|
|
440
|
-
}
|
|
441
|
-
if (maxFractionDigits === 0) {
|
|
442
|
-
const roundUp = fractionPart[0] >= "5";
|
|
443
|
-
const integer = BigInt(integerPart) + (roundUp ? 1n : 0n);
|
|
444
|
-
return { integerPart: integer.toString(), fractionPart: "" };
|
|
445
|
-
}
|
|
446
|
-
const trimmed = fractionPart.slice(0, maxFractionDigits);
|
|
447
|
-
if (fractionPart[maxFractionDigits] < "5") {
|
|
448
|
-
return { integerPart, fractionPart: trimmed };
|
|
449
|
-
}
|
|
450
|
-
const digits = trimmed.split("").map((digit) => Number.parseInt(digit, 10));
|
|
451
|
-
let carry = 1;
|
|
452
|
-
for (let i = digits.length - 1; i >= 0 && carry > 0; i -= 1) {
|
|
453
|
-
const sum = digits[i] + carry;
|
|
454
|
-
if (sum === 10) {
|
|
455
|
-
digits[i] = 0;
|
|
456
|
-
carry = 1;
|
|
457
|
-
} else {
|
|
458
|
-
digits[i] = sum;
|
|
459
|
-
carry = 0;
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
return {
|
|
463
|
-
integerPart: carry > 0 ? (BigInt(integerPart) + 1n).toString() : integerPart,
|
|
464
|
-
fractionPart: digits.join("")
|
|
465
|
-
};
|
|
466
|
-
}
|
|
467
|
-
function formatRawAmount(amount) {
|
|
468
|
-
return formatUnits(amount.raw, amount.decimals);
|
|
469
|
-
}
|
|
470
|
-
function formatCompactAmount(amount, locale) {
|
|
471
|
-
const value = Number(formatRawAmount(amount));
|
|
472
|
-
const formatted = new Intl.NumberFormat(locale, {
|
|
473
|
-
notation: "compact",
|
|
474
|
-
maximumFractionDigits: 2
|
|
475
|
-
}).format(value);
|
|
476
|
-
return FormattedAmountUi(formatted);
|
|
477
|
-
}
|
|
478
|
-
function formatBpsAsPercent(bps, locale) {
|
|
479
|
-
const whole = bps / 100n;
|
|
480
|
-
const fraction = bps % 100n;
|
|
481
|
-
const wholeFormatted = whole.toLocaleString(locale);
|
|
482
|
-
const decimalSeparator = new Intl.NumberFormat(locale).formatToParts(1.1).find((p) => p.type === "decimal")?.value ?? ".";
|
|
483
|
-
if (fraction === 0n) {
|
|
484
|
-
return FormattedPercentUi(`${wholeFormatted}%`);
|
|
485
|
-
}
|
|
486
|
-
const fractionFormatted = fraction.toString().padStart(2, "0").replace(/0+$/, "");
|
|
487
|
-
return FormattedPercentUi(
|
|
488
|
-
`${wholeFormatted}${decimalSeparator}${fractionFormatted}%`
|
|
489
|
-
);
|
|
490
|
-
}
|
|
491
|
-
function usdAmount(amount) {
|
|
492
|
-
return FormattedAmountAssetUi(`$${amount}`);
|
|
493
|
-
}
|
|
494
|
-
function assetAmount(amount, symbol) {
|
|
495
|
-
return FormattedAmountAssetUi(`${amount} ${symbol}`);
|
|
496
|
-
}
|
|
497
|
-
var NA_AMOUNT_ASSET_UI = FormattedAmountAssetUi("-");
|
|
498
|
-
var USD_FRACTION_DIGITS = AssetDecimals(2);
|
|
499
|
-
function formattedUsdPrice(amount, locale) {
|
|
500
|
-
if (!amount) return NA_AMOUNT_ASSET_UI;
|
|
501
|
-
return usdAmount(
|
|
502
|
-
formatAmount(amount, locale, { maxFractionDigits: USD_FRACTION_DIGITS })
|
|
503
|
-
);
|
|
504
|
-
}
|
|
505
|
-
function formattedPricePerShare(quote, locale) {
|
|
506
|
-
if (!quote) return NA_AMOUNT_ASSET_UI;
|
|
507
|
-
return formattedUsdPrice(computePrice(quote), locale);
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
// src/shared/core/blockchain/math.ts
|
|
511
|
-
import { parseUnits } from "viem";
|
|
512
|
-
function parseBlockchainAmount(amount, decimals) {
|
|
513
|
-
const trimmed = amount.trim();
|
|
514
|
-
if (trimmed === "") return { valid: false, reason: { type: "empty" } };
|
|
515
|
-
if (trimmed.startsWith("-")) {
|
|
516
|
-
return { valid: false, reason: { type: "negative" } };
|
|
517
|
-
}
|
|
518
|
-
if (/[eE]/.test(trimmed)) {
|
|
519
|
-
return { valid: false, reason: { type: "invalid-format" } };
|
|
520
|
-
}
|
|
521
|
-
if (!/^\d+(\.\d+)?$/.test(trimmed)) {
|
|
522
|
-
return { valid: false, reason: { type: "invalid-format" } };
|
|
523
|
-
}
|
|
524
|
-
const [, fraction = ""] = trimmed.split(".");
|
|
525
|
-
if (fraction.length > decimals) {
|
|
526
|
-
return {
|
|
527
|
-
valid: false,
|
|
528
|
-
reason: { type: "too-many-decimals", maxDecimals: decimals }
|
|
529
|
-
};
|
|
530
|
-
}
|
|
531
|
-
try {
|
|
532
|
-
return {
|
|
533
|
-
valid: true,
|
|
534
|
-
amount: BlockchainAmount({
|
|
535
|
-
raw: parseUnits(trimmed, decimals),
|
|
536
|
-
decimals
|
|
537
|
-
})
|
|
538
|
-
};
|
|
539
|
-
} catch {
|
|
540
|
-
return { valid: false, reason: { type: "invalid-format" } };
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
// src/shared/core/blockchain/swap/constants.ts
|
|
545
|
-
var SUPERSTATE_TOS_URL = "https://superstate.com/terms";
|
|
546
|
-
var SWAP_POLL_INTERVAL_MS = 15e3;
|
|
547
|
-
var DEFAULT_AMOUNT_TO_COMPUTE_PRICE = 1000000n;
|
|
548
|
-
var SLIPPAGE_OPTIONS_BPS = [25n, 50n, 100n, 200n, 500n].map(
|
|
549
|
-
(n) => Bps(n)
|
|
550
|
-
);
|
|
551
|
-
var DEFAULT_SLIPPAGE_BPS = Bps(50n);
|
|
552
|
-
var SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA = EvmContractAddress("0x84f8e9a6C9Cc12fe911259372EfCa5582C4ae557");
|
|
553
|
-
|
|
554
|
-
// src/shared/core/blockchain/swap/quote.ts
|
|
516
|
+
// src/shared/core/checkout/superstate/blockchain/quote.ts
|
|
555
517
|
var SwapQuote = {
|
|
556
518
|
/**
|
|
557
519
|
* Assembles a {@link SwapQuote} from a raw contract {@link SwapPreview}. The
|
|
@@ -571,12 +533,12 @@ var SwapQuote = {
|
|
|
571
533
|
})
|
|
572
534
|
};
|
|
573
535
|
|
|
574
|
-
// src/shared/core/blockchain/
|
|
536
|
+
// src/shared/core/checkout/superstate/blockchain/status.ts
|
|
575
537
|
function isStopped(status) {
|
|
576
538
|
return (status.stopped & status.swapLevel) !== 0n;
|
|
577
539
|
}
|
|
578
540
|
|
|
579
|
-
// src/shared/core/blockchain/
|
|
541
|
+
// src/shared/core/checkout/superstate/blockchain/swapped-event.ts
|
|
580
542
|
import { parseEventLogs } from "viem";
|
|
581
543
|
function decodeSwappedOutputAmount(receipt, outputDecimals) {
|
|
582
544
|
try {
|
|
@@ -594,83 +556,59 @@ function decodeSwappedOutputAmount(receipt, outputDecimals) {
|
|
|
594
556
|
}
|
|
595
557
|
}
|
|
596
558
|
|
|
597
|
-
// src/shared/core/
|
|
598
|
-
var
|
|
599
|
-
var
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
var
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
};
|
|
610
|
-
var USDC_ADDRESSES = {
|
|
611
|
-
ethereum_mainnet: EvmContractAddress(
|
|
612
|
-
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
|
|
613
|
-
),
|
|
614
|
-
ethereum_sepolia: EvmContractAddress(
|
|
615
|
-
"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"
|
|
616
|
-
)
|
|
617
|
-
};
|
|
618
|
-
var USDT_ADDRESSES = {
|
|
619
|
-
ethereum_mainnet: EvmContractAddress(
|
|
620
|
-
"0xdac17f958d2ee523a2206206994597c13d831ec7"
|
|
621
|
-
),
|
|
622
|
-
ethereum_sepolia: EvmContractAddress(
|
|
623
|
-
"0x7169D38820dfd117C3FA1f22a697dBA58d90BA06"
|
|
624
|
-
)
|
|
559
|
+
// src/shared/core/checkout/superstate/constants.ts
|
|
560
|
+
var SUPERSTATE_ISSUER_NAME = "Superstate";
|
|
561
|
+
var SUPERSTATE_SUPPORTED_INPUT_ASSETS = [USDC_SYMBOL];
|
|
562
|
+
var SWAP_POLL_INTERVAL_MS = 15e3;
|
|
563
|
+
var DEFAULT_AMOUNT_TO_COMPUTE_PRICE = 1000000n;
|
|
564
|
+
var SLIPPAGE_OPTIONS_BPS = [25n, 50n, 100n, 200n, 500n].map(
|
|
565
|
+
(n) => Bps(n)
|
|
566
|
+
);
|
|
567
|
+
var DEFAULT_SLIPPAGE_BPS = Bps(50n);
|
|
568
|
+
var SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA = EvmContractAddress("0x84f8e9a6C9Cc12fe911259372EfCa5582C4ae557");
|
|
569
|
+
var SUPERSTATE_SWAP_CONTRACT_ADDRESSES = {
|
|
570
|
+
ethereum_sepolia: SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA
|
|
625
571
|
};
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
572
|
+
function superstateSwapContractAddress(chain) {
|
|
573
|
+
return SUPERSTATE_SWAP_CONTRACT_ADDRESSES[chain] ?? null;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
// src/shared/core/checkout/superstate/formatters.ts
|
|
577
|
+
function formattedPricePerShare(quote, locale) {
|
|
578
|
+
if (!quote) return NA_AMOUNT_ASSET_UI;
|
|
579
|
+
return formattedUsdPrice(computePrice(quote), locale);
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
// src/shared/core/offers/offers-namespace.ts
|
|
583
|
+
var OffersNamespaceImpl = class {
|
|
584
|
+
constructor(ctx) {
|
|
585
|
+
this.ctx = ctx;
|
|
586
|
+
this.log = internalLogger(ctx.logger, "OFFERS");
|
|
587
|
+
}
|
|
588
|
+
async list() {
|
|
589
|
+
return this.log.wrap("list", void 0, async () => {
|
|
590
|
+
await this.ctx.ensureUserAuthenticated();
|
|
591
|
+
return fetchOffers(this.ctx.api, void 0);
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
async listPage(params) {
|
|
595
|
+
return this.log.wrap("listPage", params, async () => {
|
|
596
|
+
await this.ctx.ensureUserAuthenticated();
|
|
597
|
+
return fetchOffersPage(this.ctx.api, params, void 0);
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
async get(id) {
|
|
601
|
+
return this.log.wrap("get", id, async () => {
|
|
602
|
+
await this.ctx.ensureUserAuthenticated();
|
|
603
|
+
return fetchOfferDetails(this.ctx.api, id, void 0);
|
|
604
|
+
});
|
|
646
605
|
}
|
|
647
606
|
};
|
|
648
607
|
|
|
649
|
-
// src/shared/types/
|
|
650
|
-
var
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
var PKCEState = (value) => value;
|
|
654
|
-
var RedirectUri = (value) => value;
|
|
655
|
-
var ClientId = (value) => value;
|
|
656
|
-
var ClientSecret = (value) => value;
|
|
657
|
-
|
|
658
|
-
// src/shared/pkce.ts
|
|
659
|
-
async function generatePKCEParams(config) {
|
|
660
|
-
const state = generateSecureRandomBase64Url(32);
|
|
661
|
-
const codeVerifier = generateSecureRandomBase64Url(32);
|
|
662
|
-
const codeChallengeRaw = await sha256(codeVerifier);
|
|
663
|
-
const codeChallenge = arrayBufferToBase64Url(codeChallengeRaw, false);
|
|
664
|
-
return {
|
|
665
|
-
clientId: config.clientId,
|
|
666
|
-
responseType: "code",
|
|
667
|
-
redirectUri: config.redirectUri,
|
|
668
|
-
codeChallenge: CodeChallenge(codeChallenge),
|
|
669
|
-
codeChallengeMethod: "S256",
|
|
670
|
-
state: PKCEState(state),
|
|
671
|
-
codeVerifier: CodeVerifier(codeVerifier)
|
|
672
|
-
};
|
|
673
|
-
}
|
|
608
|
+
// src/shared/types/blockchain/wallet-error.ts
|
|
609
|
+
var RedactedWalletError = {
|
|
610
|
+
fromWalletError: (error) => error.type === "unknown" ? { type: "unknown" } : error
|
|
611
|
+
};
|
|
674
612
|
|
|
675
613
|
// src/shared/types/user.ts
|
|
676
614
|
var UserId = (value) => value;
|
|
@@ -683,56 +621,50 @@ var User = {
|
|
|
683
621
|
};
|
|
684
622
|
|
|
685
623
|
export {
|
|
624
|
+
AuthorizationCode,
|
|
625
|
+
CodeVerifier,
|
|
626
|
+
CodeChallenge,
|
|
627
|
+
PKCEState,
|
|
628
|
+
RedirectUri,
|
|
629
|
+
ClientId,
|
|
630
|
+
ClientSecret,
|
|
631
|
+
generatePKCEParams,
|
|
686
632
|
ERC20_ABI,
|
|
687
|
-
SUPERSTATE_SWAP_ABI,
|
|
688
633
|
BPS_DENOM,
|
|
689
634
|
applyBps,
|
|
635
|
+
USDC_SYMBOL,
|
|
636
|
+
USDC,
|
|
637
|
+
USDT_SYMBOL,
|
|
638
|
+
USDT,
|
|
639
|
+
TOKEN_REGISTRY,
|
|
640
|
+
ondoSwapContractAddress,
|
|
641
|
+
ONDO_POLL_INTERVAL_MS,
|
|
642
|
+
ONDO_QUOTE_EXPIRY_THRESHOLD_MS,
|
|
643
|
+
DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE,
|
|
644
|
+
ONDO_SETTLEMENT_ASSET,
|
|
645
|
+
DEFAULT_ONDO_SELL_TOKENS_TO_COMPUTE_PRICE,
|
|
646
|
+
ONDO_SUPPORTED_INPUT_ASSETS,
|
|
647
|
+
computeOndoBuyPrice,
|
|
648
|
+
computeOndoSellPrice,
|
|
649
|
+
SUPERSTATE_SWAP_ABI,
|
|
690
650
|
computePrice,
|
|
691
651
|
computeSlip,
|
|
652
|
+
SwapQuote,
|
|
692
653
|
isStopped,
|
|
693
654
|
decodeSwappedOutputAmount,
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
TxExplorerUrl,
|
|
697
|
-
ShortenedWalletAddress,
|
|
698
|
-
FormattedAmountAssetUi,
|
|
699
|
-
AssetIconUrl,
|
|
700
|
-
getChainId,
|
|
701
|
-
getNetworkName,
|
|
702
|
-
txExplorerUrl,
|
|
703
|
-
shortenAddress,
|
|
704
|
-
formatAmount,
|
|
705
|
-
formatRawAmount,
|
|
706
|
-
formatCompactAmount,
|
|
707
|
-
formatBpsAsPercent,
|
|
708
|
-
usdAmount,
|
|
709
|
-
assetAmount,
|
|
710
|
-
NA_AMOUNT_ASSET_UI,
|
|
711
|
-
formattedUsdPrice,
|
|
712
|
-
formattedPricePerShare,
|
|
713
|
-
parseBlockchainAmount,
|
|
714
|
-
SUPERSTATE_TOS_URL,
|
|
655
|
+
SUPERSTATE_ISSUER_NAME,
|
|
656
|
+
SUPERSTATE_SUPPORTED_INPUT_ASSETS,
|
|
715
657
|
SWAP_POLL_INTERVAL_MS,
|
|
716
658
|
DEFAULT_AMOUNT_TO_COMPUTE_PRICE,
|
|
717
659
|
SLIPPAGE_OPTIONS_BPS,
|
|
718
660
|
DEFAULT_SLIPPAGE_BPS,
|
|
719
661
|
SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA,
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
USDT,
|
|
725
|
-
TOKEN_REGISTRY,
|
|
726
|
-
AuthorizationCode,
|
|
727
|
-
CodeVerifier,
|
|
728
|
-
CodeChallenge,
|
|
729
|
-
PKCEState,
|
|
730
|
-
RedirectUri,
|
|
731
|
-
ClientId,
|
|
732
|
-
ClientSecret,
|
|
733
|
-
generatePKCEParams,
|
|
662
|
+
superstateSwapContractAddress,
|
|
663
|
+
formattedPricePerShare,
|
|
664
|
+
OffersNamespaceImpl,
|
|
665
|
+
RedactedWalletError,
|
|
734
666
|
UserId,
|
|
735
667
|
UserEmail,
|
|
736
668
|
User
|
|
737
669
|
};
|
|
738
|
-
//# sourceMappingURL=chunk-
|
|
670
|
+
//# sourceMappingURL=chunk-LSPZETDH.js.map
|