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

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 (33) hide show
  1. package/README.md +10 -0
  2. package/dist/{chunk-45LAPB7U.js → chunk-3WW5FLT7.js} +2 -2
  3. package/dist/{chunk-HDJEDOS4.js → chunk-C6GF7MDF.js} +759 -412
  4. package/dist/chunk-C6GF7MDF.js.map +1 -0
  5. package/dist/{chunk-M7WDZZPX.js → chunk-IZJ4JSSC.js} +69 -4
  6. package/dist/chunk-IZJ4JSSC.js.map +1 -0
  7. package/dist/client/index.cjs +11305 -7943
  8. package/dist/client/index.cjs.map +1 -1
  9. package/dist/client/index.d.cts +1545 -10
  10. package/dist/client/index.d.ts +1545 -10
  11. package/dist/client/index.js +7725 -4781
  12. package/dist/client/index.js.map +1 -1
  13. package/dist/server/index.cjs +347 -62
  14. package/dist/server/index.cjs.map +1 -1
  15. package/dist/server/index.d.cts +6 -2
  16. package/dist/server/index.d.ts +6 -2
  17. package/dist/server/index.js +4 -2
  18. package/dist/server/index.js.map +1 -1
  19. package/dist/{tokens-namespace-DrwRi0AQ.d.cts → time-CVZpAkGY.d.cts} +815 -192
  20. package/dist/{tokens-namespace-DrwRi0AQ.d.ts → time-CVZpAkGY.d.ts} +815 -192
  21. package/dist/{token-registry-snapshot-C-Qs3Lgs.d.ts → token-registry-snapshot-BkwA8KmD.d.ts} +74 -8
  22. package/dist/{token-registry-snapshot-CpzLmsc2.d.cts → token-registry-snapshot-bR14QehS.d.cts} +74 -8
  23. package/dist/universal/index.cjs +812 -385
  24. package/dist/universal/index.cjs.map +1 -1
  25. package/dist/universal/index.d.cts +54 -6
  26. package/dist/universal/index.d.ts +54 -6
  27. package/dist/universal/index.js +30 -2
  28. package/package.json +1 -1
  29. package/dist/chunk-HDJEDOS4.js.map +0 -1
  30. package/dist/chunk-M7WDZZPX.js.map +0 -1
  31. package/dist/time-BOCS1TbH.d.cts +0 -50
  32. package/dist/time-C7mhO5_a.d.ts +0 -50
  33. /package/dist/{chunk-45LAPB7U.js.map → chunk-3WW5FLT7.js.map} +0 -0
