@coinlist-co/react 0.10.1 → 0.11.1-rc.10770e8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +32 -0
  2. package/dist/chunk-7CTH4KPU.js +2399 -0
  3. package/dist/chunk-7CTH4KPU.js.map +1 -0
  4. package/dist/{chunk-AQVCOWOV.js → chunk-LSPZETDH.js} +249 -317
  5. package/dist/chunk-LSPZETDH.js.map +1 -0
  6. package/dist/chunk-UZUQALFY.js +279 -0
  7. package/dist/chunk-UZUQALFY.js.map +1 -0
  8. package/dist/client/index.cjs +13430 -3308
  9. package/dist/client/index.cjs.map +1 -1
  10. package/dist/client/index.d.cts +5486 -899
  11. package/dist/client/index.d.ts +5486 -899
  12. package/dist/client/index.js +11025 -2388
  13. package/dist/client/index.js.map +1 -1
  14. package/dist/collections-BBI_XydI.d.cts +116 -0
  15. package/dist/collections-BrX9rRWc.d.ts +116 -0
  16. package/dist/config-CMl1bR3F.d.cts +2959 -0
  17. package/dist/config-CMl1bR3F.d.ts +2959 -0
  18. package/dist/server/index.cjs +1768 -511
  19. package/dist/server/index.cjs.map +1 -1
  20. package/dist/server/index.d.cts +266 -162
  21. package/dist/server/index.d.ts +266 -162
  22. package/dist/server/index.js +235 -169
  23. package/dist/server/index.js.map +1 -1
  24. package/dist/shared/index.cjs +2423 -926
  25. package/dist/shared/index.cjs.map +1 -1
  26. package/dist/shared/index.d.cts +325 -132
  27. package/dist/shared/index.d.ts +325 -132
  28. package/dist/shared/index.js +112 -28
  29. package/package.json +12 -8
  30. package/dist/chunk-AQVCOWOV.js.map +0 -1
  31. package/dist/chunk-TBU3EBNM.js +0 -442
  32. package/dist/chunk-TBU3EBNM.js.map +0 -1
  33. package/dist/chunk-UOHD7US2.js +0 -855
  34. package/dist/chunk-UOHD7US2.js.map +0 -1
  35. package/dist/collections-Bv1Oxzu_.d.ts +0 -28
  36. package/dist/collections-DDyxbOPZ.d.cts +0 -28
  37. package/dist/requirement-oVZA1INj.d.cts +0 -1040
  38. package/dist/requirement-oVZA1INj.d.ts +0 -1040
