@coinlist-co/react 0.12.2-rc.abd9d38 → 0.12.2-rc.e1f6c82

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 (36) hide show
  1. package/README.md +10 -0
  2. package/dist/{chunk-45LAPB7U.js → chunk-EKLUJZ7T.js} +10 -10
  3. package/dist/chunk-EKLUJZ7T.js.map +1 -0
  4. package/dist/{chunk-HDJEDOS4.js → chunk-GIE4UWB3.js} +1207 -799
  5. package/dist/chunk-GIE4UWB3.js.map +1 -0
  6. package/dist/chunk-MJ6YXZWH.js +22 -0
  7. package/dist/chunk-MJ6YXZWH.js.map +1 -0
  8. package/dist/{chunk-M7WDZZPX.js → chunk-PIOQA6HW.js} +194 -190
  9. package/dist/chunk-PIOQA6HW.js.map +1 -0
  10. package/dist/client/index.d.ts +2977 -4267
  11. package/dist/client/index.js +8552 -5713
  12. package/dist/client/index.js.map +1 -1
  13. package/dist/server/index.d.ts +7 -33
  14. package/dist/server/index.js +8 -4
  15. package/dist/server/index.js.map +1 -1
  16. package/dist/{tokens-namespace-DrwRi0AQ.d.cts → time-Bbqlt2x7.d.ts} +2081 -2734
  17. package/dist/{token-registry-snapshot-C-Qs3Lgs.d.ts → token-registry-snapshot-DttZXGvY.d.ts} +74 -42
  18. package/dist/universal/index.d.ts +59 -998
  19. package/dist/universal/index.js +38 -36
  20. package/package.json +18 -14
  21. package/dist/chunk-45LAPB7U.js.map +0 -1
  22. package/dist/chunk-HDJEDOS4.js.map +0 -1
  23. package/dist/chunk-M7WDZZPX.js.map +0 -1
  24. package/dist/client/index.cjs +0 -17098
  25. package/dist/client/index.cjs.map +0 -1
  26. package/dist/client/index.d.cts +0 -6660
  27. package/dist/server/index.cjs +0 -4240
  28. package/dist/server/index.cjs.map +0 -1
  29. package/dist/server/index.d.cts +0 -378
  30. package/dist/time-BOCS1TbH.d.cts +0 -50
  31. package/dist/time-C7mhO5_a.d.ts +0 -50
  32. package/dist/token-registry-snapshot-CpzLmsc2.d.cts +0 -179
  33. package/dist/tokens-namespace-DrwRi0AQ.d.ts +0 -3364
  34. package/dist/universal/index.cjs +0 -4135
  35. package/dist/universal/index.cjs.map +0 -1
  36. package/dist/universal/index.d.cts +0 -1314