@@ -27,11 +27,22 @@ __export(universal_exports, {
27
27
  AssetIconUrl: () => AssetIconUrl,
28
28
  AssetId: () => AssetId,
29
29
  AssetSymbol: () => AssetSymbol,
30
+ AsyncOfferDetail: () => AsyncOfferDetail,
30
31
  AuthorizationCode: () => AuthorizationCode,
31
32
  BPS_DENOM: () => BPS_DENOM,
32
33
  Blockchain: () => Blockchain,
33
34
  BlockchainAmount: () => BlockchainAmount,
34
35
  Bps: () => Bps,
36
+ CENTRIFUGE_POLL_INTERVAL_MS: () => CENTRIFUGE_POLL_INTERVAL_MS,
37
+ CentrifugeNamespaceImpl: () => CentrifugeNamespaceImpl,
38
+ CentrifugeVaultBuyTransaction: () => CentrifugeVaultBuyTransaction,
39
+ CentrifugeVaultClaimProceedsTransaction: () => CentrifugeVaultClaimProceedsTransaction,
40
+ CentrifugeVaultClaimTransaction: () => CentrifugeVaultClaimTransaction,
41
+ CentrifugeVaultLeg: () => CentrifugeVaultLeg,
42
+ CentrifugeVaultLegId: () => CentrifugeVaultLegId,
43
+ CentrifugeVaultPosition: () => CentrifugeVaultPosition,
44
+ CentrifugeVaultRedeemPosition: () => CentrifugeVaultRedeemPosition,
45
+ CentrifugeVaultStatus: () => CentrifugeVaultStatus,
35
46
  Chain: () => Chain,
36
47
  ClientCredentialsOAuth: () => ClientCredentialsOAuth,
37
48
  ClientId: () => ClientId,
@@ -95,6 +106,7 @@ __export(universal_exports, {
95
106
  OfferSlug: () => OfferSlug,
96
107
  OfferSwapContract: () => OfferSwapContract,
97
108
  OfferToken: () => OfferToken,
109
+ OfferVaultContract: () => OfferVaultContract,
98
110
  OffersNamespaceImpl: () => OffersNamespaceImpl,
99
111
  OndoBuyTransaction: () => OndoBuyTransaction,
100
112
  OndoNamespaceImpl: () => OndoNamespaceImpl,
@@ -153,6 +165,7 @@ __export(universal_exports, {
153
165
  ValidationError: () => ValidationError,
154
166
  WalletAddress: () => WalletAddress,
155
167
  WalletOwnershipChallenge: () => WalletOwnershipChallenge,
168
+ WalletSelection: () => WalletSelection,
156
169
  WalletsNamespaceImpl: () => WalletsNamespaceImpl,
157
170
  apiErrorCode: () => apiErrorCode,
158
171
  applyBps: () => applyBps,
@@ -185,6 +198,7 @@ __export(universal_exports, {
185
198
  ondoQuoteOfferDeadline: () => ondoQuoteOfferDeadline,
186
199
  parseBlockchainAmount: () => parseBlockchainAmount,
187
200
  parseUint256: () => parseUint256,
201
+ resolveCentrifugeVaults: () => resolveCentrifugeVaults,
188
202
  shortenAddress: () => shortenAddress,
189
203
  superstateSwapContractAddress: () => superstateSwapContractAddress,
190
204
  swapSpender: () => swapSpender,
@@ -456,50 +470,6 @@ async function generatePKCEParams(config) {
456
470
  };
457
471
  }
458
472
 
459
- // src/universal/types/pagination.ts
460
- var Cursor = (value) => value;
461
- var PaginatedResponse = {
462
- fromDto: (dto, itemMapper) => PaginatedResponse.fromDtoPage(dto, (items) => items.map(itemMapper)),
463
- /**
464
- * For a mapper that decides the page as a whole - one that drops items it
465
- * cannot map, such as `Offer.listFromDto` - rather than item by item. The
466
- * cursors are the wire's either way: dropping an item changes what the
467
- * page holds, not where the next page starts.
468
- */
469
- fromDtoPage: (dto, pageMapper) => ({
470
- data: pageMapper(dto.data),
471
- startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
472
- startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
473
- })
474
- };
475
- var PaginationParams = {
476
- toQueryParams: (params) => {
477
- const queryParams = {};
478
- if (params.after) {
479
- queryParams.starting_after = params.after;
480
- }
481
- if (params.before) {
482
- queryParams.starting_before = params.before;
483
- }
484
- if (params.limit) {
485
- queryParams.limit = params.limit;
486
- }
487
- return queryParams;
488
- }
489
- };
490
-
491
- // src/universal/types/asset.ts
492
- var AssetId = (value) => value;
493
- var AssetCode = (value) => value;
494
- var Asset = {
495
- fromDto: (dto) => ({
496
- id: AssetId(dto.id),
497
- code: AssetCode(dto.code),
498
- name: dto.name,
499
- fractionalDigits: dto.fractional_digits
500
- })
501
- };
502
-
503
473
  // src/universal/types/errors.ts
504
474
  var NotImplementedError = class extends Error {
505
475
  constructor(message = "Not implemented yet") {
@@ -532,39 +502,8 @@ var MathError = class extends Error {
532
502
  }
533
503
  };
534
504
 
535
- // src/universal/core/shared/utils/wire.ts
536
- function unknownTypeError(dto, model) {
537
- const type = dto.type;
538
- throw new ValidationError(
539
- `${model}.type: unknown type ${JSON.stringify(type)}`
540
- );
541
- }
542
- function requiredString(value, field) {
543
- const text = notBlankStringOrNull(value);
544
- if (text === null) {
545
- throw new ValidationError(
546
- `${field}: expected a non-blank string, got ${typeof value === "string" ? "a blank string" : String(value)}`
547
- );
548
- }
549
- return text;
550
- }
551
- function requiredDate(value, field) {
552
- const date = typeof value === "string" ? new Date(value) : null;
553
- if (date === null || Number.isNaN(date.getTime())) {
554
- throw new ValidationError(
555
- `${field}: expected a date, got ${JSON.stringify(value)}`
556
- );
557
- }
558
- return date;
559
- }
560
- function requiredArray(value, field) {
561
- if (!Array.isArray(value)) {
562
- throw new ValidationError(
563
- `${field}: expected an array, got ${typeof value}`
564
- );
565
- }
566
- return value;
567
- }
505
+ // src/universal/core/shared/blockchain/math.ts
506
+ var import_viem = require("viem");
568
507
 
569
508
  // src/universal/types/blockchain/core.ts
570
509
  var ETHEREUM_CHAINS = {
@@ -663,77 +602,714 @@ var StablecoinSymbol = (value) => value;
663
602
  var KnownAssetSymbol = StablecoinSymbol;
664
603
  var Bps = (value) => value;
665
604
 
666
- // src/universal/types/offer.ts
667
- var OfferId = (value) => value;
668
- var OfferSlug = (value) => value;
669
- var OFFER_TYPES = {
670
- "coinlist::token_sale": true,
671
- "superstate::swap": true,
672
- "ondo::swap": true
605
+ // src/universal/core/shared/blockchain/math.ts
606
+ function blockchainAmountFromRawOrThrow({
607
+ label,
608
+ raw,
609
+ decimals
610
+ }) {
611
+ const trimmed = raw.trim();
612
+ if (trimmed === "") {
613
+ throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
614
+ }
615
+ let value;
616
+ try {
617
+ value = BigInt(trimmed);
618
+ } catch {
619
+ throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
620
+ }
621
+ try {
622
+ return BlockchainAmount({ raw: assertUint256(value), decimals });
623
+ } catch {
624
+ throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
625
+ }
626
+ }
627
+ function parseBlockchainAmount(amount, decimals) {
628
+ const trimmed = amount.trim();
629
+ if (trimmed === "") return { valid: false, reason: { type: "empty" } };
630
+ if (trimmed.startsWith("-")) {
631
+ return { valid: false, reason: { type: "negative" } };
632
+ }
633
+ if (/[eE]/.test(trimmed)) {
634
+ return { valid: false, reason: { type: "invalid-format" } };
635
+ }
636
+ if (trimmed === ".") {
637
+ return { valid: false, reason: { type: "invalid-format" } };
638
+ }
639
+ const normalised = trimmed.replace(/^\./, "0.").replace(/\.$/, "");
640
+ if (!/^\d+(\.\d+)?$/.test(normalised)) {
641
+ return { valid: false, reason: { type: "invalid-format" } };
642
+ }
643
+ const [, fraction = ""] = normalised.split(".");
644
+ if (fraction.length > decimals) {
645
+ return {
646
+ valid: false,
647
+ reason: { type: "too-many-decimals", maxDecimals: decimals }
648
+ };
649
+ }
650
+ try {
651
+ const raw = (0, import_viem.parseUnits)(normalised, decimals);
652
+ if (raw > MAX_UINT_256) {
653
+ return { valid: false, reason: { type: "overflow" } };
654
+ }
655
+ return {
656
+ valid: true,
657
+ amount: BlockchainAmount({ raw, decimals })
658
+ };
659
+ } catch {
660
+ return { valid: false, reason: { type: "invalid-format" } };
661
+ }
662
+ }
663
+
664
+ // src/universal/core/shared/utils/wire.ts
665
+ function unknownTypeError(dto, model) {
666
+ const type = dto.type;
667
+ throw new ValidationError(
668
+ `${model}.type: unknown type ${JSON.stringify(type)}`
669
+ );
670
+ }
671
+ function requiredString(value, field) {
672
+ const text = notBlankStringOrNull(value);
673
+ if (text === null) {
674
+ throw new ValidationError(
675
+ `${field}: expected a non-blank string, got ${typeof value === "string" ? "a blank string" : String(value)}`
676
+ );
677
+ }
678
+ return text;
679
+ }
680
+ function requiredDate(value, field) {
681
+ const date = typeof value === "string" ? new Date(value) : null;
682
+ if (date === null || Number.isNaN(date.getTime())) {
683
+ throw new ValidationError(
684
+ `${field}: expected a date, got ${JSON.stringify(value)}`
685
+ );
686
+ }
687
+ return date;
688
+ }
689
+ function dateOrNull(value, field) {
690
+ return value === null ? null : requiredDate(value, field);
691
+ }
692
+ function decimalOrNull(value) {
693
+ return value === null ? null : DecimalString(value);
694
+ }
695
+ function requiredArray(value, field) {
696
+ if (!Array.isArray(value)) {
697
+ throw new ValidationError(
698
+ `${field}: expected an array, got ${typeof value}`
699
+ );
700
+ }
701
+ return value;
702
+ }
703
+
704
+ // src/universal/types/providers/centrifuge/centrifuge.ts
705
+ var CentrifugeVaultStatus = {
706
+ fromDto: (dto) => ({
707
+ chain: EthereumChain(dto.chain),
708
+ symbol: AssetSymbol(dto.symbol),
709
+ vaultAddress: EvmContractAddress(dto.vault_address),
710
+ linked: dto.linked,
711
+ permissioned: dto.permissioned,
712
+ membershipValidUntil: dateOrNull(
713
+ dto.membership_valid_until,
714
+ "CentrifugeVaultStatus.membership_valid_until"
715
+ ),
716
+ halted: dto.halted,
717
+ priceUpdatedAt: dateOrNull(
718
+ dto.price_updated_at,
719
+ "CentrifugeVaultStatus.price_updated_at"
720
+ ),
721
+ orderability: parseOrderability(
722
+ dto.can_order,
723
+ dto.reasons,
724
+ "CentrifugeVaultStatus"
725
+ ),
726
+ asOf: requiredDate(dto.as_of, "CentrifugeVaultStatus.as_of")
727
+ })
673
728
  };
674
- var isOfferType = (value) => Object.keys(OFFER_TYPES).includes(value);
675
- var OfferEditorial = {
676
- /**
677
- * `model` prefixes the field in the error (`'Offer'`, `'OfferDetail'`), so
678
- * the same three checks name the payload that failed them.
679
- */
680
- fromDto: (dto, model) => ({
681
- tagline: requiredString(dto.tagline, `${model}.tagline`),
682
- bannerUrl: requiredString(dto.banner_url, `${model}.banner_url`),
683
- startsAt: requiredDate(dto.starts_at, `${model}.starts_at`)
729
+ var CentrifugeVaultBuyTransaction = {
730
+ fromDto: (dto) => {
731
+ const spendInputAmount = blockchainAmountFromRawOrThrow({
732
+ label: "spend_input_amount",
733
+ raw: dto.spend_input_amount,
734
+ decimals: AssetDecimals(dto.spend_input_decimals)
735
+ });
736
+ if (spendInputAmount.raw <= 0n) {
737
+ throw new ValidationError(
738
+ `spend_input_amount: must be greater than zero ("${dto.spend_input_amount}") - a deposit of nothing is not a request`
739
+ );
740
+ }
741
+ return {
742
+ ...parseTransactionCore(dto, "CentrifugeVaultBuyTransaction"),
743
+ spendInputAmount
744
+ };
745
+ }
746
+ };
747
+ var CentrifugeVaultClaimTransaction = {
748
+ fromDto: (dto) => ({
749
+ ...parseTransactionCore(dto, "CentrifugeVaultClaimTransaction"),
750
+ claimableShares: blockchainAmountFromRawOrThrow({
751
+ label: "claimable_shares",
752
+ raw: dto.claimable_shares,
753
+ decimals: AssetDecimals(dto.share_decimals)
754
+ })
684
755
  })
685
756
  };
686
- var Offer = {
757
+ var CentrifugeVaultPosition = {
687
758
  fromDto: (dto) => {
688
- const tokens = requiredArray(dto.tokens, "Offer.tokens");
689
- const base2 = {
690
- id: OfferId(dto.id),
691
- slug: OfferSlug(dto.slug),
692
- endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
693
- tokens: OfferToken.listFromDto(tokens)
759
+ const assetDecimals = AssetDecimals(dto.asset_decimals);
760
+ const shareDecimals = AssetDecimals(dto.share_decimals);
761
+ const asset = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: assetDecimals });
762
+ const shares = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: shareDecimals });
763
+ return {
764
+ chain: EthereumChain(dto.chain),
765
+ symbol: AssetSymbol(dto.symbol),
766
+ walletAddress: EvmWalletAddress(dto.wallet_address),
767
+ status: dto.status,
768
+ requested: asset("requested", dto.requested),
769
+ pending: asset("pending", dto.pending),
770
+ filledAssets: asset("filled_assets", dto.filled_assets),
771
+ earnedShares: shares("earned_shares", dto.earned_shares),
772
+ claimedShares: shares("claimed_shares", dto.claimed_shares),
773
+ claimableShares: shares("claimable_shares", dto.claimable_shares),
774
+ shareBalance: shares("share_balance", dto.share_balance),
775
+ averagePrice: decimalOrNull(dto.average_price),
776
+ frozen: dto.frozen,
777
+ asOf: requiredDate(dto.as_of, "CentrifugeVaultPosition.as_of")
694
778
  };
695
- switch (dto.type) {
696
- case "coinlist::token_sale":
697
- return {
698
- ...base2,
699
- ...OfferEditorial.fromDto(dto, "Offer"),
700
- type: dto.type,
701
- logoUrl: requiredString(dto.logo_url, "Offer.logo_url")
702
- };
703
- case "superstate::swap":
704
- return {
705
- ...base2,
706
- ...OfferEditorial.fromDto(dto, "Offer"),
707
- type: dto.type,
708
- logoUrl: notBlankStringOrNull(dto.logo_url)
709
- };
710
- // `tagline`, `banner_url` and `starts_at` arrive as `null` and are left
711
- // on the wire: copying them would hand every consumer a `startsAt` that
712
- // is 1970 for one variant and a date for the others.
713
- case "ondo::swap":
714
- return {
715
- ...base2,
716
- type: dto.type,
717
- logoUrl: notBlankStringOrNull(dto.logo_url)
718
- };
719
- default:
720
- return unknownTypeError(dto, "Offer");
721
- }
722
- },
723
- /**
724
- * Maps a page of offers, dropping every offer whose `type` this SDK does not
725
- * name. The same reasoning as {@link OfferToken.listFromDto}: a plain `.map`
726
- * would throw out of `fromDto` and, through `PaginatedResponse.fromDto`,
727
- * reject the whole page, so one offer of an unknown type would blank the
728
- * grid for every offer beside it. A single offer fetched by id still
729
- * throws, because there is nothing beside it to keep.
730
- */
731
- listFromDto: (dtos) => dtos.filter((dto) => isOfferType(dto.type)).map(Offer.fromDto)
779
+ }
732
780
  };
733
- var OfferToken = {
781
+ var CentrifugeVaultRedeemPosition = {
734
782
  fromDto: (dto) => ({
735
- role: dto.role,
736
- chain: Chain(dto.chain),
783
+ chain: EthereumChain(dto.chain),
784
+ symbol: AssetSymbol(dto.symbol),
785
+ walletAddress: EvmWalletAddress(dto.wallet_address),
786
+ status: dto.status,
787
+ pending: blockchainAmountFromRawOrThrow({
788
+ label: "pending",
789
+ raw: dto.pending,
790
+ decimals: AssetDecimals(dto.share_decimals)
791
+ }),
792
+ claimableAssets: blockchainAmountFromRawOrThrow({
793
+ label: "claimable_assets",
794
+ raw: dto.claimable_assets,
795
+ decimals: AssetDecimals(dto.asset_decimals)
796
+ }),
797
+ frozen: dto.frozen,
798
+ asOf: requiredDate(dto.as_of, "CentrifugeVaultRedeemPosition.as_of")
799
+ })
800
+ };
801
+ var CentrifugeVaultLeg = {
802
+ /**
803
+ * What a claim on the leg would collect: shares for `invest`, the funding
804
+ * token for `redeem`.
805
+ */
806
+ claimable: (leg) => {
807
+ switch (leg.direction) {
808
+ case "invest":
809
+ return leg.position.claimableShares;
810
+ case "redeem":
811
+ return leg.position.claimableAssets;
812
+ default: {
813
+ const exhaustive = leg;
814
+ return exhaustive;
815
+ }
816
+ }
817
+ },
818
+ /** Whether the leg has anything queued or anything ready to claim. */
819
+ isActive: (leg) => leg.position.pending.raw > 0n || CentrifugeVaultLeg.claimable(leg).raw > 0n
820
+ };
821
+ var CentrifugeVaultLegId = {
822
+ /** Addresses compare case-insensitively: frontline echoes them lower case. */
823
+ of: (leg) => [
824
+ leg.direction,
825
+ leg.position.chain,
826
+ leg.position.walletAddress.toLowerCase()
827
+ ].join(":")
828
+ };
829
+ var CentrifugeVaultClaimProceedsTransaction = {
830
+ fromDto: (dto) => ({
831
+ ...parseTransactionCore(dto, "CentrifugeVaultClaimProceedsTransaction"),
832
+ claimableAssets: blockchainAmountFromRawOrThrow({
833
+ label: "claimable_assets",
834
+ raw: dto.claimable_assets,
835
+ decimals: AssetDecimals(dto.asset_decimals)
836
+ })
837
+ })
838
+ };
839
+ function parseOrderability(canOrder, reasons, model) {
840
+ const [first, ...rest] = reasons;
841
+ if (canOrder) {
842
+ if (first !== void 0) {
843
+ throw new ValidationError(
844
+ `${model}.reasons: expected none when can_order is true, got ${JSON.stringify(reasons)}`
845
+ );
846
+ }
847
+ return { type: "orderable" };
848
+ }
849
+ if (first === void 0) {
850
+ throw new ValidationError(
851
+ `${model}.reasons: expected at least one when can_order is false`
852
+ );
853
+ }
854
+ return { type: "blocked", reasons: [first, ...rest] };
855
+ }
856
+ function parseTransactionCore(dto, model) {
857
+ return {
858
+ tx: {
859
+ to: EvmContractAddress(dto.to),
860
+ data: HexEncodedTransactionData(dto.data)
861
+ },
862
+ expiresAt: dateOrNull(dto.expires_at, `${model}.expires_at`)
863
+ };
864
+ }
865
+
866
+ // src/universal/api/frontline/providers/centrifuge/centrifuge.ts
867
+ async function getCentrifugeVaultStatus(api, params) {
868
+ const dto = await api.send({
869
+ method: "GET",
870
+ url: "/v1/centrifuge/vault/status",
871
+ queryParams: {
872
+ symbol: params.symbol,
873
+ chain: params.chain
874
+ },
875
+ attributes: Attributes.protected()
876
+ });
877
+ return CentrifugeVaultStatus.fromDto(dto);
878
+ }
879
+ async function buildCentrifugeVaultBuy(api, params) {
880
+ const dto = await api.send({
881
+ method: "POST",
882
+ url: "/v1/centrifuge/vault/invest",
883
+ body: {
884
+ ...walletFields(params),
885
+ amount: params.amount.raw.toString()
886
+ },
887
+ attributes: Attributes.protected()
888
+ });
889
+ if (dto.spend_input_decimals !== params.amount.decimals) {
890
+ throw new ValidationError(
891
+ `spend_input_decimals: the request was priced in ${dto.spend_input_decimals} decimals but the deposit was sized in ${params.amount.decimals}`
892
+ );
893
+ }
894
+ return CentrifugeVaultBuyTransaction.fromDto(dto);
895
+ }
896
+ async function getCentrifugeVaultPosition(api, params) {
897
+ const dto = await api.send({
898
+ method: "GET",
899
+ url: "/v1/centrifuge/vault/position",
900
+ queryParams: walletFields(params),
901
+ attributes: Attributes.protected()
902
+ });
903
+ return CentrifugeVaultPosition.fromDto(dto);
904
+ }
905
+ async function getCentrifugeVaultRedeemPosition(api, params) {
906
+ const dto = await api.send({
907
+ method: "GET",
908
+ url: "/v1/centrifuge/vault/redeem-position",
909
+ queryParams: walletFields(params),
910
+ attributes: Attributes.protected()
911
+ });
912
+ return CentrifugeVaultRedeemPosition.fromDto(dto);
913
+ }
914
+ async function createCentrifugeVaultClaim(api, params) {
915
+ const dto = await api.send({
916
+ method: "POST",
917
+ url: "/v1/centrifuge/vault/claim",
918
+ body: walletFields(params),
919
+ attributes: Attributes.protected()
920
+ });
921
+ return CentrifugeVaultClaimTransaction.fromDto(dto);
922
+ }
923
+ async function createCentrifugeVaultClaimProceeds(api, params) {
924
+ const dto = await api.send({
925
+ method: "POST",
926
+ url: "/v1/centrifuge/vault/claim-proceeds",
927
+ body: walletFields(params),
928
+ attributes: Attributes.protected()
929
+ });
930
+ return CentrifugeVaultClaimProceedsTransaction.fromDto(dto);
931
+ }
932
+ function walletFields(params) {
933
+ return {
934
+ symbol: params.symbol,
935
+ chain: params.chain,
936
+ wallet_address: params.walletAddress
937
+ };
938
+ }
939
+
940
+ // src/universal/core/shared/observability/log-cause.ts
941
+ var import_viem2 = require("viem");
942
+ function classifyLogCause(error) {
943
+ if (error instanceof HttpError) {
944
+ return httpCause(error);
945
+ }
946
+ if (error instanceof ValidationError) {
947
+ return { type: "validation", message: error.message };
948
+ }
949
+ if (error instanceof InvariantError) {
950
+ return { type: "invariant", message: error.message };
951
+ }
952
+ if (error instanceof MathError) {
953
+ return { type: "math", message: error.message };
954
+ }
955
+ if (error instanceof NotAuthenticatedError) {
956
+ return { type: "not-authenticated" };
957
+ }
958
+ if (error instanceof NotImplementedError) {
959
+ return { type: "not-implemented" };
960
+ }
961
+ if (error instanceof import_viem2.BaseError) {
962
+ const http = error.walk((e) => e instanceof HttpError);
963
+ if (http instanceof HttpError) {
964
+ return httpCause(http);
965
+ }
966
+ return { type: "rpc", reason: rpcFailureReason(error) };
967
+ }
968
+ return { type: "generic-error", name: errorName(error) };
969
+ }
970
+ function rpcFailureReason(error) {
971
+ if (error.walk((e) => e instanceof import_viem2.ContractFunctionRevertedError)) {
972
+ return "reverted";
973
+ }
974
+ if (error.walk((e) => e instanceof import_viem2.RpcError)) {
975
+ return "node-rejected";
976
+ }
977
+ if (error.walk(
978
+ (e) => e instanceof import_viem2.HttpRequestError || e instanceof import_viem2.WebSocketRequestError || e instanceof import_viem2.SocketClosedError || e instanceof import_viem2.TimeoutError
979
+ )) {
980
+ return "transport";
981
+ }
982
+ if (error instanceof import_viem2.ContractFunctionExecutionError) {
983
+ return "malformed-response";
984
+ }
985
+ return "unknown";
986
+ }
987
+ function describeErrorUnredacted(error) {
988
+ if (error instanceof HttpError) {
989
+ return describeHttpErrorRedacted(error);
990
+ }
991
+ if (error instanceof Error) {
992
+ return `${error.name}: ${error.message}`;
993
+ }
994
+ return `thrown non-error: ${stringifyUnredacted(error)}`;
995
+ }
996
+ function stringifyUnredacted(value) {
997
+ if (value === void 0) return "";
998
+ try {
999
+ return JSON.stringify(
1000
+ value,
1001
+ (_key, item) => typeof item === "bigint" ? `${item}` : item
1002
+ ) ?? String(value);
1003
+ } catch (_) {
1004
+ return "<unserializable>";
1005
+ }
1006
+ }
1007
+ function describeHttpErrorRedacted(error) {
1008
+ const code = apiErrorCode(error);
1009
+ const status = error.response.status;
1010
+ return code === null ? `HttpError ${status}` : `HttpError ${status} (${code})`;
1011
+ }
1012
+ function errorName(error) {
1013
+ return error instanceof Error ? error.name : `non-error ${typeof error}`;
1014
+ }
1015
+ function httpCause(error) {
1016
+ return {
1017
+ type: "http",
1018
+ requestId: error.requestId,
1019
+ status: error.response.status,
1020
+ code: apiErrorCode(error),
1021
+ eventId: apiErrorEventId(error)
1022
+ };
1023
+ }
1024
+ function apiErrorEventId(error) {
1025
+ const body = error.response.body;
1026
+ if (typeof body !== "object" || body === null) return null;
1027
+ const eventId = body.event_id;
1028
+ return typeof eventId === "string" ? eventId : null;
1029
+ }
1030
+
1031
+ // src/universal/core/shared/observability/internal-logger.ts
1032
+ function internalLogger(logger, scope) {
1033
+ return logger ? scopedLogger(logger, scope, {}) : noopInternalLogger;
1034
+ }
1035
+ var LEVEL_RANK = {
1036
+ none: 0,
1037
+ error: 1,
1038
+ warn: 2,
1039
+ info: 3,
1040
+ debug: 4
1041
+ };
1042
+ function scopedLogger(logger, scope, bindings) {
1043
+ const admits = (level) => LEVEL_RANK[logger.level()] >= LEVEL_RANK[level];
1044
+ const safe = (event) => ({
1045
+ msg: event.msg,
1046
+ scope,
1047
+ bindings,
1048
+ fields: event.fields ?? {},
1049
+ ...event.cause === void 0 ? {} : { cause: event.cause }
1050
+ });
1051
+ const unredacted = (event) => ({
1052
+ msg: event.msg,
1053
+ scope,
1054
+ bindings,
1055
+ fields: event.fields ?? {}
1056
+ });
1057
+ const self = {
1058
+ child: (binding) => scopedLogger(logger, scope, { ...bindings, ...binding }),
1059
+ debug: (event) => {
1060
+ if (admits("debug")) logger.debug(() => unredacted(event()));
1061
+ },
1062
+ info: (event) => {
1063
+ if (admits("info")) logger.info(() => safe(event()));
1064
+ },
1065
+ warn: (event) => {
1066
+ if (admits("warn")) logger.warn(() => safe(event()));
1067
+ },
1068
+ error: (event) => {
1069
+ if (admits("error")) logger.error(() => safe(event()));
1070
+ },
1071
+ failure: (event, error) => {
1072
+ if (admits("debug"))
1073
+ logger.debug(() => unredacted(verbatim(event(), error)));
1074
+ if (admits("error")) logger.error(() => safe(classified(event(), error)));
1075
+ },
1076
+ warning: (event, error) => {
1077
+ if (admits("debug"))
1078
+ logger.debug(() => unredacted(verbatim(event(), error)));
1079
+ if (admits("warn")) logger.warn(() => safe(classified(event(), error)));
1080
+ },
1081
+ wrap: async (op, params, run) => {
1082
+ const opLog = self.child({ op });
1083
+ opLog.debug(() => ({ msg: "call", fields: { params } }));
1084
+ try {
1085
+ return await run();
1086
+ } catch (error) {
1087
+ opLog.failure(() => ({ msg: "call failed" }), error);
1088
+ throw error;
1089
+ }
1090
+ }
1091
+ };
1092
+ return self;
1093
+ }
1094
+ function verbatim(event, error) {
1095
+ return {
1096
+ msg: event.msg,
1097
+ fields: { ...event.fields, error: describeErrorUnredacted(error) }
1098
+ };
1099
+ }
1100
+ function classified(event, error) {
1101
+ return { ...event, cause: event.cause ?? classifyLogCause(error) };
1102
+ }
1103
+ var noopInternalLogger = {
1104
+ child: () => noopInternalLogger,
1105
+ debug: () => void 0,
1106
+ info: () => void 0,
1107
+ warn: () => void 0,
1108
+ error: () => void 0,
1109
+ failure: () => void 0,
1110
+ warning: () => void 0,
1111
+ wrap: (_op, _params, run) => run()
1112
+ };
1113
+
1114
+ // src/universal/core/checkout/centrifuge/centrifuge-namespace.ts
1115
+ var CentrifugeNamespaceImpl = class {
1116
+ constructor(ctx) {
1117
+ this.ctx = ctx;
1118
+ this.log = internalLogger(ctx.logger, "CENTRIFUGE");
1119
+ }
1120
+ async getVaultStatus(params) {
1121
+ return this.log.wrap("getVaultStatus", params, async () => {
1122
+ await this.ctx.ensureUserAuthenticated();
1123
+ return getCentrifugeVaultStatus(this.ctx.api, params);
1124
+ });
1125
+ }
1126
+ async getPosition(params) {
1127
+ return this.log.wrap("getPosition", params, async () => {
1128
+ await this.ctx.ensureUserAuthenticated();
1129
+ return getCentrifugeVaultPosition(this.ctx.api, params);
1130
+ });
1131
+ }
1132
+ async getRedeemPosition(params) {
1133
+ return this.log.wrap("getRedeemPosition", params, async () => {
1134
+ await this.ctx.ensureUserAuthenticated();
1135
+ return getCentrifugeVaultRedeemPosition(this.ctx.api, params);
1136
+ });
1137
+ }
1138
+ async createClaim(params) {
1139
+ return this.log.wrap("createClaim", params, async () => {
1140
+ await this.ctx.ensureUserAuthenticated();
1141
+ return createCentrifugeVaultClaim(this.ctx.api, params);
1142
+ });
1143
+ }
1144
+ async createClaimProceeds(params) {
1145
+ return this.log.wrap("createClaimProceeds", params, async () => {
1146
+ await this.ctx.ensureUserAuthenticated();
1147
+ return createCentrifugeVaultClaimProceeds(this.ctx.api, params);
1148
+ });
1149
+ }
1150
+ async buildBuyTransaction(params) {
1151
+ return this.log.wrap("buildBuyTransaction", params, async () => {
1152
+ await this.ctx.ensureUserAuthenticated();
1153
+ return buildCentrifugeVaultBuy(this.ctx.api, params);
1154
+ });
1155
+ }
1156
+ };
1157
+
1158
+ // src/universal/core/checkout/centrifuge/constants.ts
1159
+ var CENTRIFUGE_POLL_INTERVAL_MS = 15e3;
1160
+
1161
+ // src/universal/core/checkout/centrifuge/vaults.ts
1162
+ function resolveCentrifugeVaults(offer, lookup) {
1163
+ return offer.vaultContracts.map((contract) => {
1164
+ const { chain } = contract;
1165
+ if (!isEthereumChain(chain)) {
1166
+ return { type: "unresolved", chain, missing: "evm-chain" };
1167
+ }
1168
+ const onChain = (role) => offer.tokens.filter(
1169
+ (token) => token.role === role && token.chain === chain
1170
+ );
1171
+ const share = firstKnown(onChain("vault"), lookup);
1172
+ if (share === null) {
1173
+ return { type: "unresolved", chain, missing: "share-token" };
1174
+ }
1175
+ const funding = firstKnown(onChain("funding"), lookup);
1176
+ if (funding === null) {
1177
+ return { type: "unresolved", chain, missing: "funding-token" };
1178
+ }
1179
+ return {
1180
+ type: "resolved",
1181
+ vault: { chain, proxy: contract.address, share, funding }
1182
+ };
1183
+ });
1184
+ }
1185
+ function firstKnown(tokens, lookup) {
1186
+ for (const token of tokens) {
1187
+ const metadata = lookup(token);
1188
+ if (metadata !== null) return metadata;
1189
+ }
1190
+ return null;
1191
+ }
1192
+ function isEthereumChain(chain) {
1193
+ return chain in ETHEREUM_CHAINS;
1194
+ }
1195
+
1196
+ // src/universal/types/pagination.ts
1197
+ var Cursor = (value) => value;
1198
+ var PaginatedResponse = {
1199
+ fromDto: (dto, itemMapper) => PaginatedResponse.fromDtoPage(dto, (items) => items.map(itemMapper)),
1200
+ /**
1201
+ * For a mapper that decides the page as a whole - one that drops items it
1202
+ * cannot map, such as `Offer.listFromDto` - rather than item by item. The
1203
+ * cursors are the wire's either way: dropping an item changes what the
1204
+ * page holds, not where the next page starts.
1205
+ */
1206
+ fromDtoPage: (dto, pageMapper) => ({
1207
+ data: pageMapper(dto.data),
1208
+ startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
1209
+ startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
1210
+ })
1211
+ };
1212
+ var PaginationParams = {
1213
+ toQueryParams: (params) => {
1214
+ const queryParams = {};
1215
+ if (params.after) {
1216
+ queryParams.starting_after = params.after;
1217
+ }
1218
+ if (params.before) {
1219
+ queryParams.starting_before = params.before;
1220
+ }
1221
+ if (params.limit) {
1222
+ queryParams.limit = params.limit;
1223
+ }
1224
+ return queryParams;
1225
+ }
1226
+ };
1227
+
1228
+ // src/universal/types/asset.ts
1229
+ var AssetId = (value) => value;
1230
+ var AssetCode = (value) => value;
1231
+ var Asset = {
1232
+ fromDto: (dto) => ({
1233
+ id: AssetId(dto.id),
1234
+ code: AssetCode(dto.code),
1235
+ name: dto.name,
1236
+ fractionalDigits: dto.fractional_digits
1237
+ })
1238
+ };
1239
+
1240
+ // src/universal/types/offer.ts
1241
+ var OfferId = (value) => value;
1242
+ var OfferSlug = (value) => value;
1243
+ var OFFER_TYPES = {
1244
+ "coinlist::token_sale": true,
1245
+ "superstate::swap": true,
1246
+ "ondo::swap": true,
1247
+ "centrifuge::vault": true
1248
+ };
1249
+ var isOfferType = (value) => Object.keys(OFFER_TYPES).includes(value);
1250
+ var OfferEditorial = {
1251
+ /**
1252
+ * `model` prefixes the field in the error (`'Offer'`, `'OfferDetail'`), so
1253
+ * the same three checks name the payload that failed them.
1254
+ */
1255
+ fromDto: (dto, model) => ({
1256
+ tagline: requiredString(dto.tagline, `${model}.tagline`),
1257
+ bannerUrl: requiredString(dto.banner_url, `${model}.banner_url`),
1258
+ startsAt: requiredDate(dto.starts_at, `${model}.starts_at`)
1259
+ })
1260
+ };
1261
+ var Offer = {
1262
+ fromDto: (dto) => {
1263
+ const tokens = requiredArray(dto.tokens, "Offer.tokens");
1264
+ const base2 = {
1265
+ id: OfferId(dto.id),
1266
+ slug: OfferSlug(dto.slug),
1267
+ endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
1268
+ tokens: OfferToken.listFromDto(tokens)
1269
+ };
1270
+ switch (dto.type) {
1271
+ case "coinlist::token_sale":
1272
+ return {
1273
+ ...base2,
1274
+ ...OfferEditorial.fromDto(dto, "Offer"),
1275
+ type: dto.type,
1276
+ logoUrl: requiredString(dto.logo_url, "Offer.logo_url")
1277
+ };
1278
+ case "superstate::swap":
1279
+ return {
1280
+ ...base2,
1281
+ ...OfferEditorial.fromDto(dto, "Offer"),
1282
+ type: dto.type,
1283
+ logoUrl: notBlankStringOrNull(dto.logo_url)
1284
+ };
1285
+ // `tagline`, `banner_url` and `starts_at` arrive as `null` and are left
1286
+ // on the wire: copying them would hand every consumer a `startsAt` that
1287
+ // is 1970 for one variant and a date for the others.
1288
+ case "ondo::swap":
1289
+ case "centrifuge::vault":
1290
+ return {
1291
+ ...base2,
1292
+ type: dto.type,
1293
+ logoUrl: notBlankStringOrNull(dto.logo_url)
1294
+ };
1295
+ default:
1296
+ return unknownTypeError(dto, "Offer");
1297
+ }
1298
+ },
1299
+ /**
1300
+ * Maps a page of offers, dropping every offer whose `type` this SDK does not
1301
+ * name. The same reasoning as {@link OfferToken.listFromDto}: a plain `.map`
1302
+ * would throw out of `fromDto` and, through `PaginatedResponse.fromDto`,
1303
+ * reject the whole page, so one offer of an unknown type would blank the
1304
+ * grid for every offer beside it. A single offer fetched by id still
1305
+ * throws, because there is nothing beside it to keep.
1306
+ */
1307
+ listFromDto: (dtos) => dtos.filter((dto) => isOfferType(dto.type)).map(Offer.fromDto)
1308
+ };
1309
+ var OfferToken = {
1310
+ fromDto: (dto) => ({
1311
+ role: dto.role,
1312
+ chain: Chain(dto.chain),
737
1313
  address: EvmContractAddress(dto.address)
738
1314
  }),
739
1315
  /**
@@ -749,12 +1325,36 @@ var OfferToken = {
749
1325
  */
750
1326
  listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferToken.fromDto)
751
1327
  };
752
-
753
- // src/universal/types/trading.ts
754
- var Ticker = (value) => value;
755
- var Isin = (value) => value;
756
-
757
- // src/universal/types/offer-detail.ts
1328
+
1329
+ // src/universal/types/trading.ts
1330
+ var Ticker = (value) => value;
1331
+ var Isin = (value) => value;
1332
+
1333
+ // src/universal/types/offer-detail.ts
1334
+ var AsyncOfferDetail = {
1335
+ /**
1336
+ * Narrows an offer fetched generically, e.g. on an offer page, to one with
1337
+ * something to claim.
1338
+ *
1339
+ * An exhaustive `switch` rather than a list of async types, so a new offer
1340
+ * type is a compile error here until someone decides whether it settles
1341
+ * later.
1342
+ */
1343
+ is: (offer) => {
1344
+ switch (offer.type) {
1345
+ case "centrifuge::vault":
1346
+ return true;
1347
+ case "ondo::swap":
1348
+ case "superstate::swap":
1349
+ case "coinlist::token_sale":
1350
+ return false;
1351
+ default: {
1352
+ const exhaustive = offer;
1353
+ return exhaustive;
1354
+ }
1355
+ }
1356
+ }
1357
+ };
758
1358
  var OfferOptionId = (value) => value;
759
1359
  var OfferOptionSlug = (value) => value;
760
1360
  var OfferSwapContract = {
@@ -763,6 +1363,19 @@ var OfferSwapContract = {
763
1363
  address: EvmContractAddress(dto.address)
764
1364
  })
765
1365
  };
1366
+ var OfferVaultContract = {
1367
+ fromDto: (dto) => ({
1368
+ chain: Chain(dto.chain),
1369
+ address: EvmContractAddress(dto.address)
1370
+ }),
1371
+ /**
1372
+ * Drops every proxy on a chain this SDK does not name, as
1373
+ * `OfferToken.listFromDto` does: frontline publishes the full offer-token
1374
+ * chain list, which runs ahead of {@link Chain}, and one unmodelled chain
1375
+ * should not throw away the proxies the SDK can use.
1376
+ */
1377
+ listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferVaultContract.fromDto)
1378
+ };
766
1379
  var OfferDetail = {
767
1380
  fromDto: (dto) => {
768
1381
  const fundingAssets = requiredArray(
@@ -825,6 +1438,18 @@ var OfferDetail = {
825
1438
  "OfferDetail.swap_contracts"
826
1439
  ).map(OfferSwapContract.fromDto)
827
1440
  };
1441
+ // No editorial, as for Ondo. `[]` is fine and a missing key is not, for
1442
+ // the same reason as `swap_contracts`: this is the spender a user
1443
+ // approves.
1444
+ case "centrifuge::vault":
1445
+ return {
1446
+ ...base2,
1447
+ type: dto.type,
1448
+ logoUrl: notBlankStringOrNull(dto.logo_url),
1449
+ vaultContracts: OfferVaultContract.listFromDto(
1450
+ requiredArray(dto.vault_contracts, "OfferDetail.vault_contracts")
1451
+ )
1452
+ };
828
1453
  default:
829
1454
  return unknownTypeError(dto, "OfferDetail");
830
1455
  }
@@ -949,180 +1574,6 @@ async function createParticipation(api, params) {
949
1574
  return Participation.fromDto(dto);
950
1575
  }
951
1576
 
952
- // src/universal/core/shared/observability/log-cause.ts
953
- var import_viem = require("viem");
954
- function classifyLogCause(error) {
955
- if (error instanceof HttpError) {
956
- return httpCause(error);
957
- }
958
- if (error instanceof ValidationError) {
959
- return { type: "validation", message: error.message };
960
- }
961
- if (error instanceof InvariantError) {
962
- return { type: "invariant", message: error.message };
963
- }
964
- if (error instanceof MathError) {
965
- return { type: "math", message: error.message };
966
- }
967
- if (error instanceof NotAuthenticatedError) {
968
- return { type: "not-authenticated" };
969
- }
970
- if (error instanceof NotImplementedError) {
971
- return { type: "not-implemented" };
972
- }
973
- if (error instanceof import_viem.BaseError) {
974
- const http = error.walk((e) => e instanceof HttpError);
975
- if (http instanceof HttpError) {
976
- return httpCause(http);
977
- }
978
- return { type: "rpc", reason: rpcFailureReason(error) };
979
- }
980
- return { type: "generic-error", name: errorName(error) };
981
- }
982
- function rpcFailureReason(error) {
983
- if (error.walk((e) => e instanceof import_viem.ContractFunctionRevertedError)) {
984
- return "reverted";
985
- }
986
- if (error.walk((e) => e instanceof import_viem.RpcError)) {
987
- return "node-rejected";
988
- }
989
- if (error.walk(
990
- (e) => e instanceof import_viem.HttpRequestError || e instanceof import_viem.WebSocketRequestError || e instanceof import_viem.SocketClosedError || e instanceof import_viem.TimeoutError
991
- )) {
992
- return "transport";
993
- }
994
- if (error instanceof import_viem.ContractFunctionExecutionError) {
995
- return "malformed-response";
996
- }
997
- return "unknown";
998
- }
999
- function describeErrorUnredacted(error) {
1000
- if (error instanceof HttpError) {
1001
- return describeHttpErrorRedacted(error);
1002
- }
1003
- if (error instanceof Error) {
1004
- return `${error.name}: ${error.message}`;
1005
- }
1006
- return `thrown non-error: ${stringifyUnredacted(error)}`;
1007
- }
1008
- function stringifyUnredacted(value) {
1009
- if (value === void 0) return "";
1010
- try {
1011
- return JSON.stringify(
1012
- value,
1013
- (_key, item) => typeof item === "bigint" ? `${item}` : item
1014
- ) ?? String(value);
1015
- } catch (_) {
1016
- return "<unserializable>";
1017
- }
1018
- }
1019
- function describeHttpErrorRedacted(error) {
1020
- const code = apiErrorCode(error);
1021
- const status = error.response.status;
1022
- return code === null ? `HttpError ${status}` : `HttpError ${status} (${code})`;
1023
- }
1024
- function errorName(error) {
1025
- return error instanceof Error ? error.name : `non-error ${typeof error}`;
1026
- }
1027
- function httpCause(error) {
1028
- return {
1029
- type: "http",
1030
- requestId: error.requestId,
1031
- status: error.response.status,
1032
- code: apiErrorCode(error),
1033
- eventId: apiErrorEventId(error)
1034
- };
1035
- }
1036
- function apiErrorEventId(error) {
1037
- const body = error.response.body;
1038
- if (typeof body !== "object" || body === null) return null;
1039
- const eventId = body.event_id;
1040
- return typeof eventId === "string" ? eventId : null;
1041
- }
1042
-
1043
- // src/universal/core/shared/observability/internal-logger.ts
1044
- function internalLogger(logger, scope) {
1045
- return logger ? scopedLogger(logger, scope, {}) : noopInternalLogger;
1046
- }
1047
- var LEVEL_RANK = {
1048
- none: 0,
1049
- error: 1,
1050
- warn: 2,
1051
- info: 3,
1052
- debug: 4
1053
- };
1054
- function scopedLogger(logger, scope, bindings) {
1055
- const admits = (level) => LEVEL_RANK[logger.level()] >= LEVEL_RANK[level];
1056
- const safe = (event) => ({
1057
- msg: event.msg,
1058
- scope,
1059
- bindings,
1060
- fields: event.fields ?? {},
1061
- ...event.cause === void 0 ? {} : { cause: event.cause }
1062
- });
1063
- const unredacted = (event) => ({
1064
- msg: event.msg,
1065
- scope,
1066
- bindings,
1067
- fields: event.fields ?? {}
1068
- });
1069
- const self = {
1070
- child: (binding) => scopedLogger(logger, scope, { ...bindings, ...binding }),
1071
- debug: (event) => {
1072
- if (admits("debug")) logger.debug(() => unredacted(event()));
1073
- },
1074
- info: (event) => {
1075
- if (admits("info")) logger.info(() => safe(event()));
1076
- },
1077
- warn: (event) => {
1078
- if (admits("warn")) logger.warn(() => safe(event()));
1079
- },
1080
- error: (event) => {
1081
- if (admits("error")) logger.error(() => safe(event()));
1082
- },
1083
- failure: (event, error) => {
1084
- if (admits("debug"))
1085
- logger.debug(() => unredacted(verbatim(event(), error)));
1086
- if (admits("error")) logger.error(() => safe(classified(event(), error)));
1087
- },
1088
- warning: (event, error) => {
1089
- if (admits("debug"))
1090
- logger.debug(() => unredacted(verbatim(event(), error)));
1091
- if (admits("warn")) logger.warn(() => safe(classified(event(), error)));
1092
- },
1093
- wrap: async (op, params, run) => {
1094
- const opLog = self.child({ op });
1095
- opLog.debug(() => ({ msg: "call", fields: { params } }));
1096
- try {
1097
- return await run();
1098
- } catch (error) {
1099
- opLog.failure(() => ({ msg: "call failed" }), error);
1100
- throw error;
1101
- }
1102
- }
1103
- };
1104
- return self;
1105
- }
1106
- function verbatim(event, error) {
1107
- return {
1108
- msg: event.msg,
1109
- fields: { ...event.fields, error: describeErrorUnredacted(error) }
1110
- };
1111
- }
1112
- function classified(event, error) {
1113
- return { ...event, cause: event.cause ?? classifyLogCause(error) };
1114
- }
1115
- var noopInternalLogger = {
1116
- child: () => noopInternalLogger,
1117
- debug: () => void 0,
1118
- info: () => void 0,
1119
- warn: () => void 0,
1120
- error: () => void 0,
1121
- failure: () => void 0,
1122
- warning: () => void 0,
1123
- wrap: (_op, _params, run) => run()
1124
- };
1125
-
1126
1577
  // src/universal/core/checkout/coin-list/token-sale-namespace.ts
1127
1578
  var CoinListTokenSaleNamespaceImpl = class {
1128
1579
  constructor(ctx) {
@@ -1278,7 +1729,7 @@ function isOndoNotTradableError(error) {
1278
1729
  }
1279
1730
 
1280
1731
  // src/universal/core/shared/blockchain/formatters.ts
1281
- var import_viem2 = require("viem");
1732
+ var import_viem3 = require("viem");
1282
1733
 
1283
1734
  // src/universal/types/blockchain/ui.ts
1284
1735
  var FormattedAmountUi = (value) => value;
@@ -1349,7 +1800,7 @@ function roundFractionHalfUp(integerPart, fractionPart, maxFractionDigits) {
1349
1800
  };
1350
1801
  }
1351
1802
  function formatRawAmount(amount) {
1352
- return (0, import_viem2.formatUnits)(amount.raw, amount.decimals);
1803
+ return (0, import_viem3.formatUnits)(amount.raw, amount.decimals);
1353
1804
  }
1354
1805
  function formatCompactAmount(amount, locale) {
1355
1806
  const value = Number(formatRawAmount(amount));
@@ -1453,66 +1904,6 @@ function explorerBaseUrl(chain) {
1453
1904
  }
1454
1905
  }
1455
1906
 
1456
- // src/universal/core/shared/blockchain/math.ts
1457
- var import_viem3 = require("viem");
1458
- function blockchainAmountFromRawOrThrow({
1459
- label,
1460
- raw,
1461
- decimals
1462
- }) {
1463
- const trimmed = raw.trim();
1464
- if (trimmed === "") {
1465
- throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
1466
- }
1467
- let value;
1468
- try {
1469
- value = BigInt(trimmed);
1470
- } catch {
1471
- throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
1472
- }
1473
- try {
1474
- return BlockchainAmount({ raw: assertUint256(value), decimals });
1475
- } catch {
1476
- throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
1477
- }
1478
- }
1479
- function parseBlockchainAmount(amount, decimals) {
1480
- const trimmed = amount.trim();
1481
- if (trimmed === "") return { valid: false, reason: { type: "empty" } };
1482
- if (trimmed.startsWith("-")) {
1483
- return { valid: false, reason: { type: "negative" } };
1484
- }
1485
- if (/[eE]/.test(trimmed)) {
1486
- return { valid: false, reason: { type: "invalid-format" } };
1487
- }
1488
- if (trimmed === ".") {
1489
- return { valid: false, reason: { type: "invalid-format" } };
1490
- }
1491
- const normalised = trimmed.replace(/^\./, "0.").replace(/\.$/, "");
1492
- if (!/^\d+(\.\d+)?$/.test(normalised)) {
1493
- return { valid: false, reason: { type: "invalid-format" } };
1494
- }
1495
- const [, fraction = ""] = normalised.split(".");
1496
- if (fraction.length > decimals) {
1497
- return {
1498
- valid: false,
1499
- reason: { type: "too-many-decimals", maxDecimals: decimals }
1500
- };
1501
- }
1502
- try {
1503
- const raw = (0, import_viem3.parseUnits)(normalised, decimals);
1504
- if (raw > MAX_UINT_256) {
1505
- return { valid: false, reason: { type: "overflow" } };
1506
- }
1507
- return {
1508
- valid: true,
1509
- amount: BlockchainAmount({ raw, decimals })
1510
- };
1511
- } catch {
1512
- return { valid: false, reason: { type: "invalid-format" } };
1513
- }
1514
- }
1515
-
1516
1907
  // src/universal/types/providers/ondo/ondo.ts
1517
1908
  var OndoTradingStatus = {
1518
1909
  fromDto: (dto) => {
@@ -1528,7 +1919,6 @@ var OndoTradingStatus = {
1528
1919
  };
1529
1920
  }
1530
1921
  };
1531
- var decimalOrNull = (value) => value === null ? null : DecimalString(value);
1532
1922
  var OndoQuote = {
1533
1923
  fromDto: (dto) => {
1534
1924
  const assetDecimals = AssetDecimals(dto.asset_decimals);
@@ -3359,7 +3749,9 @@ var TokenRegistrySnapshot = {
3359
3749
  }
3360
3750
  };
3361
3751
  function offerDisplayTokens(offer) {
3362
- const swaps = offer.tokens.filter((token) => token.role === "swap");
3752
+ const swaps = offer.tokens.filter(
3753
+ (token) => token.role === "swap" || token.role === "vault"
3754
+ );
3363
3755
  const distributions = offer.tokens.filter(
3364
3756
  (token) => token.role === "distribution"
3365
3757
  );
@@ -3885,6 +4277,27 @@ var RedactedWalletError = {
3885
4277
  fromWalletError: (error) => error.type === "unknown" ? { type: "unknown" } : error
3886
4278
  };
3887
4279
 
4280
+ // src/universal/types/blockchain/wallet-selection.ts
4281
+ var WalletSelection = {
4282
+ /**
4283
+ * Every wallet in display order - embedded first, then the external one -
4284
+ * each address once. Addresses compare case-insensitively, so a host that
4285
+ * hands the same wallet over as both embedded and external sees it once.
4286
+ */
4287
+ all: (selection) => {
4288
+ const seen = /* @__PURE__ */ new Set();
4289
+ return [
4290
+ ...selection.embedded,
4291
+ ...selection.external === null ? [] : [selection.external]
4292
+ ].filter((wallet) => {
4293
+ const key = wallet.address.toLowerCase();
4294
+ if (seen.has(key)) return false;
4295
+ seen.add(key);
4296
+ return true;
4297
+ });
4298
+ }
4299
+ };
4300
+
3888
4301
  // src/universal/types/oauth-session.ts
3889
4302
  var ClientCredentialsOAuth = (value) => value;
3890
4303
  var OAuthRefreshToken = (value) => value;
@@ -3967,11 +4380,22 @@ var User = {
3967
4380
  AssetIconUrl,
3968
4381
  AssetId,
3969
4382
  AssetSymbol,
4383
+ AsyncOfferDetail,
3970
4384
  AuthorizationCode,
3971
4385
  BPS_DENOM,
3972
4386
  Blockchain,
3973
4387
  BlockchainAmount,
3974
4388
  Bps,
4389
+ CENTRIFUGE_POLL_INTERVAL_MS,
4390
+ CentrifugeNamespaceImpl,
4391
+ CentrifugeVaultBuyTransaction,
4392
+ CentrifugeVaultClaimProceedsTransaction,
4393
+ CentrifugeVaultClaimTransaction,
4394
+ CentrifugeVaultLeg,
4395
+ CentrifugeVaultLegId,
4396
+ CentrifugeVaultPosition,
4397
+ CentrifugeVaultRedeemPosition,
4398
+ CentrifugeVaultStatus,
3975
4399
  Chain,
3976
4400
  ClientCredentialsOAuth,
3977
4401
  ClientId,
@@ -4035,6 +4459,7 @@ var User = {
4035
4459
  OfferSlug,
4036
4460
  OfferSwapContract,
4037
4461
  OfferToken,
4462
+ OfferVaultContract,
4038
4463
  OffersNamespaceImpl,
4039
4464
  OndoBuyTransaction,
4040
4465
  OndoNamespaceImpl,
@@ -4093,6 +4518,7 @@ var User = {
4093
4518
  ValidationError,
4094
4519
  WalletAddress,
4095
4520
  WalletOwnershipChallenge,
4521
+ WalletSelection,
4096
4522
  WalletsNamespaceImpl,
4097
4523
  apiErrorCode,
4098
4524
  applyBps,
@@ -4125,6 +4551,7 @@ var User = {
4125
4551
  ondoQuoteOfferDeadline,
4126
4552
  parseBlockchainAmount,
4127
4553
  parseUint256,
4554
+ resolveCentrifugeVaults,
4128
4555
  shortenAddress,
4129
4556
  superstateSwapContractAddress,
4130
4557
  swapSpender,