@@ -1,8 +1,40 @@
1
- import { B as Bps, U as Uint256, N as Newtype, a as EthereumChain, G as AssetDecimals, M as AssetSymbol, d as BlockchainAmount, E as EvmWalletAddress, b as EvmContractAddress, Q as SwapStatus, V as KnownAssetSymbol, F as Erc20Asset, H as StablecoinSymbol, X as ClientId, Y as RedirectUri, Z as CodeChallenge, _ as PKCEState, i as CodeVerifier } from '../requirement-oVZA1INj.js';
2
- export { $ as AllowWalletParams, a0 as AllowWalletResponse, a1 as Asset, a2 as AssetCode, A as AssetId, h as AuthorizationCode, a3 as Blockchain, J as ClientCredentialsOAuth, L as ClientSecret, c as CoinListErc20Namespace, C as CoinListSwapNamespace, f as CoinListTokenSaleNamespace, j as Config, q as ConnectExternalWalletParams, a4 as CreateParticipationParams, p as CreateWalletOwnershipChallengeParams, a5 as Cursor, a6 as DocumentFormType, v as DocumentSubmission, a7 as DocumentSubmissionStatus, D as DocumentType, a8 as Erc20NamespaceImpl, a9 as FaqItem, aa as GetSwapAuthorizationParams, ab as GetSwapPreviewParams, ac as GetTokenAllowanceParams, ad as GetTokenBalanceParams, ae as HexEncodedTransactionData, af as Iso2CountryCode, K as KycLevelName, w as KycToken, ag as Link, ah as MAX_UINT_256, ai as Milestone, k as OAuthAccessToken, aj as OAuthRefreshToken, I as OAuthSession, l as Offer, o as OfferDetail, O as OfferId, ak as OfferOption, r as OfferOptionAddress, s as OfferOptionAddressId, g as OfferOptionId, al as OfferOptionSlug, am as OfferSlug, an as OfferType, n as PaginatedResponse, ao as PaginatedResponseDto, m as PaginationParams, P as Participation, ap as ParticipationId, aq as ParticipationStatus, ar as ParticipationsPaginationParams, u as Pii, as as PiiAddress, at as PiiJurisdiction, au as PiiKind, R as Requirement, av as RequirementActionNeededReason, aw as RequirementId, t as RequirementStatusInfo, z as RequirementStatusValue, y as RequirementType, ax as SwapAuthorization, ay as SwapContractRef, S as SwapNamespaceImpl, az as SwapPreview, aA as TermItem, aB as TokenAllowance, aC as TokenBalance, T as TokenSaleNamespaceImpl, aD as WalletAddress, x as WalletChallengeType, W as WalletOwnershipChallenge, aE as WalletProtocol, aF as assertUint256, aG as fetchAllPages } from '../requirement-oVZA1INj.js';
1
+ import { ao as PaginationParams, ap as PaginatedResponse, p as Bps, aq as Uint256, a as EthereumChain, X as AssetDecimals, h as AssetSymbol, B as BlockchainAmount, q as EvmWalletAddress, ar as KnownAssetSymbol, y as Erc20Asset, b as EvmContractAddress, x as StablecoinSymbol, as as DecimalString, i as OndoBuyTransaction, j as OndoSellTransaction, at as SwapStatus, au as Newtype } from '../config-CMl1bR3F.js';
2
+ export { av as AllowWalletParams, aw as AllowWalletResponse, ax as Asset, ay as AssetCode, e as AssetId, A as AuthorizationCode, az as Blockchain, Y as BuildOndoBuyParams, Z as BuildOndoSellParams, aA as BuildOndoSwapParamsCore, aB as Chain, al as ClientCredentialsOAuth, aC as ClientId, am as ClientSecret, aD as CodeChallenge, C as CodeVerifier, c as CoinListTokenSaleNamespace, f as CoinListTokenSaleNamespaceImpl, u as Config, aE as ConnectExternalWalletParams, aF as CreateKycTokenParams, aG as CreateParticipationParams, aH as CreateWalletOwnershipChallengeParams, aI as Cursor, a3 as DebugEvent, aJ as DocumentFormType, N as DocumentSubmission, aK as DocumentSubmissionStatus, aL as DocumentType, aM as ETHEREUM_CHAINS, E as Erc20Namespace, aN as Erc20NamespaceImpl, aO as FaqItem, a4 as FrontlineEventId, aP as GetOndoQuoteParams, aQ as GetOndoTradingStatusParams, aR as GetSwapAuthorizationParams, aS as GetSwapPreviewParams, aT as GetTokenAllowanceParams, aU as GetTokenBalanceParams, aV as HexEncodedTransactionData, a5 as HttpError, a6 as HttpResponse, aW as Iso2CountryCode, M as KycLevelName, a7 as KycToken, aX as Link, aY as ListOptionAddressesParams, a8 as LogBinding, a9 as LogBindings, aa as LogCause, ab as LogLevel, ac as LogScope, ad as LogValue, L as Logger, aZ as MAX_ASSET_DECIMALS, a_ as MAX_UINT_256, a$ as Milestone, v as OAuthAccessToken, b0 as OAuthRefreshToken, ak as OAuthSession, F as Offer, z as OfferDetail, O as OfferId, b1 as OfferOption, J as OfferOptionAddress, a0 as OfferOptionAddressId, d as OfferOptionId, b2 as OfferOptionSlug, b3 as OfferSlug, b4 as OfferToken, D as OfferType, w as OffersNamespace, b5 as OffersNamespaceImpl, g as OndoNamespace, m as OndoNamespaceImpl, _ as OndoQuote, b6 as OndoQuoteDuration, $ as OndoQuoteSize, b7 as OndoSellOutcome, k as OndoSwapTransactionCore, V as OndoTradingStatus, l as OrderBookSide, b8 as PKCEState, b9 as PaginatedResponseDto, P as Participation, ba as ParticipationId, bb as ParticipationStatus, bc as ParticipationsPaginationParams, bd as Pii, be as PiiAddress, bf as PiiJurisdiction, bg as PiiKind, U as PinoLoggerOptions, ae as ProductionLogLevel, bh as QueryParamValue, bi as QueryParamValues, af as RedactedWalletError, bj as RedirectUri, bk as RemoveOptionAddressParams, ag as RequestId, s as Requirement, bl as RequirementActionNeededReason, K as RequirementId, G as RequirementStatusInfo, I as RequirementStatusValue, H as RequirementType, R as RequirementsNamespace, t as RequirementsNamespaceImpl, bm as SOLANA_CHAINS, bn as STABLE_DECIMALS, ah as SafeEvent, ai as SafeFields, bo as SolanaChain, bp as SubmitDocumentParams, n as SuperstateSwapNamespace, r as SuperstateSwapNamespaceImpl, bq as SwapAuthorization, br as SwapContractRef, bs as SwapPreview, bt as TermItem, bu as Ticker, bv as TokenAllowance, bw as TokenBalance, a2 as TokenIdentifier, bx as TokenLogo, by as TokenLogoImage, bz as TokenLogoUrl, a1 as TokenMetadata, bA as TokenRole, T as TokensNamespace, bB as TokensNamespaceImpl, bC as Tx, aj as UnredactedFields, bD as WalletAddress, Q as WalletChallengeType, W as WalletError, bE as WalletOwnershipChallenge, bF as WalletProtocol, o as WalletsNamespace, bG as WalletsNamespaceImpl, bH as apiErrorCode, bI as assertUint256, bJ as parseUint256 } from '../config-CMl1bR3F.js';
3
+ import { T as TxExplorerUrl, F as FormattedAmountAssetUi, d as FormattedAmountUi, b as FormattedPercentUi, a as ShortenedWalletAddress, N as NonEmptyArray, S as SwapQuote } from '../collections-BrX9rRWc.js';
4
+ export { A as AssetIconUrl, B as BroadcastTxParams, C as ConnectWallet, c as EvmSigner, E as EvmWallet, P as PKCEConfig, e as PKCEParams, W as WriteContractParams, g as generatePKCEParams } from '../collections-BrX9rRWc.js';
3
5
  import { Hash, TransactionReceipt } from 'viem';
