@coinlist-co/react 0.12.2-rc.31c2f50 → 0.12.2-rc.3de3751

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-NBO5E2RO.js → chunk-HMLWCXAP.js} +1329 -945
  3. package/dist/chunk-HMLWCXAP.js.map +1 -0
  4. package/dist/{chunk-4IZ2F732.js → chunk-L7SVKXXW.js} +10 -10
  5. package/dist/chunk-L7SVKXXW.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-UJYSXXJF.js → chunk-RLOYYAMO.js} +193 -364
  9. package/dist/chunk-RLOYYAMO.js.map +1 -0
  10. package/dist/client/index.d.ts +3302 -4561
  11. package/dist/client/index.js +9396 -7549
  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-D_XSpiS-.d.ts → time-DkU7jivQ.d.ts} +2179 -2906
  17. package/dist/{token-registry-snapshot-BsAfBL_b.d.ts → token-registry-snapshot-D0OWXMe4.d.ts} +62 -34
  18. package/dist/universal/index.d.ts +84 -1337
  19. package/dist/universal/index.js +39 -47
  20. package/package.json +18 -14
  21. package/dist/chunk-4IZ2F732.js.map +0 -1
  22. package/dist/chunk-NBO5E2RO.js.map +0 -1
  23. package/dist/chunk-UJYSXXJF.js.map +0 -1
  24. package/dist/client/index.cjs +0 -17133
  25. package/dist/client/index.cjs.map +0 -1
  26. package/dist/client/index.d.cts +0 -6671
  27. package/dist/server/index.cjs +0 -4269
  28. package/dist/server/index.cjs.map +0 -1
  29. package/dist/server/index.d.cts +0 -378
  30. package/dist/time-CFocgYyl.d.cts +0 -50
  31. package/dist/time-DvgN98Q9.d.ts +0 -50
  32. package/dist/token-registry-snapshot-Cc_eA5zM.d.cts +0 -181
  33. package/dist/tokens-namespace-D_XSpiS-.d.cts +0 -3436
  34. package/dist/universal/index.cjs +0 -4321
  35. package/dist/universal/index.cjs.map +0 -1
  36. package/dist/universal/index.d.cts +0 -1629
@@ -1,35 +1,28 @@
1
1
  import {
2
2
  AssetDecimals,
3
- AssetSymbol,
4
3
  BlockchainAmount,
5
4
  Bps,
6
5
  DecimalString,
7
- EthereumChain,
6
+ ETHEREUM_CHAINS,
8
7
  EvmContractAddress,
9
- EvmWalletAddress,
10
- HexEncodedTransactionData,
11
8
  InvariantError,
12
9
  MAX_UINT_256,
13
10
  MathError,
14
11
  NA_AMOUNT_ASSET_UI,
15
- SUPERSTATE_SWAP_ABI,
16
12
  StablecoinSymbol,
17
- ValidationError,
18
13
  apiErrorCode,
19
14
  arrayBufferToBase64Url,
20
15
  assertUint256,
21
- blockchainAmountFromRawOrThrow,
22
- dateOrNull,
23
- decimalOrNull,
16
+ contractOn,
24
17
  fetchOfferDetails,
25
18
  fetchOffers,
26
19
  fetchOffersPage,
27
20
  formattedUsdPrice,
28
21
  generateSecureRandomBase64Url,
29
22
  internalLogger,
30
- requiredDate,
23
+ pricePerShare,
31
24
  sha256
32
- } from "./chunk-NBO5E2RO.js";
25
+ } from "./chunk-HMLWCXAP.js";
33
26
 
34
27
  // src/universal/types/oauth.ts
35
28
  var AuthorizationCode = (value) => value;
@@ -57,6 +50,127 @@ async function generatePKCEParams(config) {
57
50
  };
58
51
  }
59
52
 
