@coinlist-co/react 0.12.2-rc.7b430dd → 0.12.2-rc.a59b344
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-DCW7NQXH.js → chunk-4IZ2F732.js} +52 -19
- package/dist/chunk-4IZ2F732.js.map +1 -0
- package/dist/{chunk-MOE5S6CE.js → chunk-NBO5E2RO.js} +152 -6
- package/dist/chunk-NBO5E2RO.js.map +1 -0
- package/dist/{chunk-VH34YC3Q.js → chunk-UJYSXXJF.js} +168 -3
- package/dist/chunk-UJYSXXJF.js.map +1 -0
- package/dist/client/index.cjs +469 -145
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +114 -35
- package/dist/client/index.d.ts +114 -35
- package/dist/client/index.js +297 -114
- package/dist/client/index.js.map +1 -1
- package/dist/server/index.cjs +507 -116
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +65 -41
- package/dist/server/index.d.ts +65 -41
- package/dist/server/index.js +321 -65
- package/dist/server/index.js.map +1 -1
- package/dist/time-CFocgYyl.d.cts +50 -0
- package/dist/time-DvgN98Q9.d.ts +50 -0
- package/dist/{token-registry-snapshot-BNBNuDu1.d.ts → token-registry-snapshot-BsAfBL_b.d.ts} +9 -7
- package/dist/{token-registry-snapshot-CqI6dXM_.d.cts → token-registry-snapshot-Cc_eA5zM.d.cts} +9 -7
- package/dist/{tokens-namespace-CIWBtgt2.d.cts → tokens-namespace-D_XSpiS-.d.cts} +154 -19
- package/dist/{tokens-namespace-CIWBtgt2.d.ts → tokens-namespace-D_XSpiS-.d.ts} +154 -19
- package/dist/universal/index.cjs +333 -40
- package/dist/universal/index.cjs.map +1 -1
- package/dist/universal/index.d.cts +358 -5
- package/dist/universal/index.d.ts +358 -5
- package/dist/universal/index.js +28 -2
- package/package.json +1 -1
- package/dist/chunk-DCW7NQXH.js.map +0 -1
- package/dist/chunk-MOE5S6CE.js.map +0 -1
- package/dist/chunk-VH34YC3Q.js.map +0 -1
package/dist/universal/index.cjs
CHANGED
|
@@ -32,6 +32,11 @@ __export(universal_exports, {
|
|
|
32
32
|
Blockchain: () => Blockchain,
|
|
33
33
|
BlockchainAmount: () => BlockchainAmount,
|
|
34
34
|
Bps: () => Bps,
|
|
35
|
+
CentrifugeVaultBuyTransaction: () => CentrifugeVaultBuyTransaction,
|
|
36
|
+
CentrifugeVaultClaimTransaction: () => CentrifugeVaultClaimTransaction,
|
|
37
|
+
CentrifugeVaultPosition: () => CentrifugeVaultPosition,
|
|
38
|
+
CentrifugeVaultQuote: () => CentrifugeVaultQuote,
|
|
39
|
+
CentrifugeVaultStatus: () => CentrifugeVaultStatus,
|
|
35
40
|
Chain: () => Chain,
|
|
36
41
|
ClientCredentialsOAuth: () => ClientCredentialsOAuth,
|
|
37
42
|
ClientId: () => ClientId,
|
|
@@ -51,6 +56,7 @@ __export(universal_exports, {
|
|
|
51
56
|
DocumentSubmission: () => DocumentSubmission,
|
|
52
57
|
ERC20_ABI: () => ERC20_ABI,
|
|
53
58
|
ETHEREUM_CHAINS: () => ETHEREUM_CHAINS,
|
|
59
|
+
EpochMillis: () => EpochMillis,
|
|
54
60
|
Erc20NamespaceImpl: () => Erc20NamespaceImpl,
|
|
55
61
|
EthereumChain: () => EthereumChain,
|
|
56
62
|
EvmContractAddress: () => EvmContractAddress,
|
|
@@ -71,11 +77,13 @@ __export(universal_exports, {
|
|
|
71
77
|
MAX_UINT_256: () => MAX_UINT_256,
|
|
72
78
|
MathError: () => MathError,
|
|
73
79
|
Milestone: () => Milestone,
|
|
80
|
+
Millis: () => Millis,
|
|
74
81
|
NA_AMOUNT_ASSET_UI: () => NA_AMOUNT_ASSET_UI,
|
|
75
82
|
NotAuthenticatedError: () => NotAuthenticatedError,
|
|
76
83
|
NotImplementedError: () => NotImplementedError,
|
|
77
84
|
OAuthRefreshToken: () => OAuthRefreshToken,
|
|
78
85
|
OAuthSession: () => OAuthSession,
|
|
86
|
+
ONDO_NOT_TRADABLE_CODE: () => ONDO_NOT_TRADABLE_CODE,
|
|
79
87
|
ONDO_POLL_INTERVAL_MS: () => ONDO_POLL_INTERVAL_MS,
|
|
80
88
|
ONDO_QUOTE_MAX_TTL_MS: () => ONDO_QUOTE_MAX_TTL_MS,
|
|
81
89
|
ONDO_SETTLEMENT_ASSET: () => ONDO_SETTLEMENT_ASSET,
|
|
@@ -92,6 +100,7 @@ __export(universal_exports, {
|
|
|
92
100
|
OfferSlug: () => OfferSlug,
|
|
93
101
|
OfferSwapContract: () => OfferSwapContract,
|
|
94
102
|
OfferToken: () => OfferToken,
|
|
103
|
+
OfferVaultContract: () => OfferVaultContract,
|
|
95
104
|
OffersNamespaceImpl: () => OffersNamespaceImpl,
|
|
96
105
|
OndoBuyTransaction: () => OndoBuyTransaction,
|
|
97
106
|
OndoNamespaceImpl: () => OndoNamespaceImpl,
|
|
@@ -123,6 +132,7 @@ __export(universal_exports, {
|
|
|
123
132
|
SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA: () => SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA,
|
|
124
133
|
SWAP_LEVEL: () => SWAP_LEVEL,
|
|
125
134
|
SWAP_POLL_INTERVAL_MS: () => SWAP_POLL_INTERVAL_MS,
|
|
135
|
+
Seconds: () => Seconds,
|
|
126
136
|
ShortenedWalletAddress: () => ShortenedWalletAddress,
|
|
127
137
|
SolanaChain: () => SolanaChain,
|
|
128
138
|
StablecoinSymbol: () => StablecoinSymbol,
|
|
@@ -166,13 +176,16 @@ __export(universal_exports, {
|
|
|
166
176
|
formatBpsAsPercent: () => formatBpsAsPercent,
|
|
167
177
|
formatCompactAmount: () => formatCompactAmount,
|
|
168
178
|
formatRawAmount: () => formatRawAmount,
|
|
179
|
+
formatShareAmount: () => formatShareAmount,
|
|
169
180
|
formattedPricePerShare: () => formattedPricePerShare,
|
|
170
181
|
formattedUsdPrice: () => formattedUsdPrice,
|
|
171
182
|
generatePKCEParams: () => generatePKCEParams,
|
|
172
183
|
getChainId: () => getChainId,
|
|
173
184
|
getNetworkName: () => getNetworkName,
|
|
174
185
|
isChain: () => isChain,
|
|
186
|
+
isExpired: () => isExpired,
|
|
175
187
|
isOfferType: () => isOfferType,
|
|
188
|
+
isOndoNotTradableError: () => isOndoNotTradableError,
|
|
176
189
|
isSwapAvailable: () => isSwapAvailable,
|
|
177
190
|
offerDisplayTokens: () => offerDisplayTokens,
|
|
178
191
|
ondoQuoteOfferDeadline: () => ondoQuoteOfferDeadline,
|
|
@@ -187,6 +200,15 @@ __export(universal_exports, {
|
|
|
187
200
|
});
|
|
188
201
|
module.exports = __toCommonJS(universal_exports);
|
|
189
202
|
|
|
203
|
+
// src/universal/api/internal-access-token-source.ts
|
|
204
|
+
var SentWith = {
|
|
205
|
+
userToken: (token) => ({
|
|
206
|
+
type: "user-token",
|
|
207
|
+
token
|
|
208
|
+
}),
|
|
209
|
+
noUserToken: { type: "no-user-token" }
|
|
210
|
+
};
|
|
211
|
+
|
|
190
212
|
// src/universal/api/http-attributes.ts
|
|
191
213
|
var empty = {};
|
|
192
214
|
var concat = (left, right) => ({
|
|
@@ -214,6 +236,10 @@ var retryAttempt = (attempt) => ({
|
|
|
214
236
|
var renewAttempted = (value) => ({
|
|
215
237
|
renewAttempted: value
|
|
216
238
|
});
|
|
239
|
+
var notRetryable = () => ({ retryable: false });
|
|
240
|
+
var sentWith = (token) => ({
|
|
241
|
+
sentWith: token
|
|
242
|
+
});
|
|
217
243
|
var requestId = (id) => ({ requestId: id });
|
|
218
244
|
var getRequestId = (attrs) => attrs?.requestId ?? null;
|
|
219
245
|
var isProtected = (attrs) => attrs?.protected === true;
|
|
@@ -221,6 +247,8 @@ var needUserAgent = (attrs) => attrs?.userAgent === true;
|
|
|
221
247
|
var isIdempotent = (attrs) => attrs?.idempotencyKey === true;
|
|
222
248
|
var getRetryAttempt = (attrs) => attrs?.retryAttempt ?? 0;
|
|
223
249
|
var wasRenewAttempted = (attrs) => attrs?.renewAttempted === true;
|
|
250
|
+
var isRetryable = (attrs) => attrs?.retryable !== false;
|
|
251
|
+
var getSentWith = (attrs) => attrs?.sentWith === void 0 ? SentWith.noUserToken : SentWith.userToken(attrs.sentWith);
|
|
224
252
|
var getClientCredentials = (attrs) => attrs?.clientCredentials;
|
|
225
253
|
var Attributes = {
|
|
226
254
|
empty,
|
|
@@ -236,6 +264,10 @@ var Attributes = {
|
|
|
236
264
|
getRetryAttempt,
|
|
237
265
|
renewAttempted,
|
|
238
266
|
wasRenewAttempted,
|
|
267
|
+
notRetryable,
|
|
268
|
+
isRetryable,
|
|
269
|
+
sentWith,
|
|
270
|
+
getSentWith,
|
|
239
271
|
clientCredentials,
|
|
240
272
|
getClientCredentials,
|
|
241
273
|
requestId,
|
|
@@ -506,40 +538,6 @@ var MathError = class extends Error {
|
|
|
506
538
|
}
|
|
507
539
|
};
|
|
508
540
|
|
|
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
|
-
|
|
543
541
|
// src/universal/types/blockchain/core.ts
|
|
544
542
|
var ETHEREUM_CHAINS = {
|
|
545
543
|
ethereum_mainnet: true,
|
|
@@ -637,13 +635,54 @@ var StablecoinSymbol = (value) => value;
|
|
|
637
635
|
var KnownAssetSymbol = StablecoinSymbol;
|
|
638
636
|
var Bps = (value) => value;
|
|
639
637
|
|
|
638
|
+
// src/universal/core/shared/utils/wire.ts
|
|
639
|
+
function unknownTypeError(dto, model) {
|
|
640
|
+
const type = dto.type;
|
|
641
|
+
throw new ValidationError(
|
|
642
|
+
`${model}.type: unknown type ${JSON.stringify(type)}`
|
|
643
|
+
);
|
|
644
|
+
}
|
|
645
|
+
function requiredString(value, field) {
|
|
646
|
+
const text = notBlankStringOrNull(value);
|
|
647
|
+
if (text === null) {
|
|
648
|
+
throw new ValidationError(
|
|
649
|
+
`${field}: expected a non-blank string, got ${typeof value === "string" ? "a blank string" : String(value)}`
|
|
650
|
+
);
|
|
651
|
+
}
|
|
652
|
+
return text;
|
|
653
|
+
}
|
|
654
|
+
function requiredDate(value, field) {
|
|
655
|
+
const date = typeof value === "string" ? new Date(value) : null;
|
|
656
|
+
if (date === null || Number.isNaN(date.getTime())) {
|
|
657
|
+
throw new ValidationError(
|
|
658
|
+
`${field}: expected a date, got ${JSON.stringify(value)}`
|
|
659
|
+
);
|
|
660
|
+
}
|
|
661
|
+
return date;
|
|
662
|
+
}
|
|
663
|
+
function dateOrNull(value, field) {
|
|
664
|
+
return value === null ? null : requiredDate(value, field);
|
|
665
|
+
}
|
|
666
|
+
function decimalOrNull(value) {
|
|
667
|
+
return value === null ? null : DecimalString(value);
|
|
668
|
+
}
|
|
669
|
+
function requiredArray(value, field) {
|
|
670
|
+
if (!Array.isArray(value)) {
|
|
671
|
+
throw new ValidationError(
|
|
672
|
+
`${field}: expected an array, got ${typeof value}`
|
|
673
|
+
);
|
|
674
|
+
}
|
|
675
|
+
return value;
|
|
676
|
+
}
|
|
677
|
+
|
|
640
678
|
// src/universal/types/offer.ts
|
|
641
679
|
var OfferId = (value) => value;
|
|
642
680
|
var OfferSlug = (value) => value;
|
|
643
681
|
var OFFER_TYPES = {
|
|
644
682
|
"coinlist::token_sale": true,
|
|
645
683
|
"superstate::swap": true,
|
|
646
|
-
"ondo::swap": true
|
|
684
|
+
"ondo::swap": true,
|
|
685
|
+
"centrifuge::vault": true
|
|
647
686
|
};
|
|
648
687
|
var isOfferType = (value) => Object.keys(OFFER_TYPES).includes(value);
|
|
649
688
|
var OfferEditorial = {
|
|
@@ -685,6 +724,7 @@ var Offer = {
|
|
|
685
724
|
// on the wire: copying them would hand every consumer a `startsAt` that
|
|
686
725
|
// is 1970 for one variant and a date for the others.
|
|
687
726
|
case "ondo::swap":
|
|
727
|
+
case "centrifuge::vault":
|
|
688
728
|
return {
|
|
689
729
|
...base2,
|
|
690
730
|
type: dto.type,
|
|
@@ -737,6 +777,19 @@ var OfferSwapContract = {
|
|
|
737
777
|
address: EvmContractAddress(dto.address)
|
|
738
778
|
})
|
|
739
779
|
};
|
|
780
|
+
var OfferVaultContract = {
|
|
781
|
+
fromDto: (dto) => ({
|
|
782
|
+
chain: Chain(dto.chain),
|
|
783
|
+
address: EvmContractAddress(dto.address)
|
|
784
|
+
}),
|
|
785
|
+
/**
|
|
786
|
+
* Drops every proxy on a chain this SDK does not name, as
|
|
787
|
+
* `OfferToken.listFromDto` does: frontline publishes the full offer-token
|
|
788
|
+
* chain list, which runs ahead of {@link Chain}, and one unmodelled chain
|
|
789
|
+
* should not throw away the proxies the SDK can use.
|
|
790
|
+
*/
|
|
791
|
+
listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferVaultContract.fromDto)
|
|
792
|
+
};
|
|
740
793
|
var OfferDetail = {
|
|
741
794
|
fromDto: (dto) => {
|
|
742
795
|
const fundingAssets = requiredArray(
|
|
@@ -799,6 +852,18 @@ var OfferDetail = {
|
|
|
799
852
|
"OfferDetail.swap_contracts"
|
|
800
853
|
).map(OfferSwapContract.fromDto)
|
|
801
854
|
};
|
|
855
|
+
// No editorial, as for Ondo. `[]` is fine and a missing key is not, for
|
|
856
|
+
// the same reason as `swap_contracts`: this is the spender a user
|
|
857
|
+
// approves.
|
|
858
|
+
case "centrifuge::vault":
|
|
859
|
+
return {
|
|
860
|
+
...base2,
|
|
861
|
+
type: dto.type,
|
|
862
|
+
logoUrl: notBlankStringOrNull(dto.logo_url),
|
|
863
|
+
vaultContracts: OfferVaultContract.listFromDto(
|
|
864
|
+
requiredArray(dto.vault_contracts, "OfferDetail.vault_contracts")
|
|
865
|
+
)
|
|
866
|
+
};
|
|
802
867
|
default:
|
|
803
868
|
return unknownTypeError(dto, "OfferDetail");
|
|
804
869
|
}
|
|
@@ -1245,6 +1310,12 @@ function assertPriceFits(raw) {
|
|
|
1245
1310
|
}
|
|
1246
1311
|
}
|
|
1247
1312
|
|
|
1313
|
+
// src/universal/core/checkout/ondo/not-tradable.ts
|
|
1314
|
+
var ONDO_NOT_TRADABLE_CODE = "not_tradable";
|
|
1315
|
+
function isOndoNotTradableError(error) {
|
|
1316
|
+
return apiErrorCode(error) === ONDO_NOT_TRADABLE_CODE;
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1248
1319
|
// src/universal/core/shared/blockchain/formatters.ts
|
|
1249
1320
|
var import_viem2 = require("viem");
|
|
1250
1321
|
|
|
@@ -1265,7 +1336,11 @@ function formatAmount(amount, locale, options) {
|
|
|
1265
1336
|
const decimal = formatRawAmount(amount);
|
|
1266
1337
|
let [integerPart, fractionPart = ""] = decimal.split(".");
|
|
1267
1338
|
const maxFractionDigits = options?.maxFractionDigits;
|
|
1268
|
-
const minFractionDigits =
|
|
1339
|
+
const minFractionDigits = Math.min(
|
|
1340
|
+
options?.minFractionDigits ?? (maxFractionDigits !== void 0 ? maxFractionDigits : 2),
|
|
1341
|
+
maxFractionDigits ?? amount.decimals,
|
|
1342
|
+
amount.decimals
|
|
1343
|
+
);
|
|
1269
1344
|
if (maxFractionDigits !== void 0 && fractionPart.length > maxFractionDigits) {
|
|
1270
1345
|
({ integerPart, fractionPart } = roundFractionHalfUp(
|
|
1271
1346
|
integerPart,
|
|
@@ -1273,7 +1348,8 @@ function formatAmount(amount, locale, options) {
|
|
|
1273
1348
|
maxFractionDigits
|
|
1274
1349
|
));
|
|
1275
1350
|
}
|
|
1276
|
-
const
|
|
1351
|
+
const trimmed = fractionPart.replace(/0+$/, "");
|
|
1352
|
+
const fraction = trimmed.padEnd(minFractionDigits, "0");
|
|
1277
1353
|
const integerFormatted = BigInt(integerPart).toLocaleString(locale);
|
|
1278
1354
|
if (minFractionDigits === 0 && fraction === "") {
|
|
1279
1355
|
return FormattedAmountUi(integerFormatted);
|
|
@@ -1342,6 +1418,14 @@ function assetAmount(amount, symbol) {
|
|
|
1342
1418
|
return FormattedAmountAssetUi(`${amount} ${symbol}`);
|
|
1343
1419
|
}
|
|
1344
1420
|
var NA_AMOUNT_ASSET_UI = FormattedAmountAssetUi("-");
|
|
1421
|
+
var SHARE_MAX_FRACTION_DIGITS = AssetDecimals(6);
|
|
1422
|
+
var SHARE_MIN_FRACTION_DIGITS = AssetDecimals(2);
|
|
1423
|
+
function formatShareAmount(amount, locale) {
|
|
1424
|
+
return formatAmount(amount, locale, {
|
|
1425
|
+
maxFractionDigits: SHARE_MAX_FRACTION_DIGITS,
|
|
1426
|
+
minFractionDigits: SHARE_MIN_FRACTION_DIGITS
|
|
1427
|
+
});
|
|
1428
|
+
}
|
|
1345
1429
|
var USD_FRACTION_DIGITS = AssetDecimals(2);
|
|
1346
1430
|
function formattedUsdPrice(amount, locale) {
|
|
1347
1431
|
if (!amount) return NA_AMOUNT_ASSET_UI;
|
|
@@ -1483,7 +1567,6 @@ var OndoTradingStatus = {
|
|
|
1483
1567
|
};
|
|
1484
1568
|
}
|
|
1485
1569
|
};
|
|
1486
|
-
var decimalOrNull = (value) => value === null ? null : DecimalString(value);
|
|
1487
1570
|
var OndoQuote = {
|
|
1488
1571
|
fromDto: (dto) => {
|
|
1489
1572
|
const assetDecimals = AssetDecimals(dto.asset_decimals);
|
|
@@ -3314,7 +3397,9 @@ var TokenRegistrySnapshot = {
|
|
|
3314
3397
|
}
|
|
3315
3398
|
};
|
|
3316
3399
|
function offerDisplayTokens(offer) {
|
|
3317
|
-
const swaps = offer.tokens.filter(
|
|
3400
|
+
const swaps = offer.tokens.filter(
|
|
3401
|
+
(token) => token.role === "swap" || token.role === "vault"
|
|
3402
|
+
);
|
|
3318
3403
|
const distributions = offer.tokens.filter(
|
|
3319
3404
|
(token) => token.role === "distribution"
|
|
3320
3405
|
);
|
|
@@ -3355,11 +3440,18 @@ var HttpClient = class {
|
|
|
3355
3440
|
);
|
|
3356
3441
|
let response = await this.executeRequest(preparedRequest);
|
|
3357
3442
|
for (const middleware of this.middleware.afterRequest ?? []) {
|
|
3443
|
+
let retried = false;
|
|
3358
3444
|
response = await middleware({
|
|
3359
3445
|
request: preparedRequest,
|
|
3360
3446
|
response,
|
|
3361
|
-
retry: (nextRequest = preparedRequest) =>
|
|
3447
|
+
retry: (nextRequest = preparedRequest) => {
|
|
3448
|
+
retried = true;
|
|
3449
|
+
return this.runRequestWithAfterMiddleware(nextRequest);
|
|
3450
|
+
}
|
|
3362
3451
|
});
|
|
3452
|
+
if (retried) {
|
|
3453
|
+
return response;
|
|
3454
|
+
}
|
|
3363
3455
|
}
|
|
3364
3456
|
return response;
|
|
3365
3457
|
}
|
|
@@ -3849,6 +3941,194 @@ var OAuthSession = {
|
|
|
3849
3941
|
}
|
|
3850
3942
|
};
|
|
3851
3943
|
|
|
3944
|
+
// src/universal/types/providers/centrifuge/centrifuge.ts
|
|
3945
|
+
var CentrifugeVaultQuote = {
|
|
3946
|
+
fromDto: (dto) => {
|
|
3947
|
+
const spendDecimals = AssetDecimals(dto.spend_input_decimals);
|
|
3948
|
+
const shareDecimals = AssetDecimals(dto.share_decimals);
|
|
3949
|
+
return {
|
|
3950
|
+
chain: EthereumChain(dto.chain),
|
|
3951
|
+
symbol: AssetSymbol(dto.symbol),
|
|
3952
|
+
spendInputAmount: blockchainAmountFromRawOrThrow({
|
|
3953
|
+
label: "spend_input_amount",
|
|
3954
|
+
raw: dto.spend_input_amount,
|
|
3955
|
+
decimals: spendDecimals
|
|
3956
|
+
}),
|
|
3957
|
+
estimatedShares: blockchainAmountFromRawOrThrow({
|
|
3958
|
+
label: "estimated_shares",
|
|
3959
|
+
raw: dto.estimated_shares,
|
|
3960
|
+
decimals: shareDecimals
|
|
3961
|
+
}),
|
|
3962
|
+
indicativePrice: decimalOrNull(dto.indicative_price),
|
|
3963
|
+
minimumInputAmount: dto.minimum_input_amount === null ? null : blockchainAmountFromRawOrThrow({
|
|
3964
|
+
label: "minimum_input_amount",
|
|
3965
|
+
raw: dto.minimum_input_amount,
|
|
3966
|
+
decimals: spendDecimals
|
|
3967
|
+
}),
|
|
3968
|
+
orderability: parseOrderability(
|
|
3969
|
+
dto.can_order,
|
|
3970
|
+
dto.reasons,
|
|
3971
|
+
"CentrifugeVaultQuote"
|
|
3972
|
+
)
|
|
3973
|
+
};
|
|
3974
|
+
}
|
|
3975
|
+
};
|
|
3976
|
+
var CentrifugeVaultStatus = {
|
|
3977
|
+
fromDto: (dto) => ({
|
|
3978
|
+
chain: EthereumChain(dto.chain),
|
|
3979
|
+
symbol: AssetSymbol(dto.symbol),
|
|
3980
|
+
vaultAddress: EvmContractAddress(dto.vault_address),
|
|
3981
|
+
linked: dto.linked,
|
|
3982
|
+
permissioned: dto.permissioned,
|
|
3983
|
+
membershipValidUntil: dateOrNull(
|
|
3984
|
+
dto.membership_valid_until,
|
|
3985
|
+
"CentrifugeVaultStatus.membership_valid_until"
|
|
3986
|
+
),
|
|
3987
|
+
halted: dto.halted,
|
|
3988
|
+
priceUpdatedAt: dateOrNull(
|
|
3989
|
+
dto.price_updated_at,
|
|
3990
|
+
"CentrifugeVaultStatus.price_updated_at"
|
|
3991
|
+
),
|
|
3992
|
+
orderability: parseOrderability(
|
|
3993
|
+
dto.can_order,
|
|
3994
|
+
dto.reasons,
|
|
3995
|
+
"CentrifugeVaultStatus"
|
|
3996
|
+
),
|
|
3997
|
+
asOf: requiredDate(dto.as_of, "CentrifugeVaultStatus.as_of")
|
|
3998
|
+
})
|
|
3999
|
+
};
|
|
4000
|
+
var CentrifugeVaultBuyTransaction = {
|
|
4001
|
+
fromDto: (dto) => {
|
|
4002
|
+
const spendInputAmount = blockchainAmountFromRawOrThrow({
|
|
4003
|
+
label: "spend_input_amount",
|
|
4004
|
+
raw: dto.spend_input_amount,
|
|
4005
|
+
decimals: AssetDecimals(dto.spend_input_decimals)
|
|
4006
|
+
});
|
|
4007
|
+
if (spendInputAmount.raw <= 0n) {
|
|
4008
|
+
throw new ValidationError(
|
|
4009
|
+
`spend_input_amount: must be greater than zero ("${dto.spend_input_amount}") - a deposit of nothing is not a request`
|
|
4010
|
+
);
|
|
4011
|
+
}
|
|
4012
|
+
return {
|
|
4013
|
+
...parseTransactionCore(dto, "CentrifugeVaultBuyTransaction"),
|
|
4014
|
+
spendInputAmount,
|
|
4015
|
+
estimatedShares: blockchainAmountFromRawOrThrow({
|
|
4016
|
+
label: "estimated_shares",
|
|
4017
|
+
raw: dto.estimated_shares,
|
|
4018
|
+
decimals: AssetDecimals(dto.share_decimals)
|
|
4019
|
+
})
|
|
4020
|
+
};
|
|
4021
|
+
}
|
|
4022
|
+
};
|
|
4023
|
+
var CentrifugeVaultClaimTransaction = {
|
|
4024
|
+
fromDto: (dto) => ({
|
|
4025
|
+
...parseTransactionCore(dto, "CentrifugeVaultClaimTransaction"),
|
|
4026
|
+
claimableShares: blockchainAmountFromRawOrThrow({
|
|
4027
|
+
label: "claimable_shares",
|
|
4028
|
+
raw: dto.claimable_shares,
|
|
4029
|
+
decimals: AssetDecimals(dto.share_decimals)
|
|
4030
|
+
})
|
|
4031
|
+
})
|
|
4032
|
+
};
|
|
4033
|
+
var CentrifugeVaultPosition = {
|
|
4034
|
+
fromDto: (dto) => {
|
|
4035
|
+
const assetDecimals = AssetDecimals(dto.asset_decimals);
|
|
4036
|
+
const shareDecimals = AssetDecimals(dto.share_decimals);
|
|
4037
|
+
const asset = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: assetDecimals });
|
|
4038
|
+
const shares = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: shareDecimals });
|
|
4039
|
+
return {
|
|
4040
|
+
chain: EthereumChain(dto.chain),
|
|
4041
|
+
symbol: AssetSymbol(dto.symbol),
|
|
4042
|
+
walletAddress: EvmWalletAddress(dto.wallet_address),
|
|
4043
|
+
status: dto.status,
|
|
4044
|
+
requested: asset("requested", dto.requested),
|
|
4045
|
+
pending: asset("pending", dto.pending),
|
|
4046
|
+
filledAssets: asset("filled_assets", dto.filled_assets),
|
|
4047
|
+
earnedShares: shares("earned_shares", dto.earned_shares),
|
|
4048
|
+
claimedShares: shares("claimed_shares", dto.claimed_shares),
|
|
4049
|
+
claimableShares: shares("claimable_shares", dto.claimable_shares),
|
|
4050
|
+
shareBalance: shares("share_balance", dto.share_balance),
|
|
4051
|
+
averagePrice: decimalOrNull(dto.average_price),
|
|
4052
|
+
frozen: dto.frozen,
|
|
4053
|
+
asOf: requiredDate(dto.as_of, "CentrifugeVaultPosition.as_of")
|
|
4054
|
+
};
|
|
4055
|
+
}
|
|
4056
|
+
};
|
|
4057
|
+
function parseOrderability(canOrder, reasons, model) {
|
|
4058
|
+
const [first, ...rest] = reasons;
|
|
4059
|
+
if (canOrder) {
|
|
4060
|
+
if (first !== void 0) {
|
|
4061
|
+
throw new ValidationError(
|
|
4062
|
+
`${model}.reasons: expected none when can_order is true, got ${JSON.stringify(reasons)}`
|
|
4063
|
+
);
|
|
4064
|
+
}
|
|
4065
|
+
return { type: "orderable" };
|
|
4066
|
+
}
|
|
4067
|
+
if (first === void 0) {
|
|
4068
|
+
throw new ValidationError(
|
|
4069
|
+
`${model}.reasons: expected at least one when can_order is false`
|
|
4070
|
+
);
|
|
4071
|
+
}
|
|
4072
|
+
return { type: "blocked", reasons: [first, ...rest] };
|
|
4073
|
+
}
|
|
4074
|
+
function parseTransactionCore(dto, model) {
|
|
4075
|
+
return {
|
|
4076
|
+
tx: {
|
|
4077
|
+
to: EvmContractAddress(dto.to),
|
|
4078
|
+
data: HexEncodedTransactionData(dto.data)
|
|
4079
|
+
},
|
|
4080
|
+
expiresAt: dateOrNull(dto.expires_at, `${model}.expires_at`)
|
|
4081
|
+
};
|
|
4082
|
+
}
|
|
4083
|
+
|
|
4084
|
+
// src/universal/types/time.ts
|
|
4085
|
+
var MAX_EPOCH_MILLIS = 864e13;
|
|
4086
|
+
var EpochMillis = {
|
|
4087
|
+
/**
|
|
4088
|
+
* @throws {@link ValidationError} unless `value` is an integer a `Date` can
|
|
4089
|
+
* represent: at most {@link MAX_EPOCH_MILLIS} either side of the epoch.
|
|
4090
|
+
*/
|
|
4091
|
+
of: (value) => {
|
|
4092
|
+
if (!Number.isInteger(value) || Math.abs(value) > MAX_EPOCH_MILLIS) {
|
|
4093
|
+
throw new ValidationError(
|
|
4094
|
+
`EpochMillis must be an integer within \xB1${MAX_EPOCH_MILLIS}, got ${value}`
|
|
4095
|
+
);
|
|
4096
|
+
}
|
|
4097
|
+
return value;
|
|
4098
|
+
},
|
|
4099
|
+
/** The wall clock. Code that needs the time takes a `TimeEff` instead. */
|
|
4100
|
+
now: () => EpochMillis.of(Date.now()),
|
|
4101
|
+
/** @throws {@link ValidationError} for an invalid `Date`. */
|
|
4102
|
+
fromDate: (date) => EpochMillis.of(date.getTime()),
|
|
4103
|
+
/** How long after `from` the instant `to` is; negative if it is before. */
|
|
4104
|
+
elapsed: (from, to) => Millis.of(to - from),
|
|
4105
|
+
plus: (at, duration) => EpochMillis.of(at + duration)
|
|
4106
|
+
};
|
|
4107
|
+
var Millis = {
|
|
4108
|
+
of: (value) => value
|
|
4109
|
+
};
|
|
4110
|
+
var Seconds = {
|
|
4111
|
+
/**
|
|
4112
|
+
* @throws {@link ValidationError} unless `value` is a non-negative integer.
|
|
4113
|
+
*/
|
|
4114
|
+
of: (value) => {
|
|
4115
|
+
if (!Number.isInteger(value) || value < 0) {
|
|
4116
|
+
throw new ValidationError(
|
|
4117
|
+
`Seconds must be a non-negative integer, got ${value}`
|
|
4118
|
+
);
|
|
4119
|
+
}
|
|
4120
|
+
return value;
|
|
4121
|
+
},
|
|
4122
|
+
toMillis: (value) => Millis.of(value * 1e3)
|
|
4123
|
+
};
|
|
4124
|
+
function isExpired({
|
|
4125
|
+
expiresAt,
|
|
4126
|
+
now,
|
|
4127
|
+
buffer = Millis.of(0)
|
|
4128
|
+
}) {
|
|
4129
|
+
return now >= expiresAt - buffer;
|
|
4130
|
+
}
|
|
4131
|
+
|
|
3852
4132
|
// src/universal/types/user.ts
|
|
3853
4133
|
var UserId = (value) => value;
|
|
3854
4134
|
var UserEmail = (value) => value;
|
|
@@ -3872,6 +4152,11 @@ var User = {
|
|
|
3872
4152
|
Blockchain,
|
|
3873
4153
|
BlockchainAmount,
|
|
3874
4154
|
Bps,
|
|
4155
|
+
CentrifugeVaultBuyTransaction,
|
|
4156
|
+
CentrifugeVaultClaimTransaction,
|
|
4157
|
+
CentrifugeVaultPosition,
|
|
4158
|
+
CentrifugeVaultQuote,
|
|
4159
|
+
CentrifugeVaultStatus,
|
|
3875
4160
|
Chain,
|
|
3876
4161
|
ClientCredentialsOAuth,
|
|
3877
4162
|
ClientId,
|
|
@@ -3891,6 +4176,7 @@ var User = {
|
|
|
3891
4176
|
DocumentSubmission,
|
|
3892
4177
|
ERC20_ABI,
|
|
3893
4178
|
ETHEREUM_CHAINS,
|
|
4179
|
+
EpochMillis,
|
|
3894
4180
|
Erc20NamespaceImpl,
|
|
3895
4181
|
EthereumChain,
|
|
3896
4182
|
EvmContractAddress,
|
|
@@ -3911,11 +4197,13 @@ var User = {
|
|
|
3911
4197
|
MAX_UINT_256,
|
|
3912
4198
|
MathError,
|
|
3913
4199
|
Milestone,
|
|
4200
|
+
Millis,
|
|
3914
4201
|
NA_AMOUNT_ASSET_UI,
|
|
3915
4202
|
NotAuthenticatedError,
|
|
3916
4203
|
NotImplementedError,
|
|
3917
4204
|
OAuthRefreshToken,
|
|
3918
4205
|
OAuthSession,
|
|
4206
|
+
ONDO_NOT_TRADABLE_CODE,
|
|
3919
4207
|
ONDO_POLL_INTERVAL_MS,
|
|
3920
4208
|
ONDO_QUOTE_MAX_TTL_MS,
|
|
3921
4209
|
ONDO_SETTLEMENT_ASSET,
|
|
@@ -3932,6 +4220,7 @@ var User = {
|
|
|
3932
4220
|
OfferSlug,
|
|
3933
4221
|
OfferSwapContract,
|
|
3934
4222
|
OfferToken,
|
|
4223
|
+
OfferVaultContract,
|
|
3935
4224
|
OffersNamespaceImpl,
|
|
3936
4225
|
OndoBuyTransaction,
|
|
3937
4226
|
OndoNamespaceImpl,
|
|
@@ -3963,6 +4252,7 @@ var User = {
|
|
|
3963
4252
|
SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA,
|
|
3964
4253
|
SWAP_LEVEL,
|
|
3965
4254
|
SWAP_POLL_INTERVAL_MS,
|
|
4255
|
+
Seconds,
|
|
3966
4256
|
ShortenedWalletAddress,
|
|
3967
4257
|
SolanaChain,
|
|
3968
4258
|
StablecoinSymbol,
|
|
@@ -4006,13 +4296,16 @@ var User = {
|
|
|
4006
4296
|
formatBpsAsPercent,
|
|
4007
4297
|
formatCompactAmount,
|
|
4008
4298
|
formatRawAmount,
|
|
4299
|
+
formatShareAmount,
|
|
4009
4300
|
formattedPricePerShare,
|
|
4010
4301
|
formattedUsdPrice,
|
|
4011
4302
|
generatePKCEParams,
|
|
4012
4303
|
getChainId,
|
|
4013
4304
|
getNetworkName,
|
|
4014
4305
|
isChain,
|
|
4306
|
+
isExpired,
|
|
4015
4307
|
isOfferType,
|
|
4308
|
+
isOndoNotTradableError,
|
|
4016
4309
|
isSwapAvailable,
|
|
4017
4310
|
offerDisplayTokens,
|
|
4018
4311
|
ondoQuoteOfferDeadline,
|