4
- import { S as SwapQuote } from '../collections-Bv1Oxzu_.js';
5
- export { N as NonEmptyArray } from '../collections-Bv1Oxzu_.js';
6
+
7
+ /**
8
+ * Walks every page of a cursor-paginated endpoint and returns the flattened
9
+ * result.
10
+ *
11
+ * Lives in the API layer rather than beside `PaginationParams` because it
12
+ * drives requests: it is the auto-paginating half that `list()` is built on,
13
+ * while the params and the response envelope are domain models the client and
14
+ * the server both name.
15
+ */
16
+ declare function fetchAllPages<A, P extends PaginationParams = PaginationParams>(fetchPage: (params: P) => Promise<PaginatedResponse<A>>, baseParams?: Omit<P, keyof PaginationParams>): Promise<A[]>;
17
+
18
+ /** Basis-point denominator: 10_000 bps = 100%. */
19
+ declare const BPS_DENOM: Bps;
20
+ /**
21
+ * Applies a basis-point fraction to an amount, flooring the result.
22
+ * `floor((amount × bps) / BPS_DENOM)`. The result is bounds-checked, so an
23
+ * overflow (bps far above BPS_DENOM) or a negative product is rejected.
24
+ */
25
+ declare function applyBps(amount: Uint256, bps: Bps): Uint256;
26
+
27
+ declare function getChainId(chain: EthereumChain): number;
28
+ /**
29
+ * Resolves an EIP-155 chain id to the chain the SDK names it by — the inverse
30
+ * of {@link getChainId}, for backends that report a bare `chain_id`.
31
+ *
32
+ * @throws ValidationError on an unrecognised id. Defaulting to mainnet would
33
+ * let a testnet response read as a live one.
34
+ */
35
+ declare function chainFromId(chainId: string): EthereumChain;
36
+ declare function getNetworkName(chain: EthereumChain): string;
37
+ declare function txExplorerUrl(chain: EthereumChain, txHash: Hash): TxExplorerUrl;
6
38
 
