@coinlist-co/react 0.10.1 → 0.11.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/README.md +32 -0
- package/dist/{chunk-AQVCOWOV.js → chunk-B2HCVPCQ.js} +202 -318
- package/dist/chunk-B2HCVPCQ.js.map +1 -0
- package/dist/chunk-KDGNDAHA.js +146 -0
- package/dist/chunk-KDGNDAHA.js.map +1 -0
- package/dist/chunk-UIIXXLA7.js +1863 -0
- package/dist/chunk-UIIXXLA7.js.map +1 -0
- package/dist/client/index.cjs +10382 -3262
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +4219 -862
- package/dist/client/index.d.ts +4219 -862
- package/dist/client/index.js +8727 -2369
- package/dist/client/index.js.map +1 -1
- package/dist/collections-BhDkYmzV.d.cts +65 -0
- package/dist/collections-CZhHoQHr.d.ts +65 -0
- package/dist/config-B5mwS_2l.d.cts +1926 -0
- package/dist/config-B5mwS_2l.d.ts +1926 -0
- package/dist/server/index.cjs +981 -464
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +190 -163
- package/dist/server/index.d.ts +190 -163
- package/dist/server/index.js +151 -154
- package/dist/server/index.js.map +1 -1
- package/dist/shared/index.cjs +1810 -907
- package/dist/shared/index.cjs.map +1 -1
- package/dist/shared/index.d.cts +243 -132
- package/dist/shared/index.d.ts +243 -132
- package/dist/shared/index.js +96 -28
- package/package.json +10 -7
- package/dist/chunk-AQVCOWOV.js.map +0 -1
- package/dist/chunk-TBU3EBNM.js +0 -442
- package/dist/chunk-TBU3EBNM.js.map +0 -1
- package/dist/chunk-UOHD7US2.js +0 -855
- package/dist/chunk-UOHD7US2.js.map +0 -1
- package/dist/collections-Bv1Oxzu_.d.ts +0 -28
- package/dist/collections-DDyxbOPZ.d.cts +0 -28
- package/dist/requirement-oVZA1INj.d.cts +0 -1040
- package/dist/requirement-oVZA1INj.d.ts +0 -1040
|
@@ -0,0 +1,1926 @@
|
|
|
1
|
+
import { Hex } from 'viem';
|
|
2
|
+
|
|
3
|
+
declare const __brand: unique symbol;
|
|
4
|
+
type Newtype<Base, Branding> = Base & {
|
|
5
|
+
readonly [__brand]: Branding;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
type AuthorizationCode = Newtype<string, 'AuthorizationCode'>;
|
|
9
|
+
declare const AuthorizationCode: (value: string) => AuthorizationCode;
|
|
10
|
+
type CodeVerifier = Newtype<string, 'CodeVerifier'>;
|
|
11
|
+
declare const CodeVerifier: (value: string) => CodeVerifier;
|
|
12
|
+
type CodeChallenge = Newtype<string, 'CodeChallenge'>;
|
|
13
|
+
declare const CodeChallenge: (value: string) => CodeChallenge;
|
|
14
|
+
type PKCEState = Newtype<string, 'PKCEState'>;
|
|
15
|
+
declare const PKCEState: (value: string) => PKCEState;
|
|
16
|
+
type RedirectUri = Newtype<string, 'RedirectUri'>;
|
|
17
|
+
declare const RedirectUri: (value: string) => RedirectUri;
|
|
18
|
+
type ClientId = Newtype<string, 'ClientId'>;
|
|
19
|
+
declare const ClientId: (value: string) => ClientId;
|
|
20
|
+
type ClientSecret = Newtype<string, 'ClientSecret'>;
|
|
21
|
+
declare const ClientSecret: (value: string) => ClientSecret;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The exhaustive chain set: a new {@link EthereumChain} is a compile error
|
|
25
|
+
* here until it is listed, which is what keeps the constructor total.
|
|
26
|
+
*/
|
|
27
|
+
declare const ETHEREUM_CHAINS: Record<EthereumChain, true>;
|
|
28
|
+
type EthereumChain = 'ethereum_mainnet' | 'ethereum_sepolia';
|
|
29
|
+
/**
|
|
30
|
+
* Validates that a raw backend string names a chain the SDK supports.
|
|
31
|
+
*
|
|
32
|
+
* @throws ValidationError on anything else. Passing an unknown chain through
|
|
33
|
+
* would let downstream EIP-155 lookups blow up far from the response that
|
|
34
|
+
* caused it.
|
|
35
|
+
*/
|
|
36
|
+
declare const EthereumChain: (value: string) => EthereumChain;
|
|
37
|
+
/**
|
|
38
|
+
* The exhaustive chain set: a new {@link SolanaChain} is a compile error
|
|
39
|
+
* here until it is listed, which is what keeps the constructor total.
|
|
40
|
+
*/
|
|
41
|
+
declare const SOLANA_CHAINS: Record<SolanaChain, true>;
|
|
42
|
+
type SolanaChain = 'solana_mainnet' | 'solana_devnet';
|
|
43
|
+
/**
|
|
44
|
+
* Validates that a raw backend string names a chain the SDK supports.
|
|
45
|
+
*
|
|
46
|
+
* @throws ValidationError on anything else. Passing an unknown chain through
|
|
47
|
+
* would let downstream EIP-155 lookups blow up far from the response that
|
|
48
|
+
* caused it.
|
|
49
|
+
*/
|
|
50
|
+
declare const SolanaChain: (value: string) => SolanaChain;
|
|
51
|
+
type Chain = EthereumChain | SolanaChain;
|
|
52
|
+
declare const Chain: (value: string) => Chain;
|
|
53
|
+
/**
|
|
54
|
+
* Protocol a wallet binding is scoped to. EVM-only for now: an EVM address
|
|
55
|
+
* binds once per option regardless of which EVM chain proved ownership.
|
|
56
|
+
* Frontline's enum also has `:solana`, but we don't handle Solana bindings yet,
|
|
57
|
+
* so this stays `'ethereum'` until Solana support lands.
|
|
58
|
+
*/
|
|
59
|
+
type WalletProtocol = 'ethereum';
|
|
60
|
+
/**
|
|
61
|
+
* EVM addresses keep a `0x${string}` base so they stay assignable to the
|
|
62
|
+
* `0x${string}` shapes that on-chain libraries (viem/wagmi) expect. We only
|
|
63
|
+
* drop the runtime `0x` narrowing: values are trusted at the boundary and
|
|
64
|
+
* branded via the constructor.
|
|
65
|
+
*/
|
|
66
|
+
type EvmWalletAddress = Newtype<`0x${string}`, 'EvmWalletAddress'>;
|
|
67
|
+
declare const EvmWalletAddress: (value: string) => EvmWalletAddress;
|
|
68
|
+
type EvmContractAddress = Newtype<`0x${string}`, 'EvmContractAddress'>;
|
|
69
|
+
declare const EvmContractAddress: (value: string) => EvmContractAddress;
|
|
70
|
+
/**
|
|
71
|
+
* What uniquely identifies a token: the chain it is deployed on plus its
|
|
72
|
+
* contract address. Never a symbol, which can collide across issuers.
|
|
73
|
+
*/
|
|
74
|
+
type TokenIdentifier = {
|
|
75
|
+
/** The chain the token contract is deployed on. */
|
|
76
|
+
chain: EthereumChain;
|
|
77
|
+
/**
|
|
78
|
+
* The token's contract address, in any casing — consumers that need the
|
|
79
|
+
* EIP-55 form (e.g. the token registry routes) checksum it themselves.
|
|
80
|
+
*/
|
|
81
|
+
address: EvmContractAddress;
|
|
82
|
+
};
|
|
83
|
+
type HexEncodedTransactionData = Newtype<`0x${string}`, 'HexEncodedTransactionData'>;
|
|
84
|
+
declare const HexEncodedTransactionData: (value: string) => HexEncodedTransactionData;
|
|
85
|
+
/**
|
|
86
|
+
* A transaction the backend has already encoded for us — the caller only
|
|
87
|
+
* broadcasts it. Used by the flows that hand a wallet a ready-made `to`/`data`
|
|
88
|
+
* pair (allow-listing a wallet, an Ondo swap) rather than encoding a contract
|
|
89
|
+
* call themselves.
|
|
90
|
+
*/
|
|
91
|
+
type Tx = {
|
|
92
|
+
to: EvmContractAddress;
|
|
93
|
+
data: HexEncodedTransactionData;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* The largest exponent whose power of ten still fits a uint256: 10^77 fits,
|
|
97
|
+
* 10^78 does not.
|
|
98
|
+
*
|
|
99
|
+
* The bound is arithmetic rather than a token standard's. ERC-20 reports
|
|
100
|
+
* `decimals()` as a `uint8`, so 255 is what a contract *can* say, but every
|
|
101
|
+
* {@link AssetDecimals} in this codebase is paired with a {@link Uint256} raw
|
|
102
|
+
* by construction, and scaling by anything past this leaves that pairing
|
|
103
|
+
* unrepresentable. A value between 78 and 255 would therefore pass a
|
|
104
|
+
* standard-faithful check and then break the first multiplication it reached.
|
|
105
|
+
*/
|
|
106
|
+
declare const MAX_ASSET_DECIMALS = 77;
|
|
107
|
+
/**
|
|
108
|
+
* How many decimal places one whole token divides into.
|
|
109
|
+
*
|
|
110
|
+
* Validated, unlike its neighbours here — {@link Uint256} is a bare `bigint`
|
|
111
|
+
* with a separate {@link assertUint256} guard, and {@link DecimalString} casts
|
|
112
|
+
* unchecked. The asymmetry is deliberate and follows the value's provenance:
|
|
113
|
+
* an `AssetDecimals` used to come only from literals and the token registry,
|
|
114
|
+
* but backends now publish exponents of their own (`asset_decimals` on an Ondo
|
|
115
|
+
* quote, both scales on a built swap), and those feed `10n ** BigInt(d)`
|
|
116
|
+
* during render. Guarding at construction is what keeps a fractional or
|
|
117
|
+
* unbounded exponent from surfacing as a `RangeError` mid-render — or, at
|
|
118
|
+
* 10^200, as a hung tab — instead of as the failed state the screen has.
|
|
119
|
+
*
|
|
120
|
+
* See docs/ADR-7-VALIDATED-NEWTYPES.md.
|
|
121
|
+
*
|
|
122
|
+
* @throws ValidationError on a non-integer, a negative, or anything above
|
|
123
|
+
* {@link MAX_ASSET_DECIMALS}.
|
|
124
|
+
*/
|
|
125
|
+
type AssetDecimals = Newtype<number, 'AssetDecimals'>;
|
|
126
|
+
declare const AssetDecimals: (value: number) => AssetDecimals;
|
|
127
|
+
declare const STABLE_DECIMALS: AssetDecimals;
|
|
128
|
+
/**
|
|
129
|
+
* A non-negative decimal number the backend sent as a string, kept unscaled.
|
|
130
|
+
*
|
|
131
|
+
* Reach for it when a response gives you a number but not the decimals to
|
|
132
|
+
* scale it by, or gives you one it has already applied. Inventing an exponent
|
|
133
|
+
* for either is how a display ends up orders of magnitude out.
|
|
134
|
+
*
|
|
135
|
+
* Contrast {@link BlockchainAmount}, which pairs a raw uint256 with the
|
|
136
|
+
* decimals it is denominated in and so is only constructible when you know
|
|
137
|
+
* both. Arithmetic on a `DecimalString` needs a decimal library we
|
|
138
|
+
* deliberately do not ship.
|
|
139
|
+
*/
|
|
140
|
+
type DecimalString = Newtype<string, 'DecimalString'>;
|
|
141
|
+
declare const DecimalString: (value: string) => DecimalString;
|
|
142
|
+
declare const MAX_UINT_256: bigint;
|
|
143
|
+
/**
|
|
144
|
+
* A non-negative integer within uint256 bounds. Kept unbranded (a plain
|
|
145
|
+
* `bigint`) so raw on-chain amounts flow in without ceremony; bounds are
|
|
146
|
+
* enforced where it matters (see {@link combineAmounts}).
|
|
147
|
+
*/
|
|
148
|
+
type Uint256 = bigint;
|
|
149
|
+
/**
|
|
150
|
+
* Asserts a raw bigint falls within uint256 bounds, throwing otherwise. Use at
|
|
151
|
+
* on-chain arithmetic boundaries (bps math, price computation) where a computed
|
|
152
|
+
* value could underflow below zero or overflow above 2^256-1.
|
|
153
|
+
*/
|
|
154
|
+
declare const assertUint256: (value: bigint) => Uint256;
|
|
155
|
+
type BlockchainAmount = Newtype<{
|
|
156
|
+
raw: Uint256;
|
|
157
|
+
decimals: AssetDecimals;
|
|
158
|
+
}, 'BlockchainAmount'>;
|
|
159
|
+
/**
|
|
160
|
+
* Constructs a {@link BlockchainAmount} and exposes arithmetic helpers.
|
|
161
|
+
* TypeScript has no operator overloading, so use `BlockchainAmount.add(a, b)`
|
|
162
|
+
* instead of `+`/`-` on the objects directly.
|
|
163
|
+
*/
|
|
164
|
+
declare const BlockchainAmount: ((value: {
|
|
165
|
+
raw: Uint256;
|
|
166
|
+
decimals: AssetDecimals;
|
|
167
|
+
}) => BlockchainAmount) & {
|
|
168
|
+
add: (a: BlockchainAmount, b: BlockchainAmount) => BlockchainAmount;
|
|
169
|
+
sub: (a: BlockchainAmount, b: BlockchainAmount) => BlockchainAmount;
|
|
170
|
+
};
|
|
171
|
+
type AssetSymbol = Newtype<string, 'AssetSymbol'>;
|
|
172
|
+
declare const AssetSymbol: (value: string) => AssetSymbol;
|
|
173
|
+
/**
|
|
174
|
+
* A stablecoin symbol is an {@link AssetSymbol} narrowed to the coins we
|
|
175
|
+
* support. It shares the `AssetSymbol` brand so it stays assignable to it.
|
|
176
|
+
*/
|
|
177
|
+
type StablecoinSymbol = Newtype<'USDC' | 'USDT', 'AssetSymbol'>;
|
|
178
|
+
declare const StablecoinSymbol: (value: "USDC" | "USDT") => StablecoinSymbol;
|
|
179
|
+
type KnownAssetSymbol = StablecoinSymbol;
|
|
180
|
+
declare const KnownAssetSymbol: (value: "USDC" | "USDT") => StablecoinSymbol;
|
|
181
|
+
type Erc20Asset = {
|
|
182
|
+
name: string;
|
|
183
|
+
symbol: AssetSymbol;
|
|
184
|
+
decimals: AssetDecimals;
|
|
185
|
+
};
|
|
186
|
+
type Bps = Newtype<bigint, 'Bps'>;
|
|
187
|
+
declare const Bps: (value: bigint) => Bps;
|
|
188
|
+
|
|
189
|
+
type GetTokenAllowanceParams = {
|
|
190
|
+
tokenAddress: EvmContractAddress;
|
|
191
|
+
owner: EvmWalletAddress;
|
|
192
|
+
spender: EvmContractAddress;
|
|
193
|
+
chain: EthereumChain;
|
|
194
|
+
};
|
|
195
|
+
type GetTokenBalanceParams = {
|
|
196
|
+
tokenAddress: EvmContractAddress;
|
|
197
|
+
owner: EvmWalletAddress;
|
|
198
|
+
chain: EthereumChain;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* OAuth 2.0 token response (RFC 6749 §5.1).
|
|
203
|
+
* Maps to OpenAPI schema OauthToken.
|
|
204
|
+
*/
|
|
205
|
+
type OAuthSessionDto = {
|
|
206
|
+
access_token: string;
|
|
207
|
+
expires_in: number;
|
|
208
|
+
refresh_token?: string;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
type ClientCredentialsOAuth = Newtype<OAuthAccessToken, 'ClientCredentialsOAuth'>;
|
|
212
|
+
declare const ClientCredentialsOAuth: (value: OAuthAccessToken) => ClientCredentialsOAuth;
|
|
213
|
+
type OAuthAccessToken = {
|
|
214
|
+
value: string;
|
|
215
|
+
expiresAt: Date;
|
|
216
|
+
};
|
|
217
|
+
type OAuthRefreshToken = Newtype<string, 'OAuthRefreshToken'>;
|
|
218
|
+
declare const OAuthRefreshToken: (value: string) => OAuthRefreshToken;
|
|
219
|
+
type OAuthSession = {
|
|
220
|
+
accessToken: OAuthAccessToken;
|
|
221
|
+
refreshToken?: OAuthRefreshToken;
|
|
222
|
+
};
|
|
223
|
+
declare const OAuthSession: {
|
|
224
|
+
fromDto: (dto: OAuthSessionDto) => OAuthSession;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
type HttpRequestAttributes = {
|
|
228
|
+
protected?: boolean;
|
|
229
|
+
userAgent?: boolean;
|
|
230
|
+
idempotencyKey?: boolean;
|
|
231
|
+
/** Zero-based attempt index: 0 = first request, 1 = first retry, etc. */
|
|
232
|
+
retryAttempt?: number;
|
|
233
|
+
renewAttempted?: boolean;
|
|
234
|
+
clientCredentials?: ClientCredentialsOAuth;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* The value types a query-string parameter may take.
|
|
239
|
+
*
|
|
240
|
+
* Declared here rather than beside the HTTP client because domain models build
|
|
241
|
+
* query parameters too: `ParticipationsPaginationParams.toQueryParams` returns
|
|
242
|
+
* a `Record<string, QueryParamValue>`, and a domain model must not import
|
|
243
|
+
* `@/shared/api/**`.
|
|
244
|
+
*/
|
|
245
|
+
type QueryParamValue = string | number | boolean | null | undefined;
|
|
246
|
+
type QueryParamValues = QueryParamValue | QueryParamValue[];
|
|
247
|
+
|
|
248
|
+
type HttpRequest<TBody = unknown> = {
|
|
249
|
+
method: 'GET';
|
|
250
|
+
url: string;
|
|
251
|
+
queryParams?: Record<string, QueryParamValues>;
|
|
252
|
+
headers?: Record<string, string>;
|
|
253
|
+
attributes?: HttpRequestAttributes;
|
|
254
|
+
redirect?: RequestRedirect;
|
|
255
|
+
} | {
|
|
256
|
+
method: 'POST';
|
|
257
|
+
url: string;
|
|
258
|
+
queryParams?: Record<string, QueryParamValues>;
|
|
259
|
+
headers?: Record<string, string>;
|
|
260
|
+
body: TBody;
|
|
261
|
+
attributes?: HttpRequestAttributes;
|
|
262
|
+
redirect?: RequestRedirect;
|
|
263
|
+
} | {
|
|
264
|
+
method: 'DELETE';
|
|
265
|
+
url: string;
|
|
266
|
+
queryParams?: Record<string, QueryParamValues>;
|
|
267
|
+
headers?: Record<string, string>;
|
|
268
|
+
attributes?: HttpRequestAttributes;
|
|
269
|
+
redirect?: RequestRedirect;
|
|
270
|
+
};
|
|
271
|
+
type HttpResponse<TBody = unknown> = {
|
|
272
|
+
status: number;
|
|
273
|
+
headers?: Record<string, string>;
|
|
274
|
+
body: TBody | null;
|
|
275
|
+
};
|
|
276
|
+
declare class HttpError<TBody = unknown> extends Error {
|
|
277
|
+
readonly response: HttpResponse<TBody>;
|
|
278
|
+
constructor(response: HttpResponse<TBody>);
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* The machine-readable `code` frontline attaches to an error, or `null` for
|
|
282
|
+
* anything else - a non-HTTP failure, or an error body that carries only a
|
|
283
|
+
* message.
|
|
284
|
+
*
|
|
285
|
+
* Frontline answers a failure with `{ type, message, code?, errors?,
|
|
286
|
+
* event_id? }`, and `code` is the only part of it meant to be branched on:
|
|
287
|
+
* `message` is prose that may be reworded, and `type` distinguishes
|
|
288
|
+
* `invalid_request_error` from `api_error` without saying which one.
|
|
289
|
+
*
|
|
290
|
+
* Reach for this only where a code has a distinct remedy the user can act on.
|
|
291
|
+
* Mapping the whole vocabulary would couple the SDK to strings frontline does
|
|
292
|
+
* not version; falling back to a generic failure is the right default.
|
|
293
|
+
*/
|
|
294
|
+
declare function apiErrorCode(error: unknown): string | null;
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Structural interface satisfied by both {@link AuthenticatedApiClient} and
|
|
298
|
+
* {@link ApiClient}. Used by the shared frontline API functions so they can
|
|
299
|
+
* be called from either the client or server without any browser dependencies.
|
|
300
|
+
*/
|
|
301
|
+
interface Sender {
|
|
302
|
+
send<T>(request: HttpRequest): Promise<T>;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
interface SharedNamespaceContext {
|
|
306
|
+
readonly api: Sender;
|
|
307
|
+
ensureUserAuthenticated(): Promise<void>;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Raw JSON models for the on-chain swap endpoints. uint256 values are encoded
|
|
312
|
+
* as decimal strings because they can exceed the safe integer range of JSON
|
|
313
|
+
* consumers.
|
|
314
|
+
*/
|
|
315
|
+
type WalletAuthorizationDto = {
|
|
316
|
+
object: 'wallet_authorization';
|
|
317
|
+
authorized: boolean;
|
|
318
|
+
};
|
|
319
|
+
type SwapPreviewDto = {
|
|
320
|
+
object: 'swap_preview';
|
|
321
|
+
pay_input_amount: string;
|
|
322
|
+
fee: string;
|
|
323
|
+
receive_output_amount: string;
|
|
324
|
+
};
|
|
325
|
+
type SwapStatusDto = {
|
|
326
|
+
object: 'swap_status';
|
|
327
|
+
stopped: string;
|
|
328
|
+
swap_level: string;
|
|
329
|
+
};
|
|
330
|
+
type TokenAllowanceDto = {
|
|
331
|
+
object: 'token_allowance';
|
|
332
|
+
allowance: string;
|
|
333
|
+
};
|
|
334
|
+
type TokenBalanceDto = {
|
|
335
|
+
object: 'token_balance';
|
|
336
|
+
balance: string;
|
|
337
|
+
};
|
|
338
|
+
type AllowWalletResponseDto = {
|
|
339
|
+
action: 'broadcast_transaction';
|
|
340
|
+
to: string;
|
|
341
|
+
data: string;
|
|
342
|
+
} | {
|
|
343
|
+
action: 'none';
|
|
344
|
+
already_allowed: boolean;
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Whether a wallet is authorized to interact with a given swap contract.
|
|
349
|
+
*/
|
|
350
|
+
type SwapAuthorization = {
|
|
351
|
+
authorized: boolean;
|
|
352
|
+
};
|
|
353
|
+
declare const SwapAuthorization: {
|
|
354
|
+
fromDto: (dto: WalletAuthorizationDto) => SwapAuthorization;
|
|
355
|
+
};
|
|
356
|
+
/**
|
|
357
|
+
* A read-only quote for a swap: how much goes in, the protocol fee, and how
|
|
358
|
+
* much would come out. All amounts are raw on-chain integers (uint256).
|
|
359
|
+
*/
|
|
360
|
+
type SwapPreview = {
|
|
361
|
+
inputAmount: Uint256;
|
|
362
|
+
fee: Uint256;
|
|
363
|
+
outputAmount: Uint256;
|
|
364
|
+
};
|
|
365
|
+
declare const SwapPreview: {
|
|
366
|
+
fromDto: (dto: SwapPreviewDto) => SwapPreview;
|
|
367
|
+
};
|
|
368
|
+
/**
|
|
369
|
+
* The on-chain state of a swap contract.
|
|
370
|
+
*
|
|
371
|
+
* - `stopped`: non-zero when the contract is paused/halted.
|
|
372
|
+
* - `swapLevel`: the current swap level/tier.
|
|
373
|
+
*/
|
|
374
|
+
type SwapStatus = {
|
|
375
|
+
stopped: Uint256;
|
|
376
|
+
swapLevel: Uint256;
|
|
377
|
+
};
|
|
378
|
+
declare const SwapStatus: {
|
|
379
|
+
fromDto: (dto: SwapStatusDto) => SwapStatus;
|
|
380
|
+
};
|
|
381
|
+
/**
|
|
382
|
+
* The ERC-20 allowance an owner has granted a spender for a token.
|
|
383
|
+
*/
|
|
384
|
+
type TokenAllowance = {
|
|
385
|
+
allowance: Uint256;
|
|
386
|
+
};
|
|
387
|
+
declare const TokenAllowance: {
|
|
388
|
+
fromDto: (dto: TokenAllowanceDto) => TokenAllowance;
|
|
389
|
+
};
|
|
390
|
+
/**
|
|
391
|
+
* The raw ERC-20 balance an owner holds of a token (uint256).
|
|
392
|
+
*/
|
|
393
|
+
type TokenBalance = {
|
|
394
|
+
balance: Uint256;
|
|
395
|
+
};
|
|
396
|
+
declare const TokenBalance: {
|
|
397
|
+
fromDto: (dto: TokenBalanceDto) => TokenBalance;
|
|
398
|
+
};
|
|
399
|
+
/**
|
|
400
|
+
* The backend's response to an allow-wallet request. Either the caller must
|
|
401
|
+
* broadcast an on-chain transaction to complete allow-listing, or nothing is
|
|
402
|
+
* required because the wallet is already allowed.
|
|
403
|
+
*/
|
|
404
|
+
type AllowWalletResponse = {
|
|
405
|
+
action: 'broadcast_transaction';
|
|
406
|
+
to: EvmContractAddress;
|
|
407
|
+
data: HexEncodedTransactionData;
|
|
408
|
+
} | {
|
|
409
|
+
action: 'none';
|
|
410
|
+
alreadyAllowed: boolean;
|
|
411
|
+
};
|
|
412
|
+
declare const AllowWalletResponse: {
|
|
413
|
+
fromDto: (dto: AllowWalletResponseDto) => AllowWalletResponse;
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Generic ERC-20 reads shared across on-chain flows (swap, token sale): the
|
|
418
|
+
* allowance an owner has granted a spender, and the raw token balance an owner
|
|
419
|
+
* holds. These are plain token reads, not tied to any single product flow.
|
|
420
|
+
*/
|
|
421
|
+
interface Erc20Namespace {
|
|
422
|
+
/**
|
|
423
|
+
* Reads the ERC-20 allowance an `owner` has granted a `spender`.
|
|
424
|
+
*/
|
|
425
|
+
getAllowance(params: GetTokenAllowanceParams): Promise<TokenAllowance>;
|
|
426
|
+
/**
|
|
427
|
+
* Reads the raw ERC-20 balance an `owner` holds of a token.
|
|
428
|
+
*/
|
|
429
|
+
getBalance(params: GetTokenBalanceParams): Promise<TokenBalance>;
|
|
430
|
+
}
|
|
431
|
+
declare class Erc20NamespaceImpl implements Erc20Namespace {
|
|
432
|
+
private readonly ctx;
|
|
433
|
+
constructor(ctx: SharedNamespaceContext);
|
|
434
|
+
getAllowance(params: GetTokenAllowanceParams): Promise<TokenAllowance>;
|
|
435
|
+
getBalance(params: GetTokenBalanceParams): Promise<TokenBalance>;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* The product an offer is checked out through. The backend sends one compound
|
|
440
|
+
* `{supplier}::{saleType}` string, verbatim as spelled below: a double colon
|
|
441
|
+
* between the two halves, `snake_case` within each. CoinList's token sale is
|
|
442
|
+
* `coinlist::token_sale`; there is no `coinlist::sale` and no
|
|
443
|
+
* `coinlist_token_sale`.
|
|
444
|
+
*
|
|
445
|
+
* Kept flat rather than split into a supplier and a sale type, because a flat
|
|
446
|
+
* union makes a `switch` over it exhaustive: adding a provider without
|
|
447
|
+
* handling it becomes a compile error.
|
|
448
|
+
*/
|
|
449
|
+
type OfferTypeDto = 'coinlist::token_sale' | 'superstate::swap' | 'ondo::swap';
|
|
450
|
+
type OfferDto = {
|
|
451
|
+
id: string;
|
|
452
|
+
slug: string;
|
|
453
|
+
type: OfferTypeDto;
|
|
454
|
+
tagline: string;
|
|
455
|
+
banner_url: string;
|
|
456
|
+
logo_url: string;
|
|
457
|
+
starts_at: string;
|
|
458
|
+
ends_at: string | null;
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
type OfferId = Newtype<string, 'OfferId'>;
|
|
462
|
+
declare const OfferId: (value: string) => OfferId;
|
|
463
|
+
type OfferSlug = Newtype<string, 'OfferSlug'>;
|
|
464
|
+
declare const OfferSlug: (value: string) => OfferSlug;
|
|
465
|
+
type OfferType = OfferTypeDto;
|
|
466
|
+
type Offer = {
|
|
467
|
+
id: OfferId;
|
|
468
|
+
slug: OfferSlug;
|
|
469
|
+
type: OfferType;
|
|
470
|
+
tagline: string;
|
|
471
|
+
bannerUrl: string;
|
|
472
|
+
logoUrl: string;
|
|
473
|
+
startsAt: Date;
|
|
474
|
+
endsAt: Date | null;
|
|
475
|
+
};
|
|
476
|
+
declare const Offer: {
|
|
477
|
+
fromDto: (dto: OfferDto) => Offer;
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* The cursor-paginated envelope every list endpoint returns.
|
|
482
|
+
*
|
|
483
|
+
* Generic in its item type, so each resource pairs it with its own item DTO
|
|
484
|
+
* rather than declaring an envelope of its own.
|
|
485
|
+
*/
|
|
486
|
+
interface PaginatedResponseDto<T> {
|
|
487
|
+
data: T[];
|
|
488
|
+
starting_after?: string;
|
|
489
|
+
starting_before?: string;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
type Cursor = Newtype<string, 'Cursor'>;
|
|
493
|
+
declare const Cursor: (value: string) => Cursor;
|
|
494
|
+
interface PaginatedResponse<T> {
|
|
495
|
+
data: T[];
|
|
496
|
+
startingAfter: Cursor | null;
|
|
497
|
+
startingBefore: Cursor | null;
|
|
498
|
+
}
|
|
499
|
+
declare const PaginatedResponse: {
|
|
500
|
+
fromDto: <A, B>(dto: PaginatedResponseDto<A>, itemMapper: (item: A) => B) => PaginatedResponse<B>;
|
|
501
|
+
};
|
|
502
|
+
/**
|
|
503
|
+
* Cursor-based pagination input used when requesting paginated API resources.
|
|
504
|
+
* Set `after` or `before` to navigate relative to a known cursor, and `limit`
|
|
505
|
+
* to control the maximum number of returned items.
|
|
506
|
+
*/
|
|
507
|
+
interface PaginationParams {
|
|
508
|
+
before?: Cursor;
|
|
509
|
+
after?: Cursor;
|
|
510
|
+
limit?: number;
|
|
511
|
+
}
|
|
512
|
+
declare const PaginationParams: {
|
|
513
|
+
toQueryParams: (params: PaginationParams) => Record<string, QueryParamValue>;
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
type AssetDto = {
|
|
517
|
+
code: string;
|
|
518
|
+
fractional_digits: number;
|
|
519
|
+
id: string;
|
|
520
|
+
name: string;
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
type AssetId = Newtype<string, 'AssetId'>;
|
|
524
|
+
declare const AssetId: (value: string) => AssetId;
|
|
525
|
+
type AssetCode = Newtype<string, 'AssetCode'>;
|
|
526
|
+
declare const AssetCode: (value: string) => AssetCode;
|
|
527
|
+
type Asset = {
|
|
528
|
+
id: AssetId;
|
|
529
|
+
code: AssetCode;
|
|
530
|
+
name: string;
|
|
531
|
+
fractionalDigits: number;
|
|
532
|
+
};
|
|
533
|
+
declare const Asset: {
|
|
534
|
+
fromDto: (dto: AssetDto) => Asset;
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
type ParticipationStatusDto = 'prepared' | 'pending' | 'submitted' | 'completed' | 'failed' | 'remit_submitted' | 'remitted' | 'remit_failed';
|
|
538
|
+
type ParticipationDto = {
|
|
539
|
+
object: 'participation';
|
|
540
|
+
id: string;
|
|
541
|
+
offer_id: string;
|
|
542
|
+
offer_option_id: string;
|
|
543
|
+
status: ParticipationStatusDto;
|
|
544
|
+
amount: string;
|
|
545
|
+
amount_string: string;
|
|
546
|
+
asset: AssetDto;
|
|
547
|
+
chain: string;
|
|
548
|
+
inserted_at: string | null | undefined;
|
|
549
|
+
updated_at: string | null | undefined;
|
|
550
|
+
wallet_address: string | null | undefined;
|
|
551
|
+
};
|
|
552
|
+
type CreateParticipationDto = {
|
|
553
|
+
offer_id: string;
|
|
554
|
+
offer_option_id: string;
|
|
555
|
+
chain: string;
|
|
556
|
+
wallet_address: string;
|
|
557
|
+
amount: string;
|
|
558
|
+
asset_id: string;
|
|
559
|
+
approval_transaction_hash: string | null | undefined;
|
|
560
|
+
};
|
|
561
|
+
|
|
562
|
+
type OfferDetailDto = {
|
|
563
|
+
asset: AssetDto;
|
|
564
|
+
faqs: OfferDetailFaqDto[];
|
|
565
|
+
funding_assets: AssetDto[];
|
|
566
|
+
tokens: OfferDetailTokenDto[];
|
|
567
|
+
id: string;
|
|
568
|
+
links: OfferDetailLinkDto[];
|
|
569
|
+
milestones: OfferDetailMilestoneDto[];
|
|
570
|
+
name: string;
|
|
571
|
+
object: 'offer_details';
|
|
572
|
+
options: OfferDetailOptionDto[];
|
|
573
|
+
slug: string;
|
|
574
|
+
type: OfferTypeDto;
|
|
575
|
+
terms: OfferDetailTermDto[];
|
|
576
|
+
about: string | null | undefined;
|
|
577
|
+
banner_url: string;
|
|
578
|
+
category: string;
|
|
579
|
+
ends_at: string | null;
|
|
580
|
+
logo_url: string;
|
|
581
|
+
starts_at: string;
|
|
582
|
+
tagline: string;
|
|
583
|
+
};
|
|
584
|
+
type OfferDetailFaqDto = {
|
|
585
|
+
answer: string | null;
|
|
586
|
+
question: string | null;
|
|
587
|
+
};
|
|
588
|
+
type OfferDetailLinkDto = {
|
|
589
|
+
label: string | null;
|
|
590
|
+
url: string | null;
|
|
591
|
+
};
|
|
592
|
+
type OfferDetailMilestoneDto = {
|
|
593
|
+
name: string | null;
|
|
594
|
+
schedule: string | null;
|
|
595
|
+
status: 'completed' | 'active' | 'upcoming';
|
|
596
|
+
};
|
|
597
|
+
type OfferDetailOptionDto = {
|
|
598
|
+
bid_increment: number | null;
|
|
599
|
+
floor_price_usd: number | null;
|
|
600
|
+
id: string;
|
|
601
|
+
minimum_purchase_usd: number | null;
|
|
602
|
+
price_usd: string | null;
|
|
603
|
+
sale_agreement_url: string | null;
|
|
604
|
+
slug: string;
|
|
605
|
+
total_token_supply: number | null;
|
|
606
|
+
};
|
|
607
|
+
type OfferDetailTermDto = {
|
|
608
|
+
key: string | null;
|
|
609
|
+
value: string | null;
|
|
610
|
+
};
|
|
611
|
+
type OfferDetailTokenDto = {
|
|
612
|
+
role: 'funding' | 'distribution' | 'swap';
|
|
613
|
+
chain: string;
|
|
614
|
+
address: string;
|
|
615
|
+
};
|
|
616
|
+
|
|
617
|
+
type OfferOptionId = Newtype<string, 'OfferOptionId'>;
|
|
618
|
+
declare const OfferOptionId: (value: string) => OfferOptionId;
|
|
619
|
+
type OfferOptionSlug = Newtype<string, 'OfferOptionSlug'>;
|
|
620
|
+
declare const OfferOptionSlug: (value: string) => OfferOptionSlug;
|
|
621
|
+
type OfferDetail = {
|
|
622
|
+
id: OfferId;
|
|
623
|
+
slug: OfferSlug;
|
|
624
|
+
type: OfferType;
|
|
625
|
+
name: string;
|
|
626
|
+
asset: Asset;
|
|
627
|
+
fundingAssets: Asset[];
|
|
628
|
+
tokens: OfferToken[];
|
|
629
|
+
about: string | null;
|
|
630
|
+
tagline: string;
|
|
631
|
+
bannerUrl: string;
|
|
632
|
+
logoUrl: string;
|
|
633
|
+
category: string;
|
|
634
|
+
startsAt: Date;
|
|
635
|
+
endsAt: Date | null;
|
|
636
|
+
faqs: FaqItem[];
|
|
637
|
+
links: Link[];
|
|
638
|
+
milestones: Milestone[];
|
|
639
|
+
options: OfferOption[];
|
|
640
|
+
terms: TermItem[];
|
|
641
|
+
};
|
|
642
|
+
declare const OfferDetail: {
|
|
643
|
+
fromDto: (dto: OfferDetailDto) => OfferDetail;
|
|
644
|
+
};
|
|
645
|
+
type OfferOption = {
|
|
646
|
+
id: OfferOptionId;
|
|
647
|
+
slug: OfferOptionSlug;
|
|
648
|
+
bidIncrement: number | null;
|
|
649
|
+
floorPriceUsd: number | null;
|
|
650
|
+
minimumPurchaseUsd: number | null;
|
|
651
|
+
priceUsd: string | null;
|
|
652
|
+
saleAgreementUrl: string | null;
|
|
653
|
+
totalTokenSupply: number | null;
|
|
654
|
+
};
|
|
655
|
+
declare const OfferOption: {
|
|
656
|
+
fromDto: (dto: OfferDetailOptionDto) => OfferOption;
|
|
657
|
+
};
|
|
658
|
+
type FaqItem = {
|
|
659
|
+
question: string | null;
|
|
660
|
+
answer: string | null;
|
|
661
|
+
};
|
|
662
|
+
declare const FaqItem: {
|
|
663
|
+
fromDto: (dto: OfferDetailFaqDto) => FaqItem;
|
|
664
|
+
};
|
|
665
|
+
type Link = {
|
|
666
|
+
label: string | null;
|
|
667
|
+
url: string | null;
|
|
668
|
+
};
|
|
669
|
+
declare const Link: {
|
|
670
|
+
fromDto: (dto: OfferDetailLinkDto) => Link;
|
|
671
|
+
};
|
|
672
|
+
type TermItem = {
|
|
673
|
+
key: string | null;
|
|
674
|
+
value: string | null;
|
|
675
|
+
};
|
|
676
|
+
declare const TermItem: {
|
|
677
|
+
fromDto: (dto: OfferDetailTermDto) => TermItem;
|
|
678
|
+
};
|
|
679
|
+
type Milestone = {
|
|
680
|
+
name: string | null;
|
|
681
|
+
schedule: string | null;
|
|
682
|
+
status: 'completed' | 'active' | 'upcoming';
|
|
683
|
+
};
|
|
684
|
+
declare const Milestone: {
|
|
685
|
+
fromDto: (dto: OfferDetailMilestoneDto) => Milestone;
|
|
686
|
+
};
|
|
687
|
+
type TokenRole = 'funding' | 'distribution' | 'swap';
|
|
688
|
+
type OfferToken = {
|
|
689
|
+
role: TokenRole;
|
|
690
|
+
chain: Chain;
|
|
691
|
+
address: EvmContractAddress;
|
|
692
|
+
};
|
|
693
|
+
declare const OfferToken: {
|
|
694
|
+
fromDto: (dto: OfferDetailTokenDto) => OfferToken;
|
|
695
|
+
};
|
|
696
|
+
|
|
697
|
+
/** Unique identifier for a participation. */
|
|
698
|
+
type ParticipationId = Newtype<string, 'ParticipationId'>;
|
|
699
|
+
/** Casts a string into a typed {@link ParticipationId}. */
|
|
700
|
+
declare const ParticipationId: (value: string) => ParticipationId;
|
|
701
|
+
/** Blockchain identifier for where a participation is funded. */
|
|
702
|
+
type Blockchain = Newtype<string, 'Blockchain'>;
|
|
703
|
+
/** Casts a string into a typed {@link Blockchain}. */
|
|
704
|
+
declare const Blockchain: (value: string) => Blockchain;
|
|
705
|
+
/** Wallet address used for a participation. */
|
|
706
|
+
type WalletAddress = Newtype<`0x${string}`, 'WalletAddress'>;
|
|
707
|
+
/** Casts a `0x`-prefixed string into a typed {@link WalletAddress}. */
|
|
708
|
+
declare const WalletAddress: (value: `0x${string}`) => WalletAddress;
|
|
709
|
+
/** Possible participation lifecycle states returned by the API. */
|
|
710
|
+
type ParticipationStatus = ParticipationStatusDto;
|
|
711
|
+
/** Pagination params for listing participations, with an optional offer filter. */
|
|
712
|
+
interface ParticipationsPaginationParams extends PaginationParams {
|
|
713
|
+
offerId?: OfferId;
|
|
714
|
+
}
|
|
715
|
+
declare const ParticipationsPaginationParams: {
|
|
716
|
+
toQueryParams: (params: ParticipationsPaginationParams) => Record<string, QueryParamValue>;
|
|
717
|
+
};
|
|
718
|
+
/** Domain model for a participation returned by CoinList APIs. */
|
|
719
|
+
type Participation = {
|
|
720
|
+
/** Unique participation id. */
|
|
721
|
+
id: ParticipationId;
|
|
722
|
+
/** Parent offer id. */
|
|
723
|
+
offerId: OfferId;
|
|
724
|
+
/** Selected offer option id. */
|
|
725
|
+
offerOptionId: OfferOptionId;
|
|
726
|
+
/** Current processing status. */
|
|
727
|
+
status: ParticipationStatus;
|
|
728
|
+
/** Raw participation amount from API. */
|
|
729
|
+
amount: string;
|
|
730
|
+
/** Human-readable formatted amount from API. */
|
|
731
|
+
displayAmount: string;
|
|
732
|
+
/** Asset metadata for the participation amount. */
|
|
733
|
+
asset: Asset;
|
|
734
|
+
/** Funding chain identifier. */
|
|
735
|
+
chain: Blockchain;
|
|
736
|
+
/** Creation timestamp, if returned by API. */
|
|
737
|
+
insertedAt: Date | null;
|
|
738
|
+
/** Last update timestamp, if returned by API. */
|
|
739
|
+
updatedAt: Date | null;
|
|
740
|
+
/** Wallet used for participation, blank values normalized to null. */
|
|
741
|
+
walletAddress: WalletAddress | null;
|
|
742
|
+
};
|
|
743
|
+
declare const Participation: {
|
|
744
|
+
/** Maps API DTO shape into the SDK participation domain model. */
|
|
745
|
+
fromDto: (dto: ParticipationDto) => Participation;
|
|
746
|
+
};
|
|
747
|
+
/** Parameters required to create a new participation. */
|
|
748
|
+
type CreateParticipationParams = {
|
|
749
|
+
/** Offer to participate in. */
|
|
750
|
+
offerId: OfferId;
|
|
751
|
+
/** Offer option selected for participation. */
|
|
752
|
+
offerOptionId: OfferOptionId;
|
|
753
|
+
/** Blockchain for funding. */
|
|
754
|
+
chain: Blockchain;
|
|
755
|
+
/** Wallet address that funds the participation. */
|
|
756
|
+
walletAddress: WalletAddress;
|
|
757
|
+
/**
|
|
758
|
+
* Decimal token amount to participate with (e.g. `"100"` for 100 USDC), NOT
|
|
759
|
+
* raw base units. The backend rescales this by the asset's decimals to verify
|
|
760
|
+
* it against the on-chain approval allowance.
|
|
761
|
+
*/
|
|
762
|
+
amount: string;
|
|
763
|
+
/** Funding asset id. */
|
|
764
|
+
assetId: AssetId;
|
|
765
|
+
/**
|
|
766
|
+
* Hash of the ERC-20 `approve()` transaction covering this participation.
|
|
767
|
+
* Required: the backend verifies it on-chain (sender, token, spender, and
|
|
768
|
+
* approved amount) before confirming the participation.
|
|
769
|
+
*/
|
|
770
|
+
approvalTransactionHash: string;
|
|
771
|
+
};
|
|
772
|
+
declare const CreateParticipationParams: {
|
|
773
|
+
/** Maps participation creation params into API DTO payload. */
|
|
774
|
+
toDto: (params: CreateParticipationParams) => CreateParticipationDto;
|
|
775
|
+
};
|
|
776
|
+
|
|
777
|
+
/**
|
|
778
|
+
* Read/write operations for token sales: listing and reading the current user's
|
|
779
|
+
* participations, and recording a new one. The on-chain execution flow
|
|
780
|
+
* (`executeTokenSale`) is layered on top of this in the client-side namespace.
|
|
781
|
+
*/
|
|
782
|
+
interface CoinListTokenSaleNamespace {
|
|
783
|
+
/**
|
|
784
|
+
* Fetches all participations by iterating through every paginated response,
|
|
785
|
+
* optionally filtered by offer.
|
|
786
|
+
*
|
|
787
|
+
* Requires an authenticated user; throws {@link NotAuthenticatedError}
|
|
788
|
+
* otherwise.
|
|
789
|
+
*/
|
|
790
|
+
list(offerId?: OfferId): Promise<Participation[]>;
|
|
791
|
+
/**
|
|
792
|
+
* Fetches a single page of participations, optionally filtered by offer.
|
|
793
|
+
*
|
|
794
|
+
* Requires an authenticated user; throws {@link NotAuthenticatedError}
|
|
795
|
+
* otherwise.
|
|
796
|
+
*/
|
|
797
|
+
listPage(params: ParticipationsPaginationParams): Promise<PaginatedResponse<Participation>>;
|
|
798
|
+
/**
|
|
799
|
+
* Fetches a participation by id.
|
|
800
|
+
*
|
|
801
|
+
* Requires an authenticated user; throws {@link NotAuthenticatedError}
|
|
802
|
+
* otherwise.
|
|
803
|
+
*/
|
|
804
|
+
get(id: ParticipationId): Promise<Participation>;
|
|
805
|
+
/**
|
|
806
|
+
* Records a participation with CoinList.
|
|
807
|
+
*
|
|
808
|
+
* Requires an authenticated user; throws {@link NotAuthenticatedError}
|
|
809
|
+
* otherwise.
|
|
810
|
+
*/
|
|
811
|
+
createParticipation(params: CreateParticipationParams): Promise<Participation>;
|
|
812
|
+
}
|
|
813
|
+
declare class CoinListTokenSaleNamespaceImpl implements CoinListTokenSaleNamespace {
|
|
814
|
+
private readonly ctx;
|
|
815
|
+
constructor(ctx: SharedNamespaceContext);
|
|
816
|
+
list(offerId?: OfferId): Promise<Participation[]>;
|
|
817
|
+
listPage(params: ParticipationsPaginationParams): Promise<PaginatedResponse<Participation>>;
|
|
818
|
+
get(id: ParticipationId): Promise<Participation>;
|
|
819
|
+
createParticipation(params: CreateParticipationParams): Promise<Participation>;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
type Ticker = Newtype<string, 'Ticker'>;
|
|
823
|
+
declare const Ticker: (value: string) => Ticker;
|
|
824
|
+
type OrderBookSide = 'buy' | 'sell';
|
|
825
|
+
|
|
826
|
+
/**
|
|
827
|
+
* No `chain` on the read params: Ondo runs no sandbox, so every environment
|
|
828
|
+
* prices against Ondo production on Ethereum mainnet. Accepting a chain would
|
|
829
|
+
* let a caller ask for Sepolia and silently receive mainnet pricing.
|
|
830
|
+
* {@link BuildOndoSwapTransactionParams} is the exception, and says why.
|
|
831
|
+
*/
|
|
832
|
+
type GetOndoTradingStatusParams = {
|
|
833
|
+
symbol: AssetSymbol;
|
|
834
|
+
/**
|
|
835
|
+
* Required, and deliberately not defaulted: `tradable` and both order caps
|
|
836
|
+
* describe this side only. Guessing `buy` would hand buy caps to someone
|
|
837
|
+
* sizing a sell. The endpoint answers 422 without it.
|
|
838
|
+
*/
|
|
839
|
+
side: OrderBookSide;
|
|
840
|
+
};
|
|
841
|
+
/** How long Ondo should hold the price. Omit to take Ondo's own default. */
|
|
842
|
+
type OndoQuoteDuration = 'short' | 'long';
|
|
843
|
+
/**
|
|
844
|
+
* A quote is sized by the quantity or by the dollar amount. The endpoint takes
|
|
845
|
+
* exactly one; `getOndoQuote` sends whichever is present.
|
|
846
|
+
*/
|
|
847
|
+
type OndoQuoteSize = {
|
|
848
|
+
tokenAmount: BlockchainAmount;
|
|
849
|
+
} | {
|
|
850
|
+
notionalValue: DecimalString;
|
|
851
|
+
};
|
|
852
|
+
type GetOndoQuoteParams = {
|
|
853
|
+
symbol: AssetSymbol;
|
|
854
|
+
side: OrderBookSide;
|
|
855
|
+
duration?: OndoQuoteDuration;
|
|
856
|
+
} & OndoQuoteSize;
|
|
857
|
+
/**
|
|
858
|
+
* What it takes to turn an indicative price into signed, fillable calldata.
|
|
859
|
+
*
|
|
860
|
+
* Sized by `amount` alone - the coin being spent, in its own base units - with
|
|
861
|
+
* no `notionalValue` alternative: the calldata authorises a specific ERC-20
|
|
862
|
+
* pull, so the number that ends up on chain has to be the number the caller
|
|
863
|
+
* meant, not one derived from a dollar figure. It is the **gross**: CoinList's
|
|
864
|
+
* fee comes off it, and Ondo prices the remainder.
|
|
865
|
+
*
|
|
866
|
+
* Buy-only, so there is no `side`. There is no funding token either - frontline
|
|
867
|
+
* resolves both tokens from the offer, because Ninshubur signs a request bound
|
|
868
|
+
* to them and a caller that could name them could have CoinList sign for a
|
|
869
|
+
* contract of its own.
|
|
870
|
+
*
|
|
871
|
+
* `chain` is required here although the read params refuse it, because this
|
|
872
|
+
* one names a real contract on a real chain rather than asking Ondo for a
|
|
873
|
+
* price. `walletAddress` must be the wallet that will *send* the transaction:
|
|
874
|
+
* the calldata is signed over it, so a transaction built for one wallet and
|
|
875
|
+
* broadcast by another reverts.
|
|
876
|
+
*/
|
|
877
|
+
type BuildOndoSwapTransactionParams = {
|
|
878
|
+
symbol: AssetSymbol;
|
|
879
|
+
chain: EthereumChain;
|
|
880
|
+
/** The wallet that will broadcast, and that receives the asset. */
|
|
881
|
+
walletAddress: EvmWalletAddress;
|
|
882
|
+
/**
|
|
883
|
+
* The gross amount to spend, in the funding token's base units.
|
|
884
|
+
*
|
|
885
|
+
* Its `decimals` are also what the response's `pay_input_decimals` is
|
|
886
|
+
* checked against: frontline resolves the funding token from the offer
|
|
887
|
+
* rather than from this request, so the two are independent answers to the
|
|
888
|
+
* same question and a disagreement means the wrong token was sized.
|
|
889
|
+
*/
|
|
890
|
+
amount: BlockchainAmount;
|
|
891
|
+
};
|
|
892
|
+
|
|
893
|
+
/**
|
|
894
|
+
* Raw JSON models for the Ondo swap endpoints, mirroring
|
|
895
|
+
* `OndoSwapTradingStatus`, `OndoSwapQuote` and `OndoSwapTransaction` in
|
|
896
|
+
* frontline's OpenAPI schema. The two GETs are free to poll: neither spends an
|
|
897
|
+
* attestation, so a client may call them while the user edits an order. The
|
|
898
|
+
* POST ({@link OndoSwapTransactionDto}) is not - it spends one and hands back
|
|
899
|
+
* signed calldata with a deadline.
|
|
900
|
+
*
|
|
901
|
+
* Neither GET takes a `chain`. Ondo runs no sandbox, so every environment
|
|
902
|
+
* prices against Ondo production on Ethereum mainnet. The POST does carry one:
|
|
903
|
+
* it targets a real contract, which on every environment but production is the
|
|
904
|
+
* Sepolia one with the mocked attestation.
|
|
905
|
+
*/
|
|
906
|
+
/**
|
|
907
|
+
* Whether an asset can be traded right now, and the caps if so.
|
|
908
|
+
*
|
|
909
|
+
* Every cap is a *human decimal* string and is nullable — Ondo answers a
|
|
910
|
+
* restricted `/v1/limits/*` with a 403, which frontline turns into
|
|
911
|
+
* `tradable: false` and three nulls rather than an error. A null cap therefore
|
|
912
|
+
* means **Ondo restricted the asset, not that the cap is unlimited**. The
|
|
913
|
+
* response carries no `asset_decimals`, so there is nothing to scale
|
|
914
|
+
* `gross_max_tokens` by.
|
|
915
|
+
*
|
|
916
|
+
* There is no `reason` field. A restriction surfaces only as `tradable: false`
|
|
917
|
+
* plus the nulls; frontline keeps Ondo's reason codes to its own admin surface
|
|
918
|
+
* and does not forward them.
|
|
919
|
+
*/
|
|
920
|
+
type OndoTradingStatusDto = {
|
|
921
|
+
object: 'ondo_swap_trading_status';
|
|
922
|
+
/** The `side` the request asked for, echoed back. */
|
|
923
|
+
side: 'buy' | 'sell';
|
|
924
|
+
/** For `side` only — an asset can be sellable while not buyable. */
|
|
925
|
+
tradable: boolean;
|
|
926
|
+
/** Whole tokens, for `side` only. E.g. `"100.000000000000000000"`. */
|
|
927
|
+
gross_max_tokens: string | null;
|
|
928
|
+
/** USD, for `side` only. E.g. `"1234.560000000000000000"`. */
|
|
929
|
+
gross_max_notional_value: string | null;
|
|
930
|
+
/**
|
|
931
|
+
* USD cap for the session the market is currently in, e.g. `"200000"`.
|
|
932
|
+
* Unlike the two above this comes from Ondo's sideless session endpoint, so
|
|
933
|
+
* it applies across buys and sells together.
|
|
934
|
+
*/
|
|
935
|
+
gross_max_active_notional_value: string | null;
|
|
936
|
+
};
|
|
937
|
+
/** An indicative, size- and side-aware price for an Ondo asset. */
|
|
938
|
+
type OndoQuoteDto = {
|
|
939
|
+
object: 'ondo_swap_quote';
|
|
940
|
+
/** EIP-155 chain id. Always `"1"`, per the no-sandbox note above. */
|
|
941
|
+
chain_id: string;
|
|
942
|
+
symbol: string;
|
|
943
|
+
/** Ticker of the underlying security, e.g. `"AAPL"` for `"AAPLon"`. */
|
|
944
|
+
ticker: string;
|
|
945
|
+
asset_address: string;
|
|
946
|
+
/** Decimals of the `asset_address` contract. Scales `token_base_units`. */
|
|
947
|
+
asset_decimals: number;
|
|
948
|
+
side: 'buy' | 'sell';
|
|
949
|
+
/**
|
|
950
|
+
* Quantity of the asset in its smallest unit, as a raw uint256 string:
|
|
951
|
+
* `"5000000000000000000"` is 5 tokens at 18 decimals. Map it with
|
|
952
|
+
* `blockchainAmountFromRawOrThrow`, not `parseBlockchainAmountOrThrow`.
|
|
953
|
+
*
|
|
954
|
+
* Not to be confused with the `token_amount` *request* parameter, which is
|
|
955
|
+
* the same quantity in whole tokens. Ondo names both `tokenAmount`, 1e18
|
|
956
|
+
* apart, so echoing one back as the other is a real hazard.
|
|
957
|
+
*/
|
|
958
|
+
token_base_units: string;
|
|
959
|
+
/**
|
|
960
|
+
* USD price of one whole token as a human decimal string, e.g.
|
|
961
|
+
* `"225.273151158540753535"`. Already scaled, so it needs none of the
|
|
962
|
+
* handling `token_base_units` does.
|
|
963
|
+
*/
|
|
964
|
+
price: string;
|
|
965
|
+
};
|
|
966
|
+
/**
|
|
967
|
+
* Signed, ready-to-broadcast calldata for a buy, and the amounts it commits
|
|
968
|
+
* to: `POST /v1/ondo/swap/transaction`.
|
|
969
|
+
*
|
|
970
|
+
* Unlike {@link OndoQuoteDto} this **spends an attestation**, so it is not
|
|
971
|
+
* pollable: one call per order, plus one per user-requested refresh. Frontline
|
|
972
|
+
* also reads the wallet's allowance before asking Ninshubur for anything, so
|
|
973
|
+
* an unapproved wallet is refused here rather than reverting on chain.
|
|
974
|
+
*
|
|
975
|
+
* Buy-only. There is no `side`: the funding token goes in and the asset comes
|
|
976
|
+
* out, both resolved from the offer, so a caller cannot name either.
|
|
977
|
+
*
|
|
978
|
+
* **Carries no identity and no price.** No `chain_id`, `symbol`, `ticker`,
|
|
979
|
+
* `side` or `price` - the request named the first few and frontline drops
|
|
980
|
+
* Ninshubur's `price` deliberately, because `GET /v1/ondo/swap/quote` already
|
|
981
|
+
* publishes one under that name at a different scale. Anything the UI needs
|
|
982
|
+
* beyond the amounts comes from that GET or from the offer.
|
|
983
|
+
*
|
|
984
|
+
* Every amount is a uint256 decimal string in one of two scales, and **both
|
|
985
|
+
* scales are on the wire**: `receive_output_amount` is in
|
|
986
|
+
* `receive_output_decimals`, and the other three are in
|
|
987
|
+
* `pay_input_decimals`. Neither is interchangeable with the quote's
|
|
988
|
+
* `asset_decimals`, which answers for a different number - see the two fields
|
|
989
|
+
* below.
|
|
990
|
+
*
|
|
991
|
+
* The response has no `object` envelope. `action` says what to do with the
|
|
992
|
+
* body, matching `AllowWalletResponseDto`.
|
|
993
|
+
*/
|
|
994
|
+
type OndoSwapTransactionDto = {
|
|
995
|
+
action: 'broadcast_transaction';
|
|
996
|
+
/** The swap contract the transaction is sent to. */
|
|
997
|
+
to: string;
|
|
998
|
+
/** ABI-encoded `swap(...)` calldata. Broadcast verbatim - never re-encode it. */
|
|
999
|
+
data: string;
|
|
1000
|
+
/**
|
|
1001
|
+
* When the signed calldata stops being accepted - RFC3339, e.g.
|
|
1002
|
+
* `"2026-08-13T23:04:12Z"`. This is Ninshubur's `expiration`, which signs
|
|
1003
|
+
* the same instant as the EIP-712 `deadline` in the calldata, so a
|
|
1004
|
+
* transaction broadcast after it reverts.
|
|
1005
|
+
*/
|
|
1006
|
+
expires_at: string;
|
|
1007
|
+
/**
|
|
1008
|
+
* Gross amount the wallet pays, echoing the requested `amount`, in the
|
|
1009
|
+
* funding token's smallest unit. The approval is compared against this.
|
|
1010
|
+
*/
|
|
1011
|
+
pay_input_amount: string;
|
|
1012
|
+
/**
|
|
1013
|
+
* Decimals `pay_input_amount`, `fee` and `notional_value` are counted in.
|
|
1014
|
+
*
|
|
1015
|
+
* Frontline reads it on-chain from the funding token, which it resolves from
|
|
1016
|
+
* the offer rather than from anything the caller sent. That makes it the
|
|
1017
|
+
* only published scale for a token the request never names - and an
|
|
1018
|
+
* independent answer to the one the SDK derived when it sized the order,
|
|
1019
|
+
* which is why `buildOndoSwapTransaction` compares the two.
|
|
1020
|
+
*/
|
|
1021
|
+
pay_input_decimals: number;
|
|
1022
|
+
/**
|
|
1023
|
+
* CoinList's cut of `pay_input_amount`, in the same units. Taken off the
|
|
1024
|
+
* deposit rather than added on top, so the approval never has to cover more.
|
|
1025
|
+
* `"0"` until ENG-1718 turns a fee on - frontline rejects a non-zero one
|
|
1026
|
+
* today.
|
|
1027
|
+
*/
|
|
1028
|
+
fee: string;
|
|
1029
|
+
/**
|
|
1030
|
+
* `pay_input_amount` less `fee`, in the same units. This is the amount Ondo
|
|
1031
|
+
* actually priced, and the numerator of the fill price.
|
|
1032
|
+
*/
|
|
1033
|
+
notional_value: string;
|
|
1034
|
+
/**
|
|
1035
|
+
* Quantity of the asset the wallet receives, in the *asset's* smallest unit,
|
|
1036
|
+
* e.g. `"264000000000000000"`. Scale it by `receive_output_decimals`, not by
|
|
1037
|
+
* the funding token's and not by {@link OndoQuoteDto}'s `asset_decimals`.
|
|
1038
|
+
*/
|
|
1039
|
+
receive_output_amount: string;
|
|
1040
|
+
/**
|
|
1041
|
+
* Decimals `receive_output_amount` is counted in.
|
|
1042
|
+
*
|
|
1043
|
+
* Reported by whatever priced the quantity, rather than looked up from the
|
|
1044
|
+
* asset. That is not the same number as {@link OndoQuoteDto}'s
|
|
1045
|
+
* `asset_decimals`, which frontline resolves from its own catalogue: the two
|
|
1046
|
+
* are allowed to disagree, and only this one answers for the quantity in
|
|
1047
|
+
* this response.
|
|
1048
|
+
*/
|
|
1049
|
+
receive_output_decimals: number;
|
|
1050
|
+
};
|
|
1051
|
+
|
|
1052
|
+
/**
|
|
1053
|
+
* Whether an Ondo asset can be traded right now.
|
|
1054
|
+
*
|
|
1055
|
+
* The caps only mean anything while trading is open, so they live on the
|
|
1056
|
+
* `tradable` branch. They stay {@link DecimalString} rather than
|
|
1057
|
+
* {@link BlockchainAmount} because the response carries no `asset_decimals`:
|
|
1058
|
+
* there is no honest exponent to attach, and the USD caps arrive with more
|
|
1059
|
+
* fractional digits than a stablecoin has decimals.
|
|
1060
|
+
*
|
|
1061
|
+
* Each cap is independently nullable even when tradable — Ondo may open an
|
|
1062
|
+
* asset for trading without publishing every limit.
|
|
1063
|
+
*
|
|
1064
|
+
* `side` is carried through from the response rather than dropped: the whole
|
|
1065
|
+
* status describes one side, so a buy and a sell status are otherwise
|
|
1066
|
+
* indistinguishable once a caller holds both.
|
|
1067
|
+
*/
|
|
1068
|
+
type OndoTradingStatus = {
|
|
1069
|
+
type: 'tradable';
|
|
1070
|
+
side: OrderBookSide;
|
|
1071
|
+
/** Largest order in whole tokens. */
|
|
1072
|
+
grossMaxTokens: DecimalString | null;
|
|
1073
|
+
/** Largest order in USD. */
|
|
1074
|
+
grossMaxNotionalValue: DecimalString | null;
|
|
1075
|
+
/** USD cap for the session the market is currently in. */
|
|
1076
|
+
grossMaxActiveNotionalValue: DecimalString | null;
|
|
1077
|
+
} | {
|
|
1078
|
+
type: 'not-tradable';
|
|
1079
|
+
side: OrderBookSide;
|
|
1080
|
+
};
|
|
1081
|
+
declare const OndoTradingStatus: {
|
|
1082
|
+
fromDto: (dto: OndoTradingStatusDto) => OndoTradingStatus;
|
|
1083
|
+
};
|
|
1084
|
+
/**
|
|
1085
|
+
* An indicative price for an Ondo asset, free to poll while the user edits an
|
|
1086
|
+
* order.
|
|
1087
|
+
*
|
|
1088
|
+
* **No CoinList fee is applied to the quantity or the price.** Ondo prices
|
|
1089
|
+
* exactly the amount asked for. A CoinList approval is fee-inclusive, so
|
|
1090
|
+
* sizing a quote against one without netting the fee first overstates what the
|
|
1091
|
+
* user receives. Showing a gross/net breakdown needs a CoinList swap
|
|
1092
|
+
* contract's `preview`, and no such contract exists for Ondo yet.
|
|
1093
|
+
*
|
|
1094
|
+
* The quote carries no transaction to broadcast and no expiry. Building one is
|
|
1095
|
+
* a separate endpoint that spends an attestation - see
|
|
1096
|
+
* {@link OndoSwapTransaction}.
|
|
1097
|
+
*/
|
|
1098
|
+
type OndoQuote = {
|
|
1099
|
+
/** Always `ethereum_mainnet`: Ondo runs no sandbox in any environment. */
|
|
1100
|
+
chain: EthereumChain;
|
|
1101
|
+
ticker: Ticker;
|
|
1102
|
+
/** Needed to approve or transfer the asset; the quote is the only source. */
|
|
1103
|
+
assetAddress: EvmContractAddress;
|
|
1104
|
+
/**
|
|
1105
|
+
* The asset as the quote resolves it, from frontline's own catalogue.
|
|
1106
|
+
*
|
|
1107
|
+
* Its `decimals` scale {@link tokenBaseUnits} and nothing else. They are
|
|
1108
|
+
* **not** the scale of an {@link OndoSwapTransaction}'s output: that one is
|
|
1109
|
+
* reported by whatever priced the quantity, the two sources are allowed to
|
|
1110
|
+
* disagree, and only the one that produced a number answers for it.
|
|
1111
|
+
*/
|
|
1112
|
+
asset: Erc20Asset;
|
|
1113
|
+
side: OrderBookSide;
|
|
1114
|
+
tokenBaseUnits: BlockchainAmount;
|
|
1115
|
+
/**
|
|
1116
|
+
* USD price of one whole token. Unscaled because Ondo has already scaled it,
|
|
1117
|
+
* and by USDon's 18 decimals rather than the stablecoin's 6 — re-scaling it
|
|
1118
|
+
* by either would be wrong.
|
|
1119
|
+
*/
|
|
1120
|
+
price: DecimalString;
|
|
1121
|
+
};
|
|
1122
|
+
declare const OndoQuote: {
|
|
1123
|
+
fromDto: (dto: OndoQuoteDto) => OndoQuote;
|
|
1124
|
+
};
|
|
1125
|
+
/**
|
|
1126
|
+
* A signed, expiring buy: the calldata that fills it and the amounts it
|
|
1127
|
+
* commits to, from `buildSwapTransaction`.
|
|
1128
|
+
*
|
|
1129
|
+
* Distinct from {@link OndoQuote} in three ways that matter: it costs an
|
|
1130
|
+
* attestation to obtain, it expires, and it carries a {@link Tx} the wallet
|
|
1131
|
+
* broadcasts verbatim. Treat it as single-use - once broadcast (or once
|
|
1132
|
+
* `expiresAt` passes) it is spent, and a new one must be built.
|
|
1133
|
+
*
|
|
1134
|
+
* **It carries no identity.** No chain, ticker, asset or side: the endpoint
|
|
1135
|
+
* publishes none of them, and inventing them from the request would assert
|
|
1136
|
+
* what the server resolved rather than report it. What it does publish is the
|
|
1137
|
+
* scale of every amount on it, so a caller needs nothing alongside it to read
|
|
1138
|
+
* the numbers - only to name the asset, which the offer already does.
|
|
1139
|
+
*
|
|
1140
|
+
* It carries no price either. Divide {@link notionalValue} by
|
|
1141
|
+
* {@link receiveOutputAmount} - see `computeOndoPrice` - which is the price
|
|
1142
|
+
* this transaction actually fills at rather than an indicative one that has
|
|
1143
|
+
* since moved.
|
|
1144
|
+
*/
|
|
1145
|
+
type OndoSwapTransaction = {
|
|
1146
|
+
/**
|
|
1147
|
+
* Broadcast as-is. The `to` is the swap contract, which is also the ERC-20
|
|
1148
|
+
* spender the user must have approved.
|
|
1149
|
+
*/
|
|
1150
|
+
tx: Tx;
|
|
1151
|
+
/**
|
|
1152
|
+
* When the calldata stops being accepted. A transaction broadcast after this
|
|
1153
|
+
* reverts, so callers must compare against it before signing.
|
|
1154
|
+
*/
|
|
1155
|
+
expiresAt: Date;
|
|
1156
|
+
/** Gross amount the wallet pays, in the funding token's decimals. */
|
|
1157
|
+
payInputAmount: BlockchainAmount;
|
|
1158
|
+
/**
|
|
1159
|
+
* CoinList's cut of {@link payInputAmount}, in the same decimals. Taken off
|
|
1160
|
+
* the deposit rather than added on top, so the approval never has to cover
|
|
1161
|
+
* more than `payInputAmount`. Zero until ENG-1718 lands.
|
|
1162
|
+
*/
|
|
1163
|
+
fee: BlockchainAmount;
|
|
1164
|
+
/**
|
|
1165
|
+
* `payInputAmount` less `fee`, in the same decimals: what Ondo priced.
|
|
1166
|
+
*
|
|
1167
|
+
* Read from the response rather than subtracted here. Whether the fee comes
|
|
1168
|
+
* off the deposit or goes on top of it is the server's definition to change,
|
|
1169
|
+
* and a client that derives this cannot notice when it does.
|
|
1170
|
+
*/
|
|
1171
|
+
notionalValue: BlockchainAmount;
|
|
1172
|
+
/**
|
|
1173
|
+
* What the buyer receives, at the scale whatever priced the quantity
|
|
1174
|
+
* reported - not at the {@link OndoQuote}'s.
|
|
1175
|
+
*/
|
|
1176
|
+
receiveOutputAmount: BlockchainAmount;
|
|
1177
|
+
};
|
|
1178
|
+
declare const OndoSwapTransaction: {
|
|
1179
|
+
fromDto: (dto: OndoSwapTransactionDto) => OndoSwapTransaction;
|
|
1180
|
+
};
|
|
1181
|
+
|
|
1182
|
+
/**
|
|
1183
|
+
* Ondo swap reads, plus the write that turns one into a fillable transaction.
|
|
1184
|
+
*
|
|
1185
|
+
* The two reads are free to poll - neither spends an attestation, so a client
|
|
1186
|
+
* may call them while the user edits an order. {@link buildSwapTransaction} is
|
|
1187
|
+
* not: budget one call per order placed, plus one per refresh the user asks
|
|
1188
|
+
* for.
|
|
1189
|
+
*
|
|
1190
|
+
* **No CoinList fee is applied to a read quote, and no read discloses one.**
|
|
1191
|
+
* Ondo prices exactly the amount passed. A CoinList approval is fee-inclusive,
|
|
1192
|
+
* so sizing a quote against a user's approval without subtracting the fee
|
|
1193
|
+
* first overstates what they receive. A built transaction carries the fee
|
|
1194
|
+
* explicitly, and it is zero until one lands (ENG-1718).
|
|
1195
|
+
*
|
|
1196
|
+
* Every method requires `AuthState === 'logged-in'` and throws
|
|
1197
|
+
* {@link NotAuthenticatedError} otherwise.
|
|
1198
|
+
*/
|
|
1199
|
+
interface OndoNamespace {
|
|
1200
|
+
getTradingStatus(params: GetOndoTradingStatusParams): Promise<OndoTradingStatus>;
|
|
1201
|
+
getQuote(params: GetOndoQuoteParams): Promise<OndoQuote>;
|
|
1202
|
+
/**
|
|
1203
|
+
* Builds the buy for a specific wallet and amount: spends an attestation and
|
|
1204
|
+
* returns calldata to broadcast, valid until
|
|
1205
|
+
* {@link OndoSwapTransaction.expiresAt}.
|
|
1206
|
+
*
|
|
1207
|
+
* The wallet must have approved the swap contract to spend `amount` of the
|
|
1208
|
+
* offer's funding token first - frontline reads the allowance before asking
|
|
1209
|
+
* Ninshubur for anything, and rejects a short one with a 422 carrying
|
|
1210
|
+
* `code: "insufficient_allowance"`. See `prepareSwap` on the client
|
|
1211
|
+
* namespace, which approves and then builds, in that order.
|
|
1212
|
+
*
|
|
1213
|
+
* Buy-only, and the tokens are the offer's rather than the caller's to name.
|
|
1214
|
+
*/
|
|
1215
|
+
buildSwapTransaction(params: BuildOndoSwapTransactionParams): Promise<OndoSwapTransaction>;
|
|
1216
|
+
}
|
|
1217
|
+
declare class OndoNamespaceImpl implements OndoNamespace {
|
|
1218
|
+
private readonly ctx;
|
|
1219
|
+
constructor(ctx: SharedNamespaceContext);
|
|
1220
|
+
getTradingStatus(params: GetOndoTradingStatusParams): Promise<OndoTradingStatus>;
|
|
1221
|
+
getQuote(params: GetOndoQuoteParams): Promise<OndoQuote>;
|
|
1222
|
+
buildSwapTransaction(params: BuildOndoSwapTransactionParams): Promise<OndoSwapTransaction>;
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
/** Parameters shared by contract reads scoped to a chain. */
|
|
1226
|
+
type SwapContractRef = {
|
|
1227
|
+
contractAddress: EvmContractAddress;
|
|
1228
|
+
chain: EthereumChain;
|
|
1229
|
+
};
|
|
1230
|
+
type GetSwapAuthorizationParams = SwapContractRef & {
|
|
1231
|
+
walletAddress: EvmWalletAddress;
|
|
1232
|
+
};
|
|
1233
|
+
type GetSwapPreviewParams = SwapContractRef & {
|
|
1234
|
+
inputToken: EvmContractAddress;
|
|
1235
|
+
amount: bigint;
|
|
1236
|
+
};
|
|
1237
|
+
type AllowWalletParams = {
|
|
1238
|
+
offerId: OfferId;
|
|
1239
|
+
walletAddress: EvmWalletAddress;
|
|
1240
|
+
chain: EthereumChain;
|
|
1241
|
+
signature: string;
|
|
1242
|
+
};
|
|
1243
|
+
|
|
1244
|
+
/**
|
|
1245
|
+
* Read/write operations for the on-chain swap flow: quoting a swap, inspecting
|
|
1246
|
+
* contract state, checking token allowances, and proving/allow-listing wallet
|
|
1247
|
+
* ownership.
|
|
1248
|
+
*/
|
|
1249
|
+
interface SuperstateSwapNamespace {
|
|
1250
|
+
/**
|
|
1251
|
+
* Checks whether a wallet is authorized to swap against the given contract.
|
|
1252
|
+
*/
|
|
1253
|
+
getAuthorization(params: GetSwapAuthorizationParams): Promise<SwapAuthorization>;
|
|
1254
|
+
/**
|
|
1255
|
+
* Fetches a read-only quote for swapping `amount` of `inputToken`.
|
|
1256
|
+
*/
|
|
1257
|
+
getPreview(params: GetSwapPreviewParams): Promise<SwapPreview>;
|
|
1258
|
+
/**
|
|
1259
|
+
* Reads the current on-chain state of a swap contract.
|
|
1260
|
+
*/
|
|
1261
|
+
getStatus(params: SwapContractRef): Promise<SwapStatus>;
|
|
1262
|
+
/**
|
|
1263
|
+
* Reads the ERC-20 output token a swap contract pays out.
|
|
1264
|
+
*/
|
|
1265
|
+
getOutputToken(params: SwapContractRef): Promise<Erc20Asset>;
|
|
1266
|
+
/**
|
|
1267
|
+
* Submits a signed wallet-ownership challenge to allow-list the wallet for
|
|
1268
|
+
* an offer, identified by its offer id. Obtain the challenge from
|
|
1269
|
+
* `WalletsNamespace.createOwnershipChallenge`.
|
|
1270
|
+
*/
|
|
1271
|
+
allowWallet(params: AllowWalletParams): Promise<AllowWalletResponse>;
|
|
1272
|
+
}
|
|
1273
|
+
declare class SuperstateSwapNamespaceImpl implements SuperstateSwapNamespace {
|
|
1274
|
+
private readonly ctx;
|
|
1275
|
+
constructor(ctx: SharedNamespaceContext);
|
|
1276
|
+
getAuthorization(params: GetSwapAuthorizationParams): Promise<SwapAuthorization>;
|
|
1277
|
+
getPreview(params: GetSwapPreviewParams): Promise<SwapPreview>;
|
|
1278
|
+
getStatus(params: SwapContractRef): Promise<SwapStatus>;
|
|
1279
|
+
getOutputToken(params: SwapContractRef): Promise<Erc20Asset>;
|
|
1280
|
+
allowWallet(params: AllowWalletParams): Promise<AllowWalletResponse>;
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
/** Request body for `POST /v1/offers/:offer_id/addresses`. */
|
|
1284
|
+
type CreateOfferOptionAddressDto = {
|
|
1285
|
+
offer_option_id: string;
|
|
1286
|
+
wallet_address: string;
|
|
1287
|
+
chain: string;
|
|
1288
|
+
signature: string;
|
|
1289
|
+
};
|
|
1290
|
+
/** Binding object returned by the `/v1/offers/:offer_id/addresses` resource. */
|
|
1291
|
+
type OfferOptionAddressDto = {
|
|
1292
|
+
id: string;
|
|
1293
|
+
offer_option_id: string;
|
|
1294
|
+
address: string;
|
|
1295
|
+
protocol: WalletProtocol;
|
|
1296
|
+
created_at: string;
|
|
1297
|
+
};
|
|
1298
|
+
|
|
1299
|
+
/** Unique identifier for a proven wallet binding on an offer option. */
|
|
1300
|
+
type OfferOptionAddressId = Newtype<string, 'OfferOptionAddressId'>;
|
|
1301
|
+
/** Casts a string into a typed {@link OfferOptionAddressId}. */
|
|
1302
|
+
declare const OfferOptionAddressId: (value: string) => OfferOptionAddressId;
|
|
1303
|
+
/**
|
|
1304
|
+
* A user's external wallet, proven via a wallet-ownership challenge and bound
|
|
1305
|
+
* to an offer option. Returned by the `/v1/offers/:offer_id/addresses` resource.
|
|
1306
|
+
*/
|
|
1307
|
+
type OfferOptionAddress = {
|
|
1308
|
+
/** Unique binding id. */
|
|
1309
|
+
id: OfferOptionAddressId;
|
|
1310
|
+
/** Offer option the wallet is bound to. */
|
|
1311
|
+
offerOptionId: OfferOptionId;
|
|
1312
|
+
/** The connected external wallet address. */
|
|
1313
|
+
address: EvmWalletAddress;
|
|
1314
|
+
/**
|
|
1315
|
+
* Protocol the binding is scoped to. An EVM address binds once per option
|
|
1316
|
+
* regardless of which EVM chain proved ownership.
|
|
1317
|
+
*/
|
|
1318
|
+
protocol: WalletProtocol;
|
|
1319
|
+
/** When the binding was created. */
|
|
1320
|
+
createdAt: Date;
|
|
1321
|
+
};
|
|
1322
|
+
declare const OfferOptionAddress: {
|
|
1323
|
+
/** Maps the API DTO into the SDK offer-option-address domain model. */
|
|
1324
|
+
fromDto: (dto: OfferOptionAddressDto) => OfferOptionAddress;
|
|
1325
|
+
};
|
|
1326
|
+
/** Parameters required to connect a proven external wallet to an offer option. */
|
|
1327
|
+
type ConnectExternalWalletParams = {
|
|
1328
|
+
/** Offer the option belongs to. */
|
|
1329
|
+
offerId: OfferId;
|
|
1330
|
+
/** Offer option to bind the wallet to. */
|
|
1331
|
+
offerOptionId: OfferOptionId;
|
|
1332
|
+
/** External wallet address that was proven. */
|
|
1333
|
+
walletAddress: EvmWalletAddress;
|
|
1334
|
+
/** Chain the ownership was proven on. */
|
|
1335
|
+
chain: EthereumChain;
|
|
1336
|
+
/** Signature of the wallet-ownership challenge message. */
|
|
1337
|
+
signature: Hex;
|
|
1338
|
+
};
|
|
1339
|
+
declare const ConnectExternalWalletParams: {
|
|
1340
|
+
/** Maps connect-wallet params into the API DTO payload. */
|
|
1341
|
+
toDto: (params: ConnectExternalWalletParams) => CreateOfferOptionAddressDto;
|
|
1342
|
+
};
|
|
1343
|
+
|
|
1344
|
+
/** Challenge kinds accepted by `POST /v1/wallet-ownership`. */
|
|
1345
|
+
type WalletOwnershipChallengeTypeDto = 'plain' | 'siwe';
|
|
1346
|
+
/**
|
|
1347
|
+
* Request body for `POST /v1/wallet-ownership`. `challenge_type` defaults to
|
|
1348
|
+
* `plain` on the backend; the SIWE fields (`domain`, `uri`, `statement`) are
|
|
1349
|
+
* required only when `challenge_type` is `siwe` and must be absent otherwise.
|
|
1350
|
+
*/
|
|
1351
|
+
type CreateWalletOwnershipChallengeDto = {
|
|
1352
|
+
wallet_address: string;
|
|
1353
|
+
chain: string;
|
|
1354
|
+
challenge_type?: WalletOwnershipChallengeTypeDto;
|
|
1355
|
+
domain?: string;
|
|
1356
|
+
uri?: string;
|
|
1357
|
+
statement?: string;
|
|
1358
|
+
};
|
|
1359
|
+
/** Response body for `POST /v1/wallet-ownership`. */
|
|
1360
|
+
type WalletOwnershipChallengeDto = {
|
|
1361
|
+
message: string;
|
|
1362
|
+
expires_at: string;
|
|
1363
|
+
};
|
|
1364
|
+
|
|
1365
|
+
/** Fields common to every wallet-ownership challenge request. */
|
|
1366
|
+
type WalletOwnershipChallengeParamsBase = {
|
|
1367
|
+
/** Wallet address to prove ownership of. */
|
|
1368
|
+
walletAddress: EvmWalletAddress;
|
|
1369
|
+
/** Chain the wallet belongs to. */
|
|
1370
|
+
chain: EthereumChain;
|
|
1371
|
+
};
|
|
1372
|
+
/**
|
|
1373
|
+
* How the ownership challenge is framed: a plain message or a Sign-In With
|
|
1374
|
+
* Ethereum challenge. Extracted as its own type so SDK consumers can pass it as
|
|
1375
|
+
* a standalone param without reaching into the {@link CreateWalletOwnershipChallengeParams}
|
|
1376
|
+
* union.
|
|
1377
|
+
*/
|
|
1378
|
+
type WalletChallengeType = CreateWalletOwnershipChallengeParams['challengeType'];
|
|
1379
|
+
/**
|
|
1380
|
+
* A single-use ownership challenge returned by `POST /v1/wallet-ownership`.
|
|
1381
|
+
* The consumer signs {@link message} with their wallet, then submits the
|
|
1382
|
+
* signature to connect the wallet to an offer option.
|
|
1383
|
+
*/
|
|
1384
|
+
type WalletOwnershipChallenge = {
|
|
1385
|
+
/** The message the wallet must sign. */
|
|
1386
|
+
message: string;
|
|
1387
|
+
/** When the challenge expires and can no longer be consumed. */
|
|
1388
|
+
expiresAt: Date;
|
|
1389
|
+
};
|
|
1390
|
+
declare const WalletOwnershipChallenge: {
|
|
1391
|
+
/** Maps the API DTO into the SDK wallet-ownership-challenge domain model. */
|
|
1392
|
+
fromDto: (dto: WalletOwnershipChallengeDto) => WalletOwnershipChallenge;
|
|
1393
|
+
};
|
|
1394
|
+
/**
|
|
1395
|
+
* Parameters for requesting a wallet-ownership challenge. Modeled as a
|
|
1396
|
+
* discriminated union on `challengeType` so a `siwe` challenge must carry
|
|
1397
|
+
* `domain`/`uri`/`statement`, matching the backend contract at compile time.
|
|
1398
|
+
*/
|
|
1399
|
+
type CreateWalletOwnershipChallengeParams = (WalletOwnershipChallengeParamsBase & {
|
|
1400
|
+
/** A bare message the wallet signs. */
|
|
1401
|
+
challengeType: 'plain';
|
|
1402
|
+
}) | (WalletOwnershipChallengeParamsBase & {
|
|
1403
|
+
/** Marks this as a Sign-In With Ethereum challenge. */
|
|
1404
|
+
challengeType: 'siwe';
|
|
1405
|
+
/** The requesting site's hostname (e.g. `example.com`). */
|
|
1406
|
+
domain: string;
|
|
1407
|
+
/** The requesting site's URI. */
|
|
1408
|
+
uri: string;
|
|
1409
|
+
/** Human-readable statement shown in the signing prompt. */
|
|
1410
|
+
statement: string;
|
|
1411
|
+
});
|
|
1412
|
+
declare const CreateWalletOwnershipChallengeParams: {
|
|
1413
|
+
/**
|
|
1414
|
+
* Maps challenge-request params into the API DTO payload. The discriminated
|
|
1415
|
+
* union guarantees SIWE fields are present exactly when `challengeType` is
|
|
1416
|
+
* `siwe`, so the mapping narrows on the discriminant.
|
|
1417
|
+
*/
|
|
1418
|
+
toDto: (params: CreateWalletOwnershipChallengeParams) => CreateWalletOwnershipChallengeDto;
|
|
1419
|
+
};
|
|
1420
|
+
|
|
1421
|
+
type ListOptionAddressesParams = {
|
|
1422
|
+
offerId: OfferId;
|
|
1423
|
+
/** Offer option whose bindings to list. */
|
|
1424
|
+
offerOptionId: OfferOptionId;
|
|
1425
|
+
};
|
|
1426
|
+
type RemoveOptionAddressParams = {
|
|
1427
|
+
offerId: OfferId;
|
|
1428
|
+
/** Binding to remove, as returned by {@link WalletsNamespace.list}. */
|
|
1429
|
+
addressId: OfferOptionAddressId;
|
|
1430
|
+
};
|
|
1431
|
+
/**
|
|
1432
|
+
* The user's external wallets: proving ownership of one, binding it to an
|
|
1433
|
+
* offer option, and managing those bindings.
|
|
1434
|
+
*
|
|
1435
|
+
* Ownership proof is a provider-agnostic primitive — the swap flow uses the
|
|
1436
|
+
* same challenge to allow-list a wallet — so it lives here rather than being
|
|
1437
|
+
* duplicated per product namespace.
|
|
1438
|
+
*
|
|
1439
|
+
* Every method requires an authenticated user and throws
|
|
1440
|
+
* {@link NotAuthenticatedError} otherwise.
|
|
1441
|
+
*/
|
|
1442
|
+
interface WalletsNamespace {
|
|
1443
|
+
/**
|
|
1444
|
+
* Creates a single-use challenge the user signs to prove they control a
|
|
1445
|
+
* wallet. Supports both `plain` and `siwe` challenges. Pass the signature of
|
|
1446
|
+
* the returned {@link WalletOwnershipChallenge.message} to
|
|
1447
|
+
* {@link connectExternal}.
|
|
1448
|
+
*/
|
|
1449
|
+
createOwnershipChallenge(params: CreateWalletOwnershipChallengeParams): Promise<WalletOwnershipChallenge>;
|
|
1450
|
+
/**
|
|
1451
|
+
* Binds a proven external wallet to an offer option, using a signature of a
|
|
1452
|
+
* challenge from {@link createOwnershipChallenge}.
|
|
1453
|
+
*/
|
|
1454
|
+
connectExternal(params: ConnectExternalWalletParams): Promise<OfferOptionAddress>;
|
|
1455
|
+
/**
|
|
1456
|
+
* Lists the user's proven wallet bindings for one offer option — the single
|
|
1457
|
+
* bound address for an `external_wallet` option, or every allow-listed
|
|
1458
|
+
* wallet for a `whitelisted_wallet` option.
|
|
1459
|
+
*/
|
|
1460
|
+
list(params: ListOptionAddressesParams): Promise<OfferOptionAddress[]>;
|
|
1461
|
+
/**
|
|
1462
|
+
* Removes one of the user's wallet bindings and returns the removed binding.
|
|
1463
|
+
*/
|
|
1464
|
+
remove(params: RemoveOptionAddressParams): Promise<OfferOptionAddress>;
|
|
1465
|
+
}
|
|
1466
|
+
declare class WalletsNamespaceImpl implements WalletsNamespace {
|
|
1467
|
+
private readonly ctx;
|
|
1468
|
+
constructor(ctx: SharedNamespaceContext);
|
|
1469
|
+
createOwnershipChallenge(params: CreateWalletOwnershipChallengeParams): Promise<WalletOwnershipChallenge>;
|
|
1470
|
+
connectExternal(params: ConnectExternalWalletParams): Promise<OfferOptionAddress>;
|
|
1471
|
+
list(params: ListOptionAddressesParams): Promise<OfferOptionAddress[]>;
|
|
1472
|
+
remove(params: RemoveOptionAddressParams): Promise<OfferOptionAddress>;
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
type DocumentSubmissionStatusDto = 'INITIALIZED' | 'SENT' | 'VIEWED' | 'COMPLETED' | 'DECLINED' | 'EXPIRED';
|
|
1476
|
+
type DocumentFormTypeDto = 'w8_ben' | 'w8_ben_e';
|
|
1477
|
+
type DocumentSubmissionDto = {
|
|
1478
|
+
object: 'document_submission';
|
|
1479
|
+
status: DocumentSubmissionStatusDto;
|
|
1480
|
+
form_type: DocumentFormTypeDto;
|
|
1481
|
+
};
|
|
1482
|
+
|
|
1483
|
+
/** Document types that can be signed via {@link CoinListClient.submitDocument}. */
|
|
1484
|
+
type DocumentType = 'tax_certification';
|
|
1485
|
+
/** Signing-state machine status for a document submission. */
|
|
1486
|
+
type DocumentSubmissionStatus = DocumentSubmissionStatusDto;
|
|
1487
|
+
/** The tax form derived from the entity's kind (individual vs company/trust). */
|
|
1488
|
+
type DocumentFormType = DocumentFormTypeDto;
|
|
1489
|
+
/** Result of starting (or resuming) a document signing submission. */
|
|
1490
|
+
type DocumentSubmission = {
|
|
1491
|
+
status: DocumentSubmissionStatus;
|
|
1492
|
+
formType: DocumentFormType;
|
|
1493
|
+
};
|
|
1494
|
+
declare const DocumentSubmission: {
|
|
1495
|
+
fromDto: (dto: DocumentSubmissionDto) => DocumentSubmission;
|
|
1496
|
+
};
|
|
1497
|
+
|
|
1498
|
+
type KycTokenDto = {
|
|
1499
|
+
object: 'kyc_token';
|
|
1500
|
+
token: string;
|
|
1501
|
+
};
|
|
1502
|
+
|
|
1503
|
+
/**
|
|
1504
|
+
* Sumsub verification level name. Determines which screens the Sumsub WebSDK
|
|
1505
|
+
* shows (levels are configured in the Sumsub dashboard). The backend
|
|
1506
|
+
* prescribes the level (and whether the applicant must be reset first) in the
|
|
1507
|
+
* requirement statuses response — clients never compute levels themselves.
|
|
1508
|
+
*/
|
|
1509
|
+
type KycLevelName = string;
|
|
1510
|
+
/** Short-lived Sumsub WebSDK access token scoped to the current user. */
|
|
1511
|
+
type KycToken = {
|
|
1512
|
+
token: string;
|
|
1513
|
+
};
|
|
1514
|
+
declare const KycToken: {
|
|
1515
|
+
fromDto: (dto: KycTokenDto) => KycToken;
|
|
1516
|
+
};
|
|
1517
|
+
|
|
1518
|
+
type PiiKindDto = 'person' | 'company';
|
|
1519
|
+
type PiiJurisdictionDto = {
|
|
1520
|
+
iso_2: string;
|
|
1521
|
+
name: string | null;
|
|
1522
|
+
};
|
|
1523
|
+
type PiiAddressDto = {
|
|
1524
|
+
street: string | null;
|
|
1525
|
+
city: string | null;
|
|
1526
|
+
state: string | null;
|
|
1527
|
+
postal_code: string | null;
|
|
1528
|
+
country: string | null;
|
|
1529
|
+
};
|
|
1530
|
+
type PiiDto = {
|
|
1531
|
+
object: 'user_pii';
|
|
1532
|
+
kind: PiiKindDto;
|
|
1533
|
+
full_legal_name: string | null;
|
|
1534
|
+
date_of_birth: string | null;
|
|
1535
|
+
jurisdiction: PiiJurisdictionDto | null;
|
|
1536
|
+
tax_id: string | null;
|
|
1537
|
+
permanent_address: PiiAddressDto;
|
|
1538
|
+
};
|
|
1539
|
+
|
|
1540
|
+
/** Whether the PII belongs to an individual or a company/trust entity. */
|
|
1541
|
+
type PiiKind = PiiKindDto;
|
|
1542
|
+
/** ISO 3166-1 alpha-2 country code (e.g. `'US'`). */
|
|
1543
|
+
type Iso2CountryCode = Newtype<string, 'Iso2CountryCode'>;
|
|
1544
|
+
declare const Iso2CountryCode: (value: string) => Iso2CountryCode;
|
|
1545
|
+
/** Jurisdiction derived from the entity's address country. */
|
|
1546
|
+
type PiiJurisdiction = {
|
|
1547
|
+
iso2: Iso2CountryCode;
|
|
1548
|
+
name: string | null;
|
|
1549
|
+
};
|
|
1550
|
+
declare const PiiJurisdiction: {
|
|
1551
|
+
fromDto: (dto: PiiJurisdictionDto) => PiiJurisdiction;
|
|
1552
|
+
};
|
|
1553
|
+
/** Permanent address on file for the entity. */
|
|
1554
|
+
type PiiAddress = {
|
|
1555
|
+
street: string | null;
|
|
1556
|
+
city: string | null;
|
|
1557
|
+
state: string | null;
|
|
1558
|
+
postalCode: string | null;
|
|
1559
|
+
country: string | null;
|
|
1560
|
+
};
|
|
1561
|
+
declare const PiiAddress: {
|
|
1562
|
+
fromDto: (dto: PiiAddressDto) => PiiAddress;
|
|
1563
|
+
};
|
|
1564
|
+
/**
|
|
1565
|
+
* The current user's PII, used to pre-fill tax forms such as the W-8BEN.
|
|
1566
|
+
* Fields the entity hasn't provided are `null`.
|
|
1567
|
+
*/
|
|
1568
|
+
type Pii = {
|
|
1569
|
+
kind: PiiKind;
|
|
1570
|
+
fullLegalName: string | null;
|
|
1571
|
+
dateOfBirth: string | null;
|
|
1572
|
+
jurisdiction: PiiJurisdiction | null;
|
|
1573
|
+
taxId: string | null;
|
|
1574
|
+
permanentAddress: PiiAddress;
|
|
1575
|
+
};
|
|
1576
|
+
declare const Pii: {
|
|
1577
|
+
fromDto: (dto: PiiDto) => Pii;
|
|
1578
|
+
};
|
|
1579
|
+
|
|
1580
|
+
type RequirementTypeDto = 'kyc_approved' | 'identity_verified' | 'proof_of_address' | 'source_of_funds' | 'external_wallet' | 'whitelisted_wallet' | 'jurisdiction' | 'accreditation' | 'document';
|
|
1581
|
+
type RequirementDto = {
|
|
1582
|
+
object: 'requirement';
|
|
1583
|
+
id: string;
|
|
1584
|
+
type: RequirementTypeDto;
|
|
1585
|
+
details: Record<string, unknown> | null;
|
|
1586
|
+
};
|
|
1587
|
+
type RequirementStatusValueDto = 'not_started' | 'in_progress' | 'action_needed' | 'completed' | 'rejected';
|
|
1588
|
+
type RequirementActionNeededReasonDto = 'kyc_not_verified' | 'update_pii_data';
|
|
1589
|
+
/**
|
|
1590
|
+
* Object form of a requirement status, used when the status carries extra
|
|
1591
|
+
* data: the action-needed reason and/or the Sumsub flow that resolves the
|
|
1592
|
+
* requirement (kyc_level + kyc_reset, forwarded to the kyc-token endpoint).
|
|
1593
|
+
*/
|
|
1594
|
+
type RequirementStatusObjectDto = {
|
|
1595
|
+
status: RequirementStatusValueDto;
|
|
1596
|
+
action?: RequirementActionNeededReasonDto;
|
|
1597
|
+
kyc_level?: string;
|
|
1598
|
+
kyc_reset?: boolean;
|
|
1599
|
+
};
|
|
1600
|
+
type RequirementStatusesDto = {
|
|
1601
|
+
object: 'requirement_statuses';
|
|
1602
|
+
offer_id: string;
|
|
1603
|
+
statuses: Record<string, RequirementStatusValueDto | RequirementStatusObjectDto>;
|
|
1604
|
+
};
|
|
1605
|
+
|
|
1606
|
+
type RequirementId = Newtype<string, 'RequirementId'>;
|
|
1607
|
+
declare const RequirementId: (value: string) => RequirementId;
|
|
1608
|
+
type RequirementType = RequirementTypeDto;
|
|
1609
|
+
type RequirementStatusValue = RequirementStatusValueDto;
|
|
1610
|
+
type RequirementActionNeededReason = RequirementActionNeededReasonDto;
|
|
1611
|
+
type Requirement = {
|
|
1612
|
+
id: RequirementId;
|
|
1613
|
+
type: RequirementType;
|
|
1614
|
+
details: Record<string, unknown> | null;
|
|
1615
|
+
};
|
|
1616
|
+
declare const Requirement: {
|
|
1617
|
+
fromDto: (dto: RequirementDto) => Requirement;
|
|
1618
|
+
};
|
|
1619
|
+
type RequirementStatusInfo = {
|
|
1620
|
+
id: RequirementId;
|
|
1621
|
+
status: RequirementStatusValue;
|
|
1622
|
+
/** Why the requirement needs action (KYC-backed requirements only). */
|
|
1623
|
+
action: RequirementActionNeededReason | null;
|
|
1624
|
+
/**
|
|
1625
|
+
* The Sumsub verification level that resolves this requirement, prescribed
|
|
1626
|
+
* by the backend. Present exactly when an inline Sumsub flow can be started.
|
|
1627
|
+
*/
|
|
1628
|
+
kycLevel?: KycLevelName;
|
|
1629
|
+
/**
|
|
1630
|
+
* Whether the Sumsub applicant must be reset before starting the flow
|
|
1631
|
+
* (redoing an already-approved level, e.g. to update stale PII). Forward to
|
|
1632
|
+
* the kyc-token request as-is.
|
|
1633
|
+
*/
|
|
1634
|
+
kycReset?: boolean;
|
|
1635
|
+
};
|
|
1636
|
+
declare const RequirementStatusInfo: {
|
|
1637
|
+
fromStatusesDto: (dto: RequirementStatusesDto) => RequirementStatusInfo[];
|
|
1638
|
+
};
|
|
1639
|
+
|
|
1640
|
+
type CreateKycTokenParams = {
|
|
1641
|
+
/**
|
|
1642
|
+
* Sumsub verification level to run. Defaults to the backend's standard
|
|
1643
|
+
* level.
|
|
1644
|
+
*/
|
|
1645
|
+
levelName?: KycLevelName;
|
|
1646
|
+
/**
|
|
1647
|
+
* Resets the Sumsub applicant first, so an already-approved level can be
|
|
1648
|
+
* executed again (e.g. to update stale PII). Pass the `kycReset` value from
|
|
1649
|
+
* the requirement status, and never on mid-flow token refreshes.
|
|
1650
|
+
*/
|
|
1651
|
+
reset?: boolean;
|
|
1652
|
+
};
|
|
1653
|
+
type SubmitDocumentParams = {
|
|
1654
|
+
/** Currently only `tax_certification` (W-8BEN / W-8BEN-E). */
|
|
1655
|
+
documentType: DocumentType;
|
|
1656
|
+
/**
|
|
1657
|
+
* Signing-form values keyed by the document's DocuSeal field names,
|
|
1658
|
+
* forwarded verbatim to pre-fill the document.
|
|
1659
|
+
*/
|
|
1660
|
+
fields: Record<string, string>;
|
|
1661
|
+
};
|
|
1662
|
+
/**
|
|
1663
|
+
* Everything a user must satisfy before they can participate in an offer:
|
|
1664
|
+
* reading the checklist and its live statuses, and the operations that satisfy
|
|
1665
|
+
* individual requirements — identity verification (KYC) and tax-document
|
|
1666
|
+
* signing.
|
|
1667
|
+
*
|
|
1668
|
+
* Wallet requirements (`external_wallet`, `whitelisted_wallet`) are satisfied
|
|
1669
|
+
* through `WalletsNamespace` instead, since wallet proofs are also used
|
|
1670
|
+
* outside the requirements flow.
|
|
1671
|
+
*
|
|
1672
|
+
* Every method requires an authenticated user and throws
|
|
1673
|
+
* {@link NotAuthenticatedError} otherwise.
|
|
1674
|
+
*/
|
|
1675
|
+
interface RequirementsNamespace {
|
|
1676
|
+
/**
|
|
1677
|
+
* Fetches the requirements for every option of an offer, grouped by option
|
|
1678
|
+
* id. This is the definition of the checklist; {@link statuses} tells you
|
|
1679
|
+
* where the user stands against it.
|
|
1680
|
+
*/
|
|
1681
|
+
forOffer(offerId: OfferId): Promise<Record<OfferOptionId, Requirement[]>>;
|
|
1682
|
+
/**
|
|
1683
|
+
* Fetches the current user's status for each requirement of an offer.
|
|
1684
|
+
*/
|
|
1685
|
+
statuses(offerId: OfferId): Promise<RequirementStatusInfo[]>;
|
|
1686
|
+
/**
|
|
1687
|
+
* Creates a short-lived Sumsub WebSDK access token so an identity
|
|
1688
|
+
* verification (KYC) flow can be started, e.g. by the `IdentityVerification`
|
|
1689
|
+
* component.
|
|
1690
|
+
*/
|
|
1691
|
+
createKycToken(params?: CreateKycTokenParams): Promise<KycToken>;
|
|
1692
|
+
/**
|
|
1693
|
+
* Fetches the current user's PII, used to pre-fill tax forms such as the
|
|
1694
|
+
* W-8BEN. Fields the entity hasn't provided are `null`.
|
|
1695
|
+
*/
|
|
1696
|
+
getPii(): Promise<Pii>;
|
|
1697
|
+
/**
|
|
1698
|
+
* Starts (or resumes) a document signing submission.
|
|
1699
|
+
*/
|
|
1700
|
+
submitDocument(params: SubmitDocumentParams): Promise<DocumentSubmission>;
|
|
1701
|
+
}
|
|
1702
|
+
declare class RequirementsNamespaceImpl implements RequirementsNamespace {
|
|
1703
|
+
protected readonly ctx: SharedNamespaceContext;
|
|
1704
|
+
constructor(ctx: SharedNamespaceContext);
|
|
1705
|
+
forOffer(offerId: OfferId): Promise<Record<OfferOptionId, Requirement[]>>;
|
|
1706
|
+
statuses(offerId: OfferId): Promise<RequirementStatusInfo[]>;
|
|
1707
|
+
createKycToken(params?: CreateKycTokenParams): Promise<KycToken>;
|
|
1708
|
+
getPii(): Promise<Pii>;
|
|
1709
|
+
submitDocument(params: SubmitDocumentParams): Promise<DocumentSubmission>;
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
/**
|
|
1713
|
+
* Reads over CoinList's offers: the catalogue a user can browse, and the full
|
|
1714
|
+
* detail of a single offer.
|
|
1715
|
+
*
|
|
1716
|
+
* Every method requires an authenticated user and throws
|
|
1717
|
+
* {@link NotAuthenticatedError} otherwise. On the server, the same reads are
|
|
1718
|
+
* additionally available with an app-level token — see
|
|
1719
|
+
* `ServerOffersNamespace`.
|
|
1720
|
+
*/
|
|
1721
|
+
interface OffersNamespace {
|
|
1722
|
+
/**
|
|
1723
|
+
* Fetches every offer, iterating through all pages. Prefer {@link listPage}
|
|
1724
|
+
* when you render a paginated list yourself.
|
|
1725
|
+
*/
|
|
1726
|
+
list(): Promise<Offer[]>;
|
|
1727
|
+
/**
|
|
1728
|
+
* Fetches a single page of offers. Pass the previous response's
|
|
1729
|
+
* `startingAfter` as `after` to advance.
|
|
1730
|
+
*/
|
|
1731
|
+
listPage(params: PaginationParams): Promise<PaginatedResponse<Offer>>;
|
|
1732
|
+
/**
|
|
1733
|
+
* Fetches the full detail of one offer, including its options. Note this
|
|
1734
|
+
* returns {@link OfferDetail} — a richer model than the {@link Offer}
|
|
1735
|
+
* summaries {@link list} returns.
|
|
1736
|
+
*/
|
|
1737
|
+
get(id: OfferId): Promise<OfferDetail>;
|
|
1738
|
+
}
|
|
1739
|
+
declare class OffersNamespaceImpl implements OffersNamespace {
|
|
1740
|
+
private readonly ctx;
|
|
1741
|
+
constructor(ctx: SharedNamespaceContext);
|
|
1742
|
+
list(): Promise<Offer[]>;
|
|
1743
|
+
listPage(params: PaginationParams): Promise<PaginatedResponse<Offer>>;
|
|
1744
|
+
get(id: OfferId): Promise<OfferDetail>;
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
/**
|
|
1748
|
+
* Raw JSON from the token registry (Nabu), a static CDN serving token display
|
|
1749
|
+
* metadata. It is a separate backend from frontline: responses omit optional
|
|
1750
|
+
* fields rather than sending `null`, and may grow unknown fields at any time;
|
|
1751
|
+
* we only read the fields named here.
|
|
1752
|
+
*/
|
|
1753
|
+
type NabuLogoImageDto = {
|
|
1754
|
+
url: string;
|
|
1755
|
+
width: number;
|
|
1756
|
+
height: number;
|
|
1757
|
+
};
|
|
1758
|
+
/**
|
|
1759
|
+
* A logo is either a single vector (valid at any size) or a dimensioned
|
|
1760
|
+
* raster original plus pre-scaled variants at ascending widths.
|
|
1761
|
+
*/
|
|
1762
|
+
type NabuLogoDto = {
|
|
1763
|
+
kind: 'VECTOR';
|
|
1764
|
+
url: string;
|
|
1765
|
+
} | {
|
|
1766
|
+
kind: 'RASTER';
|
|
1767
|
+
original: NabuLogoImageDto;
|
|
1768
|
+
variants: NabuLogoImageDto[];
|
|
1769
|
+
};
|
|
1770
|
+
/** One token from the registry's `/{chain}/token/{address}` route. */
|
|
1771
|
+
type NabuTokenDto = {
|
|
1772
|
+
data_version: string;
|
|
1773
|
+
schema_version: number;
|
|
1774
|
+
chain: string;
|
|
1775
|
+
protocol: string;
|
|
1776
|
+
chain_id: number;
|
|
1777
|
+
kind: string;
|
|
1778
|
+
name: string;
|
|
1779
|
+
symbol: string;
|
|
1780
|
+
decimals: number;
|
|
1781
|
+
logo: NabuLogoDto;
|
|
1782
|
+
logo_dark?: NabuLogoDto;
|
|
1783
|
+
coingecko_id?: string;
|
|
1784
|
+
teller_code?: string;
|
|
1785
|
+
address: string;
|
|
1786
|
+
};
|
|
1787
|
+
/**
|
|
1788
|
+
* One asset inside a chain snapshot. The snapshot mixes the chain's native
|
|
1789
|
+
* coin (`kind: 'COIN'`, no address) with its tokens (`kind: 'TOKEN'`), so
|
|
1790
|
+
* `address` is optional here where {@link NabuTokenDto} requires it.
|
|
1791
|
+
*/
|
|
1792
|
+
type NabuChainAssetDto = {
|
|
1793
|
+
kind: string;
|
|
1794
|
+
name: string;
|
|
1795
|
+
symbol: string;
|
|
1796
|
+
decimals: number;
|
|
1797
|
+
logo: NabuLogoDto;
|
|
1798
|
+
logo_dark?: NabuLogoDto;
|
|
1799
|
+
address?: string;
|
|
1800
|
+
};
|
|
1801
|
+
/** The registry's `/{chain}/assets.json` route: one chain, all its assets. */
|
|
1802
|
+
type NabuChainAssetsDto = {
|
|
1803
|
+
data_version: string;
|
|
1804
|
+
schema_version: number;
|
|
1805
|
+
chain: string;
|
|
1806
|
+
protocol: string;
|
|
1807
|
+
assets: NabuChainAssetDto[];
|
|
1808
|
+
};
|
|
1809
|
+
|
|
1810
|
+
/**
|
|
1811
|
+
* An absolute URL to a logo image in the token registry. Registry image URLs
|
|
1812
|
+
* are content-fingerprinted and served immutable, so a value is safe to cache
|
|
1813
|
+
* for as long as you hold it.
|
|
1814
|
+
*/
|
|
1815
|
+
type TokenLogoUrl = Newtype<string, 'TokenLogoUrl'>;
|
|
1816
|
+
declare const TokenLogoUrl: (value: string) => TokenLogoUrl;
|
|
1817
|
+
type TokenLogoImage = {
|
|
1818
|
+
url: TokenLogoUrl;
|
|
1819
|
+
width: number;
|
|
1820
|
+
height: number;
|
|
1821
|
+
};
|
|
1822
|
+
/**
|
|
1823
|
+
* `VECTOR` is a single SVG. `RASTER` has webp variants at 32/64/128/256/512px
|
|
1824
|
+
* widths (never wider than the original): use the smallest one that covers
|
|
1825
|
+
* your render size, or `original` if none does.
|
|
1826
|
+
*/
|
|
1827
|
+
type TokenLogo = {
|
|
1828
|
+
kind: 'VECTOR';
|
|
1829
|
+
url: TokenLogoUrl;
|
|
1830
|
+
} | {
|
|
1831
|
+
kind: 'RASTER';
|
|
1832
|
+
original: TokenLogoImage;
|
|
1833
|
+
variants: TokenLogoImage[];
|
|
1834
|
+
};
|
|
1835
|
+
declare const TokenLogo: {
|
|
1836
|
+
/** `baseUrl` is the registry origin; registry URLs are root-relative. */
|
|
1837
|
+
fromDto: (dto: NabuLogoDto, baseUrl: string) => TokenLogo;
|
|
1838
|
+
};
|
|
1839
|
+
/**
|
|
1840
|
+
* Display metadata for one token, from CoinList's public token registry.
|
|
1841
|
+
*
|
|
1842
|
+
* Keyed by `(chain, address)` — never by symbol, which can collide. The
|
|
1843
|
+
* registry is curated: a token missing from it is an expected answer, not an
|
|
1844
|
+
* error, so lookups return `null` rather than throwing.
|
|
1845
|
+
*/
|
|
1846
|
+
type TokenMetadata = {
|
|
1847
|
+
identifier: TokenIdentifier;
|
|
1848
|
+
name: string;
|
|
1849
|
+
symbol: AssetSymbol;
|
|
1850
|
+
decimals: AssetDecimals;
|
|
1851
|
+
logo: TokenLogo;
|
|
1852
|
+
/** Dark-theme logo; `null` when the registry configures none. */
|
|
1853
|
+
logoDark: TokenLogo | null;
|
|
1854
|
+
};
|
|
1855
|
+
declare const TokenMetadata: {
|
|
1856
|
+
/** `baseUrl` is the registry origin; registry logo URLs are root-relative. */
|
|
1857
|
+
fromDto: (dto: NabuTokenDto, baseUrl: string) => TokenMetadata;
|
|
1858
|
+
/**
|
|
1859
|
+
* Maps a chain snapshot to the tokens it lists, skipping the chain's native
|
|
1860
|
+
* coin (`kind: 'COIN'`, no contract address).
|
|
1861
|
+
*/
|
|
1862
|
+
fromChainAssetsDto: (dto: NabuChainAssetsDto, baseUrl: string) => TokenMetadata[];
|
|
1863
|
+
};
|
|
1864
|
+
|
|
1865
|
+
/**
|
|
1866
|
+
* Token display metadata — name, symbol, decimals, and logos — from
|
|
1867
|
+
* CoinList's public token registry, keyed by {@link TokenIdentifier} (the
|
|
1868
|
+
* same chain + address pairs `OfferDetail.tokens` carries).
|
|
1869
|
+
*
|
|
1870
|
+
* Unlike the other namespaces, this one is public: no method requires an
|
|
1871
|
+
* authenticated user, and nothing here touches the CoinList API — reads go to
|
|
1872
|
+
* the registry's CDN.
|
|
1873
|
+
*/
|
|
1874
|
+
interface TokensNamespace {
|
|
1875
|
+
/**
|
|
1876
|
+
* Fetches metadata for one token. Returns `null` when the registry does not
|
|
1877
|
+
* list the token — the registry is curated, so callers must fall back to
|
|
1878
|
+
* their own display defaults rather than treat this as an error.
|
|
1879
|
+
*/
|
|
1880
|
+
get(token: TokenIdentifier): Promise<TokenMetadata | null>;
|
|
1881
|
+
/**
|
|
1882
|
+
* Fetches all available tokens the registry lists for `chain`, in one
|
|
1883
|
+
* request. Prefer this over calling {@link get} in a loop when displaying a
|
|
1884
|
+
* catalogue: two hundred tokens is still a single snapshot download.
|
|
1885
|
+
*
|
|
1886
|
+
* Unlike {@link get}, a missing chain snapshot throws rather than returning
|
|
1887
|
+
* `[]`: the registry publishes one for every chain it knows, so its absence
|
|
1888
|
+
* is a deployment problem, not an empty catalogue.
|
|
1889
|
+
*/
|
|
1890
|
+
list(chain: EthereumChain): Promise<TokenMetadata[]>;
|
|
1891
|
+
}
|
|
1892
|
+
declare class TokensNamespaceImpl implements TokensNamespace {
|
|
1893
|
+
private readonly api;
|
|
1894
|
+
/**
|
|
1895
|
+
* Takes the registry origin rather than a `SharedNamespaceContext`: the
|
|
1896
|
+
* registry is unauthenticated and on its own host, so the frontline sender
|
|
1897
|
+
* and the auth check would both be dead weight here.
|
|
1898
|
+
*/
|
|
1899
|
+
constructor(baseUrl: string);
|
|
1900
|
+
get(token: TokenIdentifier): Promise<TokenMetadata | null>;
|
|
1901
|
+
list(chain: EthereumChain): Promise<TokenMetadata[]>;
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
interface Config {
|
|
1905
|
+
/** OAuth2 public identifier. */
|
|
1906
|
+
readonly clientId: ClientId;
|
|
1907
|
+
/**
|
|
1908
|
+
* OAuth2 redirect URI. Recommended to point to a frontend page where
|
|
1909
|
+
* {@link CoinListClient#completeOauth} can be called to complete the PKCE
|
|
1910
|
+
* flow on the client side.
|
|
1911
|
+
*/
|
|
1912
|
+
readonly redirectUri: RedirectUri;
|
|
1913
|
+
/**
|
|
1914
|
+
* Recommended to leave undefined. Used to change the CoinList environment;
|
|
1915
|
+
* default is production.
|
|
1916
|
+
*/
|
|
1917
|
+
readonly baseUrl?: string;
|
|
1918
|
+
/**
|
|
1919
|
+
* Recommended to leave undefined. Overrides the base URL of the public
|
|
1920
|
+
* token registry backing `coinlist.tokens`; default is the production
|
|
1921
|
+
* registry.
|
|
1922
|
+
*/
|
|
1923
|
+
readonly tokensBaseUrl?: string;
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1926
|
+
export { type HttpResponse as $, AuthorizationCode as A, BlockchainAmount as B, CodeVerifier as C, type RequirementType as D, EvmWalletAddress as E, type RequirementStatusValue as F, OfferOptionAddress as G, RequirementId as H, type WalletChallengeType as I, DocumentSubmission as J, type KycLevelName as K, OndoTradingStatus as L, AssetDecimals as M, OndoQuote as N, OfferId as O, Participation as P, type OrderBookSide as Q, type RequirementsNamespace as R, type SharedNamespaceContext as S, type Tx as T, type OndoQuoteSize as U, type BuildOndoSwapTransactionParams as V, type WalletsNamespace as W, OfferOptionAddressId as X, TokenMetadata as Y, type TokenIdentifier as Z, HttpError as _, EthereumChain as a, type RemoveOptionAddressParams as a$, KycToken as a0, OAuthSession as a1, ClientCredentialsOAuth as a2, ClientSecret as a3, type Sender as a4, PaginationParams as a5, PaginatedResponse as a6, type Uint256 as a7, KnownAssetSymbol as a8, DecimalString as a9, type GetTokenBalanceParams as aA, HexEncodedTransactionData as aB, Iso2CountryCode as aC, Link as aD, type ListOptionAddressesParams as aE, MAX_ASSET_DECIMALS as aF, MAX_UINT_256 as aG, Milestone as aH, OAuthRefreshToken as aI, OfferOption as aJ, OfferOptionSlug as aK, OfferSlug as aL, OfferToken as aM, OffersNamespaceImpl as aN, type OndoQuoteDuration as aO, PKCEState as aP, type PaginatedResponseDto as aQ, ParticipationId as aR, type ParticipationStatus as aS, ParticipationsPaginationParams as aT, Pii as aU, PiiAddress as aV, PiiJurisdiction as aW, type PiiKind as aX, type QueryParamValue as aY, type QueryParamValues as aZ, RedirectUri as a_, SwapStatus as aa, type Newtype as ab, type AllowWalletParams as ac, AllowWalletResponse as ad, Asset as ae, AssetCode as af, Blockchain as ag, Chain as ah, ClientId as ai, CodeChallenge as aj, ConnectExternalWalletParams as ak, type CreateKycTokenParams as al, CreateParticipationParams as am, CreateWalletOwnershipChallengeParams as an, Cursor as ao, type DocumentFormType as ap, type DocumentSubmissionStatus as aq, type DocumentType as ar, ETHEREUM_CHAINS as as, Erc20NamespaceImpl as at, FaqItem as au, type GetOndoQuoteParams as av, type GetOndoTradingStatusParams as aw, type GetSwapAuthorizationParams as ax, type GetSwapPreviewParams as ay, type GetTokenAllowanceParams as az, type Erc20Namespace as b, type RequirementActionNeededReason as b0, SOLANA_CHAINS as b1, STABLE_DECIMALS as b2, SolanaChain as b3, type SubmitDocumentParams as b4, SwapAuthorization as b5, type SwapContractRef as b6, SwapPreview as b7, TermItem as b8, Ticker as b9, TokenAllowance as ba, TokenBalance as bb, TokenLogo as bc, type TokenLogoImage as bd, TokenLogoUrl as be, type TokenRole as bf, TokensNamespaceImpl as bg, WalletAddress as bh, WalletOwnershipChallenge as bi, type WalletProtocol as bj, WalletsNamespaceImpl as bk, apiErrorCode as bl, assertUint256 as bm, EvmContractAddress as c, type CoinListTokenSaleNamespace as d, OfferOptionId as e, AssetId as f, CoinListTokenSaleNamespaceImpl as g, type OndoNamespace as h, AssetSymbol as i, OndoSwapTransaction as j, OndoNamespaceImpl as k, type SuperstateSwapNamespace as l, Bps as m, SuperstateSwapNamespaceImpl as n, Requirement as o, RequirementsNamespaceImpl as p, type Config as q, type OAuthAccessToken as r, type OffersNamespace as s, type TokensNamespace as t, type Erc20Asset as u, OfferDetail as v, StablecoinSymbol as w, type OfferType as x, Offer as y, RequirementStatusInfo as z };
|