@@ -1,4135 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/universal/index.ts
21
- var universal_exports = {};
22
- __export(universal_exports, {
23
- AllowWalletResponse: () => AllowWalletResponse,
24
- Asset: () => Asset,
25
- AssetCode: () => AssetCode,
26
- AssetDecimals: () => AssetDecimals,
27
- AssetIconUrl: () => AssetIconUrl,
28
- AssetId: () => AssetId,
29
- AssetSymbol: () => AssetSymbol,
30
- AuthorizationCode: () => AuthorizationCode,
31
- BPS_DENOM: () => BPS_DENOM,
32
- Blockchain: () => Blockchain,
33
- BlockchainAmount: () => BlockchainAmount,
34
- Bps: () => Bps,
35
- Chain: () => Chain,
36
- ClientCredentialsOAuth: () => ClientCredentialsOAuth,
37
- ClientId: () => ClientId,
38
- ClientSecret: () => ClientSecret,
39
- CodeChallenge: () => CodeChallenge,
40
- CodeVerifier: () => CodeVerifier,
41
- CoinListTokenSaleNamespaceImpl: () => CoinListTokenSaleNamespaceImpl,
42
- ConnectExternalWalletParams: () => ConnectExternalWalletParams,
43
- CreateParticipationParams: () => CreateParticipationParams,
44
- CreateWalletOwnershipChallengeParams: () => CreateWalletOwnershipChallengeParams,
45
- Cursor: () => Cursor,
46
- DEFAULT_AMOUNT_TO_COMPUTE_PRICE: () => DEFAULT_AMOUNT_TO_COMPUTE_PRICE,
47
- DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE: () => DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE,
48
- DEFAULT_ONDO_SELL_TOKENS_TO_COMPUTE_PRICE: () => DEFAULT_ONDO_SELL_TOKENS_TO_COMPUTE_PRICE,
49
- DEFAULT_SLIPPAGE_BPS: () => DEFAULT_SLIPPAGE_BPS,
50
- DecimalString: () => DecimalString,
51
- DocumentSubmission: () => DocumentSubmission,
52
- ERC20_ABI: () => ERC20_ABI,
53
- ETHEREUM_CHAINS: () => ETHEREUM_CHAINS,
54
- EpochMillis: () => EpochMillis,
55
- Erc20NamespaceImpl: () => Erc20NamespaceImpl,
56
- EthereumChain: () => EthereumChain,
57
- EvmContractAddress: () => EvmContractAddress,
58
- EvmWalletAddress: () => EvmWalletAddress,
59
- FaqItem: () => FaqItem,
60
- FormattedAmountAssetUi: () => FormattedAmountAssetUi,
61
- FormattedAmountUi: () => FormattedAmountUi,
62
- FormattedPercentUi: () => FormattedPercentUi,
63
- HexEncodedTransactionData: () => HexEncodedTransactionData,
64
- HttpError: () => HttpError,
65
- InvariantError: () => InvariantError,
66
- Isin: () => Isin,
67
- Iso2CountryCode: () => Iso2CountryCode,
68
- KnownAssetSymbol: () => KnownAssetSymbol,
69
- KycToken: () => KycToken,
70
- Link: () => Link,
71
- MAX_ASSET_DECIMALS: () => MAX_ASSET_DECIMALS,
72
- MAX_UINT_256: () => MAX_UINT_256,
73
- MathError: () => MathError,
74
- Milestone: () => Milestone,
75
- Millis: () => Millis,
76
- NA_AMOUNT_ASSET_UI: () => NA_AMOUNT_ASSET_UI,
77
- NotAuthenticatedError: () => NotAuthenticatedError,
78
- NotImplementedError: () => NotImplementedError,
79
- OAuthRefreshToken: () => OAuthRefreshToken,
80
- OAuthSession: () => OAuthSession,
81
- ONDO_NOT_TRADABLE_CODE: () => ONDO_NOT_TRADABLE_CODE,
82
- ONDO_POLL_INTERVAL_MS: () => ONDO_POLL_INTERVAL_MS,
83
- ONDO_QUOTE_MAX_TTL_MS: () => ONDO_QUOTE_MAX_TTL_MS,
84
- ONDO_SETTLEMENT_ASSET: () => ONDO_SETTLEMENT_ASSET,
85
- ONDO_SUPPORTED_INPUT_ASSETS: () => ONDO_SUPPORTED_INPUT_ASSETS,
86
- Offer: () => Offer,
87
- OfferDetail: () => OfferDetail,
88
- OfferEditorial: () => OfferEditorial,
89
- OfferId: () => OfferId,
90
- OfferOption: () => OfferOption,
91
- OfferOptionAddress: () => OfferOptionAddress,
92
- OfferOptionAddressId: () => OfferOptionAddressId,
93
- OfferOptionId: () => OfferOptionId,
94
- OfferOptionSlug: () => OfferOptionSlug,
95
- OfferSlug: () => OfferSlug,
96
- OfferSwapContract: () => OfferSwapContract,
97
- OfferToken: () => OfferToken,
98
- OffersNamespaceImpl: () => OffersNamespaceImpl,
99
- OndoBuyTransaction: () => OndoBuyTransaction,
100
- OndoNamespaceImpl: () => OndoNamespaceImpl,
101
- OndoQuote: () => OndoQuote,
102
- OndoSellTransaction: () => OndoSellTransaction,
103
- OndoTradingStatus: () => OndoTradingStatus,
104
- PKCEState: () => PKCEState,
105
- PaginatedResponse: () => PaginatedResponse,
106
- PaginationParams: () => PaginationParams,
107
- Participation: () => Participation,
108
- ParticipationId: () => ParticipationId,
109
- ParticipationsPaginationParams: () => ParticipationsPaginationParams,
110
- PauseFlags: () => PauseFlags,
111
- Pii: () => Pii,
112
- PiiAddress: () => PiiAddress,
113
- PiiJurisdiction: () => PiiJurisdiction,
114
- RedactedWalletError: () => RedactedWalletError,
115
- RedirectUri: () => RedirectUri,
116
- Requirement: () => Requirement,
117
- RequirementId: () => RequirementId,
118
- RequirementStatusInfo: () => RequirementStatusInfo,
119
- RequirementsNamespaceImpl: () => RequirementsNamespaceImpl,
120
- SLIPPAGE_OPTIONS_BPS: () => SLIPPAGE_OPTIONS_BPS,
121
- SOLANA_CHAINS: () => SOLANA_CHAINS,
122
- STABLE_DECIMALS: () => STABLE_DECIMALS,
123
- SUPERSTATE_ISSUER_NAME: () => SUPERSTATE_ISSUER_NAME,
124
- SUPERSTATE_SUPPORTED_INPUT_ASSETS: () => SUPERSTATE_SUPPORTED_INPUT_ASSETS,
125
- SUPERSTATE_SWAP_ABI: () => SUPERSTATE_SWAP_ABI,
126
- SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA: () => SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA,
127
- SWAP_LEVEL: () => SWAP_LEVEL,
128
- SWAP_POLL_INTERVAL_MS: () => SWAP_POLL_INTERVAL_MS,
129
- Seconds: () => Seconds,
130
- ShortenedWalletAddress: () => ShortenedWalletAddress,
131
- SolanaChain: () => SolanaChain,
132
- StablecoinSymbol: () => StablecoinSymbol,
133
- SuperstateSwapNamespaceImpl: () => SuperstateSwapNamespaceImpl,
134
- SwapPreview: () => SwapPreview,
135
- SwapQuote: () => SwapQuote,
136
- SwapStatus: () => SwapStatus,
137
- TOKEN_REGISTRY: () => TOKEN_REGISTRY,
138
- TermItem: () => TermItem,
139
- Ticker: () => Ticker,
140
- TokenLogo: () => TokenLogo,
141
- TokenLogoUrl: () => TokenLogoUrl,
142
- TokenMetadata: () => TokenMetadata,
143
- TokenRegistrySnapshot: () => TokenRegistrySnapshot,
144
- TokensNamespaceImpl: () => TokensNamespaceImpl,
145
- TxExplorerUrl: () => TxExplorerUrl,
146
- USDC: () => USDC,
147
- USDC_SYMBOL: () => USDC_SYMBOL,
148
- USDT: () => USDT,
149
- USDT_SYMBOL: () => USDT_SYMBOL,
150
- User: () => User,
151
- UserEmail: () => UserEmail,
152
- UserId: () => UserId,
153
- ValidationError: () => ValidationError,
154
- WalletAddress: () => WalletAddress,
155
- WalletOwnershipChallenge: () => WalletOwnershipChallenge,
156
- WalletsNamespaceImpl: () => WalletsNamespaceImpl,
157
- apiErrorCode: () => apiErrorCode,
158
- applyBps: () => applyBps,
159
- assertUint256: () => assertUint256,
160
- assetAmount: () => assetAmount,
161
- blockchainAmountFromRawOrThrow: () => blockchainAmountFromRawOrThrow,
162
- chainFromId: () => chainFromId,
163
- computeOndoBuyPrice: () => computeOndoBuyPrice,
164
- computeOndoSellPrice: () => computeOndoSellPrice,
165
- computePrice: () => computePrice,
166
- computeSlip: () => computeSlip,
167
- decodeSwappedOutputAmount: () => decodeSwappedOutputAmount,
168
- fetchAllPages: () => fetchAllPages,
169
- formatAmount: () => formatAmount,
170
- formatBpsAsPercent: () => formatBpsAsPercent,
171
- formatCompactAmount: () => formatCompactAmount,
172
- formatRawAmount: () => formatRawAmount,
173
- formatShareAmount: () => formatShareAmount,
174
- formattedPricePerShare: () => formattedPricePerShare,
175
- formattedUsdPrice: () => formattedUsdPrice,
176
- generatePKCEParams: () => generatePKCEParams,
177
- getChainId: () => getChainId,
178
- getNetworkName: () => getNetworkName,
179
- isChain: () => isChain,
180
- isExpired: () => isExpired,
181
- isOfferType: () => isOfferType,
182
- isOndoNotTradableError: () => isOndoNotTradableError,
183
- isSwapAvailable: () => isSwapAvailable,
184
- offerDisplayTokens: () => offerDisplayTokens,
185
- ondoQuoteOfferDeadline: () => ondoQuoteOfferDeadline,
186
- parseBlockchainAmount: () => parseBlockchainAmount,
187
- parseUint256: () => parseUint256,
188
- shortenAddress: () => shortenAddress,
189
- superstateSwapContractAddress: () => superstateSwapContractAddress,
190
- swapSpender: () => swapSpender,
191
- txExplorerUrl: () => txExplorerUrl,
192
- usdAmount: () => usdAmount,
193
- viemChain: () => viemChain
194
- });
195
- module.exports = __toCommonJS(universal_exports);
196
-
197
- // src/universal/api/internal-access-token-source.ts
198
- var SentWith = {
199
- userToken: (token) => ({
200
- type: "user-token",
201
- token
202
- }),
203
- noUserToken: { type: "no-user-token" }
204
- };
205
-
206
- // src/universal/api/http-attributes.ts
207
- var empty = {};
208
- var concat = (left, right) => ({
209
- ...left,
210
- ...right
211
- });
212
- var concatAll = (...items) => {
213
- let result = empty;
214
- for (const item of items) {
215
- result = concat(result, item);
216
- }
217
- return result;
218
- };
219
- var protectedRequest = () => ({ protected: true });
220
- var userAgent = () => ({ userAgent: true });
221
- var idempotencyKey = () => ({
222
- idempotencyKey: true
223
- });
224
- var clientCredentials = (credentials) => ({
225
- clientCredentials: credentials
226
- });
227
- var retryAttempt = (attempt) => ({
228
- retryAttempt: attempt
229
- });
230
- var renewAttempted = (value) => ({
231
- renewAttempted: value
232
- });
233
- var notRetryable = () => ({ retryable: false });
234
- var sentWith = (token) => ({
235
- sentWith: token
236
- });
237
- var requestId = (id) => ({ requestId: id });
238
- var getRequestId = (attrs) => attrs?.requestId ?? null;
239
- var isProtected = (attrs) => attrs?.protected === true;
240
- var needUserAgent = (attrs) => attrs?.userAgent === true;
241
- var isIdempotent = (attrs) => attrs?.idempotencyKey === true;
242
- var getRetryAttempt = (attrs) => attrs?.retryAttempt ?? 0;
243
- var wasRenewAttempted = (attrs) => attrs?.renewAttempted === true;
244
- var isRetryable = (attrs) => attrs?.retryable !== false;
245
- var getSentWith = (attrs) => attrs?.sentWith === void 0 ? SentWith.noUserToken : SentWith.userToken(attrs.sentWith);
246
- var getClientCredentials = (attrs) => attrs?.clientCredentials;
247
- var Attributes = {
248
- empty,
249
- concat,
250
- concatAll,
251
- protected: protectedRequest,
252
- isProtected,
253
- userAgent,
254
- needUserAgent,
255
- idempotencyKey,
256
- isIdempotent,
257
- retryAttempt,
258
- getRetryAttempt,
259
- renewAttempted,
260
- wasRenewAttempted,
261
- notRetryable,
262
- isRetryable,
263
- sentWith,
264
- getSentWith,
265
- clientCredentials,
266
- getClientCredentials,
267
- requestId,
268
- getRequestId
269
- };
270
-
271
- // src/universal/api/http.ts
272
- var HttpError = class extends Error {
273
- constructor(response) {
274
- super(`Request failed with ${response.status} status`);
275
- this.name = "HttpError";
276
- this.response = response;
277
- }
278
- /**
279
- * Correlates this failure with the `[HTTP]` log lines for the same request,
280
- * which carry the method, the URL, the duration and every retry. `null` when
281
- * the response did not come from an {@link HttpClient}.
282
- *
283
- * Worth quoting in a bug report: it is what makes a log excerpt readable.
284
- */
285
- get requestId() {
286
- return this.response.requestId ?? null;
287
- }
288
- };
289
- function apiErrorCode(error) {
290
- if (!(error instanceof HttpError)) return null;
291
- const body = error.response.body;
292
- if (typeof body !== "object" || body === null) return null;
293
- const code = body.code;
294
- return typeof code === "string" ? code : null;
295
- }
296
- async function makeRequest(request) {
297
- const headers = {
298
- Accept: "application/json",
299
- ...request.method === "POST" && request.body !== void 0 ? { "Content-Type": "application/json" } : {},
300
- ...request.headers ?? {}
301
- };
302
- const init = {
303
- method: request.method,
304
- headers,
305
- ...request.redirect !== void 0 ? { redirect: request.redirect } : {}
306
- };
307
- if (request.method === "POST" && request.body !== void 0) {
308
- init.body = JSON.stringify(request.body);
309
- }
310
- const response = await fetch(
311
- buildUrlWithQueryParams(request.url, request.queryParams),
312
- init
313
- );
314
- const responseHeaders = headersToRecord(response.headers);
315
- if (response.status === 204 || response.status === 205) {
316
- return {
317
- status: response.status,
318
- body: null,
319
- headers: responseHeaders
320
- };
321
- }
322
- if (response.status >= 300 && response.status < 400) {
323
- await response.text();
324
- return {
325
- status: response.status,
326
- body: null,
327
- headers: responseHeaders
328
- };
329
- }
330
- const text = await response.text();
331
- let body;
332
- try {
333
- body = text ? JSON.parse(text) : null;
334
- } catch (_) {
335
- throw new HttpError({
336
- status: response.status,
337
- headers: responseHeaders,
338
- body: text
339
- });
340
- }
341
- return {
342
- status: response.status,
343
- body,
344
- headers: responseHeaders
345
- };
346
- }
347
- function buildUrlWithQueryParams(url, queryParams) {
348
- if (!queryParams) {
349
- return url;
350
- }
351
- const searchParams = new URLSearchParams();
352
- for (const [key, value] of Object.entries(queryParams)) {
353
- if (value === void 0 || value === null) {
354
- continue;
355
- }
356
- if (Array.isArray(value)) {
357
- for (const item of value) {
358
- if (item === void 0 || item === null) {
359
- continue;
360
- }
361
- searchParams.append(key, String(item));
362
- }
363
- continue;
364
- }
365
- searchParams.append(key, String(value));
366
- }
367
- const queryString = searchParams.toString();
368
- if (!queryString) {
369
- return url;
370
- }
371
- return url.includes("?") ? `${url}&${queryString}` : `${url}?${queryString}`;
372
- }
373
- function headersToRecord(headers) {
374
- const record = {};
375
- headers.forEach((value, key) => {
376
- record[key.toLowerCase()] = value;
377
- });
378
- return record;
379
- }
380
-
381
- // src/universal/api/pagination.ts
382
- async function fetchAllPages(fetchPage, baseParams) {
383
- const items = [];
384
- let cursor = null;
385
- do {
386
- const params = {
387
- ...baseParams ?? {},
388
- after: cursor ?? void 0
389
- };
390
- const page = await fetchPage(params);
391
- items.push(...page.data);
392
- cursor = page.startingAfter;
393
- } while (cursor);
394
- return items;
395
- }
396
-
397
- // src/universal/core/shared/utils/crypto.ts
398
- async function sha256(data) {
399
- const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
400
- const buffer = bytes.buffer.slice(
401
- bytes.byteOffset,
402
- bytes.byteOffset + bytes.byteLength
403
- );
404
- return crypto.subtle.digest("SHA-256", buffer);
405
- }
406
- function arrayBufferToBase64Url(buffer, padding = true) {
407
- const bytes = new Uint8Array(buffer);
408
- let binary = "";
409
- for (let i = 0; i < bytes.length; i++) {
410
- binary += String.fromCharCode(bytes[i]);
411
- }
412
- let base64 = btoa(binary);
413
- base64 = base64.replace(/\+/g, "-").replace(/\//g, "_");
414
- if (!padding) {
415
- base64 = base64.replace(/=+$/, "");
416
- }
417
- return base64;
418
- }
419
- function generateSecureRandomBase64Url(byteLength) {
420
- const bytes = new Uint8Array(byteLength);
421
- crypto.getRandomValues(bytes);
422
- const buffer = bytes.buffer;
423
- return arrayBufferToBase64Url(buffer, false);
424
- }
425
- function notBlankStringOrNull(value) {
426
- if (value?.trim()) {
427
- return value;
428
- } else {
429
- return null;
430
- }
431
- }
432
-
433
- // src/universal/types/oauth.ts
434
- var AuthorizationCode = (value) => value;
435
- var CodeVerifier = (value) => value;
436
- var CodeChallenge = (value) => value;
437
- var PKCEState = (value) => value;
438
- var RedirectUri = (value) => value;
439
- var ClientId = (value) => value;
440
- var ClientSecret = (value) => value;
441
-
442
- // src/universal/core/auth/pkce.ts
443
- async function generatePKCEParams(config) {
444
- const state = generateSecureRandomBase64Url(32);
445
- const codeVerifier = generateSecureRandomBase64Url(32);
446
- const codeChallengeRaw = await sha256(codeVerifier);
447
- const codeChallenge = arrayBufferToBase64Url(codeChallengeRaw, false);
448
- return {
449
- clientId: config.clientId,
450
- responseType: "code",
451
- redirectUri: config.redirectUri,
452
- codeChallenge: CodeChallenge(codeChallenge),
453
- codeChallengeMethod: "S256",
454
- state: PKCEState(state),
455
- codeVerifier: CodeVerifier(codeVerifier)
456
- };
457
- }
458
-
459
- // src/universal/types/pagination.ts
460
- var Cursor = (value) => value;
461
- var PaginatedResponse = {
462
- fromDto: (dto, itemMapper) => PaginatedResponse.fromDtoPage(dto, (items) => items.map(itemMapper)),
463
- /**
464
- * For a mapper that decides the page as a whole - one that drops items it
465
- * cannot map, such as `Offer.listFromDto` - rather than item by item. The
466
- * cursors are the wire's either way: dropping an item changes what the
467
- * page holds, not where the next page starts.
468
- */
469
- fromDtoPage: (dto, pageMapper) => ({
470
- data: pageMapper(dto.data),
471
- startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
472
- startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
473
- })
474
- };
475
- var PaginationParams = {
476
- toQueryParams: (params) => {
477
- const queryParams = {};
478
- if (params.after) {
479
- queryParams.starting_after = params.after;
480
- }
481
- if (params.before) {
482
- queryParams.starting_before = params.before;
483
- }
484
- if (params.limit) {
485
- queryParams.limit = params.limit;
486
- }
487
- return queryParams;
488
- }
489
- };
490
-
491
- // src/universal/types/asset.ts
492
- var AssetId = (value) => value;
493
- var AssetCode = (value) => value;
494
- var Asset = {
495
- fromDto: (dto) => ({
496
- id: AssetId(dto.id),
497
- code: AssetCode(dto.code),
498
- name: dto.name,
499
- fractionalDigits: dto.fractional_digits
500
- })
501
- };
502
-
503
- // src/universal/types/errors.ts
504
- var NotImplementedError = class extends Error {
505
- constructor(message = "Not implemented yet") {
506
- super(message);
507
- this.name = "NotImplementedError";
508
- }
509
- };
510
- var NotAuthenticatedError = class extends Error {
511
- constructor(message = "The user is not authenticated. Go through the OAuth flow first!") {
512
- super(message);
513
- this.name = "NotAuthenticatedError";
514
- }
515
- };
516
- var ValidationError = class extends Error {
517
- constructor(message) {
518
- super(message);
519
- this.name = "ValidationError";
520
- }
521
- };
522
- var InvariantError = class extends Error {
523
- constructor(message) {
524
- super(message);
525
- this.name = "InvariantError";
526
- }
527
- };
528
- var MathError = class extends Error {
529
- constructor(message) {
530
- super(message);
531
- this.name = "MathError";
532
- }
533
- };
534
-
535
- // src/universal/core/shared/utils/wire.ts
536
- function unknownTypeError(dto, model) {
537
- const type = dto.type;
538
- throw new ValidationError(
539
- `${model}.type: unknown type ${JSON.stringify(type)}`
540
- );
541
- }
542
- function requiredString(value, field) {
543
- const text = notBlankStringOrNull(value);
544
- if (text === null) {
545
- throw new ValidationError(
546
- `${field}: expected a non-blank string, got ${typeof value === "string" ? "a blank string" : String(value)}`
547
- );
548
- }
549
- return text;
550
- }
551
- function requiredDate(value, field) {
552
- const date = typeof value === "string" ? new Date(value) : null;
553
- if (date === null || Number.isNaN(date.getTime())) {
554
- throw new ValidationError(
555
- `${field}: expected a date, got ${JSON.stringify(value)}`
556
- );
557
- }
558
- return date;
559
- }
560
- function requiredArray(value, field) {
561
- if (!Array.isArray(value)) {
562
- throw new ValidationError(
563
- `${field}: expected an array, got ${typeof value}`
564
- );
565
- }
566
- return value;
567
- }
568
-
569
- // src/universal/types/blockchain/core.ts
570
- var ETHEREUM_CHAINS = {
571
- ethereum_mainnet: true,
572
- ethereum_sepolia: true,
573
- base_mainnet: true,
574
- base_sepolia: true
575
- };
576
- var EthereumChain = (value) => {
577
- if (!Object.keys(ETHEREUM_CHAINS).includes(value)) {
578
- throw new ValidationError(`Unsupported Ethereum chain: "${value}"`);
579
- }
580
- return value;
581
- };
582
- var SOLANA_CHAINS = {
583
- solana_mainnet: true,
584
- solana_devnet: true
585
- };
586
- var SolanaChain = (value) => {
587
- if (!Object.keys(SOLANA_CHAINS).includes(value)) {
588
- throw new ValidationError(`Unsupported Solana chain: "${value}"`);
589
- }
590
- return value;
591
- };
592
- var isChain = (value) => Object.keys(ETHEREUM_CHAINS).includes(value) || Object.keys(SOLANA_CHAINS).includes(value);
593
- var Chain = (value) => {
594
- if (!isChain(value)) {
595
- throw new ValidationError(`Unsupported chain: "${value}"`);
596
- }
597
- return value;
598
- };
599
- var EvmWalletAddress = (value) => value;
600
- var EvmContractAddress = (value) => value;
601
- var HexEncodedTransactionData = (value) => value;
602
- var MAX_ASSET_DECIMALS = 77;
603
- var AssetDecimals = (value) => {
604
- if (!Number.isInteger(value)) {
605
- throw new ValidationError(`Asset decimals must be an integer: ${value}`);
606
- }
607
- if (value < 0 || value > MAX_ASSET_DECIMALS) {
608
- throw new ValidationError(
609
- `Asset decimals out of range [0, ${MAX_ASSET_DECIMALS}]: ${value}`
610
- );
611
- }
612
- return value;
613
- };
614
- var STABLE_DECIMALS = AssetDecimals(6);
615
- var DecimalString = (value) => value;
616
- var MAX_UINT_256 = 2n ** 256n - 1n;
617
- var assertUint256 = (value) => {
618
- if (isUint256(value)) return value;
619
- throw new InvariantError(`Value out of uint256 bounds: ${value}`);
620
- };
621
- var parseUint256 = (value, label) => {
622
- if (isUint256(value)) return value;
623
- throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
624
- };
625
- var isUint256 = (value) => value >= 0n && value <= MAX_UINT_256;
626
- var BlockchainAmount = Object.assign(
627
- (value) => value,
628
- {
629
- add: (a, b) => combineAmounts(a, b, (x, y) => x + y),
630
- sub: (a, b) => combineAmounts(a, b, (x, y) => x - y),
631
- mul: multiplyAmounts,
632
- div: divideAmounts
633
- }
634
- );
635
- function multiplyAmounts(a, b) {
636
- const product = a.raw * b.raw;
637
- return BlockchainAmount({
638
- raw: product / 10n ** BigInt(b.decimals),
639
- decimals: a.decimals
640
- });
641
- }
642
- function divideAmounts(a, b) {
643
- if (b.raw === 0n) {
644
- throw new MathError("Cannot divide a BlockchainAmount by zero");
645
- }
646
- const scaled = a.raw * 10n ** BigInt(b.decimals);
647
- return BlockchainAmount({ raw: scaled / b.raw, decimals: a.decimals });
648
- }
649
- function combineAmounts(a, b, op) {
650
- if (a.decimals !== b.decimals) {
651
- throw new InvariantError(
652
- `Cannot combine BlockchainAmounts with different decimals: ${a.decimals} vs ${b.decimals}`
653
- );
654
- }
655
- const raw = op(a.raw, b.raw);
656
- if (raw < 0n || raw > MAX_UINT_256) {
657
- throw new InvariantError(`BlockchainAmount out of uint256 bounds: ${raw}`);
658
- }
659
- return BlockchainAmount({ raw, decimals: a.decimals });
660
- }
661
- var AssetSymbol = (value) => value;
662
- var StablecoinSymbol = (value) => value;
663
- var KnownAssetSymbol = StablecoinSymbol;
664
- var Bps = (value) => value;
665
-
666
- // src/universal/types/offer.ts
667
- var OfferId = (value) => value;
668
- var OfferSlug = (value) => value;
669
- var OFFER_TYPES = {
670
- "coinlist::token_sale": true,
671
- "superstate::swap": true,
672
- "ondo::swap": true
673
- };
674
- var isOfferType = (value) => Object.keys(OFFER_TYPES).includes(value);
675
- var OfferEditorial = {
676
- /**
677
- * `model` prefixes the field in the error (`'Offer'`, `'OfferDetail'`), so
678
- * the same three checks name the payload that failed them.
679
- */
680
- fromDto: (dto, model) => ({
681
- tagline: requiredString(dto.tagline, `${model}.tagline`),
682
- bannerUrl: requiredString(dto.banner_url, `${model}.banner_url`),
683
- startsAt: requiredDate(dto.starts_at, `${model}.starts_at`)
684
- })
685
- };
686
- var Offer = {
687
- fromDto: (dto) => {
688
- const tokens = requiredArray(dto.tokens, "Offer.tokens");
689
- const base2 = {
690
- id: OfferId(dto.id),
691
- slug: OfferSlug(dto.slug),
692
- endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
693
- tokens: OfferToken.listFromDto(tokens)
694
- };
695
- switch (dto.type) {
696
- case "coinlist::token_sale":
697
- return {
698
- ...base2,
699
- ...OfferEditorial.fromDto(dto, "Offer"),
700
- type: dto.type,
701
- logoUrl: requiredString(dto.logo_url, "Offer.logo_url")
702
- };
703
- case "superstate::swap":
704
- return {
705
- ...base2,
706
- ...OfferEditorial.fromDto(dto, "Offer"),
707
- type: dto.type,
708
- logoUrl: notBlankStringOrNull(dto.logo_url)
709
- };
710
- // `tagline`, `banner_url` and `starts_at` arrive as `null` and are left
711
- // on the wire: copying them would hand every consumer a `startsAt` that
712
- // is 1970 for one variant and a date for the others.
713
- case "ondo::swap":
714
- return {
715
- ...base2,
716
- type: dto.type,
717
- logoUrl: notBlankStringOrNull(dto.logo_url)
718
- };
719
- default:
720
- return unknownTypeError(dto, "Offer");
721
- }
722
- },
723
- /**
724
- * Maps a page of offers, dropping every offer whose `type` this SDK does not
725
- * name. The same reasoning as {@link OfferToken.listFromDto}: a plain `.map`
726
- * would throw out of `fromDto` and, through `PaginatedResponse.fromDto`,
727
- * reject the whole page, so one offer of an unknown type would blank the
728
- * grid for every offer beside it. A single offer fetched by id still
729
- * throws, because there is nothing beside it to keep.
730
- */
731
- listFromDto: (dtos) => dtos.filter((dto) => isOfferType(dto.type)).map(Offer.fromDto)
732
- };
733
- var OfferToken = {
734
- fromDto: (dto) => ({
735
- role: dto.role,
736
- chain: Chain(dto.chain),
737
- address: EvmContractAddress(dto.address)
738
- }),
739
- /**
740
- * Maps an offer's token list, dropping every token on a chain this SDK does
741
- * not name. Frontline's chain registry runs ahead of {@link Chain}, and a
742
- * plain `.map` would throw out of `Offer.fromDto` and, through
743
- * `PaginatedResponse.fromDto`, reject the whole offers page - which is how
744
- * one Base token blanked production's offers list. Dropping costs that
745
- * token's metadata alone: `coinlist.tokens.get` takes an `EthereumChain`,
746
- * so nobody could have looked it up anyway.
747
- *
748
- * Same shape as `TokenMetadata.fromRegistryDto`.
749
- */
750
- listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferToken.fromDto)
751
- };
752
-
753
- // src/universal/types/trading.ts
754
- var Ticker = (value) => value;
755
- var Isin = (value) => value;
756
-
757
- // src/universal/types/offer-detail.ts
758
- var OfferOptionId = (value) => value;
759
- var OfferOptionSlug = (value) => value;
760
- var OfferSwapContract = {
761
- fromDto: (dto) => ({
762
- chain: Chain(dto.chain),
763
- address: EvmContractAddress(dto.address)
764
- })
765
- };
766
- var OfferDetail = {
767
- fromDto: (dto) => {
768
- const fundingAssets = requiredArray(
769
- dto.funding_assets,
770
- "OfferDetail.funding_assets"
771
- );
772
- const options = requiredArray(dto.options, "OfferDetail.options");
773
- const terms = requiredArray(dto.terms, "OfferDetail.terms");
774
- const links = requiredArray(dto.links, "OfferDetail.links");
775
- const faqs = requiredArray(dto.faqs, "OfferDetail.faqs");
776
- const milestones = requiredArray(dto.milestones, "OfferDetail.milestones");
777
- const tokens = requiredArray(dto.tokens, "OfferDetail.tokens");
778
- const isin = notBlankStringOrNull(dto.isin);
779
- const ticker = notBlankStringOrNull(dto.ticker);
780
- const base2 = {
781
- id: OfferId(dto.id),
782
- slug: OfferSlug(dto.slug),
783
- name: dto.name,
784
- asset: Asset.fromDto(dto.asset),
785
- fundingAssets: fundingAssets.map(Asset.fromDto),
786
- tokens: OfferToken.listFromDto(tokens),
787
- about: notBlankStringOrNull(dto.about),
788
- category: dto.category,
789
- issuer: notBlankStringOrNull(dto.issuer),
790
- isin: isin === null ? null : Isin(isin),
791
- ticker: ticker === null ? null : Ticker(ticker),
792
- instrumentType: notBlankStringOrNull(dto.instrument_type),
793
- listingVenue: notBlankStringOrNull(dto.listing_venue),
794
- endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
795
- faqs: faqs.map(FaqItem.fromDto),
796
- links: links.map(Link.fromDto),
797
- milestones: milestones.map(Milestone.fromDto),
798
- options: options.map(OfferOption.fromDto),
799
- terms: terms.map(TermItem.fromDto)
800
- };
801
- switch (dto.type) {
802
- case "coinlist::token_sale":
803
- return {
804
- ...base2,
805
- ...OfferEditorial.fromDto(dto, "OfferDetail"),
806
- type: dto.type,
807
- logoUrl: requiredString(dto.logo_url, "OfferDetail.logo_url")
808
- };
809
- case "superstate::swap":
810
- return {
811
- ...base2,
812
- ...OfferEditorial.fromDto(dto, "OfferDetail"),
813
- type: dto.type,
814
- logoUrl: notBlankStringOrNull(dto.logo_url)
815
- };
816
- // `tagline`, `banner_url` and `starts_at` arrive as `null` and are left
817
- // on the wire, as in `Offer.fromDto`.
818
- case "ondo::swap":
819
- return {
820
- ...base2,
821
- type: dto.type,
822
- logoUrl: notBlankStringOrNull(dto.logo_url),
823
- swapContracts: requiredArray(
824
- dto.swap_contracts,
825
- "OfferDetail.swap_contracts"
826
- ).map(OfferSwapContract.fromDto)
827
- };
828
- default:
829
- return unknownTypeError(dto, "OfferDetail");
830
- }
831
- }
832
- };
833
- var OfferOption = {
834
- fromDto: (dto) => ({
835
- id: OfferOptionId(dto.id),
836
- slug: OfferOptionSlug(dto.slug),
837
- bidIncrement: dto.bid_increment,
838
- floorPriceUsd: dto.floor_price_usd,
839
- minimumPurchaseUsd: dto.minimum_purchase_usd,
840
- priceUsd: dto.price_usd,
841
- saleAgreementUrl: notBlankStringOrNull(dto.sale_agreement_url),
842
- totalTokenSupply: dto.total_token_supply
843
- })
844
- };
845
- var FaqItem = {
846
- fromDto: (dto) => ({
847
- question: notBlankStringOrNull(dto.question),
848
- answer: notBlankStringOrNull(dto.answer)
849
- })
850
- };
851
- var Link = {
852
- fromDto: (dto) => ({
853
- label: notBlankStringOrNull(dto.label),
854
- url: notBlankStringOrNull(dto.url)
855
- })
856
- };
857
- var TermItem = {
858
- fromDto: (dto) => ({
859
- key: notBlankStringOrNull(dto.key),
860
- value: notBlankStringOrNull(dto.value)
861
- })
862
- };
863
- var Milestone = {
864
- fromDto: (dto) => ({
865
- name: notBlankStringOrNull(dto.name),
866
- schedule: notBlankStringOrNull(dto.schedule),
867
- status: dto.status
868
- })
869
- };
870
-
871
- // src/universal/types/providers/coin-list/token-sale.ts
872
- var ParticipationId = (value) => value;
873
- var Blockchain = (value) => value;
874
- var WalletAddress = (value) => value;
875
- var ParticipationsPaginationParams = {
876
- toQueryParams: (params) => {
877
- const queryParams = PaginationParams.toQueryParams(params);
878
- if (params.offerId) {
879
- queryParams["filters[0][field]"] = "offer_id";
880
- queryParams["filters[0][op]"] = "==";
881
- queryParams["filters[0][value]"] = params.offerId;
882
- }
883
- return queryParams;
884
- }
885
- };
886
- var Participation = {
887
- /** Maps API DTO shape into the SDK participation domain model. */
888
- fromDto: (dto) => {
889
- const walletAddress = notBlankStringOrNull(dto.wallet_address);
890
- return {
891
- id: ParticipationId(dto.id),
892
- offerId: OfferId(dto.offer_id),
893
- offerOptionId: OfferOptionId(dto.offer_option_id),
894
- status: dto.status,
895
- amount: dto.amount,
896
- displayAmount: dto.amount_string,
897
- asset: Asset.fromDto(dto.asset),
898
- chain: Blockchain(dto.chain),
899
- insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
900
- updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
901
- walletAddress: walletAddress ? WalletAddress(walletAddress) : null
902
- };
903
- }
904
- };
905
- var CreateParticipationParams = {
906
- /** Maps participation creation params into API DTO payload. */
907
- toDto: (params) => ({
908
- offer_id: params.offerId,
909
- offer_option_id: params.offerOptionId,
910
- chain: params.chain,
911
- wallet_address: params.walletAddress,
912
- amount: params.amount,
913
- asset_id: params.assetId,
914
- approval_transaction_hash: params.approvalTransactionHash
915
- })
916
- };
917
-
918
- // src/universal/api/frontline/providers/coin-list/token-sale.ts
919
- async function fetchParticipations(api, offerId) {
920
- return fetchAllPages(
921
- (params) => fetchParticipationsPage(api, params),
922
- { offerId }
923
- );
924
- }
925
- async function fetchParticipationsPage(api, params) {
926
- const pageDto = await api.send({
927
- method: "GET",
928
- url: "/v1/participations",
929
- queryParams: ParticipationsPaginationParams.toQueryParams(params),
930
- attributes: Attributes.protected()
931
- });
932
- return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
933
- }
934
- async function fetchParticipation(api, id) {
935
- const dto = await api.send({
936
- method: "GET",
937
- url: `/v1/participations/${id}`,
938
- attributes: Attributes.protected()
939
- });
940
- return Participation.fromDto(dto);
941
- }
942
- async function createParticipation(api, params) {
943
- const dto = await api.send({
944
- method: "POST",
945
- url: "/v1/participations",
946
- body: CreateParticipationParams.toDto(params),
947
- attributes: Attributes.protected()
948
- });
949
- return Participation.fromDto(dto);
950
- }
951
-
952
- // src/universal/core/shared/observability/log-cause.ts
953
- var import_viem = require("viem");
954
- function classifyLogCause(error) {
955
- if (error instanceof HttpError) {
956
- return httpCause(error);
957
- }
958
- if (error instanceof ValidationError) {
959
- return { type: "validation", message: error.message };
960
- }
961
- if (error instanceof InvariantError) {
962
- return { type: "invariant", message: error.message };
963
- }
964
- if (error instanceof MathError) {
965
- return { type: "math", message: error.message };
966
- }
967
- if (error instanceof NotAuthenticatedError) {
968
- return { type: "not-authenticated" };
969
- }
970
- if (error instanceof NotImplementedError) {
971
- return { type: "not-implemented" };
972
- }
973
- if (error instanceof import_viem.BaseError) {
974
- const http = error.walk((e) => e instanceof HttpError);
975
- if (http instanceof HttpError) {
976
- return httpCause(http);
977
- }
978
- return { type: "rpc", reason: rpcFailureReason(error) };
979
- }
980
- return { type: "generic-error", name: errorName(error) };
981
- }
982
- function rpcFailureReason(error) {
983
- if (error.walk((e) => e instanceof import_viem.ContractFunctionRevertedError)) {
984
- return "reverted";
985
- }
986
- if (error.walk((e) => e instanceof import_viem.RpcError)) {
987
- return "node-rejected";
988
- }
989
- if (error.walk(
990
- (e) => e instanceof import_viem.HttpRequestError || e instanceof import_viem.WebSocketRequestError || e instanceof import_viem.SocketClosedError || e instanceof import_viem.TimeoutError
991
- )) {
992
- return "transport";
993
- }
994
- if (error instanceof import_viem.ContractFunctionExecutionError) {
995
- return "malformed-response";
996
- }
997
- return "unknown";
998
- }
999
- function describeErrorUnredacted(error) {
1000
- if (error instanceof HttpError) {
1001
- return describeHttpErrorRedacted(error);
1002
- }
1003
- if (error instanceof Error) {
1004
- return `${error.name}: ${error.message}`;
1005
- }
1006
- return `thrown non-error: ${stringifyUnredacted(error)}`;
1007
- }
1008
- function stringifyUnredacted(value) {
1009
- if (value === void 0) return "";
1010
- try {
1011
- return JSON.stringify(
1012
- value,
1013
- (_key, item) => typeof item === "bigint" ? `${item}` : item
1014
- ) ?? String(value);
1015
- } catch (_) {
1016
- return "<unserializable>";
1017
- }
1018
- }
1019
- function describeHttpErrorRedacted(error) {
1020
- const code = apiErrorCode(error);
1021
- const status = error.response.status;
1022
- return code === null ? `HttpError ${status}` : `HttpError ${status} (${code})`;
1023
- }
1024
- function errorName(error) {
1025
- return error instanceof Error ? error.name : `non-error ${typeof error}`;
1026
- }
1027
- function httpCause(error) {
1028
- return {
1029
- type: "http",
1030
- requestId: error.requestId,
1031
- status: error.response.status,
1032
- code: apiErrorCode(error),
1033
- eventId: apiErrorEventId(error)
1034
- };
1035
- }
1036
- function apiErrorEventId(error) {
1037
- const body = error.response.body;
1038
- if (typeof body !== "object" || body === null) return null;
1039
- const eventId = body.event_id;
1040
- return typeof eventId === "string" ? eventId : null;
1041
- }
1042
-
1043
- // src/universal/core/shared/observability/internal-logger.ts
1044
- function internalLogger(logger, scope) {
1045
- return logger ? scopedLogger(logger, scope, {}) : noopInternalLogger;
1046
- }
1047
- var LEVEL_RANK = {
1048
- none: 0,
1049
- error: 1,
1050
- warn: 2,
1051
- info: 3,
1052
- debug: 4
1053
- };
1054
- function scopedLogger(logger, scope, bindings) {
1055
- const admits = (level) => LEVEL_RANK[logger.level()] >= LEVEL_RANK[level];
1056
- const safe = (event) => ({
1057
- msg: event.msg,
1058
- scope,
1059
- bindings,
1060
- fields: event.fields ?? {},
1061
- ...event.cause === void 0 ? {} : { cause: event.cause }
1062
- });
1063
- const unredacted = (event) => ({
1064
- msg: event.msg,
1065
- scope,
1066
- bindings,
1067
- fields: event.fields ?? {}
1068
- });
1069
- const self = {
1070
- child: (binding) => scopedLogger(logger, scope, { ...bindings, ...binding }),
1071
- debug: (event) => {
1072
- if (admits("debug")) logger.debug(() => unredacted(event()));
1073
- },
1074
- info: (event) => {
1075
- if (admits("info")) logger.info(() => safe(event()));
1076
- },
1077
- warn: (event) => {
1078
- if (admits("warn")) logger.warn(() => safe(event()));
1079
- },
1080
- error: (event) => {
1081
- if (admits("error")) logger.error(() => safe(event()));
1082
- },
1083
- failure: (event, error) => {
1084
- if (admits("debug"))
1085
- logger.debug(() => unredacted(verbatim(event(), error)));
1086
- if (admits("error")) logger.error(() => safe(classified(event(), error)));
1087
- },
1088
- warning: (event, error) => {
1089
- if (admits("debug"))
1090
- logger.debug(() => unredacted(verbatim(event(), error)));
1091
- if (admits("warn")) logger.warn(() => safe(classified(event(), error)));
1092
- },
1093
- wrap: async (op, params, run) => {
1094
- const opLog = self.child({ op });
1095
- opLog.debug(() => ({ msg: "call", fields: { params } }));
1096
- try {
1097
- return await run();
1098
- } catch (error) {
1099
- opLog.failure(() => ({ msg: "call failed" }), error);
1100
- throw error;
1101
- }
1102
- }
1103
- };
1104
- return self;
1105
- }
1106
- function verbatim(event, error) {
1107
- return {
1108
- msg: event.msg,
1109
- fields: { ...event.fields, error: describeErrorUnredacted(error) }
1110
- };
1111
- }
1112
- function classified(event, error) {
1113
- return { ...event, cause: event.cause ?? classifyLogCause(error) };
1114
- }
1115
- var noopInternalLogger = {
1116
- child: () => noopInternalLogger,
1117
- debug: () => void 0,
1118
- info: () => void 0,
1119
- warn: () => void 0,
1120
- error: () => void 0,
1121
- failure: () => void 0,
1122
- warning: () => void 0,
1123
- wrap: (_op, _params, run) => run()
1124
- };
1125
-
1126
- // src/universal/core/checkout/coin-list/token-sale-namespace.ts
1127
- var CoinListTokenSaleNamespaceImpl = class {
1128
- constructor(ctx) {
1129
- this.ctx = ctx;
1130
- this.log = internalLogger(ctx.logger, "TOKEN_SALE");
1131
- }
1132
- async list(offerId) {
1133
- return this.log.wrap("list", offerId, async () => {
1134
- await this.ctx.ensureUserAuthenticated();
1135
- return fetchParticipations(this.ctx.api, offerId);
1136
- });
1137
- }
1138
- async listPage(params) {
1139
- return this.log.wrap("listPage", params, async () => {
1140
- await this.ctx.ensureUserAuthenticated();
1141
- return fetchParticipationsPage(this.ctx.api, params);
1142
- });
1143
- }
1144
- async get(id) {
1145
- return this.log.wrap("get", id, async () => {
1146
- await this.ctx.ensureUserAuthenticated();
1147
- return fetchParticipation(this.ctx.api, id);
1148
- });
1149
- }
1150
- async createParticipation(params) {
1151
- return this.log.wrap("createParticipation", params, async () => {
1152
- await this.ctx.ensureUserAuthenticated();
1153
- return createParticipation(this.ctx.api, params);
1154
- });
1155
- }
1156
- };
1157
-
1158
- // src/universal/core/shared/blockchain/token-registry.ts
1159
- var USDC_SYMBOL = StablecoinSymbol("USDC");
1160
- var USDC = {
1161
- name: "USD Coin",
1162
- symbol: USDC_SYMBOL,
1163
- decimals: AssetDecimals(6)
1164
- };
1165
- var USDT_SYMBOL = StablecoinSymbol("USDT");
1166
- var USDT = {
1167
- name: "Tether USD",
1168
- symbol: USDT_SYMBOL,
1169
- decimals: AssetDecimals(6)
1170
- };
1171
- var USDC_ADDRESSES = {
1172
- ethereum_mainnet: EvmContractAddress(
1173
- "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
1174
- ),
1175
- ethereum_sepolia: EvmContractAddress(
1176
- "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"
1177
- ),
1178
- base_mainnet: EvmContractAddress(
1179
- "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
1180
- ),
1181
- base_sepolia: EvmContractAddress(
1182
- "0x036CbD53842c5426634e7929541eC2318f3dCF7e"
1183
- )
1184
- };
1185
- var USDT_ADDRESSES = {
1186
- ethereum_mainnet: EvmContractAddress(
1187
- "0xdac17f958d2ee523a2206206994597c13d831ec7"
1188
- ),
1189
- ethereum_sepolia: EvmContractAddress(
1190
- "0x7169D38820dfd117C3FA1f22a697dBA58d90BA06"
1191
- ),
1192
- base_mainnet: EvmContractAddress(
1193
- "0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2"
1194
- ),
1195
- base_sepolia: null
1196
- };
1197
- var TOKEN_REGISTRY = {
1198
- erc20: (symbol) => {
1199
- switch (symbol) {
1200
- case "USDC":
1201
- return USDC;
1202
- case "USDT":
1203
- return USDT;
1204
- default:
1205
- throw new InvariantError(`Unknown asset symbol: ${symbol}`);
1206
- }
1207
- },
1208
- /**
1209
- * USDC's contract on `chain`. USDC is deployed on every chain the SDK
1210
- * models, so the table is total and the answer is never `null`.
1211
- */
1212
- usdcAddress: (chain) => USDC_ADDRESSES[chain],
1213
- /**
1214
- * USDT's contract on `chain`, or `null` where Tether publishes none —
1215
- * Base Sepolia today. The honest answer, never a fake address a balance
1216
- * read would call.
1217
- */
1218
- usdtAddress: (chain) => USDT_ADDRESSES[chain]
1219
- };
1220
-
1221
- // src/universal/core/checkout/ondo/constants.ts
1222
- var ONDO_POLL_INTERVAL_MS = 15e3;
1223
- var ONDO_QUOTE_MAX_TTL_MS = 15e3;
1224
- var DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE = DecimalString("1000");
1225
- var ONDO_SETTLEMENT_ASSET = USDC_SYMBOL;
1226
- var DEFAULT_ONDO_SELL_TOKENS_TO_COMPUTE_PRICE = 1;
1227
- var ONDO_SUPPORTED_INPUT_ASSETS = [
1228
- USDC_SYMBOL
1229
- ];
1230
-
1231
- // src/universal/core/checkout/ondo/math.ts
1232
- function computeOndoBuyPrice(transaction) {
1233
- const { notionalValue, receiveOutputAmount } = transaction;
1234
- return pricePerShare({
1235
- usd: notionalValue,
1236
- shares: receiveOutputAmount
1237
- });
1238
- }
1239
- function computeOndoSellPrice(transaction) {
1240
- const { expected, spendInputAmount } = transaction;
1241
- return pricePerShare({
1242
- usd: grossProceeds(expected),
1243
- shares: spendInputAmount
1244
- });
1245
- }
1246
- function ondoQuoteOfferDeadline(expiresAt, nowMs = Date.now()) {
1247
- return new Date(Math.min(expiresAt.getTime(), nowMs + ONDO_QUOTE_MAX_TTL_MS));
1248
- }
1249
- function grossProceeds(expected) {
1250
- const raw = expected.quantity.raw + expected.fee.raw;
1251
- if (raw > MAX_UINT_256) {
1252
- throw new MathError(`Ondo sell proceeds: out of uint256 bounds (${raw})`);
1253
- }
1254
- return BlockchainAmount.add(expected.quantity, expected.fee);
1255
- }
1256
- function pricePerShare({
1257
- usd,
1258
- shares
1259
- }) {
1260
- const price = BlockchainAmount.div(usd, shares);
1261
- return BlockchainAmount({
1262
- raw: assertPriceFits(price.raw),
1263
- decimals: price.decimals
1264
- });
1265
- }
1266
- function assertPriceFits(raw) {
1267
- try {
1268
- return assertUint256(raw);
1269
- } catch {
1270
- throw new MathError(`Ondo price: out of uint256 bounds (${raw})`);
1271
- }
1272
- }
1273
-
1274
- // src/universal/core/checkout/ondo/not-tradable.ts
1275
- var ONDO_NOT_TRADABLE_CODE = "not_tradable";
1276
- function isOndoNotTradableError(error) {
1277
- return apiErrorCode(error) === ONDO_NOT_TRADABLE_CODE;
1278
- }
1279
-
1280
- // src/universal/core/shared/blockchain/formatters.ts
1281
- var import_viem2 = require("viem");
1282
-
1283
- // src/universal/types/blockchain/ui.ts
1284
- var FormattedAmountUi = (value) => value;
1285
- var FormattedPercentUi = (value) => value;
1286
- var TxExplorerUrl = (value) => value;
1287
- var ShortenedWalletAddress = (value) => value;
1288
- var FormattedAmountAssetUi = (value) => value;
1289
- var AssetIconUrl = (value) => value;
1290
-
1291
- // src/universal/core/shared/blockchain/formatters.ts
1292
- function shortenAddress(address) {
1293
- const short = address.length > 10 ? `${address.slice(0, 6)}\u2026${address.slice(-4)}` : address;
1294
- return ShortenedWalletAddress(short);
1295
- }
1296
- function formatAmount(amount, locale, options) {
1297
- const decimal = formatRawAmount(amount);
1298
- let [integerPart, fractionPart = ""] = decimal.split(".");
1299
- const maxFractionDigits = options?.maxFractionDigits;
1300
- const minFractionDigits = Math.min(
1301
- options?.minFractionDigits ?? (maxFractionDigits !== void 0 ? maxFractionDigits : 2),
1302
- maxFractionDigits ?? amount.decimals,
1303
- amount.decimals
1304
- );
1305
- if (maxFractionDigits !== void 0 && fractionPart.length > maxFractionDigits) {
1306
- ({ integerPart, fractionPart } = roundFractionHalfUp(
1307
- integerPart,
1308
- fractionPart,
1309
- maxFractionDigits
1310
- ));
1311
- }
1312
- const trimmed = fractionPart.replace(/0+$/, "");
1313
- const fraction = trimmed.padEnd(minFractionDigits, "0");
1314
- const integerFormatted = BigInt(integerPart).toLocaleString(locale);
1315
- if (minFractionDigits === 0 && fraction === "") {
1316
- return FormattedAmountUi(integerFormatted);
1317
- }
1318
- const decimalSeparator = new Intl.NumberFormat(locale).formatToParts(1.1).find((p) => p.type === "decimal")?.value ?? ".";
1319
- return FormattedAmountUi(`${integerFormatted}${decimalSeparator}${fraction}`);
1320
- }
1321
- function roundFractionHalfUp(integerPart, fractionPart, maxFractionDigits) {
1322
- if (fractionPart.length <= maxFractionDigits) {
1323
- return { integerPart, fractionPart };
1324
- }
1325
- if (maxFractionDigits === 0) {
1326
- const roundUp = fractionPart[0] >= "5";
1327
- const integer = BigInt(integerPart) + (roundUp ? 1n : 0n);
1328
- return { integerPart: integer.toString(), fractionPart: "" };
1329
- }
1330
- const trimmed = fractionPart.slice(0, maxFractionDigits);
1331
- if (fractionPart[maxFractionDigits] < "5") {
1332
- return { integerPart, fractionPart: trimmed };
1333
- }
1334
- const digits = trimmed.split("").map((digit) => Number.parseInt(digit, 10));
1335
- let carry = 1;
1336
- for (let i = digits.length - 1; i >= 0 && carry > 0; i -= 1) {
1337
- const sum = digits[i] + carry;
1338
- if (sum === 10) {
1339
- digits[i] = 0;
1340
- carry = 1;
1341
- } else {
1342
- digits[i] = sum;
1343
- carry = 0;
1344
- }
1345
- }
1346
- return {
1347
- integerPart: carry > 0 ? (BigInt(integerPart) + 1n).toString() : integerPart,
1348
- fractionPart: digits.join("")
1349
- };
1350
- }
1351
- function formatRawAmount(amount) {
1352
- return (0, import_viem2.formatUnits)(amount.raw, amount.decimals);
1353
- }
1354
- function formatCompactAmount(amount, locale) {
1355
- const value = Number(formatRawAmount(amount));
1356
- const formatted = new Intl.NumberFormat(locale, {
1357
- notation: "compact",
1358
- maximumFractionDigits: 2
1359
- }).format(value);
1360
- return FormattedAmountUi(formatted);
1361
- }
1362
- function formatBpsAsPercent(bps, locale) {
1363
- const whole = bps / 100n;
1364
- const fraction = bps % 100n;
1365
- const wholeFormatted = whole.toLocaleString(locale);
1366
- const decimalSeparator = new Intl.NumberFormat(locale).formatToParts(1.1).find((p) => p.type === "decimal")?.value ?? ".";
1367
- if (fraction === 0n) {
1368
- return FormattedPercentUi(`${wholeFormatted}%`);
1369
- }
1370
- const fractionFormatted = fraction.toString().padStart(2, "0").replace(/0+$/, "");
1371
- return FormattedPercentUi(
1372
- `${wholeFormatted}${decimalSeparator}${fractionFormatted}%`
1373
- );
1374
- }
1375
- function usdAmount(amount) {
1376
- return FormattedAmountAssetUi(`$${amount}`);
1377
- }
1378
- function assetAmount(amount, symbol) {
1379
- return FormattedAmountAssetUi(`${amount} ${symbol}`);
1380
- }
1381
- var NA_AMOUNT_ASSET_UI = FormattedAmountAssetUi("-");
1382
- var SHARE_MAX_FRACTION_DIGITS = AssetDecimals(6);
1383
- var SHARE_MIN_FRACTION_DIGITS = AssetDecimals(2);
1384
- function formatShareAmount(amount, locale) {
1385
- return formatAmount(amount, locale, {
1386
- maxFractionDigits: SHARE_MAX_FRACTION_DIGITS,
1387
- minFractionDigits: SHARE_MIN_FRACTION_DIGITS
1388
- });
1389
- }
1390
- var USD_FRACTION_DIGITS = AssetDecimals(2);
1391
- function formattedUsdPrice(amount, locale) {
1392
- if (!amount) return NA_AMOUNT_ASSET_UI;
1393
- return usdAmount(
1394
- formatAmount(amount, locale, { maxFractionDigits: USD_FRACTION_DIGITS })
1395
- );
1396
- }
1397
-
1398
- // src/universal/core/shared/blockchain/chain.ts
1399
- var import_chains = require("viem/chains");
1400
- var VIEM_CHAINS = {
1401
- ethereum_mainnet: import_chains.mainnet,
1402
- ethereum_sepolia: import_chains.sepolia,
1403
- base_mainnet: import_chains.base,
1404
- base_sepolia: import_chains.baseSepolia
1405
- };
1406
- function viemChain(chain) {
1407
- return VIEM_CHAINS[chain];
1408
- }
1409
- function getChainId(chain) {
1410
- return VIEM_CHAINS[chain].id;
1411
- }
1412
- function chainFromId(chainId) {
1413
- const chains = Object.keys(VIEM_CHAINS);
1414
- const chain = chains.find((c) => String(VIEM_CHAINS[c].id) === chainId);
1415
- if (!chain) {
1416
- throw new ValidationError(`Unsupported EIP-155 chain id: "${chainId}"`);
1417
- }
1418
- return chain;
1419
- }
1420
- function getNetworkName(chain) {
1421
- switch (chain) {
1422
- case "ethereum_mainnet":
1423
- return "Ethereum";
1424
- case "ethereum_sepolia":
1425
- return "Ethereum Sepolia";
1426
- case "base_mainnet":
1427
- return "Base";
1428
- case "base_sepolia":
1429
- return "Base Sepolia";
1430
- default: {
1431
- const _exhaustive = chain;
1432
- return _exhaustive;
1433
- }
1434
- }
1435
- }
1436
- function txExplorerUrl(chain, txHash) {
1437
- return TxExplorerUrl(`${explorerBaseUrl(chain)}/tx/${txHash}`);
1438
- }
1439
- function explorerBaseUrl(chain) {
1440
- switch (chain) {
1441
- case "ethereum_mainnet":
1442
- return "https://etherscan.io";
1443
- case "ethereum_sepolia":
1444
- return "https://sepolia.etherscan.io";
1445
- case "base_mainnet":
1446
- return "https://basescan.org";
1447
- case "base_sepolia":
1448
- return "https://sepolia-explorer.base.org";
1449
- default: {
1450
- const _exhaustive = chain;
1451
- return _exhaustive;
1452
- }
1453
- }
1454
- }
1455
-
1456
- // src/universal/core/shared/blockchain/math.ts
1457
- var import_viem3 = require("viem");
1458
- function blockchainAmountFromRawOrThrow({
1459
- label,
1460
- raw,
1461
- decimals
1462
- }) {
1463
- const trimmed = raw.trim();
1464
- if (trimmed === "") {
1465
- throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
1466
- }
1467
- let value;
1468
- try {
1469
- value = BigInt(trimmed);
1470
- } catch {
1471
- throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
1472
- }
1473
- try {
1474
- return BlockchainAmount({ raw: assertUint256(value), decimals });
1475
- } catch {
1476
- throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
1477
- }
1478
- }
1479
- function parseBlockchainAmount(amount, decimals) {
1480
- const trimmed = amount.trim();
1481
- if (trimmed === "") return { valid: false, reason: { type: "empty" } };
1482
- if (trimmed.startsWith("-")) {
1483
- return { valid: false, reason: { type: "negative" } };
1484
- }
1485
- if (/[eE]/.test(trimmed)) {
1486
- return { valid: false, reason: { type: "invalid-format" } };
1487
- }
1488
- if (trimmed === ".") {
1489
- return { valid: false, reason: { type: "invalid-format" } };
1490
- }
1491
- const normalised = trimmed.replace(/^\./, "0.").replace(/\.$/, "");
1492
- if (!/^\d+(\.\d+)?$/.test(normalised)) {
1493
- return { valid: false, reason: { type: "invalid-format" } };
1494
- }
1495
- const [, fraction = ""] = normalised.split(".");
1496
- if (fraction.length > decimals) {
1497
- return {
1498
- valid: false,
1499
- reason: { type: "too-many-decimals", maxDecimals: decimals }
1500
- };
1501
- }
1502
- try {
1503
- const raw = (0, import_viem3.parseUnits)(normalised, decimals);
1504
- if (raw > MAX_UINT_256) {
1505
- return { valid: false, reason: { type: "overflow" } };
1506
- }
1507
- return {
1508
- valid: true,
1509
- amount: BlockchainAmount({ raw, decimals })
1510
- };
1511
- } catch {
1512
- return { valid: false, reason: { type: "invalid-format" } };
1513
- }
1514
- }
1515
-
1516
- // src/universal/types/providers/ondo/ondo.ts
1517
- var OndoTradingStatus = {
1518
- fromDto: (dto) => {
1519
- if (!dto.tradable) return { type: "not-tradable", side: dto.side };
1520
- return {
1521
- type: "tradable",
1522
- side: dto.side,
1523
- grossMaxTokens: decimalOrNull(dto.gross_max_tokens),
1524
- grossMaxNotionalValue: decimalOrNull(dto.gross_max_notional_value),
1525
- grossMaxActiveNotionalValue: decimalOrNull(
1526
- dto.gross_max_active_notional_value
1527
- )
1528
- };
1529
- }
1530
- };
1531
- var decimalOrNull = (value) => value === null ? null : DecimalString(value);
1532
- var OndoQuote = {
1533
- fromDto: (dto) => {
1534
- const assetDecimals = AssetDecimals(dto.asset_decimals);
1535
- return {
1536
- chain: chainFromId(dto.chain_id),
1537
- ticker: Ticker(dto.ticker),
1538
- assetAddress: EvmContractAddress(dto.asset_address),
1539
- asset: {
1540
- name: dto.ticker,
1541
- symbol: AssetSymbol(dto.symbol),
1542
- decimals: assetDecimals
1543
- },
1544
- side: dto.side,
1545
- tokenBaseUnits: blockchainAmountFromRawOrThrow({
1546
- label: "tokenBaseUnits",
1547
- raw: dto.token_base_units,
1548
- decimals: assetDecimals
1549
- }),
1550
- price: DecimalString(dto.price)
1551
- };
1552
- }
1553
- };
1554
- var OndoBuyTransaction = {
1555
- fromDto: (dto) => {
1556
- const spendDecimals = AssetDecimals(dto.spend_input_decimals);
1557
- const outputDecimals = AssetDecimals(dto.receive_output_decimals);
1558
- return {
1559
- ...parseSwapCore(dto, spendDecimals),
1560
- side: "buy",
1561
- fee: blockchainAmountFromRawOrThrow({
1562
- label: "fee",
1563
- raw: dto.fee,
1564
- decimals: spendDecimals
1565
- }),
1566
- notionalValue: blockchainAmountFromRawOrThrow({
1567
- label: "notional_value",
1568
- raw: dto.notional_value,
1569
- decimals: spendDecimals
1570
- }),
1571
- receiveOutputAmount: parsePositiveAmount({
1572
- label: "receive_output_amount",
1573
- raw: dto.receive_output_amount,
1574
- decimals: outputDecimals,
1575
- // A transaction that yields nothing is not one to sign - the user
1576
- // would pay the deposit and receive no asset - and frontline refuses
1577
- // to emit one. A zero here is a changed encoding, not a small order.
1578
- // Rejecting it at the boundary is also what lets `computeOndoBuyPrice`
1579
- // divide by it without a fallible result: the failure surfaces as the
1580
- // data hook's ERROR state rather than as a division during render.
1581
- reason: "a buy that yields nothing is not fillable"
1582
- })
1583
- };
1584
- }
1585
- };
1586
- var OndoSellTransaction = {
1587
- fromDto: (dto) => {
1588
- const spendDecimals = AssetDecimals(dto.spend_input_decimals);
1589
- const outputDecimals = AssetDecimals(dto.receive_output_decimals);
1590
- const expectedQuantity = parsePositiveAmount({
1591
- label: "expected_quantity",
1592
- raw: dto.expected_quantity,
1593
- decimals: outputDecimals,
1594
- reason: "a sale that yields nothing is not fillable"
1595
- });
1596
- return {
1597
- ...parseSwapCore(dto, spendDecimals),
1598
- side: "sell",
1599
- expected: {
1600
- quantity: expectedQuantity,
1601
- fee: blockchainAmountFromRawOrThrow({
1602
- label: "expected_fee",
1603
- raw: dto.expected_fee,
1604
- decimals: outputDecimals
1605
- })
1606
- },
1607
- minimum: {
1608
- quantity: parseMinimumQuantity(
1609
- dto.minimum_quantity,
1610
- outputDecimals,
1611
- expectedQuantity
1612
- ),
1613
- fee: blockchainAmountFromRawOrThrow({
1614
- label: "minimum_fee",
1615
- raw: dto.minimum_fee,
1616
- decimals: outputDecimals
1617
- })
1618
- }
1619
- };
1620
- }
1621
- };
1622
- function parseSwapCore(dto, spendDecimals) {
1623
- return {
1624
- tx: {
1625
- to: EvmContractAddress(dto.to),
1626
- data: HexEncodedTransactionData(dto.data)
1627
- },
1628
- expiresAt: parseExpiresAt(dto.expires_at),
1629
- spendInputAmount: parsePositiveAmount({
1630
- label: "spend_input_amount",
1631
- raw: dto.spend_input_amount,
1632
- decimals: spendDecimals,
1633
- // A transaction that takes nothing from the wallet is not one to sign:
1634
- // it would settle one leg of a trade and skip the other. Frontline
1635
- // refuses an `amount` of zero whichever way the trade runs, so this is a
1636
- // changed encoding rather than a small order.
1637
- //
1638
- // Guarded on both sides rather than on the sale alone, because which
1639
- // amount becomes the divisor in the price flips with the direction: a
1640
- // guard placed by that would be a rule about the arithmetic rather than
1641
- // about the trade.
1642
- reason: "a swap that spends nothing is not fillable"
1643
- })
1644
- };
1645
- }
1646
- function parseMinimumQuantity(raw, decimals, expectedQuantity) {
1647
- const amount = parsePositiveAmount({
1648
- label: "minimum_quantity",
1649
- raw,
1650
- decimals,
1651
- reason: "a floor of zero guarantees nothing"
1652
- });
1653
- if (amount.raw > expectedQuantity.raw) {
1654
- throw new ValidationError(
1655
- `minimum_quantity: must not exceed expected_quantity ("${raw}" > "${expectedQuantity.raw}")`
1656
- );
1657
- }
1658
- return amount;
1659
- }
1660
- function parsePositiveAmount({
1661
- label,
1662
- raw,
1663
- decimals,
1664
- reason
1665
- }) {
1666
- const amount = blockchainAmountFromRawOrThrow({ label, raw, decimals });
1667
- if (amount.raw <= 0n) {
1668
- throw new ValidationError(
1669
- `${label}: must be greater than zero ("${raw}") - ${reason}`
1670
- );
1671
- }
1672
- return amount;
1673
- }
1674
- function parseExpiresAt(value) {
1675
- const date = new Date(value);
1676
- if (Number.isNaN(date.getTime())) {
1677
- throw new ValidationError(`expires_at: not a date ("${value}")`);
1678
- }
1679
- return date;
1680
- }
1681
-
1682
- // src/universal/api/frontline/providers/ondo/ondo.ts
1683
- async function getOndoTradingStatus(api, params) {
1684
- const dto = await api.send({
1685
- method: "GET",
1686
- url: "/v1/ondo/swap/trading-status",
1687
- queryParams: { symbol: params.symbol, side: params.side },
1688
- attributes: Attributes.protected()
1689
- });
1690
- return OndoTradingStatus.fromDto(dto);
1691
- }
1692
- async function getOndoQuote(api, params) {
1693
- const dto = await api.send({
1694
- method: "GET",
1695
- url: "/v1/ondo/swap/quote",
1696
- queryParams: {
1697
- symbol: params.symbol,
1698
- side: params.side,
1699
- duration: params.duration,
1700
- ...sizeParam(params)
1701
- },
1702
- attributes: Attributes.protected()
1703
- });
1704
- return OndoQuote.fromDto(dto);
1705
- }
1706
- async function buildOndoBuy(api, params) {
1707
- const dto = await api.send({
1708
- method: "POST",
1709
- url: "/v1/ondo/swap/buy",
1710
- body: swapBody(params),
1711
- attributes: Attributes.protected()
1712
- });
1713
- assertSpendScaleAgrees({
1714
- published: dto.spend_input_decimals,
1715
- sized: params.amount,
1716
- trade: "purchase"
1717
- });
1718
- return OndoBuyTransaction.fromDto(dto);
1719
- }
1720
- async function buildOndoSell(api, params) {
1721
- const dto = await api.send({
1722
- method: "POST",
1723
- url: "/v1/ondo/swap/sell",
1724
- body: swapBody(params),
1725
- attributes: Attributes.protected()
1726
- });
1727
- assertSpendScaleAgrees({
1728
- published: dto.spend_input_decimals,
1729
- sized: params.amount,
1730
- trade: "sale",
1731
- // The two answers come from two chains, so on a testnet they can disagree
1732
- // for a reason that is neither the caller's nor a corrupt response. Say so,
1733
- // or a QA run reads as a puzzle rather than a diagnosis.
1734
- note: "the quote resolves the asset on Ethereum mainnet while the swap executes on the chain requested, so these disagree until frontline serves a chain-scoped quote"
1735
- });
1736
- return OndoSellTransaction.fromDto(dto);
1737
- }
1738
- function swapBody(params) {
1739
- return {
1740
- symbol: params.symbol,
1741
- chain: params.chain,
1742
- wallet_address: params.walletAddress,
1743
- amount: params.amount.raw.toString()
1744
- };
1745
- }
1746
- function assertSpendScaleAgrees({
1747
- published,
1748
- sized,
1749
- trade,
1750
- note
1751
- }) {
1752
- if (published === sized.decimals) return;
1753
- const because = note === void 0 ? "" : ` - ${note}`;
1754
- throw new ValidationError(
1755
- `spend_input_decimals: the ${trade} was priced in ${published} decimals but the order was sized in ${sized.decimals}${because}`
1756
- );
1757
- }
1758
- function sizeParam(params) {
1759
- const tokenAmount = "tokenAmount" in params ? params.tokenAmount : void 0;
1760
- const notionalValue = "notionalValue" in params ? params.notionalValue : void 0;
1761
- if (tokenAmount !== void 0) {
1762
- if (notionalValue !== void 0) {
1763
- throw new ValidationError(
1764
- "An Ondo quote takes tokenAmount or notionalValue, not both"
1765
- );
1766
- }
1767
- return { token_amount: formatRawAmount(tokenAmount) };
1768
- }
1769
- if (notionalValue === void 0) {
1770
- throw new ValidationError(
1771
- "An Ondo quote must be sized by tokenAmount or notionalValue"
1772
- );
1773
- }
1774
- return { notional_value: notionalValue };
1775
- }
1776
-
1777
- // src/universal/core/checkout/ondo/ondo-namespace.ts
1778
- var OndoNamespaceImpl = class {
1779
- constructor(ctx) {
1780
- this.ctx = ctx;
1781
- this.log = internalLogger(ctx.logger, "ONDO");
1782
- }
1783
- async getTradingStatus(params) {
1784
- return this.log.wrap("getTradingStatus", params, async () => {
1785
- await this.ctx.ensureUserAuthenticated();
1786
- return getOndoTradingStatus(this.ctx.api, params);
1787
- });
1788
- }
1789
- async getQuote(params) {
1790
- return this.log.wrap("getQuote", params, async () => {
1791
- await this.ctx.ensureUserAuthenticated();
1792
- return getOndoQuote(this.ctx.api, params);
1793
- });
1794
- }
1795
- async buildBuyTransaction(params) {
1796
- return this.log.wrap("buildBuyTransaction", params, async () => {
1797
- await this.ctx.ensureUserAuthenticated();
1798
- return buildOndoBuy(this.ctx.api, params);
1799
- });
1800
- }
1801
- async buildSellTransaction(params) {
1802
- return this.log.wrap("buildSellTransaction", params, async () => {
1803
- await this.ctx.ensureUserAuthenticated();
1804
- return buildOndoSell(this.ctx.api, params);
1805
- });
1806
- }
1807
- };
1808
-
1809
- // src/universal/core/checkout/superstate/blockchain/abi.ts
1810
- var SUPERSTATE_SWAP_ABI = [
1811
- {
1812
- type: "function",
1813
- name: "KIND",
1814
- inputs: [],
1815
- outputs: [
1816
- {
1817
- name: "",
1818
- type: "uint16",
1819
- internalType: "uint16"
1820
- }
1821
- ],
1822
- stateMutability: "view"
1823
- },
1824
- {
1825
- type: "function",
1826
- name: "ONE_HUNDRED_P",
1827
- inputs: [],
1828
- outputs: [
1829
- {
1830
- name: "",
1831
- type: "uint256",
1832
- internalType: "uint256"
1833
- }
1834
- ],
1835
- stateMutability: "view"
1836
- },
1837
- {
1838
- type: "function",
1839
- name: "SWAP_LEVEL",
1840
- inputs: [],
1841
- outputs: [
1842
- {
1843
- name: "",
1844
- type: "uint32",
1845
- internalType: "uint32"
1846
- }
1847
- ],
1848
- stateMutability: "view"
1849
- },
1850
- {
1851
- type: "function",
1852
- name: "VERSION",
1853
- inputs: [],
1854
- outputs: [
1855
- {
1856
- name: "",
1857
- type: "uint16",
1858
- internalType: "uint16"
1859
- }
1860
- ],
1861
- stateMutability: "view"
1862
- },
1863
- {
1864
- type: "function",
1865
- name: "authorized",
1866
- inputs: [
1867
- {
1868
- name: "user",
1869
- type: "address",
1870
- internalType: "address"
1871
- }
1872
- ],
1873
- outputs: [
1874
- {
1875
- name: "",
1876
- type: "bool",
1877
- internalType: "bool"
1878
- }
1879
- ],
1880
- stateMutability: "view"
1881
- },
1882
- {
1883
- type: "function",
1884
- name: "bpp",
1885
- inputs: [
1886
- {
1887
- name: "amount",
1888
- type: "uint256",
1889
- internalType: "uint256"
1890
- }
1891
- ],
1892
- outputs: [
1893
- {
1894
- name: "",
1895
- type: "uint256",
1896
- internalType: "uint256"
1897
- }
1898
- ],
1899
- stateMutability: "view"
1900
- },
1901
- {
1902
- type: "function",
1903
- name: "bps",
1904
- inputs: [],
1905
- outputs: [
1906
- {
1907
- name: "",
1908
- type: "uint256",
1909
- internalType: "uint256"
1910
- }
1911
- ],
1912
- stateMutability: "view"
1913
- },
1914
- {
1915
- type: "function",
1916
- name: "cancelOwnershipHandover",
1917
- inputs: [],
1918
- outputs: [],
1919
- stateMutability: "payable"
1920
- },
1921
- {
1922
- type: "function",
1923
- name: "completeOwnershipHandover",
1924
- inputs: [
1925
- {
1926
- name: "pendingOwner",
1927
- type: "address",
1928
- internalType: "address"
1929
- }
1930
- ],
1931
- outputs: [],
1932
- stateMutability: "payable"
1933
- },
1934
- {
1935
- type: "function",
1936
- name: "fee",
1937
- inputs: [
1938
- {
1939
- name: "amount",
1940
- type: "uint256",
1941
- internalType: "uint256"
1942
- }
1943
- ],
1944
- outputs: [
1945
- {
1946
- name: "",
1947
- type: "uint256",
1948
- internalType: "uint256"
1949
- },
1950
- {
1951
- name: "",
1952
- type: "uint256",
1953
- internalType: "uint256"
1954
- }
1955
- ],
1956
- stateMutability: "view"
1957
- },
1958
- {
1959
- type: "function",
1960
- name: "id",
1961
- inputs: [],
1962
- outputs: [
1963
- {
1964
- name: "",
1965
- type: "bytes32",
1966
- internalType: "bytes32"
1967
- }
1968
- ],
1969
- stateMutability: "view"
1970
- },
1971
- {
1972
- type: "function",
1973
- name: "inputTokens",
1974
- inputs: [
1975
- {
1976
- name: "",
1977
- type: "address",
1978
- internalType: "address"
1979
- }
1980
- ],
1981
- outputs: [
1982
- {
1983
- name: "",
1984
- type: "bool",
1985
- internalType: "bool"
1986
- }
1987
- ],
1988
- stateMutability: "view"
1989
- },
1990
- {
1991
- type: "function",
1992
- name: "outputToken",
1993
- inputs: [],
1994
- outputs: [
1995
- {
1996
- name: "",
1997
- type: "address",
1998
- internalType: "address"
1999
- }
2000
- ],
2001
- stateMutability: "view"
2002
- },
2003
- {
2004
- type: "function",
2005
- name: "outputTokenBalance",
2006
- inputs: [],
2007
- outputs: [
2008
- {
2009
- name: "",
2010
- type: "uint256",
2011
- internalType: "uint256"
2012
- }
2013
- ],
2014
- stateMutability: "view"
2015
- },
2016
- {
2017
- type: "function",
2018
- name: "owner",
2019
- inputs: [],
2020
- outputs: [
2021
- {
2022
- name: "result",
2023
- type: "address",
2024
- internalType: "address"
2025
- }
2026
- ],
2027
- stateMutability: "view"
2028
- },
2029
- {
2030
- type: "function",
2031
- name: "ownershipHandoverExpiresAt",
2032
- inputs: [
2033
- {
2034
- name: "pendingOwner",
2035
- type: "address",
2036
- internalType: "address"
2037
- }
2038
- ],
2039
- outputs: [
2040
- {
2041
- name: "result",
2042
- type: "uint256",
2043
- internalType: "uint256"
2044
- }
2045
- ],
2046
- stateMutability: "view"
2047
- },
2048
- {
2049
- type: "function",
2050
- name: "pause",
2051
- inputs: [
2052
- {
2053
- name: "level",
2054
- type: "uint32",
2055
- internalType: "uint32"
2056
- }
2057
- ],
2058
- outputs: [
2059
- {
2060
- name: "",
2061
- type: "bool",
2062
- internalType: "bool"
2063
- }
2064
- ],
2065
- stateMutability: "nonpayable"
2066
- },
2067
- {
2068
- type: "function",
2069
- name: "paused",
2070
- inputs: [],
2071
- outputs: [
2072
- {
2073
- name: "",
2074
- type: "uint32",
2075
- internalType: "uint32"
2076
- }
2077
- ],
2078
- stateMutability: "view"
2079
- },
2080
- {
2081
- type: "function",
2082
- name: "preview",
2083
- inputs: [
2084
- {
2085
- name: "token",
2086
- type: "address",
2087
- internalType: "address"
2088
- },
2089
- {
2090
- name: "amount",
2091
- type: "uint256",
2092
- internalType: "uint256"
2093
- }
2094
- ],
2095
- outputs: [
2096
- {
2097
- name: "",
2098
- type: "tuple",
2099
- internalType: "struct Preview",
2100
- components: [
2101
- {
2102
- name: "input",
2103
- type: "uint256",
2104
- internalType: "uint256"
2105
- },
2106
- {
2107
- name: "fee",
2108
- type: "uint256",
2109
- internalType: "uint256"
2110
- },
2111
- {
2112
- name: "output",
2113
- type: "uint256",
2114
- internalType: "uint256"
2115
- }
2116
- ]
2117
- }
2118
- ],
2119
- stateMutability: "view"
2120
- },
2121
- {
2122
- type: "function",
2123
- name: "renounceOwnership",
2124
- inputs: [],
2125
- outputs: [],
2126
- stateMutability: "payable"
2127
- },
2128
- {
2129
- type: "function",
2130
- name: "requestOwnershipHandover",
2131
- inputs: [],
2132
- outputs: [],
2133
- stateMutability: "payable"
2134
- },
2135
- {
2136
- type: "function",
2137
- name: "setBps",
2138
- inputs: [
2139
- {
2140
- name: "points",
2141
- type: "uint256",
2142
- internalType: "uint256"
2143
- }
2144
- ],
2145
- outputs: [
2146
- {
2147
- name: "",
2148
- type: "bool",
2149
- internalType: "bool"
2150
- }
2151
- ],
2152
- stateMutability: "nonpayable"
2153
- },
2154
- {
2155
- type: "function",
2156
- name: "setInputToken",
2157
- inputs: [
2158
- {
2159
- name: "token",
2160
- type: "address",
2161
- internalType: "address"
2162
- },
2163
- {
2164
- name: "val",
2165
- type: "bool",
2166
- internalType: "bool"
2167
- }
2168
- ],
2169
- outputs: [
2170
- {
2171
- name: "",
2172
- type: "bool",
2173
- internalType: "bool"
2174
- }
2175
- ],
2176
- stateMutability: "nonpayable"
2177
- },
2178
- {
2179
- type: "function",
2180
- name: "status",
2181
- inputs: [],
2182
- outputs: [
2183
- {
2184
- name: "",
2185
- type: "tuple",
2186
- internalType: "struct Status",
2187
- components: [
2188
- {
2189
- name: "flags",
2190
- type: "uint32",
2191
- internalType: "uint32"
2192
- },
2193
- {
2194
- name: "state",
2195
- type: "uint8",
2196
- internalType: "enum State"
2197
- }
2198
- ]
2199
- }
2200
- ],
2201
- stateMutability: "view"
2202
- },
2203
- {
2204
- type: "function",
2205
- name: "stop",
2206
- inputs: [],
2207
- outputs: [
2208
- {
2209
- name: "",
2210
- type: "bool",
2211
- internalType: "bool"
2212
- }
2213
- ],
2214
- stateMutability: "nonpayable"
2215
- },
2216
- {
2217
- type: "function",
2218
- name: "stopped",
2219
- inputs: [],
2220
- outputs: [
2221
- {
2222
- name: "",
2223
- type: "bool",
2224
- internalType: "bool"
2225
- }
2226
- ],
2227
- stateMutability: "view"
2228
- },
2229
- {
2230
- type: "function",
2231
- name: "swap",
2232
- inputs: [
2233
- {
2234
- name: "token",
2235
- type: "address",
2236
- internalType: "address"
2237
- },
2238
- {
2239
- name: "amount",
2240
- type: "uint256",
2241
- internalType: "uint256"
2242
- },
2243
- {
2244
- name: "slip",
2245
- type: "uint256",
2246
- internalType: "uint256"
2247
- }
2248
- ],
2249
- outputs: [
2250
- {
2251
- name: "",
2252
- type: "uint256",
2253
- internalType: "uint256"
2254
- }
2255
- ],
2256
- stateMutability: "nonpayable"
2257
- },
2258
- {
2259
- type: "function",
2260
- name: "tokenBalance",
2261
- inputs: [
2262
- {
2263
- name: "token",
2264
- type: "address",
2265
- internalType: "address"
2266
- }
2267
- ],
2268
- outputs: [
2269
- {
2270
- name: "",
2271
- type: "uint256",
2272
- internalType: "uint256"
2273
- }
2274
- ],
2275
- stateMutability: "view"
2276
- },
2277
- {
2278
- type: "function",
2279
- name: "totals",
2280
- inputs: [
2281
- {
2282
- name: "user",
2283
- type: "address",
2284
- internalType: "address"
2285
- },
2286
- {
2287
- name: "token",
2288
- type: "address",
2289
- internalType: "address"
2290
- }
2291
- ],
2292
- outputs: [
2293
- {
2294
- name: "",
2295
- type: "tuple",
2296
- internalType: "struct SwapTotal",
2297
- components: [
2298
- {
2299
- name: "inputSum",
2300
- type: "uint256",
2301
- internalType: "uint256"
2302
- },
2303
- {
2304
- name: "feeSum",
2305
- type: "uint256",
2306
- internalType: "uint256"
2307
- },
2308
- {
2309
- name: "outputSum",
2310
- type: "uint256",
2311
- internalType: "uint256"
2312
- },
2313
- {
2314
- name: "count",
2315
- type: "uint256",
2316
- internalType: "uint256"
2317
- }
2318
- ]
2319
- }
2320
- ],
2321
- stateMutability: "view"
2322
- },
2323
- {
2324
- type: "function",
2325
- name: "totals",
2326
- inputs: [
2327
- {
2328
- name: "token",
2329
- type: "address",
2330
- internalType: "address"
2331
- }
2332
- ],
2333
- outputs: [
2334
- {
2335
- name: "",
2336
- type: "tuple",
2337
- internalType: "struct SwapTotal",
2338
- components: [
2339
- {
2340
- name: "inputSum",
2341
- type: "uint256",
2342
- internalType: "uint256"
2343
- },
2344
- {
2345
- name: "feeSum",
2346
- type: "uint256",
2347
- internalType: "uint256"
2348
- },
2349
- {
2350
- name: "outputSum",
2351
- type: "uint256",
2352
- internalType: "uint256"
2353
- },
2354
- {
2355
- name: "count",
2356
- type: "uint256",
2357
- internalType: "uint256"
2358
- }
2359
- ]
2360
- }
2361
- ],
2362
- stateMutability: "view"
2363
- },
2364
- {
2365
- type: "function",
2366
- name: "transfer",
2367
- inputs: [
2368
- {
2369
- name: "to",
2370
- type: "address",
2371
- internalType: "address"
2372
- },
2373
- {
2374
- name: "amount",
2375
- type: "uint256",
2376
- internalType: "uint256"
2377
- }
2378
- ],
2379
- outputs: [
2380
- {
2381
- name: "",
2382
- type: "bool",
2383
- internalType: "bool"
2384
- }
2385
- ],
2386
- stateMutability: "nonpayable"
2387
- },
2388
- {
2389
- type: "function",
2390
- name: "transfer",
2391
- inputs: [
2392
- {
2393
- name: "to",
2394
- type: "address",
2395
- internalType: "address"
2396
- },
2397
- {
2398
- name: "token",
2399
- type: "address",
2400
- internalType: "address"
2401
- },
2402
- {
2403
- name: "amount",
2404
- type: "uint256",
2405
- internalType: "uint256"
2406
- }
2407
- ],
2408
- outputs: [
2409
- {
2410
- name: "",
2411
- type: "bool",
2412
- internalType: "bool"
2413
- }
2414
- ],
2415
- stateMutability: "nonpayable"
2416
- },
2417
- {
2418
- type: "function",
2419
- name: "transferOwnership",
2420
- inputs: [
2421
- {
2422
- name: "newOwner",
2423
- type: "address",
2424
- internalType: "address"
2425
- }
2426
- ],
2427
- outputs: [],
2428
- stateMutability: "payable"
2429
- },
2430
- {
2431
- type: "event",
2432
- name: "BpsUpdated",
2433
- inputs: [
2434
- {
2435
- name: "prev",
2436
- type: "uint256",
2437
- indexed: false,
2438
- internalType: "uint256"
2439
- },
2440
- {
2441
- name: "next",
2442
- type: "uint256",
2443
- indexed: false,
2444
- internalType: "uint256"
2445
- }
2446
- ],
2447
- anonymous: false
2448
- },
2449
- {
2450
- type: "event",
2451
- name: "InputTokenUpdated",
2452
- inputs: [
2453
- {
2454
- name: "token",
2455
- type: "address",
2456
- indexed: true,
2457
- internalType: "address"
2458
- },
2459
- {
2460
- name: "prev",
2461
- type: "bool",
2462
- indexed: false,
2463
- internalType: "bool"
2464
- },
2465
- {
2466
- name: "next",
2467
- type: "bool",
2468
- indexed: false,
2469
- internalType: "bool"
2470
- }
2471
- ],
2472
- anonymous: false
2473
- },
2474
- {
2475
- type: "event",
2476
- name: "OwnershipHandoverCanceled",
2477
- inputs: [
2478
- {
2479
- name: "pendingOwner",
2480
- type: "address",
2481
- indexed: true,
2482
- internalType: "address"
2483
- }
2484
- ],
2485
- anonymous: false
2486
- },
2487
- {
2488
- type: "event",
2489
- name: "OwnershipHandoverRequested",
2490
- inputs: [
2491
- {
2492
- name: "pendingOwner",
2493
- type: "address",
2494
- indexed: true,
2495
- internalType: "address"
2496
- }
2497
- ],
2498
- anonymous: false
2499
- },
2500
- {
2501
- type: "event",
2502
- name: "OwnershipTransferred",
2503
- inputs: [
2504
- {
2505
- name: "oldOwner",
2506
- type: "address",
2507
- indexed: true,
2508
- internalType: "address"
2509
- },
2510
- {
2511
- name: "newOwner",
2512
- type: "address",
2513
- indexed: true,
2514
- internalType: "address"
2515
- }
2516
- ],
2517
- anonymous: false
2518
- },
2519
- {
2520
- type: "event",
2521
- name: "Paused",
2522
- inputs: [
2523
- {
2524
- name: "previous",
2525
- type: "uint32",
2526
- indexed: false,
2527
- internalType: "uint32"
2528
- },
2529
- {
2530
- name: "next",
2531
- type: "uint32",
2532
- indexed: false,
2533
- internalType: "uint32"
2534
- }
2535
- ],
2536
- anonymous: false
2537
- },
2538
- {
2539
- type: "event",
2540
- name: "Stopped",
2541
- inputs: [],
2542
- anonymous: false
2543
- },
2544
- {
2545
- type: "event",
2546
- name: "Swapped",
2547
- inputs: [
2548
- {
2549
- name: "user",
2550
- type: "address",
2551
- indexed: true,
2552
- internalType: "address"
2553
- },
2554
- {
2555
- name: "inputToken",
2556
- type: "address",
2557
- indexed: true,
2558
- internalType: "address"
2559
- },
2560
- {
2561
- name: "outputToken",
2562
- type: "address",
2563
- indexed: true,
2564
- internalType: "address"
2565
- },
2566
- {
2567
- name: "inputAmount",
2568
- type: "uint256",
2569
- indexed: false,
2570
- internalType: "uint256"
2571
- },
2572
- {
2573
- name: "fee",
2574
- type: "uint256",
2575
- indexed: false,
2576
- internalType: "uint256"
2577
- },
2578
- {
2579
- name: "outputAmount",
2580
- type: "uint256",
2581
- indexed: false,
2582
- internalType: "uint256"
2583
- }
2584
- ],
2585
- anonymous: false
2586
- },
2587
- {
2588
- type: "event",
2589
- name: "Transferred",
2590
- inputs: [
2591
- {
2592
- name: "to",
2593
- type: "address",
2594
- indexed: true,
2595
- internalType: "address"
2596
- },
2597
- {
2598
- name: "token",
2599
- type: "address",
2600
- indexed: true,
2601
- internalType: "address"
2602
- },
2603
- {
2604
- name: "amount",
2605
- type: "uint256",
2606
- indexed: false,
2607
- internalType: "uint256"
2608
- }
2609
- ],
2610
- anonymous: false
2611
- },
2612
- {
2613
- type: "error",
2614
- name: "AlreadyInitialized",
2615
- inputs: []
2616
- },
2617
- {
2618
- type: "error",
2619
- name: "InsufficientAmount",
2620
- inputs: []
2621
- },
2622
- {
2623
- type: "error",
2624
- name: "InvalidAddress",
2625
- inputs: []
2626
- },
2627
- {
2628
- type: "error",
2629
- name: "InvalidAmount",
2630
- inputs: []
2631
- },
2632
- {
2633
- type: "error",
2634
- name: "IsPaused",
2635
- inputs: [
2636
- {
2637
- name: "level",
2638
- type: "uint32",
2639
- internalType: "uint32"
2640
- }
2641
- ]
2642
- },
2643
- {
2644
- type: "error",
2645
- name: "IsStopped",
2646
- inputs: []
2647
- },
2648
- {
2649
- type: "error",
2650
- name: "NewOwnerIsZeroAddress",
2651
- inputs: []
2652
- },
2653
- {
2654
- type: "error",
2655
- name: "NoHandoverRequest",
2656
- inputs: []
2657
- },
2658
- {
2659
- type: "error",
2660
- name: "SwapFailed",
2661
- inputs: [
2662
- {
2663
- name: "user",
2664
- type: "address",
2665
- internalType: "address"
2666
- },
2667
- {
2668
- name: "token",
2669
- type: "address",
2670
- internalType: "address"
2671
- }
2672
- ]
2673
- },
2674
- {
2675
- type: "error",
2676
- name: "Unauthorized",
2677
- inputs: []
2678
- }
2679
- ];
2680
-
2681
- // src/universal/core/shared/blockchain/bps.ts
2682
- var BPS_DENOM = Bps(10000n);
2683
- function applyBps(amount, bps) {
2684
- return assertUint256(amount * bps / BPS_DENOM);
2685
- }
2686
-
2687
- // src/universal/core/checkout/superstate/blockchain/math.ts
2688
- function computePrice({
2689
- inputTokenAmount,
2690
- outputTokenAmount
2691
- }) {
2692
- if (outputTokenAmount.raw === 0n) return null;
2693
- const scale = 10n ** BigInt(outputTokenAmount.decimals);
2694
- const raw = assertUint256(
2695
- inputTokenAmount.raw * scale / outputTokenAmount.raw
2696
- );
2697
- return BlockchainAmount({ raw, decimals: inputTokenAmount.decimals });
2698
- }
2699
- function computeSlip(amount, slippage) {
2700
- const retained = Bps(assertUint256(BPS_DENOM - slippage));
2701
- const slipRaw = applyBps(amount.raw, retained);
2702
- return BlockchainAmount({ raw: slipRaw, decimals: amount.decimals });
2703
- }
2704
-
2705
- // src/universal/core/checkout/superstate/blockchain/quote.ts
2706
- var SwapQuote = {
2707
- /**
2708
- * Assembles a {@link SwapQuote} from a raw contract {@link SwapPreview}. The
2709
- * input and fee are denominated in the input token; the output in the output
2710
- * token.
2711
- */
2712
- fromPreview: (preview, inputDecimals, outputDecimals) => ({
2713
- inputTokenAmount: BlockchainAmount({
2714
- raw: preview.inputAmount,
2715
- decimals: inputDecimals
2716
- }),
2717
- fee: BlockchainAmount({ raw: preview.fee, decimals: inputDecimals }),
2718
- outputTokenAmount: BlockchainAmount({
2719
- raw: preview.outputAmount,
2720
- decimals: outputDecimals
2721
- })
2722
- })
2723
- };
2724
-
2725
- // src/universal/core/checkout/superstate/blockchain/status.ts
2726
- var SWAP_LEVEL = 2;
2727
- function isSwapAvailable(status) {
2728
- switch (status.state) {
2729
- case "active":
2730
- return true;
2731
- case "stopped":
2732
- return false;
2733
- case "paused":
2734
- return (status.pausedLevels & SWAP_LEVEL) === 0;
2735
- default: {
2736
- const _exhaustive = status;
2737
- return _exhaustive;
2738
- }
2739
- }
2740
- }
2741
-
2742
- // src/universal/core/checkout/superstate/blockchain/swapped-event.ts
2743
- var import_viem4 = require("viem");
2744
- function decodeSwappedOutputAmount(receipt, outputDecimals) {
2745
- try {
2746
- const [swapped] = (0, import_viem4.parseEventLogs)({
2747
- abi: SUPERSTATE_SWAP_ABI,
2748
- eventName: "Swapped",
2749
- logs: receipt.logs
2750
- });
2751
- if (!swapped) return null;
2752
- const raw = swapped.args.outputAmount;
2753
- if (raw < 0n || raw > MAX_UINT_256) return null;
2754
- return BlockchainAmount({ raw, decimals: outputDecimals });
2755
- } catch {
2756
- return null;
2757
- }
2758
- }
2759
-
2760
- // src/universal/core/checkout/superstate/constants.ts
2761
- var SUPERSTATE_ISSUER_NAME = "Superstate";
2762
- var SUPERSTATE_SUPPORTED_INPUT_ASSETS = [USDC_SYMBOL];
2763
- var SWAP_POLL_INTERVAL_MS = 15e3;
2764
- var DEFAULT_AMOUNT_TO_COMPUTE_PRICE = 1000000n;
2765
- var SLIPPAGE_OPTIONS_BPS = [25n, 50n, 100n, 200n, 500n].map(
2766
- (n) => Bps(n)
2767
- );
2768
- var DEFAULT_SLIPPAGE_BPS = Bps(50n);
2769
- var SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA = EvmContractAddress("0x27E8CE9Ca1A1E98Bc4009F08Dc596bFcf88aCED1");
2770
- var SUPERSTATE_SWAP_CONTRACT_ADDRESSES = {
2771
- ethereum_sepolia: SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA
2772
- };
2773
- function superstateSwapContractAddress(chain) {
2774
- return SUPERSTATE_SWAP_CONTRACT_ADDRESSES[chain] ?? null;
2775
- }
2776
-
2777
- // src/universal/core/checkout/superstate/formatters.ts
2778
- function formattedPricePerShare(quote, locale) {
2779
- if (!quote) return NA_AMOUNT_ASSET_UI;
2780
- return formattedUsdPrice(computePrice(quote), locale);
2781
- }
2782
-
2783
- // src/universal/types/providers/superstate/swap.ts
2784
- var SwapPreview = {
2785
- /** Maps the contract's `Preview { input, fee, output }` struct. */
2786
- fromContract: (preview) => ({
2787
- inputAmount: parseUint256(preview.input, "SwapPreview.input"),
2788
- fee: parseUint256(preview.fee, "SwapPreview.fee"),
2789
- outputAmount: parseUint256(preview.output, "SwapPreview.output")
2790
- })
2791
- };
2792
- var PauseFlags = (value) => value;
2793
- var SwapStatus = {
2794
- /**
2795
- * Maps the contract's `Status { uint32 flags; State state }` struct, where
2796
- * `State` is `0 = Active | 1 = Paused | 2 = Stopped`.
2797
- *
2798
- * `flags` is carried onto the `paused` arm only. On the other two the
2799
- * contract sets it to a self-identifying marker rather than to information -
2800
- * so repeating it would invite a caller to read meaning into a constant.
2801
- *
2802
- * @throws ValidationError on a `state` outside the enum. A contract that has
2803
- * grown a fourth state is one the SDK does not model, and guessing `active`
2804
- * would let a halted swap read as a live one.
2805
- */
2806
- fromContract: (status) => {
2807
- switch (status.state) {
2808
- case 0:
2809
- return { state: "active" };
2810
- case 1:
2811
- return { state: "paused", pausedLevels: PauseFlags(status.flags) };
2812
- case 2:
2813
- return { state: "stopped" };
2814
- default:
2815
- throw new ValidationError(
2816
- `SwapStatus.state: unknown contract state (${status.state})`
2817
- );
2818
- }
2819
- }
2820
- };
2821
- var AllowWalletResponse = {
2822
- fromDto: (dto) => {
2823
- switch (dto.action) {
2824
- case "broadcast_transaction":
2825
- return {
2826
- action: "broadcast_transaction",
2827
- to: EvmContractAddress(dto.to),
2828
- data: HexEncodedTransactionData(dto.data)
2829
- };
2830
- case "none":
2831
- return {
2832
- action: "none",
2833
- alreadyAllowed: dto.already_allowed
2834
- };
2835
- default: {
2836
- const _exhaustive = dto;
2837
- return _exhaustive;
2838
- }
2839
- }
2840
- }
2841
- };
2842
-
2843
- // src/universal/api/frontline/providers/superstate/swap.ts
2844
- async function allowWallet(api, params) {
2845
- const dto = await api.send({
2846
- method: "POST",
2847
- url: `/v1/offers/${encodeURIComponent(params.offerId)}/allow-wallet`,
2848
- body: {
2849
- wallet_address: params.walletAddress,
2850
- chain: params.chain,
2851
- signature: params.signature
2852
- },
2853
- attributes: Attributes.protected()
2854
- });
2855
- return AllowWalletResponse.fromDto(dto);
2856
- }
2857
-
2858
- // src/universal/core/shared/blockchain/erc20/abi.ts
2859
- var ERC20_ABI = [
2860
- {
2861
- type: "function",
2862
- name: "allowance",
2863
- inputs: [
2864
- { name: "owner", type: "address" },
2865
- { name: "spender", type: "address" }
2866
- ],
2867
- outputs: [{ name: "", type: "uint256" }],
2868
- stateMutability: "view"
2869
- },
2870
- {
2871
- type: "function",
2872
- name: "approve",
2873
- inputs: [
2874
- { name: "spender", type: "address" },
2875
- { name: "amount", type: "uint256" }
2876
- ],
2877
- outputs: [{ name: "", type: "bool" }],
2878
- stateMutability: "nonpayable"
2879
- },
2880
- {
2881
- type: "function",
2882
- name: "balanceOf",
2883
- inputs: [{ name: "account", type: "address" }],
2884
- outputs: [{ name: "", type: "uint256" }],
2885
- stateMutability: "view"
2886
- },
2887
- {
2888
- type: "function",
2889
- name: "decimals",
2890
- inputs: [],
2891
- outputs: [{ name: "", type: "uint8" }],
2892
- stateMutability: "view"
2893
- },
2894
- {
2895
- type: "function",
2896
- name: "name",
2897
- inputs: [],
2898
- outputs: [{ name: "", type: "string" }],
2899
- stateMutability: "view"
2900
- },
2901
- {
2902
- type: "function",
2903
- name: "symbol",
2904
- inputs: [],
2905
- outputs: [{ name: "", type: "string" }],
2906
- stateMutability: "view"
2907
- },
2908
- {
2909
- type: "function",
2910
- name: "totalSupply",
2911
- inputs: [],
2912
- outputs: [{ name: "", type: "uint256" }],
2913
- stateMutability: "view"
2914
- },
2915
- {
2916
- type: "function",
2917
- name: "transfer",
2918
- inputs: [
2919
- { name: "recipient", type: "address" },
2920
- { name: "amount", type: "uint256" }
2921
- ],
2922
- outputs: [{ name: "", type: "bool" }],
2923
- stateMutability: "nonpayable"
2924
- },
2925
- {
2926
- type: "function",
2927
- name: "transferFrom",
2928
- inputs: [
2929
- { name: "sender", type: "address" },
2930
- { name: "recipient", type: "address" },
2931
- { name: "amount", type: "uint256" }
2932
- ],
2933
- outputs: [{ name: "", type: "bool" }],
2934
- stateMutability: "nonpayable"
2935
- },
2936
- {
2937
- type: "event",
2938
- name: "Approval",
2939
- inputs: [
2940
- { name: "owner", type: "address", indexed: true },
2941
- { name: "spender", type: "address", indexed: true },
2942
- { name: "value", type: "uint256", indexed: false }
2943
- ],
2944
- anonymous: false
2945
- },
2946
- {
2947
- type: "event",
2948
- name: "Transfer",
2949
- inputs: [
2950
- { name: "from", type: "address", indexed: true },
2951
- { name: "to", type: "address", indexed: true },
2952
- { name: "value", type: "uint256", indexed: false }
2953
- ],
2954
- anonymous: false
2955
- }
2956
- ];
2957
-
2958
- // src/universal/api/rpc/providers/superstate/swap.ts
2959
- async function getSwapAuthorization(clients, params) {
2960
- return clients(params.chain).readContract({
2961
- address: params.contractAddress,
2962
- abi: SUPERSTATE_SWAP_ABI,
2963
- functionName: "authorized",
2964
- args: [params.walletAddress]
2965
- });
2966
- }
2967
- async function getSwapPreview(clients, params) {
2968
- const preview = await clients(params.chain).readContract({
2969
- address: params.contractAddress,
2970
- abi: SUPERSTATE_SWAP_ABI,
2971
- functionName: "preview",
2972
- args: [params.inputToken, params.amount]
2973
- });
2974
- return SwapPreview.fromContract(preview);
2975
- }
2976
- async function getSwapStatus(clients, params) {
2977
- const status = await clients(params.chain).readContract({
2978
- address: params.contractAddress,
2979
- abi: SUPERSTATE_SWAP_ABI,
2980
- functionName: "status"
2981
- });
2982
- return SwapStatus.fromContract(status);
2983
- }
2984
- async function getSwapOutputToken(clients, params) {
2985
- const client = clients(params.chain);
2986
- const tokenAddress = await client.readContract({
2987
- address: params.contractAddress,
2988
- abi: SUPERSTATE_SWAP_ABI,
2989
- functionName: "outputToken"
2990
- });
2991
- const token = { address: EvmContractAddress(tokenAddress), abi: ERC20_ABI };
2992
- const [name, symbol, decimals] = await client.multicall({
2993
- contracts: [
2994
- { ...token, functionName: "name" },
2995
- { ...token, functionName: "symbol" },
2996
- { ...token, functionName: "decimals" }
2997
- ],
2998
- allowFailure: false
2999
- });
3000
- return {
3001
- name,
3002
- symbol: AssetSymbol(symbol),
3003
- decimals: AssetDecimals(decimals)
3004
- };
3005
- }
3006
-
3007
- // src/universal/core/checkout/superstate/swap-namespace.ts
3008
- var SuperstateSwapNamespaceImpl = class {
3009
- constructor(ctx) {
3010
- this.ctx = ctx;
3011
- this.log = internalLogger(ctx.logger, "SUPERSTATE");
3012
- }
3013
- async getAuthorization(params) {
3014
- return this.log.wrap(
3015
- "getAuthorization",
3016
- params,
3017
- async () => getSwapAuthorization(this.ctx.rpc, params)
3018
- );
3019
- }
3020
- async getPreview(params) {
3021
- return this.log.wrap(
3022
- "getPreview",
3023
- params,
3024
- async () => getSwapPreview(this.ctx.rpc, params)
3025
- );
3026
- }
3027
- async getStatus(params) {
3028
- return this.log.wrap(
3029
- "getStatus",
3030
- params,
3031
- async () => getSwapStatus(this.ctx.rpc, params)
3032
- );
3033
- }
3034
- async getOutputToken(params) {
3035
- return this.log.wrap(
3036
- "getOutputToken",
3037
- params,
3038
- async () => getSwapOutputToken(this.ctx.rpc, params)
3039
- );
3040
- }
3041
- async allowWallet(params) {
3042
- return this.log.wrap("allowWallet", params, async () => {
3043
- await this.ctx.ensureUserAuthenticated();
3044
- return allowWallet(this.ctx.api, params);
3045
- });
3046
- }
3047
- };
3048
-
3049
- // src/universal/api/frontline/offers.ts
3050
- async function fetchOffers(api, clientCreds) {
3051
- return fetchAllPages((params) => fetchOffersPage(api, params, clientCreds));
3052
- }
3053
- async function fetchOffersPage(api, params, clientCreds) {
3054
- const queryParams = PaginationParams.toQueryParams(params);
3055
- const pageDto = await api.send({
3056
- method: "GET",
3057
- url: "/v1/offers",
3058
- queryParams,
3059
- attributes: Attributes.concat(
3060
- Attributes.protected(),
3061
- Attributes.clientCredentials(clientCreds)
3062
- )
3063
- });
3064
- return PaginatedResponse.fromDtoPage(pageDto, Offer.listFromDto);
3065
- }
3066
- async function fetchOfferDetails(api, id, clientCreds) {
3067
- const dto = await api.send({
3068
- method: "GET",
3069
- url: `/v1/offers/${id}`,
3070
- attributes: Attributes.concat(
3071
- Attributes.protected(),
3072
- Attributes.clientCredentials(clientCreds)
3073
- )
3074
- });
3075
- return OfferDetail.fromDto(dto);
3076
- }
3077
-
3078
- // src/universal/core/offers/offers-namespace.ts
3079
- var OffersNamespaceImpl = class {
3080
- constructor(ctx) {
3081
- this.ctx = ctx;
3082
- this.log = internalLogger(ctx.logger, "OFFERS");
3083
- }
3084
- async list() {
3085
- return this.log.wrap("list", void 0, async () => {
3086
- await this.ctx.ensureUserAuthenticated();
3087
- return fetchOffers(this.ctx.api, void 0);
3088
- });
3089
- }
3090
- async listPage(params) {
3091
- return this.log.wrap("listPage", params, async () => {
3092
- await this.ctx.ensureUserAuthenticated();
3093
- return fetchOffersPage(this.ctx.api, params, void 0);
3094
- });
3095
- }
3096
- async get(id) {
3097
- return this.log.wrap("get", id, async () => {
3098
- await this.ctx.ensureUserAuthenticated();
3099
- return fetchOfferDetails(this.ctx.api, id, void 0);
3100
- });
3101
- }
3102
- };
3103
-
3104
- // src/universal/core/offers/swap-contracts.ts
3105
- function swapSpender(swapContracts, chain) {
3106
- return swapContracts.find((contract) => contract.chain === chain)?.address ?? null;
3107
- }
3108
-
3109
- // src/universal/types/document-submission.ts
3110
- var DocumentSubmission = {
3111
- fromDto: (dto) => ({
3112
- status: dto.status,
3113
- formType: dto.form_type
3114
- })
3115
- };
3116
-
3117
- // src/universal/api/frontline/documents.ts
3118
- async function submitDocument(api, documentType, fields) {
3119
- const dto = await api.send({
3120
- method: "POST",
3121
- url: `/v1/documents/${documentType}/submission`,
3122
- body: fields,
3123
- attributes: Attributes.protected()
3124
- });
3125
- return DocumentSubmission.fromDto(dto);
3126
- }
3127
-
3128
- // src/universal/types/kyc.ts
3129
- var KycToken = {
3130
- fromDto: (dto) => ({
3131
- token: dto.token
3132
- })
3133
- };
3134
-
3135
- // src/universal/api/frontline/kyc.ts
3136
- async function createKycToken(api, levelName, reset) {
3137
- const dto = await api.send({
3138
- method: "POST",
3139
- url: "/v1/kyc-token",
3140
- body: {
3141
- ...levelName === void 0 ? {} : { level_name: levelName },
3142
- ...reset === void 0 ? {} : { reset }
3143
- },
3144
- attributes: Attributes.protected()
3145
- });
3146
- return KycToken.fromDto(dto);
3147
- }
3148
-
3149
- // src/universal/types/pii.ts
3150
- var Iso2CountryCode = (value) => value;
3151
- var PiiJurisdiction = {
3152
- fromDto: (dto) => ({
3153
- iso2: Iso2CountryCode(dto.iso_2),
3154
- name: dto.name
3155
- })
3156
- };
3157
- var PiiAddress = {
3158
- fromDto: (dto) => ({
3159
- street: dto.street,
3160
- city: dto.city,
3161
- state: dto.state,
3162
- postalCode: dto.postal_code,
3163
- country: dto.country
3164
- })
3165
- };
3166
- var Pii = {
3167
- fromDto: (dto) => ({
3168
- kind: dto.kind,
3169
- fullLegalName: dto.full_legal_name,
3170
- dateOfBirth: dto.date_of_birth,
3171
- jurisdiction: dto.jurisdiction ? PiiJurisdiction.fromDto(dto.jurisdiction) : null,
3172
- taxId: dto.tax_id,
3173
- permanentAddress: PiiAddress.fromDto(dto.permanent_address)
3174
- })
3175
- };
3176
-
3177
- // src/universal/api/frontline/pii.ts
3178
- async function fetchPii(api) {
3179
- const dto = await api.send({
3180
- method: "GET",
3181
- url: "/v1/pii",
3182
- attributes: Attributes.protected()
3183
- });
3184
- return Pii.fromDto(dto);
3185
- }
3186
-
3187
- // src/universal/types/requirement.ts
3188
- var RequirementId = (value) => value;
3189
- var Requirement = {
3190
- fromDto: (dto) => ({
3191
- id: RequirementId(dto.id),
3192
- type: dto.type,
3193
- details: dto.details
3194
- })
3195
- };
3196
- var RequirementStatusInfo = {
3197
- fromStatusesDto: (dto) => Object.entries(dto.statuses).map(
3198
- ([id, value]) => typeof value === "string" ? { id: RequirementId(id), status: value, action: null } : {
3199
- id: RequirementId(id),
3200
- status: value.status,
3201
- action: value.action ?? null,
3202
- kycLevel: value.kyc_level,
3203
- kycReset: value.kyc_reset
3204
- }
3205
- )
3206
- };
3207
-
3208
- // src/universal/api/frontline/requirements.ts
3209
- async function fetchOfferRequirements(api, offerId, clientCreds) {
3210
- const response = await api.send({
3211
- method: "GET",
3212
- url: `/v1/offers/${offerId}/requirements`,
3213
- attributes: Attributes.concat(
3214
- Attributes.protected(),
3215
- Attributes.clientCredentials(clientCreds)
3216
- )
3217
- });
3218
- return Object.fromEntries(
3219
- Object.entries(response.options).map(([optionId, list]) => [
3220
- optionId,
3221
- list.data.map(Requirement.fromDto)
3222
- ])
3223
- );
3224
- }
3225
- async function fetchRequirementStatuses(api, offerId) {
3226
- const response = await api.send({
3227
- method: "GET",
3228
- url: `/v1/offers/${offerId}/requirements/statuses`,
3229
- attributes: Attributes.protected()
3230
- });
3231
- return RequirementStatusInfo.fromStatusesDto(response);
3232
- }
3233
-
3234
- // src/universal/core/requirements/requirements-namespace.ts
3235
- var RequirementsNamespaceImpl = class {
3236
- constructor(ctx) {
3237
- this.ctx = ctx;
3238
- this.log = internalLogger(ctx.logger, "REQUIREMENTS");
3239
- }
3240
- async forOffer(offerId) {
3241
- return this.log.wrap("forOffer", offerId, async () => {
3242
- await this.ctx.ensureUserAuthenticated();
3243
- return fetchOfferRequirements(
3244
- this.ctx.api,
3245
- offerId,
3246
- void 0
3247
- );
3248
- });
3249
- }
3250
- async statuses(offerId) {
3251
- return this.log.wrap("statuses", offerId, async () => {
3252
- await this.ctx.ensureUserAuthenticated();
3253
- return fetchRequirementStatuses(this.ctx.api, offerId);
3254
- });
3255
- }
3256
- async createKycToken(params) {
3257
- return this.log.wrap("createKycToken", params, async () => {
3258
- await this.ctx.ensureUserAuthenticated();
3259
- return createKycToken(
3260
- this.ctx.api,
3261
- params?.levelName,
3262
- params?.reset
3263
- );
3264
- });
3265
- }
3266
- async getPii() {
3267
- return this.log.wrap("getPii", void 0, async () => {
3268
- await this.ctx.ensureUserAuthenticated();
3269
- return fetchPii(this.ctx.api);
3270
- });
3271
- }
3272
- async submitDocument(params) {
3273
- return this.log.wrap("submitDocument", params, async () => {
3274
- await this.ctx.ensureUserAuthenticated();
3275
- return submitDocument(
3276
- this.ctx.api,
3277
- params.documentType,
3278
- params.fields
3279
- );
3280
- });
3281
- }
3282
- };
3283
-
3284
- // src/universal/api/rpc/erc20.ts
3285
- async function getTokenAllowance(clients, params) {
3286
- const allowance = await clients(params.chain).readContract({
3287
- address: params.tokenAddress,
3288
- abi: ERC20_ABI,
3289
- functionName: "allowance",
3290
- args: [params.owner, params.spender]
3291
- });
3292
- return parseUint256(allowance, "allowance");
3293
- }
3294
- async function getTokenBalance(clients, params) {
3295
- const balance = await clients(params.chain).readContract({
3296
- address: params.tokenAddress,
3297
- abi: ERC20_ABI,
3298
- functionName: "balanceOf",
3299
- args: [params.owner]
3300
- });
3301
- return parseUint256(balance, "balanceOf");
3302
- }
3303
-
3304
- // src/universal/core/shared/blockchain/erc20/erc20-namespace.ts
3305
- var Erc20NamespaceImpl = class {
3306
- constructor(ctx) {
3307
- this.ctx = ctx;
3308
- this.log = internalLogger(ctx.logger, "ERC20");
3309
- }
3310
- async getAllowance(params) {
3311
- return this.log.wrap(
3312
- "getAllowance",
3313
- params,
3314
- async () => getTokenAllowance(this.ctx.rpc, params)
3315
- );
3316
- }
3317
- async getBalance(params) {
3318
- return this.log.wrap(
3319
- "getBalance",
3320
- params,
3321
- async () => getTokenBalance(this.ctx.rpc, params)
3322
- );
3323
- }
3324
- };
3325
-
3326
- // src/universal/core/tokens/token-registry-snapshot.ts
3327
- var TokenRegistrySnapshot = {
3328
- /** Indexes a `tokens.list()` result. `[]` is a valid, empty snapshot. */
3329
- fromTokens: (tokens) => ({
3330
- tokens,
3331
- byKey: new Map(
3332
- tokens.map((token) => [registryKey(token.identifier), token])
3333
- )
3334
- }),
3335
- /**
3336
- * The registry's entry for one token, or `null` when it lists none. The
3337
- * registry is curated, so `null` is an ordinary answer rather than an
3338
- * error, and callers fall back to their own display defaults.
3339
- */
3340
- get: (snapshot, token) => snapshot.byKey.get(registryKey(token)) ?? null,
3341
- /**
3342
- * The registry's entry for the token an offer is *about*, or `null` when
3343
- * it lists none of them.
3344
- *
3345
- * Resolution follows {@link offerDisplayTokens}: the token a sale
3346
- * distributes or a swap hands over, never the funding token the user pays
3347
- * with. An offer deployed on several chains carries one such token per
3348
- * chain, and the first the registry knows wins - they are the same asset,
3349
- * so any listed one answers for the offer.
3350
- */
3351
- forOffer: (snapshot, offer) => {
3352
- for (const token of offerDisplayTokens(offer)) {
3353
- const metadata = TokenRegistrySnapshot.get(snapshot, token);
3354
- if (metadata !== null) {
3355
- return metadata;
3356
- }
3357
- }
3358
- return null;
3359
- }
3360
- };
3361
- function offerDisplayTokens(offer) {
3362
- const swaps = offer.tokens.filter((token) => token.role === "swap");
3363
- const distributions = offer.tokens.filter(
3364
- (token) => token.role === "distribution"
3365
- );
3366
- return [...swaps, ...distributions];
3367
- }
3368
- function registryKey(token) {
3369
- return `${token.chain}:${token.address.toLowerCase()}`;
3370
- }
3371
-
3372
- // src/universal/api/nabu/tokens.ts
3373
- var import_viem5 = require("viem");
3374
-
3375
- // src/universal/api/frontline/config.ts
3376
- var HEADER_API_VERSION = "X-API-Version";
3377
-
3378
- // src/universal/api/http-client.ts
3379
- var HttpClient = class {
3380
- constructor(config, middleware = {}, logger = null, options = {}) {
3381
- this.config = config;
3382
- this.middleware = middleware;
3383
- this.log = internalLogger(logger, "HTTP");
3384
- this.makeRequestId = options.makeRequestId ?? defaultMakeRequestId;
3385
- }
3386
- async send(request) {
3387
- return this.runRequestWithAfterMiddleware(request);
3388
- }
3389
- /**
3390
- * Runs beforeRequest, executeRequest, then the full afterRequest middleware
3391
- * chain. Used by send() and by the retry() callback so that when a
3392
- * middleware calls retry(), the retried response also goes through all
3393
- * afterRequest middleware (e.g. session renewal, retry). Middleware
3394
- * must use request.attributes.retryAttempt (or similar) to avoid infinite
3395
- * recursion when they trigger retries.
3396
- */
3397
- async runRequestWithAfterMiddleware(request) {
3398
- const preparedRequest = await this.runBeforeRequestMiddleware(
3399
- this.withClientDefaults(request)
3400
- );
3401
- let response = await this.executeRequest(preparedRequest);
3402
- for (const middleware of this.middleware.afterRequest ?? []) {
3403
- let retried = false;
3404
- response = await middleware({
3405
- request: preparedRequest,
3406
- response,
3407
- retry: (nextRequest = preparedRequest) => {
3408
- retried = true;
3409
- return this.runRequestWithAfterMiddleware(nextRequest);
3410
- }
3411
- });
3412
- if (retried) {
3413
- return response;
3414
- }
3415
- }
3416
- return response;
3417
- }
3418
- withClientDefaults(request) {
3419
- const url = this.resolveUrl(request.url);
3420
- const headers = {
3421
- ...request.headers ?? {},
3422
- ...this.config.xApiVersion !== void 0 ? { [HEADER_API_VERSION]: this.config.xApiVersion } : {}
3423
- };
3424
- return {
3425
- ...request,
3426
- url,
3427
- headers,
3428
- // Only when absent: a retry or a post-renewal re-send arrives with the
3429
- // first attempt's id already on it, and keeping it is the whole point.
3430
- attributes: Attributes.getRequestId(request.attributes) === null ? Attributes.concat(
3431
- request.attributes ?? Attributes.empty,
3432
- Attributes.requestId(this.makeRequestId())
3433
- ) : request.attributes
3434
- };
3435
- }
3436
- /**
3437
- * Resolves a request URL against the client's baseUrl.
3438
- *
3439
- * @internal Public only for testing. Do not use in application code; use
3440
- * {@link HttpClient.send} with a path and the client will resolve the URL.
3441
- */
3442
- resolveUrl(url) {
3443
- if (url.startsWith("http://") || url.startsWith("https://")) {
3444
- return url;
3445
- }
3446
- const base2 = this.config.baseUrl.replace(/\/$/, "");
3447
- const path = url.startsWith("/") ? url : `/${url}`;
3448
- return base2 + path;
3449
- }
3450
- async runBeforeRequestMiddleware(initialRequest) {
3451
- let request = initialRequest;
3452
- for (const middleware of this.middleware.beforeRequest ?? []) {
3453
- request = await middleware(request);
3454
- }
3455
- return request;
3456
- }
3457
- /**
3458
- * One physical attempt, logged as one line.
3459
- *
3460
- * A non-2xx is a `warn` rather than an `error` because the wire does not
3461
- * know whether it is a failure: the retry middleware may turn a 503 into a
3462
- * success, and the token registry reads a 404 as "not listed". The namespace
3463
- * above decides, and logs the `error` when it does.
3464
- */
3465
- async executeRequest(request) {
3466
- const requestId2 = Attributes.getRequestId(request.attributes);
3467
- const log = requestId2 === null ? this.log : this.log.child({ requestId: requestId2 });
3468
- const attempt = Attributes.getRetryAttempt(request.attributes) + 1;
3469
- const startedAt = Date.now();
3470
- log.debug(() => ({
3471
- msg: "request sent",
3472
- fields: describeRequestUnredacted(request)
3473
- }));
3474
- try {
3475
- const response = await makeRequest(request);
3476
- const elapsed = Date.now() - startedAt;
3477
- const outcome = () => ({
3478
- msg: "request completed",
3479
- fields: {
3480
- ...identifyRequest(request),
3481
- "http.response.status_code": response.status,
3482
- duration_ms: elapsed,
3483
- attempt
3484
- }
3485
- });
3486
- if (response.status >= 200 && response.status < 300) {
3487
- log.info(outcome);
3488
- } else {
3489
- log.warn(outcome);
3490
- }
3491
- log.debug(() => ({
3492
- msg: "response received",
3493
- fields: { body: response.body }
3494
- }));
3495
- return requestId2 === null ? response : { ...response, requestId: requestId2 };
3496
- } catch (error) {
3497
- const elapsed = Date.now() - startedAt;
3498
- log.warning(
3499
- () => ({
3500
- msg: "request threw",
3501
- fields: {
3502
- ...identifyRequest(request),
3503
- duration_ms: elapsed,
3504
- attempt
3505
- }
3506
- }),
3507
- error
3508
- );
3509
- throw error;
3510
- }
3511
- }
3512
- };
3513
- function identifyRequest(request) {
3514
- const { host, path } = splitUrl(request.url);
3515
- return {
3516
- "http.request.method": request.method,
3517
- "server.address": host,
3518
- "url.path": path
3519
- };
3520
- }
3521
- function splitUrl(url) {
3522
- try {
3523
- const parsed = new URL(url);
3524
- return { host: parsed.host, path: parsed.pathname };
3525
- } catch (_) {
3526
- return { host: null, path: url };
3527
- }
3528
- }
3529
- function defaultMakeRequestId() {
3530
- return Math.random().toString(36).slice(2, 10).padEnd(8, "0");
3531
- }
3532
- function describeRequestUnredacted(request) {
3533
- return {
3534
- "http.request.method": request.method,
3535
- "url.full": buildUrlWithQueryParams(request.url, request.queryParams),
3536
- headers: request.headers,
3537
- ...request.method === "POST" ? { body: request.body } : {}
3538
- };
3539
- }
3540
-
3541
- // src/universal/types/token-metadata.ts
3542
- var TokenLogoUrl = (value) => value;
3543
- var TokenLogo = {
3544
- /** `baseUrl` is the registry origin; registry URLs are root-relative. */
3545
- fromDto: (dto, baseUrl) => dto.kind === "VECTOR" ? { kind: "VECTOR", url: resolveLogoUrl(dto.url, baseUrl) } : {
3546
- kind: "RASTER",
3547
- original: logoImageFromDto(dto.original, baseUrl),
3548
- variants: dto.variants.map((v) => logoImageFromDto(v, baseUrl))
3549
- }
3550
- };
3551
- var TokenMetadata = {
3552
- /** `baseUrl` is the registry origin; registry logo URLs are root-relative. */
3553
- fromDto: (dto, baseUrl) => {
3554
- assertSupportedSchemaVersion(dto.schema_version);
3555
- return {
3556
- identifier: {
3557
- chain: EthereumChain(dto.chain),
3558
- address: EvmContractAddress(dto.address)
3559
- },
3560
- name: dto.name,
3561
- symbol: AssetSymbol(dto.symbol),
3562
- decimals: AssetDecimals(dto.decimals),
3563
- logo: TokenLogo.fromDto(dto.logo, baseUrl),
3564
- logoDark: dto.logo_dark === void 0 ? null : TokenLogo.fromDto(dto.logo_dark, baseUrl)
3565
- };
3566
- },
3567
- /**
3568
- * Maps the complete registry snapshot to every token it lists across the
3569
- * chains this SDK models, skipping native coins and chains outside
3570
- * {@link EthereumChain} (e.g. Solana) rather than failing on them — the
3571
- * registry may serve chains ahead of the SDK's type surface.
3572
- */
3573
- fromRegistryDto: (dto, baseUrl) => {
3574
- assertSupportedSchemaVersion(dto.schema_version);
3575
- return dto.chains.flatMap((chainDto) => {
3576
- let chain;
3577
- try {
3578
- chain = EthereumChain(chainDto.chain);
3579
- } catch {
3580
- return [];
3581
- }
3582
- return tokensOfChain(chain, chainDto.assets, baseUrl);
3583
- });
3584
- },
3585
- /**
3586
- * Maps a chain snapshot to the tokens it lists, skipping the chain's native
3587
- * coin (`kind: 'COIN'`, no contract address).
3588
- */
3589
- fromChainAssetsDto: (dto, baseUrl) => {
3590
- assertSupportedSchemaVersion(dto.schema_version);
3591
- return tokensOfChain(EthereumChain(dto.chain), dto.assets, baseUrl);
3592
- }
3593
- };
3594
- function tokensOfChain(chain, assets, baseUrl) {
3595
- return assets.filter((asset) => asset.kind === "TOKEN" && asset.address !== void 0).map((asset) => ({
3596
- identifier: {
3597
- chain,
3598
- // The filter above cannot narrow `address` for the type checker.
3599
- address: EvmContractAddress(asset.address)
3600
- },
3601
- name: asset.name,
3602
- symbol: AssetSymbol(asset.symbol),
3603
- decimals: AssetDecimals(asset.decimals),
3604
- logo: TokenLogo.fromDto(asset.logo, baseUrl),
3605
- logoDark: asset.logo_dark === void 0 ? null : TokenLogo.fromDto(asset.logo_dark, baseUrl)
3606
- }));
3607
- }
3608
- function assertSupportedSchemaVersion(version) {
3609
- if (version !== 1) {
3610
- throw new ValidationError(
3611
- `Unsupported token registry schema_version: ${version}`
3612
- );
3613
- }
3614
- }
3615
- var logoImageFromDto = (dto, baseUrl) => ({
3616
- url: resolveLogoUrl(dto.url, baseUrl),
3617
- width: dto.width,
3618
- height: dto.height
3619
- });
3620
- var resolveLogoUrl = (url, baseUrl) => TokenLogoUrl(
3621
- url.startsWith("http") ? url : `${baseUrl.replace(/\/$/, "")}${url}`
3622
- );
3623
-
3624
- // src/universal/api/nabu/tokens.ts
3625
- function createNabuApiClient(baseUrl, logger = null) {
3626
- return new HttpClient({ baseUrl }, {}, logger);
3627
- }
3628
- async function fetchTokenMetadata(client, token) {
3629
- const address = checksummed(token.address);
3630
- let response;
3631
- try {
3632
- response = await client.send({
3633
- method: "GET",
3634
- url: `/${token.chain}/token/${address}`
3635
- });
3636
- } catch (error) {
3637
- if (isRegistryHtmlFallback(error)) {
3638
- return null;
3639
- }
3640
- throw error;
3641
- }
3642
- if (response.status === 404) {
3643
- return null;
3644
- }
3645
- assertOk(response);
3646
- if (response.body === null) {
3647
- throw new ValidationError(
3648
- `Token registry returned an empty body for token "${address}" on "${token.chain}"`
3649
- );
3650
- }
3651
- return TokenMetadata.fromDto(response.body, client.config.baseUrl);
3652
- }
3653
- async function fetchTokensMetadata(client, chain) {
3654
- let response;
3655
- try {
3656
- response = await client.send({
3657
- method: "GET",
3658
- url: `/${chain}/assets.json`
3659
- });
3660
- } catch (error) {
3661
- if (isRegistryHtmlFallback(error)) {
3662
- throw new ValidationError(
3663
- `Token registry returned non-JSON for the "${chain}" snapshot`
3664
- );
3665
- }
3666
- throw error;
3667
- }
3668
- assertOk(response);
3669
- if (response.body === null) {
3670
- throw new ValidationError(
3671
- `Token registry returned an empty "${chain}" snapshot`
3672
- );
3673
- }
3674
- return TokenMetadata.fromChainAssetsDto(response.body, client.config.baseUrl);
3675
- }
3676
- async function fetchAllTokensMetadata(client) {
3677
- let response;
3678
- try {
3679
- response = await client.send({
3680
- method: "GET",
3681
- url: `/assets.json`
3682
- });
3683
- } catch (error) {
3684
- if (isRegistryHtmlFallback(error)) {
3685
- throw new ValidationError(
3686
- "Token registry returned non-JSON for the complete snapshot"
3687
- );
3688
- }
3689
- throw error;
3690
- }
3691
- assertOk(response);
3692
- if (response.body === null) {
3693
- throw new ValidationError(
3694
- "Token registry returned an empty complete snapshot"
3695
- );
3696
- }
3697
- return TokenMetadata.fromRegistryDto(response.body, client.config.baseUrl);
3698
- }
3699
- function isRegistryHtmlFallback(error) {
3700
- return error instanceof HttpError && error.response.status >= 200 && error.response.status < 300;
3701
- }
3702
- function assertOk(response) {
3703
- if (response.status < 200 || response.status >= 300) {
3704
- throw new HttpError(response);
3705
- }
3706
- }
3707
- function checksummed(address) {
3708
- try {
3709
- return (0, import_viem5.getAddress)(address);
3710
- } catch (_) {
3711
- throw new ValidationError(`Invalid EVM contract address: "${address}"`);
3712
- }
3713
- }
3714
-
3715
- // src/universal/core/tokens/tokens-namespace.ts
3716
- var TokensNamespaceImpl = class {
3717
- /**
3718
- * Takes the registry origin rather than a `UniversalNamespaceContext`: the
3719
- * registry is unauthenticated and on its own host, so the frontline sender
3720
- * and the auth check would both be dead weight here.
3721
- */
3722
- constructor(baseUrl, logger = null) {
3723
- this.api = createNabuApiClient(baseUrl, logger);
3724
- this.log = internalLogger(logger, "TOKENS");
3725
- }
3726
- get(token) {
3727
- return this.log.wrap(
3728
- "get",
3729
- token,
3730
- () => fetchTokenMetadata(this.api, token)
3731
- );
3732
- }
3733
- list(chain) {
3734
- return this.log.wrap(
3735
- "list",
3736
- chain,
3737
- () => chain === void 0 ? fetchAllTokensMetadata(this.api) : fetchTokensMetadata(this.api, chain)
3738
- );
3739
- }
3740
- };
3741
-
3742
- // src/universal/types/offer-option-address.ts
3743
- var OfferOptionAddressId = (value) => value;
3744
- var OfferOptionAddress = {
3745
- /** Maps the API DTO into the SDK offer-option-address domain model. */
3746
- fromDto: (dto) => ({
3747
- id: OfferOptionAddressId(dto.id),
3748
- offerOptionId: OfferOptionId(dto.offer_option_id),
3749
- address: EvmWalletAddress(dto.address),
3750
- protocol: dto.protocol,
3751
- createdAt: new Date(dto.created_at)
3752
- })
3753
- };
3754
- var ConnectExternalWalletParams = {
3755
- /** Maps connect-wallet params into the API DTO payload. */
3756
- toDto: (params) => ({
3757
- offer_option_id: params.offerOptionId,
3758
- wallet_address: params.walletAddress,
3759
- chain: params.chain,
3760
- signature: params.signature
3761
- })
3762
- };
3763
-
3764
- // src/universal/types/wallet-ownership-challenge.ts
3765
- var WalletOwnershipChallenge = {
3766
- /** Maps the API DTO into the SDK wallet-ownership-challenge domain model. */
3767
- fromDto: (dto) => ({
3768
- message: dto.message,
3769
- expiresAt: new Date(dto.expires_at)
3770
- })
3771
- };
3772
- var CreateWalletOwnershipChallengeParams = {
3773
- /**
3774
- * Maps challenge-request params into the API DTO payload. The discriminated
3775
- * union guarantees SIWE fields are present exactly when `challengeType` is
3776
- * `siwe`, so the mapping narrows on the discriminant.
3777
- */
3778
- toDto: (params) => {
3779
- switch (params.challengeType) {
3780
- case "plain":
3781
- return {
3782
- wallet_address: params.walletAddress,
3783
- chain: params.chain,
3784
- challenge_type: "plain"
3785
- };
3786
- case "siwe":
3787
- return {
3788
- wallet_address: params.walletAddress,
3789
- chain: params.chain,
3790
- challenge_type: "siwe",
3791
- domain: params.domain,
3792
- uri: params.uri,
3793
- statement: params.statement
3794
- };
3795
- default: {
3796
- const _exhaustive = params;
3797
- return _exhaustive;
3798
- }
3799
- }
3800
- }
3801
- };
3802
-
3803
- // src/universal/api/frontline/wallet-connect.ts
3804
- async function createWalletOwnershipChallenge(api, params) {
3805
- const dto = await api.send({
3806
- method: "POST",
3807
- url: "/v1/wallet-ownership",
3808
- body: CreateWalletOwnershipChallengeParams.toDto(params),
3809
- attributes: Attributes.protected()
3810
- });
3811
- return WalletOwnershipChallenge.fromDto(dto);
3812
- }
3813
- async function connectExternalWallet(api, params) {
3814
- const dto = await api.send({
3815
- method: "POST",
3816
- url: `/v1/offers/${params.offerId}/addresses`,
3817
- body: ConnectExternalWalletParams.toDto(params),
3818
- attributes: Attributes.protected()
3819
- });
3820
- return OfferOptionAddress.fromDto(dto);
3821
- }
3822
- async function listOptionAddresses(api, offerId, offerOptionId) {
3823
- const { data } = await api.send({
3824
- method: "GET",
3825
- url: `/v1/offers/${offerId}/addresses`,
3826
- queryParams: { offer_option_id: offerOptionId },
3827
- attributes: Attributes.protected()
3828
- });
3829
- return data.map(OfferOptionAddress.fromDto);
3830
- }
3831
- async function removeOptionAddress(api, offerId, addressId) {
3832
- const dto = await api.send({
3833
- method: "DELETE",
3834
- url: `/v1/offers/${offerId}/addresses/${addressId}`,
3835
- attributes: Attributes.protected()
3836
- });
3837
- return OfferOptionAddress.fromDto(dto);
3838
- }
3839
-
3840
- // src/universal/core/wallets/wallets-namespace.ts
3841
- var WalletsNamespaceImpl = class {
3842
- constructor(ctx) {
3843
- this.ctx = ctx;
3844
- this.log = internalLogger(ctx.logger, "WALLETS");
3845
- }
3846
- async createOwnershipChallenge(params) {
3847
- return this.log.wrap("createOwnershipChallenge", params, async () => {
3848
- await this.ctx.ensureUserAuthenticated();
3849
- return createWalletOwnershipChallenge(
3850
- this.ctx.api,
3851
- params
3852
- );
3853
- });
3854
- }
3855
- async connectExternal(params) {
3856
- return this.log.wrap("connectExternal", params, async () => {
3857
- await this.ctx.ensureUserAuthenticated();
3858
- return connectExternalWallet(this.ctx.api, params);
3859
- });
3860
- }
3861
- async list(params) {
3862
- return this.log.wrap("list", params, async () => {
3863
- await this.ctx.ensureUserAuthenticated();
3864
- return listOptionAddresses(
3865
- this.ctx.api,
3866
- params.offerId,
3867
- params.offerOptionId
3868
- );
3869
- });
3870
- }
3871
- async remove(params) {
3872
- return this.log.wrap("remove", params, async () => {
3873
- await this.ctx.ensureUserAuthenticated();
3874
- return removeOptionAddress(
3875
- this.ctx.api,
3876
- params.offerId,
3877
- params.addressId
3878
- );
3879
- });
3880
- }
3881
- };
3882
-
3883
- // src/universal/types/blockchain/wallet-error.ts
3884
- var RedactedWalletError = {
3885
- fromWalletError: (error) => error.type === "unknown" ? { type: "unknown" } : error
3886
- };
3887
-
3888
- // src/universal/types/oauth-session.ts
3889
- var ClientCredentialsOAuth = (value) => value;
3890
- var OAuthRefreshToken = (value) => value;
3891
- var OAuthSession = {
3892
- fromDto: (dto) => {
3893
- const expiresAt = new Date(Date.now() + dto.expires_in * 1e3);
3894
- return {
3895
- accessToken: {
3896
- value: dto.access_token,
3897
- expiresAt
3898
- },
3899
- ...dto.refresh_token != null && dto.refresh_token !== "" ? { refreshToken: OAuthRefreshToken(dto.refresh_token) } : void 0
3900
- };
3901
- }
3902
- };
3903
-
3904
- // src/universal/types/time.ts
3905
- var MAX_EPOCH_MILLIS = 864e13;
3906
- var EpochMillis = {
3907
- /**
3908
- * @throws {@link ValidationError} unless `value` is an integer a `Date` can
3909
- * represent: at most {@link MAX_EPOCH_MILLIS} either side of the epoch.
3910
- */
3911
- of: (value) => {
3912
- if (!Number.isInteger(value) || Math.abs(value) > MAX_EPOCH_MILLIS) {
3913
- throw new ValidationError(
3914
- `EpochMillis must be an integer within \xB1${MAX_EPOCH_MILLIS}, got ${value}`
3915
- );
3916
- }
3917
- return value;
3918
- },
3919
- /** The wall clock. Code that needs the time takes a `TimeEff` instead. */
3920
- now: () => EpochMillis.of(Date.now()),
3921
- /** @throws {@link ValidationError} for an invalid `Date`. */
3922
- fromDate: (date) => EpochMillis.of(date.getTime()),
3923
- /** How long after `from` the instant `to` is; negative if it is before. */
3924
- elapsed: (from, to) => Millis.of(to - from),
3925
- plus: (at, duration) => EpochMillis.of(at + duration)
3926
- };
3927
- var Millis = {
3928
- of: (value) => value
3929
- };
3930
- var Seconds = {
3931
- /**
3932
- * @throws {@link ValidationError} unless `value` is a non-negative integer.
3933
- */
3934
- of: (value) => {
3935
- if (!Number.isInteger(value) || value < 0) {
3936
- throw new ValidationError(
3937
- `Seconds must be a non-negative integer, got ${value}`
3938
- );
3939
- }
3940
- return value;
3941
- },
3942
- toMillis: (value) => Millis.of(value * 1e3)
3943
- };
3944
- function isExpired({
3945
- expiresAt,
3946
- now,
3947
- buffer = Millis.of(0)
3948
- }) {
3949
- return now >= expiresAt - buffer;
3950
- }
3951
-
3952
- // src/universal/types/user.ts
3953
- var UserId = (value) => value;
3954
- var UserEmail = (value) => value;
3955
- var User = {
3956
- fromDto: (dto) => ({
3957
- id: UserId(dto.id),
3958
- email: UserEmail(dto.email)
3959
- })
3960
- };
3961
- // Annotate the CommonJS export names for ESM import in node:
3962
- 0 && (module.exports = {
3963
- AllowWalletResponse,
3964
- Asset,
3965
- AssetCode,
3966
- AssetDecimals,
3967
- AssetIconUrl,
3968
- AssetId,
3969
- AssetSymbol,
3970
- AuthorizationCode,
3971
- BPS_DENOM,
3972
- Blockchain,
3973
- BlockchainAmount,
3974
- Bps,
3975
- Chain,
3976
- ClientCredentialsOAuth,
3977
- ClientId,
3978
- ClientSecret,
3979
- CodeChallenge,
3980
- CodeVerifier,
3981
- CoinListTokenSaleNamespaceImpl,
3982
- ConnectExternalWalletParams,
3983
- CreateParticipationParams,
3984
- CreateWalletOwnershipChallengeParams,
3985
- Cursor,
3986
- DEFAULT_AMOUNT_TO_COMPUTE_PRICE,
3987
- DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE,
3988
- DEFAULT_ONDO_SELL_TOKENS_TO_COMPUTE_PRICE,
3989
- DEFAULT_SLIPPAGE_BPS,
3990
- DecimalString,
3991
- DocumentSubmission,
3992
- ERC20_ABI,
3993
- ETHEREUM_CHAINS,
3994
- EpochMillis,
3995
- Erc20NamespaceImpl,
3996
- EthereumChain,
3997
- EvmContractAddress,
3998
- EvmWalletAddress,
3999
- FaqItem,
4000
- FormattedAmountAssetUi,
4001
- FormattedAmountUi,
4002
- FormattedPercentUi,
4003
- HexEncodedTransactionData,
4004
- HttpError,
4005
- InvariantError,
4006
- Isin,
4007
- Iso2CountryCode,
4008
- KnownAssetSymbol,
4009
- KycToken,
4010
- Link,
4011
- MAX_ASSET_DECIMALS,
4012
- MAX_UINT_256,
4013
- MathError,
4014
- Milestone,
4015
- Millis,
4016
- NA_AMOUNT_ASSET_UI,
4017
- NotAuthenticatedError,
4018
- NotImplementedError,
4019
- OAuthRefreshToken,
4020
- OAuthSession,
4021
- ONDO_NOT_TRADABLE_CODE,
4022
- ONDO_POLL_INTERVAL_MS,
4023
- ONDO_QUOTE_MAX_TTL_MS,
4024
- ONDO_SETTLEMENT_ASSET,
4025
- ONDO_SUPPORTED_INPUT_ASSETS,
4026
- Offer,
4027
- OfferDetail,
4028
- OfferEditorial,
4029
- OfferId,
4030
- OfferOption,
4031
- OfferOptionAddress,
4032
- OfferOptionAddressId,
4033
- OfferOptionId,
4034
- OfferOptionSlug,
4035
- OfferSlug,
4036
- OfferSwapContract,
4037
- OfferToken,
4038
- OffersNamespaceImpl,
4039
- OndoBuyTransaction,
4040
- OndoNamespaceImpl,
4041
- OndoQuote,
4042
- OndoSellTransaction,
4043
- OndoTradingStatus,
4044
- PKCEState,
4045
- PaginatedResponse,
4046
- PaginationParams,
4047
- Participation,
4048
- ParticipationId,
4049
- ParticipationsPaginationParams,
4050
- PauseFlags,
4051
- Pii,
4052
- PiiAddress,
4053
- PiiJurisdiction,
4054
- RedactedWalletError,
4055
- RedirectUri,
4056
- Requirement,
4057
- RequirementId,
4058
- RequirementStatusInfo,
4059
- RequirementsNamespaceImpl,
4060
- SLIPPAGE_OPTIONS_BPS,
4061
- SOLANA_CHAINS,
4062
- STABLE_DECIMALS,
4063
- SUPERSTATE_ISSUER_NAME,
4064
- SUPERSTATE_SUPPORTED_INPUT_ASSETS,
4065
- SUPERSTATE_SWAP_ABI,
4066
- SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA,
4067
- SWAP_LEVEL,
4068
- SWAP_POLL_INTERVAL_MS,
4069
- Seconds,
4070
- ShortenedWalletAddress,
4071
- SolanaChain,
4072
- StablecoinSymbol,
4073
- SuperstateSwapNamespaceImpl,
4074
- SwapPreview,
4075
- SwapQuote,
4076
- SwapStatus,
4077
- TOKEN_REGISTRY,
4078
- TermItem,
4079
- Ticker,
4080
- TokenLogo,
4081
- TokenLogoUrl,
4082
- TokenMetadata,
4083
- TokenRegistrySnapshot,
4084
- TokensNamespaceImpl,
4085
- TxExplorerUrl,
4086
- USDC,
4087
- USDC_SYMBOL,
4088
- USDT,
4089
- USDT_SYMBOL,
4090
- User,
4091
- UserEmail,
4092
- UserId,
4093
- ValidationError,
4094
- WalletAddress,
4095
- WalletOwnershipChallenge,
4096
- WalletsNamespaceImpl,
4097
- apiErrorCode,
4098
- applyBps,
4099
- assertUint256,
4100
- assetAmount,
4101
- blockchainAmountFromRawOrThrow,
4102
- chainFromId,
4103
- computeOndoBuyPrice,
4104
- computeOndoSellPrice,
4105
- computePrice,
4106
- computeSlip,
4107
- decodeSwappedOutputAmount,
4108
- fetchAllPages,
4109
- formatAmount,
4110
- formatBpsAsPercent,
4111
- formatCompactAmount,
4112
- formatRawAmount,
4113
- formatShareAmount,
4114
- formattedPricePerShare,
4115
- formattedUsdPrice,
4116
- generatePKCEParams,
4117
- getChainId,
4118
- getNetworkName,
4119
- isChain,
4120
- isExpired,
4121
- isOfferType,
4122
- isOndoNotTradableError,
4123
- isSwapAvailable,
4124
- offerDisplayTokens,
4125
- ondoQuoteOfferDeadline,
4126
- parseBlockchainAmount,
4127
- parseUint256,
4128
- shortenAddress,
4129
- superstateSwapContractAddress,
4130
- swapSpender,
4131
- txExplorerUrl,
4132
- usdAmount,
4133
- viemChain
4134
- });
4135
- //# sourceMappingURL=index.cjs.map