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