7
39
  /**
8
40
  * Minimal ERC-20 ABI the SDK writes against (mirrors viem's `erc20Abi`). The
@@ -156,6 +188,222 @@ declare const ERC20_ABI: readonly [{
156
188
  readonly anonymous: false;
157
189
  }];
158
190
 
191
+ declare function shortenAddress(address: EvmWalletAddress): ShortenedWalletAddress;
192
+ type FormatAmountOptions = {
193
+ maxFractionDigits?: AssetDecimals;
194
+ };
195
+ declare function formatAmount(amount: BlockchainAmount, locale: string, options?: FormatAmountOptions): FormattedAmountUi;
196
+ declare function formatRawAmount(amount: BlockchainAmount): string;
197
+ /**
198
+ * Formats a {@link BlockchainAmount} using compact notation (e.g. `1.37B`,
199
+ * `5M`). Compact notation only surfaces a couple of significant decimals, so
200
+ * the bigint → number narrowing here is intentional and safe: full precision
201
+ * is deliberately dropped in favour of a human-readable summary value.
202
+ */
203
+ declare function formatCompactAmount(amount: BlockchainAmount, locale: string): FormattedAmountUi;
204
+ declare function formatBpsAsPercent(bps: Bps, locale: string): FormattedPercentUi;
205
+ declare function usdAmount(amount: FormattedAmountUi): FormattedAmountAssetUi;
206
+ declare function assetAmount(amount: FormattedAmountUi, symbol: AssetSymbol): FormattedAmountAssetUi;
207
+ /** Placeholder shown when an amount is unavailable (e.g. a loading quote). */
208
+ declare const NA_AMOUNT_ASSET_UI: FormattedAmountAssetUi;
209
+ /**
210
+ * Formats a USD amount capped at 2 fractional digits, falling back to the
211
+ * {@link NA_AMOUNT_ASSET_UI} placeholder when the amount is absent.
212
+ */
213
+ declare function formattedUsdPrice(amount: BlockchainAmount | null, locale: string): FormattedAmountAssetUi;
214
+
215
+ /** A typed, i18n-agnostic reason a raw amount string failed to parse. */
216
+ type AmountParseErrorReason = {
217
+ type: 'empty';
218
+ } | {
219
+ type: 'negative';
220
+ } | {
221
+ type: 'invalid-format';
222
+ } | {
223
+ type: 'too-many-decimals';
224
+ maxDecimals: AssetDecimals;
225
+ }
226
+ /** Scaled up by `decimals`, the amount no longer fits a uint256. */
227
+ | {
228
+ type: 'overflow';
229
+ };
230
+ type AmountParseResult = {
231
+ valid: true;
232
+ amount: BlockchainAmount;
233
+ } | {
234
+ valid: false;
235
+ reason: AmountParseErrorReason;
236
+ };
237
+ /**
238
+ * Wraps a raw uint256 base-unit string — what Ondo and the on-chain reads
239
+ * return ("100000000" is 100 USDC, not 100 wei-of-nothing) — in a
240
+ * {@link BlockchainAmount} at the given decimals. The value is already scaled,
241
+ * so `decimals` is only the unit tag that travels with it.
242
+ *
243
+ * Distinct from {@link parseBlockchainAmount}, which takes a *human decimal*
244
+ * string and scales it up. Feeding a raw amount to that one silently
245
+ * multiplies it by 10^decimals — pick by what the backend sends, not by which
246
+ * one is closer at hand.
247
+ *
248
+ * @throws ValidationError when the string is not a non-negative uint256
249
+ * integer. A backend that regresses to decimal strings fails loudly here
250
+ * rather than truncating.
251
+ */
252
+ declare function blockchainAmountFromRawOrThrow({ label, raw, decimals, }: {
253
+ label: string;
254
+ raw: string;
255
+ decimals: AssetDecimals;
256
+ }): BlockchainAmount;
257
+ /**
258
+ * Parses a user-entered decimal string into a {@link BlockchainAmount} at the
259
+ * given token decimals. Rejects scientific notation, negatives, malformed
260
+ * input, more fractional digits than the token supports, and amounts that
261
+ * scale past uint256 — surfacing a typed {@link AmountParseErrorReason} so
262
+ * callers own the display copy.
263
+ */
264
+ declare function parseBlockchainAmount(amount: string, decimals: AssetDecimals): AmountParseResult;
265
+
266
+ declare const USDC_SYMBOL: StablecoinSymbol;
267
+ declare const USDC: Erc20Asset;
268
+ declare const USDT_SYMBOL: StablecoinSymbol;
269
+ declare const USDT: Erc20Asset;
270
+ /** Lookups for the stablecoins the SDK's swap flows support out of the box. */
271
+ declare const TOKEN_REGISTRY: {
272
+ erc20: (symbol: KnownAssetSymbol) => Erc20Asset;
273
+ /**
274
+ * USDC's contract on `chain`. USDC is deployed on every chain the SDK
275
+ * models, so the table is total and the answer is never `null`.
276
+ */
277
+ usdcAddress: (chain: EthereumChain) => EvmContractAddress;
278
+ /**
279
+ * USDT's contract on `chain`, or `null` where Tether publishes none —
280
+ * Base Sepolia today. The honest answer, never a fake address a balance
281
+ * read would call.
282
+ */
283
+ usdtAddress: (chain: EthereumChain) => EvmContractAddress | null;
284
+ };
285
+
286
+ /** The Ondo integration contract on `chain`, or `null` where none is deployed. */
287
+ declare function ondoSwapContractAddress(chain: EthereumChain): EvmContractAddress | null;
288
+ /**
289
+ * How often the Ondo checkout refreshes what it is allowed to poll: the market
290
+ * status and the indicative price. Both are free - neither spends an
291
+ * attestation - so this is paced for a price the user can trust rather than
292
+ * for cost.
293
+ *
294
+ * A built transaction is deliberately not on this timer. Building spends an
295
+ * attestation, so it happens once per order and once per refresh the user
296
+ * asks for.
297
+ */
298
+ declare const ONDO_POLL_INTERVAL_MS = 15000;
299
+ /**
300
+ * How close to its deadline a built transaction stops being offerable.
301
+ *
302
+ * Placing an order is not instant - the wallet has to prompt, the user has to
303
+ * confirm, and the transaction has to reach a node - so calldata with a second
304
+ * left is one the contract will reject. Treating the last few seconds as
305
+ * already expired turns a paid-for revert into a refresh button.
306
+ */
307
+ declare const ONDO_QUOTE_EXPIRY_THRESHOLD_MS = 5000;
308
+ /**
309
+ * The order size the sidebar prices against before the user names one.
310
+ *
311
+ * Ondo prices by size, so some amount has to be sent. $1,000 is a plausible
312
+ * order rather than a token one: a size so small that Ondo's minimum rejects
313
+ * it would leave the panel permanently blank.
314
+ *
315
+ * Named distinctly from `DEFAULT_AMOUNT_TO_COMPUTE_PRICE` in the swap
316
+ * constants, which is a raw `bigint` of USDC base units for a different
317
+ * endpoint. Both barrels are flat, so two constants of the same name could not
318
+ * coexist - and they mean different things anyway.
319
+ */
320
+ declare const DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE: DecimalString;
321
+ /**
322
+ * The coin an Ondo sell settles into, for display only.
323
+ *
324
+ * The scale of every amount on a built transaction comes off the response, so
325
+ * this names the token and never sizes it - `receive_output_decimals` is the
326
+ * only authority on how many decimals the proceeds are counted in, and the two
327
+ * are allowed to disagree.
328
+ *
329
+ * Named apart from {@link ONDO_SUPPORTED_INPUT_ASSETS} rather than read out of
330
+ * it, though both are USDC today. On a buy USDC is what the user funds with
331
+ * and one of a list that may grow; on a sell it is what they settle into and
332
+ * there is one of it. Reading `ONDO_SUPPORTED_INPUT_ASSETS[0]` here would make
333
+ * the sell screen quietly follow whichever funding coin happened to be listed
334
+ * first.
335
+ */
336
+ declare const ONDO_SETTLEMENT_ASSET: StablecoinSymbol;
337
+ /**
338
+ * The order size the sidebar prices a sell against before the user names one.
339
+ *
340
+ * Sells are quoted by token amount rather than by notional: the fee comes out
341
+ * of dollars, and Ondo's price is size-aware, so a buy's quantity depends on
342
+ * the quote being asked for while a sell is sized by what the user already
343
+ * holds. One whole share is a size Ondo will price - small enough to be
344
+ * plausible for any asset, large enough that Ondo's minimum does not reject it
345
+ * and leave the panel permanently blank.
346
+ *
347
+ * The buy counterpart is {@link DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE}, which
348
+ * is a dollar figure for the same reason in reverse.
349
+ */
350
+ declare const DEFAULT_ONDO_SELL_TOKENS_TO_COMPUTE_PRICE = 1;
351
+ /**
352
+ * The coins an Ondo buy can be funded with, in display order, with the first
353
+ * preselected.
354
+ *
355
+ * USDC alone today: it is what the Sepolia integration contract accepts. The
356
+ * amount step renders a single entry as a plain card and two or more as a
357
+ * picker, so adding one here is all it takes.
358
+ */
359
+ declare const ONDO_SUPPORTED_INPUT_ASSETS: NonEmptyArray<StablecoinSymbol>;
360
+
361
+ /**
362
+ * The price of one whole asset token in a built Ondo purchase, in the funding
363
+ * token's units - USD per share.
364
+ *
365
+ * Neither builder publishes a price. Frontline drops Ninshubur's deliberately,
366
+ * because `GET /v1/ondo/swap/quote` already serves one under that name at a
367
+ * different scale, and echoing both would leave a caller to guess which was
368
+ * which.
369
+ *
370
+ * Dividing the two amounts the response *does* carry is better than reading
371
+ * the indicative one anyway: it is the price this transaction fills at, rather
372
+ * than a poll that has since moved and was struck against a different size.
373
+ *
374
+ * **Fee-exclusive.** `notionalValue` is the deposit after CoinList's fee comes
375
+ * off, so this is the price Ondo filled at, not the buyer's all-in cost per
376
+ * token - that would be `spendInputAmount / receiveOutputAmount`, and it is
377
+ * higher. Fee-exclusive is what the review screen wants, because it renders
378
+ * the fee on its own line: price x quantity, plus fee, comes to the total.
379
+ * Making this all-in would double-count the fee against that breakdown.
380
+ *
381
+ * The two are equal until ENG-1718 turns a fee on, which frontline rejects
382
+ * today. They diverge the moment it does, so the choice is load-bearing rather
383
+ * than academic.
384
+ */
385
+ declare function computeOndoBuyPrice(transaction: OndoBuyTransaction): BlockchainAmount;
386
+ /**
387
+ * The price of one whole asset token in a built Ondo sale, in the settlement
388
+ * token's units - USD per share, the same thing
389
+ * {@link computeOndoBuyPrice} answers with the ratio inverted.
390
+ *
391
+ * **Fee-exclusive, and it takes arithmetic to be so.** `expected.quantity` is
392
+ * published already net of `expected.fee`, so the proceeds are added back
393
+ * before dividing: what comes out is the price Ondo filled at, which is the
394
+ * buy arm's meaning rather than a second one. That is what lets one review row
395
+ * render on either screen, and what keeps the sell breakdown honest - the fee
396
+ * sits on its own line beside this, and a net price would count it twice.
397
+ *
398
+ * Read against {@link OndoSellTransaction.expected} alone. The `minimum` arm
399
+ * describes the same trade at a different outcome, and pricing that one would
400
+ * answer "the worst price this could fill at", which no screen asks for.
401
+ *
402
+ * The two readings coincide while frontline forces the fee to zero, which it
403
+ * does today. They diverge the day ENG-1718 lands.
404
+ */
405
+ declare function computeOndoSellPrice(transaction: OndoSellTransaction): BlockchainAmount;
406
+
159
407
  declare const SUPERSTATE_SWAP_ABI: readonly [{
160
408
  readonly type: "function";
161
409
  readonly name: "authorized";
@@ -473,107 +721,6 @@ declare const SUPERSTATE_SWAP_ABI: readonly [{
473
721
  }];
474
722
  }];