53
+ // src/universal/types/blockchain/wallet-error.ts
54
+ var RedactedWalletError = {
55
+ fromWalletError: (error) => error.type === "unknown" ? { type: "unknown" } : error
56
+ };
57
+
58
+ // src/universal/core/offers/swap-contracts.ts
59
+ function swapSpender(swapContracts, chain) {
60
+ return contractOn(swapContracts, chain);
61
+ }
62
+
63
+ // src/universal/core/shared/blockchain/bps.ts
64
+ var BPS_DENOM = Bps(10000n);
65
+ function applyBps(amount, bps) {
66
+ return assertUint256(amount * bps / BPS_DENOM);
67
+ }
68
+
69
+ // src/universal/core/providers/checkout/superstate/blockchain/math.ts
70
+ function computePrice({
71
+ inputTokenAmount,
72
+ outputTokenAmount
73
+ }) {
74
+ if (outputTokenAmount.raw === 0n) return null;
75
+ return pricePerShare({ usd: inputTokenAmount, shares: outputTokenAmount });
76
+ }
77
+ function computeSlip(amount, slippage) {
78
+ const retained = Bps(assertUint256(BPS_DENOM - slippage));
79
+ const slipRaw = applyBps(amount.raw, retained);
80
+ return BlockchainAmount({ raw: slipRaw, decimals: amount.decimals });
81
+ }
82
+
83
+ // src/universal/core/providers/checkout/superstate/blockchain/status.ts
84
+ var SWAP_LEVEL = 2;
85
+ function isSwapAvailable(status) {
86
+ switch (status.state) {
87
+ case "active":
88
+ return true;
89
+ case "stopped":
90
+ return false;
91
+ case "paused":
92
+ return (status.pausedLevels & SWAP_LEVEL) === 0;
93
+ default: {
94
+ const _exhaustive = status;
95
+ return _exhaustive;
96
+ }
97
+ }
98
+ }
99
+
100
+ // src/universal/core/offers/offers-namespace.ts
101
+ var OffersNamespaceImpl = class {
102
+ constructor(ctx) {
103
+ this.ctx = ctx;
104
+ this.log = internalLogger(ctx.logger, "OFFERS");
105
+ }
106
+ async list() {
107
+ return this.log.wrap("list", void 0, async () => {
108
+ await this.ctx.ensureUserAuthenticated();
109
+ return fetchOffers(this.ctx.api, void 0);
110
+ });
111
+ }
112
+ async listPage(params) {
113
+ return this.log.wrap("listPage", params, async () => {
114
+ await this.ctx.ensureUserAuthenticated();
115
+ return fetchOffersPage(this.ctx.api, params, void 0);
116
+ });
117
+ }
118
+ async get(id) {
119
+ return this.log.wrap("get", id, async () => {
120
+ await this.ctx.ensureUserAuthenticated();
121
+ return fetchOfferDetails(this.ctx.api, id, void 0);
122
+ });
123
+ }
124
+ };
125
+
126
+ // src/universal/core/tokens/token-registry-snapshot.ts
127
+ var TokenRegistrySnapshot = {
128
+ /** Indexes a `tokens.list()` result. `[]` is a valid, empty snapshot. */
129
+ fromTokens: (tokens) => ({
130
+ tokens,
131
+ byKey: new Map(
132
+ tokens.map((token) => [registryKey(token.identifier), token])
133
+ )
134
+ }),
135
+ /**
136
+ * The registry's entry for one token, or `null` when it lists none. The
137
+ * registry is curated, so `null` is an ordinary answer rather than an
138
+ * error, and callers fall back to their own display defaults.
139
+ */
140
+ get: (snapshot, token) => snapshot.byKey.get(registryKey(token)) ?? null,
141
+ /**
142
+ * The registry's entry for the token an offer is *about*, or `null` when
143
+ * it lists none of them.
144
+ *
145
+ * Resolution follows {@link offerDisplayTokens}: the token a sale
146
+ * distributes or a swap hands over, never the funding token the user pays
147
+ * with. An offer deployed on several chains carries one such token per
148
+ * chain, and the first the registry knows wins - they are the same asset,
149
+ * so any listed one answers for the offer.
150
+ */
151
+ forOffer: (snapshot, offer) => {
152
+ for (const token of offerDisplayTokens(offer)) {
153
+ const metadata = TokenRegistrySnapshot.get(snapshot, token);
154
+ if (metadata !== null) {
155
+ return metadata;
156
+ }
157
+ }
158
+ return null;
159
+ }
160
+ };
161
+ function offerDisplayTokens(offer) {
162
+ const swaps = offer.tokens.filter(
163
+ (token) => token.role === "swap" || token.role === "vault"
164
+ );
165
+ const distributions = offer.tokens.filter(
166
+ (token) => token.role === "distribution"
167
+ );
168
+ return [...swaps, ...distributions];
169
+ }
170
+ function registryKey(token) {
171
+ return `${token.chain}:${token.address.toLowerCase()}`;
172
+ }
173
+
60
174
  // src/universal/core/shared/blockchain/token-registry.ts
