@coinlist-co/react 0.11.1-rc.e102bdb → 0.12.0
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-7CTH4KPU.js → chunk-6CQHDASY.js} +648 -620
- package/dist/chunk-6CQHDASY.js.map +1 -0
- package/dist/{chunk-UZUQALFY.js → chunk-F6WGUKZC.js} +9 -9
- package/dist/chunk-F6WGUKZC.js.map +1 -0
- package/dist/{chunk-LSPZETDH.js → chunk-ZFBEI3BW.js} +131 -134
- package/dist/chunk-ZFBEI3BW.js.map +1 -0
- package/dist/client/index.cjs +1489 -1346
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +395 -254
- package/dist/client/index.d.ts +395 -254
- package/dist/client/index.js +852 -739
- package/dist/client/index.js.map +1 -1
- package/dist/{collections-BBI_XydI.d.cts → collections-DOm9VKVm.d.cts} +1 -1
- package/dist/{collections-BrX9rRWc.d.ts → collections-aCv-Wr2a.d.ts} +1 -1
- package/dist/{config-CMl1bR3F.d.cts → config-DIaFzrMW.d.cts} +56 -13
- package/dist/{config-CMl1bR3F.d.ts → config-DIaFzrMW.d.ts} +56 -13
- package/dist/server/index.cjs +262 -236
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +4 -4
- package/dist/server/index.d.ts +4 -4
- package/dist/server/index.js +3 -3
- package/dist/server/index.js.map +1 -1
- package/dist/{shared → universal}/index.cjs +948 -919
- package/dist/universal/index.cjs.map +1 -0
- package/dist/{shared → universal}/index.d.cts +566 -536
- package/dist/{shared → universal}/index.d.ts +566 -536
- package/dist/{shared → universal}/index.js +9 -5
- package/package.json +23 -17
- package/dist/chunk-7CTH4KPU.js.map +0 -1
- package/dist/chunk-LSPZETDH.js.map +0 -1
- package/dist/chunk-UZUQALFY.js.map +0 -1
- package/dist/shared/index.cjs.map +0 -1
- /package/dist/{shared → universal}/index.js.map +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
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-
|
|
5
|
-
import {
|
|
1
|
+
import { aq as PaginationParams, ar as PaginatedResponse, as as DecimalString, x as StablecoinSymbol, j as OndoBuyTransaction, B as BlockchainAmount, k as OndoSellTransaction, p as Bps, at as SwapStatus, Z as AssetDecimals, b as EvmContractAddress, a as EthereumChain, i as OfferSwapContract, au as Uint256, h as AssetSymbol, q as EvmWalletAddress, av as KnownAssetSymbol, y as Erc20Asset, aw as Newtype } from '../config-DIaFzrMW.cjs';
|
|
2
|
+
export { ax as AllowWalletParams, ay as AllowWalletResponse, az as Asset, aA as AssetCode, e as AssetId, A as AuthorizationCode, aB as Blockchain, _ as BuildOndoBuyParams, $ as BuildOndoSellParams, aC as BuildOndoSwapParamsCore, aD as Chain, an as ClientCredentialsOAuth, aE as ClientId, ao as ClientSecret, aF as CodeChallenge, C as CodeVerifier, c as CoinListTokenSaleNamespace, f as CoinListTokenSaleNamespaceImpl, u as Config, aG as ConnectExternalWalletParams, aH as CreateKycTokenParams, aI as CreateParticipationParams, aJ as CreateWalletOwnershipChallengeParams, aK as Cursor, a5 as DebugEvent, aL as DocumentFormType, Q as DocumentSubmission, aM as DocumentSubmissionStatus, aN as DocumentType, aO as ETHEREUM_CHAINS, E as Erc20Namespace, aP as Erc20NamespaceImpl, aQ as FaqItem, a6 as FrontlineEventId, aR as GetOndoQuoteParams, aS as GetOndoTradingStatusParams, aT as GetSwapAuthorizationParams, aU as GetSwapPreviewParams, aV as GetTokenAllowanceParams, aW as GetTokenBalanceParams, aX as HexEncodedTransactionData, a7 as HttpError, a8 as HttpResponse, aY as Iso2CountryCode, N as KycLevelName, a9 as KycToken, aZ as Link, a_ as ListOptionAddressesParams, aa as LogBinding, ab as LogBindings, ac as LogCause, ad as LogLevel, ae as LogScope, af as LogValue, L as Logger, a$ as MAX_ASSET_DECIMALS, b0 as MAX_UINT_256, b1 as Milestone, v as OAuthAccessToken, b2 as OAuthRefreshToken, am as OAuthSession, G as Offer, z as OfferDetail, O as OfferId, b3 as OfferOption, K as OfferOptionAddress, a3 as OfferOptionAddressId, d as OfferOptionId, b4 as OfferOptionSlug, b5 as OfferSlug, b6 as OfferToken, F as OfferType, w as OffersNamespace, b7 as OffersNamespaceImpl, g as OndoNamespace, n as OndoNamespaceImpl, a0 as OndoQuote, b8 as OndoQuoteDuration, a1 as OndoQuoteSize, b9 as OndoSellOutcome, l as OndoSwapTransactionCore, Y as OndoTradingStatus, m as OrderBookSide, ba as PKCEState, bb as PaginatedResponseDto, P as Participation, bc as ParticipationId, bd as ParticipationStatus, be as ParticipationsPaginationParams, bf as Pii, bg as PiiAddress, bh as PiiJurisdiction, bi as PiiKind, X as PinoLoggerOptions, ag as ProductionLogLevel, bj as QueryParamValue, bk as QueryParamValues, ah as RedactedWalletError, bl as RedirectUri, bm as RemoveOptionAddressParams, ai as RequestId, s as Requirement, bn as RequirementActionNeededReason, M as RequirementId, H as RequirementStatusInfo, J as RequirementStatusValue, I as RequirementType, R as RequirementsNamespace, t as RequirementsNamespaceImpl, bo as SOLANA_CHAINS, bp as STABLE_DECIMALS, aj as SafeEvent, ak as SafeFields, bq as SolanaChain, br as SubmitDocumentParams, S as SuperstateSwapNamespace, r as SuperstateSwapNamespaceImpl, bs as SwapAuthorization, bt as SwapContractRef, bu as SwapPreview, bv as TermItem, bw as Ticker, bx as TokenAllowance, by as TokenBalance, a2 as TokenIdentifier, a4 as TokenLogo, bz as TokenLogoImage, bA as TokenLogoUrl, D as TokenMetadata, bB as TokenRole, T as TokensNamespace, bC as TokensNamespaceImpl, bD as Tx, al as UnredactedFields, bE as WalletAddress, V as WalletChallengeType, W as WalletError, bF as WalletOwnershipChallenge, bG as WalletProtocol, o as WalletsNamespace, bH as WalletsNamespaceImpl, bI as apiErrorCode, bJ as assertUint256, bK as isChain, bL as parseUint256 } from '../config-DIaFzrMW.cjs';
|
|
3
|
+
import { N as NonEmptyArray, S as SwapQuote, F as FormattedAmountAssetUi, T as TxExplorerUrl, d as FormattedAmountUi, b as FormattedPercentUi, a as ShortenedWalletAddress } from '../collections-DOm9VKVm.cjs';
|
|
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-DOm9VKVm.cjs';
|
|
5
|
+
import { TransactionReceipt, Hash } from 'viem';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Walks every page of a cursor-paginated endpoint and returns the flattened
|
|
@@ -15,797 +15,827 @@ import { Hash, TransactionReceipt } from 'viem';
|
|
|
15
15
|
*/
|
|
16
16
|
declare function fetchAllPages<A, P extends PaginationParams = PaginationParams>(fetchPage: (params: P) => Promise<PaginatedResponse<A>>, baseParams?: Omit<P, keyof PaginationParams>): Promise<A[]>;
|
|
17
17
|
|
|
18
|
-
/** Basis-point denominator: 10_000 bps = 100%. */
|
|
19
|
-
declare const BPS_DENOM: Bps;
|
|
20
18
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
19
|
+
* How often the Ondo checkout refreshes what it is allowed to poll: the market
|
|
20
|
+
* status and the indicative price. Both are free - neither spends an
|
|
21
|
+
* attestation - so this is paced for a price the user can trust rather than
|
|
22
|
+
* for cost.
|
|
23
|
+
*
|
|
24
|
+
* A built transaction is deliberately not on this timer. Building spends an
|
|
25
|
+
* attestation, so it happens once per order and once per refresh the user
|
|
26
|
+
* asks for.
|
|
24
27
|
*/
|
|
25
|
-
declare
|
|
26
|
-
|
|
27
|
-
declare function getChainId(chain: EthereumChain): number;
|
|
28
|
+
declare const ONDO_POLL_INTERVAL_MS = 15000;
|
|
28
29
|
/**
|
|
29
|
-
*
|
|
30
|
-
* of {@link getChainId}, for backends that report a bare `chain_id`.
|
|
30
|
+
* How close to its deadline a built transaction stops being offerable.
|
|
31
31
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
32
|
+
* Placing an order is not instant - the wallet has to prompt, the user has to
|
|
33
|
+
* confirm, and the transaction has to reach a node - so calldata with a second
|
|
34
|
+
* left is one the contract will reject. Treating the last few seconds as
|
|
35
|
+
* already expired turns a paid-for revert into a refresh button.
|
|
34
36
|
*/
|
|
35
|
-
declare
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
declare const ONDO_QUOTE_EXPIRY_THRESHOLD_MS = 5000;
|
|
38
|
+
/**
|
|
39
|
+
* The order size the sidebar prices against before the user names one.
|
|
40
|
+
*
|
|
41
|
+
* Ondo prices by size, so some amount has to be sent. $1,000 is a plausible
|
|
42
|
+
* order rather than a token one: a size so small that Ondo's minimum rejects
|
|
43
|
+
* it would leave the panel permanently blank.
|
|
44
|
+
*
|
|
45
|
+
* Named distinctly from `DEFAULT_AMOUNT_TO_COMPUTE_PRICE` in the swap
|
|
46
|
+
* constants, which is a raw `bigint` of USDC base units for a different
|
|
47
|
+
* endpoint. Both barrels are flat, so two constants of the same name could not
|
|
48
|
+
* coexist - and they mean different things anyway.
|
|
49
|
+
*/
|
|
50
|
+
declare const DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE: DecimalString;
|
|
51
|
+
/**
|
|
52
|
+
* The coin an Ondo sell settles into, for display only.
|
|
53
|
+
*
|
|
54
|
+
* The scale of every amount on a built transaction comes off the response, so
|
|
55
|
+
* this names the token and never sizes it - `receive_output_decimals` is the
|
|
56
|
+
* only authority on how many decimals the proceeds are counted in, and the two
|
|
57
|
+
* are allowed to disagree.
|
|
58
|
+
*
|
|
59
|
+
* Named apart from {@link ONDO_SUPPORTED_INPUT_ASSETS} rather than read out of
|
|
60
|
+
* it, though both are USDC today. On a buy USDC is what the user funds with
|
|
61
|
+
* and one of a list that may grow; on a sell it is what they settle into and
|
|
62
|
+
* there is one of it. Reading `ONDO_SUPPORTED_INPUT_ASSETS[0]` here would make
|
|
63
|
+
* the sell screen quietly follow whichever funding coin happened to be listed
|
|
64
|
+
* first.
|
|
65
|
+
*/
|
|
66
|
+
declare const ONDO_SETTLEMENT_ASSET: StablecoinSymbol;
|
|
67
|
+
/**
|
|
68
|
+
* The order size the sidebar prices a sell against before the user names one.
|
|
69
|
+
*
|
|
70
|
+
* Sells are quoted by token amount rather than by notional: the fee comes out
|
|
71
|
+
* of dollars, and Ondo's price is size-aware, so a buy's quantity depends on
|
|
72
|
+
* the quote being asked for while a sell is sized by what the user already
|
|
73
|
+
* holds. One whole share is a size Ondo will price - small enough to be
|
|
74
|
+
* plausible for any asset, large enough that Ondo's minimum does not reject it
|
|
75
|
+
* and leave the panel permanently blank.
|
|
76
|
+
*
|
|
77
|
+
* The buy counterpart is {@link DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE}, which
|
|
78
|
+
* is a dollar figure for the same reason in reverse.
|
|
79
|
+
*/
|
|
80
|
+
declare const DEFAULT_ONDO_SELL_TOKENS_TO_COMPUTE_PRICE = 1;
|
|
81
|
+
/**
|
|
82
|
+
* The coins an Ondo buy can be funded with, in display order, with the first
|
|
83
|
+
* preselected.
|
|
84
|
+
*
|
|
85
|
+
* USDC alone today: it is what the Sepolia integration contract accepts. The
|
|
86
|
+
* amount step renders a single entry as a plain card and two or more as a
|
|
87
|
+
* picker, so adding one here is all it takes.
|
|
88
|
+
*/
|
|
89
|
+
declare const ONDO_SUPPORTED_INPUT_ASSETS: NonEmptyArray<StablecoinSymbol>;
|
|
38
90
|
|
|
39
91
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
92
|
+
* The price of one whole asset token in a built Ondo purchase, in the funding
|
|
93
|
+
* token's units - USD per share.
|
|
94
|
+
*
|
|
95
|
+
* Neither builder publishes a price. Frontline drops Ninshubur's deliberately,
|
|
96
|
+
* because `GET /v1/ondo/swap/quote` already serves one under that name at a
|
|
97
|
+
* different scale, and echoing both would leave a caller to guess which was
|
|
98
|
+
* which.
|
|
99
|
+
*
|
|
100
|
+
* Dividing the two amounts the response *does* carry is better than reading
|
|
101
|
+
* the indicative one anyway: it is the price this transaction fills at, rather
|
|
102
|
+
* than a poll that has since moved and was struck against a different size.
|
|
103
|
+
*
|
|
104
|
+
* **Fee-exclusive.** `notionalValue` is the deposit after CoinList's fee comes
|
|
105
|
+
* off, so this is the price Ondo filled at, not the buyer's all-in cost per
|
|
106
|
+
* token - that would be `spendInputAmount / receiveOutputAmount`, and it is
|
|
107
|
+
* higher. Fee-exclusive is what the review screen wants, because it renders
|
|
108
|
+
* the fee on its own line: price x quantity, plus fee, comes to the total.
|
|
109
|
+
* Making this all-in would double-count the fee against that breakdown.
|
|
110
|
+
*
|
|
111
|
+
* The two are equal until ENG-1718 turns a fee on, which frontline rejects
|
|
112
|
+
* today. They diverge the moment it does, so the choice is load-bearing rather
|
|
113
|
+
* than academic.
|
|
43
114
|
*/
|
|
44
|
-
declare
|
|
115
|
+
declare function computeOndoBuyPrice(transaction: OndoBuyTransaction): BlockchainAmount;
|
|
116
|
+
/**
|
|
117
|
+
* The price of one whole asset token in a built Ondo sale, in the settlement
|
|
118
|
+
* token's units - USD per share, the same thing
|
|
119
|
+
* {@link computeOndoBuyPrice} answers with the ratio inverted.
|
|
120
|
+
*
|
|
121
|
+
* **Fee-exclusive, and it takes arithmetic to be so.** `expected.quantity` is
|
|
122
|
+
* published already net of `expected.fee`, so the proceeds are added back
|
|
123
|
+
* before dividing: what comes out is the price Ondo filled at, which is the
|
|
124
|
+
* buy arm's meaning rather than a second one. That is what lets one review row
|
|
125
|
+
* render on either screen, and what keeps the sell breakdown honest - the fee
|
|
126
|
+
* sits on its own line beside this, and a net price would count it twice.
|
|
127
|
+
*
|
|
128
|
+
* Read against {@link OndoSellTransaction.expected} alone. The `minimum` arm
|
|
129
|
+
* describes the same trade at a different outcome, and pricing that one would
|
|
130
|
+
* answer "the worst price this could fill at", which no screen asks for.
|
|
131
|
+
*
|
|
132
|
+
* The two readings coincide while frontline forces the fee to zero, which it
|
|
133
|
+
* does today. They diverge the day ENG-1718 lands.
|
|
134
|
+
*/
|
|
135
|
+
declare function computeOndoSellPrice(transaction: OndoSellTransaction): BlockchainAmount;
|
|
136
|
+
|
|
137
|
+
declare const SUPERSTATE_SWAP_ABI: readonly [{
|
|
45
138
|
readonly type: "function";
|
|
46
|
-
readonly name: "
|
|
139
|
+
readonly name: "authorized";
|
|
47
140
|
readonly inputs: readonly [{
|
|
48
|
-
readonly name: "
|
|
49
|
-
readonly type: "address";
|
|
50
|
-
}, {
|
|
51
|
-
readonly name: "spender";
|
|
141
|
+
readonly name: "user";
|
|
52
142
|
readonly type: "address";
|
|
143
|
+
readonly internalType: "address";
|
|
144
|
+
}];
|
|
145
|
+
readonly outputs: readonly [{
|
|
146
|
+
readonly name: "";
|
|
147
|
+
readonly type: "bool";
|
|
148
|
+
readonly internalType: "bool";
|
|
53
149
|
}];
|
|
150
|
+
readonly stateMutability: "view";
|
|
151
|
+
}, {
|
|
152
|
+
readonly type: "function";
|
|
153
|
+
readonly name: "stopped";
|
|
154
|
+
readonly inputs: readonly [];
|
|
54
155
|
readonly outputs: readonly [{
|
|
55
156
|
readonly name: "";
|
|
56
157
|
readonly type: "uint256";
|
|
158
|
+
readonly internalType: "uint256";
|
|
57
159
|
}];
|
|
58
160
|
readonly stateMutability: "view";
|
|
59
161
|
}, {
|
|
60
162
|
readonly type: "function";
|
|
61
|
-
readonly name: "
|
|
163
|
+
readonly name: "SWAP_LEVEL";
|
|
164
|
+
readonly inputs: readonly [];
|
|
165
|
+
readonly outputs: readonly [{
|
|
166
|
+
readonly name: "";
|
|
167
|
+
readonly type: "uint256";
|
|
168
|
+
readonly internalType: "uint256";
|
|
169
|
+
}];
|
|
170
|
+
readonly stateMutability: "view";
|
|
171
|
+
}, {
|
|
172
|
+
readonly type: "function";
|
|
173
|
+
readonly name: "preview";
|
|
62
174
|
readonly inputs: readonly [{
|
|
63
|
-
readonly name: "
|
|
175
|
+
readonly name: "token";
|
|
64
176
|
readonly type: "address";
|
|
177
|
+
readonly internalType: "address";
|
|
65
178
|
}, {
|
|
66
179
|
readonly name: "amount";
|
|
67
180
|
readonly type: "uint256";
|
|
181
|
+
readonly internalType: "uint256";
|
|
68
182
|
}];
|
|
69
183
|
readonly outputs: readonly [{
|
|
70
184
|
readonly name: "";
|
|
71
|
-
readonly type: "
|
|
185
|
+
readonly type: "tuple";
|
|
186
|
+
readonly internalType: "struct Preview";
|
|
187
|
+
readonly components: readonly [{
|
|
188
|
+
readonly name: "input";
|
|
189
|
+
readonly type: "uint256";
|
|
190
|
+
readonly internalType: "uint256";
|
|
191
|
+
}, {
|
|
192
|
+
readonly name: "fee";
|
|
193
|
+
readonly type: "uint256";
|
|
194
|
+
readonly internalType: "uint256";
|
|
195
|
+
}, {
|
|
196
|
+
readonly name: "output";
|
|
197
|
+
readonly type: "uint256";
|
|
198
|
+
readonly internalType: "uint256";
|
|
199
|
+
}];
|
|
72
200
|
}];
|
|
73
|
-
readonly stateMutability: "
|
|
201
|
+
readonly stateMutability: "view";
|
|
74
202
|
}, {
|
|
75
203
|
readonly type: "function";
|
|
76
|
-
readonly name: "
|
|
204
|
+
readonly name: "swap";
|
|
77
205
|
readonly inputs: readonly [{
|
|
78
|
-
readonly name: "
|
|
206
|
+
readonly name: "token";
|
|
79
207
|
readonly type: "address";
|
|
208
|
+
readonly internalType: "address";
|
|
209
|
+
}, {
|
|
210
|
+
readonly name: "amount";
|
|
211
|
+
readonly type: "uint256";
|
|
212
|
+
readonly internalType: "uint256";
|
|
213
|
+
}, {
|
|
214
|
+
readonly name: "slip";
|
|
215
|
+
readonly type: "uint256";
|
|
216
|
+
readonly internalType: "uint256";
|
|
80
217
|
}];
|
|
81
218
|
readonly outputs: readonly [{
|
|
82
219
|
readonly name: "";
|
|
83
220
|
readonly type: "uint256";
|
|
221
|
+
readonly internalType: "uint256";
|
|
84
222
|
}];
|
|
85
|
-
readonly stateMutability: "
|
|
223
|
+
readonly stateMutability: "nonpayable";
|
|
86
224
|
}, {
|
|
87
225
|
readonly type: "function";
|
|
88
|
-
readonly name: "
|
|
89
|
-
readonly inputs: readonly [
|
|
90
|
-
|
|
91
|
-
readonly
|
|
92
|
-
readonly
|
|
226
|
+
readonly name: "tokenBalance";
|
|
227
|
+
readonly inputs: readonly [{
|
|
228
|
+
readonly name: "token";
|
|
229
|
+
readonly type: "address";
|
|
230
|
+
readonly internalType: "address";
|
|
93
231
|
}];
|
|
94
|
-
readonly stateMutability: "view";
|
|
95
|
-
}, {
|
|
96
|
-
readonly type: "function";
|
|
97
|
-
readonly name: "name";
|
|
98
|
-
readonly inputs: readonly [];
|
|
99
232
|
readonly outputs: readonly [{
|
|
100
233
|
readonly name: "";
|
|
101
|
-
readonly type: "
|
|
234
|
+
readonly type: "uint256";
|
|
235
|
+
readonly internalType: "uint256";
|
|
102
236
|
}];
|
|
103
237
|
readonly stateMutability: "view";
|
|
104
238
|
}, {
|
|
105
239
|
readonly type: "function";
|
|
106
|
-
readonly name: "
|
|
240
|
+
readonly name: "outputToken";
|
|
107
241
|
readonly inputs: readonly [];
|
|
108
242
|
readonly outputs: readonly [{
|
|
109
243
|
readonly name: "";
|
|
110
|
-
readonly type: "
|
|
244
|
+
readonly type: "address";
|
|
245
|
+
readonly internalType: "address";
|
|
111
246
|
}];
|
|
112
247
|
readonly stateMutability: "view";
|
|
113
248
|
}, {
|
|
114
249
|
readonly type: "function";
|
|
115
|
-
readonly name: "
|
|
250
|
+
readonly name: "outputTokenBalance";
|
|
116
251
|
readonly inputs: readonly [];
|
|
117
252
|
readonly outputs: readonly [{
|
|
118
253
|
readonly name: "";
|
|
119
254
|
readonly type: "uint256";
|
|
255
|
+
readonly internalType: "uint256";
|
|
120
256
|
}];
|
|
121
257
|
readonly stateMutability: "view";
|
|
122
258
|
}, {
|
|
123
259
|
readonly type: "function";
|
|
124
|
-
readonly name: "
|
|
260
|
+
readonly name: "totals";
|
|
125
261
|
readonly inputs: readonly [{
|
|
126
|
-
readonly name: "
|
|
262
|
+
readonly name: "token";
|
|
127
263
|
readonly type: "address";
|
|
128
|
-
|
|
129
|
-
readonly name: "amount";
|
|
130
|
-
readonly type: "uint256";
|
|
264
|
+
readonly internalType: "address";
|
|
131
265
|
}];
|
|
132
266
|
readonly outputs: readonly [{
|
|
133
267
|
readonly name: "";
|
|
134
|
-
readonly type: "
|
|
268
|
+
readonly type: "tuple";
|
|
269
|
+
readonly internalType: "struct SwapTotal";
|
|
270
|
+
readonly components: readonly [{
|
|
271
|
+
readonly name: "inputSum";
|
|
272
|
+
readonly type: "uint256";
|
|
273
|
+
readonly internalType: "uint256";
|
|
274
|
+
}, {
|
|
275
|
+
readonly name: "feeSum";
|
|
276
|
+
readonly type: "uint256";
|
|
277
|
+
readonly internalType: "uint256";
|
|
278
|
+
}, {
|
|
279
|
+
readonly name: "outputSum";
|
|
280
|
+
readonly type: "uint256";
|
|
281
|
+
readonly internalType: "uint256";
|
|
282
|
+
}, {
|
|
283
|
+
readonly name: "count";
|
|
284
|
+
readonly type: "uint256";
|
|
285
|
+
readonly internalType: "uint256";
|
|
286
|
+
}];
|
|
135
287
|
}];
|
|
136
|
-
readonly stateMutability: "
|
|
288
|
+
readonly stateMutability: "view";
|
|
137
289
|
}, {
|
|
138
290
|
readonly type: "function";
|
|
139
|
-
readonly name: "
|
|
291
|
+
readonly name: "totals";
|
|
140
292
|
readonly inputs: readonly [{
|
|
141
|
-
readonly name: "
|
|
293
|
+
readonly name: "user";
|
|
142
294
|
readonly type: "address";
|
|
295
|
+
readonly internalType: "address";
|
|
143
296
|
}, {
|
|
144
|
-
readonly name: "
|
|
297
|
+
readonly name: "token";
|
|
298
|
+
readonly type: "address";
|
|
299
|
+
readonly internalType: "address";
|
|
300
|
+
}];
|
|
301
|
+
readonly outputs: readonly [{
|
|
302
|
+
readonly name: "";
|
|
303
|
+
readonly type: "tuple";
|
|
304
|
+
readonly internalType: "struct SwapTotal";
|
|
305
|
+
readonly components: readonly [{
|
|
306
|
+
readonly name: "inputSum";
|
|
307
|
+
readonly type: "uint256";
|
|
308
|
+
readonly internalType: "uint256";
|
|
309
|
+
}, {
|
|
310
|
+
readonly name: "feeSum";
|
|
311
|
+
readonly type: "uint256";
|
|
312
|
+
readonly internalType: "uint256";
|
|
313
|
+
}, {
|
|
314
|
+
readonly name: "outputSum";
|
|
315
|
+
readonly type: "uint256";
|
|
316
|
+
readonly internalType: "uint256";
|
|
317
|
+
}, {
|
|
318
|
+
readonly name: "count";
|
|
319
|
+
readonly type: "uint256";
|
|
320
|
+
readonly internalType: "uint256";
|
|
321
|
+
}];
|
|
322
|
+
}];
|
|
323
|
+
readonly stateMutability: "view";
|
|
324
|
+
}, {
|
|
325
|
+
readonly type: "function";
|
|
326
|
+
readonly name: "transfer";
|
|
327
|
+
readonly inputs: readonly [{
|
|
328
|
+
readonly name: "to";
|
|
145
329
|
readonly type: "address";
|
|
330
|
+
readonly internalType: "address";
|
|
146
331
|
}, {
|
|
147
332
|
readonly name: "amount";
|
|
148
333
|
readonly type: "uint256";
|
|
334
|
+
readonly internalType: "uint256";
|
|
149
335
|
}];
|
|
150
336
|
readonly outputs: readonly [{
|
|
151
337
|
readonly name: "";
|
|
152
338
|
readonly type: "bool";
|
|
339
|
+
readonly internalType: "bool";
|
|
340
|
+
}];
|
|
341
|
+
readonly stateMutability: "nonpayable";
|
|
342
|
+
}, {
|
|
343
|
+
readonly type: "function";
|
|
344
|
+
readonly name: "transfer";
|
|
345
|
+
readonly inputs: readonly [{
|
|
346
|
+
readonly name: "to";
|
|
347
|
+
readonly type: "address";
|
|
348
|
+
readonly internalType: "address";
|
|
349
|
+
}, {
|
|
350
|
+
readonly name: "token";
|
|
351
|
+
readonly type: "address";
|
|
352
|
+
readonly internalType: "address";
|
|
353
|
+
}, {
|
|
354
|
+
readonly name: "amount";
|
|
355
|
+
readonly type: "uint256";
|
|
356
|
+
readonly internalType: "uint256";
|
|
357
|
+
}];
|
|
358
|
+
readonly outputs: readonly [{
|
|
359
|
+
readonly name: "";
|
|
360
|
+
readonly type: "bool";
|
|
361
|
+
readonly internalType: "bool";
|
|
362
|
+
}];
|
|
363
|
+
readonly stateMutability: "nonpayable";
|
|
364
|
+
}, {
|
|
365
|
+
readonly type: "function";
|
|
366
|
+
readonly name: "setBps";
|
|
367
|
+
readonly inputs: readonly [{
|
|
368
|
+
readonly name: "points";
|
|
369
|
+
readonly type: "uint256";
|
|
370
|
+
readonly internalType: "uint256";
|
|
371
|
+
}];
|
|
372
|
+
readonly outputs: readonly [{
|
|
373
|
+
readonly name: "";
|
|
374
|
+
readonly type: "bool";
|
|
375
|
+
readonly internalType: "bool";
|
|
153
376
|
}];
|
|
154
377
|
readonly stateMutability: "nonpayable";
|
|
155
378
|
}, {
|
|
156
379
|
readonly type: "event";
|
|
157
|
-
readonly name: "
|
|
380
|
+
readonly name: "Swapped";
|
|
158
381
|
readonly inputs: readonly [{
|
|
159
|
-
readonly name: "
|
|
382
|
+
readonly name: "user";
|
|
160
383
|
readonly type: "address";
|
|
161
384
|
readonly indexed: true;
|
|
385
|
+
readonly internalType: "address";
|
|
162
386
|
}, {
|
|
163
|
-
readonly name: "
|
|
387
|
+
readonly name: "inputToken";
|
|
164
388
|
readonly type: "address";
|
|
165
389
|
readonly indexed: true;
|
|
390
|
+
readonly internalType: "address";
|
|
166
391
|
}, {
|
|
167
|
-
readonly name: "
|
|
392
|
+
readonly name: "outputToken";
|
|
393
|
+
readonly type: "address";
|
|
394
|
+
readonly indexed: true;
|
|
395
|
+
readonly internalType: "address";
|
|
396
|
+
}, {
|
|
397
|
+
readonly name: "inputAmount";
|
|
168
398
|
readonly type: "uint256";
|
|
169
399
|
readonly indexed: false;
|
|
400
|
+
readonly internalType: "uint256";
|
|
401
|
+
}, {
|
|
402
|
+
readonly name: "outputAmount";
|
|
403
|
+
readonly type: "uint256";
|
|
404
|
+
readonly indexed: false;
|
|
405
|
+
readonly internalType: "uint256";
|
|
170
406
|
}];
|
|
171
407
|
readonly anonymous: false;
|
|
172
408
|
}, {
|
|
173
409
|
readonly type: "event";
|
|
174
|
-
readonly name: "
|
|
410
|
+
readonly name: "Transferred";
|
|
175
411
|
readonly inputs: readonly [{
|
|
176
|
-
readonly name: "
|
|
412
|
+
readonly name: "to";
|
|
177
413
|
readonly type: "address";
|
|
178
414
|
readonly indexed: true;
|
|
415
|
+
readonly internalType: "address";
|
|
179
416
|
}, {
|
|
180
|
-
readonly name: "
|
|
417
|
+
readonly name: "token";
|
|
181
418
|
readonly type: "address";
|
|
182
419
|
readonly indexed: true;
|
|
420
|
+
readonly internalType: "address";
|
|
183
421
|
}, {
|
|
184
|
-
readonly name: "
|
|
422
|
+
readonly name: "amount";
|
|
185
423
|
readonly type: "uint256";
|
|
186
424
|
readonly indexed: false;
|
|
425
|
+
readonly internalType: "uint256";
|
|
187
426
|
}];
|
|
188
427
|
readonly anonymous: false;
|
|
428
|
+
}, {
|
|
429
|
+
readonly type: "error";
|
|
430
|
+
readonly name: "InvalidAddress";
|
|
431
|
+
readonly inputs: readonly [];
|
|
432
|
+
}, {
|
|
433
|
+
readonly type: "error";
|
|
434
|
+
readonly name: "InsufficientAmount";
|
|
435
|
+
readonly inputs: readonly [];
|
|
436
|
+
}, {
|
|
437
|
+
readonly type: "error";
|
|
438
|
+
readonly name: "InvalidAmount";
|
|
439
|
+
readonly inputs: readonly [];
|
|
440
|
+
}, {
|
|
441
|
+
readonly type: "error";
|
|
442
|
+
readonly name: "SwapFailed";
|
|
443
|
+
readonly inputs: readonly [{
|
|
444
|
+
readonly name: "user";
|
|
445
|
+
readonly type: "address";
|
|
446
|
+
readonly internalType: "address";
|
|
447
|
+
}, {
|
|
448
|
+
readonly name: "token";
|
|
449
|
+
readonly type: "address";
|
|
450
|
+
readonly internalType: "address";
|
|
451
|
+
}];
|
|
189
452
|
}];
|
|
190
453
|
|
|
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
454
|
/**
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
455
|
+
* Price of 1 output token in USD, assuming the input token is a $1 stablecoin.
|
|
456
|
+
*
|
|
457
|
+
* `raw_price = inputTokenAmount.raw × 10^outputDecimals ÷ outputTokenAmount.raw`
|
|
458
|
+
*
|
|
459
|
+
* The multiplication happens before the division so we never lose precision to
|
|
460
|
+
* integer truncation early. This mirrors standard fixed-point practice on-chain.
|
|
461
|
+
* Returned decimals match the input token decimals (always the stablecoin's 6).
|
|
202
462
|
*/
|
|
203
|
-
declare function
|
|
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;
|
|
463
|
+
declare function computePrice({ inputTokenAmount, outputTokenAmount, }: SwapQuote): BlockchainAmount | null;
|
|
209
464
|
/**
|
|
210
|
-
*
|
|
211
|
-
*
|
|
465
|
+
* Applies slippage to an amount, returning the minimum acceptable amount:
|
|
466
|
+
* `amount × (BPS_DENOM − slippage) / BPS_DENOM`. Throws when `slippage` exceeds
|
|
467
|
+
* `BPS_DENOM` (the retained fraction would be negative).
|
|
212
468
|
*/
|
|
213
|
-
declare function
|
|
469
|
+
declare function computeSlip(amount: BlockchainAmount, slippage: Bps): BlockchainAmount;
|
|
214
470
|
|
|
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
471
|
/**
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
* {@link BlockchainAmount} at the given decimals. The value is already scaled,
|
|
241
|
-
* so `decimals` is only the unit tag that travels with it.
|
|
472
|
+
* Interprets the on-chain swap availability read from `stopped()` and
|
|
473
|
+
* `SWAP_LEVEL()`.
|
|
242
474
|
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
* multiplies it by 10^decimals — pick by what the backend sends, not by which
|
|
246
|
-
* one is closer at hand.
|
|
475
|
+
* The contract tracks paused operations as a bitmask in `stopped`. The swap is
|
|
476
|
+
* stopped when the SWAP_LEVEL flag is set:
|
|
247
477
|
*
|
|
248
|
-
*
|
|
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.
|
|
478
|
+
* (stopped & SWAP_LEVEL) != 0 -> stopped (not active)
|
|
263
479
|
*/
|
|
264
|
-
declare function
|
|
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
|
-
};
|
|
480
|
+
declare function isStopped(status: SwapStatus): boolean;
|
|
285
481
|
|
|
286
|
-
/** The Ondo integration contract on `chain`, or `null` where none is deployed. */
|
|
287
|
-
declare function ondoSwapContractAddress(chain: EthereumChain): EvmContractAddress | null;
|
|
288
482
|
/**
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
* attestation - so this is paced for a price the user can trust rather than
|
|
292
|
-
* for cost.
|
|
483
|
+
* Decodes the confirmed output amount from the `Swapped` event in a swap
|
|
484
|
+
* transaction receipt.
|
|
293
485
|
*
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
*
|
|
486
|
+
* Returns `null` when the event is absent or the amount is not a valid uint256
|
|
487
|
+
* so callers can fall back to the quote's expected output — the swap already
|
|
488
|
+
* confirmed on-chain, so a missing/undecodable event should not fail the flow.
|
|
297
489
|
*/
|
|
298
|
-
declare
|
|
490
|
+
declare function decodeSwappedOutputAmount(receipt: TransactionReceipt, outputDecimals: AssetDecimals): BlockchainAmount | null;
|
|
491
|
+
|
|
299
492
|
/**
|
|
300
|
-
*
|
|
493
|
+
* Who issues the asset a Superstate swap pays out.
|
|
301
494
|
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
* already expired turns a paid-for revert into a refresh button.
|
|
495
|
+
* A constant rather than a field off the offer: no frontline endpoint carries
|
|
496
|
+
* an issuer, and every offer this checkout serves is Superstate's by
|
|
497
|
+
* definition — `CheckoutContainer` routes here on `superstate::swap` alone.
|
|
306
498
|
*/
|
|
307
|
-
declare const
|
|
499
|
+
declare const SUPERSTATE_ISSUER_NAME = "Superstate";
|
|
308
500
|
/**
|
|
309
|
-
* The
|
|
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.
|
|
501
|
+
* The coins a Superstate swap can be funded with, in display order, with the
|
|
502
|
+
* first preselected.
|
|
314
503
|
*
|
|
315
|
-
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
* coexist - and they mean different things anyway.
|
|
504
|
+
* USDC alone today: it is what the deployed swap contract accepts. The amount
|
|
505
|
+
* step renders a single entry as a plain card and two or more as a picker, so
|
|
506
|
+
* adding one here is all it takes.
|
|
319
507
|
*/
|
|
320
|
-
declare const
|
|
321
|
-
/**
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
*
|
|
325
|
-
*
|
|
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.
|
|
508
|
+
declare const SUPERSTATE_SUPPORTED_INPUT_ASSETS: NonEmptyArray<StablecoinSymbol>;
|
|
509
|
+
/** Poll interval for refreshing on-chain swap quotes and balances. */
|
|
510
|
+
declare const SWAP_POLL_INTERVAL_MS = 15000;
|
|
511
|
+
/**
|
|
512
|
+
* Notional input used to derive a display price-per-share when the user has
|
|
513
|
+
* not yet entered an amount (1 USDC at 6 decimals).
|
|
335
514
|
*/
|
|
336
|
-
declare const
|
|
515
|
+
declare const DEFAULT_AMOUNT_TO_COMPUTE_PRICE = 1000000n;
|
|
516
|
+
/** Slippage tolerances offered in the review step, in basis points. */
|
|
517
|
+
declare const SLIPPAGE_OPTIONS_BPS: Bps[];
|
|
518
|
+
/** Default slippage tolerance (0.5%). */
|
|
519
|
+
declare const DEFAULT_SLIPPAGE_BPS: Bps;
|
|
337
520
|
/**
|
|
338
|
-
* The
|
|
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.
|
|
521
|
+
* The Superstate swap contract on Ethereum Sepolia, and therefore the ERC-20
|
|
522
|
+
* spender the user approves there.
|
|
346
523
|
*
|
|
347
|
-
*
|
|
348
|
-
*
|
|
524
|
+
* Exported in its own right for a partner driving `coinlist.superstate.execute`
|
|
525
|
+
* at Level 1, where the contract is an explicit parameter.
|
|
349
526
|
*/
|
|
350
|
-
declare const
|
|
527
|
+
declare const SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA: EvmContractAddress;
|
|
351
528
|
/**
|
|
352
|
-
* The
|
|
353
|
-
* preselected.
|
|
529
|
+
* The Superstate swap contract on `chain`, or `null` where none is deployed.
|
|
354
530
|
*
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
531
|
+
* TODO(ENG-1734): Ondo now reads its spender off the offer's `swap_contracts`
|
|
532
|
+
* via `swapSpender`, which is why that helper sits in `shared/core/offers/`
|
|
533
|
+
* rather than under a provider. Superstate still resolves from this table, so
|
|
534
|
+
* two mechanisms answer one question. Migrate once frontline serves
|
|
535
|
+
* `swap_contracts` on Superstate offers too.
|
|
358
536
|
*/
|
|
359
|
-
declare
|
|
537
|
+
declare function superstateSwapContractAddress(chain: EthereumChain): EvmContractAddress | null;
|
|
360
538
|
|
|
361
539
|
/**
|
|
362
|
-
*
|
|
363
|
-
* token's units - USD per share.
|
|
540
|
+
* Formats a quote's implied price per output token as a USD amount.
|
|
364
541
|
*
|
|
365
|
-
*
|
|
366
|
-
* because
|
|
367
|
-
*
|
|
368
|
-
|
|
542
|
+
* Lives with the provider rather than in `@/universal/core/shared/blockchain/formatters`
|
|
543
|
+
* because {@link SwapQuote} and {@link computePrice} are Superstate's: the
|
|
544
|
+
* shared formatters stay provider-agnostic.
|
|
545
|
+
*/
|
|
546
|
+
declare function formattedPricePerShare(quote: SwapQuote | null, locale: string): FormattedAmountAssetUi;
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* The CoinList contract a swap on `chain` settles through, and therefore the
|
|
550
|
+
* ERC-20 spender the user approves - or `null` where this offer cannot be
|
|
551
|
+
* swapped on that chain.
|
|
369
552
|
*
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
*
|
|
553
|
+
* Read off the offer rather than held as a constant because the address varies
|
|
554
|
+
* by environment, not only by chain: beta and production both run
|
|
555
|
+
* `ethereum_sepolia` and deploy a different contract on each, and one constant
|
|
556
|
+
* cannot name both. Frontline resolves it per environment and serves the
|
|
557
|
+
* answer on the offer.
|
|
373
558
|
*
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
*
|
|
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.
|
|
559
|
+
* The array varies per *offer* as well as per chain - frontline drops a chain
|
|
560
|
+
* whose funding and swap tokens do not both resolve for this asset - so an
|
|
561
|
+
* array read for one symbol must not be reused for another. An empty array
|
|
562
|
+
* means "cannot swap here", which is an answer rather than an error.
|
|
380
563
|
*
|
|
381
|
-
*
|
|
382
|
-
*
|
|
383
|
-
*
|
|
564
|
+
* A capability rather than a provider slice, and named for the data it reads
|
|
565
|
+
* rather than for its first caller: `swap_contracts` is an offer field, and
|
|
566
|
+
* `universal-core-isolation-and-sharing` would stop Superstate reusing this if
|
|
567
|
+
* it lived under `checkout/ondo/`. Superstate has not migrated yet - it still
|
|
568
|
+
* reads `superstateSwapContractAddress` - so Ondo is the only caller today.
|
|
384
569
|
*/
|
|
385
|
-
declare function
|
|
570
|
+
declare function swapSpender(swapContracts: OfferSwapContract[], chain: EthereumChain): EvmContractAddress | null;
|
|
571
|
+
|
|
572
|
+
/** Basis-point denominator: 10_000 bps = 100%. */
|
|
573
|
+
declare const BPS_DENOM: Bps;
|
|
386
574
|
/**
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
*
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
*
|
|
396
|
-
*
|
|
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.
|
|
575
|
+
* Applies a basis-point fraction to an amount, flooring the result.
|
|
576
|
+
* `floor((amount × bps) / BPS_DENOM)`. The result is bounds-checked, so an
|
|
577
|
+
* overflow (bps far above BPS_DENOM) or a negative product is rejected.
|
|
578
|
+
*/
|
|
579
|
+
declare function applyBps(amount: Uint256, bps: Bps): Uint256;
|
|
580
|
+
|
|
581
|
+
declare function getChainId(chain: EthereumChain): number;
|
|
582
|
+
/**
|
|
583
|
+
* Resolves an EIP-155 chain id to the chain the SDK names it by — the inverse
|
|
584
|
+
* of {@link getChainId}, for backends that report a bare `chain_id`.
|
|
401
585
|
*
|
|
402
|
-
*
|
|
403
|
-
*
|
|
586
|
+
* @throws ValidationError on an unrecognised id. Defaulting to mainnet would
|
|
587
|
+
* let a testnet response read as a live one.
|
|
404
588
|
*/
|
|
405
|
-
declare function
|
|
589
|
+
declare function chainFromId(chainId: string): EthereumChain;
|
|
590
|
+
declare function getNetworkName(chain: EthereumChain): string;
|
|
591
|
+
declare function txExplorerUrl(chain: EthereumChain, txHash: Hash): TxExplorerUrl;
|
|
406
592
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
readonly internalType: "address";
|
|
414
|
-
}];
|
|
415
|
-
readonly outputs: readonly [{
|
|
416
|
-
readonly name: "";
|
|
417
|
-
readonly type: "bool";
|
|
418
|
-
readonly internalType: "bool";
|
|
419
|
-
}];
|
|
420
|
-
readonly stateMutability: "view";
|
|
421
|
-
}, {
|
|
422
|
-
readonly type: "function";
|
|
423
|
-
readonly name: "stopped";
|
|
424
|
-
readonly inputs: readonly [];
|
|
425
|
-
readonly outputs: readonly [{
|
|
426
|
-
readonly name: "";
|
|
427
|
-
readonly type: "uint256";
|
|
428
|
-
readonly internalType: "uint256";
|
|
429
|
-
}];
|
|
430
|
-
readonly stateMutability: "view";
|
|
431
|
-
}, {
|
|
432
|
-
readonly type: "function";
|
|
433
|
-
readonly name: "SWAP_LEVEL";
|
|
434
|
-
readonly inputs: readonly [];
|
|
435
|
-
readonly outputs: readonly [{
|
|
436
|
-
readonly name: "";
|
|
437
|
-
readonly type: "uint256";
|
|
438
|
-
readonly internalType: "uint256";
|
|
439
|
-
}];
|
|
440
|
-
readonly stateMutability: "view";
|
|
441
|
-
}, {
|
|
593
|
+
/**
|
|
594
|
+
* Minimal ERC-20 ABI the SDK writes against (mirrors viem's `erc20Abi`). The
|
|
595
|
+
* swap flow uses `approve`; `allowance`/`balanceOf`/`decimals`/`symbol`/`name`
|
|
596
|
+
* are included so reads share a single SDK-owned ABI.
|
|
597
|
+
*/
|
|
598
|
+
declare const ERC20_ABI: readonly [{
|
|
442
599
|
readonly type: "function";
|
|
443
|
-
readonly name: "
|
|
600
|
+
readonly name: "allowance";
|
|
444
601
|
readonly inputs: readonly [{
|
|
445
|
-
readonly name: "
|
|
602
|
+
readonly name: "owner";
|
|
446
603
|
readonly type: "address";
|
|
447
|
-
readonly internalType: "address";
|
|
448
604
|
}, {
|
|
449
|
-
readonly name: "
|
|
450
|
-
readonly type: "
|
|
451
|
-
readonly internalType: "uint256";
|
|
605
|
+
readonly name: "spender";
|
|
606
|
+
readonly type: "address";
|
|
452
607
|
}];
|
|
453
608
|
readonly outputs: readonly [{
|
|
454
609
|
readonly name: "";
|
|
455
|
-
readonly type: "
|
|
456
|
-
readonly internalType: "struct Preview";
|
|
457
|
-
readonly components: readonly [{
|
|
458
|
-
readonly name: "input";
|
|
459
|
-
readonly type: "uint256";
|
|
460
|
-
readonly internalType: "uint256";
|
|
461
|
-
}, {
|
|
462
|
-
readonly name: "fee";
|
|
463
|
-
readonly type: "uint256";
|
|
464
|
-
readonly internalType: "uint256";
|
|
465
|
-
}, {
|
|
466
|
-
readonly name: "output";
|
|
467
|
-
readonly type: "uint256";
|
|
468
|
-
readonly internalType: "uint256";
|
|
469
|
-
}];
|
|
610
|
+
readonly type: "uint256";
|
|
470
611
|
}];
|
|
471
612
|
readonly stateMutability: "view";
|
|
472
613
|
}, {
|
|
473
614
|
readonly type: "function";
|
|
474
|
-
readonly name: "
|
|
615
|
+
readonly name: "approve";
|
|
475
616
|
readonly inputs: readonly [{
|
|
476
|
-
readonly name: "
|
|
617
|
+
readonly name: "spender";
|
|
477
618
|
readonly type: "address";
|
|
478
|
-
readonly internalType: "address";
|
|
479
619
|
}, {
|
|
480
620
|
readonly name: "amount";
|
|
481
621
|
readonly type: "uint256";
|
|
482
|
-
readonly internalType: "uint256";
|
|
483
|
-
}, {
|
|
484
|
-
readonly name: "slip";
|
|
485
|
-
readonly type: "uint256";
|
|
486
|
-
readonly internalType: "uint256";
|
|
487
622
|
}];
|
|
488
623
|
readonly outputs: readonly [{
|
|
489
624
|
readonly name: "";
|
|
490
|
-
readonly type: "
|
|
491
|
-
readonly internalType: "uint256";
|
|
625
|
+
readonly type: "bool";
|
|
492
626
|
}];
|
|
493
627
|
readonly stateMutability: "nonpayable";
|
|
494
628
|
}, {
|
|
495
629
|
readonly type: "function";
|
|
496
|
-
readonly name: "
|
|
630
|
+
readonly name: "balanceOf";
|
|
497
631
|
readonly inputs: readonly [{
|
|
498
|
-
readonly name: "
|
|
632
|
+
readonly name: "account";
|
|
499
633
|
readonly type: "address";
|
|
500
|
-
readonly internalType: "address";
|
|
501
634
|
}];
|
|
502
635
|
readonly outputs: readonly [{
|
|
503
636
|
readonly name: "";
|
|
504
637
|
readonly type: "uint256";
|
|
505
|
-
readonly internalType: "uint256";
|
|
506
638
|
}];
|
|
507
639
|
readonly stateMutability: "view";
|
|
508
640
|
}, {
|
|
509
641
|
readonly type: "function";
|
|
510
|
-
readonly name: "
|
|
642
|
+
readonly name: "decimals";
|
|
511
643
|
readonly inputs: readonly [];
|
|
512
644
|
readonly outputs: readonly [{
|
|
513
645
|
readonly name: "";
|
|
514
|
-
readonly type: "
|
|
515
|
-
readonly internalType: "address";
|
|
646
|
+
readonly type: "uint8";
|
|
516
647
|
}];
|
|
517
648
|
readonly stateMutability: "view";
|
|
518
649
|
}, {
|
|
519
650
|
readonly type: "function";
|
|
520
|
-
readonly name: "
|
|
651
|
+
readonly name: "name";
|
|
521
652
|
readonly inputs: readonly [];
|
|
522
653
|
readonly outputs: readonly [{
|
|
523
|
-
readonly name: "";
|
|
524
|
-
readonly type: "
|
|
525
|
-
readonly internalType: "uint256";
|
|
526
|
-
}];
|
|
527
|
-
readonly stateMutability: "view";
|
|
528
|
-
}, {
|
|
529
|
-
readonly type: "function";
|
|
530
|
-
readonly name: "totals";
|
|
531
|
-
readonly inputs: readonly [{
|
|
532
|
-
readonly name: "token";
|
|
533
|
-
readonly type: "address";
|
|
534
|
-
readonly internalType: "address";
|
|
535
|
-
}];
|
|
536
|
-
readonly outputs: readonly [{
|
|
537
|
-
readonly name: "";
|
|
538
|
-
readonly type: "tuple";
|
|
539
|
-
readonly internalType: "struct SwapTotal";
|
|
540
|
-
readonly components: readonly [{
|
|
541
|
-
readonly name: "inputSum";
|
|
542
|
-
readonly type: "uint256";
|
|
543
|
-
readonly internalType: "uint256";
|
|
544
|
-
}, {
|
|
545
|
-
readonly name: "feeSum";
|
|
546
|
-
readonly type: "uint256";
|
|
547
|
-
readonly internalType: "uint256";
|
|
548
|
-
}, {
|
|
549
|
-
readonly name: "outputSum";
|
|
550
|
-
readonly type: "uint256";
|
|
551
|
-
readonly internalType: "uint256";
|
|
552
|
-
}, {
|
|
553
|
-
readonly name: "count";
|
|
554
|
-
readonly type: "uint256";
|
|
555
|
-
readonly internalType: "uint256";
|
|
556
|
-
}];
|
|
557
|
-
}];
|
|
558
|
-
readonly stateMutability: "view";
|
|
559
|
-
}, {
|
|
560
|
-
readonly type: "function";
|
|
561
|
-
readonly name: "totals";
|
|
562
|
-
readonly inputs: readonly [{
|
|
563
|
-
readonly name: "user";
|
|
564
|
-
readonly type: "address";
|
|
565
|
-
readonly internalType: "address";
|
|
566
|
-
}, {
|
|
567
|
-
readonly name: "token";
|
|
568
|
-
readonly type: "address";
|
|
569
|
-
readonly internalType: "address";
|
|
570
|
-
}];
|
|
571
|
-
readonly outputs: readonly [{
|
|
572
|
-
readonly name: "";
|
|
573
|
-
readonly type: "tuple";
|
|
574
|
-
readonly internalType: "struct SwapTotal";
|
|
575
|
-
readonly components: readonly [{
|
|
576
|
-
readonly name: "inputSum";
|
|
577
|
-
readonly type: "uint256";
|
|
578
|
-
readonly internalType: "uint256";
|
|
579
|
-
}, {
|
|
580
|
-
readonly name: "feeSum";
|
|
581
|
-
readonly type: "uint256";
|
|
582
|
-
readonly internalType: "uint256";
|
|
583
|
-
}, {
|
|
584
|
-
readonly name: "outputSum";
|
|
585
|
-
readonly type: "uint256";
|
|
586
|
-
readonly internalType: "uint256";
|
|
587
|
-
}, {
|
|
588
|
-
readonly name: "count";
|
|
589
|
-
readonly type: "uint256";
|
|
590
|
-
readonly internalType: "uint256";
|
|
591
|
-
}];
|
|
654
|
+
readonly name: "";
|
|
655
|
+
readonly type: "string";
|
|
592
656
|
}];
|
|
593
657
|
readonly stateMutability: "view";
|
|
594
658
|
}, {
|
|
595
659
|
readonly type: "function";
|
|
596
|
-
readonly name: "
|
|
597
|
-
readonly inputs: readonly [
|
|
598
|
-
|
|
599
|
-
readonly
|
|
600
|
-
readonly
|
|
601
|
-
}, {
|
|
602
|
-
readonly name: "amount";
|
|
603
|
-
readonly type: "uint256";
|
|
604
|
-
readonly internalType: "uint256";
|
|
660
|
+
readonly name: "symbol";
|
|
661
|
+
readonly inputs: readonly [];
|
|
662
|
+
readonly outputs: readonly [{
|
|
663
|
+
readonly name: "";
|
|
664
|
+
readonly type: "string";
|
|
605
665
|
}];
|
|
666
|
+
readonly stateMutability: "view";
|
|
667
|
+
}, {
|
|
668
|
+
readonly type: "function";
|
|
669
|
+
readonly name: "totalSupply";
|
|
670
|
+
readonly inputs: readonly [];
|
|
606
671
|
readonly outputs: readonly [{
|
|
607
672
|
readonly name: "";
|
|
608
|
-
readonly type: "
|
|
609
|
-
readonly internalType: "bool";
|
|
673
|
+
readonly type: "uint256";
|
|
610
674
|
}];
|
|
611
|
-
readonly stateMutability: "
|
|
675
|
+
readonly stateMutability: "view";
|
|
612
676
|
}, {
|
|
613
677
|
readonly type: "function";
|
|
614
678
|
readonly name: "transfer";
|
|
615
679
|
readonly inputs: readonly [{
|
|
616
|
-
readonly name: "
|
|
617
|
-
readonly type: "address";
|
|
618
|
-
readonly internalType: "address";
|
|
619
|
-
}, {
|
|
620
|
-
readonly name: "token";
|
|
680
|
+
readonly name: "recipient";
|
|
621
681
|
readonly type: "address";
|
|
622
|
-
readonly internalType: "address";
|
|
623
682
|
}, {
|
|
624
683
|
readonly name: "amount";
|
|
625
684
|
readonly type: "uint256";
|
|
626
|
-
readonly internalType: "uint256";
|
|
627
685
|
}];
|
|
628
686
|
readonly outputs: readonly [{
|
|
629
687
|
readonly name: "";
|
|
630
688
|
readonly type: "bool";
|
|
631
|
-
readonly internalType: "bool";
|
|
632
689
|
}];
|
|
633
690
|
readonly stateMutability: "nonpayable";
|
|
634
691
|
}, {
|
|
635
692
|
readonly type: "function";
|
|
636
|
-
readonly name: "
|
|
693
|
+
readonly name: "transferFrom";
|
|
637
694
|
readonly inputs: readonly [{
|
|
638
|
-
readonly name: "
|
|
695
|
+
readonly name: "sender";
|
|
696
|
+
readonly type: "address";
|
|
697
|
+
}, {
|
|
698
|
+
readonly name: "recipient";
|
|
699
|
+
readonly type: "address";
|
|
700
|
+
}, {
|
|
701
|
+
readonly name: "amount";
|
|
639
702
|
readonly type: "uint256";
|
|
640
|
-
readonly internalType: "uint256";
|
|
641
703
|
}];
|
|
642
704
|
readonly outputs: readonly [{
|
|
643
705
|
readonly name: "";
|
|
644
706
|
readonly type: "bool";
|
|
645
|
-
readonly internalType: "bool";
|
|
646
707
|
}];
|
|
647
708
|
readonly stateMutability: "nonpayable";
|
|
648
709
|
}, {
|
|
649
710
|
readonly type: "event";
|
|
650
|
-
readonly name: "
|
|
711
|
+
readonly name: "Approval";
|
|
651
712
|
readonly inputs: readonly [{
|
|
652
|
-
readonly name: "
|
|
653
|
-
readonly type: "address";
|
|
654
|
-
readonly indexed: true;
|
|
655
|
-
readonly internalType: "address";
|
|
656
|
-
}, {
|
|
657
|
-
readonly name: "inputToken";
|
|
713
|
+
readonly name: "owner";
|
|
658
714
|
readonly type: "address";
|
|
659
715
|
readonly indexed: true;
|
|
660
|
-
readonly internalType: "address";
|
|
661
716
|
}, {
|
|
662
|
-
readonly name: "
|
|
717
|
+
readonly name: "spender";
|
|
663
718
|
readonly type: "address";
|
|
664
719
|
readonly indexed: true;
|
|
665
|
-
readonly internalType: "address";
|
|
666
|
-
}, {
|
|
667
|
-
readonly name: "inputAmount";
|
|
668
|
-
readonly type: "uint256";
|
|
669
|
-
readonly indexed: false;
|
|
670
|
-
readonly internalType: "uint256";
|
|
671
720
|
}, {
|
|
672
|
-
readonly name: "
|
|
721
|
+
readonly name: "value";
|
|
673
722
|
readonly type: "uint256";
|
|
674
723
|
readonly indexed: false;
|
|
675
|
-
readonly internalType: "uint256";
|
|
676
724
|
}];
|
|
677
725
|
readonly anonymous: false;
|
|
678
726
|
}, {
|
|
679
727
|
readonly type: "event";
|
|
680
|
-
readonly name: "
|
|
728
|
+
readonly name: "Transfer";
|
|
681
729
|
readonly inputs: readonly [{
|
|
682
|
-
readonly name: "
|
|
730
|
+
readonly name: "from";
|
|
683
731
|
readonly type: "address";
|
|
684
732
|
readonly indexed: true;
|
|
685
|
-
readonly internalType: "address";
|
|
686
733
|
}, {
|
|
687
|
-
readonly name: "
|
|
734
|
+
readonly name: "to";
|
|
688
735
|
readonly type: "address";
|
|
689
736
|
readonly indexed: true;
|
|
690
|
-
readonly internalType: "address";
|
|
691
737
|
}, {
|
|
692
|
-
readonly name: "
|
|
738
|
+
readonly name: "value";
|
|
693
739
|
readonly type: "uint256";
|
|
694
740
|
readonly indexed: false;
|
|
695
|
-
readonly internalType: "uint256";
|
|
696
741
|
}];
|
|
697
742
|
readonly anonymous: false;
|
|
698
|
-
}, {
|
|
699
|
-
readonly type: "error";
|
|
700
|
-
readonly name: "InvalidAddress";
|
|
701
|
-
readonly inputs: readonly [];
|
|
702
|
-
}, {
|
|
703
|
-
readonly type: "error";
|
|
704
|
-
readonly name: "InsufficientAmount";
|
|
705
|
-
readonly inputs: readonly [];
|
|
706
|
-
}, {
|
|
707
|
-
readonly type: "error";
|
|
708
|
-
readonly name: "InvalidAmount";
|
|
709
|
-
readonly inputs: readonly [];
|
|
710
|
-
}, {
|
|
711
|
-
readonly type: "error";
|
|
712
|
-
readonly name: "SwapFailed";
|
|
713
|
-
readonly inputs: readonly [{
|
|
714
|
-
readonly name: "user";
|
|
715
|
-
readonly type: "address";
|
|
716
|
-
readonly internalType: "address";
|
|
717
|
-
}, {
|
|
718
|
-
readonly name: "token";
|
|
719
|
-
readonly type: "address";
|
|
720
|
-
readonly internalType: "address";
|
|
721
|
-
}];
|
|
722
743
|
}];
|
|
723
744
|
|
|
745
|
+
declare function shortenAddress(address: EvmWalletAddress): ShortenedWalletAddress;
|
|
746
|
+
type FormatAmountOptions = {
|
|
747
|
+
maxFractionDigits?: AssetDecimals;
|
|
748
|
+
};
|
|
749
|
+
declare function formatAmount(amount: BlockchainAmount, locale: string, options?: FormatAmountOptions): FormattedAmountUi;
|
|
750
|
+
declare function formatRawAmount(amount: BlockchainAmount): string;
|
|
724
751
|
/**
|
|
725
|
-
*
|
|
726
|
-
*
|
|
727
|
-
*
|
|
728
|
-
*
|
|
729
|
-
* The multiplication happens before the division so we never lose precision to
|
|
730
|
-
* integer truncation early. This mirrors standard fixed-point practice on-chain.
|
|
731
|
-
* Returned decimals match the input token decimals (always the stablecoin's 6).
|
|
732
|
-
*/
|
|
733
|
-
declare function computePrice({ inputTokenAmount, outputTokenAmount, }: SwapQuote): BlockchainAmount | null;
|
|
734
|
-
/**
|
|
735
|
-
* Applies slippage to an amount, returning the minimum acceptable amount:
|
|
736
|
-
* `amount × (BPS_DENOM − slippage) / BPS_DENOM`. Throws when `slippage` exceeds
|
|
737
|
-
* `BPS_DENOM` (the retained fraction would be negative).
|
|
738
|
-
*/
|
|
739
|
-
declare function computeSlip(amount: BlockchainAmount, slippage: Bps): BlockchainAmount;
|
|
740
|
-
|
|
741
|
-
/**
|
|
742
|
-
* Interprets the on-chain swap availability read from `stopped()` and
|
|
743
|
-
* `SWAP_LEVEL()`.
|
|
744
|
-
*
|
|
745
|
-
* The contract tracks paused operations as a bitmask in `stopped`. The swap is
|
|
746
|
-
* stopped when the SWAP_LEVEL flag is set:
|
|
747
|
-
*
|
|
748
|
-
* (stopped & SWAP_LEVEL) != 0 -> stopped (not active)
|
|
752
|
+
* Formats a {@link BlockchainAmount} using compact notation (e.g. `1.37B`,
|
|
753
|
+
* `5M`). Compact notation only surfaces a couple of significant decimals, so
|
|
754
|
+
* the bigint → number narrowing here is intentional and safe: full precision
|
|
755
|
+
* is deliberately dropped in favour of a human-readable summary value.
|
|
749
756
|
*/
|
|
750
|
-
declare function
|
|
751
|
-
|
|
757
|
+
declare function formatCompactAmount(amount: BlockchainAmount, locale: string): FormattedAmountUi;
|
|
758
|
+
declare function formatBpsAsPercent(bps: Bps, locale: string): FormattedPercentUi;
|
|
759
|
+
declare function usdAmount(amount: FormattedAmountUi): FormattedAmountAssetUi;
|
|
760
|
+
declare function assetAmount(amount: FormattedAmountUi, symbol: AssetSymbol): FormattedAmountAssetUi;
|
|
761
|
+
/** Placeholder shown when an amount is unavailable (e.g. a loading quote). */
|
|
762
|
+
declare const NA_AMOUNT_ASSET_UI: FormattedAmountAssetUi;
|
|
752
763
|
/**
|
|
753
|
-
*
|
|
754
|
-
*
|
|
755
|
-
*
|
|
756
|
-
* Returns `null` when the event is absent or the amount is not a valid uint256
|
|
757
|
-
* so callers can fall back to the quote's expected output — the swap already
|
|
758
|
-
* confirmed on-chain, so a missing/undecodable event should not fail the flow.
|
|
764
|
+
* Formats a USD amount capped at 2 fractional digits, falling back to the
|
|
765
|
+
* {@link NA_AMOUNT_ASSET_UI} placeholder when the amount is absent.
|
|
759
766
|
*/
|
|
760
|
-
declare function
|
|
767
|
+
declare function formattedUsdPrice(amount: BlockchainAmount | null, locale: string): FormattedAmountAssetUi;
|
|
761
768
|
|
|
769
|
+
/** A typed, i18n-agnostic reason a raw amount string failed to parse. */
|
|
770
|
+
type AmountParseErrorReason = {
|
|
771
|
+
type: 'empty';
|
|
772
|
+
} | {
|
|
773
|
+
type: 'negative';
|
|
774
|
+
} | {
|
|
775
|
+
type: 'invalid-format';
|
|
776
|
+
} | {
|
|
777
|
+
type: 'too-many-decimals';
|
|
778
|
+
maxDecimals: AssetDecimals;
|
|
779
|
+
}
|
|
780
|
+
/** Scaled up by `decimals`, the amount no longer fits a uint256. */
|
|
781
|
+
| {
|
|
782
|
+
type: 'overflow';
|
|
783
|
+
};
|
|
784
|
+
type AmountParseResult = {
|
|
785
|
+
valid: true;
|
|
786
|
+
amount: BlockchainAmount;
|
|
787
|
+
} | {
|
|
788
|
+
valid: false;
|
|
789
|
+
reason: AmountParseErrorReason;
|
|
790
|
+
};
|
|
762
791
|
/**
|
|
763
|
-
*
|
|
792
|
+
* Wraps a raw uint256 base-unit string — what Ondo and the on-chain reads
|
|
793
|
+
* return ("100000000" is 100 USDC, not 100 wei-of-nothing) — in a
|
|
794
|
+
* {@link BlockchainAmount} at the given decimals. The value is already scaled,
|
|
795
|
+
* so `decimals` is only the unit tag that travels with it.
|
|
764
796
|
*
|
|
765
|
-
*
|
|
766
|
-
*
|
|
767
|
-
*
|
|
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.
|
|
797
|
+
* Distinct from {@link parseBlockchainAmount}, which takes a *human decimal*
|
|
798
|
+
* string and scales it up. Feeding a raw amount to that one silently
|
|
799
|
+
* multiplies it by 10^decimals — pick by what the backend sends, not by which
|
|
800
|
+
* one is closer at hand.
|
|
773
801
|
*
|
|
774
|
-
*
|
|
775
|
-
*
|
|
776
|
-
*
|
|
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).
|
|
802
|
+
* @throws ValidationError when the string is not a non-negative uint256
|
|
803
|
+
* integer. A backend that regresses to decimal strings fails loudly here
|
|
804
|
+
* rather than truncating.
|
|
784
805
|
*/
|
|
785
|
-
declare
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
806
|
+
declare function blockchainAmountFromRawOrThrow({ label, raw, decimals, }: {
|
|
807
|
+
label: string;
|
|
808
|
+
raw: string;
|
|
809
|
+
decimals: AssetDecimals;
|
|
810
|
+
}): BlockchainAmount;
|
|
790
811
|
/**
|
|
791
|
-
*
|
|
792
|
-
*
|
|
793
|
-
*
|
|
794
|
-
*
|
|
795
|
-
*
|
|
812
|
+
* Parses a user-entered decimal string into a {@link BlockchainAmount} at the
|
|
813
|
+
* given token decimals. Rejects scientific notation, negatives, malformed
|
|
814
|
+
* input, more fractional digits than the token supports, and amounts that
|
|
815
|
+
* scale past uint256 — surfacing a typed {@link AmountParseErrorReason} so
|
|
816
|
+
* callers own the display copy.
|
|
796
817
|
*/
|
|
797
|
-
declare
|
|
798
|
-
/** The Superstate swap contract on `chain`, or `null` where none is deployed. */
|
|
799
|
-
declare function superstateSwapContractAddress(chain: EthereumChain): EvmContractAddress | null;
|
|
818
|
+
declare function parseBlockchainAmount(amount: string, decimals: AssetDecimals): AmountParseResult;
|
|
800
819
|
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
820
|
+
declare const USDC_SYMBOL: StablecoinSymbol;
|
|
821
|
+
declare const USDC: Erc20Asset;
|
|
822
|
+
declare const USDT_SYMBOL: StablecoinSymbol;
|
|
823
|
+
declare const USDT: Erc20Asset;
|
|
824
|
+
/** Lookups for the stablecoins the SDK's swap flows support out of the box. */
|
|
825
|
+
declare const TOKEN_REGISTRY: {
|
|
826
|
+
erc20: (symbol: KnownAssetSymbol) => Erc20Asset;
|
|
827
|
+
/**
|
|
828
|
+
* USDC's contract on `chain`. USDC is deployed on every chain the SDK
|
|
829
|
+
* models, so the table is total and the answer is never `null`.
|
|
830
|
+
*/
|
|
831
|
+
usdcAddress: (chain: EthereumChain) => EvmContractAddress;
|
|
832
|
+
/**
|
|
833
|
+
* USDT's contract on `chain`, or `null` where Tether publishes none —
|
|
834
|
+
* Base Sepolia today. The honest answer, never a fake address a balance
|
|
835
|
+
* read would call.
|
|
836
|
+
*/
|
|
837
|
+
usdtAddress: (chain: EthereumChain) => EvmContractAddress | null;
|
|
838
|
+
};
|
|
809
839
|
|
|
810
840
|
/**
|
|
811
841
|
* Error thrown when a feature or code path is not yet implemented.
|
|
@@ -866,4 +896,4 @@ declare const User: {
|
|
|
866
896
|
fromDto: (dto: UserDto) => User;
|
|
867
897
|
};
|
|
868
898
|
|
|
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,
|
|
899
|
+
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, OfferSwapContract, 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, parseBlockchainAmount, shortenAddress, superstateSwapContractAddress, swapSpender, txExplorerUrl, usdAmount };
|