475
723
 
476
- /** Basis-point denominator: 10_000 bps = 100%. */
477
- declare const BPS_DENOM: Bps;
478
- /**
479
- * Applies a basis-point fraction to an amount, flooring the result.
480
- * `floor((amount × bps) / BPS_DENOM)`. The result is bounds-checked, so an
481
- * overflow (bps far above BPS_DENOM) or a negative product is rejected.
482
- */
483
- declare function applyBps(amount: Uint256, bps: Bps): Uint256;
484
-
485
- type FormattedAmountUi = Newtype<string, 'FormattedAmountUi'>;
486
- declare const FormattedAmountUi: (value: string) => FormattedAmountUi;
487
- type FormattedPercentUi = Newtype<string, 'FormattedPercentUi'>;
488
- declare const FormattedPercentUi: (value: string) => FormattedPercentUi;
489
- type TxExplorerUrl = Newtype<string, 'TxExplorerUrl'>;
490
- declare const TxExplorerUrl: (value: string) => TxExplorerUrl;
491
- /**
492
- * A wallet address shortened for display (e.g. `0x1234…5678`). Keeps a
493
- * `0x${string}` base but drops the runtime `0x` narrowing.
494
- */
495
- type ShortenedWalletAddress = Newtype<`0x${string}`, 'ShortenedWalletAddress'>;
496
- declare const ShortenedWalletAddress: (value: string) => ShortenedWalletAddress;
497
- type FormattedAmountAssetUi = Newtype<string, 'FormattedAmountAssetUi'>;
498
- declare const FormattedAmountAssetUi: (value: string) => FormattedAmountAssetUi;
499
- type AssetIconUrl = Newtype<string, 'AssetIconUrl'>;
500
- declare const AssetIconUrl: (value: string) => AssetIconUrl;
501
-
502
- declare function getChainId(chain: EthereumChain): number;
503
- declare function getNetworkName(chain: EthereumChain): string;
504
- declare function txExplorerUrl(chain: EthereumChain, txHash: Hash): TxExplorerUrl;
505
-
506
- declare function shortenAddress(address: EvmWalletAddress): ShortenedWalletAddress;
507
- type FormatAmountOptions = {
508
- maxFractionDigits?: AssetDecimals;
509
- };
510
- declare function formatAmount(amount: BlockchainAmount, locale: string, options?: FormatAmountOptions): FormattedAmountUi;
511
- declare function formatRawAmount(amount: BlockchainAmount): string;
512
- /**
513
- * Formats a {@link BlockchainAmount} using compact notation (e.g. `1.37B`,
514
- * `5M`). Compact notation only surfaces a couple of significant decimals, so
515
- * the bigint → number narrowing here is intentional and safe: full precision
516
- * is deliberately dropped in favour of a human-readable summary value.
517
- */
518
- declare function formatCompactAmount(amount: BlockchainAmount, locale: string): FormattedAmountUi;
519
- declare function formatBpsAsPercent(bps: Bps, locale: string): FormattedPercentUi;
520
- declare function usdAmount(amount: FormattedAmountUi): FormattedAmountAssetUi;
521
- declare function assetAmount(amount: FormattedAmountUi, symbol: AssetSymbol): FormattedAmountAssetUi;
522
- /** Placeholder shown when an amount is unavailable (e.g. a loading quote). */
523
- declare const NA_AMOUNT_ASSET_UI: FormattedAmountAssetUi;
524
- /**
525
- * Formats a USD amount capped at 2 fractional digits, falling back to the
526
- * {@link NA_AMOUNT_ASSET_UI} placeholder when the amount is absent.
527
- */
528
- declare function formattedUsdPrice(amount: BlockchainAmount | null, locale: string): FormattedAmountAssetUi;
529
- /** Formats a quote's implied price per output token as a USD amount. */
530
- declare function formattedPricePerShare(quote: SwapQuote | null, locale: string): FormattedAmountAssetUi;
531
-
532
- /** A typed, i18n-agnostic reason a raw amount string failed to parse. */
533
- type AmountParseErrorReason = {
534
- type: 'empty';
535
- } | {
536
- type: 'negative';
537
- } | {
538
- type: 'invalid-format';
539
- } | {
540
- type: 'too-many-decimals';
541
- maxDecimals: AssetDecimals;
542
- };
543
- type AmountParseResult = {
544
- valid: true;
545
- amount: BlockchainAmount;
546
- } | {
547
- valid: false;
548
- reason: AmountParseErrorReason;
549
- };
550
- /**
551
- * Parses a user-entered decimal string into a {@link BlockchainAmount} at the
552
- * given token decimals. Rejects scientific notation, negatives, malformed
553
- * input, and more fractional digits than the token supports — surfacing a
554
- * typed {@link AmountParseErrorReason} so callers own the display copy.
555
- */
556
- declare function parseBlockchainAmount(amount: string, decimals: AssetDecimals): AmountParseResult;
557
-
558
- declare const SUPERSTATE_TOS_URL = "https://superstate.com/terms";
559
- /** Poll interval for refreshing on-chain swap quotes and balances. */
560
- declare const SWAP_POLL_INTERVAL_MS = 15000;
561
- /**
562
- * Notional input used to derive a display price-per-share when the user has
563
- * not yet entered an amount (1 USDC at 6 decimals).
564
- */
565
- declare const DEFAULT_AMOUNT_TO_COMPUTE_PRICE = 1000000n;
566
- /** Slippage tolerances offered in the review step, in basis points. */
567
- declare const SLIPPAGE_OPTIONS_BPS: Bps[];
568
- /** Default slippage tolerance (0.5%). */
569
- declare const DEFAULT_SLIPPAGE_BPS: Bps;
570
- /**
571
- * The Superstate swap contract on Ethereum Sepolia. The mainnet address is not
572
- * yet finalized upstream, so it is intentionally not exported — callers pass
573
- * the contract address explicitly.
574
- */
575
- declare const SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA: EvmContractAddress;
576
-
577
724
  /**
578
725
  * Price of 1 output token in USD, assuming the input token is a $1 stablecoin.
579
726
  *
@@ -612,35 +759,53 @@ declare function isStopped(status: SwapStatus): boolean;
612
759
  */
