@coinlist-co/react 0.10.0 → 0.11.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 +32 -0
- package/dist/{chunk-GSSAB4K5.js → chunk-B2HCVPCQ.js} +225 -247
- package/dist/chunk-B2HCVPCQ.js.map +1 -0
- package/dist/chunk-KDGNDAHA.js +146 -0
- package/dist/chunk-KDGNDAHA.js.map +1 -0
- package/dist/chunk-UIIXXLA7.js +1863 -0
- package/dist/chunk-UIIXXLA7.js.map +1 -0
- package/dist/client/index.cjs +10559 -3442
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +4219 -862
- package/dist/client/index.d.ts +4219 -862
- package/dist/client/index.js +8729 -2370
- package/dist/client/index.js.map +1 -1
- package/dist/collections-BhDkYmzV.d.cts +65 -0
- package/dist/collections-CZhHoQHr.d.ts +65 -0
- package/dist/config-B5mwS_2l.d.cts +1926 -0
- package/dist/config-B5mwS_2l.d.ts +1926 -0
- package/dist/server/index.cjs +981 -464
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +190 -163
- package/dist/server/index.d.ts +190 -163
- package/dist/server/index.js +151 -156
- package/dist/server/index.js.map +1 -1
- package/dist/shared/index.cjs +1810 -907
- package/dist/shared/index.cjs.map +1 -1
- package/dist/shared/index.d.cts +243 -132
- package/dist/shared/index.d.ts +243 -132
- package/dist/shared/index.js +102 -114
- package/dist/shared/index.js.map +1 -1
- package/package.json +10 -7
- package/dist/chunk-7BJ2HAG7.js +0 -442
- package/dist/chunk-7BJ2HAG7.js.map +0 -1
- package/dist/chunk-AAER5LOL.js +0 -22
- package/dist/chunk-AAER5LOL.js.map +0 -1
- package/dist/chunk-GSSAB4K5.js.map +0 -1
- package/dist/chunk-TUZKKFNW.js +0 -836
- package/dist/chunk-TUZKKFNW.js.map +0 -1
- package/dist/collections-CJ24dOda.d.cts +0 -28
- package/dist/collections-ZYLKp8JB.d.ts +0 -28
- package/dist/requirement-CDi5NJI8.d.cts +0 -1036
- package/dist/requirement-CDi5NJI8.d.ts +0 -1036
package/README.md
CHANGED
|
@@ -5,3 +5,35 @@ This package is documented at:
|
|
|
5
5
|
https://docs.coinlist.co/
|
|
6
6
|
|
|
7
7
|
Please refer to the docs site for installation, configuration, and integration guides.
|
|
8
|
+
|
|
9
|
+
## Local development
|
|
10
|
+
|
|
11
|
+
The toolchain (Node 24, TypeScript) is pinned by `flake.nix` and frozen by `flake.lock`.
|
|
12
|
+
|
|
13
|
+
Prerequisites:
|
|
14
|
+
|
|
15
|
+
1. Nix — install with the [Determinate Systems installer](https://github.com/DeterminateSystems/nix-installer),
|
|
16
|
+
which enables flakes out of the box and supports clean uninstalls:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
2. [direnv](https://direnv.net/) and [nix-direnv](https://github.com/nix-community/nix-direnv)
|
|
23
|
+
(direnv on its own does not provide `use flake`).
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
direnv allow # activates the dev shell on every cd into the repo
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Without direnv, enter the same shell manually:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
nix develop
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The flake provides the toolchain, not `node_modules` — install JS dependencies as usual:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm ci
|
|
39
|
+
```
|
|
@@ -2,16 +2,55 @@ import {
|
|
|
2
2
|
AssetDecimals,
|
|
3
3
|
BlockchainAmount,
|
|
4
4
|
Bps,
|
|
5
|
+
DecimalString,
|
|
5
6
|
EvmContractAddress,
|
|
6
7
|
MAX_UINT_256,
|
|
8
|
+
NA_AMOUNT_ASSET_UI,
|
|
7
9
|
StablecoinSymbol,
|
|
10
|
+
ValidationError,
|
|
8
11
|
arrayBufferToBase64Url,
|
|
9
12
|
assertUint256,
|
|
13
|
+
fetchOfferDetails,
|
|
14
|
+
fetchOffers,
|
|
15
|
+
fetchOffersPage,
|
|
16
|
+
formattedUsdPrice,
|
|
10
17
|
generateSecureRandomBase64Url,
|
|
11
18
|
sha256
|
|
12
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-UIIXXLA7.js";
|
|
20
|
+
|
|
21
|
+
// src/shared/types/oauth.ts
|
|
22
|
+
var AuthorizationCode = (value) => value;
|
|
23
|
+
var CodeVerifier = (value) => value;
|
|
24
|
+
var CodeChallenge = (value) => value;
|
|
25
|
+
var PKCEState = (value) => value;
|
|
26
|
+
var RedirectUri = (value) => value;
|
|
27
|
+
var ClientId = (value) => value;
|
|
28
|
+
var ClientSecret = (value) => value;
|
|
29
|
+
|
|
30
|
+
// src/shared/core/auth/pkce.ts
|
|
31
|
+
async function generatePKCEParams(config) {
|
|
32
|
+
const state = generateSecureRandomBase64Url(32);
|
|
33
|
+
const codeVerifier = generateSecureRandomBase64Url(32);
|
|
34
|
+
const codeChallengeRaw = await sha256(codeVerifier);
|
|
35
|
+
const codeChallenge = arrayBufferToBase64Url(codeChallengeRaw, false);
|
|
36
|
+
return {
|
|
37
|
+
clientId: config.clientId,
|
|
38
|
+
responseType: "code",
|
|
39
|
+
redirectUri: config.redirectUri,
|
|
40
|
+
codeChallenge: CodeChallenge(codeChallenge),
|
|
41
|
+
codeChallengeMethod: "S256",
|
|
42
|
+
state: PKCEState(state),
|
|
43
|
+
codeVerifier: CodeVerifier(codeVerifier)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
13
46
|
|
|
14
|
-
// src/shared/core/blockchain/
|
|
47
|
+
// src/shared/core/blockchain/bps.ts
|
|
48
|
+
var BPS_DENOM = Bps(10000n);
|
|
49
|
+
function applyBps(amount, bps) {
|
|
50
|
+
return assertUint256(amount * bps / BPS_DENOM);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// src/shared/core/blockchain/erc20/abi.ts
|
|
15
54
|
var ERC20_ABI = [
|
|
16
55
|
{
|
|
17
56
|
type: "function",
|
|
@@ -111,7 +150,98 @@ var ERC20_ABI = [
|
|
|
111
150
|
}
|
|
112
151
|
];
|
|
113
152
|
|
|
114
|
-
// src/shared/core/blockchain/
|
|
153
|
+
// src/shared/core/blockchain/token-registry.ts
|
|
154
|
+
var USDC_SYMBOL = StablecoinSymbol("USDC");
|
|
155
|
+
var USDC = {
|
|
156
|
+
name: "USD Coin",
|
|
157
|
+
symbol: USDC_SYMBOL,
|
|
158
|
+
decimals: AssetDecimals(6)
|
|
159
|
+
};
|
|
160
|
+
var USDT_SYMBOL = StablecoinSymbol("USDT");
|
|
161
|
+
var USDT = {
|
|
162
|
+
name: "Tether USD",
|
|
163
|
+
symbol: USDT_SYMBOL,
|
|
164
|
+
decimals: AssetDecimals(6)
|
|
165
|
+
};
|
|
166
|
+
var USDC_ADDRESSES = {
|
|
167
|
+
ethereum_mainnet: EvmContractAddress(
|
|
168
|
+
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
|
|
169
|
+
),
|
|
170
|
+
ethereum_sepolia: EvmContractAddress(
|
|
171
|
+
"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"
|
|
172
|
+
)
|
|
173
|
+
};
|
|
174
|
+
var USDT_ADDRESSES = {
|
|
175
|
+
ethereum_mainnet: EvmContractAddress(
|
|
176
|
+
"0xdac17f958d2ee523a2206206994597c13d831ec7"
|
|
177
|
+
),
|
|
178
|
+
ethereum_sepolia: EvmContractAddress(
|
|
179
|
+
"0x7169D38820dfd117C3FA1f22a697dBA58d90BA06"
|
|
180
|
+
)
|
|
181
|
+
};
|
|
182
|
+
var TOKEN_REGISTRY = {
|
|
183
|
+
erc20: (symbol) => {
|
|
184
|
+
switch (symbol) {
|
|
185
|
+
case "USDC":
|
|
186
|
+
return USDC;
|
|
187
|
+
case "USDT":
|
|
188
|
+
return USDT;
|
|
189
|
+
default:
|
|
190
|
+
throw new Error(`Unknown asset symbol: ${symbol}`);
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
contractAddress: (symbol, chain) => {
|
|
194
|
+
switch (symbol) {
|
|
195
|
+
case "USDC":
|
|
196
|
+
return USDC_ADDRESSES[chain];
|
|
197
|
+
case "USDT":
|
|
198
|
+
return USDT_ADDRESSES[chain];
|
|
199
|
+
default:
|
|
200
|
+
throw new Error(`Unknown asset symbol: ${symbol}`);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
// src/shared/core/checkout/ondo/constants.ts
|
|
206
|
+
var ONDO_SWAP_CONTRACT_ADDRESSES = {
|
|
207
|
+
ethereum_sepolia: EvmContractAddress(
|
|
208
|
+
"0xFF9c5Ade32d9B4102469Bd5F3817CB0061b25feC"
|
|
209
|
+
)
|
|
210
|
+
};
|
|
211
|
+
function ondoSwapContractAddress(chain) {
|
|
212
|
+
return ONDO_SWAP_CONTRACT_ADDRESSES[chain] ?? null;
|
|
213
|
+
}
|
|
214
|
+
var ONDO_POLL_INTERVAL_MS = 15e3;
|
|
215
|
+
var ONDO_QUOTE_EXPIRY_THRESHOLD_MS = 5e3;
|
|
216
|
+
var DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE = DecimalString("1000");
|
|
217
|
+
var ONDO_SUPPORTED_INPUT_ASSETS = [
|
|
218
|
+
USDC_SYMBOL
|
|
219
|
+
];
|
|
220
|
+
|
|
221
|
+
// src/shared/core/checkout/ondo/math.ts
|
|
222
|
+
function computeOndoPrice(transaction) {
|
|
223
|
+
const { notionalValue, receiveOutputAmount } = transaction;
|
|
224
|
+
if (receiveOutputAmount.raw <= 0n) {
|
|
225
|
+
throw new ValidationError(
|
|
226
|
+
"Ondo price: receiveOutputAmount must be greater than zero"
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
const scaled = notionalValue.raw * 10n ** BigInt(receiveOutputAmount.decimals);
|
|
230
|
+
const raw = scaled / receiveOutputAmount.raw;
|
|
231
|
+
return BlockchainAmount({
|
|
232
|
+
raw: assertPriceFits(raw),
|
|
233
|
+
decimals: notionalValue.decimals
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
function assertPriceFits(raw) {
|
|
237
|
+
try {
|
|
238
|
+
return assertUint256(raw);
|
|
239
|
+
} catch {
|
|
240
|
+
throw new ValidationError(`Ondo price: out of uint256 bounds (${raw})`);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// src/shared/core/checkout/superstate/blockchain/abi.ts
|
|
115
245
|
var SUPERSTATE_SWAP_ABI = [
|
|
116
246
|
{
|
|
117
247
|
type: "function",
|
|
@@ -333,13 +463,7 @@ var SUPERSTATE_SWAP_ABI = [
|
|
|
333
463
|
}
|
|
334
464
|
];
|
|
335
465
|
|
|
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/core/blockchain/swap/math.ts
|
|
466
|
+
// src/shared/core/checkout/superstate/blockchain/math.ts
|
|
343
467
|
function computePrice({
|
|
344
468
|
inputTokenAmount,
|
|
345
469
|
outputTokenAmount
|
|
@@ -357,12 +481,32 @@ function computeSlip(amount, slippage) {
|
|
|
357
481
|
return BlockchainAmount({ raw: slipRaw, decimals: amount.decimals });
|
|
358
482
|
}
|
|
359
483
|
|
|
360
|
-
// src/shared/core/blockchain/
|
|
484
|
+
// src/shared/core/checkout/superstate/blockchain/quote.ts
|
|
485
|
+
var SwapQuote = {
|
|
486
|
+
/**
|
|
487
|
+
* Assembles a {@link SwapQuote} from a raw contract {@link SwapPreview}. The
|
|
488
|
+
* input and fee are denominated in the input token; the output in the output
|
|
489
|
+
* token.
|
|
490
|
+
*/
|
|
491
|
+
fromPreview: (preview, inputDecimals, outputDecimals) => ({
|
|
492
|
+
inputTokenAmount: BlockchainAmount({
|
|
493
|
+
raw: preview.inputAmount,
|
|
494
|
+
decimals: inputDecimals
|
|
495
|
+
}),
|
|
496
|
+
fee: BlockchainAmount({ raw: preview.fee, decimals: inputDecimals }),
|
|
497
|
+
outputTokenAmount: BlockchainAmount({
|
|
498
|
+
raw: preview.outputAmount,
|
|
499
|
+
decimals: outputDecimals
|
|
500
|
+
})
|
|
501
|
+
})
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
// src/shared/core/checkout/superstate/blockchain/status.ts
|
|
361
505
|
function isStopped(status) {
|
|
362
506
|
return (status.stopped & status.swapLevel) !== 0n;
|
|
363
507
|
}
|
|
364
508
|
|
|
365
|
-
// src/shared/core/blockchain/
|
|
509
|
+
// src/shared/core/checkout/superstate/blockchain/swapped-event.ts
|
|
366
510
|
import { parseEventLogs } from "viem";
|
|
367
511
|
function decodeSwappedOutputAmount(receipt, outputDecimals) {
|
|
368
512
|
try {
|
|
@@ -380,141 +524,9 @@ function decodeSwappedOutputAmount(receipt, outputDecimals) {
|
|
|
380
524
|
}
|
|
381
525
|
}
|
|
382
526
|
|
|
383
|
-
// src/shared/
|
|
384
|
-
var
|
|
385
|
-
var
|
|
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";
|
|
527
|
+
// src/shared/core/checkout/superstate/constants.ts
|
|
528
|
+
var SUPERSTATE_ISSUER_NAME = "Superstate";
|
|
529
|
+
var SUPERSTATE_SUPPORTED_INPUT_ASSETS = [USDC_SYMBOL];
|
|
518
530
|
var SWAP_POLL_INTERVAL_MS = 15e3;
|
|
519
531
|
var DEFAULT_AMOUNT_TO_COMPUTE_PRICE = 1000000n;
|
|
520
532
|
var SLIPPAGE_OPTIONS_BPS = [25n, 50n, 100n, 200n, 500n].map(
|
|
@@ -522,88 +534,49 @@ var SLIPPAGE_OPTIONS_BPS = [25n, 50n, 100n, 200n, 500n].map(
|
|
|
522
534
|
);
|
|
523
535
|
var DEFAULT_SLIPPAGE_BPS = Bps(50n);
|
|
524
536
|
var SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA = EvmContractAddress("0x84f8e9a6C9Cc12fe911259372EfCa5582C4ae557");
|
|
525
|
-
|
|
526
|
-
|
|
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
|
-
})
|
|
537
|
+
var SUPERSTATE_SWAP_CONTRACT_ADDRESSES = {
|
|
538
|
+
ethereum_sepolia: SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA
|
|
544
539
|
};
|
|
540
|
+
function superstateSwapContractAddress(chain) {
|
|
541
|
+
return SUPERSTATE_SWAP_CONTRACT_ADDRESSES[chain] ?? null;
|
|
542
|
+
}
|
|
545
543
|
|
|
546
|
-
// src/shared/core/
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
var
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
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
|
-
}
|
|
544
|
+
// src/shared/core/checkout/superstate/formatters.ts
|
|
545
|
+
function formattedPricePerShare(quote, locale) {
|
|
546
|
+
if (!quote) return NA_AMOUNT_ASSET_UI;
|
|
547
|
+
return formattedUsdPrice(computePrice(quote), locale);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
// src/shared/core/offers/offers-namespace.ts
|
|
551
|
+
var OffersNamespaceImpl = class {
|
|
552
|
+
constructor(ctx) {
|
|
553
|
+
this.ctx = ctx;
|
|
554
|
+
}
|
|
555
|
+
async list() {
|
|
556
|
+
await this.ctx.ensureUserAuthenticated();
|
|
557
|
+
return fetchOffers(this.ctx.api, void 0);
|
|
595
558
|
}
|
|
559
|
+
async listPage(params) {
|
|
560
|
+
await this.ctx.ensureUserAuthenticated();
|
|
561
|
+
return fetchOffersPage(this.ctx.api, params, void 0);
|
|
562
|
+
}
|
|
563
|
+
async get(id) {
|
|
564
|
+
await this.ctx.ensureUserAuthenticated();
|
|
565
|
+
return fetchOfferDetails(this.ctx.api, id, void 0);
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
// src/shared/types/user.ts
|
|
570
|
+
var UserId = (value) => value;
|
|
571
|
+
var UserEmail = (value) => value;
|
|
572
|
+
var User = {
|
|
573
|
+
fromDto: (dto) => ({
|
|
574
|
+
id: UserId(dto.id),
|
|
575
|
+
email: UserEmail(dto.email)
|
|
576
|
+
})
|
|
596
577
|
};
|
|
597
578
|
|
|
598
579
|
export {
|
|
599
|
-
ERC20_ABI,
|
|
600
|
-
SUPERSTATE_SWAP_ABI,
|
|
601
|
-
BPS_DENOM,
|
|
602
|
-
applyBps,
|
|
603
|
-
computePrice,
|
|
604
|
-
computeSlip,
|
|
605
|
-
isStopped,
|
|
606
|
-
decodeSwappedOutputAmount,
|
|
607
580
|
AuthorizationCode,
|
|
608
581
|
CodeVerifier,
|
|
609
582
|
CodeChallenge,
|
|
@@ -612,33 +585,38 @@ export {
|
|
|
612
585
|
ClientId,
|
|
613
586
|
ClientSecret,
|
|
614
587
|
generatePKCEParams,
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
588
|
+
ERC20_ABI,
|
|
589
|
+
BPS_DENOM,
|
|
590
|
+
applyBps,
|
|
591
|
+
USDC_SYMBOL,
|
|
592
|
+
USDC,
|
|
593
|
+
USDT_SYMBOL,
|
|
594
|
+
USDT,
|
|
595
|
+
TOKEN_REGISTRY,
|
|
596
|
+
ondoSwapContractAddress,
|
|
597
|
+
ONDO_POLL_INTERVAL_MS,
|
|
598
|
+
ONDO_QUOTE_EXPIRY_THRESHOLD_MS,
|
|
599
|
+
DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE,
|
|
600
|
+
ONDO_SUPPORTED_INPUT_ASSETS,
|
|
601
|
+
computeOndoPrice,
|
|
602
|
+
SUPERSTATE_SWAP_ABI,
|
|
603
|
+
computePrice,
|
|
604
|
+
computeSlip,
|
|
605
|
+
SwapQuote,
|
|
606
|
+
isStopped,
|
|
607
|
+
decodeSwappedOutputAmount,
|
|
608
|
+
SUPERSTATE_ISSUER_NAME,
|
|
609
|
+
SUPERSTATE_SUPPORTED_INPUT_ASSETS,
|
|
632
610
|
SWAP_POLL_INTERVAL_MS,
|
|
633
611
|
DEFAULT_AMOUNT_TO_COMPUTE_PRICE,
|
|
634
612
|
SLIPPAGE_OPTIONS_BPS,
|
|
635
613
|
DEFAULT_SLIPPAGE_BPS,
|
|
636
614
|
SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA,
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
615
|
+
superstateSwapContractAddress,
|
|
616
|
+
formattedPricePerShare,
|
|
617
|
+
OffersNamespaceImpl,
|
|
618
|
+
UserId,
|
|
619
|
+
UserEmail,
|
|
620
|
+
User
|
|
643
621
|
};
|
|
644
|
-
//# sourceMappingURL=chunk-
|
|
622
|
+
//# sourceMappingURL=chunk-B2HCVPCQ.js.map
|