@coinlist-co/react 0.12.1-rc.73e7e17 → 0.12.1-rc.9aec85a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-3ZZCK4IT.js → chunk-DCW7NQXH.js} +129 -3
- package/dist/chunk-DCW7NQXH.js.map +1 -0
- package/dist/{chunk-D42IQHQZ.js → chunk-MOE5S6CE.js} +1345 -257
- package/dist/chunk-MOE5S6CE.js.map +1 -0
- package/dist/{chunk-ZUVVNZJJ.js → chunk-VH34YC3Q.js} +72 -330
- package/dist/chunk-VH34YC3Q.js.map +1 -0
- package/dist/client/index.cjs +9477 -8125
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +398 -166
- package/dist/client/index.d.ts +398 -166
- package/dist/client/index.js +4959 -4544
- package/dist/client/index.js.map +1 -1
- package/dist/server/index.cjs +1458 -263
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +5 -3
- package/dist/server/index.js.map +1 -1
- package/dist/{collections-CMoojQ9M.d.ts → token-registry-snapshot-BNBNuDu1.d.ts} +65 -2
- package/dist/{collections-koI4cjYa.d.cts → token-registry-snapshot-CqI6dXM_.d.cts} +65 -2
- package/dist/{config-BmK0t-XO.d.cts → tokens-namespace-CIWBtgt2.d.cts} +463 -229
- package/dist/{config-BmK0t-XO.d.ts → tokens-namespace-CIWBtgt2.d.ts} +463 -229
- package/dist/universal/index.cjs +1275 -450
- package/dist/universal/index.cjs.map +1 -1
- package/dist/universal/index.d.cts +431 -54
- package/dist/universal/index.d.ts +431 -54
- package/dist/universal/index.js +26 -16
- package/package.json +1 -1
- package/dist/chunk-3ZZCK4IT.js.map +0 -1
- package/dist/chunk-D42IQHQZ.js.map +0 -1
- package/dist/chunk-ZUVVNZJJ.js.map +0 -1
package/dist/universal/index.cjs
CHANGED
|
@@ -77,11 +77,12 @@ __export(universal_exports, {
|
|
|
77
77
|
OAuthRefreshToken: () => OAuthRefreshToken,
|
|
78
78
|
OAuthSession: () => OAuthSession,
|
|
79
79
|
ONDO_POLL_INTERVAL_MS: () => ONDO_POLL_INTERVAL_MS,
|
|
80
|
-
|
|
80
|
+
ONDO_QUOTE_MAX_TTL_MS: () => ONDO_QUOTE_MAX_TTL_MS,
|
|
81
81
|
ONDO_SETTLEMENT_ASSET: () => ONDO_SETTLEMENT_ASSET,
|
|
82
82
|
ONDO_SUPPORTED_INPUT_ASSETS: () => ONDO_SUPPORTED_INPUT_ASSETS,
|
|
83
83
|
Offer: () => Offer,
|
|
84
84
|
OfferDetail: () => OfferDetail,
|
|
85
|
+
OfferEditorial: () => OfferEditorial,
|
|
85
86
|
OfferId: () => OfferId,
|
|
86
87
|
OfferOption: () => OfferOption,
|
|
87
88
|
OfferOptionAddress: () => OfferOptionAddress,
|
|
@@ -103,6 +104,7 @@ __export(universal_exports, {
|
|
|
103
104
|
Participation: () => Participation,
|
|
104
105
|
ParticipationId: () => ParticipationId,
|
|
105
106
|
ParticipationsPaginationParams: () => ParticipationsPaginationParams,
|
|
107
|
+
PauseFlags: () => PauseFlags,
|
|
106
108
|
Pii: () => Pii,
|
|
107
109
|
PiiAddress: () => PiiAddress,
|
|
108
110
|
PiiJurisdiction: () => PiiJurisdiction,
|
|
@@ -119,23 +121,22 @@ __export(universal_exports, {
|
|
|
119
121
|
SUPERSTATE_SUPPORTED_INPUT_ASSETS: () => SUPERSTATE_SUPPORTED_INPUT_ASSETS,
|
|
120
122
|
SUPERSTATE_SWAP_ABI: () => SUPERSTATE_SWAP_ABI,
|
|
121
123
|
SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA: () => SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA,
|
|
124
|
+
SWAP_LEVEL: () => SWAP_LEVEL,
|
|
122
125
|
SWAP_POLL_INTERVAL_MS: () => SWAP_POLL_INTERVAL_MS,
|
|
123
126
|
ShortenedWalletAddress: () => ShortenedWalletAddress,
|
|
124
127
|
SolanaChain: () => SolanaChain,
|
|
125
128
|
StablecoinSymbol: () => StablecoinSymbol,
|
|
126
129
|
SuperstateSwapNamespaceImpl: () => SuperstateSwapNamespaceImpl,
|
|
127
|
-
SwapAuthorization: () => SwapAuthorization,
|
|
128
130
|
SwapPreview: () => SwapPreview,
|
|
129
131
|
SwapQuote: () => SwapQuote,
|
|
130
132
|
SwapStatus: () => SwapStatus,
|
|
131
133
|
TOKEN_REGISTRY: () => TOKEN_REGISTRY,
|
|
132
134
|
TermItem: () => TermItem,
|
|
133
135
|
Ticker: () => Ticker,
|
|
134
|
-
TokenAllowance: () => TokenAllowance,
|
|
135
|
-
TokenBalance: () => TokenBalance,
|
|
136
136
|
TokenLogo: () => TokenLogo,
|
|
137
137
|
TokenLogoUrl: () => TokenLogoUrl,
|
|
138
138
|
TokenMetadata: () => TokenMetadata,
|
|
139
|
+
TokenRegistrySnapshot: () => TokenRegistrySnapshot,
|
|
139
140
|
TokensNamespaceImpl: () => TokensNamespaceImpl,
|
|
140
141
|
TxExplorerUrl: () => TxExplorerUrl,
|
|
141
142
|
USDC: () => USDC,
|
|
@@ -171,14 +172,18 @@ __export(universal_exports, {
|
|
|
171
172
|
getChainId: () => getChainId,
|
|
172
173
|
getNetworkName: () => getNetworkName,
|
|
173
174
|
isChain: () => isChain,
|
|
174
|
-
|
|
175
|
+
isOfferType: () => isOfferType,
|
|
176
|
+
isSwapAvailable: () => isSwapAvailable,
|
|
177
|
+
offerDisplayTokens: () => offerDisplayTokens,
|
|
178
|
+
ondoQuoteOfferDeadline: () => ondoQuoteOfferDeadline,
|
|
175
179
|
parseBlockchainAmount: () => parseBlockchainAmount,
|
|
176
180
|
parseUint256: () => parseUint256,
|
|
177
181
|
shortenAddress: () => shortenAddress,
|
|
178
182
|
superstateSwapContractAddress: () => superstateSwapContractAddress,
|
|
179
183
|
swapSpender: () => swapSpender,
|
|
180
184
|
txExplorerUrl: () => txExplorerUrl,
|
|
181
|
-
usdAmount: () => usdAmount
|
|
185
|
+
usdAmount: () => usdAmount,
|
|
186
|
+
viemChain: () => viemChain
|
|
182
187
|
});
|
|
183
188
|
module.exports = __toCommonJS(universal_exports);
|
|
184
189
|
|
|
@@ -428,8 +433,15 @@ async function generatePKCEParams(config) {
|
|
|
428
433
|
// src/universal/types/pagination.ts
|
|
429
434
|
var Cursor = (value) => value;
|
|
430
435
|
var PaginatedResponse = {
|
|
431
|
-
fromDto: (dto, itemMapper) => (
|
|
432
|
-
|
|
436
|
+
fromDto: (dto, itemMapper) => PaginatedResponse.fromDtoPage(dto, (items) => items.map(itemMapper)),
|
|
437
|
+
/**
|
|
438
|
+
* For a mapper that decides the page as a whole - one that drops items it
|
|
439
|
+
* cannot map, such as `Offer.listFromDto` - rather than item by item. The
|
|
440
|
+
* cursors are the wire's either way: dropping an item changes what the
|
|
441
|
+
* page holds, not where the next page starts.
|
|
442
|
+
*/
|
|
443
|
+
fromDtoPage: (dto, pageMapper) => ({
|
|
444
|
+
data: pageMapper(dto.data),
|
|
433
445
|
startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
|
|
434
446
|
startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
|
|
435
447
|
})
|
|
@@ -494,6 +506,40 @@ var MathError = class extends Error {
|
|
|
494
506
|
}
|
|
495
507
|
};
|
|
496
508
|
|
|
509
|
+
// src/universal/core/shared/utils/wire.ts
|
|
510
|
+
function unknownTypeError(dto, model) {
|
|
511
|
+
const type = dto.type;
|
|
512
|
+
throw new ValidationError(
|
|
513
|
+
`${model}.type: unknown type ${JSON.stringify(type)}`
|
|
514
|
+
);
|
|
515
|
+
}
|
|
516
|
+
function requiredString(value, field) {
|
|
517
|
+
const text = notBlankStringOrNull(value);
|
|
518
|
+
if (text === null) {
|
|
519
|
+
throw new ValidationError(
|
|
520
|
+
`${field}: expected a non-blank string, got ${typeof value === "string" ? "a blank string" : String(value)}`
|
|
521
|
+
);
|
|
522
|
+
}
|
|
523
|
+
return text;
|
|
524
|
+
}
|
|
525
|
+
function requiredDate(value, field) {
|
|
526
|
+
const date = typeof value === "string" ? new Date(value) : null;
|
|
527
|
+
if (date === null || Number.isNaN(date.getTime())) {
|
|
528
|
+
throw new ValidationError(
|
|
529
|
+
`${field}: expected a date, got ${JSON.stringify(value)}`
|
|
530
|
+
);
|
|
531
|
+
}
|
|
532
|
+
return date;
|
|
533
|
+
}
|
|
534
|
+
function requiredArray(value, field) {
|
|
535
|
+
if (!Array.isArray(value)) {
|
|
536
|
+
throw new ValidationError(
|
|
537
|
+
`${field}: expected an array, got ${typeof value}`
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
return value;
|
|
541
|
+
}
|
|
542
|
+
|
|
497
543
|
// src/universal/types/blockchain/core.ts
|
|
498
544
|
var ETHEREUM_CHAINS = {
|
|
499
545
|
ethereum_mainnet: true,
|
|
@@ -594,25 +640,69 @@ var Bps = (value) => value;
|
|
|
594
640
|
// src/universal/types/offer.ts
|
|
595
641
|
var OfferId = (value) => value;
|
|
596
642
|
var OfferSlug = (value) => value;
|
|
643
|
+
var OFFER_TYPES = {
|
|
644
|
+
"coinlist::token_sale": true,
|
|
645
|
+
"superstate::swap": true,
|
|
646
|
+
"ondo::swap": true
|
|
647
|
+
};
|
|
648
|
+
var isOfferType = (value) => Object.keys(OFFER_TYPES).includes(value);
|
|
649
|
+
var OfferEditorial = {
|
|
650
|
+
/**
|
|
651
|
+
* `model` prefixes the field in the error (`'Offer'`, `'OfferDetail'`), so
|
|
652
|
+
* the same three checks name the payload that failed them.
|
|
653
|
+
*/
|
|
654
|
+
fromDto: (dto, model) => ({
|
|
655
|
+
tagline: requiredString(dto.tagline, `${model}.tagline`),
|
|
656
|
+
bannerUrl: requiredString(dto.banner_url, `${model}.banner_url`),
|
|
657
|
+
startsAt: requiredDate(dto.starts_at, `${model}.starts_at`)
|
|
658
|
+
})
|
|
659
|
+
};
|
|
597
660
|
var Offer = {
|
|
598
661
|
fromDto: (dto) => {
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
`Offer.tokens: expected an array, got ${typeof dto.tokens}`
|
|
602
|
-
);
|
|
603
|
-
}
|
|
604
|
-
return {
|
|
662
|
+
const tokens = requiredArray(dto.tokens, "Offer.tokens");
|
|
663
|
+
const base2 = {
|
|
605
664
|
id: OfferId(dto.id),
|
|
606
665
|
slug: OfferSlug(dto.slug),
|
|
607
|
-
type: dto.type,
|
|
608
|
-
tagline: dto.tagline,
|
|
609
|
-
bannerUrl: dto.banner_url,
|
|
610
|
-
logoUrl: dto.logo_url,
|
|
611
|
-
startsAt: new Date(dto.starts_at),
|
|
612
666
|
endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
|
|
613
|
-
tokens: OfferToken.listFromDto(
|
|
667
|
+
tokens: OfferToken.listFromDto(tokens)
|
|
614
668
|
};
|
|
615
|
-
|
|
669
|
+
switch (dto.type) {
|
|
670
|
+
case "coinlist::token_sale":
|
|
671
|
+
return {
|
|
672
|
+
...base2,
|
|
673
|
+
...OfferEditorial.fromDto(dto, "Offer"),
|
|
674
|
+
type: dto.type,
|
|
675
|
+
logoUrl: requiredString(dto.logo_url, "Offer.logo_url")
|
|
676
|
+
};
|
|
677
|
+
case "superstate::swap":
|
|
678
|
+
return {
|
|
679
|
+
...base2,
|
|
680
|
+
...OfferEditorial.fromDto(dto, "Offer"),
|
|
681
|
+
type: dto.type,
|
|
682
|
+
logoUrl: notBlankStringOrNull(dto.logo_url)
|
|
683
|
+
};
|
|
684
|
+
// `tagline`, `banner_url` and `starts_at` arrive as `null` and are left
|
|
685
|
+
// on the wire: copying them would hand every consumer a `startsAt` that
|
|
686
|
+
// is 1970 for one variant and a date for the others.
|
|
687
|
+
case "ondo::swap":
|
|
688
|
+
return {
|
|
689
|
+
...base2,
|
|
690
|
+
type: dto.type,
|
|
691
|
+
logoUrl: notBlankStringOrNull(dto.logo_url)
|
|
692
|
+
};
|
|
693
|
+
default:
|
|
694
|
+
return unknownTypeError(dto, "Offer");
|
|
695
|
+
}
|
|
696
|
+
},
|
|
697
|
+
/**
|
|
698
|
+
* Maps a page of offers, dropping every offer whose `type` this SDK does not
|
|
699
|
+
* name. The same reasoning as {@link OfferToken.listFromDto}: a plain `.map`
|
|
700
|
+
* would throw out of `fromDto` and, through `PaginatedResponse.fromDto`,
|
|
701
|
+
* reject the whole page, so one offer of an unknown type would blank the
|
|
702
|
+
* grid for every offer beside it. A single offer fetched by id still
|
|
703
|
+
* throws, because there is nothing beside it to keep.
|
|
704
|
+
*/
|
|
705
|
+
listFromDto: (dtos) => dtos.filter((dto) => isOfferType(dto.type)).map(Offer.fromDto)
|
|
616
706
|
};
|
|
617
707
|
var OfferToken = {
|
|
618
708
|
fromDto: (dto) => ({
|
|
@@ -649,76 +739,69 @@ var OfferSwapContract = {
|
|
|
649
739
|
};
|
|
650
740
|
var OfferDetail = {
|
|
651
741
|
fromDto: (dto) => {
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
if (!Array.isArray(dto.terms)) {
|
|
663
|
-
throw new ValidationError(
|
|
664
|
-
`OfferDetail.terms: expected an array, got ${typeof dto.terms}`
|
|
665
|
-
);
|
|
666
|
-
}
|
|
667
|
-
if (!Array.isArray(dto.links)) {
|
|
668
|
-
throw new ValidationError(
|
|
669
|
-
`OfferDetail.links: expected an array, got ${typeof dto.links}`
|
|
670
|
-
);
|
|
671
|
-
}
|
|
672
|
-
if (!Array.isArray(dto.faqs)) {
|
|
673
|
-
throw new ValidationError(
|
|
674
|
-
`OfferDetail.faqs: expected an array, got ${typeof dto.faqs}`
|
|
675
|
-
);
|
|
676
|
-
}
|
|
677
|
-
if (!Array.isArray(dto.milestones)) {
|
|
678
|
-
throw new ValidationError(
|
|
679
|
-
`OfferDetail.milestones: expected an array, got ${typeof dto.milestones}`
|
|
680
|
-
);
|
|
681
|
-
}
|
|
682
|
-
if (!Array.isArray(dto.tokens)) {
|
|
683
|
-
throw new ValidationError(
|
|
684
|
-
`OfferDetail.tokens: expected an array, got ${typeof dto.tokens}`
|
|
685
|
-
);
|
|
686
|
-
}
|
|
687
|
-
const swapContracts = dto.swap_contracts === void 0 ? [] : dto.swap_contracts;
|
|
688
|
-
if (!Array.isArray(swapContracts)) {
|
|
689
|
-
throw new ValidationError(
|
|
690
|
-
`OfferDetail.swap_contracts: expected an array, got ${typeof swapContracts}`
|
|
691
|
-
);
|
|
692
|
-
}
|
|
742
|
+
const fundingAssets = requiredArray(
|
|
743
|
+
dto.funding_assets,
|
|
744
|
+
"OfferDetail.funding_assets"
|
|
745
|
+
);
|
|
746
|
+
const options = requiredArray(dto.options, "OfferDetail.options");
|
|
747
|
+
const terms = requiredArray(dto.terms, "OfferDetail.terms");
|
|
748
|
+
const links = requiredArray(dto.links, "OfferDetail.links");
|
|
749
|
+
const faqs = requiredArray(dto.faqs, "OfferDetail.faqs");
|
|
750
|
+
const milestones = requiredArray(dto.milestones, "OfferDetail.milestones");
|
|
751
|
+
const tokens = requiredArray(dto.tokens, "OfferDetail.tokens");
|
|
693
752
|
const isin = notBlankStringOrNull(dto.isin);
|
|
694
753
|
const ticker = notBlankStringOrNull(dto.ticker);
|
|
695
|
-
|
|
754
|
+
const base2 = {
|
|
696
755
|
id: OfferId(dto.id),
|
|
697
756
|
slug: OfferSlug(dto.slug),
|
|
698
|
-
type: dto.type,
|
|
699
757
|
name: dto.name,
|
|
700
758
|
asset: Asset.fromDto(dto.asset),
|
|
701
|
-
fundingAssets:
|
|
702
|
-
tokens: OfferToken.listFromDto(
|
|
703
|
-
swapContracts: swapContracts.map(OfferSwapContract.fromDto),
|
|
759
|
+
fundingAssets: fundingAssets.map(Asset.fromDto),
|
|
760
|
+
tokens: OfferToken.listFromDto(tokens),
|
|
704
761
|
about: notBlankStringOrNull(dto.about),
|
|
705
|
-
tagline: dto.tagline,
|
|
706
|
-
bannerUrl: dto.banner_url,
|
|
707
|
-
logoUrl: dto.logo_url,
|
|
708
762
|
category: dto.category,
|
|
709
763
|
issuer: notBlankStringOrNull(dto.issuer),
|
|
710
764
|
isin: isin === null ? null : Isin(isin),
|
|
711
765
|
ticker: ticker === null ? null : Ticker(ticker),
|
|
712
766
|
instrumentType: notBlankStringOrNull(dto.instrument_type),
|
|
713
767
|
listingVenue: notBlankStringOrNull(dto.listing_venue),
|
|
714
|
-
startsAt: new Date(dto.starts_at),
|
|
715
768
|
endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
|
|
716
|
-
faqs:
|
|
717
|
-
links:
|
|
718
|
-
milestones:
|
|
719
|
-
options:
|
|
720
|
-
terms:
|
|
769
|
+
faqs: faqs.map(FaqItem.fromDto),
|
|
770
|
+
links: links.map(Link.fromDto),
|
|
771
|
+
milestones: milestones.map(Milestone.fromDto),
|
|
772
|
+
options: options.map(OfferOption.fromDto),
|
|
773
|
+
terms: terms.map(TermItem.fromDto)
|
|
721
774
|
};
|
|
775
|
+
switch (dto.type) {
|
|
776
|
+
case "coinlist::token_sale":
|
|
777
|
+
return {
|
|
778
|
+
...base2,
|
|
779
|
+
...OfferEditorial.fromDto(dto, "OfferDetail"),
|
|
780
|
+
type: dto.type,
|
|
781
|
+
logoUrl: requiredString(dto.logo_url, "OfferDetail.logo_url")
|
|
782
|
+
};
|
|
783
|
+
case "superstate::swap":
|
|
784
|
+
return {
|
|
785
|
+
...base2,
|
|
786
|
+
...OfferEditorial.fromDto(dto, "OfferDetail"),
|
|
787
|
+
type: dto.type,
|
|
788
|
+
logoUrl: notBlankStringOrNull(dto.logo_url)
|
|
789
|
+
};
|
|
790
|
+
// `tagline`, `banner_url` and `starts_at` arrive as `null` and are left
|
|
791
|
+
// on the wire, as in `Offer.fromDto`.
|
|
792
|
+
case "ondo::swap":
|
|
793
|
+
return {
|
|
794
|
+
...base2,
|
|
795
|
+
type: dto.type,
|
|
796
|
+
logoUrl: notBlankStringOrNull(dto.logo_url),
|
|
797
|
+
swapContracts: requiredArray(
|
|
798
|
+
dto.swap_contracts,
|
|
799
|
+
"OfferDetail.swap_contracts"
|
|
800
|
+
).map(OfferSwapContract.fromDto)
|
|
801
|
+
};
|
|
802
|
+
default:
|
|
803
|
+
return unknownTypeError(dto, "OfferDetail");
|
|
804
|
+
}
|
|
722
805
|
}
|
|
723
806
|
};
|
|
724
807
|
var OfferOption = {
|
|
@@ -841,6 +924,7 @@ async function createParticipation(api, params) {
|
|
|
841
924
|
}
|
|
842
925
|
|
|
843
926
|
// src/universal/core/shared/observability/log-cause.ts
|
|
927
|
+
var import_viem = require("viem");
|
|
844
928
|
function classifyLogCause(error) {
|
|
845
929
|
if (error instanceof HttpError) {
|
|
846
930
|
return httpCause(error);
|
|
@@ -860,8 +944,32 @@ function classifyLogCause(error) {
|
|
|
860
944
|
if (error instanceof NotImplementedError) {
|
|
861
945
|
return { type: "not-implemented" };
|
|
862
946
|
}
|
|
947
|
+
if (error instanceof import_viem.BaseError) {
|
|
948
|
+
const http = error.walk((e) => e instanceof HttpError);
|
|
949
|
+
if (http instanceof HttpError) {
|
|
950
|
+
return httpCause(http);
|
|
951
|
+
}
|
|
952
|
+
return { type: "rpc", reason: rpcFailureReason(error) };
|
|
953
|
+
}
|
|
863
954
|
return { type: "generic-error", name: errorName(error) };
|
|
864
955
|
}
|
|
956
|
+
function rpcFailureReason(error) {
|
|
957
|
+
if (error.walk((e) => e instanceof import_viem.ContractFunctionRevertedError)) {
|
|
958
|
+
return "reverted";
|
|
959
|
+
}
|
|
960
|
+
if (error.walk((e) => e instanceof import_viem.RpcError)) {
|
|
961
|
+
return "node-rejected";
|
|
962
|
+
}
|
|
963
|
+
if (error.walk(
|
|
964
|
+
(e) => e instanceof import_viem.HttpRequestError || e instanceof import_viem.WebSocketRequestError || e instanceof import_viem.SocketClosedError || e instanceof import_viem.TimeoutError
|
|
965
|
+
)) {
|
|
966
|
+
return "transport";
|
|
967
|
+
}
|
|
968
|
+
if (error instanceof import_viem.ContractFunctionExecutionError) {
|
|
969
|
+
return "malformed-response";
|
|
970
|
+
}
|
|
971
|
+
return "unknown";
|
|
972
|
+
}
|
|
865
973
|
function describeErrorUnredacted(error) {
|
|
866
974
|
if (error instanceof HttpError) {
|
|
867
975
|
return describeHttpErrorRedacted(error);
|
|
@@ -1086,7 +1194,7 @@ var TOKEN_REGISTRY = {
|
|
|
1086
1194
|
|
|
1087
1195
|
// src/universal/core/checkout/ondo/constants.ts
|
|
1088
1196
|
var ONDO_POLL_INTERVAL_MS = 15e3;
|
|
1089
|
-
var
|
|
1197
|
+
var ONDO_QUOTE_MAX_TTL_MS = 15e3;
|
|
1090
1198
|
var DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE = DecimalString("1000");
|
|
1091
1199
|
var ONDO_SETTLEMENT_ASSET = USDC_SYMBOL;
|
|
1092
1200
|
var DEFAULT_ONDO_SELL_TOKENS_TO_COMPUTE_PRICE = 1;
|
|
@@ -1109,6 +1217,9 @@ function computeOndoSellPrice(transaction) {
|
|
|
1109
1217
|
shares: spendInputAmount
|
|
1110
1218
|
});
|
|
1111
1219
|
}
|
|
1220
|
+
function ondoQuoteOfferDeadline(expiresAt, nowMs = Date.now()) {
|
|
1221
|
+
return new Date(Math.min(expiresAt.getTime(), nowMs + ONDO_QUOTE_MAX_TTL_MS));
|
|
1222
|
+
}
|
|
1112
1223
|
function grossProceeds(expected) {
|
|
1113
1224
|
const raw = expected.quantity.raw + expected.fee.raw;
|
|
1114
1225
|
if (raw > MAX_UINT_256) {
|
|
@@ -1135,7 +1246,7 @@ function assertPriceFits(raw) {
|
|
|
1135
1246
|
}
|
|
1136
1247
|
|
|
1137
1248
|
// src/universal/core/shared/blockchain/formatters.ts
|
|
1138
|
-
var
|
|
1249
|
+
var import_viem2 = require("viem");
|
|
1139
1250
|
|
|
1140
1251
|
// src/universal/types/blockchain/ui.ts
|
|
1141
1252
|
var FormattedAmountUi = (value) => value;
|
|
@@ -1201,7 +1312,7 @@ function roundFractionHalfUp(integerPart, fractionPart, maxFractionDigits) {
|
|
|
1201
1312
|
};
|
|
1202
1313
|
}
|
|
1203
1314
|
function formatRawAmount(amount) {
|
|
1204
|
-
return (0,
|
|
1315
|
+
return (0, import_viem2.formatUnits)(amount.raw, amount.decimals);
|
|
1205
1316
|
}
|
|
1206
1317
|
function formatCompactAmount(amount, locale) {
|
|
1207
1318
|
const value = Number(formatRawAmount(amount));
|
|
@@ -1240,18 +1351,22 @@ function formattedUsdPrice(amount, locale) {
|
|
|
1240
1351
|
}
|
|
1241
1352
|
|
|
1242
1353
|
// src/universal/core/shared/blockchain/chain.ts
|
|
1243
|
-
var
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1354
|
+
var import_chains = require("viem/chains");
|
|
1355
|
+
var VIEM_CHAINS = {
|
|
1356
|
+
ethereum_mainnet: import_chains.mainnet,
|
|
1357
|
+
ethereum_sepolia: import_chains.sepolia,
|
|
1358
|
+
base_mainnet: import_chains.base,
|
|
1359
|
+
base_sepolia: import_chains.baseSepolia
|
|
1248
1360
|
};
|
|
1361
|
+
function viemChain(chain) {
|
|
1362
|
+
return VIEM_CHAINS[chain];
|
|
1363
|
+
}
|
|
1249
1364
|
function getChainId(chain) {
|
|
1250
|
-
return
|
|
1365
|
+
return VIEM_CHAINS[chain].id;
|
|
1251
1366
|
}
|
|
1252
1367
|
function chainFromId(chainId) {
|
|
1253
|
-
const chains = Object.keys(
|
|
1254
|
-
const chain = chains.find((c) => String(
|
|
1368
|
+
const chains = Object.keys(VIEM_CHAINS);
|
|
1369
|
+
const chain = chains.find((c) => String(VIEM_CHAINS[c].id) === chainId);
|
|
1255
1370
|
if (!chain) {
|
|
1256
1371
|
throw new ValidationError(`Unsupported EIP-155 chain id: "${chainId}"`);
|
|
1257
1372
|
}
|
|
@@ -1294,7 +1409,7 @@ function explorerBaseUrl(chain) {
|
|
|
1294
1409
|
}
|
|
1295
1410
|
|
|
1296
1411
|
// src/universal/core/shared/blockchain/math.ts
|
|
1297
|
-
var
|
|
1412
|
+
var import_viem3 = require("viem");
|
|
1298
1413
|
function blockchainAmountFromRawOrThrow({
|
|
1299
1414
|
label,
|
|
1300
1415
|
raw,
|
|
@@ -1325,10 +1440,14 @@ function parseBlockchainAmount(amount, decimals) {
|
|
|
1325
1440
|
if (/[eE]/.test(trimmed)) {
|
|
1326
1441
|
return { valid: false, reason: { type: "invalid-format" } };
|
|
1327
1442
|
}
|
|
1328
|
-
if (
|
|
1443
|
+
if (trimmed === ".") {
|
|
1444
|
+
return { valid: false, reason: { type: "invalid-format" } };
|
|
1445
|
+
}
|
|
1446
|
+
const normalised = trimmed.replace(/^\./, "0.").replace(/\.$/, "");
|
|
1447
|
+
if (!/^\d+(\.\d+)?$/.test(normalised)) {
|
|
1329
1448
|
return { valid: false, reason: { type: "invalid-format" } };
|
|
1330
1449
|
}
|
|
1331
|
-
const [, fraction = ""] =
|
|
1450
|
+
const [, fraction = ""] = normalised.split(".");
|
|
1332
1451
|
if (fraction.length > decimals) {
|
|
1333
1452
|
return {
|
|
1334
1453
|
valid: false,
|
|
@@ -1336,7 +1455,7 @@ function parseBlockchainAmount(amount, decimals) {
|
|
|
1336
1455
|
};
|
|
1337
1456
|
}
|
|
1338
1457
|
try {
|
|
1339
|
-
const raw = (0,
|
|
1458
|
+
const raw = (0, import_viem3.parseUnits)(normalised, decimals);
|
|
1340
1459
|
if (raw > MAX_UINT_256) {
|
|
1341
1460
|
return { valid: false, reason: { type: "overflow" } };
|
|
1342
1461
|
}
|
|
@@ -1646,190 +1765,796 @@ var OndoNamespaceImpl = class {
|
|
|
1646
1765
|
var SUPERSTATE_SWAP_ABI = [
|
|
1647
1766
|
{
|
|
1648
1767
|
type: "function",
|
|
1649
|
-
name: "
|
|
1650
|
-
inputs: [
|
|
1651
|
-
outputs: [
|
|
1768
|
+
name: "KIND",
|
|
1769
|
+
inputs: [],
|
|
1770
|
+
outputs: [
|
|
1771
|
+
{
|
|
1772
|
+
name: "",
|
|
1773
|
+
type: "uint16",
|
|
1774
|
+
internalType: "uint16"
|
|
1775
|
+
}
|
|
1776
|
+
],
|
|
1652
1777
|
stateMutability: "view"
|
|
1653
1778
|
},
|
|
1654
1779
|
{
|
|
1655
1780
|
type: "function",
|
|
1656
|
-
name: "
|
|
1781
|
+
name: "ONE_HUNDRED_P",
|
|
1657
1782
|
inputs: [],
|
|
1658
|
-
outputs: [
|
|
1783
|
+
outputs: [
|
|
1784
|
+
{
|
|
1785
|
+
name: "",
|
|
1786
|
+
type: "uint256",
|
|
1787
|
+
internalType: "uint256"
|
|
1788
|
+
}
|
|
1789
|
+
],
|
|
1659
1790
|
stateMutability: "view"
|
|
1660
1791
|
},
|
|
1661
1792
|
{
|
|
1662
1793
|
type: "function",
|
|
1663
1794
|
name: "SWAP_LEVEL",
|
|
1664
1795
|
inputs: [],
|
|
1665
|
-
outputs: [
|
|
1796
|
+
outputs: [
|
|
1797
|
+
{
|
|
1798
|
+
name: "",
|
|
1799
|
+
type: "uint32",
|
|
1800
|
+
internalType: "uint32"
|
|
1801
|
+
}
|
|
1802
|
+
],
|
|
1666
1803
|
stateMutability: "view"
|
|
1667
1804
|
},
|
|
1668
1805
|
{
|
|
1669
1806
|
type: "function",
|
|
1670
|
-
name: "
|
|
1671
|
-
inputs: [
|
|
1672
|
-
{ name: "token", type: "address", internalType: "address" },
|
|
1673
|
-
{ name: "amount", type: "uint256", internalType: "uint256" }
|
|
1674
|
-
],
|
|
1807
|
+
name: "VERSION",
|
|
1808
|
+
inputs: [],
|
|
1675
1809
|
outputs: [
|
|
1676
1810
|
{
|
|
1677
1811
|
name: "",
|
|
1678
|
-
type: "
|
|
1679
|
-
internalType: "
|
|
1680
|
-
components: [
|
|
1681
|
-
{ name: "input", type: "uint256", internalType: "uint256" },
|
|
1682
|
-
{ name: "fee", type: "uint256", internalType: "uint256" },
|
|
1683
|
-
{ name: "output", type: "uint256", internalType: "uint256" }
|
|
1684
|
-
]
|
|
1812
|
+
type: "uint16",
|
|
1813
|
+
internalType: "uint16"
|
|
1685
1814
|
}
|
|
1686
1815
|
],
|
|
1687
1816
|
stateMutability: "view"
|
|
1688
1817
|
},
|
|
1689
1818
|
{
|
|
1690
1819
|
type: "function",
|
|
1691
|
-
name: "
|
|
1820
|
+
name: "authorized",
|
|
1692
1821
|
inputs: [
|
|
1693
|
-
{
|
|
1694
|
-
|
|
1695
|
-
|
|
1822
|
+
{
|
|
1823
|
+
name: "user",
|
|
1824
|
+
type: "address",
|
|
1825
|
+
internalType: "address"
|
|
1826
|
+
}
|
|
1696
1827
|
],
|
|
1697
|
-
outputs: [
|
|
1698
|
-
|
|
1828
|
+
outputs: [
|
|
1829
|
+
{
|
|
1830
|
+
name: "",
|
|
1831
|
+
type: "bool",
|
|
1832
|
+
internalType: "bool"
|
|
1833
|
+
}
|
|
1834
|
+
],
|
|
1835
|
+
stateMutability: "view"
|
|
1699
1836
|
},
|
|
1700
1837
|
{
|
|
1701
1838
|
type: "function",
|
|
1702
|
-
name: "
|
|
1703
|
-
inputs: [
|
|
1704
|
-
|
|
1839
|
+
name: "bpp",
|
|
1840
|
+
inputs: [
|
|
1841
|
+
{
|
|
1842
|
+
name: "amount",
|
|
1843
|
+
type: "uint256",
|
|
1844
|
+
internalType: "uint256"
|
|
1845
|
+
}
|
|
1846
|
+
],
|
|
1847
|
+
outputs: [
|
|
1848
|
+
{
|
|
1849
|
+
name: "",
|
|
1850
|
+
type: "uint256",
|
|
1851
|
+
internalType: "uint256"
|
|
1852
|
+
}
|
|
1853
|
+
],
|
|
1705
1854
|
stateMutability: "view"
|
|
1706
1855
|
},
|
|
1707
1856
|
{
|
|
1708
1857
|
type: "function",
|
|
1709
|
-
name: "
|
|
1858
|
+
name: "bps",
|
|
1710
1859
|
inputs: [],
|
|
1711
|
-
outputs: [
|
|
1860
|
+
outputs: [
|
|
1861
|
+
{
|
|
1862
|
+
name: "",
|
|
1863
|
+
type: "uint256",
|
|
1864
|
+
internalType: "uint256"
|
|
1865
|
+
}
|
|
1866
|
+
],
|
|
1712
1867
|
stateMutability: "view"
|
|
1713
1868
|
},
|
|
1714
1869
|
{
|
|
1715
1870
|
type: "function",
|
|
1716
|
-
name: "
|
|
1871
|
+
name: "cancelOwnershipHandover",
|
|
1717
1872
|
inputs: [],
|
|
1718
|
-
outputs: [
|
|
1719
|
-
stateMutability: "
|
|
1873
|
+
outputs: [],
|
|
1874
|
+
stateMutability: "payable"
|
|
1720
1875
|
},
|
|
1721
1876
|
{
|
|
1722
1877
|
type: "function",
|
|
1723
|
-
name: "
|
|
1724
|
-
inputs: [
|
|
1725
|
-
outputs: [
|
|
1878
|
+
name: "completeOwnershipHandover",
|
|
1879
|
+
inputs: [
|
|
1726
1880
|
{
|
|
1727
|
-
name: "",
|
|
1728
|
-
type: "
|
|
1729
|
-
internalType: "
|
|
1730
|
-
components: [
|
|
1731
|
-
{ name: "inputSum", type: "uint256", internalType: "uint256" },
|
|
1732
|
-
{ name: "feeSum", type: "uint256", internalType: "uint256" },
|
|
1733
|
-
{ name: "outputSum", type: "uint256", internalType: "uint256" },
|
|
1734
|
-
{ name: "count", type: "uint256", internalType: "uint256" }
|
|
1735
|
-
]
|
|
1881
|
+
name: "pendingOwner",
|
|
1882
|
+
type: "address",
|
|
1883
|
+
internalType: "address"
|
|
1736
1884
|
}
|
|
1737
1885
|
],
|
|
1738
|
-
|
|
1886
|
+
outputs: [],
|
|
1887
|
+
stateMutability: "payable"
|
|
1739
1888
|
},
|
|
1740
1889
|
{
|
|
1741
1890
|
type: "function",
|
|
1742
|
-
name: "
|
|
1891
|
+
name: "fee",
|
|
1743
1892
|
inputs: [
|
|
1744
|
-
{
|
|
1745
|
-
|
|
1893
|
+
{
|
|
1894
|
+
name: "amount",
|
|
1895
|
+
type: "uint256",
|
|
1896
|
+
internalType: "uint256"
|
|
1897
|
+
}
|
|
1746
1898
|
],
|
|
1747
1899
|
outputs: [
|
|
1748
1900
|
{
|
|
1749
1901
|
name: "",
|
|
1750
|
-
type: "
|
|
1751
|
-
internalType: "
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
]
|
|
1902
|
+
type: "uint256",
|
|
1903
|
+
internalType: "uint256"
|
|
1904
|
+
},
|
|
1905
|
+
{
|
|
1906
|
+
name: "",
|
|
1907
|
+
type: "uint256",
|
|
1908
|
+
internalType: "uint256"
|
|
1758
1909
|
}
|
|
1759
1910
|
],
|
|
1760
1911
|
stateMutability: "view"
|
|
1761
1912
|
},
|
|
1762
1913
|
{
|
|
1763
1914
|
type: "function",
|
|
1764
|
-
name: "
|
|
1765
|
-
inputs: [
|
|
1766
|
-
|
|
1767
|
-
{
|
|
1915
|
+
name: "id",
|
|
1916
|
+
inputs: [],
|
|
1917
|
+
outputs: [
|
|
1918
|
+
{
|
|
1919
|
+
name: "",
|
|
1920
|
+
type: "bytes32",
|
|
1921
|
+
internalType: "bytes32"
|
|
1922
|
+
}
|
|
1768
1923
|
],
|
|
1769
|
-
|
|
1770
|
-
stateMutability: "nonpayable"
|
|
1924
|
+
stateMutability: "view"
|
|
1771
1925
|
},
|
|
1772
1926
|
{
|
|
1773
1927
|
type: "function",
|
|
1774
|
-
name: "
|
|
1928
|
+
name: "inputTokens",
|
|
1775
1929
|
inputs: [
|
|
1776
|
-
{
|
|
1777
|
-
|
|
1778
|
-
|
|
1930
|
+
{
|
|
1931
|
+
name: "",
|
|
1932
|
+
type: "address",
|
|
1933
|
+
internalType: "address"
|
|
1934
|
+
}
|
|
1779
1935
|
],
|
|
1780
|
-
outputs: [
|
|
1781
|
-
|
|
1936
|
+
outputs: [
|
|
1937
|
+
{
|
|
1938
|
+
name: "",
|
|
1939
|
+
type: "bool",
|
|
1940
|
+
internalType: "bool"
|
|
1941
|
+
}
|
|
1942
|
+
],
|
|
1943
|
+
stateMutability: "view"
|
|
1782
1944
|
},
|
|
1783
1945
|
{
|
|
1784
1946
|
type: "function",
|
|
1785
|
-
name: "
|
|
1786
|
-
inputs: [
|
|
1787
|
-
outputs: [
|
|
1788
|
-
stateMutability: "nonpayable"
|
|
1789
|
-
},
|
|
1790
|
-
{
|
|
1791
|
-
type: "event",
|
|
1792
|
-
name: "Swapped",
|
|
1793
|
-
inputs: [
|
|
1794
|
-
{ name: "user", type: "address", indexed: true, internalType: "address" },
|
|
1795
|
-
{
|
|
1796
|
-
name: "inputToken",
|
|
1797
|
-
type: "address",
|
|
1798
|
-
indexed: true,
|
|
1799
|
-
internalType: "address"
|
|
1800
|
-
},
|
|
1947
|
+
name: "outputToken",
|
|
1948
|
+
inputs: [],
|
|
1949
|
+
outputs: [
|
|
1801
1950
|
{
|
|
1802
|
-
name: "
|
|
1951
|
+
name: "",
|
|
1803
1952
|
type: "address",
|
|
1804
|
-
indexed: true,
|
|
1805
1953
|
internalType: "address"
|
|
1806
|
-
}
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1954
|
+
}
|
|
1955
|
+
],
|
|
1956
|
+
stateMutability: "view"
|
|
1957
|
+
},
|
|
1958
|
+
{
|
|
1959
|
+
type: "function",
|
|
1960
|
+
name: "outputTokenBalance",
|
|
1961
|
+
inputs: [],
|
|
1962
|
+
outputs: [
|
|
1813
1963
|
{
|
|
1814
|
-
name: "
|
|
1964
|
+
name: "",
|
|
1815
1965
|
type: "uint256",
|
|
1816
|
-
indexed: false,
|
|
1817
1966
|
internalType: "uint256"
|
|
1818
1967
|
}
|
|
1819
1968
|
],
|
|
1820
|
-
|
|
1969
|
+
stateMutability: "view"
|
|
1821
1970
|
},
|
|
1822
1971
|
{
|
|
1823
|
-
type: "
|
|
1824
|
-
name: "
|
|
1825
|
-
inputs: [
|
|
1826
|
-
|
|
1972
|
+
type: "function",
|
|
1973
|
+
name: "owner",
|
|
1974
|
+
inputs: [],
|
|
1975
|
+
outputs: [
|
|
1827
1976
|
{
|
|
1828
|
-
name: "
|
|
1977
|
+
name: "result",
|
|
1829
1978
|
type: "address",
|
|
1830
|
-
indexed: true,
|
|
1831
1979
|
internalType: "address"
|
|
1832
|
-
}
|
|
1980
|
+
}
|
|
1981
|
+
],
|
|
1982
|
+
stateMutability: "view"
|
|
1983
|
+
},
|
|
1984
|
+
{
|
|
1985
|
+
type: "function",
|
|
1986
|
+
name: "ownershipHandoverExpiresAt",
|
|
1987
|
+
inputs: [
|
|
1988
|
+
{
|
|
1989
|
+
name: "pendingOwner",
|
|
1990
|
+
type: "address",
|
|
1991
|
+
internalType: "address"
|
|
1992
|
+
}
|
|
1993
|
+
],
|
|
1994
|
+
outputs: [
|
|
1995
|
+
{
|
|
1996
|
+
name: "result",
|
|
1997
|
+
type: "uint256",
|
|
1998
|
+
internalType: "uint256"
|
|
1999
|
+
}
|
|
2000
|
+
],
|
|
2001
|
+
stateMutability: "view"
|
|
2002
|
+
},
|
|
2003
|
+
{
|
|
2004
|
+
type: "function",
|
|
2005
|
+
name: "pause",
|
|
2006
|
+
inputs: [
|
|
2007
|
+
{
|
|
2008
|
+
name: "level",
|
|
2009
|
+
type: "uint32",
|
|
2010
|
+
internalType: "uint32"
|
|
2011
|
+
}
|
|
2012
|
+
],
|
|
2013
|
+
outputs: [
|
|
2014
|
+
{
|
|
2015
|
+
name: "",
|
|
2016
|
+
type: "bool",
|
|
2017
|
+
internalType: "bool"
|
|
2018
|
+
}
|
|
2019
|
+
],
|
|
2020
|
+
stateMutability: "nonpayable"
|
|
2021
|
+
},
|
|
2022
|
+
{
|
|
2023
|
+
type: "function",
|
|
2024
|
+
name: "paused",
|
|
2025
|
+
inputs: [],
|
|
2026
|
+
outputs: [
|
|
2027
|
+
{
|
|
2028
|
+
name: "",
|
|
2029
|
+
type: "uint32",
|
|
2030
|
+
internalType: "uint32"
|
|
2031
|
+
}
|
|
2032
|
+
],
|
|
2033
|
+
stateMutability: "view"
|
|
2034
|
+
},
|
|
2035
|
+
{
|
|
2036
|
+
type: "function",
|
|
2037
|
+
name: "preview",
|
|
2038
|
+
inputs: [
|
|
2039
|
+
{
|
|
2040
|
+
name: "token",
|
|
2041
|
+
type: "address",
|
|
2042
|
+
internalType: "address"
|
|
2043
|
+
},
|
|
2044
|
+
{
|
|
2045
|
+
name: "amount",
|
|
2046
|
+
type: "uint256",
|
|
2047
|
+
internalType: "uint256"
|
|
2048
|
+
}
|
|
2049
|
+
],
|
|
2050
|
+
outputs: [
|
|
2051
|
+
{
|
|
2052
|
+
name: "",
|
|
2053
|
+
type: "tuple",
|
|
2054
|
+
internalType: "struct Preview",
|
|
2055
|
+
components: [
|
|
2056
|
+
{
|
|
2057
|
+
name: "input",
|
|
2058
|
+
type: "uint256",
|
|
2059
|
+
internalType: "uint256"
|
|
2060
|
+
},
|
|
2061
|
+
{
|
|
2062
|
+
name: "fee",
|
|
2063
|
+
type: "uint256",
|
|
2064
|
+
internalType: "uint256"
|
|
2065
|
+
},
|
|
2066
|
+
{
|
|
2067
|
+
name: "output",
|
|
2068
|
+
type: "uint256",
|
|
2069
|
+
internalType: "uint256"
|
|
2070
|
+
}
|
|
2071
|
+
]
|
|
2072
|
+
}
|
|
2073
|
+
],
|
|
2074
|
+
stateMutability: "view"
|
|
2075
|
+
},
|
|
2076
|
+
{
|
|
2077
|
+
type: "function",
|
|
2078
|
+
name: "renounceOwnership",
|
|
2079
|
+
inputs: [],
|
|
2080
|
+
outputs: [],
|
|
2081
|
+
stateMutability: "payable"
|
|
2082
|
+
},
|
|
2083
|
+
{
|
|
2084
|
+
type: "function",
|
|
2085
|
+
name: "requestOwnershipHandover",
|
|
2086
|
+
inputs: [],
|
|
2087
|
+
outputs: [],
|
|
2088
|
+
stateMutability: "payable"
|
|
2089
|
+
},
|
|
2090
|
+
{
|
|
2091
|
+
type: "function",
|
|
2092
|
+
name: "setBps",
|
|
2093
|
+
inputs: [
|
|
2094
|
+
{
|
|
2095
|
+
name: "points",
|
|
2096
|
+
type: "uint256",
|
|
2097
|
+
internalType: "uint256"
|
|
2098
|
+
}
|
|
2099
|
+
],
|
|
2100
|
+
outputs: [
|
|
2101
|
+
{
|
|
2102
|
+
name: "",
|
|
2103
|
+
type: "bool",
|
|
2104
|
+
internalType: "bool"
|
|
2105
|
+
}
|
|
2106
|
+
],
|
|
2107
|
+
stateMutability: "nonpayable"
|
|
2108
|
+
},
|
|
2109
|
+
{
|
|
2110
|
+
type: "function",
|
|
2111
|
+
name: "setInputToken",
|
|
2112
|
+
inputs: [
|
|
2113
|
+
{
|
|
2114
|
+
name: "token",
|
|
2115
|
+
type: "address",
|
|
2116
|
+
internalType: "address"
|
|
2117
|
+
},
|
|
2118
|
+
{
|
|
2119
|
+
name: "val",
|
|
2120
|
+
type: "bool",
|
|
2121
|
+
internalType: "bool"
|
|
2122
|
+
}
|
|
2123
|
+
],
|
|
2124
|
+
outputs: [
|
|
2125
|
+
{
|
|
2126
|
+
name: "",
|
|
2127
|
+
type: "bool",
|
|
2128
|
+
internalType: "bool"
|
|
2129
|
+
}
|
|
2130
|
+
],
|
|
2131
|
+
stateMutability: "nonpayable"
|
|
2132
|
+
},
|
|
2133
|
+
{
|
|
2134
|
+
type: "function",
|
|
2135
|
+
name: "status",
|
|
2136
|
+
inputs: [],
|
|
2137
|
+
outputs: [
|
|
2138
|
+
{
|
|
2139
|
+
name: "",
|
|
2140
|
+
type: "tuple",
|
|
2141
|
+
internalType: "struct Status",
|
|
2142
|
+
components: [
|
|
2143
|
+
{
|
|
2144
|
+
name: "flags",
|
|
2145
|
+
type: "uint32",
|
|
2146
|
+
internalType: "uint32"
|
|
2147
|
+
},
|
|
2148
|
+
{
|
|
2149
|
+
name: "state",
|
|
2150
|
+
type: "uint8",
|
|
2151
|
+
internalType: "enum State"
|
|
2152
|
+
}
|
|
2153
|
+
]
|
|
2154
|
+
}
|
|
2155
|
+
],
|
|
2156
|
+
stateMutability: "view"
|
|
2157
|
+
},
|
|
2158
|
+
{
|
|
2159
|
+
type: "function",
|
|
2160
|
+
name: "stop",
|
|
2161
|
+
inputs: [],
|
|
2162
|
+
outputs: [
|
|
2163
|
+
{
|
|
2164
|
+
name: "",
|
|
2165
|
+
type: "bool",
|
|
2166
|
+
internalType: "bool"
|
|
2167
|
+
}
|
|
2168
|
+
],
|
|
2169
|
+
stateMutability: "nonpayable"
|
|
2170
|
+
},
|
|
2171
|
+
{
|
|
2172
|
+
type: "function",
|
|
2173
|
+
name: "stopped",
|
|
2174
|
+
inputs: [],
|
|
2175
|
+
outputs: [
|
|
2176
|
+
{
|
|
2177
|
+
name: "",
|
|
2178
|
+
type: "bool",
|
|
2179
|
+
internalType: "bool"
|
|
2180
|
+
}
|
|
2181
|
+
],
|
|
2182
|
+
stateMutability: "view"
|
|
2183
|
+
},
|
|
2184
|
+
{
|
|
2185
|
+
type: "function",
|
|
2186
|
+
name: "swap",
|
|
2187
|
+
inputs: [
|
|
2188
|
+
{
|
|
2189
|
+
name: "token",
|
|
2190
|
+
type: "address",
|
|
2191
|
+
internalType: "address"
|
|
2192
|
+
},
|
|
2193
|
+
{
|
|
2194
|
+
name: "amount",
|
|
2195
|
+
type: "uint256",
|
|
2196
|
+
internalType: "uint256"
|
|
2197
|
+
},
|
|
2198
|
+
{
|
|
2199
|
+
name: "slip",
|
|
2200
|
+
type: "uint256",
|
|
2201
|
+
internalType: "uint256"
|
|
2202
|
+
}
|
|
2203
|
+
],
|
|
2204
|
+
outputs: [
|
|
2205
|
+
{
|
|
2206
|
+
name: "",
|
|
2207
|
+
type: "uint256",
|
|
2208
|
+
internalType: "uint256"
|
|
2209
|
+
}
|
|
2210
|
+
],
|
|
2211
|
+
stateMutability: "nonpayable"
|
|
2212
|
+
},
|
|
2213
|
+
{
|
|
2214
|
+
type: "function",
|
|
2215
|
+
name: "tokenBalance",
|
|
2216
|
+
inputs: [
|
|
2217
|
+
{
|
|
2218
|
+
name: "token",
|
|
2219
|
+
type: "address",
|
|
2220
|
+
internalType: "address"
|
|
2221
|
+
}
|
|
2222
|
+
],
|
|
2223
|
+
outputs: [
|
|
2224
|
+
{
|
|
2225
|
+
name: "",
|
|
2226
|
+
type: "uint256",
|
|
2227
|
+
internalType: "uint256"
|
|
2228
|
+
}
|
|
2229
|
+
],
|
|
2230
|
+
stateMutability: "view"
|
|
2231
|
+
},
|
|
2232
|
+
{
|
|
2233
|
+
type: "function",
|
|
2234
|
+
name: "totals",
|
|
2235
|
+
inputs: [
|
|
2236
|
+
{
|
|
2237
|
+
name: "user",
|
|
2238
|
+
type: "address",
|
|
2239
|
+
internalType: "address"
|
|
2240
|
+
},
|
|
2241
|
+
{
|
|
2242
|
+
name: "token",
|
|
2243
|
+
type: "address",
|
|
2244
|
+
internalType: "address"
|
|
2245
|
+
}
|
|
2246
|
+
],
|
|
2247
|
+
outputs: [
|
|
2248
|
+
{
|
|
2249
|
+
name: "",
|
|
2250
|
+
type: "tuple",
|
|
2251
|
+
internalType: "struct SwapTotal",
|
|
2252
|
+
components: [
|
|
2253
|
+
{
|
|
2254
|
+
name: "inputSum",
|
|
2255
|
+
type: "uint256",
|
|
2256
|
+
internalType: "uint256"
|
|
2257
|
+
},
|
|
2258
|
+
{
|
|
2259
|
+
name: "feeSum",
|
|
2260
|
+
type: "uint256",
|
|
2261
|
+
internalType: "uint256"
|
|
2262
|
+
},
|
|
2263
|
+
{
|
|
2264
|
+
name: "outputSum",
|
|
2265
|
+
type: "uint256",
|
|
2266
|
+
internalType: "uint256"
|
|
2267
|
+
},
|
|
2268
|
+
{
|
|
2269
|
+
name: "count",
|
|
2270
|
+
type: "uint256",
|
|
2271
|
+
internalType: "uint256"
|
|
2272
|
+
}
|
|
2273
|
+
]
|
|
2274
|
+
}
|
|
2275
|
+
],
|
|
2276
|
+
stateMutability: "view"
|
|
2277
|
+
},
|
|
2278
|
+
{
|
|
2279
|
+
type: "function",
|
|
2280
|
+
name: "totals",
|
|
2281
|
+
inputs: [
|
|
2282
|
+
{
|
|
2283
|
+
name: "token",
|
|
2284
|
+
type: "address",
|
|
2285
|
+
internalType: "address"
|
|
2286
|
+
}
|
|
2287
|
+
],
|
|
2288
|
+
outputs: [
|
|
2289
|
+
{
|
|
2290
|
+
name: "",
|
|
2291
|
+
type: "tuple",
|
|
2292
|
+
internalType: "struct SwapTotal",
|
|
2293
|
+
components: [
|
|
2294
|
+
{
|
|
2295
|
+
name: "inputSum",
|
|
2296
|
+
type: "uint256",
|
|
2297
|
+
internalType: "uint256"
|
|
2298
|
+
},
|
|
2299
|
+
{
|
|
2300
|
+
name: "feeSum",
|
|
2301
|
+
type: "uint256",
|
|
2302
|
+
internalType: "uint256"
|
|
2303
|
+
},
|
|
2304
|
+
{
|
|
2305
|
+
name: "outputSum",
|
|
2306
|
+
type: "uint256",
|
|
2307
|
+
internalType: "uint256"
|
|
2308
|
+
},
|
|
2309
|
+
{
|
|
2310
|
+
name: "count",
|
|
2311
|
+
type: "uint256",
|
|
2312
|
+
internalType: "uint256"
|
|
2313
|
+
}
|
|
2314
|
+
]
|
|
2315
|
+
}
|
|
2316
|
+
],
|
|
2317
|
+
stateMutability: "view"
|
|
2318
|
+
},
|
|
2319
|
+
{
|
|
2320
|
+
type: "function",
|
|
2321
|
+
name: "transfer",
|
|
2322
|
+
inputs: [
|
|
2323
|
+
{
|
|
2324
|
+
name: "to",
|
|
2325
|
+
type: "address",
|
|
2326
|
+
internalType: "address"
|
|
2327
|
+
},
|
|
2328
|
+
{
|
|
2329
|
+
name: "amount",
|
|
2330
|
+
type: "uint256",
|
|
2331
|
+
internalType: "uint256"
|
|
2332
|
+
}
|
|
2333
|
+
],
|
|
2334
|
+
outputs: [
|
|
2335
|
+
{
|
|
2336
|
+
name: "",
|
|
2337
|
+
type: "bool",
|
|
2338
|
+
internalType: "bool"
|
|
2339
|
+
}
|
|
2340
|
+
],
|
|
2341
|
+
stateMutability: "nonpayable"
|
|
2342
|
+
},
|
|
2343
|
+
{
|
|
2344
|
+
type: "function",
|
|
2345
|
+
name: "transfer",
|
|
2346
|
+
inputs: [
|
|
2347
|
+
{
|
|
2348
|
+
name: "to",
|
|
2349
|
+
type: "address",
|
|
2350
|
+
internalType: "address"
|
|
2351
|
+
},
|
|
2352
|
+
{
|
|
2353
|
+
name: "token",
|
|
2354
|
+
type: "address",
|
|
2355
|
+
internalType: "address"
|
|
2356
|
+
},
|
|
2357
|
+
{
|
|
2358
|
+
name: "amount",
|
|
2359
|
+
type: "uint256",
|
|
2360
|
+
internalType: "uint256"
|
|
2361
|
+
}
|
|
2362
|
+
],
|
|
2363
|
+
outputs: [
|
|
2364
|
+
{
|
|
2365
|
+
name: "",
|
|
2366
|
+
type: "bool",
|
|
2367
|
+
internalType: "bool"
|
|
2368
|
+
}
|
|
2369
|
+
],
|
|
2370
|
+
stateMutability: "nonpayable"
|
|
2371
|
+
},
|
|
2372
|
+
{
|
|
2373
|
+
type: "function",
|
|
2374
|
+
name: "transferOwnership",
|
|
2375
|
+
inputs: [
|
|
2376
|
+
{
|
|
2377
|
+
name: "newOwner",
|
|
2378
|
+
type: "address",
|
|
2379
|
+
internalType: "address"
|
|
2380
|
+
}
|
|
2381
|
+
],
|
|
2382
|
+
outputs: [],
|
|
2383
|
+
stateMutability: "payable"
|
|
2384
|
+
},
|
|
2385
|
+
{
|
|
2386
|
+
type: "event",
|
|
2387
|
+
name: "BpsUpdated",
|
|
2388
|
+
inputs: [
|
|
2389
|
+
{
|
|
2390
|
+
name: "prev",
|
|
2391
|
+
type: "uint256",
|
|
2392
|
+
indexed: false,
|
|
2393
|
+
internalType: "uint256"
|
|
2394
|
+
},
|
|
2395
|
+
{
|
|
2396
|
+
name: "next",
|
|
2397
|
+
type: "uint256",
|
|
2398
|
+
indexed: false,
|
|
2399
|
+
internalType: "uint256"
|
|
2400
|
+
}
|
|
2401
|
+
],
|
|
2402
|
+
anonymous: false
|
|
2403
|
+
},
|
|
2404
|
+
{
|
|
2405
|
+
type: "event",
|
|
2406
|
+
name: "InputTokenUpdated",
|
|
2407
|
+
inputs: [
|
|
2408
|
+
{
|
|
2409
|
+
name: "token",
|
|
2410
|
+
type: "address",
|
|
2411
|
+
indexed: true,
|
|
2412
|
+
internalType: "address"
|
|
2413
|
+
},
|
|
2414
|
+
{
|
|
2415
|
+
name: "prev",
|
|
2416
|
+
type: "bool",
|
|
2417
|
+
indexed: false,
|
|
2418
|
+
internalType: "bool"
|
|
2419
|
+
},
|
|
2420
|
+
{
|
|
2421
|
+
name: "next",
|
|
2422
|
+
type: "bool",
|
|
2423
|
+
indexed: false,
|
|
2424
|
+
internalType: "bool"
|
|
2425
|
+
}
|
|
2426
|
+
],
|
|
2427
|
+
anonymous: false
|
|
2428
|
+
},
|
|
2429
|
+
{
|
|
2430
|
+
type: "event",
|
|
2431
|
+
name: "OwnershipHandoverCanceled",
|
|
2432
|
+
inputs: [
|
|
2433
|
+
{
|
|
2434
|
+
name: "pendingOwner",
|
|
2435
|
+
type: "address",
|
|
2436
|
+
indexed: true,
|
|
2437
|
+
internalType: "address"
|
|
2438
|
+
}
|
|
2439
|
+
],
|
|
2440
|
+
anonymous: false
|
|
2441
|
+
},
|
|
2442
|
+
{
|
|
2443
|
+
type: "event",
|
|
2444
|
+
name: "OwnershipHandoverRequested",
|
|
2445
|
+
inputs: [
|
|
2446
|
+
{
|
|
2447
|
+
name: "pendingOwner",
|
|
2448
|
+
type: "address",
|
|
2449
|
+
indexed: true,
|
|
2450
|
+
internalType: "address"
|
|
2451
|
+
}
|
|
2452
|
+
],
|
|
2453
|
+
anonymous: false
|
|
2454
|
+
},
|
|
2455
|
+
{
|
|
2456
|
+
type: "event",
|
|
2457
|
+
name: "OwnershipTransferred",
|
|
2458
|
+
inputs: [
|
|
2459
|
+
{
|
|
2460
|
+
name: "oldOwner",
|
|
2461
|
+
type: "address",
|
|
2462
|
+
indexed: true,
|
|
2463
|
+
internalType: "address"
|
|
2464
|
+
},
|
|
2465
|
+
{
|
|
2466
|
+
name: "newOwner",
|
|
2467
|
+
type: "address",
|
|
2468
|
+
indexed: true,
|
|
2469
|
+
internalType: "address"
|
|
2470
|
+
}
|
|
2471
|
+
],
|
|
2472
|
+
anonymous: false
|
|
2473
|
+
},
|
|
2474
|
+
{
|
|
2475
|
+
type: "event",
|
|
2476
|
+
name: "Paused",
|
|
2477
|
+
inputs: [
|
|
2478
|
+
{
|
|
2479
|
+
name: "previous",
|
|
2480
|
+
type: "uint32",
|
|
2481
|
+
indexed: false,
|
|
2482
|
+
internalType: "uint32"
|
|
2483
|
+
},
|
|
2484
|
+
{
|
|
2485
|
+
name: "next",
|
|
2486
|
+
type: "uint32",
|
|
2487
|
+
indexed: false,
|
|
2488
|
+
internalType: "uint32"
|
|
2489
|
+
}
|
|
2490
|
+
],
|
|
2491
|
+
anonymous: false
|
|
2492
|
+
},
|
|
2493
|
+
{
|
|
2494
|
+
type: "event",
|
|
2495
|
+
name: "Stopped",
|
|
2496
|
+
inputs: [],
|
|
2497
|
+
anonymous: false
|
|
2498
|
+
},
|
|
2499
|
+
{
|
|
2500
|
+
type: "event",
|
|
2501
|
+
name: "Swapped",
|
|
2502
|
+
inputs: [
|
|
2503
|
+
{
|
|
2504
|
+
name: "user",
|
|
2505
|
+
type: "address",
|
|
2506
|
+
indexed: true,
|
|
2507
|
+
internalType: "address"
|
|
2508
|
+
},
|
|
2509
|
+
{
|
|
2510
|
+
name: "inputToken",
|
|
2511
|
+
type: "address",
|
|
2512
|
+
indexed: true,
|
|
2513
|
+
internalType: "address"
|
|
2514
|
+
},
|
|
2515
|
+
{
|
|
2516
|
+
name: "outputToken",
|
|
2517
|
+
type: "address",
|
|
2518
|
+
indexed: true,
|
|
2519
|
+
internalType: "address"
|
|
2520
|
+
},
|
|
2521
|
+
{
|
|
2522
|
+
name: "inputAmount",
|
|
2523
|
+
type: "uint256",
|
|
2524
|
+
indexed: false,
|
|
2525
|
+
internalType: "uint256"
|
|
2526
|
+
},
|
|
2527
|
+
{
|
|
2528
|
+
name: "fee",
|
|
2529
|
+
type: "uint256",
|
|
2530
|
+
indexed: false,
|
|
2531
|
+
internalType: "uint256"
|
|
2532
|
+
},
|
|
2533
|
+
{
|
|
2534
|
+
name: "outputAmount",
|
|
2535
|
+
type: "uint256",
|
|
2536
|
+
indexed: false,
|
|
2537
|
+
internalType: "uint256"
|
|
2538
|
+
}
|
|
2539
|
+
],
|
|
2540
|
+
anonymous: false
|
|
2541
|
+
},
|
|
2542
|
+
{
|
|
2543
|
+
type: "event",
|
|
2544
|
+
name: "Transferred",
|
|
2545
|
+
inputs: [
|
|
2546
|
+
{
|
|
2547
|
+
name: "to",
|
|
2548
|
+
type: "address",
|
|
2549
|
+
indexed: true,
|
|
2550
|
+
internalType: "address"
|
|
2551
|
+
},
|
|
2552
|
+
{
|
|
2553
|
+
name: "token",
|
|
2554
|
+
type: "address",
|
|
2555
|
+
indexed: true,
|
|
2556
|
+
internalType: "address"
|
|
2557
|
+
},
|
|
1833
2558
|
{
|
|
1834
2559
|
name: "amount",
|
|
1835
2560
|
type: "uint256",
|
|
@@ -1841,7 +2566,7 @@ var SUPERSTATE_SWAP_ABI = [
|
|
|
1841
2566
|
},
|
|
1842
2567
|
{
|
|
1843
2568
|
type: "error",
|
|
1844
|
-
name: "
|
|
2569
|
+
name: "AlreadyInitialized",
|
|
1845
2570
|
inputs: []
|
|
1846
2571
|
},
|
|
1847
2572
|
{
|
|
@@ -1849,18 +2574,62 @@ var SUPERSTATE_SWAP_ABI = [
|
|
|
1849
2574
|
name: "InsufficientAmount",
|
|
1850
2575
|
inputs: []
|
|
1851
2576
|
},
|
|
2577
|
+
{
|
|
2578
|
+
type: "error",
|
|
2579
|
+
name: "InvalidAddress",
|
|
2580
|
+
inputs: []
|
|
2581
|
+
},
|
|
1852
2582
|
{
|
|
1853
2583
|
type: "error",
|
|
1854
2584
|
name: "InvalidAmount",
|
|
1855
2585
|
inputs: []
|
|
1856
2586
|
},
|
|
2587
|
+
{
|
|
2588
|
+
type: "error",
|
|
2589
|
+
name: "IsPaused",
|
|
2590
|
+
inputs: [
|
|
2591
|
+
{
|
|
2592
|
+
name: "level",
|
|
2593
|
+
type: "uint32",
|
|
2594
|
+
internalType: "uint32"
|
|
2595
|
+
}
|
|
2596
|
+
]
|
|
2597
|
+
},
|
|
2598
|
+
{
|
|
2599
|
+
type: "error",
|
|
2600
|
+
name: "IsStopped",
|
|
2601
|
+
inputs: []
|
|
2602
|
+
},
|
|
2603
|
+
{
|
|
2604
|
+
type: "error",
|
|
2605
|
+
name: "NewOwnerIsZeroAddress",
|
|
2606
|
+
inputs: []
|
|
2607
|
+
},
|
|
2608
|
+
{
|
|
2609
|
+
type: "error",
|
|
2610
|
+
name: "NoHandoverRequest",
|
|
2611
|
+
inputs: []
|
|
2612
|
+
},
|
|
1857
2613
|
{
|
|
1858
2614
|
type: "error",
|
|
1859
2615
|
name: "SwapFailed",
|
|
1860
2616
|
inputs: [
|
|
1861
|
-
{
|
|
1862
|
-
|
|
2617
|
+
{
|
|
2618
|
+
name: "user",
|
|
2619
|
+
type: "address",
|
|
2620
|
+
internalType: "address"
|
|
2621
|
+
},
|
|
2622
|
+
{
|
|
2623
|
+
name: "token",
|
|
2624
|
+
type: "address",
|
|
2625
|
+
internalType: "address"
|
|
2626
|
+
}
|
|
1863
2627
|
]
|
|
2628
|
+
},
|
|
2629
|
+
{
|
|
2630
|
+
type: "error",
|
|
2631
|
+
name: "Unauthorized",
|
|
2632
|
+
inputs: []
|
|
1864
2633
|
}
|
|
1865
2634
|
];
|
|
1866
2635
|
|
|
@@ -1909,15 +2678,27 @@ var SwapQuote = {
|
|
|
1909
2678
|
};
|
|
1910
2679
|
|
|
1911
2680
|
// src/universal/core/checkout/superstate/blockchain/status.ts
|
|
1912
|
-
|
|
1913
|
-
|
|
2681
|
+
var SWAP_LEVEL = 2;
|
|
2682
|
+
function isSwapAvailable(status) {
|
|
2683
|
+
switch (status.state) {
|
|
2684
|
+
case "active":
|
|
2685
|
+
return true;
|
|
2686
|
+
case "stopped":
|
|
2687
|
+
return false;
|
|
2688
|
+
case "paused":
|
|
2689
|
+
return (status.pausedLevels & SWAP_LEVEL) === 0;
|
|
2690
|
+
default: {
|
|
2691
|
+
const _exhaustive = status;
|
|
2692
|
+
return _exhaustive;
|
|
2693
|
+
}
|
|
2694
|
+
}
|
|
1914
2695
|
}
|
|
1915
2696
|
|
|
1916
2697
|
// src/universal/core/checkout/superstate/blockchain/swapped-event.ts
|
|
1917
|
-
var
|
|
2698
|
+
var import_viem4 = require("viem");
|
|
1918
2699
|
function decodeSwappedOutputAmount(receipt, outputDecimals) {
|
|
1919
2700
|
try {
|
|
1920
|
-
const [swapped] = (0,
|
|
2701
|
+
const [swapped] = (0, import_viem4.parseEventLogs)({
|
|
1921
2702
|
abi: SUPERSTATE_SWAP_ABI,
|
|
1922
2703
|
eventName: "Swapped",
|
|
1923
2704
|
logs: receipt.logs
|
|
@@ -1940,7 +2721,7 @@ var SLIPPAGE_OPTIONS_BPS = [25n, 50n, 100n, 200n, 500n].map(
|
|
|
1940
2721
|
(n) => Bps(n)
|
|
1941
2722
|
);
|
|
1942
2723
|
var DEFAULT_SLIPPAGE_BPS = Bps(50n);
|
|
1943
|
-
var SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA = EvmContractAddress("
|
|
2724
|
+
var SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA = EvmContractAddress("0x27E8CE9Ca1A1E98Bc4009F08Dc596bFcf88aCED1");
|
|
1944
2725
|
var SUPERSTATE_SWAP_CONTRACT_ADDRESSES = {
|
|
1945
2726
|
ethereum_sepolia: SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA
|
|
1946
2727
|
};
|
|
@@ -1955,39 +2736,42 @@ function formattedPricePerShare(quote, locale) {
|
|
|
1955
2736
|
}
|
|
1956
2737
|
|
|
1957
2738
|
// src/universal/types/providers/superstate/swap.ts
|
|
1958
|
-
var SwapAuthorization = {
|
|
1959
|
-
fromDto: (dto) => ({
|
|
1960
|
-
authorized: dto.authorized
|
|
1961
|
-
})
|
|
1962
|
-
};
|
|
1963
2739
|
var SwapPreview = {
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
)
|
|
1969
|
-
fee: parseUint256(BigInt(dto.fee), "SwapPreview.fee"),
|
|
1970
|
-
outputAmount: parseUint256(
|
|
1971
|
-
BigInt(dto.receive_output_amount),
|
|
1972
|
-
"SwapPreview.receive_output_amount"
|
|
1973
|
-
)
|
|
2740
|
+
/** Maps the contract's `Preview { input, fee, output }` struct. */
|
|
2741
|
+
fromContract: (preview) => ({
|
|
2742
|
+
inputAmount: parseUint256(preview.input, "SwapPreview.input"),
|
|
2743
|
+
fee: parseUint256(preview.fee, "SwapPreview.fee"),
|
|
2744
|
+
outputAmount: parseUint256(preview.output, "SwapPreview.output")
|
|
1974
2745
|
})
|
|
1975
2746
|
};
|
|
2747
|
+
var PauseFlags = (value) => value;
|
|
1976
2748
|
var SwapStatus = {
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
2749
|
+
/**
|
|
2750
|
+
* Maps the contract's `Status { uint32 flags; State state }` struct, where
|
|
2751
|
+
* `State` is `0 = Active | 1 = Paused | 2 = Stopped`.
|
|
2752
|
+
*
|
|
2753
|
+
* `flags` is carried onto the `paused` arm only. On the other two the
|
|
2754
|
+
* contract sets it to a self-identifying marker rather than to information -
|
|
2755
|
+
* so repeating it would invite a caller to read meaning into a constant.
|
|
2756
|
+
*
|
|
2757
|
+
* @throws ValidationError on a `state` outside the enum. A contract that has
|
|
2758
|
+
* grown a fourth state is one the SDK does not model, and guessing `active`
|
|
2759
|
+
* would let a halted swap read as a live one.
|
|
2760
|
+
*/
|
|
2761
|
+
fromContract: (status) => {
|
|
2762
|
+
switch (status.state) {
|
|
2763
|
+
case 0:
|
|
2764
|
+
return { state: "active" };
|
|
2765
|
+
case 1:
|
|
2766
|
+
return { state: "paused", pausedLevels: PauseFlags(status.flags) };
|
|
2767
|
+
case 2:
|
|
2768
|
+
return { state: "stopped" };
|
|
2769
|
+
default:
|
|
2770
|
+
throw new ValidationError(
|
|
2771
|
+
`SwapStatus.state: unknown contract state (${status.state})`
|
|
2772
|
+
);
|
|
2773
|
+
}
|
|
2774
|
+
}
|
|
1991
2775
|
};
|
|
1992
2776
|
var AllowWalletResponse = {
|
|
1993
2777
|
fromDto: (dto) => {
|
|
@@ -2009,87 +2793,9 @@ var AllowWalletResponse = {
|
|
|
2009
2793
|
}
|
|
2010
2794
|
}
|
|
2011
2795
|
}
|
|
2012
|
-
};
|
|
2013
|
-
|
|
2014
|
-
// src/universal/api/frontline/providers/superstate/swap.ts
|
|
2015
|
-
async function getSwapAuthorization(api, params) {
|
|
2016
|
-
const dto = await api.send({
|
|
2017
|
-
method: "GET",
|
|
2018
|
-
url: "/v1/wallet/authorized",
|
|
2019
|
-
queryParams: {
|
|
2020
|
-
chain: params.chain,
|
|
2021
|
-
contract_address: params.contractAddress,
|
|
2022
|
-
wallet_address: params.walletAddress
|
|
2023
|
-
},
|
|
2024
|
-
attributes: Attributes.protected()
|
|
2025
|
-
});
|
|
2026
|
-
return SwapAuthorization.fromDto(dto);
|
|
2027
|
-
}
|
|
2028
|
-
async function getSwapOutputToken(api, params) {
|
|
2029
|
-
const dto = await api.send({
|
|
2030
|
-
method: "GET",
|
|
2031
|
-
url: "/v1/swap/output-token",
|
|
2032
|
-
queryParams: {
|
|
2033
|
-
chain: params.chain,
|
|
2034
|
-
contract_address: params.contractAddress
|
|
2035
|
-
},
|
|
2036
|
-
attributes: Attributes.protected()
|
|
2037
|
-
});
|
|
2038
|
-
return toErc20Asset(dto);
|
|
2039
|
-
}
|
|
2040
|
-
async function getSwapPreview(api, params) {
|
|
2041
|
-
const dto = await api.send({
|
|
2042
|
-
method: "GET",
|
|
2043
|
-
url: "/v1/swap/preview",
|
|
2044
|
-
queryParams: {
|
|
2045
|
-
chain: params.chain,
|
|
2046
|
-
contract_address: params.contractAddress,
|
|
2047
|
-
input_token: params.inputToken,
|
|
2048
|
-
amount: params.amount.toString()
|
|
2049
|
-
},
|
|
2050
|
-
attributes: Attributes.protected()
|
|
2051
|
-
});
|
|
2052
|
-
return SwapPreview.fromDto(dto);
|
|
2053
|
-
}
|
|
2054
|
-
async function getSwapStatus(api, params) {
|
|
2055
|
-
const dto = await api.send({
|
|
2056
|
-
method: "GET",
|
|
2057
|
-
url: "/v1/swap/status",
|
|
2058
|
-
queryParams: {
|
|
2059
|
-
chain: params.chain,
|
|
2060
|
-
contract_address: params.contractAddress
|
|
2061
|
-
},
|
|
2062
|
-
attributes: Attributes.protected()
|
|
2063
|
-
});
|
|
2064
|
-
return SwapStatus.fromDto(dto);
|
|
2065
|
-
}
|
|
2066
|
-
async function getTokenAllowance(api, params) {
|
|
2067
|
-
const dto = await api.send({
|
|
2068
|
-
method: "GET",
|
|
2069
|
-
url: "/v1/token/allowance",
|
|
2070
|
-
queryParams: {
|
|
2071
|
-
chain: params.chain,
|
|
2072
|
-
token_address: params.tokenAddress,
|
|
2073
|
-
owner: params.owner,
|
|
2074
|
-
spender: params.spender
|
|
2075
|
-
},
|
|
2076
|
-
attributes: Attributes.protected()
|
|
2077
|
-
});
|
|
2078
|
-
return TokenAllowance.fromDto(dto);
|
|
2079
|
-
}
|
|
2080
|
-
async function getTokenBalance(api, params) {
|
|
2081
|
-
const dto = await api.send({
|
|
2082
|
-
method: "GET",
|
|
2083
|
-
url: "/v1/token/balance",
|
|
2084
|
-
queryParams: {
|
|
2085
|
-
chain: params.chain,
|
|
2086
|
-
token_address: params.tokenAddress,
|
|
2087
|
-
owner: params.owner
|
|
2088
|
-
},
|
|
2089
|
-
attributes: Attributes.protected()
|
|
2090
|
-
});
|
|
2091
|
-
return TokenBalance.fromDto(dto);
|
|
2092
|
-
}
|
|
2796
|
+
};
|
|
2797
|
+
|
|
2798
|
+
// src/universal/api/frontline/providers/superstate/swap.ts
|
|
2093
2799
|
async function allowWallet(api, params) {
|
|
2094
2800
|
const dto = await api.send({
|
|
2095
2801
|
method: "POST",
|
|
@@ -2103,11 +2809,153 @@ async function allowWallet(api, params) {
|
|
|
2103
2809
|
});
|
|
2104
2810
|
return AllowWalletResponse.fromDto(dto);
|
|
2105
2811
|
}
|
|
2106
|
-
|
|
2812
|
+
|
|
2813
|
+
// src/universal/core/shared/blockchain/erc20/abi.ts
|
|
2814
|
+
var ERC20_ABI = [
|
|
2815
|
+
{
|
|
2816
|
+
type: "function",
|
|
2817
|
+
name: "allowance",
|
|
2818
|
+
inputs: [
|
|
2819
|
+
{ name: "owner", type: "address" },
|
|
2820
|
+
{ name: "spender", type: "address" }
|
|
2821
|
+
],
|
|
2822
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
2823
|
+
stateMutability: "view"
|
|
2824
|
+
},
|
|
2825
|
+
{
|
|
2826
|
+
type: "function",
|
|
2827
|
+
name: "approve",
|
|
2828
|
+
inputs: [
|
|
2829
|
+
{ name: "spender", type: "address" },
|
|
2830
|
+
{ name: "amount", type: "uint256" }
|
|
2831
|
+
],
|
|
2832
|
+
outputs: [{ name: "", type: "bool" }],
|
|
2833
|
+
stateMutability: "nonpayable"
|
|
2834
|
+
},
|
|
2835
|
+
{
|
|
2836
|
+
type: "function",
|
|
2837
|
+
name: "balanceOf",
|
|
2838
|
+
inputs: [{ name: "account", type: "address" }],
|
|
2839
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
2840
|
+
stateMutability: "view"
|
|
2841
|
+
},
|
|
2842
|
+
{
|
|
2843
|
+
type: "function",
|
|
2844
|
+
name: "decimals",
|
|
2845
|
+
inputs: [],
|
|
2846
|
+
outputs: [{ name: "", type: "uint8" }],
|
|
2847
|
+
stateMutability: "view"
|
|
2848
|
+
},
|
|
2849
|
+
{
|
|
2850
|
+
type: "function",
|
|
2851
|
+
name: "name",
|
|
2852
|
+
inputs: [],
|
|
2853
|
+
outputs: [{ name: "", type: "string" }],
|
|
2854
|
+
stateMutability: "view"
|
|
2855
|
+
},
|
|
2856
|
+
{
|
|
2857
|
+
type: "function",
|
|
2858
|
+
name: "symbol",
|
|
2859
|
+
inputs: [],
|
|
2860
|
+
outputs: [{ name: "", type: "string" }],
|
|
2861
|
+
stateMutability: "view"
|
|
2862
|
+
},
|
|
2863
|
+
{
|
|
2864
|
+
type: "function",
|
|
2865
|
+
name: "totalSupply",
|
|
2866
|
+
inputs: [],
|
|
2867
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
2868
|
+
stateMutability: "view"
|
|
2869
|
+
},
|
|
2870
|
+
{
|
|
2871
|
+
type: "function",
|
|
2872
|
+
name: "transfer",
|
|
2873
|
+
inputs: [
|
|
2874
|
+
{ name: "recipient", type: "address" },
|
|
2875
|
+
{ name: "amount", type: "uint256" }
|
|
2876
|
+
],
|
|
2877
|
+
outputs: [{ name: "", type: "bool" }],
|
|
2878
|
+
stateMutability: "nonpayable"
|
|
2879
|
+
},
|
|
2880
|
+
{
|
|
2881
|
+
type: "function",
|
|
2882
|
+
name: "transferFrom",
|
|
2883
|
+
inputs: [
|
|
2884
|
+
{ name: "sender", type: "address" },
|
|
2885
|
+
{ name: "recipient", type: "address" },
|
|
2886
|
+
{ name: "amount", type: "uint256" }
|
|
2887
|
+
],
|
|
2888
|
+
outputs: [{ name: "", type: "bool" }],
|
|
2889
|
+
stateMutability: "nonpayable"
|
|
2890
|
+
},
|
|
2891
|
+
{
|
|
2892
|
+
type: "event",
|
|
2893
|
+
name: "Approval",
|
|
2894
|
+
inputs: [
|
|
2895
|
+
{ name: "owner", type: "address", indexed: true },
|
|
2896
|
+
{ name: "spender", type: "address", indexed: true },
|
|
2897
|
+
{ name: "value", type: "uint256", indexed: false }
|
|
2898
|
+
],
|
|
2899
|
+
anonymous: false
|
|
2900
|
+
},
|
|
2901
|
+
{
|
|
2902
|
+
type: "event",
|
|
2903
|
+
name: "Transfer",
|
|
2904
|
+
inputs: [
|
|
2905
|
+
{ name: "from", type: "address", indexed: true },
|
|
2906
|
+
{ name: "to", type: "address", indexed: true },
|
|
2907
|
+
{ name: "value", type: "uint256", indexed: false }
|
|
2908
|
+
],
|
|
2909
|
+
anonymous: false
|
|
2910
|
+
}
|
|
2911
|
+
];
|
|
2912
|
+
|
|
2913
|
+
// src/universal/api/rpc/providers/superstate/swap.ts
|
|
2914
|
+
async function getSwapAuthorization(clients, params) {
|
|
2915
|
+
return clients(params.chain).readContract({
|
|
2916
|
+
address: params.contractAddress,
|
|
2917
|
+
abi: SUPERSTATE_SWAP_ABI,
|
|
2918
|
+
functionName: "authorized",
|
|
2919
|
+
args: [params.walletAddress]
|
|
2920
|
+
});
|
|
2921
|
+
}
|
|
2922
|
+
async function getSwapPreview(clients, params) {
|
|
2923
|
+
const preview = await clients(params.chain).readContract({
|
|
2924
|
+
address: params.contractAddress,
|
|
2925
|
+
abi: SUPERSTATE_SWAP_ABI,
|
|
2926
|
+
functionName: "preview",
|
|
2927
|
+
args: [params.inputToken, params.amount]
|
|
2928
|
+
});
|
|
2929
|
+
return SwapPreview.fromContract(preview);
|
|
2930
|
+
}
|
|
2931
|
+
async function getSwapStatus(clients, params) {
|
|
2932
|
+
const status = await clients(params.chain).readContract({
|
|
2933
|
+
address: params.contractAddress,
|
|
2934
|
+
abi: SUPERSTATE_SWAP_ABI,
|
|
2935
|
+
functionName: "status"
|
|
2936
|
+
});
|
|
2937
|
+
return SwapStatus.fromContract(status);
|
|
2938
|
+
}
|
|
2939
|
+
async function getSwapOutputToken(clients, params) {
|
|
2940
|
+
const client = clients(params.chain);
|
|
2941
|
+
const tokenAddress = await client.readContract({
|
|
2942
|
+
address: params.contractAddress,
|
|
2943
|
+
abi: SUPERSTATE_SWAP_ABI,
|
|
2944
|
+
functionName: "outputToken"
|
|
2945
|
+
});
|
|
2946
|
+
const token = { address: EvmContractAddress(tokenAddress), abi: ERC20_ABI };
|
|
2947
|
+
const [name, symbol, decimals] = await client.multicall({
|
|
2948
|
+
contracts: [
|
|
2949
|
+
{ ...token, functionName: "name" },
|
|
2950
|
+
{ ...token, functionName: "symbol" },
|
|
2951
|
+
{ ...token, functionName: "decimals" }
|
|
2952
|
+
],
|
|
2953
|
+
allowFailure: false
|
|
2954
|
+
});
|
|
2107
2955
|
return {
|
|
2108
|
-
name
|
|
2109
|
-
symbol: AssetSymbol(
|
|
2110
|
-
decimals: AssetDecimals(
|
|
2956
|
+
name,
|
|
2957
|
+
symbol: AssetSymbol(symbol),
|
|
2958
|
+
decimals: AssetDecimals(decimals)
|
|
2111
2959
|
};
|
|
2112
2960
|
}
|
|
2113
2961
|
|
|
@@ -2118,28 +2966,32 @@ var SuperstateSwapNamespaceImpl = class {
|
|
|
2118
2966
|
this.log = internalLogger(ctx.logger, "SUPERSTATE");
|
|
2119
2967
|
}
|
|
2120
2968
|
async getAuthorization(params) {
|
|
2121
|
-
return this.log.wrap(
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2969
|
+
return this.log.wrap(
|
|
2970
|
+
"getAuthorization",
|
|
2971
|
+
params,
|
|
2972
|
+
async () => getSwapAuthorization(this.ctx.rpc, params)
|
|
2973
|
+
);
|
|
2125
2974
|
}
|
|
2126
2975
|
async getPreview(params) {
|
|
2127
|
-
return this.log.wrap(
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2976
|
+
return this.log.wrap(
|
|
2977
|
+
"getPreview",
|
|
2978
|
+
params,
|
|
2979
|
+
async () => getSwapPreview(this.ctx.rpc, params)
|
|
2980
|
+
);
|
|
2131
2981
|
}
|
|
2132
2982
|
async getStatus(params) {
|
|
2133
|
-
return this.log.wrap(
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2983
|
+
return this.log.wrap(
|
|
2984
|
+
"getStatus",
|
|
2985
|
+
params,
|
|
2986
|
+
async () => getSwapStatus(this.ctx.rpc, params)
|
|
2987
|
+
);
|
|
2137
2988
|
}
|
|
2138
2989
|
async getOutputToken(params) {
|
|
2139
|
-
return this.log.wrap(
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2990
|
+
return this.log.wrap(
|
|
2991
|
+
"getOutputToken",
|
|
2992
|
+
params,
|
|
2993
|
+
async () => getSwapOutputToken(this.ctx.rpc, params)
|
|
2994
|
+
);
|
|
2143
2995
|
}
|
|
2144
2996
|
async allowWallet(params) {
|
|
2145
2997
|
return this.log.wrap("allowWallet", params, async () => {
|
|
@@ -2164,7 +3016,7 @@ async function fetchOffersPage(api, params, clientCreds) {
|
|
|
2164
3016
|
Attributes.clientCredentials(clientCreds)
|
|
2165
3017
|
)
|
|
2166
3018
|
});
|
|
2167
|
-
return PaginatedResponse.
|
|
3019
|
+
return PaginatedResponse.fromDtoPage(pageDto, Offer.listFromDto);
|
|
2168
3020
|
}
|
|
2169
3021
|
async function fetchOfferDetails(api, id, clientCreds) {
|
|
2170
3022
|
const dto = await api.send({
|
|
@@ -2384,105 +3236,25 @@ var RequirementsNamespaceImpl = class {
|
|
|
2384
3236
|
}
|
|
2385
3237
|
};
|
|
2386
3238
|
|
|
2387
|
-
// src/universal/
|
|
2388
|
-
|
|
2389
|
-
{
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
outputs: [{ name: "", type: "bool" }],
|
|
2407
|
-
stateMutability: "nonpayable"
|
|
2408
|
-
},
|
|
2409
|
-
{
|
|
2410
|
-
type: "function",
|
|
2411
|
-
name: "balanceOf",
|
|
2412
|
-
inputs: [{ name: "account", type: "address" }],
|
|
2413
|
-
outputs: [{ name: "", type: "uint256" }],
|
|
2414
|
-
stateMutability: "view"
|
|
2415
|
-
},
|
|
2416
|
-
{
|
|
2417
|
-
type: "function",
|
|
2418
|
-
name: "decimals",
|
|
2419
|
-
inputs: [],
|
|
2420
|
-
outputs: [{ name: "", type: "uint8" }],
|
|
2421
|
-
stateMutability: "view"
|
|
2422
|
-
},
|
|
2423
|
-
{
|
|
2424
|
-
type: "function",
|
|
2425
|
-
name: "name",
|
|
2426
|
-
inputs: [],
|
|
2427
|
-
outputs: [{ name: "", type: "string" }],
|
|
2428
|
-
stateMutability: "view"
|
|
2429
|
-
},
|
|
2430
|
-
{
|
|
2431
|
-
type: "function",
|
|
2432
|
-
name: "symbol",
|
|
2433
|
-
inputs: [],
|
|
2434
|
-
outputs: [{ name: "", type: "string" }],
|
|
2435
|
-
stateMutability: "view"
|
|
2436
|
-
},
|
|
2437
|
-
{
|
|
2438
|
-
type: "function",
|
|
2439
|
-
name: "totalSupply",
|
|
2440
|
-
inputs: [],
|
|
2441
|
-
outputs: [{ name: "", type: "uint256" }],
|
|
2442
|
-
stateMutability: "view"
|
|
2443
|
-
},
|
|
2444
|
-
{
|
|
2445
|
-
type: "function",
|
|
2446
|
-
name: "transfer",
|
|
2447
|
-
inputs: [
|
|
2448
|
-
{ name: "recipient", type: "address" },
|
|
2449
|
-
{ name: "amount", type: "uint256" }
|
|
2450
|
-
],
|
|
2451
|
-
outputs: [{ name: "", type: "bool" }],
|
|
2452
|
-
stateMutability: "nonpayable"
|
|
2453
|
-
},
|
|
2454
|
-
{
|
|
2455
|
-
type: "function",
|
|
2456
|
-
name: "transferFrom",
|
|
2457
|
-
inputs: [
|
|
2458
|
-
{ name: "sender", type: "address" },
|
|
2459
|
-
{ name: "recipient", type: "address" },
|
|
2460
|
-
{ name: "amount", type: "uint256" }
|
|
2461
|
-
],
|
|
2462
|
-
outputs: [{ name: "", type: "bool" }],
|
|
2463
|
-
stateMutability: "nonpayable"
|
|
2464
|
-
},
|
|
2465
|
-
{
|
|
2466
|
-
type: "event",
|
|
2467
|
-
name: "Approval",
|
|
2468
|
-
inputs: [
|
|
2469
|
-
{ name: "owner", type: "address", indexed: true },
|
|
2470
|
-
{ name: "spender", type: "address", indexed: true },
|
|
2471
|
-
{ name: "value", type: "uint256", indexed: false }
|
|
2472
|
-
],
|
|
2473
|
-
anonymous: false
|
|
2474
|
-
},
|
|
2475
|
-
{
|
|
2476
|
-
type: "event",
|
|
2477
|
-
name: "Transfer",
|
|
2478
|
-
inputs: [
|
|
2479
|
-
{ name: "from", type: "address", indexed: true },
|
|
2480
|
-
{ name: "to", type: "address", indexed: true },
|
|
2481
|
-
{ name: "value", type: "uint256", indexed: false }
|
|
2482
|
-
],
|
|
2483
|
-
anonymous: false
|
|
2484
|
-
}
|
|
2485
|
-
];
|
|
3239
|
+
// src/universal/api/rpc/erc20.ts
|
|
3240
|
+
async function getTokenAllowance(clients, params) {
|
|
3241
|
+
const allowance = await clients(params.chain).readContract({
|
|
3242
|
+
address: params.tokenAddress,
|
|
3243
|
+
abi: ERC20_ABI,
|
|
3244
|
+
functionName: "allowance",
|
|
3245
|
+
args: [params.owner, params.spender]
|
|
3246
|
+
});
|
|
3247
|
+
return parseUint256(allowance, "allowance");
|
|
3248
|
+
}
|
|
3249
|
+
async function getTokenBalance(clients, params) {
|
|
3250
|
+
const balance = await clients(params.chain).readContract({
|
|
3251
|
+
address: params.tokenAddress,
|
|
3252
|
+
abi: ERC20_ABI,
|
|
3253
|
+
functionName: "balanceOf",
|
|
3254
|
+
args: [params.owner]
|
|
3255
|
+
});
|
|
3256
|
+
return parseUint256(balance, "balanceOf");
|
|
3257
|
+
}
|
|
2486
3258
|
|
|
2487
3259
|
// src/universal/core/shared/blockchain/erc20/erc20-namespace.ts
|
|
2488
3260
|
var Erc20NamespaceImpl = class {
|
|
@@ -2491,21 +3263,69 @@ var Erc20NamespaceImpl = class {
|
|
|
2491
3263
|
this.log = internalLogger(ctx.logger, "ERC20");
|
|
2492
3264
|
}
|
|
2493
3265
|
async getAllowance(params) {
|
|
2494
|
-
return this.log.wrap(
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
3266
|
+
return this.log.wrap(
|
|
3267
|
+
"getAllowance",
|
|
3268
|
+
params,
|
|
3269
|
+
async () => getTokenAllowance(this.ctx.rpc, params)
|
|
3270
|
+
);
|
|
2498
3271
|
}
|
|
2499
3272
|
async getBalance(params) {
|
|
2500
|
-
return this.log.wrap(
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
3273
|
+
return this.log.wrap(
|
|
3274
|
+
"getBalance",
|
|
3275
|
+
params,
|
|
3276
|
+
async () => getTokenBalance(this.ctx.rpc, params)
|
|
3277
|
+
);
|
|
3278
|
+
}
|
|
3279
|
+
};
|
|
3280
|
+
|
|
3281
|
+
// src/universal/core/tokens/token-registry-snapshot.ts
|
|
3282
|
+
var TokenRegistrySnapshot = {
|
|
3283
|
+
/** Indexes a `tokens.list()` result. `[]` is a valid, empty snapshot. */
|
|
3284
|
+
fromTokens: (tokens) => ({
|
|
3285
|
+
tokens,
|
|
3286
|
+
byKey: new Map(
|
|
3287
|
+
tokens.map((token) => [registryKey(token.identifier), token])
|
|
3288
|
+
)
|
|
3289
|
+
}),
|
|
3290
|
+
/**
|
|
3291
|
+
* The registry's entry for one token, or `null` when it lists none. The
|
|
3292
|
+
* registry is curated, so `null` is an ordinary answer rather than an
|
|
3293
|
+
* error, and callers fall back to their own display defaults.
|
|
3294
|
+
*/
|
|
3295
|
+
get: (snapshot, token) => snapshot.byKey.get(registryKey(token)) ?? null,
|
|
3296
|
+
/**
|
|
3297
|
+
* The registry's entry for the token an offer is *about*, or `null` when
|
|
3298
|
+
* it lists none of them.
|
|
3299
|
+
*
|
|
3300
|
+
* Resolution follows {@link offerDisplayTokens}: the token a sale
|
|
3301
|
+
* distributes or a swap hands over, never the funding token the user pays
|
|
3302
|
+
* with. An offer deployed on several chains carries one such token per
|
|
3303
|
+
* chain, and the first the registry knows wins - they are the same asset,
|
|
3304
|
+
* so any listed one answers for the offer.
|
|
3305
|
+
*/
|
|
3306
|
+
forOffer: (snapshot, offer) => {
|
|
3307
|
+
for (const token of offerDisplayTokens(offer)) {
|
|
3308
|
+
const metadata = TokenRegistrySnapshot.get(snapshot, token);
|
|
3309
|
+
if (metadata !== null) {
|
|
3310
|
+
return metadata;
|
|
3311
|
+
}
|
|
3312
|
+
}
|
|
3313
|
+
return null;
|
|
2504
3314
|
}
|
|
2505
3315
|
};
|
|
3316
|
+
function offerDisplayTokens(offer) {
|
|
3317
|
+
const swaps = offer.tokens.filter((token) => token.role === "swap");
|
|
3318
|
+
const distributions = offer.tokens.filter(
|
|
3319
|
+
(token) => token.role === "distribution"
|
|
3320
|
+
);
|
|
3321
|
+
return [...swaps, ...distributions];
|
|
3322
|
+
}
|
|
3323
|
+
function registryKey(token) {
|
|
3324
|
+
return `${token.chain}:${token.address.toLowerCase()}`;
|
|
3325
|
+
}
|
|
2506
3326
|
|
|
2507
3327
|
// src/universal/api/nabu/tokens.ts
|
|
2508
|
-
var
|
|
3328
|
+
var import_viem5 = require("viem");
|
|
2509
3329
|
|
|
2510
3330
|
// src/universal/api/frontline/config.ts
|
|
2511
3331
|
var HEADER_API_VERSION = "X-API-Version";
|
|
@@ -2571,9 +3391,9 @@ var HttpClient = class {
|
|
|
2571
3391
|
if (url.startsWith("http://") || url.startsWith("https://")) {
|
|
2572
3392
|
return url;
|
|
2573
3393
|
}
|
|
2574
|
-
const
|
|
3394
|
+
const base2 = this.config.baseUrl.replace(/\/$/, "");
|
|
2575
3395
|
const path = url.startsWith("/") ? url : `/${url}`;
|
|
2576
|
-
return
|
|
3396
|
+
return base2 + path;
|
|
2577
3397
|
}
|
|
2578
3398
|
async runBeforeRequestMiddleware(initialRequest) {
|
|
2579
3399
|
let request = initialRequest;
|
|
@@ -2834,7 +3654,7 @@ function assertOk(response) {
|
|
|
2834
3654
|
}
|
|
2835
3655
|
function checksummed(address) {
|
|
2836
3656
|
try {
|
|
2837
|
-
return (0,
|
|
3657
|
+
return (0, import_viem5.getAddress)(address);
|
|
2838
3658
|
} catch (_) {
|
|
2839
3659
|
throw new ValidationError(`Invalid EVM contract address: "${address}"`);
|
|
2840
3660
|
}
|
|
@@ -3097,11 +3917,12 @@ var User = {
|
|
|
3097
3917
|
OAuthRefreshToken,
|
|
3098
3918
|
OAuthSession,
|
|
3099
3919
|
ONDO_POLL_INTERVAL_MS,
|
|
3100
|
-
|
|
3920
|
+
ONDO_QUOTE_MAX_TTL_MS,
|
|
3101
3921
|
ONDO_SETTLEMENT_ASSET,
|
|
3102
3922
|
ONDO_SUPPORTED_INPUT_ASSETS,
|
|
3103
3923
|
Offer,
|
|
3104
3924
|
OfferDetail,
|
|
3925
|
+
OfferEditorial,
|
|
3105
3926
|
OfferId,
|
|
3106
3927
|
OfferOption,
|
|
3107
3928
|
OfferOptionAddress,
|
|
@@ -3123,6 +3944,7 @@ var User = {
|
|
|
3123
3944
|
Participation,
|
|
3124
3945
|
ParticipationId,
|
|
3125
3946
|
ParticipationsPaginationParams,
|
|
3947
|
+
PauseFlags,
|
|
3126
3948
|
Pii,
|
|
3127
3949
|
PiiAddress,
|
|
3128
3950
|
PiiJurisdiction,
|
|
@@ -3139,23 +3961,22 @@ var User = {
|
|
|
3139
3961
|
SUPERSTATE_SUPPORTED_INPUT_ASSETS,
|
|
3140
3962
|
SUPERSTATE_SWAP_ABI,
|
|
3141
3963
|
SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA,
|
|
3964
|
+
SWAP_LEVEL,
|
|
3142
3965
|
SWAP_POLL_INTERVAL_MS,
|
|
3143
3966
|
ShortenedWalletAddress,
|
|
3144
3967
|
SolanaChain,
|
|
3145
3968
|
StablecoinSymbol,
|
|
3146
3969
|
SuperstateSwapNamespaceImpl,
|
|
3147
|
-
SwapAuthorization,
|
|
3148
3970
|
SwapPreview,
|
|
3149
3971
|
SwapQuote,
|
|
3150
3972
|
SwapStatus,
|
|
3151
3973
|
TOKEN_REGISTRY,
|
|
3152
3974
|
TermItem,
|
|
3153
3975
|
Ticker,
|
|
3154
|
-
TokenAllowance,
|
|
3155
|
-
TokenBalance,
|
|
3156
3976
|
TokenLogo,
|
|
3157
3977
|
TokenLogoUrl,
|
|
3158
3978
|
TokenMetadata,
|
|
3979
|
+
TokenRegistrySnapshot,
|
|
3159
3980
|
TokensNamespaceImpl,
|
|
3160
3981
|
TxExplorerUrl,
|
|
3161
3982
|
USDC,
|
|
@@ -3191,13 +4012,17 @@ var User = {
|
|
|
3191
4012
|
getChainId,
|
|
3192
4013
|
getNetworkName,
|
|
3193
4014
|
isChain,
|
|
3194
|
-
|
|
4015
|
+
isOfferType,
|
|
4016
|
+
isSwapAvailable,
|
|
4017
|
+
offerDisplayTokens,
|
|
4018
|
+
ondoQuoteOfferDeadline,
|
|
3195
4019
|
parseBlockchainAmount,
|
|
3196
4020
|
parseUint256,
|
|
3197
4021
|
shortenAddress,
|
|
3198
4022
|
superstateSwapContractAddress,
|
|
3199
4023
|
swapSpender,
|
|
3200
4024
|
txExplorerUrl,
|
|
3201
|
-
usdAmount
|
|
4025
|
+
usdAmount,
|
|
4026
|
+
viemChain
|
|
3202
4027
|
});
|
|
3203
4028
|
//# sourceMappingURL=index.cjs.map
|