613
760
  declare function decodeSwappedOutputAmount(receipt: TransactionReceipt, outputDecimals: AssetDecimals): BlockchainAmount | null;
614
761
 
615
- declare const USDC_SYMBOL: StablecoinSymbol;
616
- declare const USDC: Erc20Asset;
617
- declare const USDT_SYMBOL: StablecoinSymbol;
618
- declare const USDT: Erc20Asset;
619
- /** Lookups for the stablecoins the SDK's swap flows support out of the box. */
620
- declare const TOKEN_REGISTRY: {
621
- erc20: (symbol: KnownAssetSymbol) => Erc20Asset;
622
- contractAddress: (symbol: KnownAssetSymbol, chain: EthereumChain) => EvmContractAddress;
623
- };
762
+ /**
763
+ * Who issues the asset a Superstate swap pays out.
764
+ *
765
+ * A constant rather than a field off the offer: no frontline endpoint carries
766
+ * an issuer, and every offer this checkout serves is Superstate's by
767
+ * definition — `CheckoutContainer` routes here on `superstate::swap` alone.
768
+ */
769
+ declare const SUPERSTATE_ISSUER_NAME = "Superstate";
770
+ /**
771
+ * The coins a Superstate swap can be funded with, in display order, with the
772
+ * first preselected.
773
+ *
774
+ * USDC alone today: it is what the deployed swap contract accepts. The amount
775
+ * step renders a single entry as a plain card and two or more as a picker, so
776
+ * adding one here is all it takes.
777
+ */
778
+ declare const SUPERSTATE_SUPPORTED_INPUT_ASSETS: NonEmptyArray<StablecoinSymbol>;
779
+ /** Poll interval for refreshing on-chain swap quotes and balances. */
780
+ declare const SWAP_POLL_INTERVAL_MS = 15000;
781
+ /**
782
+ * Notional input used to derive a display price-per-share when the user has
783
+ * not yet entered an amount (1 USDC at 6 decimals).
784
+ */
785
+ declare const DEFAULT_AMOUNT_TO_COMPUTE_PRICE = 1000000n;
786
+ /** Slippage tolerances offered in the review step, in basis points. */
787
+ declare const SLIPPAGE_OPTIONS_BPS: Bps[];
788
+ /** Default slippage tolerance (0.5%). */
789
+ declare const DEFAULT_SLIPPAGE_BPS: Bps;
790
+ /**
791
+ * The Superstate swap contract on Ethereum Sepolia, and therefore the ERC-20
792
+ * spender the user approves there.
793
+ *
794
+ * Exported in its own right for a partner driving `coinlist.superstate.execute`
795
+ * at Level 1, where the contract is an explicit parameter.
796
+ */
797
+ declare const SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA: EvmContractAddress;
798
+ /** The Superstate swap contract on `chain`, or `null` where none is deployed. */
799
+ declare function superstateSwapContractAddress(chain: EthereumChain): EvmContractAddress | null;
624
800
 
