@coinlist-co/react 0.12.2-rc.8a0d02a → 0.12.2-rc.8a65e9d

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 (35) hide show
  1. package/README.md +10 -0
  2. package/dist/{chunk-C6GF7MDF.js → chunk-2FZAXGVH.js} +1011 -1184
  3. package/dist/chunk-2FZAXGVH.js.map +1 -0
  4. package/dist/{chunk-IZJ4JSSC.js → chunk-EAPBF7T2.js} +152 -234
  5. package/dist/chunk-EAPBF7T2.js.map +1 -0
  6. package/dist/chunk-IWQ6A52U.js +24 -0
  7. package/dist/chunk-IWQ6A52U.js.map +1 -0
  8. package/dist/{chunk-3WW5FLT7.js → chunk-OQ2ANYUF.js} +334 -27
  9. package/dist/chunk-OQ2ANYUF.js.map +1 -0
  10. package/dist/client/index.d.ts +3277 -5736
  11. package/dist/client/index.js +10835 -10729
  12. package/dist/client/index.js.map +1 -1
  13. package/dist/client-credentials-BwcmPcn-.d.ts +13 -0
  14. package/dist/server/index.d.ts +54 -132
  15. package/dist/server/index.js +211 -171
  16. package/dist/server/index.js.map +1 -1
  17. package/dist/{time-CVZpAkGY.d.cts → time-ChSGmKZe.d.ts} +2194 -3422
  18. package/dist/{token-registry-snapshot-BkwA8KmD.d.ts → token-registry-snapshot-DMubXr2c.d.ts} +22 -58
  19. package/dist/universal/index.d.ts +94 -1068
  20. package/dist/universal/index.js +25 -47
  21. package/package.json +18 -14
  22. package/dist/chunk-3WW5FLT7.js.map +0 -1
  23. package/dist/chunk-C6GF7MDF.js.map +0 -1
  24. package/dist/chunk-IZJ4JSSC.js.map +0 -1
  25. package/dist/client/index.cjs +0 -20460
  26. package/dist/client/index.cjs.map +0 -1
  27. package/dist/client/index.d.cts +0 -8195
  28. package/dist/server/index.cjs +0 -4525
  29. package/dist/server/index.cjs.map +0 -1
  30. package/dist/server/index.d.cts +0 -382
  31. package/dist/time-CVZpAkGY.d.ts +0 -3987
  32. package/dist/token-registry-snapshot-bR14QehS.d.cts +0 -245
  33. package/dist/universal/index.cjs +0 -4562
  34. package/dist/universal/index.cjs.map +0 -1
  35. package/dist/universal/index.d.cts +0 -1362
