@coinlist-co/react 0.12.1-rc.c2b6ba5 → 0.12.1-rc.e183ffd
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-F6WGUKZC.js → chunk-DCW7NQXH.js} +129 -3
- package/dist/chunk-DCW7NQXH.js.map +1 -0
- package/dist/{chunk-6CQHDASY.js → chunk-MOE5S6CE.js} +1354 -257
- package/dist/chunk-MOE5S6CE.js.map +1 -0
- package/dist/{chunk-ZFBEI3BW.js → chunk-ONLH57LF.js} +20 -330
- package/dist/chunk-ONLH57LF.js.map +1 -0
- package/dist/client/index.cjs +8779 -7816
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +143 -69
- package/dist/client/index.d.ts +143 -69
- package/dist/client/index.js +4177 -4109
- package/dist/client/index.js.map +1 -1
- package/dist/{collections-aCv-Wr2a.d.ts → collections-Biy3pQQL.d.cts} +1 -1
- package/dist/{collections-DOm9VKVm.d.cts → collections-JfNDG8Tc.d.ts} +1 -1
- package/dist/server/index.cjs +1463 -260
- 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/{config-DIaFzrMW.d.cts → tokens-namespace-CIWBtgt2.d.cts} +529 -230
- package/dist/{config-DIaFzrMW.d.ts → tokens-namespace-CIWBtgt2.d.ts} +529 -230
- package/dist/universal/index.cjs +1258 -478
- package/dist/universal/index.cjs.map +1 -1
- package/dist/universal/index.d.cts +427 -45
- package/dist/universal/index.d.ts +427 -45
- package/dist/universal/index.js +20 -14
- package/package.json +1 -1
- package/dist/chunk-6CQHDASY.js.map +0 -1
- package/dist/chunk-F6WGUKZC.js.map +0 -1
- package/dist/chunk-ZFBEI3BW.js.map +0 -1
package/dist/universal/index.cjs
CHANGED
|
@@ -62,6 +62,7 @@ __export(universal_exports, {
|
|
|
62
62
|
HexEncodedTransactionData: () => HexEncodedTransactionData,
|
|
63
63
|
HttpError: () => HttpError,
|
|
64
64
|
InvariantError: () => InvariantError,
|
|
65
|
+
Isin: () => Isin,
|
|
65
66
|
Iso2CountryCode: () => Iso2CountryCode,
|
|
66
67
|
KnownAssetSymbol: () => KnownAssetSymbol,
|
|
67
68
|
KycToken: () => KycToken,
|
|
@@ -81,6 +82,7 @@ __export(universal_exports, {
|
|
|
81
82
|
ONDO_SUPPORTED_INPUT_ASSETS: () => ONDO_SUPPORTED_INPUT_ASSETS,
|
|
82
83
|
Offer: () => Offer,
|
|
83
84
|
OfferDetail: () => OfferDetail,
|
|
85
|
+
OfferEditorial: () => OfferEditorial,
|
|
84
86
|
OfferId: () => OfferId,
|
|
85
87
|
OfferOption: () => OfferOption,
|
|
86
88
|
OfferOptionAddress: () => OfferOptionAddress,
|
|
@@ -102,6 +104,7 @@ __export(universal_exports, {
|
|
|
102
104
|
Participation: () => Participation,
|
|
103
105
|
ParticipationId: () => ParticipationId,
|
|
104
106
|
ParticipationsPaginationParams: () => ParticipationsPaginationParams,
|
|
107
|
+
PauseFlags: () => PauseFlags,
|
|
105
108
|
Pii: () => Pii,
|
|
106
109
|
PiiAddress: () => PiiAddress,
|
|
107
110
|
PiiJurisdiction: () => PiiJurisdiction,
|
|
@@ -118,20 +121,18 @@ __export(universal_exports, {
|
|
|
118
121
|
SUPERSTATE_SUPPORTED_INPUT_ASSETS: () => SUPERSTATE_SUPPORTED_INPUT_ASSETS,
|
|
119
122
|
SUPERSTATE_SWAP_ABI: () => SUPERSTATE_SWAP_ABI,
|
|
120
123
|
SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA: () => SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA,
|
|
124
|
+
SWAP_LEVEL: () => SWAP_LEVEL,
|
|
121
125
|
SWAP_POLL_INTERVAL_MS: () => SWAP_POLL_INTERVAL_MS,
|
|
122
126
|
ShortenedWalletAddress: () => ShortenedWalletAddress,
|
|
123
127
|
SolanaChain: () => SolanaChain,
|
|
124
128
|
StablecoinSymbol: () => StablecoinSymbol,
|
|
125
129
|
SuperstateSwapNamespaceImpl: () => SuperstateSwapNamespaceImpl,
|
|
126
|
-
SwapAuthorization: () => SwapAuthorization,
|
|
127
130
|
SwapPreview: () => SwapPreview,
|
|
128
131
|
SwapQuote: () => SwapQuote,
|
|
129
132
|
SwapStatus: () => SwapStatus,
|
|
130
133
|
TOKEN_REGISTRY: () => TOKEN_REGISTRY,
|
|
131
134
|
TermItem: () => TermItem,
|
|
132
135
|
Ticker: () => Ticker,
|
|
133
|
-
TokenAllowance: () => TokenAllowance,
|
|
134
|
-
TokenBalance: () => TokenBalance,
|
|
135
136
|
TokenLogo: () => TokenLogo,
|
|
136
137
|
TokenLogoUrl: () => TokenLogoUrl,
|
|
137
138
|
TokenMetadata: () => TokenMetadata,
|
|
@@ -170,14 +171,16 @@ __export(universal_exports, {
|
|
|
170
171
|
getChainId: () => getChainId,
|
|
171
172
|
getNetworkName: () => getNetworkName,
|
|
172
173
|
isChain: () => isChain,
|
|
173
|
-
|
|
174
|
+
isOfferType: () => isOfferType,
|
|
175
|
+
isSwapAvailable: () => isSwapAvailable,
|
|
174
176
|
parseBlockchainAmount: () => parseBlockchainAmount,
|
|
175
177
|
parseUint256: () => parseUint256,
|
|
176
178
|
shortenAddress: () => shortenAddress,
|
|
177
179
|
superstateSwapContractAddress: () => superstateSwapContractAddress,
|
|
178
180
|
swapSpender: () => swapSpender,
|
|
179
181
|
txExplorerUrl: () => txExplorerUrl,
|
|
180
|
-
usdAmount: () => usdAmount
|
|
182
|
+
usdAmount: () => usdAmount,
|
|
183
|
+
viemChain: () => viemChain
|
|
181
184
|
});
|
|
182
185
|
module.exports = __toCommonJS(universal_exports);
|
|
183
186
|
|
|
@@ -427,8 +430,15 @@ async function generatePKCEParams(config) {
|
|
|
427
430
|
// src/universal/types/pagination.ts
|
|
428
431
|
var Cursor = (value) => value;
|
|
429
432
|
var PaginatedResponse = {
|
|
430
|
-
fromDto: (dto, itemMapper) => (
|
|
431
|
-
|
|
433
|
+
fromDto: (dto, itemMapper) => PaginatedResponse.fromDtoPage(dto, (items) => items.map(itemMapper)),
|
|
434
|
+
/**
|
|
435
|
+
* For a mapper that decides the page as a whole - one that drops items it
|
|
436
|
+
* cannot map, such as `Offer.listFromDto` - rather than item by item. The
|
|
437
|
+
* cursors are the wire's either way: dropping an item changes what the
|
|
438
|
+
* page holds, not where the next page starts.
|
|
439
|
+
*/
|
|
440
|
+
fromDtoPage: (dto, pageMapper) => ({
|
|
441
|
+
data: pageMapper(dto.data),
|
|
432
442
|
startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
|
|
433
443
|
startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
|
|
434
444
|
})
|
|
@@ -493,6 +503,40 @@ var MathError = class extends Error {
|
|
|
493
503
|
}
|
|
494
504
|
};
|
|
495
505
|
|
|
506
|
+
// src/universal/core/shared/utils/wire.ts
|
|
507
|
+
function unknownTypeError(dto, model) {
|
|
508
|
+
const type = dto.type;
|
|
509
|
+
throw new ValidationError(
|
|
510
|
+
`${model}.type: unknown type ${JSON.stringify(type)}`
|
|
511
|
+
);
|
|
512
|
+
}
|
|
513
|
+
function requiredString(value, field) {
|
|
514
|
+
const text = notBlankStringOrNull(value);
|
|
515
|
+
if (text === null) {
|
|
516
|
+
throw new ValidationError(
|
|
517
|
+
`${field}: expected a non-blank string, got ${typeof value === "string" ? "a blank string" : String(value)}`
|
|
518
|
+
);
|
|
519
|
+
}
|
|
520
|
+
return text;
|
|
521
|
+
}
|
|
522
|
+
function requiredDate(value, field) {
|
|
523
|
+
const date = typeof value === "string" ? new Date(value) : null;
|
|
524
|
+
if (date === null || Number.isNaN(date.getTime())) {
|
|
525
|
+
throw new ValidationError(
|
|
526
|
+
`${field}: expected a date, got ${JSON.stringify(value)}`
|
|
527
|
+
);
|
|
528
|
+
}
|
|
529
|
+
return date;
|
|
530
|
+
}
|
|
531
|
+
function requiredArray(value, field) {
|
|
532
|
+
if (!Array.isArray(value)) {
|
|
533
|
+
throw new ValidationError(
|
|
534
|
+
`${field}: expected an array, got ${typeof value}`
|
|
535
|
+
);
|
|
536
|
+
}
|
|
537
|
+
return value;
|
|
538
|
+
}
|
|
539
|
+
|
|
496
540
|
// src/universal/types/blockchain/core.ts
|
|
497
541
|
var ETHEREUM_CHAINS = {
|
|
498
542
|
ethereum_mainnet: true,
|
|
@@ -593,25 +637,69 @@ var Bps = (value) => value;
|
|
|
593
637
|
// src/universal/types/offer.ts
|
|
594
638
|
var OfferId = (value) => value;
|
|
595
639
|
var OfferSlug = (value) => value;
|
|
640
|
+
var OFFER_TYPES = {
|
|
641
|
+
"coinlist::token_sale": true,
|
|
642
|
+
"superstate::swap": true,
|
|
643
|
+
"ondo::swap": true
|
|
644
|
+
};
|
|
645
|
+
var isOfferType = (value) => Object.keys(OFFER_TYPES).includes(value);
|
|
646
|
+
var OfferEditorial = {
|
|
647
|
+
/**
|
|
648
|
+
* `model` prefixes the field in the error (`'Offer'`, `'OfferDetail'`), so
|
|
649
|
+
* the same three checks name the payload that failed them.
|
|
650
|
+
*/
|
|
651
|
+
fromDto: (dto, model) => ({
|
|
652
|
+
tagline: requiredString(dto.tagline, `${model}.tagline`),
|
|
653
|
+
bannerUrl: requiredString(dto.banner_url, `${model}.banner_url`),
|
|
654
|
+
startsAt: requiredDate(dto.starts_at, `${model}.starts_at`)
|
|
655
|
+
})
|
|
656
|
+
};
|
|
596
657
|
var Offer = {
|
|
597
658
|
fromDto: (dto) => {
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
`Offer.tokens: expected an array, got ${typeof dto.tokens}`
|
|
601
|
-
);
|
|
602
|
-
}
|
|
603
|
-
return {
|
|
659
|
+
const tokens = requiredArray(dto.tokens, "Offer.tokens");
|
|
660
|
+
const base2 = {
|
|
604
661
|
id: OfferId(dto.id),
|
|
605
662
|
slug: OfferSlug(dto.slug),
|
|
606
|
-
type: dto.type,
|
|
607
|
-
tagline: dto.tagline,
|
|
608
|
-
bannerUrl: dto.banner_url,
|
|
609
|
-
logoUrl: dto.logo_url,
|
|
610
|
-
startsAt: new Date(dto.starts_at),
|
|
611
663
|
endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
|
|
612
|
-
tokens: OfferToken.listFromDto(
|
|
664
|
+
tokens: OfferToken.listFromDto(tokens)
|
|
613
665
|
};
|
|
614
|
-
|
|
666
|
+
switch (dto.type) {
|
|
667
|
+
case "coinlist::token_sale":
|
|
668
|
+
return {
|
|
669
|
+
...base2,
|
|
670
|
+
...OfferEditorial.fromDto(dto, "Offer"),
|
|
671
|
+
type: dto.type,
|
|
672
|
+
logoUrl: requiredString(dto.logo_url, "Offer.logo_url")
|
|
673
|
+
};
|
|
674
|
+
case "superstate::swap":
|
|
675
|
+
return {
|
|
676
|
+
...base2,
|
|
677
|
+
...OfferEditorial.fromDto(dto, "Offer"),
|
|
678
|
+
type: dto.type,
|
|
679
|
+
logoUrl: notBlankStringOrNull(dto.logo_url)
|
|
680
|
+
};
|
|
681
|
+
// `tagline`, `banner_url` and `starts_at` arrive as `null` and are left
|
|
682
|
+
// on the wire: copying them would hand every consumer a `startsAt` that
|
|
683
|
+
// is 1970 for one variant and a date for the others.
|
|
684
|
+
case "ondo::swap":
|
|
685
|
+
return {
|
|
686
|
+
...base2,
|
|
687
|
+
type: dto.type,
|
|
688
|
+
logoUrl: notBlankStringOrNull(dto.logo_url)
|
|
689
|
+
};
|
|
690
|
+
default:
|
|
691
|
+
return unknownTypeError(dto, "Offer");
|
|
692
|
+
}
|
|
693
|
+
},
|
|
694
|
+
/**
|
|
695
|
+
* Maps a page of offers, dropping every offer whose `type` this SDK does not
|
|
696
|
+
* name. The same reasoning as {@link OfferToken.listFromDto}: a plain `.map`
|
|
697
|
+
* would throw out of `fromDto` and, through `PaginatedResponse.fromDto`,
|
|
698
|
+
* reject the whole page, so one offer of an unknown type would blank the
|
|
699
|
+
* grid for every offer beside it. A single offer fetched by id still
|
|
700
|
+
* throws, because there is nothing beside it to keep.
|
|
701
|
+
*/
|
|
702
|
+
listFromDto: (dtos) => dtos.filter((dto) => isOfferType(dto.type)).map(Offer.fromDto)
|
|
615
703
|
};
|
|
616
704
|
var OfferToken = {
|
|
617
705
|
fromDto: (dto) => ({
|
|
@@ -633,6 +721,10 @@ var OfferToken = {
|
|
|
633
721
|
listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferToken.fromDto)
|
|
634
722
|
};
|
|
635
723
|
|
|
724
|
+
// src/universal/types/trading.ts
|
|
725
|
+
var Ticker = (value) => value;
|
|
726
|
+
var Isin = (value) => value;
|
|
727
|
+
|
|
636
728
|
// src/universal/types/offer-detail.ts
|
|
637
729
|
var OfferOptionId = (value) => value;
|
|
638
730
|
var OfferOptionSlug = (value) => value;
|
|
@@ -644,69 +736,69 @@ var OfferSwapContract = {
|
|
|
644
736
|
};
|
|
645
737
|
var OfferDetail = {
|
|
646
738
|
fromDto: (dto) => {
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
);
|
|
661
|
-
}
|
|
662
|
-
if (!Array.isArray(dto.links)) {
|
|
663
|
-
throw new ValidationError(
|
|
664
|
-
`OfferDetail.links: expected an array, got ${typeof dto.links}`
|
|
665
|
-
);
|
|
666
|
-
}
|
|
667
|
-
if (!Array.isArray(dto.faqs)) {
|
|
668
|
-
throw new ValidationError(
|
|
669
|
-
`OfferDetail.faqs: expected an array, got ${typeof dto.faqs}`
|
|
670
|
-
);
|
|
671
|
-
}
|
|
672
|
-
if (!Array.isArray(dto.milestones)) {
|
|
673
|
-
throw new ValidationError(
|
|
674
|
-
`OfferDetail.milestones: expected an array, got ${typeof dto.milestones}`
|
|
675
|
-
);
|
|
676
|
-
}
|
|
677
|
-
if (!Array.isArray(dto.tokens)) {
|
|
678
|
-
throw new ValidationError(
|
|
679
|
-
`OfferDetail.tokens: expected an array, got ${typeof dto.tokens}`
|
|
680
|
-
);
|
|
681
|
-
}
|
|
682
|
-
const swapContracts = dto.swap_contracts === void 0 ? [] : dto.swap_contracts;
|
|
683
|
-
if (!Array.isArray(swapContracts)) {
|
|
684
|
-
throw new ValidationError(
|
|
685
|
-
`OfferDetail.swap_contracts: expected an array, got ${typeof swapContracts}`
|
|
686
|
-
);
|
|
687
|
-
}
|
|
688
|
-
return {
|
|
739
|
+
const fundingAssets = requiredArray(
|
|
740
|
+
dto.funding_assets,
|
|
741
|
+
"OfferDetail.funding_assets"
|
|
742
|
+
);
|
|
743
|
+
const options = requiredArray(dto.options, "OfferDetail.options");
|
|
744
|
+
const terms = requiredArray(dto.terms, "OfferDetail.terms");
|
|
745
|
+
const links = requiredArray(dto.links, "OfferDetail.links");
|
|
746
|
+
const faqs = requiredArray(dto.faqs, "OfferDetail.faqs");
|
|
747
|
+
const milestones = requiredArray(dto.milestones, "OfferDetail.milestones");
|
|
748
|
+
const tokens = requiredArray(dto.tokens, "OfferDetail.tokens");
|
|
749
|
+
const isin = notBlankStringOrNull(dto.isin);
|
|
750
|
+
const ticker = notBlankStringOrNull(dto.ticker);
|
|
751
|
+
const base2 = {
|
|
689
752
|
id: OfferId(dto.id),
|
|
690
753
|
slug: OfferSlug(dto.slug),
|
|
691
|
-
type: dto.type,
|
|
692
754
|
name: dto.name,
|
|
693
755
|
asset: Asset.fromDto(dto.asset),
|
|
694
|
-
fundingAssets:
|
|
695
|
-
tokens: OfferToken.listFromDto(
|
|
696
|
-
swapContracts: swapContracts.map(OfferSwapContract.fromDto),
|
|
756
|
+
fundingAssets: fundingAssets.map(Asset.fromDto),
|
|
757
|
+
tokens: OfferToken.listFromDto(tokens),
|
|
697
758
|
about: notBlankStringOrNull(dto.about),
|
|
698
|
-
tagline: dto.tagline,
|
|
699
|
-
bannerUrl: dto.banner_url,
|
|
700
|
-
logoUrl: dto.logo_url,
|
|
701
759
|
category: dto.category,
|
|
702
|
-
|
|
760
|
+
issuer: notBlankStringOrNull(dto.issuer),
|
|
761
|
+
isin: isin === null ? null : Isin(isin),
|
|
762
|
+
ticker: ticker === null ? null : Ticker(ticker),
|
|
763
|
+
instrumentType: notBlankStringOrNull(dto.instrument_type),
|
|
764
|
+
listingVenue: notBlankStringOrNull(dto.listing_venue),
|
|
703
765
|
endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
|
|
704
|
-
faqs:
|
|
705
|
-
links:
|
|
706
|
-
milestones:
|
|
707
|
-
options:
|
|
708
|
-
terms:
|
|
766
|
+
faqs: faqs.map(FaqItem.fromDto),
|
|
767
|
+
links: links.map(Link.fromDto),
|
|
768
|
+
milestones: milestones.map(Milestone.fromDto),
|
|
769
|
+
options: options.map(OfferOption.fromDto),
|
|
770
|
+
terms: terms.map(TermItem.fromDto)
|
|
709
771
|
};
|
|
772
|
+
switch (dto.type) {
|
|
773
|
+
case "coinlist::token_sale":
|
|
774
|
+
return {
|
|
775
|
+
...base2,
|
|
776
|
+
...OfferEditorial.fromDto(dto, "OfferDetail"),
|
|
777
|
+
type: dto.type,
|
|
778
|
+
logoUrl: requiredString(dto.logo_url, "OfferDetail.logo_url")
|
|
779
|
+
};
|
|
780
|
+
case "superstate::swap":
|
|
781
|
+
return {
|
|
782
|
+
...base2,
|
|
783
|
+
...OfferEditorial.fromDto(dto, "OfferDetail"),
|
|
784
|
+
type: dto.type,
|
|
785
|
+
logoUrl: notBlankStringOrNull(dto.logo_url)
|
|
786
|
+
};
|
|
787
|
+
// `tagline`, `banner_url` and `starts_at` arrive as `null` and are left
|
|
788
|
+
// on the wire, as in `Offer.fromDto`.
|
|
789
|
+
case "ondo::swap":
|
|
790
|
+
return {
|
|
791
|
+
...base2,
|
|
792
|
+
type: dto.type,
|
|
793
|
+
logoUrl: notBlankStringOrNull(dto.logo_url),
|
|
794
|
+
swapContracts: requiredArray(
|
|
795
|
+
dto.swap_contracts,
|
|
796
|
+
"OfferDetail.swap_contracts"
|
|
797
|
+
).map(OfferSwapContract.fromDto)
|
|
798
|
+
};
|
|
799
|
+
default:
|
|
800
|
+
return unknownTypeError(dto, "OfferDetail");
|
|
801
|
+
}
|
|
710
802
|
}
|
|
711
803
|
};
|
|
712
804
|
var OfferOption = {
|
|
@@ -829,6 +921,7 @@ async function createParticipation(api, params) {
|
|
|
829
921
|
}
|
|
830
922
|
|
|
831
923
|
// src/universal/core/shared/observability/log-cause.ts
|
|
924
|
+
var import_viem = require("viem");
|
|
832
925
|
function classifyLogCause(error) {
|
|
833
926
|
if (error instanceof HttpError) {
|
|
834
927
|
return httpCause(error);
|
|
@@ -848,8 +941,32 @@ function classifyLogCause(error) {
|
|
|
848
941
|
if (error instanceof NotImplementedError) {
|
|
849
942
|
return { type: "not-implemented" };
|
|
850
943
|
}
|
|
944
|
+
if (error instanceof import_viem.BaseError) {
|
|
945
|
+
const http = error.walk((e) => e instanceof HttpError);
|
|
946
|
+
if (http instanceof HttpError) {
|
|
947
|
+
return httpCause(http);
|
|
948
|
+
}
|
|
949
|
+
return { type: "rpc", reason: rpcFailureReason(error) };
|
|
950
|
+
}
|
|
851
951
|
return { type: "generic-error", name: errorName(error) };
|
|
852
952
|
}
|
|
953
|
+
function rpcFailureReason(error) {
|
|
954
|
+
if (error.walk((e) => e instanceof import_viem.ContractFunctionRevertedError)) {
|
|
955
|
+
return "reverted";
|
|
956
|
+
}
|
|
957
|
+
if (error.walk((e) => e instanceof import_viem.RpcError)) {
|
|
958
|
+
return "node-rejected";
|
|
959
|
+
}
|
|
960
|
+
if (error.walk(
|
|
961
|
+
(e) => e instanceof import_viem.HttpRequestError || e instanceof import_viem.WebSocketRequestError || e instanceof import_viem.SocketClosedError || e instanceof import_viem.TimeoutError
|
|
962
|
+
)) {
|
|
963
|
+
return "transport";
|
|
964
|
+
}
|
|
965
|
+
if (error instanceof import_viem.ContractFunctionExecutionError) {
|
|
966
|
+
return "malformed-response";
|
|
967
|
+
}
|
|
968
|
+
return "unknown";
|
|
969
|
+
}
|
|
853
970
|
function describeErrorUnredacted(error) {
|
|
854
971
|
if (error instanceof HttpError) {
|
|
855
972
|
return describeHttpErrorRedacted(error);
|
|
@@ -1123,7 +1240,7 @@ function assertPriceFits(raw) {
|
|
|
1123
1240
|
}
|
|
1124
1241
|
|
|
1125
1242
|
// src/universal/core/shared/blockchain/formatters.ts
|
|
1126
|
-
var
|
|
1243
|
+
var import_viem2 = require("viem");
|
|
1127
1244
|
|
|
1128
1245
|
// src/universal/types/blockchain/ui.ts
|
|
1129
1246
|
var FormattedAmountUi = (value) => value;
|
|
@@ -1189,7 +1306,7 @@ function roundFractionHalfUp(integerPart, fractionPart, maxFractionDigits) {
|
|
|
1189
1306
|
};
|
|
1190
1307
|
}
|
|
1191
1308
|
function formatRawAmount(amount) {
|
|
1192
|
-
return (0,
|
|
1309
|
+
return (0, import_viem2.formatUnits)(amount.raw, amount.decimals);
|
|
1193
1310
|
}
|
|
1194
1311
|
function formatCompactAmount(amount, locale) {
|
|
1195
1312
|
const value = Number(formatRawAmount(amount));
|
|
@@ -1228,18 +1345,22 @@ function formattedUsdPrice(amount, locale) {
|
|
|
1228
1345
|
}
|
|
1229
1346
|
|
|
1230
1347
|
// src/universal/core/shared/blockchain/chain.ts
|
|
1231
|
-
var
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1348
|
+
var import_chains = require("viem/chains");
|
|
1349
|
+
var VIEM_CHAINS = {
|
|
1350
|
+
ethereum_mainnet: import_chains.mainnet,
|
|
1351
|
+
ethereum_sepolia: import_chains.sepolia,
|
|
1352
|
+
base_mainnet: import_chains.base,
|
|
1353
|
+
base_sepolia: import_chains.baseSepolia
|
|
1236
1354
|
};
|
|
1355
|
+
function viemChain(chain) {
|
|
1356
|
+
return VIEM_CHAINS[chain];
|
|
1357
|
+
}
|
|
1237
1358
|
function getChainId(chain) {
|
|
1238
|
-
return
|
|
1359
|
+
return VIEM_CHAINS[chain].id;
|
|
1239
1360
|
}
|
|
1240
1361
|
function chainFromId(chainId) {
|
|
1241
|
-
const chains = Object.keys(
|
|
1242
|
-
const chain = chains.find((c) => String(
|
|
1362
|
+
const chains = Object.keys(VIEM_CHAINS);
|
|
1363
|
+
const chain = chains.find((c) => String(VIEM_CHAINS[c].id) === chainId);
|
|
1243
1364
|
if (!chain) {
|
|
1244
1365
|
throw new ValidationError(`Unsupported EIP-155 chain id: "${chainId}"`);
|
|
1245
1366
|
}
|
|
@@ -1282,7 +1403,7 @@ function explorerBaseUrl(chain) {
|
|
|
1282
1403
|
}
|
|
1283
1404
|
|
|
1284
1405
|
// src/universal/core/shared/blockchain/math.ts
|
|
1285
|
-
var
|
|
1406
|
+
var import_viem3 = require("viem");
|
|
1286
1407
|
function blockchainAmountFromRawOrThrow({
|
|
1287
1408
|
label,
|
|
1288
1409
|
raw,
|
|
@@ -1313,10 +1434,14 @@ function parseBlockchainAmount(amount, decimals) {
|
|
|
1313
1434
|
if (/[eE]/.test(trimmed)) {
|
|
1314
1435
|
return { valid: false, reason: { type: "invalid-format" } };
|
|
1315
1436
|
}
|
|
1316
|
-
if (
|
|
1437
|
+
if (trimmed === ".") {
|
|
1438
|
+
return { valid: false, reason: { type: "invalid-format" } };
|
|
1439
|
+
}
|
|
1440
|
+
const normalised = trimmed.replace(/^\./, "0.").replace(/\.$/, "");
|
|
1441
|
+
if (!/^\d+(\.\d+)?$/.test(normalised)) {
|
|
1317
1442
|
return { valid: false, reason: { type: "invalid-format" } };
|
|
1318
1443
|
}
|
|
1319
|
-
const [, fraction = ""] =
|
|
1444
|
+
const [, fraction = ""] = normalised.split(".");
|
|
1320
1445
|
if (fraction.length > decimals) {
|
|
1321
1446
|
return {
|
|
1322
1447
|
valid: false,
|
|
@@ -1324,7 +1449,7 @@ function parseBlockchainAmount(amount, decimals) {
|
|
|
1324
1449
|
};
|
|
1325
1450
|
}
|
|
1326
1451
|
try {
|
|
1327
|
-
const raw = (0,
|
|
1452
|
+
const raw = (0, import_viem3.parseUnits)(normalised, decimals);
|
|
1328
1453
|
if (raw > MAX_UINT_256) {
|
|
1329
1454
|
return { valid: false, reason: { type: "overflow" } };
|
|
1330
1455
|
}
|
|
@@ -1337,9 +1462,6 @@ function parseBlockchainAmount(amount, decimals) {
|
|
|
1337
1462
|
}
|
|
1338
1463
|
}
|
|
1339
1464
|
|
|
1340
|
-
// src/universal/types/trading.ts
|
|
1341
|
-
var Ticker = (value) => value;
|
|
1342
|
-
|
|
1343
1465
|
// src/universal/types/providers/ondo/ondo.ts
|
|
1344
1466
|
var OndoTradingStatus = {
|
|
1345
1467
|
fromDto: (dto) => {
|
|
@@ -1637,202 +1759,808 @@ var OndoNamespaceImpl = class {
|
|
|
1637
1759
|
var SUPERSTATE_SWAP_ABI = [
|
|
1638
1760
|
{
|
|
1639
1761
|
type: "function",
|
|
1640
|
-
name: "
|
|
1641
|
-
inputs: [
|
|
1642
|
-
outputs: [
|
|
1762
|
+
name: "KIND",
|
|
1763
|
+
inputs: [],
|
|
1764
|
+
outputs: [
|
|
1765
|
+
{
|
|
1766
|
+
name: "",
|
|
1767
|
+
type: "uint16",
|
|
1768
|
+
internalType: "uint16"
|
|
1769
|
+
}
|
|
1770
|
+
],
|
|
1643
1771
|
stateMutability: "view"
|
|
1644
1772
|
},
|
|
1645
1773
|
{
|
|
1646
1774
|
type: "function",
|
|
1647
|
-
name: "
|
|
1775
|
+
name: "ONE_HUNDRED_P",
|
|
1648
1776
|
inputs: [],
|
|
1649
|
-
outputs: [
|
|
1777
|
+
outputs: [
|
|
1778
|
+
{
|
|
1779
|
+
name: "",
|
|
1780
|
+
type: "uint256",
|
|
1781
|
+
internalType: "uint256"
|
|
1782
|
+
}
|
|
1783
|
+
],
|
|
1650
1784
|
stateMutability: "view"
|
|
1651
1785
|
},
|
|
1652
1786
|
{
|
|
1653
1787
|
type: "function",
|
|
1654
1788
|
name: "SWAP_LEVEL",
|
|
1655
1789
|
inputs: [],
|
|
1656
|
-
outputs: [
|
|
1790
|
+
outputs: [
|
|
1791
|
+
{
|
|
1792
|
+
name: "",
|
|
1793
|
+
type: "uint32",
|
|
1794
|
+
internalType: "uint32"
|
|
1795
|
+
}
|
|
1796
|
+
],
|
|
1657
1797
|
stateMutability: "view"
|
|
1658
1798
|
},
|
|
1659
1799
|
{
|
|
1660
1800
|
type: "function",
|
|
1661
|
-
name: "
|
|
1662
|
-
inputs: [
|
|
1663
|
-
{ name: "token", type: "address", internalType: "address" },
|
|
1664
|
-
{ name: "amount", type: "uint256", internalType: "uint256" }
|
|
1665
|
-
],
|
|
1801
|
+
name: "VERSION",
|
|
1802
|
+
inputs: [],
|
|
1666
1803
|
outputs: [
|
|
1667
1804
|
{
|
|
1668
1805
|
name: "",
|
|
1669
|
-
type: "
|
|
1670
|
-
internalType: "
|
|
1671
|
-
components: [
|
|
1672
|
-
{ name: "input", type: "uint256", internalType: "uint256" },
|
|
1673
|
-
{ name: "fee", type: "uint256", internalType: "uint256" },
|
|
1674
|
-
{ name: "output", type: "uint256", internalType: "uint256" }
|
|
1675
|
-
]
|
|
1806
|
+
type: "uint16",
|
|
1807
|
+
internalType: "uint16"
|
|
1676
1808
|
}
|
|
1677
1809
|
],
|
|
1678
1810
|
stateMutability: "view"
|
|
1679
1811
|
},
|
|
1680
1812
|
{
|
|
1681
1813
|
type: "function",
|
|
1682
|
-
name: "
|
|
1814
|
+
name: "authorized",
|
|
1683
1815
|
inputs: [
|
|
1684
|
-
{
|
|
1685
|
-
|
|
1686
|
-
|
|
1816
|
+
{
|
|
1817
|
+
name: "user",
|
|
1818
|
+
type: "address",
|
|
1819
|
+
internalType: "address"
|
|
1820
|
+
}
|
|
1687
1821
|
],
|
|
1688
|
-
outputs: [
|
|
1689
|
-
|
|
1822
|
+
outputs: [
|
|
1823
|
+
{
|
|
1824
|
+
name: "",
|
|
1825
|
+
type: "bool",
|
|
1826
|
+
internalType: "bool"
|
|
1827
|
+
}
|
|
1828
|
+
],
|
|
1829
|
+
stateMutability: "view"
|
|
1690
1830
|
},
|
|
1691
1831
|
{
|
|
1692
1832
|
type: "function",
|
|
1693
|
-
name: "
|
|
1694
|
-
inputs: [
|
|
1695
|
-
|
|
1833
|
+
name: "bpp",
|
|
1834
|
+
inputs: [
|
|
1835
|
+
{
|
|
1836
|
+
name: "amount",
|
|
1837
|
+
type: "uint256",
|
|
1838
|
+
internalType: "uint256"
|
|
1839
|
+
}
|
|
1840
|
+
],
|
|
1841
|
+
outputs: [
|
|
1842
|
+
{
|
|
1843
|
+
name: "",
|
|
1844
|
+
type: "uint256",
|
|
1845
|
+
internalType: "uint256"
|
|
1846
|
+
}
|
|
1847
|
+
],
|
|
1696
1848
|
stateMutability: "view"
|
|
1697
1849
|
},
|
|
1698
1850
|
{
|
|
1699
1851
|
type: "function",
|
|
1700
|
-
name: "
|
|
1852
|
+
name: "bps",
|
|
1701
1853
|
inputs: [],
|
|
1702
|
-
outputs: [
|
|
1854
|
+
outputs: [
|
|
1855
|
+
{
|
|
1856
|
+
name: "",
|
|
1857
|
+
type: "uint256",
|
|
1858
|
+
internalType: "uint256"
|
|
1859
|
+
}
|
|
1860
|
+
],
|
|
1703
1861
|
stateMutability: "view"
|
|
1704
1862
|
},
|
|
1705
1863
|
{
|
|
1706
1864
|
type: "function",
|
|
1707
|
-
name: "
|
|
1865
|
+
name: "cancelOwnershipHandover",
|
|
1708
1866
|
inputs: [],
|
|
1709
|
-
outputs: [
|
|
1710
|
-
stateMutability: "
|
|
1867
|
+
outputs: [],
|
|
1868
|
+
stateMutability: "payable"
|
|
1711
1869
|
},
|
|
1712
1870
|
{
|
|
1713
1871
|
type: "function",
|
|
1714
|
-
name: "
|
|
1715
|
-
inputs: [
|
|
1716
|
-
outputs: [
|
|
1872
|
+
name: "completeOwnershipHandover",
|
|
1873
|
+
inputs: [
|
|
1717
1874
|
{
|
|
1718
|
-
name: "",
|
|
1719
|
-
type: "
|
|
1720
|
-
internalType: "
|
|
1721
|
-
components: [
|
|
1722
|
-
{ name: "inputSum", type: "uint256", internalType: "uint256" },
|
|
1723
|
-
{ name: "feeSum", type: "uint256", internalType: "uint256" },
|
|
1724
|
-
{ name: "outputSum", type: "uint256", internalType: "uint256" },
|
|
1725
|
-
{ name: "count", type: "uint256", internalType: "uint256" }
|
|
1726
|
-
]
|
|
1875
|
+
name: "pendingOwner",
|
|
1876
|
+
type: "address",
|
|
1877
|
+
internalType: "address"
|
|
1727
1878
|
}
|
|
1728
1879
|
],
|
|
1729
|
-
|
|
1880
|
+
outputs: [],
|
|
1881
|
+
stateMutability: "payable"
|
|
1730
1882
|
},
|
|
1731
1883
|
{
|
|
1732
1884
|
type: "function",
|
|
1733
|
-
name: "
|
|
1885
|
+
name: "fee",
|
|
1734
1886
|
inputs: [
|
|
1735
|
-
{
|
|
1736
|
-
|
|
1887
|
+
{
|
|
1888
|
+
name: "amount",
|
|
1889
|
+
type: "uint256",
|
|
1890
|
+
internalType: "uint256"
|
|
1891
|
+
}
|
|
1737
1892
|
],
|
|
1738
1893
|
outputs: [
|
|
1739
1894
|
{
|
|
1740
1895
|
name: "",
|
|
1741
|
-
type: "
|
|
1742
|
-
internalType: "
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
]
|
|
1896
|
+
type: "uint256",
|
|
1897
|
+
internalType: "uint256"
|
|
1898
|
+
},
|
|
1899
|
+
{
|
|
1900
|
+
name: "",
|
|
1901
|
+
type: "uint256",
|
|
1902
|
+
internalType: "uint256"
|
|
1749
1903
|
}
|
|
1750
1904
|
],
|
|
1751
1905
|
stateMutability: "view"
|
|
1752
1906
|
},
|
|
1753
1907
|
{
|
|
1754
1908
|
type: "function",
|
|
1755
|
-
name: "
|
|
1756
|
-
inputs: [
|
|
1757
|
-
|
|
1758
|
-
{
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
{
|
|
1764
|
-
type: "function",
|
|
1765
|
-
name: "transfer",
|
|
1766
|
-
inputs: [
|
|
1767
|
-
{ name: "to", type: "address", internalType: "address" },
|
|
1768
|
-
{ name: "token", type: "address", internalType: "address" },
|
|
1769
|
-
{ name: "amount", type: "uint256", internalType: "uint256" }
|
|
1909
|
+
name: "id",
|
|
1910
|
+
inputs: [],
|
|
1911
|
+
outputs: [
|
|
1912
|
+
{
|
|
1913
|
+
name: "",
|
|
1914
|
+
type: "bytes32",
|
|
1915
|
+
internalType: "bytes32"
|
|
1916
|
+
}
|
|
1770
1917
|
],
|
|
1771
|
-
|
|
1772
|
-
stateMutability: "nonpayable"
|
|
1918
|
+
stateMutability: "view"
|
|
1773
1919
|
},
|
|
1774
1920
|
{
|
|
1775
1921
|
type: "function",
|
|
1776
|
-
name: "
|
|
1777
|
-
inputs: [{ name: "points", type: "uint256", internalType: "uint256" }],
|
|
1778
|
-
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
1779
|
-
stateMutability: "nonpayable"
|
|
1780
|
-
},
|
|
1781
|
-
{
|
|
1782
|
-
type: "event",
|
|
1783
|
-
name: "Swapped",
|
|
1922
|
+
name: "inputTokens",
|
|
1784
1923
|
inputs: [
|
|
1785
|
-
{ name: "user", type: "address", indexed: true, internalType: "address" },
|
|
1786
|
-
{
|
|
1787
|
-
name: "inputToken",
|
|
1788
|
-
type: "address",
|
|
1789
|
-
indexed: true,
|
|
1790
|
-
internalType: "address"
|
|
1791
|
-
},
|
|
1792
1924
|
{
|
|
1793
|
-
name: "
|
|
1925
|
+
name: "",
|
|
1794
1926
|
type: "address",
|
|
1795
|
-
indexed: true,
|
|
1796
1927
|
internalType: "address"
|
|
1797
|
-
}
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
type: "uint256",
|
|
1801
|
-
indexed: false,
|
|
1802
|
-
internalType: "uint256"
|
|
1803
|
-
},
|
|
1928
|
+
}
|
|
1929
|
+
],
|
|
1930
|
+
outputs: [
|
|
1804
1931
|
{
|
|
1805
|
-
name: "
|
|
1806
|
-
type: "
|
|
1807
|
-
|
|
1808
|
-
internalType: "uint256"
|
|
1932
|
+
name: "",
|
|
1933
|
+
type: "bool",
|
|
1934
|
+
internalType: "bool"
|
|
1809
1935
|
}
|
|
1810
1936
|
],
|
|
1811
|
-
|
|
1937
|
+
stateMutability: "view"
|
|
1812
1938
|
},
|
|
1813
1939
|
{
|
|
1814
|
-
type: "
|
|
1815
|
-
name: "
|
|
1816
|
-
inputs: [
|
|
1817
|
-
|
|
1940
|
+
type: "function",
|
|
1941
|
+
name: "outputToken",
|
|
1942
|
+
inputs: [],
|
|
1943
|
+
outputs: [
|
|
1818
1944
|
{
|
|
1819
|
-
name: "
|
|
1945
|
+
name: "",
|
|
1820
1946
|
type: "address",
|
|
1821
|
-
indexed: true,
|
|
1822
1947
|
internalType: "address"
|
|
1823
|
-
},
|
|
1824
|
-
{
|
|
1825
|
-
name: "amount",
|
|
1826
|
-
type: "uint256",
|
|
1827
|
-
indexed: false,
|
|
1828
|
-
internalType: "uint256"
|
|
1829
1948
|
}
|
|
1830
1949
|
],
|
|
1831
|
-
|
|
1950
|
+
stateMutability: "view"
|
|
1951
|
+
},
|
|
1952
|
+
{
|
|
1953
|
+
type: "function",
|
|
1954
|
+
name: "outputTokenBalance",
|
|
1955
|
+
inputs: [],
|
|
1956
|
+
outputs: [
|
|
1957
|
+
{
|
|
1958
|
+
name: "",
|
|
1959
|
+
type: "uint256",
|
|
1960
|
+
internalType: "uint256"
|
|
1961
|
+
}
|
|
1962
|
+
],
|
|
1963
|
+
stateMutability: "view"
|
|
1964
|
+
},
|
|
1965
|
+
{
|
|
1966
|
+
type: "function",
|
|
1967
|
+
name: "owner",
|
|
1968
|
+
inputs: [],
|
|
1969
|
+
outputs: [
|
|
1970
|
+
{
|
|
1971
|
+
name: "result",
|
|
1972
|
+
type: "address",
|
|
1973
|
+
internalType: "address"
|
|
1974
|
+
}
|
|
1975
|
+
],
|
|
1976
|
+
stateMutability: "view"
|
|
1977
|
+
},
|
|
1978
|
+
{
|
|
1979
|
+
type: "function",
|
|
1980
|
+
name: "ownershipHandoverExpiresAt",
|
|
1981
|
+
inputs: [
|
|
1982
|
+
{
|
|
1983
|
+
name: "pendingOwner",
|
|
1984
|
+
type: "address",
|
|
1985
|
+
internalType: "address"
|
|
1986
|
+
}
|
|
1987
|
+
],
|
|
1988
|
+
outputs: [
|
|
1989
|
+
{
|
|
1990
|
+
name: "result",
|
|
1991
|
+
type: "uint256",
|
|
1992
|
+
internalType: "uint256"
|
|
1993
|
+
}
|
|
1994
|
+
],
|
|
1995
|
+
stateMutability: "view"
|
|
1996
|
+
},
|
|
1997
|
+
{
|
|
1998
|
+
type: "function",
|
|
1999
|
+
name: "pause",
|
|
2000
|
+
inputs: [
|
|
2001
|
+
{
|
|
2002
|
+
name: "level",
|
|
2003
|
+
type: "uint32",
|
|
2004
|
+
internalType: "uint32"
|
|
2005
|
+
}
|
|
2006
|
+
],
|
|
2007
|
+
outputs: [
|
|
2008
|
+
{
|
|
2009
|
+
name: "",
|
|
2010
|
+
type: "bool",
|
|
2011
|
+
internalType: "bool"
|
|
2012
|
+
}
|
|
2013
|
+
],
|
|
2014
|
+
stateMutability: "nonpayable"
|
|
2015
|
+
},
|
|
2016
|
+
{
|
|
2017
|
+
type: "function",
|
|
2018
|
+
name: "paused",
|
|
2019
|
+
inputs: [],
|
|
2020
|
+
outputs: [
|
|
2021
|
+
{
|
|
2022
|
+
name: "",
|
|
2023
|
+
type: "uint32",
|
|
2024
|
+
internalType: "uint32"
|
|
2025
|
+
}
|
|
2026
|
+
],
|
|
2027
|
+
stateMutability: "view"
|
|
2028
|
+
},
|
|
2029
|
+
{
|
|
2030
|
+
type: "function",
|
|
2031
|
+
name: "preview",
|
|
2032
|
+
inputs: [
|
|
2033
|
+
{
|
|
2034
|
+
name: "token",
|
|
2035
|
+
type: "address",
|
|
2036
|
+
internalType: "address"
|
|
2037
|
+
},
|
|
2038
|
+
{
|
|
2039
|
+
name: "amount",
|
|
2040
|
+
type: "uint256",
|
|
2041
|
+
internalType: "uint256"
|
|
2042
|
+
}
|
|
2043
|
+
],
|
|
2044
|
+
outputs: [
|
|
2045
|
+
{
|
|
2046
|
+
name: "",
|
|
2047
|
+
type: "tuple",
|
|
2048
|
+
internalType: "struct Preview",
|
|
2049
|
+
components: [
|
|
2050
|
+
{
|
|
2051
|
+
name: "input",
|
|
2052
|
+
type: "uint256",
|
|
2053
|
+
internalType: "uint256"
|
|
2054
|
+
},
|
|
2055
|
+
{
|
|
2056
|
+
name: "fee",
|
|
2057
|
+
type: "uint256",
|
|
2058
|
+
internalType: "uint256"
|
|
2059
|
+
},
|
|
2060
|
+
{
|
|
2061
|
+
name: "output",
|
|
2062
|
+
type: "uint256",
|
|
2063
|
+
internalType: "uint256"
|
|
2064
|
+
}
|
|
2065
|
+
]
|
|
2066
|
+
}
|
|
2067
|
+
],
|
|
2068
|
+
stateMutability: "view"
|
|
2069
|
+
},
|
|
2070
|
+
{
|
|
2071
|
+
type: "function",
|
|
2072
|
+
name: "renounceOwnership",
|
|
2073
|
+
inputs: [],
|
|
2074
|
+
outputs: [],
|
|
2075
|
+
stateMutability: "payable"
|
|
2076
|
+
},
|
|
2077
|
+
{
|
|
2078
|
+
type: "function",
|
|
2079
|
+
name: "requestOwnershipHandover",
|
|
2080
|
+
inputs: [],
|
|
2081
|
+
outputs: [],
|
|
2082
|
+
stateMutability: "payable"
|
|
2083
|
+
},
|
|
2084
|
+
{
|
|
2085
|
+
type: "function",
|
|
2086
|
+
name: "setBps",
|
|
2087
|
+
inputs: [
|
|
2088
|
+
{
|
|
2089
|
+
name: "points",
|
|
2090
|
+
type: "uint256",
|
|
2091
|
+
internalType: "uint256"
|
|
2092
|
+
}
|
|
2093
|
+
],
|
|
2094
|
+
outputs: [
|
|
2095
|
+
{
|
|
2096
|
+
name: "",
|
|
2097
|
+
type: "bool",
|
|
2098
|
+
internalType: "bool"
|
|
2099
|
+
}
|
|
2100
|
+
],
|
|
2101
|
+
stateMutability: "nonpayable"
|
|
2102
|
+
},
|
|
2103
|
+
{
|
|
2104
|
+
type: "function",
|
|
2105
|
+
name: "setInputToken",
|
|
2106
|
+
inputs: [
|
|
2107
|
+
{
|
|
2108
|
+
name: "token",
|
|
2109
|
+
type: "address",
|
|
2110
|
+
internalType: "address"
|
|
2111
|
+
},
|
|
2112
|
+
{
|
|
2113
|
+
name: "val",
|
|
2114
|
+
type: "bool",
|
|
2115
|
+
internalType: "bool"
|
|
2116
|
+
}
|
|
2117
|
+
],
|
|
2118
|
+
outputs: [
|
|
2119
|
+
{
|
|
2120
|
+
name: "",
|
|
2121
|
+
type: "bool",
|
|
2122
|
+
internalType: "bool"
|
|
2123
|
+
}
|
|
2124
|
+
],
|
|
2125
|
+
stateMutability: "nonpayable"
|
|
2126
|
+
},
|
|
2127
|
+
{
|
|
2128
|
+
type: "function",
|
|
2129
|
+
name: "status",
|
|
2130
|
+
inputs: [],
|
|
2131
|
+
outputs: [
|
|
2132
|
+
{
|
|
2133
|
+
name: "",
|
|
2134
|
+
type: "tuple",
|
|
2135
|
+
internalType: "struct Status",
|
|
2136
|
+
components: [
|
|
2137
|
+
{
|
|
2138
|
+
name: "flags",
|
|
2139
|
+
type: "uint32",
|
|
2140
|
+
internalType: "uint32"
|
|
2141
|
+
},
|
|
2142
|
+
{
|
|
2143
|
+
name: "state",
|
|
2144
|
+
type: "uint8",
|
|
2145
|
+
internalType: "enum State"
|
|
2146
|
+
}
|
|
2147
|
+
]
|
|
2148
|
+
}
|
|
2149
|
+
],
|
|
2150
|
+
stateMutability: "view"
|
|
2151
|
+
},
|
|
2152
|
+
{
|
|
2153
|
+
type: "function",
|
|
2154
|
+
name: "stop",
|
|
2155
|
+
inputs: [],
|
|
2156
|
+
outputs: [
|
|
2157
|
+
{
|
|
2158
|
+
name: "",
|
|
2159
|
+
type: "bool",
|
|
2160
|
+
internalType: "bool"
|
|
2161
|
+
}
|
|
2162
|
+
],
|
|
2163
|
+
stateMutability: "nonpayable"
|
|
2164
|
+
},
|
|
2165
|
+
{
|
|
2166
|
+
type: "function",
|
|
2167
|
+
name: "stopped",
|
|
2168
|
+
inputs: [],
|
|
2169
|
+
outputs: [
|
|
2170
|
+
{
|
|
2171
|
+
name: "",
|
|
2172
|
+
type: "bool",
|
|
2173
|
+
internalType: "bool"
|
|
2174
|
+
}
|
|
2175
|
+
],
|
|
2176
|
+
stateMutability: "view"
|
|
2177
|
+
},
|
|
2178
|
+
{
|
|
2179
|
+
type: "function",
|
|
2180
|
+
name: "swap",
|
|
2181
|
+
inputs: [
|
|
2182
|
+
{
|
|
2183
|
+
name: "token",
|
|
2184
|
+
type: "address",
|
|
2185
|
+
internalType: "address"
|
|
2186
|
+
},
|
|
2187
|
+
{
|
|
2188
|
+
name: "amount",
|
|
2189
|
+
type: "uint256",
|
|
2190
|
+
internalType: "uint256"
|
|
2191
|
+
},
|
|
2192
|
+
{
|
|
2193
|
+
name: "slip",
|
|
2194
|
+
type: "uint256",
|
|
2195
|
+
internalType: "uint256"
|
|
2196
|
+
}
|
|
2197
|
+
],
|
|
2198
|
+
outputs: [
|
|
2199
|
+
{
|
|
2200
|
+
name: "",
|
|
2201
|
+
type: "uint256",
|
|
2202
|
+
internalType: "uint256"
|
|
2203
|
+
}
|
|
2204
|
+
],
|
|
2205
|
+
stateMutability: "nonpayable"
|
|
2206
|
+
},
|
|
2207
|
+
{
|
|
2208
|
+
type: "function",
|
|
2209
|
+
name: "tokenBalance",
|
|
2210
|
+
inputs: [
|
|
2211
|
+
{
|
|
2212
|
+
name: "token",
|
|
2213
|
+
type: "address",
|
|
2214
|
+
internalType: "address"
|
|
2215
|
+
}
|
|
2216
|
+
],
|
|
2217
|
+
outputs: [
|
|
2218
|
+
{
|
|
2219
|
+
name: "",
|
|
2220
|
+
type: "uint256",
|
|
2221
|
+
internalType: "uint256"
|
|
2222
|
+
}
|
|
2223
|
+
],
|
|
2224
|
+
stateMutability: "view"
|
|
2225
|
+
},
|
|
2226
|
+
{
|
|
2227
|
+
type: "function",
|
|
2228
|
+
name: "totals",
|
|
2229
|
+
inputs: [
|
|
2230
|
+
{
|
|
2231
|
+
name: "user",
|
|
2232
|
+
type: "address",
|
|
2233
|
+
internalType: "address"
|
|
2234
|
+
},
|
|
2235
|
+
{
|
|
2236
|
+
name: "token",
|
|
2237
|
+
type: "address",
|
|
2238
|
+
internalType: "address"
|
|
2239
|
+
}
|
|
2240
|
+
],
|
|
2241
|
+
outputs: [
|
|
2242
|
+
{
|
|
2243
|
+
name: "",
|
|
2244
|
+
type: "tuple",
|
|
2245
|
+
internalType: "struct SwapTotal",
|
|
2246
|
+
components: [
|
|
2247
|
+
{
|
|
2248
|
+
name: "inputSum",
|
|
2249
|
+
type: "uint256",
|
|
2250
|
+
internalType: "uint256"
|
|
2251
|
+
},
|
|
2252
|
+
{
|
|
2253
|
+
name: "feeSum",
|
|
2254
|
+
type: "uint256",
|
|
2255
|
+
internalType: "uint256"
|
|
2256
|
+
},
|
|
2257
|
+
{
|
|
2258
|
+
name: "outputSum",
|
|
2259
|
+
type: "uint256",
|
|
2260
|
+
internalType: "uint256"
|
|
2261
|
+
},
|
|
2262
|
+
{
|
|
2263
|
+
name: "count",
|
|
2264
|
+
type: "uint256",
|
|
2265
|
+
internalType: "uint256"
|
|
2266
|
+
}
|
|
2267
|
+
]
|
|
2268
|
+
}
|
|
2269
|
+
],
|
|
2270
|
+
stateMutability: "view"
|
|
2271
|
+
},
|
|
2272
|
+
{
|
|
2273
|
+
type: "function",
|
|
2274
|
+
name: "totals",
|
|
2275
|
+
inputs: [
|
|
2276
|
+
{
|
|
2277
|
+
name: "token",
|
|
2278
|
+
type: "address",
|
|
2279
|
+
internalType: "address"
|
|
2280
|
+
}
|
|
2281
|
+
],
|
|
2282
|
+
outputs: [
|
|
2283
|
+
{
|
|
2284
|
+
name: "",
|
|
2285
|
+
type: "tuple",
|
|
2286
|
+
internalType: "struct SwapTotal",
|
|
2287
|
+
components: [
|
|
2288
|
+
{
|
|
2289
|
+
name: "inputSum",
|
|
2290
|
+
type: "uint256",
|
|
2291
|
+
internalType: "uint256"
|
|
2292
|
+
},
|
|
2293
|
+
{
|
|
2294
|
+
name: "feeSum",
|
|
2295
|
+
type: "uint256",
|
|
2296
|
+
internalType: "uint256"
|
|
2297
|
+
},
|
|
2298
|
+
{
|
|
2299
|
+
name: "outputSum",
|
|
2300
|
+
type: "uint256",
|
|
2301
|
+
internalType: "uint256"
|
|
2302
|
+
},
|
|
2303
|
+
{
|
|
2304
|
+
name: "count",
|
|
2305
|
+
type: "uint256",
|
|
2306
|
+
internalType: "uint256"
|
|
2307
|
+
}
|
|
2308
|
+
]
|
|
2309
|
+
}
|
|
2310
|
+
],
|
|
2311
|
+
stateMutability: "view"
|
|
2312
|
+
},
|
|
2313
|
+
{
|
|
2314
|
+
type: "function",
|
|
2315
|
+
name: "transfer",
|
|
2316
|
+
inputs: [
|
|
2317
|
+
{
|
|
2318
|
+
name: "to",
|
|
2319
|
+
type: "address",
|
|
2320
|
+
internalType: "address"
|
|
2321
|
+
},
|
|
2322
|
+
{
|
|
2323
|
+
name: "amount",
|
|
2324
|
+
type: "uint256",
|
|
2325
|
+
internalType: "uint256"
|
|
2326
|
+
}
|
|
2327
|
+
],
|
|
2328
|
+
outputs: [
|
|
2329
|
+
{
|
|
2330
|
+
name: "",
|
|
2331
|
+
type: "bool",
|
|
2332
|
+
internalType: "bool"
|
|
2333
|
+
}
|
|
2334
|
+
],
|
|
2335
|
+
stateMutability: "nonpayable"
|
|
2336
|
+
},
|
|
2337
|
+
{
|
|
2338
|
+
type: "function",
|
|
2339
|
+
name: "transfer",
|
|
2340
|
+
inputs: [
|
|
2341
|
+
{
|
|
2342
|
+
name: "to",
|
|
2343
|
+
type: "address",
|
|
2344
|
+
internalType: "address"
|
|
2345
|
+
},
|
|
2346
|
+
{
|
|
2347
|
+
name: "token",
|
|
2348
|
+
type: "address",
|
|
2349
|
+
internalType: "address"
|
|
2350
|
+
},
|
|
2351
|
+
{
|
|
2352
|
+
name: "amount",
|
|
2353
|
+
type: "uint256",
|
|
2354
|
+
internalType: "uint256"
|
|
2355
|
+
}
|
|
2356
|
+
],
|
|
2357
|
+
outputs: [
|
|
2358
|
+
{
|
|
2359
|
+
name: "",
|
|
2360
|
+
type: "bool",
|
|
2361
|
+
internalType: "bool"
|
|
2362
|
+
}
|
|
2363
|
+
],
|
|
2364
|
+
stateMutability: "nonpayable"
|
|
2365
|
+
},
|
|
2366
|
+
{
|
|
2367
|
+
type: "function",
|
|
2368
|
+
name: "transferOwnership",
|
|
2369
|
+
inputs: [
|
|
2370
|
+
{
|
|
2371
|
+
name: "newOwner",
|
|
2372
|
+
type: "address",
|
|
2373
|
+
internalType: "address"
|
|
2374
|
+
}
|
|
2375
|
+
],
|
|
2376
|
+
outputs: [],
|
|
2377
|
+
stateMutability: "payable"
|
|
2378
|
+
},
|
|
2379
|
+
{
|
|
2380
|
+
type: "event",
|
|
2381
|
+
name: "BpsUpdated",
|
|
2382
|
+
inputs: [
|
|
2383
|
+
{
|
|
2384
|
+
name: "prev",
|
|
2385
|
+
type: "uint256",
|
|
2386
|
+
indexed: false,
|
|
2387
|
+
internalType: "uint256"
|
|
2388
|
+
},
|
|
2389
|
+
{
|
|
2390
|
+
name: "next",
|
|
2391
|
+
type: "uint256",
|
|
2392
|
+
indexed: false,
|
|
2393
|
+
internalType: "uint256"
|
|
2394
|
+
}
|
|
2395
|
+
],
|
|
2396
|
+
anonymous: false
|
|
2397
|
+
},
|
|
2398
|
+
{
|
|
2399
|
+
type: "event",
|
|
2400
|
+
name: "InputTokenUpdated",
|
|
2401
|
+
inputs: [
|
|
2402
|
+
{
|
|
2403
|
+
name: "token",
|
|
2404
|
+
type: "address",
|
|
2405
|
+
indexed: true,
|
|
2406
|
+
internalType: "address"
|
|
2407
|
+
},
|
|
2408
|
+
{
|
|
2409
|
+
name: "prev",
|
|
2410
|
+
type: "bool",
|
|
2411
|
+
indexed: false,
|
|
2412
|
+
internalType: "bool"
|
|
2413
|
+
},
|
|
2414
|
+
{
|
|
2415
|
+
name: "next",
|
|
2416
|
+
type: "bool",
|
|
2417
|
+
indexed: false,
|
|
2418
|
+
internalType: "bool"
|
|
2419
|
+
}
|
|
2420
|
+
],
|
|
2421
|
+
anonymous: false
|
|
2422
|
+
},
|
|
2423
|
+
{
|
|
2424
|
+
type: "event",
|
|
2425
|
+
name: "OwnershipHandoverCanceled",
|
|
2426
|
+
inputs: [
|
|
2427
|
+
{
|
|
2428
|
+
name: "pendingOwner",
|
|
2429
|
+
type: "address",
|
|
2430
|
+
indexed: true,
|
|
2431
|
+
internalType: "address"
|
|
2432
|
+
}
|
|
2433
|
+
],
|
|
2434
|
+
anonymous: false
|
|
2435
|
+
},
|
|
2436
|
+
{
|
|
2437
|
+
type: "event",
|
|
2438
|
+
name: "OwnershipHandoverRequested",
|
|
2439
|
+
inputs: [
|
|
2440
|
+
{
|
|
2441
|
+
name: "pendingOwner",
|
|
2442
|
+
type: "address",
|
|
2443
|
+
indexed: true,
|
|
2444
|
+
internalType: "address"
|
|
2445
|
+
}
|
|
2446
|
+
],
|
|
2447
|
+
anonymous: false
|
|
2448
|
+
},
|
|
2449
|
+
{
|
|
2450
|
+
type: "event",
|
|
2451
|
+
name: "OwnershipTransferred",
|
|
2452
|
+
inputs: [
|
|
2453
|
+
{
|
|
2454
|
+
name: "oldOwner",
|
|
2455
|
+
type: "address",
|
|
2456
|
+
indexed: true,
|
|
2457
|
+
internalType: "address"
|
|
2458
|
+
},
|
|
2459
|
+
{
|
|
2460
|
+
name: "newOwner",
|
|
2461
|
+
type: "address",
|
|
2462
|
+
indexed: true,
|
|
2463
|
+
internalType: "address"
|
|
2464
|
+
}
|
|
2465
|
+
],
|
|
2466
|
+
anonymous: false
|
|
2467
|
+
},
|
|
2468
|
+
{
|
|
2469
|
+
type: "event",
|
|
2470
|
+
name: "Paused",
|
|
2471
|
+
inputs: [
|
|
2472
|
+
{
|
|
2473
|
+
name: "previous",
|
|
2474
|
+
type: "uint32",
|
|
2475
|
+
indexed: false,
|
|
2476
|
+
internalType: "uint32"
|
|
2477
|
+
},
|
|
2478
|
+
{
|
|
2479
|
+
name: "next",
|
|
2480
|
+
type: "uint32",
|
|
2481
|
+
indexed: false,
|
|
2482
|
+
internalType: "uint32"
|
|
2483
|
+
}
|
|
2484
|
+
],
|
|
2485
|
+
anonymous: false
|
|
2486
|
+
},
|
|
2487
|
+
{
|
|
2488
|
+
type: "event",
|
|
2489
|
+
name: "Stopped",
|
|
2490
|
+
inputs: [],
|
|
2491
|
+
anonymous: false
|
|
2492
|
+
},
|
|
2493
|
+
{
|
|
2494
|
+
type: "event",
|
|
2495
|
+
name: "Swapped",
|
|
2496
|
+
inputs: [
|
|
2497
|
+
{
|
|
2498
|
+
name: "user",
|
|
2499
|
+
type: "address",
|
|
2500
|
+
indexed: true,
|
|
2501
|
+
internalType: "address"
|
|
2502
|
+
},
|
|
2503
|
+
{
|
|
2504
|
+
name: "inputToken",
|
|
2505
|
+
type: "address",
|
|
2506
|
+
indexed: true,
|
|
2507
|
+
internalType: "address"
|
|
2508
|
+
},
|
|
2509
|
+
{
|
|
2510
|
+
name: "outputToken",
|
|
2511
|
+
type: "address",
|
|
2512
|
+
indexed: true,
|
|
2513
|
+
internalType: "address"
|
|
2514
|
+
},
|
|
2515
|
+
{
|
|
2516
|
+
name: "inputAmount",
|
|
2517
|
+
type: "uint256",
|
|
2518
|
+
indexed: false,
|
|
2519
|
+
internalType: "uint256"
|
|
2520
|
+
},
|
|
2521
|
+
{
|
|
2522
|
+
name: "fee",
|
|
2523
|
+
type: "uint256",
|
|
2524
|
+
indexed: false,
|
|
2525
|
+
internalType: "uint256"
|
|
2526
|
+
},
|
|
2527
|
+
{
|
|
2528
|
+
name: "outputAmount",
|
|
2529
|
+
type: "uint256",
|
|
2530
|
+
indexed: false,
|
|
2531
|
+
internalType: "uint256"
|
|
2532
|
+
}
|
|
2533
|
+
],
|
|
2534
|
+
anonymous: false
|
|
2535
|
+
},
|
|
2536
|
+
{
|
|
2537
|
+
type: "event",
|
|
2538
|
+
name: "Transferred",
|
|
2539
|
+
inputs: [
|
|
2540
|
+
{
|
|
2541
|
+
name: "to",
|
|
2542
|
+
type: "address",
|
|
2543
|
+
indexed: true,
|
|
2544
|
+
internalType: "address"
|
|
2545
|
+
},
|
|
2546
|
+
{
|
|
2547
|
+
name: "token",
|
|
2548
|
+
type: "address",
|
|
2549
|
+
indexed: true,
|
|
2550
|
+
internalType: "address"
|
|
2551
|
+
},
|
|
2552
|
+
{
|
|
2553
|
+
name: "amount",
|
|
2554
|
+
type: "uint256",
|
|
2555
|
+
indexed: false,
|
|
2556
|
+
internalType: "uint256"
|
|
2557
|
+
}
|
|
2558
|
+
],
|
|
2559
|
+
anonymous: false
|
|
1832
2560
|
},
|
|
1833
2561
|
{
|
|
1834
2562
|
type: "error",
|
|
1835
|
-
name: "
|
|
2563
|
+
name: "AlreadyInitialized",
|
|
1836
2564
|
inputs: []
|
|
1837
2565
|
},
|
|
1838
2566
|
{
|
|
@@ -1840,18 +2568,62 @@ var SUPERSTATE_SWAP_ABI = [
|
|
|
1840
2568
|
name: "InsufficientAmount",
|
|
1841
2569
|
inputs: []
|
|
1842
2570
|
},
|
|
2571
|
+
{
|
|
2572
|
+
type: "error",
|
|
2573
|
+
name: "InvalidAddress",
|
|
2574
|
+
inputs: []
|
|
2575
|
+
},
|
|
1843
2576
|
{
|
|
1844
2577
|
type: "error",
|
|
1845
2578
|
name: "InvalidAmount",
|
|
1846
2579
|
inputs: []
|
|
1847
2580
|
},
|
|
2581
|
+
{
|
|
2582
|
+
type: "error",
|
|
2583
|
+
name: "IsPaused",
|
|
2584
|
+
inputs: [
|
|
2585
|
+
{
|
|
2586
|
+
name: "level",
|
|
2587
|
+
type: "uint32",
|
|
2588
|
+
internalType: "uint32"
|
|
2589
|
+
}
|
|
2590
|
+
]
|
|
2591
|
+
},
|
|
2592
|
+
{
|
|
2593
|
+
type: "error",
|
|
2594
|
+
name: "IsStopped",
|
|
2595
|
+
inputs: []
|
|
2596
|
+
},
|
|
2597
|
+
{
|
|
2598
|
+
type: "error",
|
|
2599
|
+
name: "NewOwnerIsZeroAddress",
|
|
2600
|
+
inputs: []
|
|
2601
|
+
},
|
|
2602
|
+
{
|
|
2603
|
+
type: "error",
|
|
2604
|
+
name: "NoHandoverRequest",
|
|
2605
|
+
inputs: []
|
|
2606
|
+
},
|
|
1848
2607
|
{
|
|
1849
2608
|
type: "error",
|
|
1850
2609
|
name: "SwapFailed",
|
|
1851
2610
|
inputs: [
|
|
1852
|
-
{
|
|
1853
|
-
|
|
2611
|
+
{
|
|
2612
|
+
name: "user",
|
|
2613
|
+
type: "address",
|
|
2614
|
+
internalType: "address"
|
|
2615
|
+
},
|
|
2616
|
+
{
|
|
2617
|
+
name: "token",
|
|
2618
|
+
type: "address",
|
|
2619
|
+
internalType: "address"
|
|
2620
|
+
}
|
|
1854
2621
|
]
|
|
2622
|
+
},
|
|
2623
|
+
{
|
|
2624
|
+
type: "error",
|
|
2625
|
+
name: "Unauthorized",
|
|
2626
|
+
inputs: []
|
|
1855
2627
|
}
|
|
1856
2628
|
];
|
|
1857
2629
|
|
|
@@ -1900,15 +2672,27 @@ var SwapQuote = {
|
|
|
1900
2672
|
};
|
|
1901
2673
|
|
|
1902
2674
|
// src/universal/core/checkout/superstate/blockchain/status.ts
|
|
1903
|
-
|
|
1904
|
-
|
|
2675
|
+
var SWAP_LEVEL = 2;
|
|
2676
|
+
function isSwapAvailable(status) {
|
|
2677
|
+
switch (status.state) {
|
|
2678
|
+
case "active":
|
|
2679
|
+
return true;
|
|
2680
|
+
case "stopped":
|
|
2681
|
+
return false;
|
|
2682
|
+
case "paused":
|
|
2683
|
+
return (status.pausedLevels & SWAP_LEVEL) === 0;
|
|
2684
|
+
default: {
|
|
2685
|
+
const _exhaustive = status;
|
|
2686
|
+
return _exhaustive;
|
|
2687
|
+
}
|
|
2688
|
+
}
|
|
1905
2689
|
}
|
|
1906
2690
|
|
|
1907
2691
|
// src/universal/core/checkout/superstate/blockchain/swapped-event.ts
|
|
1908
|
-
var
|
|
2692
|
+
var import_viem4 = require("viem");
|
|
1909
2693
|
function decodeSwappedOutputAmount(receipt, outputDecimals) {
|
|
1910
2694
|
try {
|
|
1911
|
-
const [swapped] = (0,
|
|
2695
|
+
const [swapped] = (0, import_viem4.parseEventLogs)({
|
|
1912
2696
|
abi: SUPERSTATE_SWAP_ABI,
|
|
1913
2697
|
eventName: "Swapped",
|
|
1914
2698
|
logs: receipt.logs
|
|
@@ -1931,7 +2715,7 @@ var SLIPPAGE_OPTIONS_BPS = [25n, 50n, 100n, 200n, 500n].map(
|
|
|
1931
2715
|
(n) => Bps(n)
|
|
1932
2716
|
);
|
|
1933
2717
|
var DEFAULT_SLIPPAGE_BPS = Bps(50n);
|
|
1934
|
-
var SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA = EvmContractAddress("
|
|
2718
|
+
var SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA = EvmContractAddress("0x27E8CE9Ca1A1E98Bc4009F08Dc596bFcf88aCED1");
|
|
1935
2719
|
var SUPERSTATE_SWAP_CONTRACT_ADDRESSES = {
|
|
1936
2720
|
ethereum_sepolia: SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA
|
|
1937
2721
|
};
|
|
@@ -1946,141 +2730,66 @@ function formattedPricePerShare(quote, locale) {
|
|
|
1946
2730
|
}
|
|
1947
2731
|
|
|
1948
2732
|
// src/universal/types/providers/superstate/swap.ts
|
|
1949
|
-
var SwapAuthorization = {
|
|
1950
|
-
fromDto: (dto) => ({
|
|
1951
|
-
authorized: dto.authorized
|
|
1952
|
-
})
|
|
1953
|
-
};
|
|
1954
2733
|
var SwapPreview = {
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
)
|
|
1960
|
-
fee: parseUint256(BigInt(dto.fee), "SwapPreview.fee"),
|
|
1961
|
-
outputAmount: parseUint256(
|
|
1962
|
-
BigInt(dto.receive_output_amount),
|
|
1963
|
-
"SwapPreview.receive_output_amount"
|
|
1964
|
-
)
|
|
2734
|
+
/** Maps the contract's `Preview { input, fee, output }` struct. */
|
|
2735
|
+
fromContract: (preview) => ({
|
|
2736
|
+
inputAmount: parseUint256(preview.input, "SwapPreview.input"),
|
|
2737
|
+
fee: parseUint256(preview.fee, "SwapPreview.fee"),
|
|
2738
|
+
outputAmount: parseUint256(preview.output, "SwapPreview.output")
|
|
1965
2739
|
})
|
|
1966
2740
|
};
|
|
2741
|
+
var PauseFlags = (value) => value;
|
|
1967
2742
|
var SwapStatus = {
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
2743
|
+
/**
|
|
2744
|
+
* Maps the contract's `Status { uint32 flags; State state }` struct, where
|
|
2745
|
+
* `State` is `0 = Active | 1 = Paused | 2 = Stopped`.
|
|
2746
|
+
*
|
|
2747
|
+
* `flags` is carried onto the `paused` arm only. On the other two the
|
|
2748
|
+
* contract sets it to a self-identifying marker rather than to information -
|
|
2749
|
+
* so repeating it would invite a caller to read meaning into a constant.
|
|
2750
|
+
*
|
|
2751
|
+
* @throws ValidationError on a `state` outside the enum. A contract that has
|
|
2752
|
+
* grown a fourth state is one the SDK does not model, and guessing `active`
|
|
2753
|
+
* would let a halted swap read as a live one.
|
|
2754
|
+
*/
|
|
2755
|
+
fromContract: (status) => {
|
|
2756
|
+
switch (status.state) {
|
|
2757
|
+
case 0:
|
|
2758
|
+
return { state: "active" };
|
|
2759
|
+
case 1:
|
|
2760
|
+
return { state: "paused", pausedLevels: PauseFlags(status.flags) };
|
|
2761
|
+
case 2:
|
|
2762
|
+
return { state: "stopped" };
|
|
2763
|
+
default:
|
|
2764
|
+
throw new ValidationError(
|
|
2765
|
+
`SwapStatus.state: unknown contract state (${status.state})`
|
|
2766
|
+
);
|
|
2767
|
+
}
|
|
2768
|
+
}
|
|
1982
2769
|
};
|
|
1983
2770
|
var AllowWalletResponse = {
|
|
1984
2771
|
fromDto: (dto) => {
|
|
1985
2772
|
switch (dto.action) {
|
|
1986
2773
|
case "broadcast_transaction":
|
|
1987
|
-
return {
|
|
1988
|
-
action: "broadcast_transaction",
|
|
1989
|
-
to: EvmContractAddress(dto.to),
|
|
1990
|
-
data: HexEncodedTransactionData(dto.data)
|
|
1991
|
-
};
|
|
1992
|
-
case "none":
|
|
1993
|
-
return {
|
|
1994
|
-
action: "none",
|
|
1995
|
-
alreadyAllowed: dto.already_allowed
|
|
1996
|
-
};
|
|
1997
|
-
default: {
|
|
1998
|
-
const _exhaustive = dto;
|
|
1999
|
-
return _exhaustive;
|
|
2000
|
-
}
|
|
2001
|
-
}
|
|
2002
|
-
}
|
|
2003
|
-
};
|
|
2004
|
-
|
|
2005
|
-
// src/universal/api/frontline/providers/superstate/swap.ts
|
|
2006
|
-
async function getSwapAuthorization(api, params) {
|
|
2007
|
-
const dto = await api.send({
|
|
2008
|
-
method: "GET",
|
|
2009
|
-
url: "/v1/wallet/authorized",
|
|
2010
|
-
queryParams: {
|
|
2011
|
-
chain: params.chain,
|
|
2012
|
-
contract_address: params.contractAddress,
|
|
2013
|
-
wallet_address: params.walletAddress
|
|
2014
|
-
},
|
|
2015
|
-
attributes: Attributes.protected()
|
|
2016
|
-
});
|
|
2017
|
-
return SwapAuthorization.fromDto(dto);
|
|
2018
|
-
}
|
|
2019
|
-
async function getSwapOutputToken(api, params) {
|
|
2020
|
-
const dto = await api.send({
|
|
2021
|
-
method: "GET",
|
|
2022
|
-
url: "/v1/swap/output-token",
|
|
2023
|
-
queryParams: {
|
|
2024
|
-
chain: params.chain,
|
|
2025
|
-
contract_address: params.contractAddress
|
|
2026
|
-
},
|
|
2027
|
-
attributes: Attributes.protected()
|
|
2028
|
-
});
|
|
2029
|
-
return toErc20Asset(dto);
|
|
2030
|
-
}
|
|
2031
|
-
async function getSwapPreview(api, params) {
|
|
2032
|
-
const dto = await api.send({
|
|
2033
|
-
method: "GET",
|
|
2034
|
-
url: "/v1/swap/preview",
|
|
2035
|
-
queryParams: {
|
|
2036
|
-
chain: params.chain,
|
|
2037
|
-
contract_address: params.contractAddress,
|
|
2038
|
-
input_token: params.inputToken,
|
|
2039
|
-
amount: params.amount.toString()
|
|
2040
|
-
},
|
|
2041
|
-
attributes: Attributes.protected()
|
|
2042
|
-
});
|
|
2043
|
-
return SwapPreview.fromDto(dto);
|
|
2044
|
-
}
|
|
2045
|
-
async function getSwapStatus(api, params) {
|
|
2046
|
-
const dto = await api.send({
|
|
2047
|
-
method: "GET",
|
|
2048
|
-
url: "/v1/swap/status",
|
|
2049
|
-
queryParams: {
|
|
2050
|
-
chain: params.chain,
|
|
2051
|
-
contract_address: params.contractAddress
|
|
2052
|
-
},
|
|
2053
|
-
attributes: Attributes.protected()
|
|
2054
|
-
});
|
|
2055
|
-
return SwapStatus.fromDto(dto);
|
|
2056
|
-
}
|
|
2057
|
-
async function getTokenAllowance(api, params) {
|
|
2058
|
-
const dto = await api.send({
|
|
2059
|
-
method: "GET",
|
|
2060
|
-
url: "/v1/token/allowance",
|
|
2061
|
-
queryParams: {
|
|
2062
|
-
chain: params.chain,
|
|
2063
|
-
token_address: params.tokenAddress,
|
|
2064
|
-
owner: params.owner,
|
|
2065
|
-
spender: params.spender
|
|
2066
|
-
},
|
|
2067
|
-
attributes: Attributes.protected()
|
|
2068
|
-
});
|
|
2069
|
-
return TokenAllowance.fromDto(dto);
|
|
2070
|
-
}
|
|
2071
|
-
async function getTokenBalance(api, params) {
|
|
2072
|
-
const dto = await api.send({
|
|
2073
|
-
method: "GET",
|
|
2074
|
-
url: "/v1/token/balance",
|
|
2075
|
-
queryParams: {
|
|
2076
|
-
chain: params.chain,
|
|
2077
|
-
token_address: params.tokenAddress,
|
|
2078
|
-
owner: params.owner
|
|
2079
|
-
},
|
|
2080
|
-
attributes: Attributes.protected()
|
|
2081
|
-
});
|
|
2082
|
-
return TokenBalance.fromDto(dto);
|
|
2083
|
-
}
|
|
2774
|
+
return {
|
|
2775
|
+
action: "broadcast_transaction",
|
|
2776
|
+
to: EvmContractAddress(dto.to),
|
|
2777
|
+
data: HexEncodedTransactionData(dto.data)
|
|
2778
|
+
};
|
|
2779
|
+
case "none":
|
|
2780
|
+
return {
|
|
2781
|
+
action: "none",
|
|
2782
|
+
alreadyAllowed: dto.already_allowed
|
|
2783
|
+
};
|
|
2784
|
+
default: {
|
|
2785
|
+
const _exhaustive = dto;
|
|
2786
|
+
return _exhaustive;
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2789
|
+
}
|
|
2790
|
+
};
|
|
2791
|
+
|
|
2792
|
+
// src/universal/api/frontline/providers/superstate/swap.ts
|
|
2084
2793
|
async function allowWallet(api, params) {
|
|
2085
2794
|
const dto = await api.send({
|
|
2086
2795
|
method: "POST",
|
|
@@ -2094,11 +2803,153 @@ async function allowWallet(api, params) {
|
|
|
2094
2803
|
});
|
|
2095
2804
|
return AllowWalletResponse.fromDto(dto);
|
|
2096
2805
|
}
|
|
2097
|
-
|
|
2806
|
+
|
|
2807
|
+
// src/universal/core/shared/blockchain/erc20/abi.ts
|
|
2808
|
+
var ERC20_ABI = [
|
|
2809
|
+
{
|
|
2810
|
+
type: "function",
|
|
2811
|
+
name: "allowance",
|
|
2812
|
+
inputs: [
|
|
2813
|
+
{ name: "owner", type: "address" },
|
|
2814
|
+
{ name: "spender", type: "address" }
|
|
2815
|
+
],
|
|
2816
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
2817
|
+
stateMutability: "view"
|
|
2818
|
+
},
|
|
2819
|
+
{
|
|
2820
|
+
type: "function",
|
|
2821
|
+
name: "approve",
|
|
2822
|
+
inputs: [
|
|
2823
|
+
{ name: "spender", type: "address" },
|
|
2824
|
+
{ name: "amount", type: "uint256" }
|
|
2825
|
+
],
|
|
2826
|
+
outputs: [{ name: "", type: "bool" }],
|
|
2827
|
+
stateMutability: "nonpayable"
|
|
2828
|
+
},
|
|
2829
|
+
{
|
|
2830
|
+
type: "function",
|
|
2831
|
+
name: "balanceOf",
|
|
2832
|
+
inputs: [{ name: "account", type: "address" }],
|
|
2833
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
2834
|
+
stateMutability: "view"
|
|
2835
|
+
},
|
|
2836
|
+
{
|
|
2837
|
+
type: "function",
|
|
2838
|
+
name: "decimals",
|
|
2839
|
+
inputs: [],
|
|
2840
|
+
outputs: [{ name: "", type: "uint8" }],
|
|
2841
|
+
stateMutability: "view"
|
|
2842
|
+
},
|
|
2843
|
+
{
|
|
2844
|
+
type: "function",
|
|
2845
|
+
name: "name",
|
|
2846
|
+
inputs: [],
|
|
2847
|
+
outputs: [{ name: "", type: "string" }],
|
|
2848
|
+
stateMutability: "view"
|
|
2849
|
+
},
|
|
2850
|
+
{
|
|
2851
|
+
type: "function",
|
|
2852
|
+
name: "symbol",
|
|
2853
|
+
inputs: [],
|
|
2854
|
+
outputs: [{ name: "", type: "string" }],
|
|
2855
|
+
stateMutability: "view"
|
|
2856
|
+
},
|
|
2857
|
+
{
|
|
2858
|
+
type: "function",
|
|
2859
|
+
name: "totalSupply",
|
|
2860
|
+
inputs: [],
|
|
2861
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
2862
|
+
stateMutability: "view"
|
|
2863
|
+
},
|
|
2864
|
+
{
|
|
2865
|
+
type: "function",
|
|
2866
|
+
name: "transfer",
|
|
2867
|
+
inputs: [
|
|
2868
|
+
{ name: "recipient", type: "address" },
|
|
2869
|
+
{ name: "amount", type: "uint256" }
|
|
2870
|
+
],
|
|
2871
|
+
outputs: [{ name: "", type: "bool" }],
|
|
2872
|
+
stateMutability: "nonpayable"
|
|
2873
|
+
},
|
|
2874
|
+
{
|
|
2875
|
+
type: "function",
|
|
2876
|
+
name: "transferFrom",
|
|
2877
|
+
inputs: [
|
|
2878
|
+
{ name: "sender", type: "address" },
|
|
2879
|
+
{ name: "recipient", type: "address" },
|
|
2880
|
+
{ name: "amount", type: "uint256" }
|
|
2881
|
+
],
|
|
2882
|
+
outputs: [{ name: "", type: "bool" }],
|
|
2883
|
+
stateMutability: "nonpayable"
|
|
2884
|
+
},
|
|
2885
|
+
{
|
|
2886
|
+
type: "event",
|
|
2887
|
+
name: "Approval",
|
|
2888
|
+
inputs: [
|
|
2889
|
+
{ name: "owner", type: "address", indexed: true },
|
|
2890
|
+
{ name: "spender", type: "address", indexed: true },
|
|
2891
|
+
{ name: "value", type: "uint256", indexed: false }
|
|
2892
|
+
],
|
|
2893
|
+
anonymous: false
|
|
2894
|
+
},
|
|
2895
|
+
{
|
|
2896
|
+
type: "event",
|
|
2897
|
+
name: "Transfer",
|
|
2898
|
+
inputs: [
|
|
2899
|
+
{ name: "from", type: "address", indexed: true },
|
|
2900
|
+
{ name: "to", type: "address", indexed: true },
|
|
2901
|
+
{ name: "value", type: "uint256", indexed: false }
|
|
2902
|
+
],
|
|
2903
|
+
anonymous: false
|
|
2904
|
+
}
|
|
2905
|
+
];
|
|
2906
|
+
|
|
2907
|
+
// src/universal/api/rpc/providers/superstate/swap.ts
|
|
2908
|
+
async function getSwapAuthorization(clients, params) {
|
|
2909
|
+
return clients(params.chain).readContract({
|
|
2910
|
+
address: params.contractAddress,
|
|
2911
|
+
abi: SUPERSTATE_SWAP_ABI,
|
|
2912
|
+
functionName: "authorized",
|
|
2913
|
+
args: [params.walletAddress]
|
|
2914
|
+
});
|
|
2915
|
+
}
|
|
2916
|
+
async function getSwapPreview(clients, params) {
|
|
2917
|
+
const preview = await clients(params.chain).readContract({
|
|
2918
|
+
address: params.contractAddress,
|
|
2919
|
+
abi: SUPERSTATE_SWAP_ABI,
|
|
2920
|
+
functionName: "preview",
|
|
2921
|
+
args: [params.inputToken, params.amount]
|
|
2922
|
+
});
|
|
2923
|
+
return SwapPreview.fromContract(preview);
|
|
2924
|
+
}
|
|
2925
|
+
async function getSwapStatus(clients, params) {
|
|
2926
|
+
const status = await clients(params.chain).readContract({
|
|
2927
|
+
address: params.contractAddress,
|
|
2928
|
+
abi: SUPERSTATE_SWAP_ABI,
|
|
2929
|
+
functionName: "status"
|
|
2930
|
+
});
|
|
2931
|
+
return SwapStatus.fromContract(status);
|
|
2932
|
+
}
|
|
2933
|
+
async function getSwapOutputToken(clients, params) {
|
|
2934
|
+
const client = clients(params.chain);
|
|
2935
|
+
const tokenAddress = await client.readContract({
|
|
2936
|
+
address: params.contractAddress,
|
|
2937
|
+
abi: SUPERSTATE_SWAP_ABI,
|
|
2938
|
+
functionName: "outputToken"
|
|
2939
|
+
});
|
|
2940
|
+
const token = { address: EvmContractAddress(tokenAddress), abi: ERC20_ABI };
|
|
2941
|
+
const [name, symbol, decimals] = await client.multicall({
|
|
2942
|
+
contracts: [
|
|
2943
|
+
{ ...token, functionName: "name" },
|
|
2944
|
+
{ ...token, functionName: "symbol" },
|
|
2945
|
+
{ ...token, functionName: "decimals" }
|
|
2946
|
+
],
|
|
2947
|
+
allowFailure: false
|
|
2948
|
+
});
|
|
2098
2949
|
return {
|
|
2099
|
-
name
|
|
2100
|
-
symbol: AssetSymbol(
|
|
2101
|
-
decimals: AssetDecimals(
|
|
2950
|
+
name,
|
|
2951
|
+
symbol: AssetSymbol(symbol),
|
|
2952
|
+
decimals: AssetDecimals(decimals)
|
|
2102
2953
|
};
|
|
2103
2954
|
}
|
|
2104
2955
|
|
|
@@ -2109,28 +2960,32 @@ var SuperstateSwapNamespaceImpl = class {
|
|
|
2109
2960
|
this.log = internalLogger(ctx.logger, "SUPERSTATE");
|
|
2110
2961
|
}
|
|
2111
2962
|
async getAuthorization(params) {
|
|
2112
|
-
return this.log.wrap(
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2963
|
+
return this.log.wrap(
|
|
2964
|
+
"getAuthorization",
|
|
2965
|
+
params,
|
|
2966
|
+
async () => getSwapAuthorization(this.ctx.rpc, params)
|
|
2967
|
+
);
|
|
2116
2968
|
}
|
|
2117
2969
|
async getPreview(params) {
|
|
2118
|
-
return this.log.wrap(
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2970
|
+
return this.log.wrap(
|
|
2971
|
+
"getPreview",
|
|
2972
|
+
params,
|
|
2973
|
+
async () => getSwapPreview(this.ctx.rpc, params)
|
|
2974
|
+
);
|
|
2122
2975
|
}
|
|
2123
2976
|
async getStatus(params) {
|
|
2124
|
-
return this.log.wrap(
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2977
|
+
return this.log.wrap(
|
|
2978
|
+
"getStatus",
|
|
2979
|
+
params,
|
|
2980
|
+
async () => getSwapStatus(this.ctx.rpc, params)
|
|
2981
|
+
);
|
|
2128
2982
|
}
|
|
2129
2983
|
async getOutputToken(params) {
|
|
2130
|
-
return this.log.wrap(
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2984
|
+
return this.log.wrap(
|
|
2985
|
+
"getOutputToken",
|
|
2986
|
+
params,
|
|
2987
|
+
async () => getSwapOutputToken(this.ctx.rpc, params)
|
|
2988
|
+
);
|
|
2134
2989
|
}
|
|
2135
2990
|
async allowWallet(params) {
|
|
2136
2991
|
return this.log.wrap("allowWallet", params, async () => {
|
|
@@ -2155,7 +3010,7 @@ async function fetchOffersPage(api, params, clientCreds) {
|
|
|
2155
3010
|
Attributes.clientCredentials(clientCreds)
|
|
2156
3011
|
)
|
|
2157
3012
|
});
|
|
2158
|
-
return PaginatedResponse.
|
|
3013
|
+
return PaginatedResponse.fromDtoPage(pageDto, Offer.listFromDto);
|
|
2159
3014
|
}
|
|
2160
3015
|
async function fetchOfferDetails(api, id, clientCreds) {
|
|
2161
3016
|
const dto = await api.send({
|
|
@@ -2375,105 +3230,25 @@ var RequirementsNamespaceImpl = class {
|
|
|
2375
3230
|
}
|
|
2376
3231
|
};
|
|
2377
3232
|
|
|
2378
|
-
// src/universal/
|
|
2379
|
-
|
|
2380
|
-
{
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
outputs: [{ name: "", type: "bool" }],
|
|
2398
|
-
stateMutability: "nonpayable"
|
|
2399
|
-
},
|
|
2400
|
-
{
|
|
2401
|
-
type: "function",
|
|
2402
|
-
name: "balanceOf",
|
|
2403
|
-
inputs: [{ name: "account", type: "address" }],
|
|
2404
|
-
outputs: [{ name: "", type: "uint256" }],
|
|
2405
|
-
stateMutability: "view"
|
|
2406
|
-
},
|
|
2407
|
-
{
|
|
2408
|
-
type: "function",
|
|
2409
|
-
name: "decimals",
|
|
2410
|
-
inputs: [],
|
|
2411
|
-
outputs: [{ name: "", type: "uint8" }],
|
|
2412
|
-
stateMutability: "view"
|
|
2413
|
-
},
|
|
2414
|
-
{
|
|
2415
|
-
type: "function",
|
|
2416
|
-
name: "name",
|
|
2417
|
-
inputs: [],
|
|
2418
|
-
outputs: [{ name: "", type: "string" }],
|
|
2419
|
-
stateMutability: "view"
|
|
2420
|
-
},
|
|
2421
|
-
{
|
|
2422
|
-
type: "function",
|
|
2423
|
-
name: "symbol",
|
|
2424
|
-
inputs: [],
|
|
2425
|
-
outputs: [{ name: "", type: "string" }],
|
|
2426
|
-
stateMutability: "view"
|
|
2427
|
-
},
|
|
2428
|
-
{
|
|
2429
|
-
type: "function",
|
|
2430
|
-
name: "totalSupply",
|
|
2431
|
-
inputs: [],
|
|
2432
|
-
outputs: [{ name: "", type: "uint256" }],
|
|
2433
|
-
stateMutability: "view"
|
|
2434
|
-
},
|
|
2435
|
-
{
|
|
2436
|
-
type: "function",
|
|
2437
|
-
name: "transfer",
|
|
2438
|
-
inputs: [
|
|
2439
|
-
{ name: "recipient", type: "address" },
|
|
2440
|
-
{ name: "amount", type: "uint256" }
|
|
2441
|
-
],
|
|
2442
|
-
outputs: [{ name: "", type: "bool" }],
|
|
2443
|
-
stateMutability: "nonpayable"
|
|
2444
|
-
},
|
|
2445
|
-
{
|
|
2446
|
-
type: "function",
|
|
2447
|
-
name: "transferFrom",
|
|
2448
|
-
inputs: [
|
|
2449
|
-
{ name: "sender", type: "address" },
|
|
2450
|
-
{ name: "recipient", type: "address" },
|
|
2451
|
-
{ name: "amount", type: "uint256" }
|
|
2452
|
-
],
|
|
2453
|
-
outputs: [{ name: "", type: "bool" }],
|
|
2454
|
-
stateMutability: "nonpayable"
|
|
2455
|
-
},
|
|
2456
|
-
{
|
|
2457
|
-
type: "event",
|
|
2458
|
-
name: "Approval",
|
|
2459
|
-
inputs: [
|
|
2460
|
-
{ name: "owner", type: "address", indexed: true },
|
|
2461
|
-
{ name: "spender", type: "address", indexed: true },
|
|
2462
|
-
{ name: "value", type: "uint256", indexed: false }
|
|
2463
|
-
],
|
|
2464
|
-
anonymous: false
|
|
2465
|
-
},
|
|
2466
|
-
{
|
|
2467
|
-
type: "event",
|
|
2468
|
-
name: "Transfer",
|
|
2469
|
-
inputs: [
|
|
2470
|
-
{ name: "from", type: "address", indexed: true },
|
|
2471
|
-
{ name: "to", type: "address", indexed: true },
|
|
2472
|
-
{ name: "value", type: "uint256", indexed: false }
|
|
2473
|
-
],
|
|
2474
|
-
anonymous: false
|
|
2475
|
-
}
|
|
2476
|
-
];
|
|
3233
|
+
// src/universal/api/rpc/erc20.ts
|
|
3234
|
+
async function getTokenAllowance(clients, params) {
|
|
3235
|
+
const allowance = await clients(params.chain).readContract({
|
|
3236
|
+
address: params.tokenAddress,
|
|
3237
|
+
abi: ERC20_ABI,
|
|
3238
|
+
functionName: "allowance",
|
|
3239
|
+
args: [params.owner, params.spender]
|
|
3240
|
+
});
|
|
3241
|
+
return parseUint256(allowance, "allowance");
|
|
3242
|
+
}
|
|
3243
|
+
async function getTokenBalance(clients, params) {
|
|
3244
|
+
const balance = await clients(params.chain).readContract({
|
|
3245
|
+
address: params.tokenAddress,
|
|
3246
|
+
abi: ERC20_ABI,
|
|
3247
|
+
functionName: "balanceOf",
|
|
3248
|
+
args: [params.owner]
|
|
3249
|
+
});
|
|
3250
|
+
return parseUint256(balance, "balanceOf");
|
|
3251
|
+
}
|
|
2477
3252
|
|
|
2478
3253
|
// src/universal/core/shared/blockchain/erc20/erc20-namespace.ts
|
|
2479
3254
|
var Erc20NamespaceImpl = class {
|
|
@@ -2482,21 +3257,23 @@ var Erc20NamespaceImpl = class {
|
|
|
2482
3257
|
this.log = internalLogger(ctx.logger, "ERC20");
|
|
2483
3258
|
}
|
|
2484
3259
|
async getAllowance(params) {
|
|
2485
|
-
return this.log.wrap(
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
3260
|
+
return this.log.wrap(
|
|
3261
|
+
"getAllowance",
|
|
3262
|
+
params,
|
|
3263
|
+
async () => getTokenAllowance(this.ctx.rpc, params)
|
|
3264
|
+
);
|
|
2489
3265
|
}
|
|
2490
3266
|
async getBalance(params) {
|
|
2491
|
-
return this.log.wrap(
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
3267
|
+
return this.log.wrap(
|
|
3268
|
+
"getBalance",
|
|
3269
|
+
params,
|
|
3270
|
+
async () => getTokenBalance(this.ctx.rpc, params)
|
|
3271
|
+
);
|
|
2495
3272
|
}
|
|
2496
3273
|
};
|
|
2497
3274
|
|
|
2498
3275
|
// src/universal/api/nabu/tokens.ts
|
|
2499
|
-
var
|
|
3276
|
+
var import_viem5 = require("viem");
|
|
2500
3277
|
|
|
2501
3278
|
// src/universal/api/frontline/config.ts
|
|
2502
3279
|
var HEADER_API_VERSION = "X-API-Version";
|
|
@@ -2562,9 +3339,9 @@ var HttpClient = class {
|
|
|
2562
3339
|
if (url.startsWith("http://") || url.startsWith("https://")) {
|
|
2563
3340
|
return url;
|
|
2564
3341
|
}
|
|
2565
|
-
const
|
|
3342
|
+
const base2 = this.config.baseUrl.replace(/\/$/, "");
|
|
2566
3343
|
const path = url.startsWith("/") ? url : `/${url}`;
|
|
2567
|
-
return
|
|
3344
|
+
return base2 + path;
|
|
2568
3345
|
}
|
|
2569
3346
|
async runBeforeRequestMiddleware(initialRequest) {
|
|
2570
3347
|
let request = initialRequest;
|
|
@@ -2825,7 +3602,7 @@ function assertOk(response) {
|
|
|
2825
3602
|
}
|
|
2826
3603
|
function checksummed(address) {
|
|
2827
3604
|
try {
|
|
2828
|
-
return (0,
|
|
3605
|
+
return (0, import_viem5.getAddress)(address);
|
|
2829
3606
|
} catch (_) {
|
|
2830
3607
|
throw new ValidationError(`Invalid EVM contract address: "${address}"`);
|
|
2831
3608
|
}
|
|
@@ -3073,6 +3850,7 @@ var User = {
|
|
|
3073
3850
|
HexEncodedTransactionData,
|
|
3074
3851
|
HttpError,
|
|
3075
3852
|
InvariantError,
|
|
3853
|
+
Isin,
|
|
3076
3854
|
Iso2CountryCode,
|
|
3077
3855
|
KnownAssetSymbol,
|
|
3078
3856
|
KycToken,
|
|
@@ -3092,6 +3870,7 @@ var User = {
|
|
|
3092
3870
|
ONDO_SUPPORTED_INPUT_ASSETS,
|
|
3093
3871
|
Offer,
|
|
3094
3872
|
OfferDetail,
|
|
3873
|
+
OfferEditorial,
|
|
3095
3874
|
OfferId,
|
|
3096
3875
|
OfferOption,
|
|
3097
3876
|
OfferOptionAddress,
|
|
@@ -3113,6 +3892,7 @@ var User = {
|
|
|
3113
3892
|
Participation,
|
|
3114
3893
|
ParticipationId,
|
|
3115
3894
|
ParticipationsPaginationParams,
|
|
3895
|
+
PauseFlags,
|
|
3116
3896
|
Pii,
|
|
3117
3897
|
PiiAddress,
|
|
3118
3898
|
PiiJurisdiction,
|
|
@@ -3129,20 +3909,18 @@ var User = {
|
|
|
3129
3909
|
SUPERSTATE_SUPPORTED_INPUT_ASSETS,
|
|
3130
3910
|
SUPERSTATE_SWAP_ABI,
|
|
3131
3911
|
SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA,
|
|
3912
|
+
SWAP_LEVEL,
|
|
3132
3913
|
SWAP_POLL_INTERVAL_MS,
|
|
3133
3914
|
ShortenedWalletAddress,
|
|
3134
3915
|
SolanaChain,
|
|
3135
3916
|
StablecoinSymbol,
|
|
3136
3917
|
SuperstateSwapNamespaceImpl,
|
|
3137
|
-
SwapAuthorization,
|
|
3138
3918
|
SwapPreview,
|
|
3139
3919
|
SwapQuote,
|
|
3140
3920
|
SwapStatus,
|
|
3141
3921
|
TOKEN_REGISTRY,
|
|
3142
3922
|
TermItem,
|
|
3143
3923
|
Ticker,
|
|
3144
|
-
TokenAllowance,
|
|
3145
|
-
TokenBalance,
|
|
3146
3924
|
TokenLogo,
|
|
3147
3925
|
TokenLogoUrl,
|
|
3148
3926
|
TokenMetadata,
|
|
@@ -3181,13 +3959,15 @@ var User = {
|
|
|
3181
3959
|
getChainId,
|
|
3182
3960
|
getNetworkName,
|
|
3183
3961
|
isChain,
|
|
3184
|
-
|
|
3962
|
+
isOfferType,
|
|
3963
|
+
isSwapAvailable,
|
|
3185
3964
|
parseBlockchainAmount,
|
|
3186
3965
|
parseUint256,
|
|
3187
3966
|
shortenAddress,
|
|
3188
3967
|
superstateSwapContractAddress,
|
|
3189
3968
|
swapSpender,
|
|
3190
3969
|
txExplorerUrl,
|
|
3191
|
-
usdAmount
|
|
3970
|
+
usdAmount,
|
|
3971
|
+
viemChain
|
|
3192
3972
|
});
|
|
3193
3973
|
//# sourceMappingURL=index.cjs.map
|