625
- type PKCEParams = {
626
- clientId: ClientId;
627
- responseType: 'code';
628
- redirectUri: RedirectUri;
629
- codeChallenge: CodeChallenge;
630
- codeChallengeMethod: 'S256';
631
- state: PKCEState;
632
- codeVerifier: CodeVerifier;
633
- };
634
- type PKCEConfig = {
635
- clientId: ClientId;
636
- redirectUri: RedirectUri;
637
- };
638
801
  /**
639
- * Generates PKCE parameters for an OAuth2 authorization code flow.
640
- * Pure crypto — no React, no DOM beyond Web Crypto API. Safe to use
641
- * in server-side code and Next.js middleware.
802
+ * Formats a quote's implied price per output token as a USD amount.
803
+ *
804
+ * Lives with the provider rather than in `@/shared/core/blockchain/formatters`
805
+ * because {@link SwapQuote} and {@link computePrice} are Superstate's: the
806
+ * shared formatters stay provider-agnostic.
642
807
  */
643
- declare function generatePKCEParams(config: PKCEConfig): Promise<PKCEParams>;
808
+ declare function formattedPricePerShare(quote: SwapQuote | null, locale: string): FormattedAmountAssetUi;
644
809
 
645
810
  /**
646
811
  * Error thrown when a feature or code path is not yet implemented.
@@ -655,6 +820,34 @@ declare class NotImplementedError extends Error {
655
820
  declare class NotAuthenticatedError extends Error {
656
821
  constructor(message?: string);
657
822
  }
823
+ declare class ValidationError extends Error {
824
+ constructor(message: string);
825
+ }
826
+ /**
827
+ * Error thrown when the SDK computes something impossible: a value outside
828
+ * uint256 after its own arithmetic, a symbol missing from a registry the SDK
829
+ * itself ships. Distinct from {@link ValidationError}, which means the backend
830
+ * sent a shape the SDK does not understand.
831
+ *
832
+ * The two have different remedies, which is the whole reason they are separate
833
+ * types: a {@link ValidationError} is worth reporting to CoinList, an
834
+ * `InvariantError` is an SDK bug worth reporting against the SDK.
835
+ */
836
+ declare class InvariantError extends Error {
837
+ constructor(message: string);
838
+ }
839
+ /**
840
+ * Error thrown when an arithmetic operation has no answer to give: a division
841
+ * by zero, or a result that falls outside the range its type can represent.
842
+ *
843
+ * Distinct from {@link ValidationError}, which says a value arrived malformed.
844
+ * A `MathError` says every operand was well-formed and the operation on them
845
+ * still has no result, so the two are worth catching apart: one points at the
846
+ * response, the other at the arithmetic we asked for.
847
+ */
848
+ declare class MathError extends Error {
849
+ constructor(message: string);
850
+ }
658
851
 