61
175
  var USDC_SYMBOL = StablecoinSymbol("USDC");
62
176
  var USDC = {
@@ -120,7 +234,13 @@ var TOKEN_REGISTRY = {
120
234
  usdtAddress: (chain) => USDT_ADDRESSES[chain]
121
235
  };
122
236
 
123
- // src/universal/core/checkout/ondo/constants.ts
237
+ // src/universal/core/providers/checkout/ondo/not-tradable.ts
238
+ var ONDO_NOT_TRADABLE_CODE = "not_tradable";
239
+ function isOndoNotTradableError(error) {
240
+ return apiErrorCode(error) === ONDO_NOT_TRADABLE_CODE;
241
+ }
242
+
243
+ // src/universal/core/providers/checkout/ondo/constants.ts
124
244
  var ONDO_POLL_INTERVAL_MS = 15e3;
125
245
  var ONDO_QUOTE_MAX_TTL_MS = 15e3;
126
246
  var DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE = DecimalString("1000");
@@ -130,7 +250,7 @@ var ONDO_SUPPORTED_INPUT_ASSETS = [
130
250
  USDC_SYMBOL
131
251
  ];
132
252
 
133
- // src/universal/core/checkout/ondo/math.ts
253
+ // src/universal/core/providers/checkout/ondo/math.ts
134
254
  function computeOndoBuyPrice(transaction) {
135
255
  const { notionalValue, receiveOutputAmount } = transaction;
136
256
  return pricePerShare({
@@ -155,110 +275,8 @@ function grossProceeds(expected) {
155
275
  }
156
276
  return BlockchainAmount.add(expected.quantity, expected.fee);
157
277
  }
158
- function pricePerShare({
159
- usd,
160
- shares
161
- }) {
162
- const price = BlockchainAmount.div(usd, shares);
163
- return BlockchainAmount({
164
- raw: assertPriceFits(price.raw),
165
- decimals: price.decimals
166
- });
167
- }
168
- function assertPriceFits(raw) {
169
- try {
170
- return assertUint256(raw);
171
- } catch {
172
- throw new MathError(`Ondo price: out of uint256 bounds (${raw})`);
173
- }
174
- }
175
-
176
- // src/universal/core/checkout/ondo/not-tradable.ts
177
- var ONDO_NOT_TRADABLE_CODE = "not_tradable";
178
- function isOndoNotTradableError(error) {
179
- return apiErrorCode(error) === ONDO_NOT_TRADABLE_CODE;
180
- }
181
-
182
- // src/universal/core/shared/blockchain/bps.ts
183
- var BPS_DENOM = Bps(10000n);
184
- function applyBps(amount, bps) {
185
- return assertUint256(amount * bps / BPS_DENOM);
186
- }
187
278
 
188
- // src/universal/core/checkout/superstate/blockchain/math.ts
189
- function computePrice({
190
- inputTokenAmount,
191
- outputTokenAmount
192
- }) {
193
- if (outputTokenAmount.raw === 0n) return null;
194
- const scale = 10n ** BigInt(outputTokenAmount.decimals);
195
- const raw = assertUint256(
196
- inputTokenAmount.raw * scale / outputTokenAmount.raw
197
- );
198
- return BlockchainAmount({ raw, decimals: inputTokenAmount.decimals });
199
- }
200
- function computeSlip(amount, slippage) {
201
- const retained = Bps(assertUint256(BPS_DENOM - slippage));
202
- const slipRaw = applyBps(amount.raw, retained);
203
- return BlockchainAmount({ raw: slipRaw, decimals: amount.decimals });
204
- }
205
-
206
- // src/universal/core/checkout/superstate/blockchain/quote.ts
207
- var SwapQuote = {
208
- /**
209
- * Assembles a {@link SwapQuote} from a raw contract {@link SwapPreview}. The
210
- * input and fee are denominated in the input token; the output in the output
211
- * token.
212
- */
213
- fromPreview: (preview, inputDecimals, outputDecimals) => ({
214
- inputTokenAmount: BlockchainAmount({
215
- raw: preview.inputAmount,
216
- decimals: inputDecimals
217
- }),
218
- fee: BlockchainAmount({ raw: preview.fee, decimals: inputDecimals }),
219
- outputTokenAmount: BlockchainAmount({
220
- raw: preview.outputAmount,
221
- decimals: outputDecimals
222
- })
223
- })
224
- };
225
-
226
- // src/universal/core/checkout/superstate/blockchain/status.ts
227
- var SWAP_LEVEL = 2;
228
- function isSwapAvailable(status) {
229
- switch (status.state) {
230
- case "active":
231
- return true;
232
- case "stopped":
233
- return false;
234
- case "paused":
235
- return (status.pausedLevels & SWAP_LEVEL) === 0;
236
- default: {
237
- const _exhaustive = status;
238
- return _exhaustive;
239
- }
240
- }
241
- }
242
-
243
- // src/universal/core/checkout/superstate/blockchain/swapped-event.ts
244
- import { parseEventLogs } from "viem";
245
- function decodeSwappedOutputAmount(receipt, outputDecimals) {
246
- try {
247
- const [swapped] = parseEventLogs({
248
- abi: SUPERSTATE_SWAP_ABI,
249
- eventName: "Swapped",
250
- logs: receipt.logs
251
- });
252
- if (!swapped) return null;
253
- const raw = swapped.args.outputAmount;
254
- if (raw < 0n || raw > MAX_UINT_256) return null;
255
- return BlockchainAmount({ raw, decimals: outputDecimals });
256
- } catch {
257
- return null;
258
- }
259
- }
260
-
261
- // src/universal/core/checkout/superstate/constants.ts
279
+ // src/universal/core/providers/checkout/superstate/constants.ts
262
280
  var SUPERSTATE_ISSUER_NAME = "Superstate";
263
281
  var SUPERSTATE_SUPPORTED_INPUT_ASSETS = [USDC_SYMBOL];
264
282
  var SWAP_POLL_INTERVAL_MS = 15e3;
@@ -275,246 +293,68 @@ function superstateSwapContractAddress(chain) {
275
293
  return SUPERSTATE_SWAP_CONTRACT_ADDRESSES[chain] ?? null;
276
294
  }
277
295
 
278
- // src/universal/core/checkout/superstate/formatters.ts
296
+ // src/universal/core/providers/checkout/superstate/formatters.ts
279
297
  function formattedPricePerShare(quote, locale) {
280
298
  if (!quote) return NA_AMOUNT_ASSET_UI;
281
299
  return formattedUsdPrice(computePrice(quote), locale);
282
300
  }
283
301
 
284
- // src/universal/core/offers/offers-namespace.ts
285
- var OffersNamespaceImpl = class {
286
- constructor(ctx) {
287
- this.ctx = ctx;
288
- this.log = internalLogger(ctx.logger, "OFFERS");
289
- }
290
- async list() {
291
- return this.log.wrap("list", void 0, async () => {
292
- await this.ctx.ensureUserAuthenticated();
293
- return fetchOffers(this.ctx.api, void 0);
294
- });
295
- }
296
- async listPage(params) {
297
- return this.log.wrap("listPage", params, async () => {
298
- await this.ctx.ensureUserAuthenticated();
299
- return fetchOffersPage(this.ctx.api, params, void 0);
300
- });
301
- }
302
- async get(id) {
303
- return this.log.wrap("get", id, async () => {
304
- await this.ctx.ensureUserAuthenticated();
305
- return fetchOfferDetails(this.ctx.api, id, void 0);
306
- });
307
- }
308
- };
309
-
310
- // src/universal/core/offers/swap-contracts.ts
311
- function swapSpender(swapContracts, chain) {
312
- return swapContracts.find((contract) => contract.chain === chain)?.address ?? null;
313
- }
314
-
315
- // src/universal/core/tokens/token-registry-snapshot.ts
316
- var TokenRegistrySnapshot = {
317
- /** Indexes a `tokens.list()` result. `[]` is a valid, empty snapshot. */
318
- fromTokens: (tokens) => ({
319
- tokens,
320
- byKey: new Map(
321
- tokens.map((token) => [registryKey(token.identifier), token])
322
- )
323
- }),
302
+ // src/universal/types/blockchain/wallet-selection.ts
303
+ var WalletSelection = {
324
304
  /**
325
- * The registry's entry for one token, or `null` when it lists none. The
326
- * registry is curated, so `null` is an ordinary answer rather than an
327
- * error, and callers fall back to their own display defaults.
305
+ * Every wallet in display order - embedded first, then the external one -
306
+ * each address once. Addresses compare case-insensitively, so a host that
307
+ * hands the same wallet over as both embedded and external sees it once.
328
308
  */
329
- get: (snapshot, token) => snapshot.byKey.get(registryKey(token)) ?? null,
330
- /**
331
- * The registry's entry for the token an offer is *about*, or `null` when
332
- * it lists none of them.
333
- *
334
- * Resolution follows {@link offerDisplayTokens}: the token a sale
335
- * distributes or a swap hands over, never the funding token the user pays
336
- * with. An offer deployed on several chains carries one such token per
337
- * chain, and the first the registry knows wins - they are the same asset,
338
- * so any listed one answers for the offer.
339
- */
340
- forOffer: (snapshot, offer) => {
341
- for (const token of offerDisplayTokens(offer)) {
342
- const metadata = TokenRegistrySnapshot.get(snapshot, token);
343
- if (metadata !== null) {
344
- return metadata;
345
- }
346
- }
347
- return null;
309
+ all: (selection) => {
310
+ const seen = /* @__PURE__ */ new Set();
311
+ return [
312
+ ...selection.embedded,
313
+ ...selection.external === null ? [] : [selection.external]
314
+ ].filter((wallet) => {
315
+ const key = wallet.address.toLowerCase();
316
+ if (seen.has(key)) return false;
317
+ seen.add(key);
318
+ return true;
319
+ });
348
320
  }
349
321
  };
350
- function offerDisplayTokens(offer) {
351
- const swaps = offer.tokens.filter(
352
- (token) => token.role === "swap" || token.role === "vault"
353
- );
354
- const distributions = offer.tokens.filter(
355
- (token) => token.role === "distribution"
356
- );
357
- return [...swaps, ...distributions];
358
- }
359
- function registryKey(token) {
360
- return `${token.chain}:${token.address.toLowerCase()}`;
361
- }
362
-
363
- // src/universal/types/blockchain/wallet-error.ts
364
- var RedactedWalletError = {
365
- fromWalletError: (error) => error.type === "unknown" ? { type: "unknown" } : error
366
- };
367
322
 
368
- // src/universal/types/providers/centrifuge/centrifuge.ts
369
- var CentrifugeVaultQuote = {
370
- fromDto: (dto) => {
371
- const spendDecimals = AssetDecimals(dto.spend_input_decimals);
372
- const shareDecimals = AssetDecimals(dto.share_decimals);
373
- return {
374
- chain: EthereumChain(dto.chain),
375
- symbol: AssetSymbol(dto.symbol),
376
- spendInputAmount: blockchainAmountFromRawOrThrow({
377
- label: "spend_input_amount",
378
- raw: dto.spend_input_amount,
379
- decimals: spendDecimals
380
- }),
381
- estimatedShares: blockchainAmountFromRawOrThrow({
382
- label: "estimated_shares",
383
- raw: dto.estimated_shares,
384
- decimals: shareDecimals
385
- }),
386
- indicativePrice: decimalOrNull(dto.indicative_price),
387
- minimumInputAmount: dto.minimum_input_amount === null ? null : blockchainAmountFromRawOrThrow({
388
- label: "minimum_input_amount",
389
- raw: dto.minimum_input_amount,
390
- decimals: spendDecimals
391
- }),
392
- orderability: parseOrderability(
393
- dto.can_order,
394
- dto.reasons,
395
- "CentrifugeVaultQuote"
396
- )
397
- };
398
- }
399
- };
400
- var CentrifugeVaultStatus = {
401
- fromDto: (dto) => ({
402
- chain: EthereumChain(dto.chain),
403
- symbol: AssetSymbol(dto.symbol),
404
- vaultAddress: EvmContractAddress(dto.vault_address),
405
- linked: dto.linked,
406
- permissioned: dto.permissioned,
407
- membershipValidUntil: dateOrNull(
408
- dto.membership_valid_until,
409
- "CentrifugeVaultStatus.membership_valid_until"
410
- ),
411
- halted: dto.halted,
412
- priceUpdatedAt: dateOrNull(
413
- dto.price_updated_at,
414
- "CentrifugeVaultStatus.price_updated_at"
415
- ),
416
- orderability: parseOrderability(
417
- dto.can_order,
418
- dto.reasons,
419
- "CentrifugeVaultStatus"
420
- ),
421
- asOf: requiredDate(dto.as_of, "CentrifugeVaultStatus.as_of")
422
- })
423
- };
424
- var CentrifugeVaultBuyTransaction = {
425
- fromDto: (dto) => {
426
- const spendInputAmount = blockchainAmountFromRawOrThrow({
427
- label: "spend_input_amount",
428
- raw: dto.spend_input_amount,
429
- decimals: AssetDecimals(dto.spend_input_decimals)
430
- });
431
- if (spendInputAmount.raw <= 0n) {
432
- throw new ValidationError(
433
- `spend_input_amount: must be greater than zero ("${dto.spend_input_amount}") - a deposit of nothing is not a request`
434
- );
323
+ // src/universal/core/providers/checkout/centrifuge/vaults.ts
324
+ function resolveCentrifugeVaults(offer, lookup) {
325
+ return offer.vaultContracts.map((contract) => {
326
+ const { chain } = contract;
327
+ if (!isEthereumChain(chain)) {
328
+ return { type: "unresolved", chain, missing: "evm-chain" };
329
+ }
330
+ const onChain = (role) => offer.tokens.filter(
331
+ (token) => token.role === role && token.chain === chain
332
+ );
333
+ const share = firstKnown(onChain("vault"), lookup);
334
+ if (share === null) {
335
+ return { type: "unresolved", chain, missing: "share-token" };
336
+ }
337
+ const funding = firstKnown(onChain("funding"), lookup);
338
+ if (funding === null) {
339
+ return { type: "unresolved", chain, missing: "funding-token" };
435
340
  }
436
341
  return {
437
- ...parseTransactionCore(dto, "CentrifugeVaultBuyTransaction"),
438
- spendInputAmount,
439
- estimatedShares: blockchainAmountFromRawOrThrow({
440
- label: "estimated_shares",
441
- raw: dto.estimated_shares,
442
- decimals: AssetDecimals(dto.share_decimals)
443
- })
444
- };
445
- }
446
- };
447
- var CentrifugeVaultClaimTransaction = {
448
- fromDto: (dto) => ({
449
- ...parseTransactionCore(dto, "CentrifugeVaultClaimTransaction"),
450
- claimableShares: blockchainAmountFromRawOrThrow({
451
- label: "claimable_shares",
452
- raw: dto.claimable_shares,
453
- decimals: AssetDecimals(dto.share_decimals)
454
- })
455
- })
456
- };
457
- var CentrifugeVaultPosition = {
458
- fromDto: (dto) => {
459
- const assetDecimals = AssetDecimals(dto.asset_decimals);
460
- const shareDecimals = AssetDecimals(dto.share_decimals);
461
- const asset = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: assetDecimals });
462
- const shares = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: shareDecimals });
463
- return {
464
- chain: EthereumChain(dto.chain),
465
- symbol: AssetSymbol(dto.symbol),
466
- walletAddress: EvmWalletAddress(dto.wallet_address),
467
- status: dto.status,
468
- requested: asset("requested", dto.requested),
469
- pending: asset("pending", dto.pending),
470
- filledAssets: asset("filled_assets", dto.filled_assets),
471
- earnedShares: shares("earned_shares", dto.earned_shares),
472
- claimedShares: shares("claimed_shares", dto.claimed_shares),
473
- claimableShares: shares("claimable_shares", dto.claimable_shares),
474
- shareBalance: shares("share_balance", dto.share_balance),
475
- averagePrice: decimalOrNull(dto.average_price),
476
- frozen: dto.frozen,
477
- asOf: requiredDate(dto.as_of, "CentrifugeVaultPosition.as_of")
342
+ type: "resolved",
343
+ vault: { chain, proxy: contract.address, share, funding }
478
344
  };
345
+ });
346
+ }
347
+ function firstKnown(tokens, lookup) {
348
+ for (const token of tokens) {
349
+ const metadata = lookup(token);
350
+ if (metadata !== null) return metadata;
479
351
  }
480
- };
481
- function parseOrderability(canOrder, reasons, model) {
482
- const [first, ...rest] = reasons;
483
- if (canOrder) {
484
- if (first !== void 0) {
485
- throw new ValidationError(
486
- `${model}.reasons: expected none when can_order is true, got ${JSON.stringify(reasons)}`
487
- );
488
- }
489
- return { type: "orderable" };
490
- }
491
- if (first === void 0) {
492
- throw new ValidationError(
493
- `${model}.reasons: expected at least one when can_order is false`
494
- );
495
- }
496
- return { type: "blocked", reasons: [first, ...rest] };
352
+ return null;
497
353
  }
498
- function parseTransactionCore(dto, model) {
499
- return {
500
- tx: {
501
- to: EvmContractAddress(dto.to),
502
- data: HexEncodedTransactionData(dto.data)
503
- },
504
- expiresAt: dateOrNull(dto.expires_at, `${model}.expires_at`)
505
- };
354
+ function isEthereumChain(chain) {
355
+ return chain in ETHEREUM_CHAINS;
506
356
  }
507
357
 
508
- // src/universal/types/user.ts
509
- var UserId = (value) => value;
510
- var UserEmail = (value) => value;
511
- var User = {
512
- fromDto: (dto) => ({
513
- id: UserId(dto.id),
514
- email: UserEmail(dto.email)
515
- })
516
- };
517
-
518
358
  export {
519
359
  AuthorizationCode,
520
360
  CodeVerifier,
@@ -524,30 +364,30 @@ export {
524
364
  ClientId,
525
365
  ClientSecret,
526
366
  generatePKCEParams,
367
+ RedactedWalletError,
368
+ swapSpender,
369
+ computePrice,
370
+ computeSlip,
371
+ SWAP_LEVEL,
372
+ isSwapAvailable,
373
+ OffersNamespaceImpl,
374
+ TokenRegistrySnapshot,
375
+ offerDisplayTokens,
527
376
  USDC_SYMBOL,
528
377
  USDC,
529
378
  USDT_SYMBOL,
530
379
  USDT,
531
380
  TOKEN_REGISTRY,
532
381
  ONDO_POLL_INTERVAL_MS,
533
- ONDO_QUOTE_MAX_TTL_MS,
534
382
  DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE,
535
383
  ONDO_SETTLEMENT_ASSET,
536
384
  DEFAULT_ONDO_SELL_TOKENS_TO_COMPUTE_PRICE,
537
385
  ONDO_SUPPORTED_INPUT_ASSETS,
386
+ ONDO_NOT_TRADABLE_CODE,
387
+ isOndoNotTradableError,
538
388
  computeOndoBuyPrice,
539
389
  computeOndoSellPrice,
540
390
  ondoQuoteOfferDeadline,
541
- ONDO_NOT_TRADABLE_CODE,
542
- isOndoNotTradableError,
543
- BPS_DENOM,
544
- applyBps,
545
- computePrice,
546
- computeSlip,
547
- SwapQuote,
548
- SWAP_LEVEL,
549
- isSwapAvailable,
550
- decodeSwappedOutputAmount,
551
391
  SUPERSTATE_ISSUER_NAME,
552
392
  SUPERSTATE_SUPPORTED_INPUT_ASSETS,
553
393
  SWAP_POLL_INTERVAL_MS,
@@ -557,18 +397,7 @@ export {
557
397
  SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA,
558
398
  superstateSwapContractAddress,
559
399
  formattedPricePerShare,
560
- OffersNamespaceImpl,
561
- swapSpender,
562
- TokenRegistrySnapshot,
563
- offerDisplayTokens,
564
- RedactedWalletError,
565
- CentrifugeVaultQuote,
566
- CentrifugeVaultStatus,
567
- CentrifugeVaultBuyTransaction,
568
- CentrifugeVaultClaimTransaction,
569
- CentrifugeVaultPosition,
570
- UserId,
571
- UserEmail,
572
- User
400
+ WalletSelection,
401
+ resolveCentrifugeVaults
573
402
  };
574
- //# sourceMappingURL=chunk-UJYSXXJF.js.map
403
+ //# sourceMappingURL=chunk-RLOYYAMO.js.map