@@ -1,93 +1,4 @@
1
- // src/universal/api/internal-access-token-source.ts
2
- var SentWith = {
3
- userToken: (token) => ({
4
- type: "user-token",
5
- token
6
- }),
7
- noUserToken: { type: "no-user-token" }
8
- };
9
- var TokenTrigger = {
10
- beforeRequest: { type: "before-request" },
11
- after401: (rejected) => ({
12
- type: "after-401",
13
- rejected
14
- })
15
- };
16
- function isRejectedToken(token, rejected) {
17
- switch (rejected.type) {
18
- case "user-token":
19
- return rejected.token.value === token.value;
20
- case "no-user-token":
21
- return false;
22
- }
23
- }
24
-
25
- // src/universal/api/http-attributes.ts
26
- var empty = {};
27
- var concat = (left, right) => ({
28
- ...left,
29
- ...right
30
- });
31
- var concatAll = (...items) => {
32
- let result = empty;
33
- for (const item of items) {
34
- result = concat(result, item);
35
- }
36
- return result;
37
- };
38
- var protectedRequest = () => ({ protected: true });
39
- var userAgent = () => ({ userAgent: true });
40
- var idempotencyKey = () => ({
41
- idempotencyKey: true
42
- });
43
- var clientCredentials = (credentials) => ({
44
- clientCredentials: credentials
45
- });
46
- var retryAttempt = (attempt) => ({
47
- retryAttempt: attempt
48
- });
49
- var renewAttempted = (value) => ({
50
- renewAttempted: value
51
- });
52
- var notRetryable = () => ({ retryable: false });
53
- var sentWith = (token) => ({
54
- sentWith: token
55
- });
56
- var requestId = (id) => ({ requestId: id });
57
- var getRequestId = (attrs) => attrs?.requestId ?? null;
58
- var isProtected = (attrs) => attrs?.protected === true;
59
- var needUserAgent = (attrs) => attrs?.userAgent === true;
60
- var isIdempotent = (attrs) => attrs?.idempotencyKey === true;
61
- var getRetryAttempt = (attrs) => attrs?.retryAttempt ?? 0;
62
- var wasRenewAttempted = (attrs) => attrs?.renewAttempted === true;
63
- var isRetryable = (attrs) => attrs?.retryable !== false;
64
- var getSentWith = (attrs) => attrs?.sentWith === void 0 ? SentWith.noUserToken : SentWith.userToken(attrs.sentWith);
65
- var getClientCredentials = (attrs) => attrs?.clientCredentials;
66
- var Attributes = {
67
- empty,
68
- concat,
69
- concatAll,
70
- protected: protectedRequest,
71
- isProtected,
72
- userAgent,
73
- needUserAgent,
74
- idempotencyKey,
75
- isIdempotent,
76
- retryAttempt,
77
- getRetryAttempt,
78
- renewAttempted,
79
- wasRenewAttempted,
80
- notRetryable,
81
- isRetryable,
82
- sentWith,
83
- getSentWith,
84
- clientCredentials,
85
- getClientCredentials,
86
- requestId,
87
- getRequestId
88
- };
89
-
90
- // src/universal/api/http.ts
1
+ // src/universal/types/http.ts
91
2
  var HttpError = class extends Error {
92
3
  constructor(response) {
93
4
  super(`Request failed with ${response.status} status`);
@@ -112,104 +23,6 @@ function apiErrorCode(error) {
112
23
  const code = body.code;
113
24
  return typeof code === "string" ? code : null;
114
25
  }
115
- async function makeRequest(request) {
116
- const headers = {
117
- Accept: "application/json",
118
- ...request.method === "POST" && request.body !== void 0 ? { "Content-Type": "application/json" } : {},
119
- ...request.headers ?? {}
120
- };
121
- const init = {
122
- method: request.method,
123
- headers,
124
- ...request.redirect !== void 0 ? { redirect: request.redirect } : {}
125
- };
126
- if (request.method === "POST" && request.body !== void 0) {
127
- init.body = JSON.stringify(request.body);
128
- }
129
- const response = await fetch(
130
- buildUrlWithQueryParams(request.url, request.queryParams),
131
- init
132
- );
133
- const responseHeaders = headersToRecord(response.headers);
134
- if (response.status === 204 || response.status === 205) {
135
- return {
136
- status: response.status,
137
- body: null,
138
- headers: responseHeaders
139
- };
140
- }
141
- if (response.status >= 300 && response.status < 400) {
142
- await response.text();
143
- return {
144
- status: response.status,
145
- body: null,
146
- headers: responseHeaders
147
- };
148
- }
149
- const text = await response.text();
150
- let body;
151
- try {
152
- body = text ? JSON.parse(text) : null;
153
- } catch (_) {
154
- throw new HttpError({
155
- status: response.status,
156
- headers: responseHeaders,
157
- body: text
158
- });
159
- }
160
- return {
161
- status: response.status,
162
- body,
163
- headers: responseHeaders
164
- };
165
- }
166
- function buildUrlWithQueryParams(url, queryParams) {
167
- if (!queryParams) {
168
- return url;
169
- }
170
- const searchParams = new URLSearchParams();
171
- for (const [key, value] of Object.entries(queryParams)) {
172
- if (value === void 0 || value === null) {
173
- continue;
174
- }
175
- if (Array.isArray(value)) {
176
- for (const item of value) {
177
- if (item === void 0 || item === null) {
178
- continue;
179
- }
180
- searchParams.append(key, String(item));
181
- }
182
- continue;
183
- }
184
- searchParams.append(key, String(value));
185
- }
186
- const queryString = searchParams.toString();
187
- if (!queryString) {
188
- return url;
189
- }
190
- return url.includes("?") ? `${url}&${queryString}` : `${url}?${queryString}`;
191
- }
192
- function headersToRecord(headers) {
193
- const record = {};
194
- headers.forEach((value, key) => {
195
- record[key.toLowerCase()] = value;
196
- });
197
- return record;
198
- }
199
- function concatAttributes(request, attrs) {
200
- const nextAttributes = Attributes.concat(
201
- request.attributes ?? Attributes.empty,
202
- attrs
203
- );
204
- const nextRequest = {
205
- ...request,
206
- attributes: nextAttributes
207
- };
208
- return nextRequest;
209
- }
210
- var Request = {
211
- concatAttributes
212
- };
213
26
 
214
27
  // src/universal/types/errors.ts
215
28
  var NotImplementedError = class extends Error {
@@ -291,105 +104,74 @@ function isExpired({
291
104
  return now >= expiresAt - buffer;
292
105
  }
293
106
 
294
- // src/universal/core/shared/blockchain/erc20/abi.ts
295
- var ERC20_ABI = [
296
- {
297
- type: "function",
298
- name: "allowance",
299
- inputs: [
300
- { name: "owner", type: "address" },
301
- { name: "spender", type: "address" }
302
- ],
303
- outputs: [{ name: "", type: "uint256" }],
304
- stateMutability: "view"
305
- },
306
- {
307
- type: "function",
308
- name: "approve",
309
- inputs: [
310
- { name: "spender", type: "address" },
311
- { name: "amount", type: "uint256" }
312
- ],
313
- outputs: [{ name: "", type: "bool" }],
314
- stateMutability: "nonpayable"
315
- },
316
- {
317
- type: "function",
318
- name: "balanceOf",
319
- inputs: [{ name: "account", type: "address" }],
320
- outputs: [{ name: "", type: "uint256" }],
321
- stateMutability: "view"
322
- },
323
- {
324
- type: "function",
325
- name: "decimals",
326
- inputs: [],
327
- outputs: [{ name: "", type: "uint8" }],
328
- stateMutability: "view"
329
- },
330
- {
331
- type: "function",
332
- name: "name",
333
- inputs: [],
334
- outputs: [{ name: "", type: "string" }],
335
- stateMutability: "view"
336
- },
337
- {
338
- type: "function",
339
- name: "symbol",
340
- inputs: [],
341
- outputs: [{ name: "", type: "string" }],
342
- stateMutability: "view"
343
- },
344
- {
345
- type: "function",
346
- name: "totalSupply",
347
- inputs: [],
348
- outputs: [{ name: "", type: "uint256" }],
349
- stateMutability: "view"
350
- },
351
- {
352
- type: "function",
353
- name: "transfer",
354
- inputs: [
355
- { name: "recipient", type: "address" },
356
- { name: "amount", type: "uint256" }
357
- ],
358
- outputs: [{ name: "", type: "bool" }],
359
- stateMutability: "nonpayable"
360
- },
361
- {
362
- type: "function",
363
- name: "transferFrom",
364
- inputs: [
365
- { name: "sender", type: "address" },
366
- { name: "recipient", type: "address" },
367
- { name: "amount", type: "uint256" }
368
- ],
369
- outputs: [{ name: "", type: "bool" }],
370
- stateMutability: "nonpayable"
371
- },
372
- {
373
- type: "event",
374
- name: "Approval",
375
- inputs: [
376
- { name: "owner", type: "address", indexed: true },
377
- { name: "spender", type: "address", indexed: true },
378
- { name: "value", type: "uint256", indexed: false }
379
- ],
380
- anonymous: false
381
- },
382
- {
383
- type: "event",
384
- name: "Transfer",
385
- inputs: [
386
- { name: "from", type: "address", indexed: true },
387
- { name: "to", type: "address", indexed: true },
388
- { name: "value", type: "uint256", indexed: false }
389
- ],
390
- anonymous: false
107
+ // src/universal/types/blockchain/ui.ts
108
+ var FormattedAmountUi = (value) => value;
109
+ var FormattedPercentUi = (value) => value;
110
+ var TxExplorerUrl = (value) => value;
111
+ var ShortenedWalletAddress = (value) => value;
112
+ var FormattedAmountAssetUi = (value) => value;
113
+ var AssetIconUrl = (value) => value;
114
+
115
+ // src/universal/core/shared/blockchain/chain.ts
116
+ import { base, baseSepolia, mainnet, sepolia } from "viem/chains";
117
+ var VIEM_CHAINS = {
118
+ ethereum_mainnet: mainnet,
119
+ ethereum_sepolia: sepolia,
120
+ base_mainnet: base,
121
+ base_sepolia: baseSepolia
122
+ };
123
+ function viemChain(chain) {
124
+ return VIEM_CHAINS[chain];
125
+ }
126
+ function getChainId(chain) {
127
+ return VIEM_CHAINS[chain].id;
128
+ }
129
+ function chainFromId(chainId) {
130
+ const chains = Object.keys(VIEM_CHAINS);
131
+ const chain = chains.find((c) => String(VIEM_CHAINS[c].id) === chainId);
132
+ if (!chain) {
133
+ throw new ValidationError(`Unsupported EIP-155 chain id: "${chainId}"`);
391
134
  }
392
- ];
135
+ return chain;
136
+ }
137
+ function contractOn(contracts, chain) {
138
+ return contracts.find((contract) => contract.chain === chain)?.address ?? null;
139
+ }
140
+ function getNetworkName(chain) {
141
+ switch (chain) {
142
+ case "ethereum_mainnet":
143
+ return "Ethereum";
144
+ case "ethereum_sepolia":
145
+ return "Ethereum Sepolia";
146
+ case "base_mainnet":
147
+ return "Base";
148
+ case "base_sepolia":
149
+ return "Base Sepolia";
150
+ default: {
151
+ const _exhaustive = chain;
152
+ return _exhaustive;
153
+ }
154
+ }
155
+ }
156
+ function txExplorerUrl(chain, txHash) {
157
+ return TxExplorerUrl(`${explorerBaseUrl(chain)}/tx/${txHash}`);
158
+ }
159
+ function explorerBaseUrl(chain) {
160
+ switch (chain) {
161
+ case "ethereum_mainnet":
162
+ return "https://etherscan.io";
163
+ case "ethereum_sepolia":
164
+ return "https://sepolia.etherscan.io";
165
+ case "base_mainnet":
166
+ return "https://basescan.org";
167
+ case "base_sepolia":
168
+ return "https://sepolia-explorer.base.org";
169
+ default: {
170
+ const _exhaustive = chain;
171
+ return _exhaustive;
172
+ }
173
+ }
174
+ }
393
175
 
394
176
  // src/universal/types/blockchain/core.ts
395
177
  var ETHEREUM_CHAINS = {
@@ -453,8 +235,18 @@ var BlockchainAmount = Object.assign(
453
235
  {
454
236
  add: (a, b) => combineAmounts(a, b, (x, y) => x + y),
455
237
  sub: (a, b) => combineAmounts(a, b, (x, y) => x - y),
456
- mul: multiplyAmounts,
457
- div: divideAmounts
238
+ /**
239
+ * `a * b`, in `a`'s decimals - a price times a quantity. Multiplies before
240
+ * it rescales, then truncates towards zero. The exact inverse of `div`.
241
+ */
242
+ mul: (a, b) => multiplyAmounts(a, b),
243
+ /**
244
+ * `a / b`, in `a`'s decimals - a price, a ratio. Rescales before it
245
+ * divides, then truncates towards zero.
246
+ *
247
+ * @throws MathError when `b` is zero.
248
+ */
249
+ div: (a, b) => divideAmounts(a, b)
458
250
  }
459
251
  );
460
252
  function multiplyAmounts(a, b) {
@@ -511,6 +303,36 @@ function blockchainAmountFromRawOrThrow({
511
303
  throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
512
304
  }
513
305
  }
306
+ function positiveAmountFromRawOrThrow({
307
+ label,
308
+ raw,
309
+ decimals,
310
+ reason
311
+ }) {
312
+ const amount = blockchainAmountFromRawOrThrow({ label, raw, decimals });
313
+ if (amount.raw === 0n) {
314
+ throw new ValidationError(
315
+ `${label}: must be greater than zero ("${raw}") - ${reason}`
316
+ );
317
+ }
318
+ return amount;
319
+ }
320
+ function pricePerShare({
321
+ usd,
322
+ shares
323
+ }) {
324
+ const price = BlockchainAmount.div(usd, shares);
325
+ return BlockchainAmount({
326
+ raw: assertPriceFits(price.raw),
327
+ decimals: price.decimals
328
+ });
329
+ }
330
+ function assertPriceFits(raw) {
331
+ if (raw > MAX_UINT_256) {
332
+ throw new MathError(`Price per share: out of uint256 bounds (${raw})`);
333
+ }
334
+ return raw;
335
+ }
514
336
  function parseBlockchainAmount(amount, decimals) {
515
337
  const trimmed = amount.trim();
516
338
  if (trimmed === "") return { valid: false, reason: { type: "empty" } };
@@ -624,10 +446,13 @@ function requiredDate(value, field) {
624
446
  return date;
625
447
  }
626
448
  function dateOrNull(value, field) {
627
- return value === null ? null : requiredDate(value, field);
449
+ return mapNullish(value, (date) => requiredDate(date, field));
628
450
  }
629
451
  function decimalOrNull(value) {
630
- return value === null ? null : DecimalString(value);
452
+ return mapNullish(value, DecimalString);
453
+ }
454
+ function mapNullish(value, parse) {
455
+ return value === null || value === void 0 ? null : parse(value);
631
456
  }
632
457
  function requiredArray(value, field) {
633
458
  if (!Array.isArray(value)) {
@@ -637,6 +462,12 @@ function requiredArray(value, field) {
637
462
  }
638
463
  return value;
639
464
  }
465
+ function txFromWire(wire) {
466
+ return {
467
+ to: EvmContractAddress(wire.to),
468
+ data: HexEncodedTransactionData(wire.data)
469
+ };
470
+ }
640
471
 
641
472
  // src/universal/types/providers/centrifuge/centrifuge.ts
642
473
  var CentrifugeVaultStatus = {
@@ -665,19 +496,16 @@ var CentrifugeVaultStatus = {
665
496
  };
666
497
  var CentrifugeVaultBuyTransaction = {
667
498
  fromDto: (dto) => {
668
- const spendInputAmount = blockchainAmountFromRawOrThrow({
669
- label: "spend_input_amount",
670
- raw: dto.spend_input_amount,
671
- decimals: AssetDecimals(dto.spend_input_decimals)
672
- });
673
- if (spendInputAmount.raw <= 0n) {
674
- throw new ValidationError(
675
- `spend_input_amount: must be greater than zero ("${dto.spend_input_amount}") - a deposit of nothing is not a request`
676
- );
677
- }
678
499
  return {
679
500
  ...parseTransactionCore(dto, "CentrifugeVaultBuyTransaction"),
680
- spendInputAmount
501
+ spendInputAmount: positiveAmountFromRawOrThrow({
502
+ label: "spend_input_amount",
503
+ raw: dto.spend_input_amount,
504
+ decimals: AssetDecimals(dto.spend_input_decimals),
505
+ // Frontline refuses an `amount` of zero, so a zero here is a changed
506
+ // encoding, not a small deposit - and not calldata worth signing.
507
+ reason: "a deposit of nothing is not a request"
508
+ })
681
509
  };
682
510
  }
683
511
  };
@@ -691,72 +519,41 @@ var CentrifugeVaultClaimTransaction = {
691
519
  })
692
520
  })
693
521
  };
694
- var CentrifugeVaultPosition = {
695
- fromDto: (dto) => {
696
- const assetDecimals = AssetDecimals(dto.asset_decimals);
697
- const shareDecimals = AssetDecimals(dto.share_decimals);
698
- const asset = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: assetDecimals });
699
- const shares = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: shareDecimals });
522
+ var CentrifugeAssets = (amount) => amount;
523
+ var CentrifugeShares = (amount) => amount;
524
+ var CentrifugeDepositPosition = {
525
+ fromContract: (raw, context) => {
526
+ const assets = (label, value) => CentrifugeAssets(contractAmount(label, value, context.assetDecimals));
700
527
  return {
701
- chain: EthereumChain(dto.chain),
702
- symbol: AssetSymbol(dto.symbol),
703
- walletAddress: EvmWalletAddress(dto.wallet_address),
704
- status: dto.status,
705
- requested: asset("requested", dto.requested),
706
- pending: asset("pending", dto.pending),
707
- filledAssets: asset("filled_assets", dto.filled_assets),
708
- earnedShares: shares("earned_shares", dto.earned_shares),
709
- claimedShares: shares("claimed_shares", dto.claimed_shares),
710
- claimableShares: shares("claimable_shares", dto.claimable_shares),
711
- shareBalance: shares("share_balance", dto.share_balance),
712
- averagePrice: decimalOrNull(dto.average_price),
713
- frozen: dto.frozen,
714
- asOf: requiredDate(dto.as_of, "CentrifugeVaultPosition.as_of")
528
+ chain: context.chain,
529
+ proxy: context.proxy,
530
+ walletAddress: context.walletAddress,
531
+ pending: assets("pendingDepositRequest", raw.pendingDepositRequest),
532
+ claimable: assets("claimableDepositRequest", raw.claimableDepositRequest)
715
533
  };
716
534
  }
717
535
  };
718
- var CentrifugeVaultRedeemPosition = {
719
- fromDto: (dto) => ({
720
- chain: EthereumChain(dto.chain),
721
- symbol: AssetSymbol(dto.symbol),
722
- walletAddress: EvmWalletAddress(dto.wallet_address),
723
- status: dto.status,
724
- pending: blockchainAmountFromRawOrThrow({
725
- label: "pending",
726
- raw: dto.pending,
727
- decimals: AssetDecimals(dto.share_decimals)
728
- }),
729
- claimableAssets: blockchainAmountFromRawOrThrow({
730
- label: "claimable_assets",
731
- raw: dto.claimable_assets,
732
- decimals: AssetDecimals(dto.asset_decimals)
733
- }),
734
- frozen: dto.frozen,
735
- asOf: requiredDate(dto.as_of, "CentrifugeVaultRedeemPosition.as_of")
736
- })
536
+ var CentrifugeRedeemPosition = {
537
+ fromContract: (raw, context) => {
538
+ const shares = (label, value) => CentrifugeShares(contractAmount(label, value, context.shareDecimals));
539
+ return {
540
+ chain: context.chain,
541
+ proxy: context.proxy,
542
+ walletAddress: context.walletAddress,
543
+ pending: shares("pendingRedeemRequest", raw.pendingRedeemRequest),
544
+ claimable: shares("claimableRedeemRequest", raw.claimableRedeemRequest)
545
+ };
546
+ }
737
547
  };
738
548
  var CentrifugeVaultLeg = {
739
- /**
740
- * What a claim on the leg would collect: shares for `invest`, the funding
741
- * token for `redeem`.
742
- */
743
- claimable: (leg) => {
744
- switch (leg.direction) {
745
- case "invest":
746
- return leg.position.claimableShares;
747
- case "redeem":
748
- return leg.position.claimableAssets;
749
- default: {
750
- const exhaustive = leg;
751
- return exhaustive;
752
- }
753
- }
754
- },
755
549
  /** Whether the leg has anything queued or anything ready to claim. */
756
- isActive: (leg) => leg.position.pending.raw > 0n || CentrifugeVaultLeg.claimable(leg).raw > 0n
550
+ isActive: (leg) => leg.position.pending.raw > 0n || leg.position.claimable.raw > 0n
757
551
  };
552
+ function contractAmount(label, value, decimals) {
553
+ return BlockchainAmount({ raw: parseUint256(value, label), decimals });
554
+ }
758
555
  var CentrifugeVaultLegId = {
759
- /** Addresses compare case-insensitively: frontline echoes them lower case. */
556
+ /** Addresses compare case-insensitively: a host may pass either case. */
760
557
  of: (leg) => [
761
558
  leg.direction,
762
559
  leg.position.chain,
@@ -773,33 +570,133 @@ var CentrifugeVaultClaimProceedsTransaction = {
773
570
  })
774
571
  })
775
572
  };
776
- function parseOrderability(canOrder, reasons, model) {
777
- const [first, ...rest] = reasons;
778
- if (canOrder) {
779
- if (first !== void 0) {
780
- throw new ValidationError(
781
- `${model}.reasons: expected none when can_order is true, got ${JSON.stringify(reasons)}`
782
- );
783
- }
784
- return { type: "orderable" };
785
- }
786
- if (first === void 0) {
787
- throw new ValidationError(
788
- `${model}.reasons: expected at least one when can_order is false`
789
- );
573
+ function parseOrderability(canOrder, reasons, model) {
574
+ const [first, ...rest] = reasons;
575
+ if (canOrder) {
576
+ if (first !== void 0) {
577
+ throw new ValidationError(
578
+ `${model}.reasons: expected none when can_order is true, got ${JSON.stringify(reasons)}`
579
+ );
580
+ }
581
+ return { type: "orderable" };
582
+ }
583
+ if (first === void 0) {
584
+ throw new ValidationError(
585
+ `${model}.reasons: expected at least one when can_order is false`
586
+ );
587
+ }
588
+ return { type: "blocked", reasons: [first, ...rest] };
589
+ }
590
+ function parseTransactionCore(dto, model) {
591
+ return {
592
+ tx: txFromWire(dto),
593
+ expiresAt: dateOrNull(dto.expires_at, `${model}.expires_at`)
594
+ };
595
+ }
596
+
597
+ // src/universal/api/frontline/providers/shared/spend-scale.ts
598
+ function assertSpendScaleAgrees({
599
+ published,
600
+ sized,
601
+ trade,
602
+ note
603
+ }) {
604
+ if (published === sized.decimals) return;
605
+ const because = note === void 0 ? "" : ` - ${note}`;
606
+ throw new ValidationError(
607
+ `spend_input_decimals: the ${trade} was priced in ${published} decimals but the order was sized in ${sized.decimals}${because}`
608
+ );
609
+ }
610
+
611
+ // src/universal/types/access-token-source.ts
612
+ var SentWith = {
613
+ userToken: (token) => ({
614
+ type: "user-token",
615
+ token
616
+ }),
617
+ noUserToken: { type: "no-user-token" }
618
+ };
619
+ var TokenTrigger = {
620
+ beforeRequest: { type: "before-request" },
621
+ after401: (rejected) => ({
622
+ type: "after-401",
623
+ rejected
624
+ })
625
+ };
626
+ function isRejectedToken(token, rejected) {
627
+ switch (rejected.type) {
628
+ case "user-token":
629
+ return rejected.token.value === token.value;
630
+ case "no-user-token":
631
+ return false;
790
632
  }
791
- return { type: "blocked", reasons: [first, ...rest] };
792
- }
793
- function parseTransactionCore(dto, model) {
794
- return {
795
- tx: {
796
- to: EvmContractAddress(dto.to),
797
- data: HexEncodedTransactionData(dto.data)
798
- },
799
- expiresAt: dateOrNull(dto.expires_at, `${model}.expires_at`)
800
- };
801
633
  }
802
634
 
635
+ // src/universal/api/http-attributes.ts
636
+ var empty = {};
637
+ var concat = (left, right) => ({
638
+ ...left,
639
+ ...right
640
+ });
641
+ var concatAll = (...items) => {
642
+ let result = empty;
643
+ for (const item of items) {
644
+ result = concat(result, item);
645
+ }
646
+ return result;
647
+ };
648
+ var protectedRequest = () => ({ protected: true });
649
+ var userAgent = () => ({ userAgent: true });
650
+ var idempotencyKey = () => ({
651
+ idempotencyKey: true
652
+ });
653
+ var clientCredentials = (credentials) => ({
654
+ clientCredentials: credentials
655
+ });
656
+ var retryAttempt = (attempt) => ({
657
+ retryAttempt: attempt
658
+ });
659
+ var renewAttempted = (value) => ({
660
+ renewAttempted: value
661
+ });
662
+ var notRetryable = () => ({ retryable: false });
663
+ var sentWith = (token) => ({
664
+ sentWith: token
665
+ });
666
+ var requestId = (id) => ({ requestId: id });
667
+ var getRequestId = (attrs) => attrs?.requestId ?? null;
668
+ var isProtected = (attrs) => attrs?.protected === true;
669
+ var needUserAgent = (attrs) => attrs?.userAgent === true;
670
+ var isIdempotent = (attrs) => attrs?.idempotencyKey === true;
671
+ var getRetryAttempt = (attrs) => attrs?.retryAttempt ?? 0;
672
+ var wasRenewAttempted = (attrs) => attrs?.renewAttempted === true;
673
+ var isRetryable = (attrs) => attrs?.retryable !== false;
674
+ var getSentWith = (attrs) => attrs?.sentWith === void 0 ? SentWith.noUserToken : SentWith.userToken(attrs.sentWith);
675
+ var getClientCredentials = (attrs) => attrs?.clientCredentials;
676
+ var Attributes = {
677
+ empty,
678
+ concat,
679
+ concatAll,
680
+ protected: protectedRequest,
681
+ isProtected,
682
+ userAgent,
683
+ needUserAgent,
684
+ idempotencyKey,
685
+ isIdempotent,
686
+ retryAttempt,
687
+ getRetryAttempt,
688
+ renewAttempted,
689
+ wasRenewAttempted,
690
+ notRetryable,
691
+ isRetryable,
692
+ sentWith,
693
+ getSentWith,
694
+ clientCredentials,
695
+ getClientCredentials,
696
+ requestId,
697
+ getRequestId
698
+ };
699
+
803
700
  // src/universal/api/frontline/providers/centrifuge/centrifuge.ts
804
701
  async function getCentrifugeVaultStatus(api, params) {
805
702
  const dto = await api.send({
@@ -823,30 +720,12 @@ async function buildCentrifugeVaultBuy(api, params) {
823
720
  },
824
721
  attributes: Attributes.protected()
825
722
  });
826
- if (dto.spend_input_decimals !== params.amount.decimals) {
827
- throw new ValidationError(
828
- `spend_input_decimals: the request was priced in ${dto.spend_input_decimals} decimals but the deposit was sized in ${params.amount.decimals}`
829
- );
830
- }
831
- return CentrifugeVaultBuyTransaction.fromDto(dto);
832
- }
833
- async function getCentrifugeVaultPosition(api, params) {
834
- const dto = await api.send({
835
- method: "GET",
836
- url: "/v1/centrifuge/vault/position",
837
- queryParams: walletFields(params),
838
- attributes: Attributes.protected()
839
- });
840
- return CentrifugeVaultPosition.fromDto(dto);
841
- }
842
- async function getCentrifugeVaultRedeemPosition(api, params) {
843
- const dto = await api.send({
844
- method: "GET",
845
- url: "/v1/centrifuge/vault/redeem-position",
846
- queryParams: walletFields(params),
847
- attributes: Attributes.protected()
723
+ assertSpendScaleAgrees({
724
+ published: dto.spend_input_decimals,
725
+ sized: params.amount,
726
+ trade: "deposit"
848
727
  });
849
- return CentrifugeVaultRedeemPosition.fromDto(dto);
728
+ return CentrifugeVaultBuyTransaction.fromDto(dto);
850
729
  }
851
730
  async function createCentrifugeVaultClaim(api, params) {
852
731
  const dto = await api.send({
@@ -874,6 +753,86 @@ function walletFields(params) {
874
753
  };
875
754
  }
876
755
 
756
+ // src/universal/core/providers/centrifuge/blockchain/abi.ts
757
+ var CENTRIFUGE_PROXY_ABI = [
758
+ {
759
+ type: "function",
760
+ name: "pendingDepositRequest",
761
+ inputs: [{ name: "investor", type: "address" }],
762
+ outputs: [{ name: "", type: "uint256" }],
763
+ stateMutability: "view"
764
+ },
765
+ {
766
+ type: "function",
767
+ name: "claimableDepositRequest",
768
+ inputs: [{ name: "investor", type: "address" }],
769
+ outputs: [{ name: "", type: "uint256" }],
770
+ stateMutability: "view"
771
+ },
772
+ {
773
+ type: "function",
774
+ name: "pendingRedeemRequest",
775
+ inputs: [{ name: "investor", type: "address" }],
776
+ outputs: [{ name: "", type: "uint256" }],
777
+ stateMutability: "view"
778
+ },
779
+ {
780
+ type: "function",
781
+ name: "claimableRedeemRequest",
782
+ inputs: [{ name: "investor", type: "address" }],
783
+ outputs: [{ name: "", type: "uint256" }],
784
+ stateMutability: "view"
785
+ }
786
+ ];
787
+
788
+ // src/universal/api/rpc/providers/centrifuge/position.ts
789
+ async function readCentrifugeDepositPosition(clients, params) {
790
+ const client = clients(params.vault.chain);
791
+ const proxy = proxyOf(params);
792
+ const wallet = params.walletAddress;
793
+ const [pendingDepositRequest, claimableDepositRequest] = await client.multicall({
794
+ allowFailure: false,
795
+ contracts: [
796
+ { ...proxy, functionName: "pendingDepositRequest", args: [wallet] },
797
+ { ...proxy, functionName: "claimableDepositRequest", args: [wallet] }
798
+ ]
799
+ });
800
+ return CentrifugeDepositPosition.fromContract(
801
+ { pendingDepositRequest, claimableDepositRequest },
802
+ contextOf(params)
803
+ );
804
+ }
805
+ async function readCentrifugeRedeemPosition(clients, params) {
806
+ const client = clients(params.vault.chain);
807
+ const proxy = proxyOf(params);
808
+ const wallet = params.walletAddress;
809
+ const [pendingRedeemRequest, claimableRedeemRequest] = await client.multicall(
810
+ {
811
+ allowFailure: false,
812
+ contracts: [
813
+ { ...proxy, functionName: "pendingRedeemRequest", args: [wallet] },
814
+ { ...proxy, functionName: "claimableRedeemRequest", args: [wallet] }
815
+ ]
816
+ }
817
+ );
818
+ return CentrifugeRedeemPosition.fromContract(
819
+ { pendingRedeemRequest, claimableRedeemRequest },
820
+ contextOf(params)
821
+ );
822
+ }
823
+ function proxyOf(params) {
824
+ return { address: params.vault.proxy, abi: CENTRIFUGE_PROXY_ABI };
825
+ }
826
+ function contextOf(params) {
827
+ return {
828
+ chain: params.vault.chain,
829
+ proxy: params.vault.proxy,
830
+ walletAddress: params.walletAddress,
831
+ assetDecimals: params.vault.funding.decimals,
832
+ shareDecimals: params.vault.share.decimals
833
+ };
834
+ }
835
+
877
836
  // src/universal/core/shared/observability/log-cause.ts
878
837
  import {
879
838
  BaseError,
@@ -1057,7 +1016,7 @@ var noopInternalLogger = {
1057
1016
  wrap: (_op, _params, run) => run()
1058
1017
  };
1059
1018
 
1060
- // src/universal/core/checkout/centrifuge/centrifuge-namespace.ts
1019
+ // src/universal/core/providers/centrifuge/centrifuge-namespace.ts
1061
1020
  var CentrifugeNamespaceImpl = class {
1062
1021
  constructor(ctx) {
1063
1022
  this.ctx = ctx;
@@ -1069,17 +1028,19 @@ var CentrifugeNamespaceImpl = class {
1069
1028
  return getCentrifugeVaultStatus(this.ctx.api, params);
1070
1029
  });
1071
1030
  }
1072
- async getPosition(params) {
1073
- return this.log.wrap("getPosition", params, async () => {
1074
- await this.ctx.ensureUserAuthenticated();
1075
- return getCentrifugeVaultPosition(this.ctx.api, params);
1076
- });
1031
+ async readDepositPosition(params) {
1032
+ return this.log.wrap(
1033
+ "readDepositPosition",
1034
+ params,
1035
+ () => readCentrifugeDepositPosition(this.ctx.rpc, params)
1036
+ );
1077
1037
  }
1078
- async getRedeemPosition(params) {
1079
- return this.log.wrap("getRedeemPosition", params, async () => {
1080
- await this.ctx.ensureUserAuthenticated();
1081
- return getCentrifugeVaultRedeemPosition(this.ctx.api, params);
1082
- });
1038
+ async readRedeemPosition(params) {
1039
+ return this.log.wrap(
1040
+ "readRedeemPosition",
1041
+ params,
1042
+ () => readCentrifugeRedeemPosition(this.ctx.rpc, params)
1043
+ );
1083
1044
  }
1084
1045
  async createClaim(params) {
1085
1046
  return this.log.wrap("createClaim", params, async () => {
@@ -1101,20 +1062,112 @@ var CentrifugeNamespaceImpl = class {
1101
1062
  }
1102
1063
  };
1103
1064
 
1104
- // src/universal/api/pagination.ts
1105
- async function fetchAllPages(fetchPage, baseParams) {
1106
- const items = [];
1107
- let cursor = null;
1108
- do {
1109
- const params = {
1110
- ...baseParams ?? {},
1111
- after: cursor ?? void 0
1112
- };
1113
- const page = await fetchPage(params);
1114
- items.push(...page.data);
1115
- cursor = page.startingAfter;
1116
- } while (cursor);
1117
- return items;
1065
+ // src/universal/core/shared/blockchain/formatters.ts
1066
+ import { formatUnits } from "viem";
1067
+ function shortenAddress(address) {
1068
+ const short = address.length > 10 ? `${address.slice(0, 6)}\u2026${address.slice(-4)}` : address;
1069
+ return ShortenedWalletAddress(short);
1070
+ }
1071
+ function formatAmount(amount, locale, options) {
1072
+ const decimal = formatRawAmount(amount);
1073
+ let [integerPart, fractionPart = ""] = decimal.split(".");
1074
+ const maxFractionDigits = options?.maxFractionDigits;
1075
+ const minFractionDigits = Math.min(
1076
+ options?.minFractionDigits ?? (maxFractionDigits !== void 0 ? maxFractionDigits : 2),
1077
+ maxFractionDigits ?? amount.decimals,
1078
+ amount.decimals
1079
+ );
1080
+ if (maxFractionDigits !== void 0 && fractionPart.length > maxFractionDigits) {
1081
+ ({ integerPart, fractionPart } = roundFractionHalfUp(
1082
+ integerPart,
1083
+ fractionPart,
1084
+ maxFractionDigits
1085
+ ));
1086
+ }
1087
+ const trimmed = fractionPart.replace(/0+$/, "");
1088
+ const fraction = trimmed.padEnd(minFractionDigits, "0");
1089
+ const integerFormatted = BigInt(integerPart).toLocaleString(locale);
1090
+ if (minFractionDigits === 0 && fraction === "") {
1091
+ return FormattedAmountUi(integerFormatted);
1092
+ }
1093
+ const decimalSeparator = new Intl.NumberFormat(locale).formatToParts(1.1).find((p) => p.type === "decimal")?.value ?? ".";
1094
+ return FormattedAmountUi(`${integerFormatted}${decimalSeparator}${fraction}`);
1095
+ }
1096
+ function roundFractionHalfUp(integerPart, fractionPart, maxFractionDigits) {
1097
+ if (fractionPart.length <= maxFractionDigits) {
1098
+ return { integerPart, fractionPart };
1099
+ }
1100
+ if (maxFractionDigits === 0) {
1101
+ const roundUp = fractionPart[0] >= "5";
1102
+ const integer = BigInt(integerPart) + (roundUp ? 1n : 0n);
1103
+ return { integerPart: integer.toString(), fractionPart: "" };
1104
+ }
1105
+ const trimmed = fractionPart.slice(0, maxFractionDigits);
1106
+ if (fractionPart[maxFractionDigits] < "5") {
1107
+ return { integerPart, fractionPart: trimmed };
1108
+ }
1109
+ const digits = trimmed.split("").map((digit) => Number.parseInt(digit, 10));
1110
+ let carry = 1;
1111
+ for (let i = digits.length - 1; i >= 0 && carry > 0; i -= 1) {
1112
+ const sum = digits[i] + carry;
1113
+ if (sum === 10) {
1114
+ digits[i] = 0;
1115
+ carry = 1;
1116
+ } else {
1117
+ digits[i] = sum;
1118
+ carry = 0;
1119
+ }
1120
+ }
1121
+ return {
1122
+ integerPart: carry > 0 ? (BigInt(integerPart) + 1n).toString() : integerPart,
1123
+ fractionPart: digits.join("")
1124
+ };
1125
+ }
1126
+ function formatRawAmount(amount) {
1127
+ return formatUnits(amount.raw, amount.decimals);
1128
+ }
1129
+ function formatCompactAmount(amount, locale) {
1130
+ const value = Number(formatRawAmount(amount));
1131
+ const formatted = new Intl.NumberFormat(locale, {
1132
+ notation: "compact",
1133
+ maximumFractionDigits: 2
1134
+ }).format(value);
1135
+ return FormattedAmountUi(formatted);
1136
+ }
1137
+ function formatBpsAsPercent(bps, locale) {
1138
+ const whole = bps / 100n;
1139
+ const fraction = bps % 100n;
1140
+ const wholeFormatted = whole.toLocaleString(locale);
1141
+ const decimalSeparator = new Intl.NumberFormat(locale).formatToParts(1.1).find((p) => p.type === "decimal")?.value ?? ".";
1142
+ if (fraction === 0n) {
1143
+ return FormattedPercentUi(`${wholeFormatted}%`);
1144
+ }
1145
+ const fractionFormatted = fraction.toString().padStart(2, "0").replace(/0+$/, "");
1146
+ return FormattedPercentUi(
1147
+ `${wholeFormatted}${decimalSeparator}${fractionFormatted}%`
1148
+ );
1149
+ }
1150
+ function usdAmount(amount) {
1151
+ return FormattedAmountAssetUi(`$${amount}`);
1152
+ }
1153
+ function assetAmount(amount, symbol) {
1154
+ return FormattedAmountAssetUi(`${amount} ${symbol}`);
1155
+ }
1156
+ var NA_AMOUNT_ASSET_UI = FormattedAmountAssetUi("-");
1157
+ var SHARE_MAX_FRACTION_DIGITS = AssetDecimals(6);
1158
+ var SHARE_MIN_FRACTION_DIGITS = AssetDecimals(2);
1159
+ function formatShareAmount(amount, locale) {
1160
+ return formatAmount(amount, locale, {
1161
+ maxFractionDigits: SHARE_MAX_FRACTION_DIGITS,
1162
+ minFractionDigits: SHARE_MIN_FRACTION_DIGITS
1163
+ });
1164
+ }
1165
+ var USD_FRACTION_DIGITS = AssetDecimals(2);
1166
+ function formattedUsdPrice(amount, locale) {
1167
+ if (!amount) return NA_AMOUNT_ASSET_UI;
1168
+ return usdAmount(
1169
+ formatAmount(amount, locale, { maxFractionDigits: USD_FRACTION_DIGITS })
1170
+ );
1118
1171
  }
1119
1172
 
1120
1173
  // src/universal/types/pagination.ts
@@ -1258,7 +1311,7 @@ var Isin = (value) => value;
1258
1311
  var AsyncOfferDetail = {
1259
1312
  /**
1260
1313
  * Narrows an offer fetched generically, e.g. on an offer page, to one with
1261
- * something to claim.
1314
+ * a second leg to show.
1262
1315
  *
1263
1316
  * An exhaustive `switch` rather than a list of async types, so a new offer
1264
1317
  * type is a compile error here until someone decides whether it settles
@@ -1267,10 +1320,10 @@ var AsyncOfferDetail = {
1267
1320
  is: (offer) => {
1268
1321
  switch (offer.type) {
1269
1322
  case "centrifuge::vault":
1323
+ case "coinlist::token_sale":
1270
1324
  return true;
1271
1325
  case "ondo::swap":
1272
1326
  case "superstate::swap":
1273
- case "coinlist::token_sale":
1274
1327
  return false;
1275
1328
  default: {
1276
1329
  const exhaustive = offer;
@@ -1300,6 +1353,17 @@ var OfferVaultContract = {
1300
1353
  */
1301
1354
  listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferVaultContract.fromDto)
1302
1355
  };
1356
+ var OfferFundingContract = {
1357
+ fromDto: (dto) => ({
1358
+ chain: Chain(dto.chain),
1359
+ address: EvmContractAddress(dto.address)
1360
+ }),
1361
+ /**
1362
+ * Drops every contract on a chain this SDK does not name, as
1363
+ * {@link OfferVaultContract.listFromDto} does.
1364
+ */
1365
+ listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferFundingContract.fromDto)
1366
+ };
1303
1367
  var OfferDetail = {
1304
1368
  fromDto: (dto) => {
1305
1369
  const fundingAssets = requiredArray(
@@ -1341,7 +1405,15 @@ var OfferDetail = {
1341
1405
  ...base2,
1342
1406
  ...OfferEditorial.fromDto(dto, "OfferDetail"),
1343
1407
  type: dto.type,
1344
- logoUrl: requiredString(dto.logo_url, "OfferDetail.logo_url")
1408
+ logoUrl: requiredString(dto.logo_url, "OfferDetail.logo_url"),
1409
+ // `[]` is fine and a missing key is not, as for `swap_contracts`:
1410
+ // this is the spender a participation's approval names.
1411
+ fundingContracts: OfferFundingContract.listFromDto(
1412
+ requiredArray(
1413
+ dto.funding_contracts,
1414
+ "OfferDetail.funding_contracts"
1415
+ )
1416
+ )
1345
1417
  };
1346
1418
  case "superstate::swap":
1347
1419
  return {
@@ -1419,8 +1491,6 @@ var Milestone = {
1419
1491
 
1420
1492
  // src/universal/types/providers/coin-list/token-sale.ts
1421
1493
  var ParticipationId = (value) => value;
1422
- var Blockchain = (value) => value;
1423
- var WalletAddress = (value) => value;
1424
1494
  var ParticipationsPaginationParams = {
1425
1495
  toQueryParams: (params) => {
1426
1496
  const queryParams = PaginationParams.toQueryParams(params);
@@ -1444,10 +1514,10 @@ var Participation = {
1444
1514
  amount: dto.amount,
1445
1515
  displayAmount: dto.amount_string,
1446
1516
  asset: Asset.fromDto(dto.asset),
1447
- chain: Blockchain(dto.chain),
1517
+ chain: isChain(dto.chain) ? dto.chain : null,
1448
1518
  insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
1449
1519
  updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
1450
- walletAddress: walletAddress ? WalletAddress(walletAddress) : null
1520
+ walletAddress: walletAddress ? EvmWalletAddress(walletAddress) : null
1451
1521
  };
1452
1522
  }
1453
1523
  };
@@ -1464,6 +1534,22 @@ var CreateParticipationParams = {
1464
1534
  })
1465
1535
  };
1466
1536
 
1537
+ // src/universal/api/pagination.ts
1538
+ async function fetchAllPages(fetchPage, baseParams) {
1539
+ const items = [];
1540
+ let cursor = null;
1541
+ do {
1542
+ const params = {
1543
+ ...baseParams ?? {},
1544
+ after: cursor ?? void 0
1545
+ };
1546
+ const page = await fetchPage(params);
1547
+ items.push(...page.data);
1548
+ cursor = page.startingAfter;
1549
+ } while (cursor);
1550
+ return items;
1551
+ }
1552
+
1467
1553
  // src/universal/api/frontline/providers/coin-list/token-sale.ts
1468
1554
  async function fetchParticipations(api, offerId) {
1469
1555
  return fetchAllPages(
@@ -1498,7 +1584,7 @@ async function createParticipation(api, params) {
1498
1584
  return Participation.fromDto(dto);
1499
1585
  }
1500
1586
 
1501
- // src/universal/core/checkout/coin-list/token-sale-namespace.ts
1587
+ // src/universal/core/providers/coin-list/token-sale-namespace.ts
1502
1588
  var CoinListTokenSaleNamespaceImpl = class {
1503
1589
  constructor(ctx) {
1504
1590
  this.ctx = ctx;
@@ -1530,180 +1616,6 @@ var CoinListTokenSaleNamespaceImpl = class {
1530
1616
  }
1531
1617
  };
1532
1618
 
1533
- // src/universal/types/blockchain/ui.ts
1534
- var FormattedAmountUi = (value) => value;
1535
- var FormattedPercentUi = (value) => value;
1536
- var TxExplorerUrl = (value) => value;
1537
- var ShortenedWalletAddress = (value) => value;
1538
- var FormattedAmountAssetUi = (value) => value;
1539
- var AssetIconUrl = (value) => value;
1540
-
1541
- // src/universal/core/shared/blockchain/formatters.ts
1542
- import { formatUnits } from "viem";
1543
- function shortenAddress(address) {
1544
- const short = address.length > 10 ? `${address.slice(0, 6)}\u2026${address.slice(-4)}` : address;
1545
- return ShortenedWalletAddress(short);
1546
- }
1547
- function formatAmount(amount, locale, options) {
1548
- const decimal = formatRawAmount(amount);
1549
- let [integerPart, fractionPart = ""] = decimal.split(".");
1550
- const maxFractionDigits = options?.maxFractionDigits;
1551
- const minFractionDigits = Math.min(
1552
- options?.minFractionDigits ?? (maxFractionDigits !== void 0 ? maxFractionDigits : 2),
1553
- maxFractionDigits ?? amount.decimals,
1554
- amount.decimals
1555
- );
1556
- if (maxFractionDigits !== void 0 && fractionPart.length > maxFractionDigits) {
1557
- ({ integerPart, fractionPart } = roundFractionHalfUp(
1558
- integerPart,
1559
- fractionPart,
1560
- maxFractionDigits
1561
- ));
1562
- }
1563
- const trimmed = fractionPart.replace(/0+$/, "");
1564
- const fraction = trimmed.padEnd(minFractionDigits, "0");
1565
- const integerFormatted = BigInt(integerPart).toLocaleString(locale);
1566
- if (minFractionDigits === 0 && fraction === "") {
1567
- return FormattedAmountUi(integerFormatted);
1568
- }
1569
- const decimalSeparator = new Intl.NumberFormat(locale).formatToParts(1.1).find((p) => p.type === "decimal")?.value ?? ".";
1570
- return FormattedAmountUi(`${integerFormatted}${decimalSeparator}${fraction}`);
1571
- }
1572
- function roundFractionHalfUp(integerPart, fractionPart, maxFractionDigits) {
1573
- if (fractionPart.length <= maxFractionDigits) {
1574
- return { integerPart, fractionPart };
1575
- }
1576
- if (maxFractionDigits === 0) {
1577
- const roundUp = fractionPart[0] >= "5";
1578
- const integer = BigInt(integerPart) + (roundUp ? 1n : 0n);
1579
- return { integerPart: integer.toString(), fractionPart: "" };
1580
- }
1581
- const trimmed = fractionPart.slice(0, maxFractionDigits);
1582
- if (fractionPart[maxFractionDigits] < "5") {
1583
- return { integerPart, fractionPart: trimmed };
1584
- }
1585
- const digits = trimmed.split("").map((digit) => Number.parseInt(digit, 10));
1586
- let carry = 1;
1587
- for (let i = digits.length - 1; i >= 0 && carry > 0; i -= 1) {
1588
- const sum = digits[i] + carry;
1589
- if (sum === 10) {
1590
- digits[i] = 0;
1591
- carry = 1;
1592
- } else {
1593
- digits[i] = sum;
1594
- carry = 0;
1595
- }
1596
- }
1597
- return {
1598
- integerPart: carry > 0 ? (BigInt(integerPart) + 1n).toString() : integerPart,
1599
- fractionPart: digits.join("")
1600
- };
1601
- }
1602
- function formatRawAmount(amount) {
1603
- return formatUnits(amount.raw, amount.decimals);
1604
- }
1605
- function formatCompactAmount(amount, locale) {
1606
- const value = Number(formatRawAmount(amount));
1607
- const formatted = new Intl.NumberFormat(locale, {
1608
- notation: "compact",
1609
- maximumFractionDigits: 2
1610
- }).format(value);
1611
- return FormattedAmountUi(formatted);
1612
- }
1613
- function formatBpsAsPercent(bps, locale) {
1614
- const whole = bps / 100n;
1615
- const fraction = bps % 100n;
1616
- const wholeFormatted = whole.toLocaleString(locale);
1617
- const decimalSeparator = new Intl.NumberFormat(locale).formatToParts(1.1).find((p) => p.type === "decimal")?.value ?? ".";
1618
- if (fraction === 0n) {
1619
- return FormattedPercentUi(`${wholeFormatted}%`);
1620
- }
1621
- const fractionFormatted = fraction.toString().padStart(2, "0").replace(/0+$/, "");
1622
- return FormattedPercentUi(
1623
- `${wholeFormatted}${decimalSeparator}${fractionFormatted}%`
1624
- );
1625
- }
1626
- function usdAmount(amount) {
1627
- return FormattedAmountAssetUi(`$${amount}`);
1628
- }
1629
- function assetAmount(amount, symbol) {
1630
- return FormattedAmountAssetUi(`${amount} ${symbol}`);
1631
- }
1632
- var NA_AMOUNT_ASSET_UI = FormattedAmountAssetUi("-");
1633
- var SHARE_MAX_FRACTION_DIGITS = AssetDecimals(6);
1634
- var SHARE_MIN_FRACTION_DIGITS = AssetDecimals(2);
1635
- function formatShareAmount(amount, locale) {
1636
- return formatAmount(amount, locale, {
1637
- maxFractionDigits: SHARE_MAX_FRACTION_DIGITS,
1638
- minFractionDigits: SHARE_MIN_FRACTION_DIGITS
1639
- });
1640
- }
1641
- var USD_FRACTION_DIGITS = AssetDecimals(2);
1642
- function formattedUsdPrice(amount, locale) {
1643
- if (!amount) return NA_AMOUNT_ASSET_UI;
1644
- return usdAmount(
1645
- formatAmount(amount, locale, { maxFractionDigits: USD_FRACTION_DIGITS })
1646
- );
1647
- }
1648
-
1649
- // src/universal/core/shared/blockchain/chain.ts
1650
- import { base, baseSepolia, mainnet, sepolia } from "viem/chains";
1651
- var VIEM_CHAINS = {
1652
- ethereum_mainnet: mainnet,
1653
- ethereum_sepolia: sepolia,
1654
- base_mainnet: base,
1655
- base_sepolia: baseSepolia
1656
- };
1657
- function viemChain(chain) {
1658
- return VIEM_CHAINS[chain];
1659
- }
1660
- function getChainId(chain) {
1661
- return VIEM_CHAINS[chain].id;
1662
- }
1663
- function chainFromId(chainId) {
1664
- const chains = Object.keys(VIEM_CHAINS);
1665
- const chain = chains.find((c) => String(VIEM_CHAINS[c].id) === chainId);
1666
- if (!chain) {
1667
- throw new ValidationError(`Unsupported EIP-155 chain id: "${chainId}"`);
1668
- }
1669
- return chain;
1670
- }
1671
- function getNetworkName(chain) {
1672
- switch (chain) {
1673
- case "ethereum_mainnet":
1674
- return "Ethereum";
1675
- case "ethereum_sepolia":
1676
- return "Ethereum Sepolia";
1677
- case "base_mainnet":
1678
- return "Base";
1679
- case "base_sepolia":
1680
- return "Base Sepolia";
1681
- default: {
1682
- const _exhaustive = chain;
1683
- return _exhaustive;
1684
- }
1685
- }
1686
- }
1687
- function txExplorerUrl(chain, txHash) {
1688
- return TxExplorerUrl(`${explorerBaseUrl(chain)}/tx/${txHash}`);
1689
- }
1690
- function explorerBaseUrl(chain) {
1691
- switch (chain) {
1692
- case "ethereum_mainnet":
1693
- return "https://etherscan.io";
1694
- case "ethereum_sepolia":
1695
- return "https://sepolia.etherscan.io";
1696
- case "base_mainnet":
1697
- return "https://basescan.org";
1698
- case "base_sepolia":
1699
- return "https://sepolia-explorer.base.org";
1700
- default: {
1701
- const _exhaustive = chain;
1702
- return _exhaustive;
1703
- }
1704
- }
1705
- }
1706
-
1707
1619
  // src/universal/types/providers/ondo/ondo.ts
1708
1620
  var OndoTradingStatus = {
1709
1621
  fromDto: (dto) => {
@@ -1758,7 +1670,7 @@ var OndoBuyTransaction = {
1758
1670
  raw: dto.notional_value,
1759
1671
  decimals: spendDecimals
1760
1672
  }),
1761
- receiveOutputAmount: parsePositiveAmount({
1673
+ receiveOutputAmount: positiveAmountFromRawOrThrow({
1762
1674
  label: "receive_output_amount",
1763
1675
  raw: dto.receive_output_amount,
1764
1676
  decimals: outputDecimals,
@@ -1777,7 +1689,7 @@ var OndoSellTransaction = {
1777
1689
  fromDto: (dto) => {
1778
1690
  const spendDecimals = AssetDecimals(dto.spend_input_decimals);
1779
1691
  const outputDecimals = AssetDecimals(dto.receive_output_decimals);
1780
- const expectedQuantity = parsePositiveAmount({
1692
+ const expectedQuantity = positiveAmountFromRawOrThrow({
1781
1693
  label: "expected_quantity",
1782
1694
  raw: dto.expected_quantity,
1783
1695
  decimals: outputDecimals,
@@ -1811,12 +1723,12 @@ var OndoSellTransaction = {
1811
1723
  };
1812
1724
  function parseSwapCore(dto, spendDecimals) {
1813
1725
  return {
1814
- tx: {
1815
- to: EvmContractAddress(dto.to),
1816
- data: HexEncodedTransactionData(dto.data)
1817
- },
1818
- expiresAt: parseExpiresAt(dto.expires_at),
1819
- spendInputAmount: parsePositiveAmount({
1726
+ tx: txFromWire(dto),
1727
+ // A transaction whose expiry cannot be read is not safely fillable - the
1728
+ // deadline is encoded in the calldata either way, so broadcasting against
1729
+ // an unknown one only spends gas on a revert.
1730
+ expiresAt: requiredDate(dto.expires_at, "expires_at"),
1731
+ spendInputAmount: positiveAmountFromRawOrThrow({
1820
1732
  label: "spend_input_amount",
1821
1733
  raw: dto.spend_input_amount,
1822
1734
  decimals: spendDecimals,
@@ -1834,7 +1746,7 @@ function parseSwapCore(dto, spendDecimals) {
1834
1746
  };
1835
1747
  }
1836
1748
  function parseMinimumQuantity(raw, decimals, expectedQuantity) {
1837
- const amount = parsePositiveAmount({
1749
+ const amount = positiveAmountFromRawOrThrow({
1838
1750
  label: "minimum_quantity",
1839
1751
  raw,
1840
1752
  decimals,
@@ -1847,27 +1759,6 @@ function parseMinimumQuantity(raw, decimals, expectedQuantity) {
1847
1759
  }
1848
1760
  return amount;
1849
1761
  }
1850
- function parsePositiveAmount({
1851
- label,
1852
- raw,
1853
- decimals,
1854
- reason
1855
- }) {
1856
- const amount = blockchainAmountFromRawOrThrow({ label, raw, decimals });
1857
- if (amount.raw <= 0n) {
1858
- throw new ValidationError(
1859
- `${label}: must be greater than zero ("${raw}") - ${reason}`
1860
- );
1861
- }
1862
- return amount;
1863
- }
1864
- function parseExpiresAt(value) {
1865
- const date = new Date(value);
1866
- if (Number.isNaN(date.getTime())) {
1867
- throw new ValidationError(`expires_at: not a date ("${value}")`);
1868
- }
1869
- return date;
1870
- }
1871
1762
 
1872
1763
  // src/universal/api/frontline/providers/ondo/ondo.ts
1873
1764
  async function getOndoTradingStatus(api, params) {
@@ -1923,27 +1814,15 @@ async function buildOndoSell(api, params) {
1923
1814
  // or a QA run reads as a puzzle rather than a diagnosis.
1924
1815
  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"
1925
1816
  });
1926
- return OndoSellTransaction.fromDto(dto);
1927
- }
1928
- function swapBody(params) {
1929
- return {
1930
- symbol: params.symbol,
1931
- chain: params.chain,
1932
- wallet_address: params.walletAddress,
1933
- amount: params.amount.raw.toString()
1934
- };
1935
- }
1936
- function assertSpendScaleAgrees({
1937
- published,
1938
- sized,
1939
- trade,
1940
- note
1941
- }) {
1942
- if (published === sized.decimals) return;
1943
- const because = note === void 0 ? "" : ` - ${note}`;
1944
- throw new ValidationError(
1945
- `spend_input_decimals: the ${trade} was priced in ${published} decimals but the order was sized in ${sized.decimals}${because}`
1946
- );
1817
+ return OndoSellTransaction.fromDto(dto);
1818
+ }
1819
+ function swapBody(params) {
1820
+ return {
1821
+ symbol: params.symbol,
1822
+ chain: params.chain,
1823
+ wallet_address: params.walletAddress,
1824
+ amount: params.amount.raw.toString()
1825
+ };
1947
1826
  }
1948
1827
  function sizeParam(params) {
1949
1828
  const tokenAmount = "tokenAmount" in params ? params.tokenAmount : void 0;
@@ -1964,7 +1843,7 @@ function sizeParam(params) {
1964
1843
  return { notional_value: notionalValue };
1965
1844
  }
1966
1845
 
1967
- // src/universal/core/checkout/ondo/ondo-namespace.ts
1846
+ // src/universal/core/providers/ondo/ondo-namespace.ts
1968
1847
  var OndoNamespaceImpl = class {
1969
1848
  constructor(ctx) {
1970
1849
  this.ctx = ctx;
@@ -1996,7 +1875,101 @@ var OndoNamespaceImpl = class {
1996
1875
  }
1997
1876
  };
1998
1877
 
1999
- // src/universal/core/checkout/superstate/blockchain/abi.ts
1878
+ // src/universal/types/providers/superstate/swap.ts
1879
+ var SwapPreview = {
1880
+ /** Maps the contract's `Preview { input, fee, output }` struct. */
1881
+ fromContract: (preview) => ({
1882
+ inputAmount: parseUint256(preview.input, "SwapPreview.input"),
1883
+ fee: parseUint256(preview.fee, "SwapPreview.fee"),
1884
+ outputAmount: parseUint256(preview.output, "SwapPreview.output")
1885
+ })
1886
+ };
1887
+ var PauseFlags = (value) => value;
1888
+ var SwapStatus = {
1889
+ /**
1890
+ * Maps the contract's `Status { uint32 flags; State state }` struct, where
1891
+ * `State` is `0 = Active | 1 = Paused | 2 = Stopped`.
1892
+ *
1893
+ * `flags` is carried onto the `paused` arm only. On the other two the
1894
+ * contract sets it to a self-identifying marker rather than to information -
1895
+ * so repeating it would invite a caller to read meaning into a constant.
1896
+ *
1897
+ * @throws ValidationError on a `state` outside the enum. A contract that has
1898
+ * grown a fourth state is one the SDK does not model, and guessing `active`
1899
+ * would let a halted swap read as a live one.
1900
+ */
1901
+ fromContract: (status) => {
1902
+ switch (status.state) {
1903
+ case 0:
1904
+ return { state: "active" };
1905
+ case 1:
1906
+ return { state: "paused", pausedLevels: PauseFlags(status.flags) };
1907
+ case 2:
1908
+ return { state: "stopped" };
1909
+ default:
1910
+ throw new ValidationError(
1911
+ `SwapStatus.state: unknown contract state (${status.state})`
1912
+ );
1913
+ }
1914
+ }
1915
+ };
1916
+ var AllowWalletResponse = {
1917
+ fromDto: (dto) => {
1918
+ switch (dto.action) {
1919
+ case "broadcast_transaction":
1920
+ return {
1921
+ action: "broadcast_transaction",
1922
+ tx: txFromWire(dto)
1923
+ };
1924
+ case "none":
1925
+ return {
1926
+ action: "none",
1927
+ alreadyAllowed: dto.already_allowed
1928
+ };
1929
+ default: {
1930
+ const _exhaustive = dto;
1931
+ return _exhaustive;
1932
+ }
1933
+ }
1934
+ }
1935
+ };
1936
+
1937
+ // src/universal/core/providers/superstate/blockchain/quote.ts
1938
+ var SwapQuote = {
1939
+ /**
1940
+ * Assembles a {@link SwapQuote} from a raw contract {@link SwapPreview}. The
1941
+ * input and fee are denominated in the input token; the output in the output
1942
+ * token.
1943
+ */
1944
+ fromPreview: (preview, inputDecimals, outputDecimals) => ({
1945
+ inputTokenAmount: BlockchainAmount({
1946
+ raw: preview.inputAmount,
1947
+ decimals: inputDecimals
1948
+ }),
1949
+ fee: BlockchainAmount({ raw: preview.fee, decimals: inputDecimals }),
1950
+ outputTokenAmount: BlockchainAmount({
1951
+ raw: preview.outputAmount,
1952
+ decimals: outputDecimals
1953
+ })
1954
+ })
1955
+ };
1956
+
1957
+ // src/universal/api/frontline/providers/superstate/swap.ts
1958
+ async function allowWallet(api, params) {
1959
+ const dto = await api.send({
1960
+ method: "POST",
1961
+ url: `/v1/offers/${encodeURIComponent(params.offerId)}/allow-wallet`,
1962
+ body: {
1963
+ wallet_address: params.walletAddress,
1964
+ chain: params.chain,
1965
+ signature: params.signature
1966
+ },
1967
+ attributes: Attributes.protected()
1968
+ });
1969
+ return AllowWalletResponse.fromDto(dto);
1970
+ }
1971
+
1972
+ // src/universal/core/providers/superstate/blockchain/abi.ts
2000
1973
  var SUPERSTATE_SWAP_ABI = [
2001
1974
  {
2002
1975
  type: "function",
@@ -2868,80 +2841,105 @@ var SUPERSTATE_SWAP_ABI = [
2868
2841
  }
2869
2842
  ];
2870
2843
 
2871
- // src/universal/types/providers/superstate/swap.ts
2872
- var SwapPreview = {
2873
- /** Maps the contract's `Preview { input, fee, output }` struct. */
2874
- fromContract: (preview) => ({
2875
- inputAmount: parseUint256(preview.input, "SwapPreview.input"),
2876
- fee: parseUint256(preview.fee, "SwapPreview.fee"),
2877
- outputAmount: parseUint256(preview.output, "SwapPreview.output")
2878
- })
2879
- };
2880
- var PauseFlags = (value) => value;
2881
- var SwapStatus = {
2882
- /**
2883
- * Maps the contract's `Status { uint32 flags; State state }` struct, where
2884
- * `State` is `0 = Active | 1 = Paused | 2 = Stopped`.
2885
- *
2886
- * `flags` is carried onto the `paused` arm only. On the other two the
2887
- * contract sets it to a self-identifying marker rather than to information -
2888
- * so repeating it would invite a caller to read meaning into a constant.
2889
- *
2890
- * @throws ValidationError on a `state` outside the enum. A contract that has
2891
- * grown a fourth state is one the SDK does not model, and guessing `active`
2892
- * would let a halted swap read as a live one.
2893
- */
2894
- fromContract: (status) => {
2895
- switch (status.state) {
2896
- case 0:
2897
- return { state: "active" };
2898
- case 1:
2899
- return { state: "paused", pausedLevels: PauseFlags(status.flags) };
2900
- case 2:
2901
- return { state: "stopped" };
2902
- default:
2903
- throw new ValidationError(
2904
- `SwapStatus.state: unknown contract state (${status.state})`
2905
- );
2906
- }
2907
- }
2908
- };
2909
- var AllowWalletResponse = {
2910
- fromDto: (dto) => {
2911
- switch (dto.action) {
2912
- case "broadcast_transaction":
2913
- return {
2914
- action: "broadcast_transaction",
2915
- to: EvmContractAddress(dto.to),
2916
- data: HexEncodedTransactionData(dto.data)
2917
- };
2918
- case "none":
2919
- return {
2920
- action: "none",
2921
- alreadyAllowed: dto.already_allowed
2922
- };
2923
- default: {
2924
- const _exhaustive = dto;
2925
- return _exhaustive;
2926
- }
2927
- }
2928
- }
2929
- };
2930
-
2931
- // src/universal/api/frontline/providers/superstate/swap.ts
2932
- async function allowWallet(api, params) {
2933
- const dto = await api.send({
2934
- method: "POST",
2935
- url: `/v1/offers/${encodeURIComponent(params.offerId)}/allow-wallet`,
2936
- body: {
2937
- wallet_address: params.walletAddress,
2938
- chain: params.chain,
2939
- signature: params.signature
2940
- },
2941
- attributes: Attributes.protected()
2942
- });
2943
- return AllowWalletResponse.fromDto(dto);
2944
- }
2844
+ // src/universal/core/shared/blockchain/erc20/abi.ts
2845
+ var ERC20_ABI = [
2846
+ {
2847
+ type: "function",
2848
+ name: "allowance",
2849
+ inputs: [
2850
+ { name: "owner", type: "address" },
2851
+ { name: "spender", type: "address" }
2852
+ ],
2853
+ outputs: [{ name: "", type: "uint256" }],
2854
+ stateMutability: "view"
2855
+ },
2856
+ {
2857
+ type: "function",
2858
+ name: "approve",
2859
+ inputs: [
2860
+ { name: "spender", type: "address" },
2861
+ { name: "amount", type: "uint256" }
2862
+ ],
2863
+ outputs: [{ name: "", type: "bool" }],
2864
+ stateMutability: "nonpayable"
2865
+ },
2866
+ {
2867
+ type: "function",
2868
+ name: "balanceOf",
2869
+ inputs: [{ name: "account", type: "address" }],
2870
+ outputs: [{ name: "", type: "uint256" }],
2871
+ stateMutability: "view"
2872
+ },
2873
+ {
2874
+ type: "function",
2875
+ name: "decimals",
2876
+ inputs: [],
2877
+ outputs: [{ name: "", type: "uint8" }],
2878
+ stateMutability: "view"
2879
+ },
2880
+ {
2881
+ type: "function",
2882
+ name: "name",
2883
+ inputs: [],
2884
+ outputs: [{ name: "", type: "string" }],
2885
+ stateMutability: "view"
2886
+ },
2887
+ {
2888
+ type: "function",
2889
+ name: "symbol",
2890
+ inputs: [],
2891
+ outputs: [{ name: "", type: "string" }],
2892
+ stateMutability: "view"
2893
+ },
2894
+ {
2895
+ type: "function",
2896
+ name: "totalSupply",
2897
+ inputs: [],
2898
+ outputs: [{ name: "", type: "uint256" }],
2899
+ stateMutability: "view"
2900
+ },
2901
+ {
2902
+ type: "function",
2903
+ name: "transfer",
2904
+ inputs: [
2905
+ { name: "recipient", type: "address" },
2906
+ { name: "amount", type: "uint256" }
2907
+ ],
2908
+ outputs: [{ name: "", type: "bool" }],
2909
+ stateMutability: "nonpayable"
2910
+ },
2911
+ {
2912
+ type: "function",
2913
+ name: "transferFrom",
2914
+ inputs: [
2915
+ { name: "sender", type: "address" },
2916
+ { name: "recipient", type: "address" },
2917
+ { name: "amount", type: "uint256" }
2918
+ ],
2919
+ outputs: [{ name: "", type: "bool" }],
2920
+ stateMutability: "nonpayable"
2921
+ },
2922
+ {
2923
+ type: "event",
2924
+ name: "Approval",
2925
+ inputs: [
2926
+ { name: "owner", type: "address", indexed: true },
2927
+ { name: "spender", type: "address", indexed: true },
2928
+ { name: "value", type: "uint256", indexed: false }
2929
+ ],
2930
+ anonymous: false
2931
+ },
2932
+ {
2933
+ type: "event",
2934
+ name: "Transfer",
2935
+ inputs: [
2936
+ { name: "from", type: "address", indexed: true },
2937
+ { name: "to", type: "address", indexed: true },
2938
+ { name: "value", type: "uint256", indexed: false }
2939
+ ],
2940
+ anonymous: false
2941
+ }
2942
+ ];
2945
2943
 
2946
2944
  // src/universal/api/rpc/providers/superstate/swap.ts
2947
2945
  async function getSwapAuthorization(clients, params) {
@@ -2992,7 +2990,7 @@ async function getSwapOutputToken(clients, params) {
2992
2990
  };
2993
2991
  }
2994
2992
 
2995
- // src/universal/core/checkout/superstate/swap-namespace.ts
2993
+ // src/universal/core/providers/superstate/superstate-namespace.ts
2996
2994
  var SuperstateSwapNamespaceImpl = class {
2997
2995
  constructor(ctx) {
2998
2996
  this.ctx = ctx;
@@ -3012,6 +3010,20 @@ var SuperstateSwapNamespaceImpl = class {
3012
3010
  async () => getSwapPreview(this.ctx.rpc, params)
3013
3011
  );
3014
3012
  }
3013
+ async getQuote(params) {
3014
+ return this.log.wrap("getQuote", params, async () => {
3015
+ const { amount, outputTokenDecimals, ...ref } = params;
3016
+ const preview = await getSwapPreview(this.ctx.rpc, {
3017
+ ...ref,
3018
+ amount: amount.raw
3019
+ });
3020
+ return SwapQuote.fromPreview(
3021
+ preview,
3022
+ amount.decimals,
3023
+ outputTokenDecimals
3024
+ );
3025
+ });
3026
+ }
3015
3027
  async getStatus(params) {
3016
3028
  return this.log.wrap(
3017
3029
  "getStatus",
@@ -3209,6 +3221,202 @@ var RequirementsNamespaceImpl = class {
3209
3221
  }
3210
3222
  };
3211
3223
 
3224
+ // src/universal/types/offer-option-address.ts
3225
+ var OfferOptionAddressId = (value) => value;
3226
+ var OfferOptionAddress = {
3227
+ /** Maps the API DTO into the SDK offer-option-address domain model. */
3228
+ fromDto: (dto) => ({
3229
+ id: OfferOptionAddressId(dto.id),
3230
+ offerOptionId: OfferOptionId(dto.offer_option_id),
3231
+ address: EvmWalletAddress(dto.address),
3232
+ protocol: dto.protocol,
3233
+ createdAt: new Date(dto.created_at)
3234
+ })
3235
+ };
3236
+ var ConnectExternalWalletParams = {
3237
+ /** Maps connect-wallet params into the API DTO payload. */
3238
+ toDto: (params) => ({
3239
+ offer_option_id: params.offerOptionId,
3240
+ wallet_address: params.walletAddress,
3241
+ chain: params.chain,
3242
+ signature: params.signature
3243
+ })
3244
+ };
3245
+
3246
+ // src/universal/types/wallet-ownership-challenge.ts
3247
+ var WalletOwnershipChallenge = {
3248
+ /** Maps the API DTO into the SDK wallet-ownership-challenge domain model. */
3249
+ fromDto: (dto) => ({
3250
+ message: dto.message,
3251
+ expiresAt: new Date(dto.expires_at)
3252
+ })
3253
+ };
3254
+ var CreateWalletOwnershipChallengeParams = {
3255
+ /**
3256
+ * Maps challenge-request params into the API DTO payload. The discriminated
3257
+ * union guarantees SIWE fields are present exactly when `challengeType` is
3258
+ * `siwe`, so the mapping narrows on the discriminant.
3259
+ */
3260
+ toDto: (params) => {
3261
+ switch (params.challengeType) {
3262
+ case "plain":
3263
+ return {
3264
+ wallet_address: params.walletAddress,
3265
+ chain: params.chain,
3266
+ challenge_type: "plain"
3267
+ };
3268
+ case "siwe":
3269
+ return {
3270
+ wallet_address: params.walletAddress,
3271
+ chain: params.chain,
3272
+ challenge_type: "siwe",
3273
+ domain: params.domain,
3274
+ uri: params.uri,
3275
+ statement: params.statement
3276
+ };
3277
+ default: {
3278
+ const _exhaustive = params;
3279
+ return _exhaustive;
3280
+ }
3281
+ }
3282
+ }
3283
+ };
3284
+
3285
+ // src/universal/api/frontline/wallet-connect.ts
3286
+ async function createWalletOwnershipChallenge(api, params) {
3287
+ const dto = await api.send({
3288
+ method: "POST",
3289
+ url: "/v1/wallet-ownership",
3290
+ body: CreateWalletOwnershipChallengeParams.toDto(params),
3291
+ attributes: Attributes.protected()
3292
+ });
3293
+ return WalletOwnershipChallenge.fromDto(dto);
3294
+ }
3295
+ async function connectExternalWallet(api, params) {
3296
+ const dto = await api.send({
3297
+ method: "POST",
3298
+ url: `/v1/offers/${params.offerId}/addresses`,
3299
+ body: ConnectExternalWalletParams.toDto(params),
3300
+ attributes: Attributes.protected()
3301
+ });
3302
+ return OfferOptionAddress.fromDto(dto);
3303
+ }
3304
+ async function listOptionAddresses(api, offerId, offerOptionId) {
3305
+ const { data } = await api.send({
3306
+ method: "GET",
3307
+ url: `/v1/offers/${offerId}/addresses`,
3308
+ queryParams: { offer_option_id: offerOptionId },
3309
+ attributes: Attributes.protected()
3310
+ });
3311
+ return data.map(OfferOptionAddress.fromDto);
3312
+ }
3313
+ async function removeOptionAddress(api, offerId, addressId) {
3314
+ const dto = await api.send({
3315
+ method: "DELETE",
3316
+ url: `/v1/offers/${offerId}/addresses/${addressId}`,
3317
+ attributes: Attributes.protected()
3318
+ });
3319
+ return OfferOptionAddress.fromDto(dto);
3320
+ }
3321
+
3322
+ // src/universal/core/wallets/wallets-namespace.ts
3323
+ var WalletsNamespaceImpl = class {
3324
+ constructor(ctx) {
3325
+ this.ctx = ctx;
3326
+ this.log = internalLogger(ctx.logger, "WALLETS");
3327
+ }
3328
+ async createOwnershipChallenge(params) {
3329
+ return this.log.wrap("createOwnershipChallenge", params, async () => {
3330
+ await this.ctx.ensureUserAuthenticated();
3331
+ return createWalletOwnershipChallenge(
3332
+ this.ctx.api,
3333
+ params
3334
+ );
3335
+ });
3336
+ }
3337
+ async connectExternal(params) {
3338
+ return this.log.wrap("connectExternal", params, async () => {
3339
+ await this.ctx.ensureUserAuthenticated();
3340
+ return connectExternalWallet(this.ctx.api, params);
3341
+ });
3342
+ }
3343
+ async list(params) {
3344
+ return this.log.wrap("list", params, async () => {
3345
+ await this.ctx.ensureUserAuthenticated();
3346
+ return listOptionAddresses(
3347
+ this.ctx.api,
3348
+ params.offerId,
3349
+ params.offerOptionId
3350
+ );
3351
+ });
3352
+ }
3353
+ async remove(params) {
3354
+ return this.log.wrap("remove", params, async () => {
3355
+ await this.ctx.ensureUserAuthenticated();
3356
+ return removeOptionAddress(
3357
+ this.ctx.api,
3358
+ params.offerId,
3359
+ params.addressId
3360
+ );
3361
+ });
3362
+ }
3363
+ };
3364
+
3365
+ // src/universal/api/frontline/offers.ts
3366
+ async function fetchOffers(api, clientCreds) {
3367
+ return fetchAllPages((params) => fetchOffersPage(api, params, clientCreds));
3368
+ }
3369
+ async function fetchOffersPage(api, params, clientCreds) {
3370
+ const queryParams = PaginationParams.toQueryParams(params);
3371
+ const pageDto = await api.send({
3372
+ method: "GET",
3373
+ url: "/v1/offers",
3374
+ queryParams,
3375
+ attributes: Attributes.concat(
3376
+ Attributes.protected(),
3377
+ Attributes.clientCredentials(clientCreds)
3378
+ )
3379
+ });
3380
+ return PaginatedResponse.fromDtoPage(pageDto, Offer.listFromDto);
3381
+ }
3382
+ async function fetchOfferDetails(api, id, clientCreds) {
3383
+ const dto = await api.send({
3384
+ method: "GET",
3385
+ url: `/v1/offers/${id}`,
3386
+ attributes: Attributes.concat(
3387
+ Attributes.protected(),
3388
+ Attributes.clientCredentials(clientCreds)
3389
+ )
3390
+ });
3391
+ return OfferDetail.fromDto(dto);
3392
+ }
3393
+
3394
+ // src/universal/core/offers/offers-namespace.ts
3395
+ var OffersNamespaceImpl = class {
3396
+ constructor(ctx) {
3397
+ this.ctx = ctx;
3398
+ this.log = internalLogger(ctx.logger, "OFFERS");
3399
+ }
3400
+ async list() {
3401
+ return this.log.wrap("list", void 0, async () => {
3402
+ await this.ctx.ensureUserAuthenticated();
3403
+ return fetchOffers(this.ctx.api, void 0);
3404
+ });
3405
+ }
3406
+ async listPage(params) {
3407
+ return this.log.wrap("listPage", params, async () => {
3408
+ await this.ctx.ensureUserAuthenticated();
3409
+ return fetchOffersPage(this.ctx.api, params, void 0);
3410
+ });
3411
+ }
3412
+ async get(id) {
3413
+ return this.log.wrap("get", id, async () => {
3414
+ await this.ctx.ensureUserAuthenticated();
3415
+ return fetchOfferDetails(this.ctx.api, id, void 0);
3416
+ });
3417
+ }
3418
+ };
3419
+
3212
3420
  // src/universal/api/rpc/erc20.ts
3213
3421
  async function getTokenAllowance(clients, params) {
3214
3422
  const allowance = await clients(params.chain).readContract({
@@ -3316,207 +3524,26 @@ function tokensOfChain(chain, assets, baseUrl) {
3316
3524
  decimals: AssetDecimals(asset.decimals),
3317
3525
  logo: TokenLogo.fromDto(asset.logo, baseUrl),
3318
3526
  logoDark: asset.logo_dark === void 0 ? null : TokenLogo.fromDto(asset.logo_dark, baseUrl)
3319
- }));
3320
- }
3321
- function assertSupportedSchemaVersion(version) {
3322
- if (version !== 1) {
3323
- throw new ValidationError(
3324
- `Unsupported token registry schema_version: ${version}`
3325
- );
3326
- }
3327
- }
3328
- var logoImageFromDto = (dto, baseUrl) => ({
3329
- url: resolveLogoUrl(dto.url, baseUrl),
3330
- width: dto.width,
3331
- height: dto.height
3332
- });
3333
- var resolveLogoUrl = (url, baseUrl) => TokenLogoUrl(
3334
- url.startsWith("http") ? url : `${baseUrl.replace(/\/$/, "")}${url}`
3335
- );
3336
-
3337
- // src/universal/api/nabu/tokens.ts
3338
- import { getAddress } from "viem";
3339
-
3340
- // src/universal/api/frontline/config.ts
3341
- var PUBLIC_API_BASE_URL = "https://api.coinlist.co";
3342
- var HEADER_API_VERSION = "X-API-Version";
3343
- var HEADER_USER_AGENT = "User-Agent";
3344
- var HEADER_IDEMPOTENCY_KEY = "Idempotency-Key";
3345
- var API_VERSION = "2025-10-17";
3346
- var COINLIST_BASE_URL = "https://coinlist.co";
3347
- var OAUTH_PAGE_PATH = "/oauth/authorize";
3348
- var SUPPORT_NEW_TICKET_URL = "https://support.coinlist.co/support/tickets/new";
3349
- var VERIFY_IDENTITY_PATH = "/verify-identity";
3350
- var VERIFY_IDENTITY_ACCREDITATION_PATH = "/verify-identity/accreditation_full";
3351
- var WALLET_PATH = "/wallet";
3352
-
3353
- // src/universal/api/http-client.ts
3354
- var HttpClient = class {
3355
- constructor(config, middleware = {}, logger = null, options = {}) {
3356
- this.config = config;
3357
- this.middleware = middleware;
3358
- this.log = internalLogger(logger, "HTTP");
3359
- this.makeRequestId = options.makeRequestId ?? defaultMakeRequestId;
3360
- }
3361
- async send(request) {
3362
- return this.runRequestWithAfterMiddleware(request);
3363
- }
3364
- /**
3365
- * Runs beforeRequest, executeRequest, then the full afterRequest middleware
3366
- * chain. Used by send() and by the retry() callback so that when a
3367
- * middleware calls retry(), the retried response also goes through all
3368
- * afterRequest middleware (e.g. session renewal, retry). Middleware
3369
- * must use request.attributes.retryAttempt (or similar) to avoid infinite
3370
- * recursion when they trigger retries.
3371
- */
3372
- async runRequestWithAfterMiddleware(request) {
3373
- const preparedRequest = await this.runBeforeRequestMiddleware(
3374
- this.withClientDefaults(request)
3375
- );
3376
- let response = await this.executeRequest(preparedRequest);
3377
- for (const middleware of this.middleware.afterRequest ?? []) {
3378
- let retried = false;
3379
- response = await middleware({
3380
- request: preparedRequest,
3381
- response,
3382
- retry: (nextRequest = preparedRequest) => {
3383
- retried = true;
3384
- return this.runRequestWithAfterMiddleware(nextRequest);
3385
- }
3386
- });
3387
- if (retried) {
3388
- return response;
3389
- }
3390
- }
3391
- return response;
3392
- }
3393
- withClientDefaults(request) {
3394
- const url = this.resolveUrl(request.url);
3395
- const headers = {
3396
- ...request.headers ?? {},
3397
- ...this.config.xApiVersion !== void 0 ? { [HEADER_API_VERSION]: this.config.xApiVersion } : {}
3398
- };
3399
- return {
3400
- ...request,
3401
- url,
3402
- headers,
3403
- // Only when absent: a retry or a post-renewal re-send arrives with the
3404
- // first attempt's id already on it, and keeping it is the whole point.
3405
- attributes: Attributes.getRequestId(request.attributes) === null ? Attributes.concat(
3406
- request.attributes ?? Attributes.empty,
3407
- Attributes.requestId(this.makeRequestId())
3408
- ) : request.attributes
3409
- };
3410
- }
3411
- /**
3412
- * Resolves a request URL against the client's baseUrl.
3413
- *
3414
- * @internal Public only for testing. Do not use in application code; use
3415
- * {@link HttpClient.send} with a path and the client will resolve the URL.
3416
- */
3417
- resolveUrl(url) {
3418
- if (url.startsWith("http://") || url.startsWith("https://")) {
3419
- return url;
3420
- }
3421
- const base2 = this.config.baseUrl.replace(/\/$/, "");
3422
- const path = url.startsWith("/") ? url : `/${url}`;
3423
- return base2 + path;
3424
- }
3425
- async runBeforeRequestMiddleware(initialRequest) {
3426
- let request = initialRequest;
3427
- for (const middleware of this.middleware.beforeRequest ?? []) {
3428
- request = await middleware(request);
3429
- }
3430
- return request;
3431
- }
3432
- /**
3433
- * One physical attempt, logged as one line.
3434
- *
3435
- * A non-2xx is a `warn` rather than an `error` because the wire does not
3436
- * know whether it is a failure: the retry middleware may turn a 503 into a
3437
- * success, and the token registry reads a 404 as "not listed". The namespace
3438
- * above decides, and logs the `error` when it does.
3439
- */
3440
- async executeRequest(request) {
3441
- const requestId2 = Attributes.getRequestId(request.attributes);
3442
- const log = requestId2 === null ? this.log : this.log.child({ requestId: requestId2 });
3443
- const attempt = Attributes.getRetryAttempt(request.attributes) + 1;
3444
- const startedAt = Date.now();
3445
- log.debug(() => ({
3446
- msg: "request sent",
3447
- fields: describeRequestUnredacted(request)
3448
- }));
3449
- try {
3450
- const response = await makeRequest(request);
3451
- const elapsed = Date.now() - startedAt;
3452
- const outcome = () => ({
3453
- msg: "request completed",
3454
- fields: {
3455
- ...identifyRequest(request),
3456
- "http.response.status_code": response.status,
3457
- duration_ms: elapsed,
3458
- attempt
3459
- }
3460
- });
3461
- if (response.status >= 200 && response.status < 300) {
3462
- log.info(outcome);
3463
- } else {
3464
- log.warn(outcome);
3465
- }
3466
- log.debug(() => ({
3467
- msg: "response received",
3468
- fields: { body: response.body }
3469
- }));
3470
- return requestId2 === null ? response : { ...response, requestId: requestId2 };
3471
- } catch (error) {
3472
- const elapsed = Date.now() - startedAt;
3473
- log.warning(
3474
- () => ({
3475
- msg: "request threw",
3476
- fields: {
3477
- ...identifyRequest(request),
3478
- duration_ms: elapsed,
3479
- attempt
3480
- }
3481
- }),
3482
- error
3483
- );
3484
- throw error;
3485
- }
3486
- }
3487
- };
3488
- function identifyRequest(request) {
3489
- const { host, path } = splitUrl(request.url);
3490
- return {
3491
- "http.request.method": request.method,
3492
- "server.address": host,
3493
- "url.path": path
3494
- };
3495
- }
3496
- function splitUrl(url) {
3497
- try {
3498
- const parsed = new URL(url);
3499
- return { host: parsed.host, path: parsed.pathname };
3500
- } catch (_) {
3501
- return { host: null, path: url };
3502
- }
3503
- }
3504
- function defaultMakeRequestId() {
3505
- return Math.random().toString(36).slice(2, 10).padEnd(8, "0");
3527
+ }));
3506
3528
  }
3507
- function describeRequestUnredacted(request) {
3508
- return {
3509
- "http.request.method": request.method,
3510
- "url.full": buildUrlWithQueryParams(request.url, request.queryParams),
3511
- headers: request.headers,
3512
- ...request.method === "POST" ? { body: request.body } : {}
3513
- };
3529
+ function assertSupportedSchemaVersion(version) {
3530
+ if (version !== 1) {
3531
+ throw new ValidationError(
3532
+ `Unsupported token registry schema_version: ${version}`
3533
+ );
3534
+ }
3514
3535
  }
3536
+ var logoImageFromDto = (dto, baseUrl) => ({
3537
+ url: resolveLogoUrl(dto.url, baseUrl),
3538
+ width: dto.width,
3539
+ height: dto.height
3540
+ });
3541
+ var resolveLogoUrl = (url, baseUrl) => TokenLogoUrl(
3542
+ url.startsWith("http") ? url : `${baseUrl.replace(/\/$/, "")}${url}`
3543
+ );
3515
3544
 
3516
3545
  // src/universal/api/nabu/tokens.ts
3517
- function createNabuApiClient(baseUrl, logger = null) {
3518
- return new HttpClient({ baseUrl }, {}, logger);
3519
- }
3546
+ import { getAddress } from "viem";
3520
3547
  async function fetchTokenMetadata(client, token) {
3521
3548
  const address = checksummed(token.address);
3522
3549
  let response;
@@ -3604,254 +3631,64 @@ function checksummed(address) {
3604
3631
  }
3605
3632
  }
3606
3633
 
3607
- // src/universal/core/tokens/tokens-namespace.ts
3634
+ // src/universal/core/shared/blockchain/tokens/tokens-namespace.ts
3608
3635
  var TokensNamespaceImpl = class {
3609
- /**
3610
- * Takes the registry origin rather than a `UniversalNamespaceContext`: the
3611
- * registry is unauthenticated and on its own host, so the frontline sender
3612
- * and the auth check would both be dead weight here.
3613
- */
3614
- constructor(baseUrl, logger = null) {
3615
- this.api = createNabuApiClient(baseUrl, logger);
3616
- this.log = internalLogger(logger, "TOKENS");
3636
+ constructor(ctx) {
3637
+ this.ctx = ctx;
3638
+ this.log = internalLogger(ctx.logger, "TOKENS");
3617
3639
  }
3618
3640
  get(token) {
3619
3641
  return this.log.wrap(
3620
3642
  "get",
3621
3643
  token,
3622
- () => fetchTokenMetadata(this.api, token)
3644
+ () => fetchTokenMetadata(this.ctx.nabu, token)
3623
3645
  );
3624
3646
  }
3625
3647
  list(chain) {
3626
3648
  return this.log.wrap(
3627
3649
  "list",
3628
3650
  chain,
3629
- () => chain === void 0 ? fetchAllTokensMetadata(this.api) : fetchTokensMetadata(this.api, chain)
3651
+ () => chain === void 0 ? fetchAllTokensMetadata(this.ctx.nabu) : fetchTokensMetadata(this.ctx.nabu, chain)
3630
3652
  );
3631
3653
  }
3632
3654
  };
3633
3655
 
3634
- // src/universal/types/offer-option-address.ts
3635
- var OfferOptionAddressId = (value) => value;
3636
- var OfferOptionAddress = {
3637
- /** Maps the API DTO into the SDK offer-option-address domain model. */
3638
- fromDto: (dto) => ({
3639
- id: OfferOptionAddressId(dto.id),
3640
- offerOptionId: OfferOptionId(dto.offer_option_id),
3641
- address: EvmWalletAddress(dto.address),
3642
- protocol: dto.protocol,
3643
- createdAt: new Date(dto.created_at)
3644
- })
3645
- };
3646
- var ConnectExternalWalletParams = {
3647
- /** Maps connect-wallet params into the API DTO payload. */
3648
- toDto: (params) => ({
3649
- offer_option_id: params.offerOptionId,
3650
- wallet_address: params.walletAddress,
3651
- chain: params.chain,
3652
- signature: params.signature
3653
- })
3654
- };
3655
-
3656
- // src/universal/types/wallet-ownership-challenge.ts
3657
- var WalletOwnershipChallenge = {
3658
- /** Maps the API DTO into the SDK wallet-ownership-challenge domain model. */
3659
- fromDto: (dto) => ({
3660
- message: dto.message,
3661
- expiresAt: new Date(dto.expires_at)
3662
- })
3663
- };
3664
- var CreateWalletOwnershipChallengeParams = {
3665
- /**
3666
- * Maps challenge-request params into the API DTO payload. The discriminated
3667
- * union guarantees SIWE fields are present exactly when `challengeType` is
3668
- * `siwe`, so the mapping narrows on the discriminant.
3669
- */
3670
- toDto: (params) => {
3671
- switch (params.challengeType) {
3672
- case "plain":
3673
- return {
3674
- wallet_address: params.walletAddress,
3675
- chain: params.chain,
3676
- challenge_type: "plain"
3677
- };
3678
- case "siwe":
3679
- return {
3680
- wallet_address: params.walletAddress,
3681
- chain: params.chain,
3682
- challenge_type: "siwe",
3683
- domain: params.domain,
3684
- uri: params.uri,
3685
- statement: params.statement
3686
- };
3687
- default: {
3688
- const _exhaustive = params;
3689
- return _exhaustive;
3690
- }
3691
- }
3692
- }
3693
- };
3694
-
3695
- // src/universal/api/frontline/wallet-connect.ts
3696
- async function createWalletOwnershipChallenge(api, params) {
3697
- const dto = await api.send({
3698
- method: "POST",
3699
- url: "/v1/wallet-ownership",
3700
- body: CreateWalletOwnershipChallengeParams.toDto(params),
3701
- attributes: Attributes.protected()
3702
- });
3703
- return WalletOwnershipChallenge.fromDto(dto);
3704
- }
3705
- async function connectExternalWallet(api, params) {
3706
- const dto = await api.send({
3707
- method: "POST",
3708
- url: `/v1/offers/${params.offerId}/addresses`,
3709
- body: ConnectExternalWalletParams.toDto(params),
3710
- attributes: Attributes.protected()
3711
- });
3712
- return OfferOptionAddress.fromDto(dto);
3713
- }
3714
- async function listOptionAddresses(api, offerId, offerOptionId) {
3715
- const { data } = await api.send({
3716
- method: "GET",
3717
- url: `/v1/offers/${offerId}/addresses`,
3718
- queryParams: { offer_option_id: offerOptionId },
3719
- attributes: Attributes.protected()
3720
- });
3721
- return data.map(OfferOptionAddress.fromDto);
3722
- }
3723
- async function removeOptionAddress(api, offerId, addressId) {
3724
- const dto = await api.send({
3725
- method: "DELETE",
3726
- url: `/v1/offers/${offerId}/addresses/${addressId}`,
3727
- attributes: Attributes.protected()
3728
- });
3729
- return OfferOptionAddress.fromDto(dto);
3730
- }
3731
-
3732
- // src/universal/core/wallets/wallets-namespace.ts
3733
- var WalletsNamespaceImpl = class {
3734
- constructor(ctx) {
3735
- this.ctx = ctx;
3736
- this.log = internalLogger(ctx.logger, "WALLETS");
3737
- }
3738
- async createOwnershipChallenge(params) {
3739
- return this.log.wrap("createOwnershipChallenge", params, async () => {
3740
- await this.ctx.ensureUserAuthenticated();
3741
- return createWalletOwnershipChallenge(
3742
- this.ctx.api,
3743
- params
3744
- );
3745
- });
3746
- }
3747
- async connectExternal(params) {
3748
- return this.log.wrap("connectExternal", params, async () => {
3749
- await this.ctx.ensureUserAuthenticated();
3750
- return connectExternalWallet(this.ctx.api, params);
3751
- });
3752
- }
3753
- async list(params) {
3754
- return this.log.wrap("list", params, async () => {
3755
- await this.ctx.ensureUserAuthenticated();
3756
- return listOptionAddresses(
3757
- this.ctx.api,
3758
- params.offerId,
3759
- params.offerOptionId
3760
- );
3761
- });
3762
- }
3763
- async remove(params) {
3764
- return this.log.wrap("remove", params, async () => {
3765
- await this.ctx.ensureUserAuthenticated();
3766
- return removeOptionAddress(
3767
- this.ctx.api,
3768
- params.offerId,
3769
- params.addressId
3770
- );
3771
- });
3772
- }
3773
- };
3774
-
3775
- // src/universal/types/oauth-session.ts
3776
- var ClientCredentialsOAuth = (value) => value;
3777
- var OAuthRefreshToken = (value) => value;
3778
- var OAuthSession = {
3779
- fromDto: (dto) => {
3780
- const expiresAt = new Date(Date.now() + dto.expires_in * 1e3);
3781
- return {
3782
- accessToken: {
3783
- value: dto.access_token,
3784
- expiresAt
3785
- },
3786
- ...dto.refresh_token != null && dto.refresh_token !== "" ? { refreshToken: OAuthRefreshToken(dto.refresh_token) } : void 0
3787
- };
3788
- }
3789
- };
3790
-
3791
- // src/universal/api/frontline/offers.ts
3792
- async function fetchOffers(api, clientCreds) {
3793
- return fetchAllPages((params) => fetchOffersPage(api, params, clientCreds));
3794
- }
3795
- async function fetchOffersPage(api, params, clientCreds) {
3796
- const queryParams = PaginationParams.toQueryParams(params);
3797
- const pageDto = await api.send({
3798
- method: "GET",
3799
- url: "/v1/offers",
3800
- queryParams,
3801
- attributes: Attributes.concat(
3802
- Attributes.protected(),
3803
- Attributes.clientCredentials(clientCreds)
3804
- )
3805
- });
3806
- return PaginatedResponse.fromDtoPage(pageDto, Offer.listFromDto);
3807
- }
3808
- async function fetchOfferDetails(api, id, clientCreds) {
3809
- const dto = await api.send({
3810
- method: "GET",
3811
- url: `/v1/offers/${id}`,
3812
- attributes: Attributes.concat(
3813
- Attributes.protected(),
3814
- Attributes.clientCredentials(clientCreds)
3815
- )
3816
- });
3817
- return OfferDetail.fromDto(dto);
3818
- }
3819
-
3820
3656
  export {
3821
3657
  sha256,
3822
3658
  arrayBufferToBase64Url,
3823
3659
  generateSecureRandomBase64Url,
3824
3660
  getUUIDv4,
3825
- PUBLIC_API_BASE_URL,
3826
- HEADER_USER_AGENT,
3827
- HEADER_IDEMPOTENCY_KEY,
3828
- API_VERSION,
3829
- COINLIST_BASE_URL,
3830
- OAUTH_PAGE_PATH,
3831
- SUPPORT_NEW_TICKET_URL,
3832
- VERIFY_IDENTITY_PATH,
3833
- VERIFY_IDENTITY_ACCREDITATION_PATH,
3834
- WALLET_PATH,
3835
3661
  SentWith,
3836
3662
  TokenTrigger,
3837
3663
  isRejectedToken,
3838
3664
  Attributes,
3839
3665
  HttpError,
3840
3666
  apiErrorCode,
3841
- Request,
3842
3667
  NotImplementedError,
3843
3668
  NotAuthenticatedError,
3844
3669
  ValidationError,
3845
3670
  InvariantError,
3846
3671
  MathError,
3672
+ classifyLogCause,
3847
3673
  describeErrorUnredacted,
3848
3674
  internalLogger,
3849
- HttpClient,
3850
3675
  EpochMillis,
3851
3676
  Millis,
3852
3677
  Seconds,
3853
3678
  isExpired,
3854
3679
  ERC20_ABI,
3680
+ FormattedAmountUi,
3681
+ FormattedPercentUi,
3682
+ TxExplorerUrl,
3683
+ ShortenedWalletAddress,
3684
+ FormattedAmountAssetUi,
3685
+ AssetIconUrl,
3686
+ viemChain,
3687
+ getChainId,
3688
+ chainFromId,
3689
+ contractOn,
3690
+ getNetworkName,
3691
+ txExplorerUrl,
3855
3692
  ETHEREUM_CHAINS,
3856
3693
  EthereumChain,
3857
3694
  SOLANA_CHAINS,
@@ -3874,17 +3711,30 @@ export {
3874
3711
  KnownAssetSymbol,
3875
3712
  Bps,
3876
3713
  blockchainAmountFromRawOrThrow,
3714
+ positiveAmountFromRawOrThrow,
3715
+ pricePerShare,
3877
3716
  parseBlockchainAmount,
3878
3717
  CentrifugeVaultStatus,
3879
3718
  CentrifugeVaultBuyTransaction,
3880
3719
  CentrifugeVaultClaimTransaction,
3881
- CentrifugeVaultPosition,
3882
- CentrifugeVaultRedeemPosition,
3720
+ CentrifugeAssets,
3721
+ CentrifugeShares,
3722
+ CentrifugeDepositPosition,
3723
+ CentrifugeRedeemPosition,
3883
3724
  CentrifugeVaultLeg,
3884
3725
  CentrifugeVaultLegId,
3885
3726
  CentrifugeVaultClaimProceedsTransaction,
3886
3727
  CentrifugeNamespaceImpl,
3887
- fetchAllPages,
3728
+ shortenAddress,
3729
+ formatAmount,
3730
+ formatRawAmount,
3731
+ formatCompactAmount,
3732
+ formatBpsAsPercent,
3733
+ usdAmount,
3734
+ assetAmount,
3735
+ NA_AMOUNT_ASSET_UI,
3736
+ formatShareAmount,
3737
+ formattedUsdPrice,
3888
3738
  Cursor,
3889
3739
  PaginatedResponse,
3890
3740
  PaginationParams,
@@ -3904,6 +3754,7 @@ export {
3904
3754
  OfferOptionSlug,
3905
3755
  OfferSwapContract,
3906
3756
  OfferVaultContract,
3757
+ OfferFundingContract,
3907
3758
  OfferDetail,
3908
3759
  OfferOption,
3909
3760
  FaqItem,
@@ -3911,33 +3762,10 @@ export {
3911
3762
  TermItem,
3912
3763
  Milestone,
3913
3764
  ParticipationId,
3914
- Blockchain,
3915
- WalletAddress,
3916
3765
  ParticipationsPaginationParams,
3917
3766
  Participation,
3918
3767
  CreateParticipationParams,
3919
3768
  CoinListTokenSaleNamespaceImpl,
3920
- FormattedAmountUi,
3921
- FormattedPercentUi,
3922
- TxExplorerUrl,
3923
- ShortenedWalletAddress,
3924
- FormattedAmountAssetUi,
3925
- AssetIconUrl,
3926
- shortenAddress,
3927
- formatAmount,
3928
- formatRawAmount,
3929
- formatCompactAmount,
3930
- formatBpsAsPercent,
3931
- usdAmount,
3932
- assetAmount,
3933
- NA_AMOUNT_ASSET_UI,
3934
- formatShareAmount,
3935
- formattedUsdPrice,
3936
- viemChain,
3937
- getChainId,
3938
- chainFromId,
3939
- getNetworkName,
3940
- txExplorerUrl,
3941
3769
  OndoTradingStatus,
3942
3770
  OndoQuote,
3943
3771
  OndoBuyTransaction,
@@ -3948,10 +3776,8 @@ export {
3948
3776
  PauseFlags,
3949
3777
  SwapStatus,
3950
3778
  AllowWalletResponse,
3779
+ SwapQuote,
3951
3780
  SuperstateSwapNamespaceImpl,
3952
- fetchOffers,
3953
- fetchOffersPage,
3954
- fetchOfferDetails,
3955
3781
  DocumentSubmission,
3956
3782
  KycToken,
3957
3783
  Iso2CountryCode,
@@ -3963,19 +3789,20 @@ export {
3963
3789
  RequirementStatusInfo,
3964
3790
  fetchOfferRequirements,
3965
3791
  RequirementsNamespaceImpl,
3966
- Erc20NamespaceImpl,
3967
- TokenLogoUrl,
3968
- TokenLogo,
3969
- TokenMetadata,
3970
- TokensNamespaceImpl,
3971
3792
  OfferOptionAddressId,
3972
3793
  OfferOptionAddress,
3973
3794
  ConnectExternalWalletParams,
3974
3795
  WalletOwnershipChallenge,
3975
3796
  CreateWalletOwnershipChallengeParams,
3976
3797
  WalletsNamespaceImpl,
3977
- ClientCredentialsOAuth,
3978
- OAuthRefreshToken,
3979
- OAuthSession
3798
+ fetchOffers,
3799
+ fetchOffersPage,
3800
+ fetchOfferDetails,
3801
+ OffersNamespaceImpl,
3802
+ Erc20NamespaceImpl,
3803
+ TokenLogoUrl,
3804
+ TokenLogo,
3805
+ TokenMetadata,
3806
+ TokensNamespaceImpl
3980
3807
  };
3981
- //# sourceMappingURL=chunk-C6GF7MDF.js.map
3808
+ //# sourceMappingURL=chunk-2FZAXGVH.js.map