659
852
  type UserDto = {
660
853
  id: string;
@@ -673,4 +866,4 @@ declare const User: {
673
866
  fromDto: (dto: UserDto) => User;
674
867
  };
675
868
 
676
- export { type AmountParseErrorReason, type AmountParseResult, AssetDecimals, AssetIconUrl, AssetSymbol, BPS_DENOM, BlockchainAmount, Bps, ClientId, CodeChallenge, CodeVerifier, DEFAULT_AMOUNT_TO_COMPUTE_PRICE, DEFAULT_SLIPPAGE_BPS, ERC20_ABI, Erc20Asset, EthereumChain, EvmContractAddress, EvmWalletAddress, type FormatAmountOptions, FormattedAmountAssetUi, FormattedAmountUi, FormattedPercentUi, KnownAssetSymbol, NA_AMOUNT_ASSET_UI, NotAuthenticatedError, NotImplementedError, type PKCEConfig, type PKCEParams, PKCEState, RedirectUri, SLIPPAGE_OPTIONS_BPS, SUPERSTATE_SWAP_ABI, SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA, SUPERSTATE_TOS_URL, SWAP_POLL_INTERVAL_MS, ShortenedWalletAddress, StablecoinSymbol, SwapQuote, SwapStatus, TOKEN_REGISTRY, TxExplorerUrl, USDC, USDC_SYMBOL, USDT, USDT_SYMBOL, Uint256, User, UserEmail, UserId, applyBps, assetAmount, computePrice, computeSlip, decodeSwappedOutputAmount, formatAmount, formatBpsAsPercent, formatCompactAmount, formatRawAmount, formattedPricePerShare, formattedUsdPrice, generatePKCEParams, getChainId, getNetworkName, isStopped, parseBlockchainAmount, shortenAddress, txExplorerUrl, usdAmount };
869
+ export { type AmountParseErrorReason, type AmountParseResult, AssetDecimals, AssetSymbol, BPS_DENOM, BlockchainAmount, Bps, DEFAULT_AMOUNT_TO_COMPUTE_PRICE, DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE, DEFAULT_ONDO_SELL_TOKENS_TO_COMPUTE_PRICE, DEFAULT_SLIPPAGE_BPS, DecimalString, ERC20_ABI, Erc20Asset, EthereumChain, EvmContractAddress, EvmWalletAddress, type FormatAmountOptions, FormattedAmountAssetUi, FormattedAmountUi, FormattedPercentUi, InvariantError, KnownAssetSymbol, MathError, NA_AMOUNT_ASSET_UI, NonEmptyArray, NotAuthenticatedError, NotImplementedError, ONDO_POLL_INTERVAL_MS, ONDO_QUOTE_EXPIRY_THRESHOLD_MS, ONDO_SETTLEMENT_ASSET, ONDO_SUPPORTED_INPUT_ASSETS, OndoBuyTransaction, OndoSellTransaction, PaginatedResponse, PaginationParams, SLIPPAGE_OPTIONS_BPS, SUPERSTATE_ISSUER_NAME, SUPERSTATE_SUPPORTED_INPUT_ASSETS, SUPERSTATE_SWAP_ABI, SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA, SWAP_POLL_INTERVAL_MS, ShortenedWalletAddress, StablecoinSymbol, SwapQuote, SwapStatus, TOKEN_REGISTRY, TxExplorerUrl, USDC, USDC_SYMBOL, USDT, USDT_SYMBOL, Uint256, User, UserEmail, UserId, ValidationError, applyBps, assetAmount, blockchainAmountFromRawOrThrow, chainFromId, computeOndoBuyPrice, computeOndoSellPrice, computePrice, computeSlip, decodeSwappedOutputAmount, fetchAllPages, formatAmount, formatBpsAsPercent, formatCompactAmount, formatRawAmount, formattedPricePerShare, formattedUsdPrice, getChainId, getNetworkName, isStopped, ondoSwapContractAddress, parseBlockchainAmount, shortenAddress, superstateSwapContractAddress, txExplorerUrl, usdAmount };