@coinlist-co/react 0.10.1 → 0.11.1-rc.209af8d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +32 -0
  2. package/dist/chunk-3Z4PLLV7.js +2249 -0
  3. package/dist/chunk-3Z4PLLV7.js.map +1 -0
  4. package/dist/{chunk-AQVCOWOV.js → chunk-T4ANQVQA.js} +216 -317
  5. package/dist/chunk-T4ANQVQA.js.map +1 -0
  6. package/dist/chunk-YPFS2SAD.js +279 -0
  7. package/dist/chunk-YPFS2SAD.js.map +1 -0
  8. package/dist/client/index.cjs +11325 -3316
  9. package/dist/client/index.cjs.map +1 -1
  10. package/dist/client/index.d.cts +4243 -881
  11. package/dist/client/index.d.ts +4243 -881
  12. package/dist/client/index.js +9103 -2389
  13. package/dist/client/index.js.map +1 -1
  14. package/dist/collections-B0nu_6q5.d.ts +116 -0
  15. package/dist/collections-DdLA4_GN.d.cts +116 -0
  16. package/dist/config-D0r6GyPL.d.cts +2638 -0
  17. package/dist/config-D0r6GyPL.d.ts +2638 -0
  18. package/dist/server/index.cjs +1631 -514
  19. package/dist/server/index.cjs.map +1 -1
  20. package/dist/server/index.d.cts +266 -162
  21. package/dist/server/index.d.ts +266 -162
  22. package/dist/server/index.js +235 -169
  23. package/dist/server/index.js.map +1 -1
  24. package/dist/shared/index.cjs +2235 -926
  25. package/dist/shared/index.cjs.map +1 -1
  26. package/dist/shared/index.d.cts +256 -132
  27. package/dist/shared/index.d.ts +256 -132
  28. package/dist/shared/index.js +102 -28
  29. package/package.json +12 -8
  30. package/dist/chunk-AQVCOWOV.js.map +0 -1
  31. package/dist/chunk-TBU3EBNM.js +0 -442
  32. package/dist/chunk-TBU3EBNM.js.map +0 -1
  33. package/dist/chunk-UOHD7US2.js +0 -855
  34. package/dist/chunk-UOHD7US2.js.map +0 -1
  35. package/dist/collections-Bv1Oxzu_.d.ts +0 -28
  36. package/dist/collections-DDyxbOPZ.d.cts +0 -28
  37. package/dist/requirement-oVZA1INj.d.cts +0 -1040
  38. package/dist/requirement-oVZA1INj.d.ts +0 -1040
@@ -0,0 +1,2638 @@
1
+ import { Hash, 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
+ * A classified wallet or transaction failure. The SDK derives this from
25
+ * whatever the {@link EvmWallet} throws, so hosts get a stable, typed error
26
+ * shape regardless of the wallet library underneath.
27
+ *
28
+ * Lives here rather than beside its classifier because it is the failure half
29
+ * of the {@link EvmWallet} contract, and because both `@/shared` and
30
+ * `@/client` name it: {@link LogCause} carries one, and classifying a thrown
31
+ * error into one needs viem's error classes, which are browser-side.
32
+ */
33
+ type WalletError = {
34
+ type: 'user_rejected';
35
+ } | {
36
+ type: 'insufficient_funds';
37
+ } | {
38
+ type: 'contract_reverted';
39
+ /**
40
+ * What the contract said, when it said anything: a `require` string, a
41
+ * panic description, a custom error's name, or the four-byte selector of
42
+ * an error the ABI could not decode.
43
+ *
44
+ * `null` when a revert carried no data, since the string the RPC node
45
+ * offers in its place is not the contract's - see `classifyWalletError`.
46
+ * Nullable rather than optional so that every arm has to answer the
47
+ * question: "it reverted and said nothing" is a fact about the revert,
48
+ * and a caller should have to read it rather than miss it.
49
+ *
50
+ * Never the custom error's arguments. A name is a compile-time
51
+ * identifier; its operands are runtime values - an address, a balance -
52
+ * and those are `'debug'` material.
53
+ */
54
+ reason: string | null;
55
+ } | {
56
+ type: 'timeout';
57
+ hash: Hash;
58
+ } | {
59
+ type: 'unknown';
60
+ cause: unknown;
61
+ };
62
+ /**
63
+ * A {@link WalletError} as it may be reported above `'debug'`: the
64
+ * classification, never the throw.
65
+ *
66
+ * Only the `unknown` arm differs, and it differs because it is the one arm
67
+ * carrying a value the SDK did not author - the raw error the wallet library
68
+ * threw, whose message and metadata hold the transaction's `from`, `to`,
69
+ * `value` and calldata. The other four carry compile-time constants or a
70
+ * server-minted identifier already, so they pass through as they stand.
71
+ *
72
+ * This exists as a type rather than as a scrub some function remembers to
73
+ * apply: `LogCause` names it, so an arm that grew a raw field would fail the
74
+ * build instead of quietly reaching {@link Logger.error}.
75
+ */
76
+ type RedactedWalletError = Exclude<WalletError, {
77
+ type: 'unknown';
78
+ }> | {
79
+ type: 'unknown';
80
+ };
81
+ declare const RedactedWalletError: {
82
+ fromWalletError: (error: WalletError) => RedactedWalletError;
83
+ };
84
+
85
+ /**
86
+ * The observability seam a host implements to see inside the SDK.
87
+ *
88
+ * Pass an implementation as {@link Config.logger} and the SDK reports every
89
+ * request it makes, every failure it classifies, and every state a hook
90
+ * settles into. Leave it out and the SDK logs nothing at all - there is no
91
+ * fallback to `console`, at any level, on any codepath.
92
+ *
93
+ * Four methods over a {@link LogEvent} lambda, plus {@link level}. An event is
94
+ * a constant `msg`, the {@link LogScope} it came from, the accumulated
95
+ * {@link LogBindings}, and a bag of `fields` - so a host forwards structured
96
+ * records rather than parsing strings.
97
+ *
98
+ * ```ts
99
+ * const logger: Logger = {
100
+ * level: () => 'info',
101
+ * debug: () => {},
102
+ * info: (event) => sink.info(toRecord(event())),
103
+ * warn: (event) => sink.warn(toRecord(event())),
104
+ * error: (event) => sink.error(toRecord(event())),
105
+ * };
106
+ * ```
107
+ *
108
+ * {@link pinoClientLogger} and {@link pinoServerLogger} are ready-made
109
+ * implementations over pino, and are what most hosts should reach for.
110
+ *
111
+ * ## Where to run it
112
+ *
113
+ * **Not in production, as the default answer.** Development, tests, staging,
114
+ * and reproducing a reported bug are where this seam earns its keep. Left
115
+ * undefined elsewhere it discloses nothing, and that holds no matter what a
116
+ * later revision of the SDK puts on a line.
117
+ *
118
+ * Where you do run one in production, `'info'` and above is the only sane
119
+ * choice, and the shipped implementations make the alternative unrepresentable
120
+ * rather than merely discouraged: `isDev: false` narrows the level to
121
+ * {@link ProductionLogLevel}, so `'debug'` does not compile. That narrowing is
122
+ * a guard for the partner who ignored this paragraph, not an endorsement of
123
+ * the practice.
124
+ *
125
+ * The distinction worth holding onto: `'info'` and above are **redacted by
126
+ * construction** - see the next section for exactly what that covers, and the
127
+ * type that enforces it. Redacted is a mechanism the SDK can hold itself to. A
128
+ * blanket "safe in production" is a promise about your environment that the
129
+ * SDK is in no position to make, and one that a single future field could
130
+ * quietly break.
131
+ *
132
+ * `'debug'` is for reproducing a bug: a developer's machine, tests, and beta
133
+ * or staging environments where the data flowing through the SDK is not real
134
+ * customer data.
135
+ *
136
+ * ## What each level may disclose
137
+ *
138
+ * **`'debug'` is unredacted. Every other level is not.**
139
+ *
140
+ * At `'debug'` the SDK reports request and response bodies, request headers,
141
+ * the full URL including its query string, and operation parameters
142
+ * **verbatim** - bearer tokens, KYC answers, tax-document fields, wallet
143
+ * signatures, the lot. There is no denylist and no redaction: see ADR-8 for
144
+ * why a partial guarantee was rejected in favour of an honest absence of one.
145
+ *
146
+ * At `'info'`, `'warn'` and `'error'` the SDK emits only its own
147
+ * classification of what happened and identifiers the server minted: a method
148
+ * and a bare path, a status, a duration, a {@link RequestId}, a frontline
149
+ * error code and event id, a {@link LogCause} arm. No request body, no
150
+ * response body, no query string, no host-supplied parameters, and no message
151
+ * text read off a thrown error the SDK did not author.
152
+ *
153
+ * The type carries that boundary rather than merely documenting it:
154
+ * {@link SafeEvent} constrains every field value to a {@link LogValue} scalar,
155
+ * so spreading a body, a DTO or an operation's params into an `info`, `warn`
156
+ * or `error` line does not compile. Only {@link DebugEvent} accepts arbitrary
157
+ * values.
158
+ *
159
+ * The one deliberate exception is an SDK-authored validation message, which
160
+ * quotes the single scalar that failed to map - `Unsupported chain:
161
+ * "solana_mainnet"`. It is a hand-written template naming one offending value,
162
+ * not a payload, and it is the whole reason this seam exists.
163
+ *
164
+ * ## Your responsibility
165
+ *
166
+ * The SDK hands you events. What happens next is yours: **you own the final
167
+ * filtering, redaction and retention** before anything is written to a file, a
168
+ * console, or a third-party sink such as Sentry or Datadog. In particular, if
169
+ * you implement {@link debug} and forward it anywhere durable, you have taken
170
+ * on storing live credentials and personal data, deliberately. Implement
171
+ * `debug` as a no-op - or return a level below it from {@link level} - in any
172
+ * environment where that is not acceptable.
173
+ *
174
+ * **Every event is a lambda, and that is load bearing.** The SDK consults
175
+ * {@link level} first and never invokes the lambda when the level forbids it,
176
+ * so an expensive debug event - a serialized DTO, a loop over balances - costs
177
+ * nothing in production where the level is `'error'` or `'none'`. Build the
178
+ * event inside the lambda, never outside it.
179
+ *
180
+ * ## Every method must be total
181
+ *
182
+ * **None of the five methods may throw, and that includes {@link level}.** The
183
+ * SDK calls them inline, on the codepath of the work it is reporting, and it
184
+ * does not catch them: a `logger.error` that throws while reporting a failed
185
+ * request turns that request's rejection into your logger's exception, and a
186
+ * `level()` that throws breaks the call it was asked about even when nothing
187
+ * else went wrong.
188
+ *
189
+ * That is deliberate. Swallowing would hide a logger that is broken in every
190
+ * environment, and the SDK cannot tell a transport blip in your sink from a
191
+ * bug in your implementation. So the contract is on this side of the seam:
192
+ * catch inside your implementation, and never let an exception out. The
193
+ * shipped pino implementations do exactly that.
194
+ *
195
+ * ```ts
196
+ * error: (event) => {
197
+ * try {
198
+ * const e = event();
199
+ * Sentry.captureMessage(e.msg, { extra: e });
200
+ * } catch {
201
+ * // never rethrow: the SDK is on the other side of this call
202
+ * }
203
+ * },
204
+ * ```
205
+ */
206
+ interface Logger {
207
+ /**
208
+ * The most detailed level this logger wants. Consulted before **every** log
209
+ * call, so keep it cheap and pure: return a captured constant or read a
210
+ * plain field. Do not read an environment variable, hit storage, or call
211
+ * out to a feature-flag service here.
212
+ *
213
+ * Returning `'none'` silences the SDK as completely as omitting the logger.
214
+ *
215
+ * **Must not throw.** It is consulted inside every SDK operation, so an
216
+ * exception here fails the operation itself.
217
+ */
218
+ level(): LogLevel;
219
+ /**
220
+ * Fine-grained detail: request and response bodies, full URLs, headers,
221
+ * operation parameters, hook transitions.
222
+ *
223
+ * **Unredacted.** This is the only level that may carry credentials or
224
+ * personal data, and it always may. Its event is a {@link DebugEvent}, whose
225
+ * fields accept arbitrary values for exactly that reason. Do not forward it
226
+ * to a durable or third-party sink outside development and beta.
227
+ *
228
+ * **Must not throw**, here and on every method below.
229
+ */
230
+ debug(event: () => DebugEvent): void;
231
+ /** Notable, expected events: a request completing, a flow advancing. */
232
+ info(event: () => SafeEvent): void;
233
+ /**
234
+ * Recoverable trouble: a retried request, a renewed session, a poll tick
235
+ * that failed while the last value still stands.
236
+ *
237
+ * Carries a {@link LogCause} when one was classified, the same as
238
+ * {@link error} does. What separates the two levels is whether anything
239
+ * actually broke, not how much is known about it.
240
+ */
241
+ warn(event: () => SafeEvent): void;
242
+ /**
243
+ * A failure. {@link SafeEvent.cause} carries what the SDK knows about it,
244
+ * classified into {@link LogCause}, and is absent when the failure is not an
245
+ * error the SDK caught - a flow reporting the step it stopped at, for
246
+ * instance.
247
+ *
248
+ * Every part of the event is SDK-authored classification or server-authored
249
+ * identifiers, so forwarding it as it stands is safe. `scope` says which
250
+ * part of the SDK the line came from, which is what to route or filter on.
251
+ */
252
+ error(event: () => SafeEvent): void;
253
+ }
254
+ /**
255
+ * A value the SDK is willing to put in a structured field above `'debug'`.
256
+ *
257
+ * Scalars only, and that is the redaction boundary made structural rather than
258
+ * documentary. Every leak ADR-8 found was an *object* spread onto a line that
259
+ * a host forwards to a tracker - an operation's params, a thrown wallet error,
260
+ * a response body. None of them is assignable to this, so each is now a
261
+ * compile error rather than a review catch.
262
+ *
263
+ * It does not stop a call site writing `{ token: accessToken }`, and it is not
264
+ * meant to: a string is a string. What it stops is the mistake that actually
265
+ * happened.
266
+ */
267
+ type LogValue = string | number | boolean | null;
268
+ /**
269
+ * Fields safe at every level: SDK-authored classification and server-minted
270
+ * identifiers, constrained to {@link LogValue}.
271
+ */
272
+ type SafeFields = Readonly<Record<string, LogValue>>;
273
+ /**
274
+ * Fields for `'debug'` only: bodies, headers, full URLs, operation params,
275
+ * raw thrown values. Arbitrary values, because that is the point of the level.
276
+ *
277
+ * The SDK's own implementations render these into a form that cannot fail to
278
+ * serialize - a `bigint`, a cycle or a getter that throws must never turn a
279
+ * log line into a second failure - but they are otherwise passed through.
280
+ */
281
+ type UnredactedFields = Readonly<Record<string, unknown>>;
282
+ /**
283
+ * One narrowing applied to a logger by {@link InternalLogger.child}.
284
+ *
285
+ * A union of single-key objects rather than a positional `string`, because the
286
+ * three things the SDK narrows by are not the same kind of thing: a request id
287
+ * correlates retries of one wire call, a flow name names an on-chain
288
+ * procedure, a hook name names a React binding. Rendered into one `[SCOPE:x]`
289
+ * prefix they were indistinguishable; as fields they must not be.
290
+ *
291
+ * `requestId` keeps its {@link RequestId} newtype rather than widening to
292
+ * `string` at the seam.
293
+ */
294
+ type LogBinding = {
295
+ readonly requestId: RequestId;
296
+ } | {
297
+ readonly flow: string;
298
+ } | {
299
+ readonly hook: string;
300
+ } | {
301
+ readonly op: string;
302
+ };
303
+ /**
304
+ * Every {@link LogBinding} applied so far, merged. This is what reaches a
305
+ * host, so a line from `prepareOndoSwap` carries `flow: 'prepareSwap'` as its
306
+ * own key and is filterable without parsing anything.
307
+ */
308
+ type LogBindings = {
309
+ readonly [K in LogBinding as keyof K]?: K[keyof K];
310
+ };
311
+ type BaseEvent = {
312
+ /**
313
+ * What happened, as a **constant string literal**.
314
+ *
315
+ * Never interpolated. A log aggregator groups by message, so a `msg` that
316
+ * embeds a status, a count or a reason produces one group per distinct
317
+ * value and is not groupable at all. Every varying value belongs in
318
+ * `fields`, which is what a host filters and facets on.
319
+ *
320
+ * This is a convention, not a checked rule: deslop reasons about import
321
+ * edges and cannot see a template literal, and the type-level approximations
322
+ * catch only some interpolations. ADR-8 records why a partial guarantee was
323
+ * refused here as elsewhere.
324
+ */
325
+ readonly msg: string;
326
+ /**
327
+ * Which part of the SDK reported this. Stamped by
328
+ * {@link internalLogger}, never by a call site.
329
+ */
330
+ readonly scope: LogScope;
331
+ /** Every {@link LogBinding} applied by {@link InternalLogger.child}. */
332
+ readonly bindings: LogBindings;
333
+ };
334
+ /**
335
+ * An event for `'info'`, `'warn'` and `'error'` - the levels a host may run in
336
+ * production.
337
+ *
338
+ * Its fields are {@link SafeFields}, so nothing but a scalar can reach it.
339
+ */
340
+ type SafeEvent = BaseEvent & {
341
+ readonly fields: SafeFields;
342
+ /**
343
+ * What the SDK knows about an accompanying failure, classified. Absent when
344
+ * there is nothing to classify.
345
+ */
346
+ readonly cause?: LogCause;
347
+ };
348
+ /**
349
+ * An event for `'debug'`, the unredacted level. Its fields accept anything.
350
+ */
351
+ type DebugEvent = BaseEvent & {
352
+ readonly fields: UnredactedFields;
353
+ };
354
+ /**
355
+ * How much the SDK may report, from silent to everything.
356
+ *
357
+ * Ordered: each level admits itself and everything before it, so `'info'`
358
+ * shows errors, warnings and info but not debug. `'none'` admits nothing.
359
+ *
360
+ * `'debug'` is the unredacted level, and it is deliberately the bottom of the
361
+ * ladder: the guarantee "`debug` is unredacted and every other level is not"
362
+ * only closes if there is nothing below it. That is why the SDK keeps its own
363
+ * five levels rather than adopting pino's seven, which put `trace` underneath.
364
+ */
365
+ type LogLevel = 'none' | 'error' | 'warn' | 'info' | 'debug';
366
+ /**
367
+ * The redacted levels: the only ones to consider running in production.
368
+ *
369
+ * Every level except `'debug'`, which is unredacted by design. Used by the
370
+ * shipped pino implementations to make a production `'debug'` logger
371
+ * unrepresentable rather than merely discouraged - see
372
+ * {@link PinoLoggerOptions}.
373
+ *
374
+ * The name marks which levels are *redacted*, not a verdict that running them
375
+ * in production is safe. The SDK's advice is to leave {@link Config.logger}
376
+ * undefined there; this type is what stops the partner who does not take it
377
+ * from reaching the unredacted level as well.
378
+ */
379
+ type ProductionLogLevel = Exclude<LogLevel, 'debug'>;
380
+ /**
381
+ * How to build one of the SDK's pino-backed loggers.
382
+ *
383
+ * A union rather than `{ level, isDev }`, and that is the whole point:
384
+ * `{ isDev: false, level: 'debug' }` does not typecheck, so a production
385
+ * build cannot ship a logger that prints bearer tokens to a browser console.
386
+ *
387
+ * `isDev` does exactly one thing - decide whether `'debug'` is a legal level.
388
+ * It changes no formatting: dev output and production output are the same
389
+ * shape, so what you debug is what you ship. Pretty-printing is a pipe the
390
+ * host owns (`node server.js | npx pino-pretty`), not a dependency the SDK
391
+ * takes.
392
+ */
393
+ type PinoLoggerOptions = {
394
+ readonly isDev: true;
395
+ readonly level: LogLevel;
396
+ } | {
397
+ readonly isDev: false;
398
+ readonly level: ProductionLogLevel;
399
+ };
400
+ /**
401
+ * Which part of the SDK a line came from, carried as the `scope` field on
402
+ * every event.
403
+ *
404
+ * It names the seam that **reported** the line, not the layer that raised what
405
+ * it reports: an error from `OFFERS` surfaced by `useOffers` is reported on a
406
+ * `HOOKS` line, because that is the hook telling you what it did with it. The
407
+ * `OFFERS` line for the same error is emitted separately, by the namespace.
408
+ *
409
+ * A closed union rather than a free string so that `ONDO` and `Ondo` cannot
410
+ * both appear, so that adding a namespace without giving it a scope fails to
411
+ * compile, and so that a host can `switch` on it when routing. Anything finer
412
+ * - an operation, a flow, a hook - is a {@link LogBinding} and appears as its
413
+ * own field.
414
+ */
415
+ type LogScope = 'HTTP' | 'AUTH' | 'OFFERS' | 'REQUIREMENTS' | 'WALLETS' | 'ERC20' | 'TOKEN_SALE' | 'SUPERSTATE' | 'ONDO' | 'TOKENS' | 'SUPPORT' | 'HOOKS';
416
+ /**
417
+ * Correlates every line one logical request produces. The first attempt, each
418
+ * retry, and the re-send after a session renewal all carry the same id, so a
419
+ * failure can be read back to the request that caused it.
420
+ */
421
+ type RequestId = Newtype<string, 'RequestId'>;
422
+ /**
423
+ * The id frontline keys its own logs by, minted server-side and returned as
424
+ * `event_id` on an error envelope. Quote it when raising a ticket with
425
+ * CoinList support: it is what leads from a partner's log line to the request
426
+ * as the backend saw it.
427
+ *
428
+ * A {@link Newtype} rather than a bare `string` because it sits next to
429
+ * {@link RequestId} and frontline's `code` on the same cause, and the three
430
+ * are not interchangeable: an id swapped for a code reads plausibly and points
431
+ * a support engineer at nothing.
432
+ */
433
+ type FrontlineEventId = Newtype<string, 'FrontlineEventId'>;
434
+ /**
435
+ * What the SDK knows about a failure, classified.
436
+ *
437
+ * **Safe to forward as it stands.** Every arm is SDK-authored classification
438
+ * or a server-authored identifier: no request or response body, no host-
439
+ * supplied parameter, and no value read off a thrown error the SDK did not
440
+ * author. There is nothing here to strip before handing it to an error
441
+ * tracker, which is deliberate - a `LogCause` reaches {@link Logger.error},
442
+ * the level a host actually runs in production, and a guarantee that depends
443
+ * on the host remembering to strip a field is not a guarantee.
444
+ *
445
+ * It is the SDK's **only** structured classification of a thrown error, and it
446
+ * reaches {@link Logger.warn} as well as {@link Logger.error}: a recoverable
447
+ * failure is no less worth naming than a fatal one, and rendering it into a
448
+ * string instead would have meant interpolating into `msg`.
449
+ *
450
+ * Bodies are a `'debug'`-only disclosure and stay on the `HTTP` lines, which
451
+ * {@link RequestId} points at.
452
+ *
453
+ * The arms are the remedies, not the exception classes: a `validation` cause
454
+ * means the backend sent something the SDK does not understand and is worth
455
+ * reporting to CoinList, while an `invariant` cause means the SDK itself
456
+ * computed something impossible and is worth reporting as an SDK bug. Reading
457
+ * `type` should tell you who has to fix it.
458
+ *
459
+ * It carries no scope of its own. The {@link SafeEvent} it arrives on has one,
460
+ * and a cause could only ever have repeated it: the scope is stamped by the
461
+ * logger that *emits* the line, not by the layer that raised the error, so a
462
+ * `validation` failure from `OFFERS` surfaced by `useOffers` would have been
463
+ * tagged `HOOKS` on the hook's line. Forward the event, not the cause alone.
464
+ */
465
+ type LogCause =
466
+ /**
467
+ * A request reached the backend and came back non-2xx.
468
+ *
469
+ * Deliberately carries no response body. `requestId` is how you get the
470
+ * rest: the `HTTP` lines for the same request carry the method, the path,
471
+ * the duration, every retry, and at `'debug'` the body itself. `code` and
472
+ * `eventId` are frontline's own - quote `eventId` when raising a ticket with
473
+ * CoinList support.
474
+ */
475
+ {
476
+ type: 'http';
477
+ requestId: RequestId | null;
478
+ status: number;
479
+ code: string | null;
480
+ eventId: FrontlineEventId | null;
481
+ }
482
+ /**
483
+ * The wire succeeded; the payload was not a shape the SDK can map.
484
+ *
485
+ * `message` is an SDK-authored template and may quote the single scalar that
486
+ * failed - `Unsupported chain: "solana_mainnet"`, `expires_at: not a date
487
+ * ("13/40/2026")`. That one value is the point of the arm; it is never a
488
+ * body and never a whole field set.
489
+ */
490
+ | {
491
+ type: 'validation';
492
+ message: string;
493
+ }
494
+ /**
495
+ * The SDK computed something impossible. An SDK bug - please report it.
496
+ * `message` is an SDK-authored template, like `validation`'s.
497
+ */
498
+ | {
499
+ type: 'invariant';
500
+ message: string;
501
+ }
502
+ /** An API-backed call was made without a logged-in user. */
503
+ | {
504
+ type: 'not-authenticated';
505
+ }
506
+ /** A code path the SDK has not shipped yet. */
507
+ | {
508
+ type: 'not-implemented';
509
+ }
510
+ /**
511
+ * The user's wallet, or the chain, refused.
512
+ *
513
+ * {@link RedactedWalletError} rather than the full `WalletError`: its
514
+ * `unknown` arm arrives with its `cause` dropped, that field holding the raw
515
+ * wallet-library error whose message and metadata carry the transaction's
516
+ * `from`, `to`, `value` and calldata. It is still on the flow's own returned
517
+ * result, and on the `'debug'` line the flow seam emits beside this one.
518
+ *
519
+ * A type rather than a scrub applied at the call site, so an arm that grew a
520
+ * raw field would fail the build.
521
+ */
522
+ | {
523
+ type: 'wallet';
524
+ error: RedactedWalletError;
525
+ }
526
+ /**
527
+ * Something the SDK does not recognise - usually a host-supplied lambda
528
+ * (`getAccessToken`, an {@link EvmWallet} method) throwing, or a
529
+ * network-level `fetch` failure.
530
+ *
531
+ * `name` is the error's class name and nothing else. The message and the
532
+ * thrown value itself are host-authored, so they are a `'debug'` disclosure:
533
+ * the paired debug line renders them in full.
534
+ */
535
+ | {
536
+ type: 'generic-error';
537
+ name: string;
538
+ };
539
+
540
+ /**
541
+ * The exhaustive chain set: a new {@link EthereumChain} is a compile error
542
+ * here until it is listed, which is what keeps the constructor total.
543
+ */
544
+ declare const ETHEREUM_CHAINS: Record<EthereumChain, true>;
545
+ type EthereumChain = 'ethereum_mainnet' | 'ethereum_sepolia';
546
+ /**
547
+ * Validates that a raw backend string names a chain the SDK supports.
548
+ *
549
+ * @throws ValidationError on anything else. Passing an unknown chain through
550
+ * would let downstream EIP-155 lookups blow up far from the response that
551
+ * caused it.
552
+ */
553
+ declare const EthereumChain: (value: string) => EthereumChain;
554
+ /**
555
+ * The exhaustive chain set: a new {@link SolanaChain} is a compile error
556
+ * here until it is listed, which is what keeps the constructor total.
557
+ */
558
+ declare const SOLANA_CHAINS: Record<SolanaChain, true>;
559
+ type SolanaChain = 'solana_mainnet' | 'solana_devnet';
560
+ /**
561
+ * Validates that a raw backend string names a chain the SDK supports.
562
+ *
563
+ * @throws ValidationError on anything else. Passing an unknown chain through
564
+ * would let downstream EIP-155 lookups blow up far from the response that
565
+ * caused it.
566
+ */
567
+ declare const SolanaChain: (value: string) => SolanaChain;
568
+ type Chain = EthereumChain | SolanaChain;
569
+ declare const Chain: (value: string) => Chain;
570
+ /**
571
+ * Protocol a wallet binding is scoped to. EVM-only for now: an EVM address
572
+ * binds once per option regardless of which EVM chain proved ownership.
573
+ * Frontline's enum also has `:solana`, but we don't handle Solana bindings yet,
574
+ * so this stays `'ethereum'` until Solana support lands.
575
+ */
576
+ type WalletProtocol = 'ethereum';
577
+ /**
578
+ * EVM addresses keep a `0x${string}` base so they stay assignable to the
579
+ * `0x${string}` shapes that on-chain libraries (viem/wagmi) expect. We only
580
+ * drop the runtime `0x` narrowing: values are trusted at the boundary and
581
+ * branded via the constructor.
582
+ */
583
+ type EvmWalletAddress = Newtype<`0x${string}`, 'EvmWalletAddress'>;
584
+ declare const EvmWalletAddress: (value: string) => EvmWalletAddress;
585
+ type EvmContractAddress = Newtype<`0x${string}`, 'EvmContractAddress'>;
586
+ declare const EvmContractAddress: (value: string) => EvmContractAddress;
587
+ /**
588
+ * What uniquely identifies a token: the chain it is deployed on plus its
589
+ * contract address. Never a symbol, which can collide across issuers.
590
+ */
591
+ type TokenIdentifier = {
592
+ /** The chain the token contract is deployed on. */
593
+ chain: EthereumChain;
594
+ /**
595
+ * The token's contract address, in any casing — consumers that need the
596
+ * EIP-55 form (e.g. the token registry routes) checksum it themselves.
597
+ */
598
+ address: EvmContractAddress;
599
+ };
600
+ type HexEncodedTransactionData = Newtype<`0x${string}`, 'HexEncodedTransactionData'>;
601
+ declare const HexEncodedTransactionData: (value: string) => HexEncodedTransactionData;
602
+ /**
603
+ * A transaction the backend has already encoded for us — the caller only
604
+ * broadcasts it. Used by the flows that hand a wallet a ready-made `to`/`data`
605
+ * pair (allow-listing a wallet, an Ondo swap) rather than encoding a contract
606
+ * call themselves.
607
+ */
608
+ type Tx = {
609
+ to: EvmContractAddress;
610
+ data: HexEncodedTransactionData;
611
+ };
612
+ /**
613
+ * The largest exponent whose power of ten still fits a uint256: 10^77 fits,
614
+ * 10^78 does not.
615
+ *
616
+ * The bound is arithmetic rather than a token standard's. ERC-20 reports
617
+ * `decimals()` as a `uint8`, so 255 is what a contract *can* say, but every
618
+ * {@link AssetDecimals} in this codebase is paired with a {@link Uint256} raw
619
+ * by construction, and scaling by anything past this leaves that pairing
620
+ * unrepresentable. A value between 78 and 255 would therefore pass a
621
+ * standard-faithful check and then break the first multiplication it reached.
622
+ */
623
+ declare const MAX_ASSET_DECIMALS = 77;
624
+ /**
625
+ * How many decimal places one whole token divides into.
626
+ *
627
+ * Validated, unlike its neighbours here — {@link Uint256} is a bare `bigint`
628
+ * with a separate {@link assertUint256} guard, and {@link DecimalString} casts
629
+ * unchecked. The asymmetry is deliberate and follows the value's provenance:
630
+ * an `AssetDecimals` used to come only from literals and the token registry,
631
+ * but backends now publish exponents of their own (`asset_decimals` on an Ondo
632
+ * quote, both scales on a built swap), and those feed `10n ** BigInt(d)`
633
+ * during render. Guarding at construction is what keeps a fractional or
634
+ * unbounded exponent from surfacing as a `RangeError` mid-render — or, at
635
+ * 10^200, as a hung tab — instead of as the failed state the screen has.
636
+ *
637
+ * See docs/ADR-7-VALIDATED-NEWTYPES.md.
638
+ *
639
+ * @throws ValidationError on a non-integer, a negative, or anything above
640
+ * {@link MAX_ASSET_DECIMALS}.
641
+ */
642
+ type AssetDecimals = Newtype<number, 'AssetDecimals'>;
643
+ declare const AssetDecimals: (value: number) => AssetDecimals;
644
+ declare const STABLE_DECIMALS: AssetDecimals;
645
+ /**
646
+ * A non-negative decimal number the backend sent as a string, kept unscaled.
647
+ *
648
+ * Reach for it when a response gives you a number but not the decimals to
649
+ * scale it by, or gives you one it has already applied. Inventing an exponent
650
+ * for either is how a display ends up orders of magnitude out.
651
+ *
652
+ * Contrast {@link BlockchainAmount}, which pairs a raw uint256 with the
653
+ * decimals it is denominated in and so is only constructible when you know
654
+ * both. Arithmetic on a `DecimalString` needs a decimal library we
655
+ * deliberately do not ship.
656
+ */
657
+ type DecimalString = Newtype<string, 'DecimalString'>;
658
+ declare const DecimalString: (value: string) => DecimalString;
659
+ declare const MAX_UINT_256: bigint;
660
+ /**
661
+ * A non-negative integer within uint256 bounds. Kept unbranded (a plain
662
+ * `bigint`) so raw on-chain amounts flow in without ceremony; bounds are
663
+ * enforced where it matters (see {@link combineAmounts}).
664
+ */
665
+ type Uint256 = bigint;
666
+ /**
667
+ * Asserts a computed bigint falls within uint256 bounds. Use at on-chain
668
+ * arithmetic boundaries (bps math, price computation) where the SDK's own
669
+ * arithmetic could underflow below zero or overflow above 2^256-1.
670
+ *
671
+ * Throws {@link InvariantError}, because reaching it means the SDK computed
672
+ * something no chain could represent. **For a value that came off the wire,
673
+ * use {@link parseUint256} instead**: the backend sending an unrepresentable
674
+ * number is a {@link ValidationError}, and the two have different remedies.
675
+ */
676
+ declare const assertUint256: (value: bigint) => Uint256;
677
+ /**
678
+ * {@link assertUint256} at a wire boundary: the same bounds check, reported as
679
+ * a {@link ValidationError} against the named field, because a value out of
680
+ * range here is the backend's, not the SDK's.
681
+ *
682
+ * `label` names the field the way a DTO mapper's other failures do, so a log
683
+ * line says which one - `SwapPreview.pay_input_amount`, not `a number`.
684
+ */
685
+ declare const parseUint256: (value: bigint, label: string) => Uint256;
686
+ type BlockchainAmount = Newtype<{
687
+ raw: Uint256;
688
+ decimals: AssetDecimals;
689
+ }, 'BlockchainAmount'>;
690
+ /**
691
+ * Constructs a {@link BlockchainAmount} and exposes arithmetic helpers.
692
+ * TypeScript has no operator overloading, so use `BlockchainAmount.add(a, b)`
693
+ * instead of `+`/`-` on the objects directly.
694
+ */
695
+ declare const BlockchainAmount: ((value: {
696
+ raw: Uint256;
697
+ decimals: AssetDecimals;
698
+ }) => BlockchainAmount) & {
699
+ add: (a: BlockchainAmount, b: BlockchainAmount) => BlockchainAmount;
700
+ sub: (a: BlockchainAmount, b: BlockchainAmount) => BlockchainAmount;
701
+ };
702
+ type AssetSymbol = Newtype<string, 'AssetSymbol'>;
703
+ declare const AssetSymbol: (value: string) => AssetSymbol;
704
+ /**
705
+ * A stablecoin symbol is an {@link AssetSymbol} narrowed to the coins we
706
+ * support. It shares the `AssetSymbol` brand so it stays assignable to it.
707
+ */
708
+ type StablecoinSymbol = Newtype<'USDC' | 'USDT', 'AssetSymbol'>;
709
+ declare const StablecoinSymbol: (value: "USDC" | "USDT") => StablecoinSymbol;
710
+ type KnownAssetSymbol = StablecoinSymbol;
711
+ declare const KnownAssetSymbol: (value: "USDC" | "USDT") => StablecoinSymbol;
712
+ type Erc20Asset = {
713
+ name: string;
714
+ symbol: AssetSymbol;
715
+ decimals: AssetDecimals;
716
+ };
717
+ type Bps = Newtype<bigint, 'Bps'>;
718
+ declare const Bps: (value: bigint) => Bps;
719
+
720
+ type GetTokenAllowanceParams = {
721
+ tokenAddress: EvmContractAddress;
722
+ owner: EvmWalletAddress;
723
+ spender: EvmContractAddress;
724
+ chain: EthereumChain;
725
+ };
726
+ type GetTokenBalanceParams = {
727
+ tokenAddress: EvmContractAddress;
728
+ owner: EvmWalletAddress;
729
+ chain: EthereumChain;
730
+ };
731
+
732
+ /**
733
+ * OAuth 2.0 token response (RFC 6749 §5.1).
734
+ * Maps to OpenAPI schema OauthToken.
735
+ */
736
+ type OAuthSessionDto = {
737
+ access_token: string;
738
+ expires_in: number;
739
+ refresh_token?: string;
740
+ };
741
+
742
+ type ClientCredentialsOAuth = Newtype<OAuthAccessToken, 'ClientCredentialsOAuth'>;
743
+ declare const ClientCredentialsOAuth: (value: OAuthAccessToken) => ClientCredentialsOAuth;
744
+ type OAuthAccessToken = {
745
+ value: string;
746
+ expiresAt: Date;
747
+ };
748
+ type OAuthRefreshToken = Newtype<string, 'OAuthRefreshToken'>;
749
+ declare const OAuthRefreshToken: (value: string) => OAuthRefreshToken;
750
+ type OAuthSession = {
751
+ accessToken: OAuthAccessToken;
752
+ refreshToken?: OAuthRefreshToken;
753
+ };
754
+ declare const OAuthSession: {
755
+ fromDto: (dto: OAuthSessionDto) => OAuthSession;
756
+ };
757
+
758
+ type HttpRequestAttributes = {
759
+ /**
760
+ * Correlates the log lines of one logical request. Minted by
761
+ * {@link HttpClient} on the first attempt and carried onto every retry and
762
+ * post-renewal re-send by {@link concat}, which is what lets a reader tell
763
+ * three attempts of one request from three separate requests.
764
+ */
765
+ requestId?: RequestId;
766
+ protected?: boolean;
767
+ userAgent?: boolean;
768
+ idempotencyKey?: boolean;
769
+ /** Zero-based attempt index: 0 = first request, 1 = first retry, etc. */
770
+ retryAttempt?: number;
771
+ renewAttempted?: boolean;
772
+ clientCredentials?: ClientCredentialsOAuth;
773
+ };
774
+
775
+ /**
776
+ * The value types a query-string parameter may take.
777
+ *
778
+ * Declared here rather than beside the HTTP client because domain models build
779
+ * query parameters too: `ParticipationsPaginationParams.toQueryParams` returns
780
+ * a `Record<string, QueryParamValue>`, and a domain model must not import
781
+ * `@/shared/api/**`.
782
+ */
783
+ type QueryParamValue = string | number | boolean | null | undefined;
784
+ type QueryParamValues = QueryParamValue | QueryParamValue[];
785
+
786
+ type HttpRequest<TBody = unknown> = {
787
+ method: 'GET';
788
+ url: string;
789
+ queryParams?: Record<string, QueryParamValues>;
790
+ headers?: Record<string, string>;
791
+ attributes?: HttpRequestAttributes;
792
+ redirect?: RequestRedirect;
793
+ } | {
794
+ method: 'POST';
795
+ url: string;
796
+ queryParams?: Record<string, QueryParamValues>;
797
+ headers?: Record<string, string>;
798
+ body: TBody;
799
+ attributes?: HttpRequestAttributes;
800
+ redirect?: RequestRedirect;
801
+ } | {
802
+ method: 'DELETE';
803
+ url: string;
804
+ queryParams?: Record<string, QueryParamValues>;
805
+ headers?: Record<string, string>;
806
+ attributes?: HttpRequestAttributes;
807
+ redirect?: RequestRedirect;
808
+ };
809
+ type HttpResponse<TBody = unknown> = {
810
+ status: number;
811
+ headers?: Record<string, string>;
812
+ body: TBody | null;
813
+ /**
814
+ * The id of the request that produced this response, stamped by
815
+ * {@link HttpClient} so that whoever turns a non-2xx into an
816
+ * {@link HttpError} can carry it without threading the request alongside.
817
+ * Absent when the response did not come from an `HttpClient`.
818
+ */
819
+ requestId?: RequestId;
820
+ };
821
+ declare class HttpError<TBody = unknown> extends Error {
822
+ readonly response: HttpResponse<TBody>;
823
+ constructor(response: HttpResponse<TBody>);
824
+ /**
825
+ * Correlates this failure with the `[HTTP]` log lines for the same request,
826
+ * which carry the method, the URL, the duration and every retry. `null` when
827
+ * the response did not come from an {@link HttpClient}.
828
+ *
829
+ * Worth quoting in a bug report: it is what makes a log excerpt readable.
830
+ */
831
+ get requestId(): RequestId | null;
832
+ }
833
+ /**
834
+ * The machine-readable `code` frontline attaches to an error, or `null` for
835
+ * anything else - a non-HTTP failure, or an error body that carries only a
836
+ * message.
837
+ *
838
+ * Frontline answers a failure with `{ type, message, code?, errors?,
839
+ * event_id? }`, and `code` is the only part of it meant to be branched on:
840
+ * `message` is prose that may be reworded, and `type` distinguishes
841
+ * `invalid_request_error` from `api_error` without saying which one.
842
+ *
843
+ * Reach for this only where a code has a distinct remedy the user can act on.
844
+ * Mapping the whole vocabulary would couple the SDK to strings frontline does
845
+ * not version; falling back to a generic failure is the right default.
846
+ */
847
+ declare function apiErrorCode(error: unknown): string | null;
848
+
849
+ /**
850
+ * Structural interface satisfied by both {@link AuthenticatedApiClient} and
851
+ * {@link ApiClient}. Used by the shared frontline API functions so they can
852
+ * be called from either the client or server without any browser dependencies.
853
+ */
854
+ interface Sender {
855
+ send<T>(request: HttpRequest): Promise<T>;
856
+ }
857
+
858
+ interface SharedNamespaceContext {
859
+ readonly api: Sender;
860
+ /**
861
+ * The host's logger, or `null` when they supplied none.
862
+ *
863
+ * Deliberately the raw port rather than a pre-scoped {@link InternalLogger}:
864
+ * one context serves every namespace, and each namespace owns its own scope.
865
+ * A namespace turns it into something usable in its constructor, with
866
+ * `internalLogger(ctx.logger, 'OFFERS')`.
867
+ */
868
+ readonly logger: Logger | null;
869
+ ensureUserAuthenticated(): Promise<void>;
870
+ }
871
+
872
+ /**
873
+ * Raw JSON models for the on-chain swap endpoints. uint256 values are encoded
874
+ * as decimal strings because they can exceed the safe integer range of JSON
875
+ * consumers.
876
+ */
877
+ type WalletAuthorizationDto = {
878
+ object: 'wallet_authorization';
879
+ authorized: boolean;
880
+ };
881
+ type SwapPreviewDto = {
882
+ object: 'swap_preview';
883
+ pay_input_amount: string;
884
+ fee: string;
885
+ receive_output_amount: string;
886
+ };
887
+ type SwapStatusDto = {
888
+ object: 'swap_status';
889
+ stopped: string;
890
+ swap_level: string;
891
+ };
892
+ type TokenAllowanceDto = {
893
+ object: 'token_allowance';
894
+ allowance: string;
895
+ };
896
+ type TokenBalanceDto = {
897
+ object: 'token_balance';
898
+ balance: string;
899
+ };
900
+ type AllowWalletResponseDto = {
901
+ action: 'broadcast_transaction';
902
+ to: string;
903
+ data: string;
904
+ } | {
905
+ action: 'none';
906
+ already_allowed: boolean;
907
+ };
908
+
909
+ /**
910
+ * Whether a wallet is authorized to interact with a given swap contract.
911
+ */
912
+ type SwapAuthorization = {
913
+ authorized: boolean;
914
+ };
915
+ declare const SwapAuthorization: {
916
+ fromDto: (dto: WalletAuthorizationDto) => SwapAuthorization;
917
+ };
918
+ /**
919
+ * A read-only quote for a swap: how much goes in, the protocol fee, and how
920
+ * much would come out. All amounts are raw on-chain integers (uint256).
921
+ */
922
+ type SwapPreview = {
923
+ inputAmount: Uint256;
924
+ fee: Uint256;
925
+ outputAmount: Uint256;
926
+ };
927
+ declare const SwapPreview: {
928
+ fromDto: (dto: SwapPreviewDto) => SwapPreview;
929
+ };
930
+ /**
931
+ * The on-chain state of a swap contract.
932
+ *
933
+ * - `stopped`: non-zero when the contract is paused/halted.
934
+ * - `swapLevel`: the current swap level/tier.
935
+ */
936
+ type SwapStatus = {
937
+ stopped: Uint256;
938
+ swapLevel: Uint256;
939
+ };
940
+ declare const SwapStatus: {
941
+ fromDto: (dto: SwapStatusDto) => SwapStatus;
942
+ };
943
+ /**
944
+ * The ERC-20 allowance an owner has granted a spender for a token.
945
+ */
946
+ type TokenAllowance = {
947
+ allowance: Uint256;
948
+ };
949
+ declare const TokenAllowance: {
950
+ fromDto: (dto: TokenAllowanceDto) => TokenAllowance;
951
+ };
952
+ /**
953
+ * The raw ERC-20 balance an owner holds of a token (uint256).
954
+ */
955
+ type TokenBalance = {
956
+ balance: Uint256;
957
+ };
958
+ declare const TokenBalance: {
959
+ fromDto: (dto: TokenBalanceDto) => TokenBalance;
960
+ };
961
+ /**
962
+ * The backend's response to an allow-wallet request. Either the caller must
963
+ * broadcast an on-chain transaction to complete allow-listing, or nothing is
964
+ * required because the wallet is already allowed.
965
+ */
966
+ type AllowWalletResponse = {
967
+ action: 'broadcast_transaction';
968
+ to: EvmContractAddress;
969
+ data: HexEncodedTransactionData;
970
+ } | {
971
+ action: 'none';
972
+ alreadyAllowed: boolean;
973
+ };
974
+ declare const AllowWalletResponse: {
975
+ fromDto: (dto: AllowWalletResponseDto) => AllowWalletResponse;
976
+ };
977
+
978
+ /**
979
+ * Generic ERC-20 reads shared across on-chain flows (swap, token sale): the
980
+ * allowance an owner has granted a spender, and the raw token balance an owner
981
+ * holds. These are plain token reads, not tied to any single product flow.
982
+ */
983
+ interface Erc20Namespace {
984
+ /**
985
+ * Reads the ERC-20 allowance an `owner` has granted a `spender`.
986
+ */
987
+ getAllowance(params: GetTokenAllowanceParams): Promise<TokenAllowance>;
988
+ /**
989
+ * Reads the raw ERC-20 balance an `owner` holds of a token.
990
+ */
991
+ getBalance(params: GetTokenBalanceParams): Promise<TokenBalance>;
992
+ }
993
+ declare class Erc20NamespaceImpl implements Erc20Namespace {
994
+ private readonly ctx;
995
+ private readonly log;
996
+ constructor(ctx: SharedNamespaceContext);
997
+ getAllowance(params: GetTokenAllowanceParams): Promise<TokenAllowance>;
998
+ getBalance(params: GetTokenBalanceParams): Promise<TokenBalance>;
999
+ }
1000
+
1001
+ /**
1002
+ * The logging surface SDK code uses. Never exported to hosts: they implement
1003
+ * {@link Logger}, which is deliberately smaller.
1004
+ */
1005
+ type InternalLogger = {
1006
+ /**
1007
+ * A logger narrowed by one more {@link LogBinding}, which every line it
1008
+ * emits carries as its own field.
1009
+ */
1010
+ child(binding: LogBinding): InternalLogger;
1011
+ /**
1012
+ * The unredacted level. Request and response bodies, full URLs, headers,
1013
+ * operation params and raw thrown errors belong here and **only** here.
1014
+ */
1015
+ debug(event: () => InternalDebugEvent): void;
1016
+ info(event: () => InternalSafeEvent): void;
1017
+ warn(event: () => InternalSafeEvent): void;
1018
+ /**
1019
+ * Reports a failure whose cause is already known, or has none. Prefer
1020
+ * {@link failure}, which classifies a thrown error for you.
1021
+ */
1022
+ error(event: () => InternalSafeEvent): void;
1023
+ /**
1024
+ * Reports a thrown error, classifying it into a {@link LogCause}. Prefer
1025
+ * this over `error` at a `catch`: classification only happens when the level
1026
+ * admits it.
1027
+ *
1028
+ * The `error` line names the error's class but never its message, since an
1029
+ * error the SDK did not author may say anything at all. The verbatim
1030
+ * rendering goes onto a paired `debug` line instead.
1031
+ *
1032
+ * For a failure the SDK recovers from, use {@link warning} instead. An
1033
+ * `error` line a host cannot act on is worse than no line at all: it trains
1034
+ * them to ignore the ones that matter.
1035
+ */
1036
+ failure(event: () => InternalSafeEvent, error: unknown): void;
1037
+ /**
1038
+ * {@link failure} for trouble that did not break anything: a poll tick that
1039
+ * failed while the last value still stands, a retried request.
1040
+ *
1041
+ * Carries the classified {@link LogCause} exactly as `failure` does. The two
1042
+ * differ in level and in nothing else, because what separates them is
1043
+ * whether anything actually broke - not how much is known about it.
1044
+ */
1045
+ warning(event: () => InternalSafeEvent, error: unknown): void;
1046
+ /**
1047
+ * Runs one namespace operation with logging around it: the call and its
1048
+ * params at `debug`, and any throw at `error` with the cause classified.
1049
+ * Every line carries `op` as a binding.
1050
+ *
1051
+ * **The params never reach the `error` line.** They routinely hold the
1052
+ * things this SDK must not put in front of a production error tracker - an
1053
+ * app bearer token, a document's signing fields, a wallet signature - and
1054
+ * the `debug` line plus the request id is how you get them back. The type
1055
+ * says so: `params` is `unknown`, which is not a {@link SafeFields} value.
1056
+ *
1057
+ * Always rethrows. Logging observes behaviour, it never changes it.
1058
+ */
1059
+ wrap<T>(op: string, params: unknown, run: () => Promise<T>): Promise<T>;
1060
+ };
1061
+ /**
1062
+ * What a call site hands to `info`, `warn`, `error`, `failure` or `warning` -
1063
+ * a {@link SafeEvent} minus the scope and bindings the logger stamps itself.
1064
+ */
1065
+ type InternalSafeEvent = {
1066
+ /** A **constant** string literal. Every varying value belongs in `fields`. */
1067
+ readonly msg: string;
1068
+ readonly fields?: SafeFields;
1069
+ readonly cause?: LogCause;
1070
+ };
1071
+ /** What a call site hands to `debug`. Its fields accept anything. */
1072
+ type InternalDebugEvent = {
1073
+ /** A **constant** string literal. Every varying value belongs in `fields`. */
1074
+ readonly msg: string;
1075
+ readonly fields?: UnredactedFields;
1076
+ };
1077
+
1078
+ /**
1079
+ * The product an offer is checked out through. The backend sends one compound
1080
+ * `{supplier}::{saleType}` string, verbatim as spelled below: a double colon
1081
+ * between the two halves, `snake_case` within each. CoinList's token sale is
1082
+ * `coinlist::token_sale`; there is no `coinlist::sale` and no
1083
+ * `coinlist_token_sale`.
1084
+ *
1085
+ * Kept flat rather than split into a supplier and a sale type, because a flat
1086
+ * union makes a `switch` over it exhaustive: adding a provider without
1087
+ * handling it becomes a compile error.
1088
+ */
1089
+ type OfferTypeDto = 'coinlist::token_sale' | 'superstate::swap' | 'ondo::swap';
1090
+ type OfferDto = {
1091
+ id: string;
1092
+ slug: string;
1093
+ type: OfferTypeDto;
1094
+ tagline: string;
1095
+ banner_url: string;
1096
+ logo_url: string;
1097
+ starts_at: string;
1098
+ ends_at: string | null;
1099
+ tokens: OfferTokenDto[];
1100
+ };
1101
+ type OfferTokenDto = {
1102
+ role: 'funding' | 'distribution' | 'swap';
1103
+ chain: string;
1104
+ address: string;
1105
+ };
1106
+
1107
+ type OfferId = Newtype<string, 'OfferId'>;
1108
+ declare const OfferId: (value: string) => OfferId;
1109
+ type OfferSlug = Newtype<string, 'OfferSlug'>;
1110
+ declare const OfferSlug: (value: string) => OfferSlug;
1111
+ type OfferType = OfferTypeDto;
1112
+ type Offer = {
1113
+ id: OfferId;
1114
+ slug: OfferSlug;
1115
+ type: OfferType;
1116
+ tagline: string;
1117
+ bannerUrl: string;
1118
+ logoUrl: string;
1119
+ startsAt: Date;
1120
+ endsAt: Date | null;
1121
+ tokens: OfferToken[];
1122
+ };
1123
+ declare const Offer: {
1124
+ fromDto: (dto: OfferDto) => Offer;
1125
+ };
1126
+ type TokenRole = 'funding' | 'distribution' | 'swap';
1127
+ type OfferToken = {
1128
+ role: TokenRole;
1129
+ chain: Chain;
1130
+ address: EvmContractAddress;
1131
+ };
1132
+ declare const OfferToken: {
1133
+ fromDto: (dto: OfferTokenDto) => OfferToken;
1134
+ };
1135
+
1136
+ /**
1137
+ * The cursor-paginated envelope every list endpoint returns.
1138
+ *
1139
+ * Generic in its item type, so each resource pairs it with its own item DTO
1140
+ * rather than declaring an envelope of its own.
1141
+ */
1142
+ interface PaginatedResponseDto<T> {
1143
+ data: T[];
1144
+ starting_after?: string;
1145
+ starting_before?: string;
1146
+ }
1147
+
1148
+ type Cursor = Newtype<string, 'Cursor'>;
1149
+ declare const Cursor: (value: string) => Cursor;
1150
+ interface PaginatedResponse<T> {
1151
+ data: T[];
1152
+ startingAfter: Cursor | null;
1153
+ startingBefore: Cursor | null;
1154
+ }
1155
+ declare const PaginatedResponse: {
1156
+ fromDto: <A, B>(dto: PaginatedResponseDto<A>, itemMapper: (item: A) => B) => PaginatedResponse<B>;
1157
+ };
1158
+ /**
1159
+ * Cursor-based pagination input used when requesting paginated API resources.
1160
+ * Set `after` or `before` to navigate relative to a known cursor, and `limit`
1161
+ * to control the maximum number of returned items.
1162
+ */
1163
+ interface PaginationParams {
1164
+ before?: Cursor;
1165
+ after?: Cursor;
1166
+ limit?: number;
1167
+ }
1168
+ declare const PaginationParams: {
1169
+ toQueryParams: (params: PaginationParams) => Record<string, QueryParamValue>;
1170
+ };
1171
+
1172
+ type AssetDto = {
1173
+ code: string;
1174
+ fractional_digits: number;
1175
+ id: string;
1176
+ name: string;
1177
+ };
1178
+
1179
+ type AssetId = Newtype<string, 'AssetId'>;
1180
+ declare const AssetId: (value: string) => AssetId;
1181
+ type AssetCode = Newtype<string, 'AssetCode'>;
1182
+ declare const AssetCode: (value: string) => AssetCode;
1183
+ type Asset = {
1184
+ id: AssetId;
1185
+ code: AssetCode;
1186
+ name: string;
1187
+ fractionalDigits: number;
1188
+ };
1189
+ declare const Asset: {
1190
+ fromDto: (dto: AssetDto) => Asset;
1191
+ };
1192
+
1193
+ type ParticipationStatusDto = 'prepared' | 'pending' | 'submitted' | 'completed' | 'failed' | 'remit_submitted' | 'remitted' | 'remit_failed';
1194
+ type ParticipationDto = {
1195
+ object: 'participation';
1196
+ id: string;
1197
+ offer_id: string;
1198
+ offer_option_id: string;
1199
+ status: ParticipationStatusDto;
1200
+ amount: string;
1201
+ amount_string: string;
1202
+ asset: AssetDto;
1203
+ chain: string;
1204
+ inserted_at: string | null | undefined;
1205
+ updated_at: string | null | undefined;
1206
+ wallet_address: string | null | undefined;
1207
+ };
1208
+ type CreateParticipationDto = {
1209
+ offer_id: string;
1210
+ offer_option_id: string;
1211
+ chain: string;
1212
+ wallet_address: string;
1213
+ amount: string;
1214
+ asset_id: string;
1215
+ approval_transaction_hash: string | null | undefined;
1216
+ };
1217
+
1218
+ type OfferDetailDto = {
1219
+ asset: AssetDto;
1220
+ faqs: OfferDetailFaqDto[];
1221
+ funding_assets: AssetDto[];
1222
+ tokens: OfferTokenDto[];
1223
+ id: string;
1224
+ links: OfferDetailLinkDto[];
1225
+ milestones: OfferDetailMilestoneDto[];
1226
+ name: string;
1227
+ object: 'offer_details';
1228
+ options: OfferDetailOptionDto[];
1229
+ slug: string;
1230
+ type: OfferTypeDto;
1231
+ terms: OfferDetailTermDto[];
1232
+ about: string | null | undefined;
1233
+ banner_url: string;
1234
+ category: string;
1235
+ ends_at: string | null;
1236
+ logo_url: string;
1237
+ starts_at: string;
1238
+ tagline: string;
1239
+ };
1240
+ type OfferDetailFaqDto = {
1241
+ answer: string | null;
1242
+ question: string | null;
1243
+ };
1244
+ type OfferDetailLinkDto = {
1245
+ label: string | null;
1246
+ url: string | null;
1247
+ };
1248
+ type OfferDetailMilestoneDto = {
1249
+ name: string | null;
1250
+ schedule: string | null;
1251
+ status: 'completed' | 'active' | 'upcoming';
1252
+ };
1253
+ type OfferDetailOptionDto = {
1254
+ bid_increment: number | null;
1255
+ floor_price_usd: number | null;
1256
+ id: string;
1257
+ minimum_purchase_usd: number | null;
1258
+ price_usd: string | null;
1259
+ sale_agreement_url: string | null;
1260
+ slug: string;
1261
+ total_token_supply: number | null;
1262
+ };
1263
+ type OfferDetailTermDto = {
1264
+ key: string | null;
1265
+ value: string | null;
1266
+ };
1267
+
1268
+ type OfferOptionId = Newtype<string, 'OfferOptionId'>;
1269
+ declare const OfferOptionId: (value: string) => OfferOptionId;
1270
+ type OfferOptionSlug = Newtype<string, 'OfferOptionSlug'>;
1271
+ declare const OfferOptionSlug: (value: string) => OfferOptionSlug;
1272
+ type OfferDetail = {
1273
+ id: OfferId;
1274
+ slug: OfferSlug;
1275
+ type: OfferType;
1276
+ name: string;
1277
+ asset: Asset;
1278
+ fundingAssets: Asset[];
1279
+ tokens: OfferToken[];
1280
+ about: string | null;
1281
+ tagline: string;
1282
+ bannerUrl: string;
1283
+ logoUrl: string;
1284
+ category: string;
1285
+ startsAt: Date;
1286
+ endsAt: Date | null;
1287
+ faqs: FaqItem[];
1288
+ links: Link[];
1289
+ milestones: Milestone[];
1290
+ options: OfferOption[];
1291
+ terms: TermItem[];
1292
+ };
1293
+ declare const OfferDetail: {
1294
+ fromDto: (dto: OfferDetailDto) => OfferDetail;
1295
+ };
1296
+ type OfferOption = {
1297
+ id: OfferOptionId;
1298
+ slug: OfferOptionSlug;
1299
+ bidIncrement: number | null;
1300
+ floorPriceUsd: number | null;
1301
+ minimumPurchaseUsd: number | null;
1302
+ priceUsd: string | null;
1303
+ saleAgreementUrl: string | null;
1304
+ totalTokenSupply: number | null;
1305
+ };
1306
+ declare const OfferOption: {
1307
+ fromDto: (dto: OfferDetailOptionDto) => OfferOption;
1308
+ };
1309
+ type FaqItem = {
1310
+ question: string | null;
1311
+ answer: string | null;
1312
+ };
1313
+ declare const FaqItem: {
1314
+ fromDto: (dto: OfferDetailFaqDto) => FaqItem;
1315
+ };
1316
+ type Link = {
1317
+ label: string | null;
1318
+ url: string | null;
1319
+ };
1320
+ declare const Link: {
1321
+ fromDto: (dto: OfferDetailLinkDto) => Link;
1322
+ };
1323
+ type TermItem = {
1324
+ key: string | null;
1325
+ value: string | null;
1326
+ };
1327
+ declare const TermItem: {
1328
+ fromDto: (dto: OfferDetailTermDto) => TermItem;
1329
+ };
1330
+ type Milestone = {
1331
+ name: string | null;
1332
+ schedule: string | null;
1333
+ status: 'completed' | 'active' | 'upcoming';
1334
+ };
1335
+ declare const Milestone: {
1336
+ fromDto: (dto: OfferDetailMilestoneDto) => Milestone;
1337
+ };
1338
+
1339
+ /** Unique identifier for a participation. */
1340
+ type ParticipationId = Newtype<string, 'ParticipationId'>;
1341
+ /** Casts a string into a typed {@link ParticipationId}. */
1342
+ declare const ParticipationId: (value: string) => ParticipationId;
1343
+ /** Blockchain identifier for where a participation is funded. */
1344
+ type Blockchain = Newtype<string, 'Blockchain'>;
1345
+ /** Casts a string into a typed {@link Blockchain}. */
1346
+ declare const Blockchain: (value: string) => Blockchain;
1347
+ /** Wallet address used for a participation. */
1348
+ type WalletAddress = Newtype<`0x${string}`, 'WalletAddress'>;
1349
+ /** Casts a `0x`-prefixed string into a typed {@link WalletAddress}. */
1350
+ declare const WalletAddress: (value: `0x${string}`) => WalletAddress;
1351
+ /** Possible participation lifecycle states returned by the API. */
1352
+ type ParticipationStatus = ParticipationStatusDto;
1353
+ /** Pagination params for listing participations, with an optional offer filter. */
1354
+ interface ParticipationsPaginationParams extends PaginationParams {
1355
+ offerId?: OfferId;
1356
+ }
1357
+ declare const ParticipationsPaginationParams: {
1358
+ toQueryParams: (params: ParticipationsPaginationParams) => Record<string, QueryParamValue>;
1359
+ };
1360
+ /** Domain model for a participation returned by CoinList APIs. */
1361
+ type Participation = {
1362
+ /** Unique participation id. */
1363
+ id: ParticipationId;
1364
+ /** Parent offer id. */
1365
+ offerId: OfferId;
1366
+ /** Selected offer option id. */
1367
+ offerOptionId: OfferOptionId;
1368
+ /** Current processing status. */
1369
+ status: ParticipationStatus;
1370
+ /** Raw participation amount from API. */
1371
+ amount: string;
1372
+ /** Human-readable formatted amount from API. */
1373
+ displayAmount: string;
1374
+ /** Asset metadata for the participation amount. */
1375
+ asset: Asset;
1376
+ /** Funding chain identifier. */
1377
+ chain: Blockchain;
1378
+ /** Creation timestamp, if returned by API. */
1379
+ insertedAt: Date | null;
1380
+ /** Last update timestamp, if returned by API. */
1381
+ updatedAt: Date | null;
1382
+ /** Wallet used for participation, blank values normalized to null. */
1383
+ walletAddress: WalletAddress | null;
1384
+ };
1385
+ declare const Participation: {
1386
+ /** Maps API DTO shape into the SDK participation domain model. */
1387
+ fromDto: (dto: ParticipationDto) => Participation;
1388
+ };
1389
+ /** Parameters required to create a new participation. */
1390
+ type CreateParticipationParams = {
1391
+ /** Offer to participate in. */
1392
+ offerId: OfferId;
1393
+ /** Offer option selected for participation. */
1394
+ offerOptionId: OfferOptionId;
1395
+ /** Blockchain for funding. */
1396
+ chain: Blockchain;
1397
+ /** Wallet address that funds the participation. */
1398
+ walletAddress: WalletAddress;
1399
+ /**
1400
+ * Decimal token amount to participate with (e.g. `"100"` for 100 USDC), NOT
1401
+ * raw base units. The backend rescales this by the asset's decimals to verify
1402
+ * it against the on-chain approval allowance.
1403
+ */
1404
+ amount: string;
1405
+ /** Funding asset id. */
1406
+ assetId: AssetId;
1407
+ /**
1408
+ * Hash of the ERC-20 `approve()` transaction covering this participation.
1409
+ * Required: the backend verifies it on-chain (sender, token, spender, and
1410
+ * approved amount) before confirming the participation.
1411
+ */
1412
+ approvalTransactionHash: string;
1413
+ };
1414
+ declare const CreateParticipationParams: {
1415
+ /** Maps participation creation params into API DTO payload. */
1416
+ toDto: (params: CreateParticipationParams) => CreateParticipationDto;
1417
+ };
1418
+
1419
+ /**
1420
+ * Read/write operations for token sales: listing and reading the current user's
1421
+ * participations, and recording a new one. The on-chain execution flow
1422
+ * (`executeTokenSale`) is layered on top of this in the client-side namespace.
1423
+ */
1424
+ interface CoinListTokenSaleNamespace {
1425
+ /**
1426
+ * Fetches all participations by iterating through every paginated response,
1427
+ * optionally filtered by offer.
1428
+ *
1429
+ * Requires an authenticated user; throws {@link NotAuthenticatedError}
1430
+ * otherwise.
1431
+ */
1432
+ list(offerId?: OfferId): Promise<Participation[]>;
1433
+ /**
1434
+ * Fetches a single page of participations, optionally filtered by offer.
1435
+ *
1436
+ * Requires an authenticated user; throws {@link NotAuthenticatedError}
1437
+ * otherwise.
1438
+ */
1439
+ listPage(params: ParticipationsPaginationParams): Promise<PaginatedResponse<Participation>>;
1440
+ /**
1441
+ * Fetches a participation by id.
1442
+ *
1443
+ * Requires an authenticated user; throws {@link NotAuthenticatedError}
1444
+ * otherwise.
1445
+ */
1446
+ get(id: ParticipationId): Promise<Participation>;
1447
+ /**
1448
+ * Records a participation with CoinList.
1449
+ *
1450
+ * Requires an authenticated user; throws {@link NotAuthenticatedError}
1451
+ * otherwise.
1452
+ */
1453
+ createParticipation(params: CreateParticipationParams): Promise<Participation>;
1454
+ }
1455
+ declare class CoinListTokenSaleNamespaceImpl implements CoinListTokenSaleNamespace {
1456
+ private readonly ctx;
1457
+ protected readonly log: InternalLogger;
1458
+ constructor(ctx: SharedNamespaceContext);
1459
+ list(offerId?: OfferId): Promise<Participation[]>;
1460
+ listPage(params: ParticipationsPaginationParams): Promise<PaginatedResponse<Participation>>;
1461
+ get(id: ParticipationId): Promise<Participation>;
1462
+ createParticipation(params: CreateParticipationParams): Promise<Participation>;
1463
+ }
1464
+
1465
+ type Ticker = Newtype<string, 'Ticker'>;
1466
+ declare const Ticker: (value: string) => Ticker;
1467
+ type OrderBookSide = 'buy' | 'sell';
1468
+
1469
+ /**
1470
+ * No `chain` on the read params: Ondo runs no sandbox, so every environment
1471
+ * prices against Ondo production on Ethereum mainnet. Accepting a chain would
1472
+ * let a caller ask for Sepolia and silently receive mainnet pricing.
1473
+ * {@link BuildOndoSwapTransactionParams} is the exception, and says why.
1474
+ */
1475
+ type GetOndoTradingStatusParams = {
1476
+ symbol: AssetSymbol;
1477
+ /**
1478
+ * Required, and deliberately not defaulted: `tradable` and both order caps
1479
+ * describe this side only. Guessing `buy` would hand buy caps to someone
1480
+ * sizing a sell. The endpoint answers 422 without it.
1481
+ */
1482
+ side: OrderBookSide;
1483
+ };
1484
+ /** How long Ondo should hold the price. Omit to take Ondo's own default. */
1485
+ type OndoQuoteDuration = 'short' | 'long';
1486
+ /**
1487
+ * A quote is sized by the quantity or by the dollar amount. The endpoint takes
1488
+ * exactly one; `getOndoQuote` sends whichever is present.
1489
+ */
1490
+ type OndoQuoteSize = {
1491
+ tokenAmount: BlockchainAmount;
1492
+ } | {
1493
+ notionalValue: DecimalString;
1494
+ };
1495
+ type GetOndoQuoteParams = {
1496
+ symbol: AssetSymbol;
1497
+ side: OrderBookSide;
1498
+ duration?: OndoQuoteDuration;
1499
+ } & OndoQuoteSize;
1500
+ /**
1501
+ * What it takes to turn an indicative price into signed, fillable calldata.
1502
+ *
1503
+ * Sized by `amount` alone - the coin being spent, in its own base units - with
1504
+ * no `notionalValue` alternative: the calldata authorises a specific ERC-20
1505
+ * pull, so the number that ends up on chain has to be the number the caller
1506
+ * meant, not one derived from a dollar figure. It is the **gross**: CoinList's
1507
+ * fee comes off it, and Ondo prices the remainder.
1508
+ *
1509
+ * Buy-only, so there is no `side`. There is no funding token either - frontline
1510
+ * resolves both tokens from the offer, because Ninshubur signs a request bound
1511
+ * to them and a caller that could name them could have CoinList sign for a
1512
+ * contract of its own.
1513
+ *
1514
+ * `chain` is required here although the read params refuse it, because this
1515
+ * one names a real contract on a real chain rather than asking Ondo for a
1516
+ * price. `walletAddress` must be the wallet that will *send* the transaction:
1517
+ * the calldata is signed over it, so a transaction built for one wallet and
1518
+ * broadcast by another reverts.
1519
+ */
1520
+ type BuildOndoSwapTransactionParams = {
1521
+ symbol: AssetSymbol;
1522
+ chain: EthereumChain;
1523
+ /** The wallet that will broadcast, and that receives the asset. */
1524
+ walletAddress: EvmWalletAddress;
1525
+ /**
1526
+ * The gross amount to spend, in the funding token's base units.
1527
+ *
1528
+ * Its `decimals` are also what the response's `pay_input_decimals` is
1529
+ * checked against: frontline resolves the funding token from the offer
1530
+ * rather than from this request, so the two are independent answers to the
1531
+ * same question and a disagreement means the wrong token was sized.
1532
+ */
1533
+ amount: BlockchainAmount;
1534
+ };
1535
+
1536
+ /**
1537
+ * Raw JSON models for the Ondo swap endpoints, mirroring
1538
+ * `OndoSwapTradingStatus`, `OndoSwapQuote` and `OndoSwapTransaction` in
1539
+ * frontline's OpenAPI schema. The two GETs are free to poll: neither spends an
1540
+ * attestation, so a client may call them while the user edits an order. The
1541
+ * POST ({@link OndoSwapTransactionDto}) is not - it spends one and hands back
1542
+ * signed calldata with a deadline.
1543
+ *
1544
+ * Neither GET takes a `chain`. Ondo runs no sandbox, so every environment
1545
+ * prices against Ondo production on Ethereum mainnet. The POST does carry one:
1546
+ * it targets a real contract, which on every environment but production is the
1547
+ * Sepolia one with the mocked attestation.
1548
+ */
1549
+ /**
1550
+ * Whether an asset can be traded right now, and the caps if so.
1551
+ *
1552
+ * Every cap is a *human decimal* string and is nullable — Ondo answers a
1553
+ * restricted `/v1/limits/*` with a 403, which frontline turns into
1554
+ * `tradable: false` and three nulls rather than an error. A null cap therefore
1555
+ * means **Ondo restricted the asset, not that the cap is unlimited**. The
1556
+ * response carries no `asset_decimals`, so there is nothing to scale
1557
+ * `gross_max_tokens` by.
1558
+ *
1559
+ * There is no `reason` field. A restriction surfaces only as `tradable: false`
1560
+ * plus the nulls; frontline keeps Ondo's reason codes to its own admin surface
1561
+ * and does not forward them.
1562
+ */
1563
+ type OndoTradingStatusDto = {
1564
+ object: 'ondo_swap_trading_status';
1565
+ /** The `side` the request asked for, echoed back. */
1566
+ side: 'buy' | 'sell';
1567
+ /** For `side` only — an asset can be sellable while not buyable. */
1568
+ tradable: boolean;
1569
+ /** Whole tokens, for `side` only. E.g. `"100.000000000000000000"`. */
1570
+ gross_max_tokens: string | null;
1571
+ /** USD, for `side` only. E.g. `"1234.560000000000000000"`. */
1572
+ gross_max_notional_value: string | null;
1573
+ /**
1574
+ * USD cap for the session the market is currently in, e.g. `"200000"`.
1575
+ * Unlike the two above this comes from Ondo's sideless session endpoint, so
1576
+ * it applies across buys and sells together.
1577
+ */
1578
+ gross_max_active_notional_value: string | null;
1579
+ };
1580
+ /** An indicative, size- and side-aware price for an Ondo asset. */
1581
+ type OndoQuoteDto = {
1582
+ object: 'ondo_swap_quote';
1583
+ /** EIP-155 chain id. Always `"1"`, per the no-sandbox note above. */
1584
+ chain_id: string;
1585
+ symbol: string;
1586
+ /** Ticker of the underlying security, e.g. `"AAPL"` for `"AAPLon"`. */
1587
+ ticker: string;
1588
+ asset_address: string;
1589
+ /** Decimals of the `asset_address` contract. Scales `token_base_units`. */
1590
+ asset_decimals: number;
1591
+ side: 'buy' | 'sell';
1592
+ /**
1593
+ * Quantity of the asset in its smallest unit, as a raw uint256 string:
1594
+ * `"5000000000000000000"` is 5 tokens at 18 decimals. Map it with
1595
+ * `blockchainAmountFromRawOrThrow`, not `parseBlockchainAmountOrThrow`.
1596
+ *
1597
+ * Not to be confused with the `token_amount` *request* parameter, which is
1598
+ * the same quantity in whole tokens. Ondo names both `tokenAmount`, 1e18
1599
+ * apart, so echoing one back as the other is a real hazard.
1600
+ */
1601
+ token_base_units: string;
1602
+ /**
1603
+ * USD price of one whole token as a human decimal string, e.g.
1604
+ * `"225.273151158540753535"`. Already scaled, so it needs none of the
1605
+ * handling `token_base_units` does.
1606
+ */
1607
+ price: string;
1608
+ };
1609
+ /**
1610
+ * Signed, ready-to-broadcast calldata for a buy, and the amounts it commits
1611
+ * to: `POST /v1/ondo/swap/transaction`.
1612
+ *
1613
+ * Unlike {@link OndoQuoteDto} this **spends an attestation**, so it is not
1614
+ * pollable: one call per order, plus one per user-requested refresh. Frontline
1615
+ * also reads the wallet's allowance before asking Ninshubur for anything, so
1616
+ * an unapproved wallet is refused here rather than reverting on chain.
1617
+ *
1618
+ * Buy-only. There is no `side`: the funding token goes in and the asset comes
1619
+ * out, both resolved from the offer, so a caller cannot name either.
1620
+ *
1621
+ * **Carries no identity and no price.** No `chain_id`, `symbol`, `ticker`,
1622
+ * `side` or `price` - the request named the first few and frontline drops
1623
+ * Ninshubur's `price` deliberately, because `GET /v1/ondo/swap/quote` already
1624
+ * publishes one under that name at a different scale. Anything the UI needs
1625
+ * beyond the amounts comes from that GET or from the offer.
1626
+ *
1627
+ * Every amount is a uint256 decimal string in one of two scales, and **both
1628
+ * scales are on the wire**: `receive_output_amount` is in
1629
+ * `receive_output_decimals`, and the other three are in
1630
+ * `pay_input_decimals`. Neither is interchangeable with the quote's
1631
+ * `asset_decimals`, which answers for a different number - see the two fields
1632
+ * below.
1633
+ *
1634
+ * The response has no `object` envelope. `action` says what to do with the
1635
+ * body, matching `AllowWalletResponseDto`.
1636
+ */
1637
+ type OndoSwapTransactionDto = {
1638
+ action: 'broadcast_transaction';
1639
+ /** The swap contract the transaction is sent to. */
1640
+ to: string;
1641
+ /** ABI-encoded `swap(...)` calldata. Broadcast verbatim - never re-encode it. */
1642
+ data: string;
1643
+ /**
1644
+ * When the signed calldata stops being accepted - RFC3339, e.g.
1645
+ * `"2026-08-13T23:04:12Z"`. This is Ninshubur's `expiration`, which signs
1646
+ * the same instant as the EIP-712 `deadline` in the calldata, so a
1647
+ * transaction broadcast after it reverts.
1648
+ */
1649
+ expires_at: string;
1650
+ /**
1651
+ * Gross amount the wallet pays, echoing the requested `amount`, in the
1652
+ * funding token's smallest unit. The approval is compared against this.
1653
+ */
1654
+ pay_input_amount: string;
1655
+ /**
1656
+ * Decimals `pay_input_amount`, `fee` and `notional_value` are counted in.
1657
+ *
1658
+ * Frontline reads it on-chain from the funding token, which it resolves from
1659
+ * the offer rather than from anything the caller sent. That makes it the
1660
+ * only published scale for a token the request never names - and an
1661
+ * independent answer to the one the SDK derived when it sized the order,
1662
+ * which is why `buildOndoSwapTransaction` compares the two.
1663
+ */
1664
+ pay_input_decimals: number;
1665
+ /**
1666
+ * CoinList's cut of `pay_input_amount`, in the same units. Taken off the
1667
+ * deposit rather than added on top, so the approval never has to cover more.
1668
+ * `"0"` until ENG-1718 turns a fee on - frontline rejects a non-zero one
1669
+ * today.
1670
+ */
1671
+ fee: string;
1672
+ /**
1673
+ * `pay_input_amount` less `fee`, in the same units. This is the amount Ondo
1674
+ * actually priced, and the numerator of the fill price.
1675
+ */
1676
+ notional_value: string;
1677
+ /**
1678
+ * Quantity of the asset the wallet receives, in the *asset's* smallest unit,
1679
+ * e.g. `"264000000000000000"`. Scale it by `receive_output_decimals`, not by
1680
+ * the funding token's and not by {@link OndoQuoteDto}'s `asset_decimals`.
1681
+ */
1682
+ receive_output_amount: string;
1683
+ /**
1684
+ * Decimals `receive_output_amount` is counted in.
1685
+ *
1686
+ * Reported by whatever priced the quantity, rather than looked up from the
1687
+ * asset. That is not the same number as {@link OndoQuoteDto}'s
1688
+ * `asset_decimals`, which frontline resolves from its own catalogue: the two
1689
+ * are allowed to disagree, and only this one answers for the quantity in
1690
+ * this response.
1691
+ */
1692
+ receive_output_decimals: number;
1693
+ };
1694
+
1695
+ /**
1696
+ * Whether an Ondo asset can be traded right now.
1697
+ *
1698
+ * The caps only mean anything while trading is open, so they live on the
1699
+ * `tradable` branch. They stay {@link DecimalString} rather than
1700
+ * {@link BlockchainAmount} because the response carries no `asset_decimals`:
1701
+ * there is no honest exponent to attach, and the USD caps arrive with more
1702
+ * fractional digits than a stablecoin has decimals.
1703
+ *
1704
+ * Each cap is independently nullable even when tradable — Ondo may open an
1705
+ * asset for trading without publishing every limit.
1706
+ *
1707
+ * `side` is carried through from the response rather than dropped: the whole
1708
+ * status describes one side, so a buy and a sell status are otherwise
1709
+ * indistinguishable once a caller holds both.
1710
+ */
1711
+ type OndoTradingStatus = {
1712
+ type: 'tradable';
1713
+ side: OrderBookSide;
1714
+ /** Largest order in whole tokens. */
1715
+ grossMaxTokens: DecimalString | null;
1716
+ /** Largest order in USD. */
1717
+ grossMaxNotionalValue: DecimalString | null;
1718
+ /** USD cap for the session the market is currently in. */
1719
+ grossMaxActiveNotionalValue: DecimalString | null;
1720
+ } | {
1721
+ type: 'not-tradable';
1722
+ side: OrderBookSide;
1723
+ };
1724
+ declare const OndoTradingStatus: {
1725
+ fromDto: (dto: OndoTradingStatusDto) => OndoTradingStatus;
1726
+ };
1727
+ /**
1728
+ * An indicative price for an Ondo asset, free to poll while the user edits an
1729
+ * order.
1730
+ *
1731
+ * **No CoinList fee is applied to the quantity or the price.** Ondo prices
1732
+ * exactly the amount asked for. A CoinList approval is fee-inclusive, so
1733
+ * sizing a quote against one without netting the fee first overstates what the
1734
+ * user receives. Showing a gross/net breakdown needs a CoinList swap
1735
+ * contract's `preview`, and no such contract exists for Ondo yet.
1736
+ *
1737
+ * The quote carries no transaction to broadcast and no expiry. Building one is
1738
+ * a separate endpoint that spends an attestation - see
1739
+ * {@link OndoSwapTransaction}.
1740
+ */
1741
+ type OndoQuote = {
1742
+ /** Always `ethereum_mainnet`: Ondo runs no sandbox in any environment. */
1743
+ chain: EthereumChain;
1744
+ ticker: Ticker;
1745
+ /** Needed to approve or transfer the asset; the quote is the only source. */
1746
+ assetAddress: EvmContractAddress;
1747
+ /**
1748
+ * The asset as the quote resolves it, from frontline's own catalogue.
1749
+ *
1750
+ * Its `decimals` scale {@link tokenBaseUnits} and nothing else. They are
1751
+ * **not** the scale of an {@link OndoSwapTransaction}'s output: that one is
1752
+ * reported by whatever priced the quantity, the two sources are allowed to
1753
+ * disagree, and only the one that produced a number answers for it.
1754
+ */
1755
+ asset: Erc20Asset;
1756
+ side: OrderBookSide;
1757
+ tokenBaseUnits: BlockchainAmount;
1758
+ /**
1759
+ * USD price of one whole token. Unscaled because Ondo has already scaled it,
1760
+ * and by USDon's 18 decimals rather than the stablecoin's 6 — re-scaling it
1761
+ * by either would be wrong.
1762
+ */
1763
+ price: DecimalString;
1764
+ };
1765
+ declare const OndoQuote: {
1766
+ fromDto: (dto: OndoQuoteDto) => OndoQuote;
1767
+ };
1768
+ /**
1769
+ * A signed, expiring buy: the calldata that fills it and the amounts it
1770
+ * commits to, from `buildSwapTransaction`.
1771
+ *
1772
+ * Distinct from {@link OndoQuote} in three ways that matter: it costs an
1773
+ * attestation to obtain, it expires, and it carries a {@link Tx} the wallet
1774
+ * broadcasts verbatim. Treat it as single-use - once broadcast (or once
1775
+ * `expiresAt` passes) it is spent, and a new one must be built.
1776
+ *
1777
+ * **It carries no identity.** No chain, ticker, asset or side: the endpoint
1778
+ * publishes none of them, and inventing them from the request would assert
1779
+ * what the server resolved rather than report it. What it does publish is the
1780
+ * scale of every amount on it, so a caller needs nothing alongside it to read
1781
+ * the numbers - only to name the asset, which the offer already does.
1782
+ *
1783
+ * It carries no price either. Divide {@link notionalValue} by
1784
+ * {@link receiveOutputAmount} - see `computeOndoPrice` - which is the price
1785
+ * this transaction actually fills at rather than an indicative one that has
1786
+ * since moved.
1787
+ */
1788
+ type OndoSwapTransaction = {
1789
+ /**
1790
+ * Broadcast as-is. The `to` is the swap contract, which is also the ERC-20
1791
+ * spender the user must have approved.
1792
+ */
1793
+ tx: Tx;
1794
+ /**
1795
+ * When the calldata stops being accepted. A transaction broadcast after this
1796
+ * reverts, so callers must compare against it before signing.
1797
+ */
1798
+ expiresAt: Date;
1799
+ /** Gross amount the wallet pays, in the funding token's decimals. */
1800
+ payInputAmount: BlockchainAmount;
1801
+ /**
1802
+ * CoinList's cut of {@link payInputAmount}, in the same decimals. Taken off
1803
+ * the deposit rather than added on top, so the approval never has to cover
1804
+ * more than `payInputAmount`. Zero until ENG-1718 lands.
1805
+ */
1806
+ fee: BlockchainAmount;
1807
+ /**
1808
+ * `payInputAmount` less `fee`, in the same decimals: what Ondo priced.
1809
+ *
1810
+ * Read from the response rather than subtracted here. Whether the fee comes
1811
+ * off the deposit or goes on top of it is the server's definition to change,
1812
+ * and a client that derives this cannot notice when it does.
1813
+ */
1814
+ notionalValue: BlockchainAmount;
1815
+ /**
1816
+ * What the buyer receives, at the scale whatever priced the quantity
1817
+ * reported - not at the {@link OndoQuote}'s.
1818
+ */
1819
+ receiveOutputAmount: BlockchainAmount;
1820
+ };
1821
+ declare const OndoSwapTransaction: {
1822
+ fromDto: (dto: OndoSwapTransactionDto) => OndoSwapTransaction;
1823
+ };
1824
+
1825
+ /**
1826
+ * Ondo swap reads, plus the write that turns one into a fillable transaction.
1827
+ *
1828
+ * The two reads are free to poll - neither spends an attestation, so a client
1829
+ * may call them while the user edits an order. {@link buildSwapTransaction} is
1830
+ * not: budget one call per order placed, plus one per refresh the user asks
1831
+ * for.
1832
+ *
1833
+ * **No CoinList fee is applied to a read quote, and no read discloses one.**
1834
+ * Ondo prices exactly the amount passed. A CoinList approval is fee-inclusive,
1835
+ * so sizing a quote against a user's approval without subtracting the fee
1836
+ * first overstates what they receive. A built transaction carries the fee
1837
+ * explicitly, and it is zero until one lands (ENG-1718).
1838
+ *
1839
+ * Every method requires `AuthState === 'logged-in'` and throws
1840
+ * {@link NotAuthenticatedError} otherwise.
1841
+ */
1842
+ interface OndoNamespace {
1843
+ getTradingStatus(params: GetOndoTradingStatusParams): Promise<OndoTradingStatus>;
1844
+ getQuote(params: GetOndoQuoteParams): Promise<OndoQuote>;
1845
+ /**
1846
+ * Builds the buy for a specific wallet and amount: spends an attestation and
1847
+ * returns calldata to broadcast, valid until
1848
+ * {@link OndoSwapTransaction.expiresAt}.
1849
+ *
1850
+ * The wallet must have approved the swap contract to spend `amount` of the
1851
+ * offer's funding token first - frontline reads the allowance before asking
1852
+ * Ninshubur for anything, and rejects a short one with a 422 carrying
1853
+ * `code: "insufficient_allowance"`. See `prepareSwap` on the client
1854
+ * namespace, which approves and then builds, in that order.
1855
+ *
1856
+ * Buy-only, and the tokens are the offer's rather than the caller's to name.
1857
+ */
1858
+ buildSwapTransaction(params: BuildOndoSwapTransactionParams): Promise<OndoSwapTransaction>;
1859
+ }
1860
+ declare class OndoNamespaceImpl implements OndoNamespace {
1861
+ private readonly ctx;
1862
+ protected readonly log: InternalLogger;
1863
+ constructor(ctx: SharedNamespaceContext);
1864
+ getTradingStatus(params: GetOndoTradingStatusParams): Promise<OndoTradingStatus>;
1865
+ getQuote(params: GetOndoQuoteParams): Promise<OndoQuote>;
1866
+ buildSwapTransaction(params: BuildOndoSwapTransactionParams): Promise<OndoSwapTransaction>;
1867
+ }
1868
+
1869
+ /** Parameters shared by contract reads scoped to a chain. */
1870
+ type SwapContractRef = {
1871
+ contractAddress: EvmContractAddress;
1872
+ chain: EthereumChain;
1873
+ };
1874
+ type GetSwapAuthorizationParams = SwapContractRef & {
1875
+ walletAddress: EvmWalletAddress;
1876
+ };
1877
+ type GetSwapPreviewParams = SwapContractRef & {
1878
+ inputToken: EvmContractAddress;
1879
+ amount: bigint;
1880
+ };
1881
+ type AllowWalletParams = {
1882
+ offerId: OfferId;
1883
+ walletAddress: EvmWalletAddress;
1884
+ chain: EthereumChain;
1885
+ signature: string;
1886
+ };
1887
+
1888
+ /**
1889
+ * Read/write operations for the on-chain swap flow: quoting a swap, inspecting
1890
+ * contract state, checking token allowances, and proving/allow-listing wallet
1891
+ * ownership.
1892
+ */
1893
+ interface SuperstateSwapNamespace {
1894
+ /**
1895
+ * Checks whether a wallet is authorized to swap against the given contract.
1896
+ */
1897
+ getAuthorization(params: GetSwapAuthorizationParams): Promise<SwapAuthorization>;
1898
+ /**
1899
+ * Fetches a read-only quote for swapping `amount` of `inputToken`.
1900
+ */
1901
+ getPreview(params: GetSwapPreviewParams): Promise<SwapPreview>;
1902
+ /**
1903
+ * Reads the current on-chain state of a swap contract.
1904
+ */
1905
+ getStatus(params: SwapContractRef): Promise<SwapStatus>;
1906
+ /**
1907
+ * Reads the ERC-20 output token a swap contract pays out.
1908
+ */
1909
+ getOutputToken(params: SwapContractRef): Promise<Erc20Asset>;
1910
+ /**
1911
+ * Submits a signed wallet-ownership challenge to allow-list the wallet for
1912
+ * an offer, identified by its offer id. Obtain the challenge from
1913
+ * `WalletsNamespace.createOwnershipChallenge`.
1914
+ */
1915
+ allowWallet(params: AllowWalletParams): Promise<AllowWalletResponse>;
1916
+ }
1917
+ declare class SuperstateSwapNamespaceImpl implements SuperstateSwapNamespace {
1918
+ private readonly ctx;
1919
+ protected readonly log: InternalLogger;
1920
+ constructor(ctx: SharedNamespaceContext);
1921
+ getAuthorization(params: GetSwapAuthorizationParams): Promise<SwapAuthorization>;
1922
+ getPreview(params: GetSwapPreviewParams): Promise<SwapPreview>;
1923
+ getStatus(params: SwapContractRef): Promise<SwapStatus>;
1924
+ getOutputToken(params: SwapContractRef): Promise<Erc20Asset>;
1925
+ allowWallet(params: AllowWalletParams): Promise<AllowWalletResponse>;
1926
+ }
1927
+
1928
+ /** Request body for `POST /v1/offers/:offer_id/addresses`. */
1929
+ type CreateOfferOptionAddressDto = {
1930
+ offer_option_id: string;
1931
+ wallet_address: string;
1932
+ chain: string;
1933
+ signature: string;
1934
+ };
1935
+ /** Binding object returned by the `/v1/offers/:offer_id/addresses` resource. */
1936
+ type OfferOptionAddressDto = {
1937
+ id: string;
1938
+ offer_option_id: string;
1939
+ address: string;
1940
+ protocol: WalletProtocol;
1941
+ created_at: string;
1942
+ };
1943
+
1944
+ /** Unique identifier for a proven wallet binding on an offer option. */
1945
+ type OfferOptionAddressId = Newtype<string, 'OfferOptionAddressId'>;
1946
+ /** Casts a string into a typed {@link OfferOptionAddressId}. */
1947
+ declare const OfferOptionAddressId: (value: string) => OfferOptionAddressId;
1948
+ /**
1949
+ * A user's external wallet, proven via a wallet-ownership challenge and bound
1950
+ * to an offer option. Returned by the `/v1/offers/:offer_id/addresses` resource.
1951
+ */
1952
+ type OfferOptionAddress = {
1953
+ /** Unique binding id. */
1954
+ id: OfferOptionAddressId;
1955
+ /** Offer option the wallet is bound to. */
1956
+ offerOptionId: OfferOptionId;
1957
+ /** The connected external wallet address. */
1958
+ address: EvmWalletAddress;
1959
+ /**
1960
+ * Protocol the binding is scoped to. An EVM address binds once per option
1961
+ * regardless of which EVM chain proved ownership.
1962
+ */
1963
+ protocol: WalletProtocol;
1964
+ /** When the binding was created. */
1965
+ createdAt: Date;
1966
+ };
1967
+ declare const OfferOptionAddress: {
1968
+ /** Maps the API DTO into the SDK offer-option-address domain model. */
1969
+ fromDto: (dto: OfferOptionAddressDto) => OfferOptionAddress;
1970
+ };
1971
+ /** Parameters required to connect a proven external wallet to an offer option. */
1972
+ type ConnectExternalWalletParams = {
1973
+ /** Offer the option belongs to. */
1974
+ offerId: OfferId;
1975
+ /** Offer option to bind the wallet to. */
1976
+ offerOptionId: OfferOptionId;
1977
+ /** External wallet address that was proven. */
1978
+ walletAddress: EvmWalletAddress;
1979
+ /** Chain the ownership was proven on. */
1980
+ chain: EthereumChain;
1981
+ /** Signature of the wallet-ownership challenge message. */
1982
+ signature: Hex;
1983
+ };
1984
+ declare const ConnectExternalWalletParams: {
1985
+ /** Maps connect-wallet params into the API DTO payload. */
1986
+ toDto: (params: ConnectExternalWalletParams) => CreateOfferOptionAddressDto;
1987
+ };
1988
+
1989
+ /** Challenge kinds accepted by `POST /v1/wallet-ownership`. */
1990
+ type WalletOwnershipChallengeTypeDto = 'plain' | 'siwe';
1991
+ /**
1992
+ * Request body for `POST /v1/wallet-ownership`. `challenge_type` defaults to
1993
+ * `plain` on the backend; the SIWE fields (`domain`, `uri`, `statement`) are
1994
+ * required only when `challenge_type` is `siwe` and must be absent otherwise.
1995
+ */
1996
+ type CreateWalletOwnershipChallengeDto = {
1997
+ wallet_address: string;
1998
+ chain: string;
1999
+ challenge_type?: WalletOwnershipChallengeTypeDto;
2000
+ domain?: string;
2001
+ uri?: string;
2002
+ statement?: string;
2003
+ };
2004
+ /** Response body for `POST /v1/wallet-ownership`. */
2005
+ type WalletOwnershipChallengeDto = {
2006
+ message: string;
2007
+ expires_at: string;
2008
+ };
2009
+
2010
+ /** Fields common to every wallet-ownership challenge request. */
2011
+ type WalletOwnershipChallengeParamsBase = {
2012
+ /** Wallet address to prove ownership of. */
2013
+ walletAddress: EvmWalletAddress;
2014
+ /** Chain the wallet belongs to. */
2015
+ chain: EthereumChain;
2016
+ };
2017
+ /**
2018
+ * How the ownership challenge is framed: a plain message or a Sign-In With
2019
+ * Ethereum challenge. Extracted as its own type so SDK consumers can pass it as
2020
+ * a standalone param without reaching into the {@link CreateWalletOwnershipChallengeParams}
2021
+ * union.
2022
+ */
2023
+ type WalletChallengeType = CreateWalletOwnershipChallengeParams['challengeType'];
2024
+ /**
2025
+ * A single-use ownership challenge returned by `POST /v1/wallet-ownership`.
2026
+ * The consumer signs {@link message} with their wallet, then submits the
2027
+ * signature to connect the wallet to an offer option.
2028
+ */
2029
+ type WalletOwnershipChallenge = {
2030
+ /** The message the wallet must sign. */
2031
+ message: string;
2032
+ /** When the challenge expires and can no longer be consumed. */
2033
+ expiresAt: Date;
2034
+ };
2035
+ declare const WalletOwnershipChallenge: {
2036
+ /** Maps the API DTO into the SDK wallet-ownership-challenge domain model. */
2037
+ fromDto: (dto: WalletOwnershipChallengeDto) => WalletOwnershipChallenge;
2038
+ };
2039
+ /**
2040
+ * Parameters for requesting a wallet-ownership challenge. Modeled as a
2041
+ * discriminated union on `challengeType` so a `siwe` challenge must carry
2042
+ * `domain`/`uri`/`statement`, matching the backend contract at compile time.
2043
+ */
2044
+ type CreateWalletOwnershipChallengeParams = (WalletOwnershipChallengeParamsBase & {
2045
+ /** A bare message the wallet signs. */
2046
+ challengeType: 'plain';
2047
+ }) | (WalletOwnershipChallengeParamsBase & {
2048
+ /** Marks this as a Sign-In With Ethereum challenge. */
2049
+ challengeType: 'siwe';
2050
+ /** The requesting site's hostname (e.g. `example.com`). */
2051
+ domain: string;
2052
+ /** The requesting site's URI. */
2053
+ uri: string;
2054
+ /** Human-readable statement shown in the signing prompt. */
2055
+ statement: string;
2056
+ });
2057
+ declare const CreateWalletOwnershipChallengeParams: {
2058
+ /**
2059
+ * Maps challenge-request params into the API DTO payload. The discriminated
2060
+ * union guarantees SIWE fields are present exactly when `challengeType` is
2061
+ * `siwe`, so the mapping narrows on the discriminant.
2062
+ */
2063
+ toDto: (params: CreateWalletOwnershipChallengeParams) => CreateWalletOwnershipChallengeDto;
2064
+ };
2065
+
2066
+ type ListOptionAddressesParams = {
2067
+ offerId: OfferId;
2068
+ /** Offer option whose bindings to list. */
2069
+ offerOptionId: OfferOptionId;
2070
+ };
2071
+ type RemoveOptionAddressParams = {
2072
+ offerId: OfferId;
2073
+ /** Binding to remove, as returned by {@link WalletsNamespace.list}. */
2074
+ addressId: OfferOptionAddressId;
2075
+ };
2076
+ /**
2077
+ * The user's external wallets: proving ownership of one, binding it to an
2078
+ * offer option, and managing those bindings.
2079
+ *
2080
+ * Ownership proof is a provider-agnostic primitive — the swap flow uses the
2081
+ * same challenge to allow-list a wallet — so it lives here rather than being
2082
+ * duplicated per product namespace.
2083
+ *
2084
+ * Every method requires an authenticated user and throws
2085
+ * {@link NotAuthenticatedError} otherwise.
2086
+ */
2087
+ interface WalletsNamespace {
2088
+ /**
2089
+ * Creates a single-use challenge the user signs to prove they control a
2090
+ * wallet. Supports both `plain` and `siwe` challenges. Pass the signature of
2091
+ * the returned {@link WalletOwnershipChallenge.message} to
2092
+ * {@link connectExternal}.
2093
+ */
2094
+ createOwnershipChallenge(params: CreateWalletOwnershipChallengeParams): Promise<WalletOwnershipChallenge>;
2095
+ /**
2096
+ * Binds a proven external wallet to an offer option, using a signature of a
2097
+ * challenge from {@link createOwnershipChallenge}.
2098
+ */
2099
+ connectExternal(params: ConnectExternalWalletParams): Promise<OfferOptionAddress>;
2100
+ /**
2101
+ * Lists the user's proven wallet bindings for one offer option — the single
2102
+ * bound address for an `external_wallet` option, or every allow-listed
2103
+ * wallet for a `whitelisted_wallet` option.
2104
+ */
2105
+ list(params: ListOptionAddressesParams): Promise<OfferOptionAddress[]>;
2106
+ /**
2107
+ * Removes one of the user's wallet bindings and returns the removed binding.
2108
+ */
2109
+ remove(params: RemoveOptionAddressParams): Promise<OfferOptionAddress>;
2110
+ }
2111
+ declare class WalletsNamespaceImpl implements WalletsNamespace {
2112
+ private readonly ctx;
2113
+ private readonly log;
2114
+ constructor(ctx: SharedNamespaceContext);
2115
+ createOwnershipChallenge(params: CreateWalletOwnershipChallengeParams): Promise<WalletOwnershipChallenge>;
2116
+ connectExternal(params: ConnectExternalWalletParams): Promise<OfferOptionAddress>;
2117
+ list(params: ListOptionAddressesParams): Promise<OfferOptionAddress[]>;
2118
+ remove(params: RemoveOptionAddressParams): Promise<OfferOptionAddress>;
2119
+ }
2120
+
2121
+ type DocumentSubmissionStatusDto = 'INITIALIZED' | 'SENT' | 'VIEWED' | 'COMPLETED' | 'DECLINED' | 'EXPIRED';
2122
+ type DocumentFormTypeDto = 'w8_ben' | 'w8_ben_e';
2123
+ type DocumentSubmissionDto = {
2124
+ object: 'document_submission';
2125
+ status: DocumentSubmissionStatusDto;
2126
+ form_type: DocumentFormTypeDto;
2127
+ };
2128
+
2129
+ /** Document types that can be signed via {@link CoinListClient.submitDocument}. */
2130
+ type DocumentType = 'tax_certification';
2131
+ /** Signing-state machine status for a document submission. */
2132
+ type DocumentSubmissionStatus = DocumentSubmissionStatusDto;
2133
+ /** The tax form derived from the entity's kind (individual vs company/trust). */
2134
+ type DocumentFormType = DocumentFormTypeDto;
2135
+ /** Result of starting (or resuming) a document signing submission. */
2136
+ type DocumentSubmission = {
2137
+ status: DocumentSubmissionStatus;
2138
+ formType: DocumentFormType;
2139
+ };
2140
+ declare const DocumentSubmission: {
2141
+ fromDto: (dto: DocumentSubmissionDto) => DocumentSubmission;
2142
+ };
2143
+
2144
+ type KycTokenDto = {
2145
+ object: 'kyc_token';
2146
+ token: string;
2147
+ };
2148
+
2149
+ /**
2150
+ * Sumsub verification level name. Determines which screens the Sumsub WebSDK
2151
+ * shows (levels are configured in the Sumsub dashboard). The backend
2152
+ * prescribes the level (and whether the applicant must be reset first) in the
2153
+ * requirement statuses response — clients never compute levels themselves.
2154
+ */
2155
+ type KycLevelName = string;
2156
+ /** Short-lived Sumsub WebSDK access token scoped to the current user. */
2157
+ type KycToken = {
2158
+ token: string;
2159
+ };
2160
+ declare const KycToken: {
2161
+ fromDto: (dto: KycTokenDto) => KycToken;
2162
+ };
2163
+
2164
+ type PiiKindDto = 'person' | 'company';
2165
+ type PiiJurisdictionDto = {
2166
+ iso_2: string;
2167
+ name: string | null;
2168
+ };
2169
+ type PiiAddressDto = {
2170
+ street: string | null;
2171
+ city: string | null;
2172
+ state: string | null;
2173
+ postal_code: string | null;
2174
+ country: string | null;
2175
+ };
2176
+ type PiiDto = {
2177
+ object: 'user_pii';
2178
+ kind: PiiKindDto;
2179
+ full_legal_name: string | null;
2180
+ date_of_birth: string | null;
2181
+ jurisdiction: PiiJurisdictionDto | null;
2182
+ tax_id: string | null;
2183
+ permanent_address: PiiAddressDto;
2184
+ };
2185
+
2186
+ /** Whether the PII belongs to an individual or a company/trust entity. */
2187
+ type PiiKind = PiiKindDto;
2188
+ /** ISO 3166-1 alpha-2 country code (e.g. `'US'`). */
2189
+ type Iso2CountryCode = Newtype<string, 'Iso2CountryCode'>;
2190
+ declare const Iso2CountryCode: (value: string) => Iso2CountryCode;
2191
+ /** Jurisdiction derived from the entity's address country. */
2192
+ type PiiJurisdiction = {
2193
+ iso2: Iso2CountryCode;
2194
+ name: string | null;
2195
+ };
2196
+ declare const PiiJurisdiction: {
2197
+ fromDto: (dto: PiiJurisdictionDto) => PiiJurisdiction;
2198
+ };
2199
+ /** Permanent address on file for the entity. */
2200
+ type PiiAddress = {
2201
+ street: string | null;
2202
+ city: string | null;
2203
+ state: string | null;
2204
+ postalCode: string | null;
2205
+ country: string | null;
2206
+ };
2207
+ declare const PiiAddress: {
2208
+ fromDto: (dto: PiiAddressDto) => PiiAddress;
2209
+ };
2210
+ /**
2211
+ * The current user's PII, used to pre-fill tax forms such as the W-8BEN.
2212
+ * Fields the entity hasn't provided are `null`.
2213
+ */
2214
+ type Pii = {
2215
+ kind: PiiKind;
2216
+ fullLegalName: string | null;
2217
+ dateOfBirth: string | null;
2218
+ jurisdiction: PiiJurisdiction | null;
2219
+ taxId: string | null;
2220
+ permanentAddress: PiiAddress;
2221
+ };
2222
+ declare const Pii: {
2223
+ fromDto: (dto: PiiDto) => Pii;
2224
+ };
2225
+
2226
+ type RequirementTypeDto = 'kyc_approved' | 'external_wallet' | 'whitelisted_wallet' | 'jurisdiction' | 'accreditation' | 'document';
2227
+ type RequirementDto = {
2228
+ object: 'requirement';
2229
+ id: string;
2230
+ type: RequirementTypeDto;
2231
+ details: Record<string, unknown> | null;
2232
+ };
2233
+ type RequirementStatusValueDto = 'not_started' | 'in_progress' | 'action_needed' | 'completed' | 'rejected';
2234
+ type RequirementActionNeededReasonDto = 'kyc_not_verified' | 'update_pii_data';
2235
+ /**
2236
+ * Object form of a requirement status, used when the status carries extra
2237
+ * data: the action-needed reason and/or the Sumsub flow that resolves the
2238
+ * requirement (kyc_level + kyc_reset, forwarded to the kyc-token endpoint).
2239
+ */
2240
+ type RequirementStatusObjectDto = {
2241
+ status: RequirementStatusValueDto;
2242
+ action?: RequirementActionNeededReasonDto;
2243
+ kyc_level?: string;
2244
+ kyc_reset?: boolean;
2245
+ };
2246
+ type RequirementStatusesDto = {
2247
+ object: 'requirement_statuses';
2248
+ offer_id: string;
2249
+ statuses: Record<string, RequirementStatusValueDto | RequirementStatusObjectDto>;
2250
+ };
2251
+
2252
+ type RequirementId = Newtype<string, 'RequirementId'>;
2253
+ declare const RequirementId: (value: string) => RequirementId;
2254
+ type RequirementType = RequirementTypeDto;
2255
+ type RequirementStatusValue = RequirementStatusValueDto;
2256
+ type RequirementActionNeededReason = RequirementActionNeededReasonDto;
2257
+ type Requirement = {
2258
+ id: RequirementId;
2259
+ type: RequirementType;
2260
+ details: Record<string, unknown> | null;
2261
+ };
2262
+ declare const Requirement: {
2263
+ fromDto: (dto: RequirementDto) => Requirement;
2264
+ };
2265
+ type RequirementStatusInfo = {
2266
+ id: RequirementId;
2267
+ status: RequirementStatusValue;
2268
+ /** Why the requirement needs action (KYC-backed requirements only). */
2269
+ action: RequirementActionNeededReason | null;
2270
+ /**
2271
+ * The Sumsub verification level that resolves this requirement, prescribed
2272
+ * by the backend. Present exactly when an inline Sumsub flow can be started.
2273
+ */
2274
+ kycLevel?: KycLevelName;
2275
+ /**
2276
+ * Whether the Sumsub applicant must be reset before starting the flow
2277
+ * (redoing an already-approved level, e.g. to update stale PII). Forward to
2278
+ * the kyc-token request as-is.
2279
+ */
2280
+ kycReset?: boolean;
2281
+ };
2282
+ declare const RequirementStatusInfo: {
2283
+ fromStatusesDto: (dto: RequirementStatusesDto) => RequirementStatusInfo[];
2284
+ };
2285
+
2286
+ type CreateKycTokenParams = {
2287
+ /**
2288
+ * Sumsub verification level to run. Defaults to the backend's standard
2289
+ * level.
2290
+ */
2291
+ levelName?: KycLevelName;
2292
+ /**
2293
+ * Resets the Sumsub applicant first, so an already-approved level can be
2294
+ * executed again (e.g. to update stale PII). Pass the `kycReset` value from
2295
+ * the requirement status, and never on mid-flow token refreshes.
2296
+ */
2297
+ reset?: boolean;
2298
+ };
2299
+ type SubmitDocumentParams = {
2300
+ /** Currently only `tax_certification` (W-8BEN / W-8BEN-E). */
2301
+ documentType: DocumentType;
2302
+ /**
2303
+ * Signing-form values keyed by the document's DocuSeal field names,
2304
+ * forwarded verbatim to pre-fill the document.
2305
+ */
2306
+ fields: Record<string, string>;
2307
+ };
2308
+ /**
2309
+ * Everything a user must satisfy before they can participate in an offer:
2310
+ * reading the checklist and its live statuses, and the operations that satisfy
2311
+ * individual requirements — identity verification (KYC) and tax-document
2312
+ * signing.
2313
+ *
2314
+ * Wallet requirements (`external_wallet`, `whitelisted_wallet`) are satisfied
2315
+ * through `WalletsNamespace` instead, since wallet proofs are also used
2316
+ * outside the requirements flow.
2317
+ *
2318
+ * Every method requires an authenticated user and throws
2319
+ * {@link NotAuthenticatedError} otherwise.
2320
+ */
2321
+ interface RequirementsNamespace {
2322
+ /**
2323
+ * Fetches the requirements for every option of an offer, grouped by option
2324
+ * id. This is the definition of the checklist; {@link statuses} tells you
2325
+ * where the user stands against it.
2326
+ */
2327
+ forOffer(offerId: OfferId): Promise<Record<OfferOptionId, Requirement[]>>;
2328
+ /**
2329
+ * Fetches the current user's status for each requirement of an offer.
2330
+ */
2331
+ statuses(offerId: OfferId): Promise<RequirementStatusInfo[]>;
2332
+ /**
2333
+ * Creates a short-lived Sumsub WebSDK access token so an identity
2334
+ * verification (KYC) flow can be started, e.g. by the `IdentityVerification`
2335
+ * component.
2336
+ */
2337
+ createKycToken(params?: CreateKycTokenParams): Promise<KycToken>;
2338
+ /**
2339
+ * Fetches the current user's PII, used to pre-fill tax forms such as the
2340
+ * W-8BEN. Fields the entity hasn't provided are `null`.
2341
+ */
2342
+ getPii(): Promise<Pii>;
2343
+ /**
2344
+ * Starts (or resumes) a document signing submission.
2345
+ */
2346
+ submitDocument(params: SubmitDocumentParams): Promise<DocumentSubmission>;
2347
+ }
2348
+ declare class RequirementsNamespaceImpl implements RequirementsNamespace {
2349
+ protected readonly ctx: SharedNamespaceContext;
2350
+ protected readonly log: InternalLogger;
2351
+ constructor(ctx: SharedNamespaceContext);
2352
+ forOffer(offerId: OfferId): Promise<Record<OfferOptionId, Requirement[]>>;
2353
+ statuses(offerId: OfferId): Promise<RequirementStatusInfo[]>;
2354
+ createKycToken(params?: CreateKycTokenParams): Promise<KycToken>;
2355
+ getPii(): Promise<Pii>;
2356
+ submitDocument(params: SubmitDocumentParams): Promise<DocumentSubmission>;
2357
+ }
2358
+
2359
+ /**
2360
+ * Reads over CoinList's offers: the catalogue a user can browse, and the full
2361
+ * detail of a single offer.
2362
+ *
2363
+ * Every method requires an authenticated user and throws
2364
+ * {@link NotAuthenticatedError} otherwise. On the server, the same reads are
2365
+ * additionally available with an app-level token — see
2366
+ * `ServerOffersNamespace`.
2367
+ */
2368
+ interface OffersNamespace {
2369
+ /**
2370
+ * Fetches every offer, iterating through all pages. Prefer {@link listPage}
2371
+ * when you render a paginated list yourself.
2372
+ */
2373
+ list(): Promise<Offer[]>;
2374
+ /**
2375
+ * Fetches a single page of offers. Pass the previous response's
2376
+ * `startingAfter` as `after` to advance.
2377
+ */
2378
+ listPage(params: PaginationParams): Promise<PaginatedResponse<Offer>>;
2379
+ /**
2380
+ * Fetches the full detail of one offer, including its options. Note this
2381
+ * returns {@link OfferDetail} — a richer model than the {@link Offer}
2382
+ * summaries {@link list} returns.
2383
+ */
2384
+ get(id: OfferId): Promise<OfferDetail>;
2385
+ }
2386
+ declare class OffersNamespaceImpl implements OffersNamespace {
2387
+ private readonly ctx;
2388
+ private readonly log;
2389
+ constructor(ctx: SharedNamespaceContext);
2390
+ list(): Promise<Offer[]>;
2391
+ listPage(params: PaginationParams): Promise<PaginatedResponse<Offer>>;
2392
+ get(id: OfferId): Promise<OfferDetail>;
2393
+ }
2394
+
2395
+ /**
2396
+ * Raw JSON from the token registry (Nabu), a static CDN serving token display
2397
+ * metadata. It is a separate backend from frontline: responses omit optional
2398
+ * fields rather than sending `null`, and may grow unknown fields at any time;
2399
+ * we only read the fields named here.
2400
+ */
2401
+ type NabuLogoImageDto = {
2402
+ url: string;
2403
+ width: number;
2404
+ height: number;
2405
+ };
2406
+ /**
2407
+ * A logo is either a single vector (valid at any size) or a dimensioned
2408
+ * raster original plus pre-scaled variants at ascending widths.
2409
+ */
2410
+ type NabuLogoDto = {
2411
+ kind: 'VECTOR';
2412
+ url: string;
2413
+ } | {
2414
+ kind: 'RASTER';
2415
+ original: NabuLogoImageDto;
2416
+ variants: NabuLogoImageDto[];
2417
+ };
2418
+ /** One token from the registry's `/{chain}/token/{address}` route. */
2419
+ type NabuTokenDto = {
2420
+ data_version: string;
2421
+ schema_version: number;
2422
+ chain: string;
2423
+ protocol: string;
2424
+ chain_id: number;
2425
+ kind: string;
2426
+ name: string;
2427
+ symbol: string;
2428
+ decimals: number;
2429
+ logo: NabuLogoDto;
2430
+ logo_dark?: NabuLogoDto;
2431
+ coingecko_id?: string;
2432
+ teller_code?: string;
2433
+ address: string;
2434
+ };
2435
+ /**
2436
+ * One asset inside a chain snapshot. The snapshot mixes the chain's native
2437
+ * coin (`kind: 'COIN'`, no address) with its tokens (`kind: 'TOKEN'`), so
2438
+ * `address` is optional here where {@link NabuTokenDto} requires it.
2439
+ */
2440
+ type NabuChainAssetDto = {
2441
+ kind: string;
2442
+ name: string;
2443
+ symbol: string;
2444
+ decimals: number;
2445
+ logo: NabuLogoDto;
2446
+ logo_dark?: NabuLogoDto;
2447
+ address?: string;
2448
+ };
2449
+ /** The registry's `/{chain}/assets.json` route: one chain, all its assets. */
2450
+ type NabuChainAssetsDto = {
2451
+ data_version: string;
2452
+ schema_version: number;
2453
+ chain: string;
2454
+ protocol: string;
2455
+ assets: NabuChainAssetDto[];
2456
+ };
2457
+ /** The registry's `/assets.json` route: the complete snapshot, every chain. */
2458
+ type NabuRegistryDto = {
2459
+ data_version: string;
2460
+ schema_version: number;
2461
+ chains: Array<{
2462
+ chain: string;
2463
+ protocol: string;
2464
+ assets: NabuChainAssetDto[];
2465
+ }>;
2466
+ };
2467
+
2468
+ /**
2469
+ * An absolute URL to a logo image in the token registry. Registry image URLs
2470
+ * are content-fingerprinted and served immutable, so a value is safe to cache
2471
+ * for as long as you hold it.
2472
+ */
2473
+ type TokenLogoUrl = Newtype<string, 'TokenLogoUrl'>;
2474
+ declare const TokenLogoUrl: (value: string) => TokenLogoUrl;
2475
+ type TokenLogoImage = {
2476
+ url: TokenLogoUrl;
2477
+ width: number;
2478
+ height: number;
2479
+ };
2480
+ /**
2481
+ * `VECTOR` is a single SVG. `RASTER` has webp variants at 32/64/128/256/512px
2482
+ * widths (never wider than the original): use the smallest one that covers
2483
+ * your render size, or `original` if none does.
2484
+ */
2485
+ type TokenLogo = {
2486
+ kind: 'VECTOR';
2487
+ url: TokenLogoUrl;
2488
+ } | {
2489
+ kind: 'RASTER';
2490
+ original: TokenLogoImage;
2491
+ variants: TokenLogoImage[];
2492
+ };
2493
+ declare const TokenLogo: {
2494
+ /** `baseUrl` is the registry origin; registry URLs are root-relative. */
2495
+ fromDto: (dto: NabuLogoDto, baseUrl: string) => TokenLogo;
2496
+ };
2497
+ /**
2498
+ * Display metadata for one token, from CoinList's public token registry.
2499
+ *
2500
+ * Keyed by `(chain, address)` — never by symbol, which can collide. The
2501
+ * registry is curated: a token missing from it is an expected answer, not an
2502
+ * error, so lookups return `null` rather than throwing.
2503
+ */
2504
+ type TokenMetadata = {
2505
+ identifier: TokenIdentifier;
2506
+ name: string;
2507
+ symbol: AssetSymbol;
2508
+ decimals: AssetDecimals;
2509
+ logo: TokenLogo;
2510
+ /** Dark-theme logo; `null` when the registry configures none. */
2511
+ logoDark: TokenLogo | null;
2512
+ };
2513
+ declare const TokenMetadata: {
2514
+ /** `baseUrl` is the registry origin; registry logo URLs are root-relative. */
2515
+ fromDto: (dto: NabuTokenDto, baseUrl: string) => TokenMetadata;
2516
+ /**
2517
+ * Maps the complete registry snapshot to every token it lists across the
2518
+ * chains this SDK models, skipping native coins and chains outside
2519
+ * {@link EthereumChain} (e.g. Solana) rather than failing on them — the
2520
+ * registry may serve chains ahead of the SDK's type surface.
2521
+ */
2522
+ fromRegistryDto: (dto: NabuRegistryDto, baseUrl: string) => TokenMetadata[];
2523
+ /**
2524
+ * Maps a chain snapshot to the tokens it lists, skipping the chain's native
2525
+ * coin (`kind: 'COIN'`, no contract address).
2526
+ */
2527
+ fromChainAssetsDto: (dto: NabuChainAssetsDto, baseUrl: string) => TokenMetadata[];
2528
+ };
2529
+
2530
+ /**
2531
+ * Token display metadata — name, symbol, decimals, and logos — from
2532
+ * CoinList's public token registry, keyed by {@link TokenIdentifier} (the
2533
+ * same chain + address pairs `Offer.tokens` carries).
2534
+ *
2535
+ * Unlike the other namespaces, this one is public: no method requires an
2536
+ * authenticated user, and nothing here touches the CoinList API — reads go to
2537
+ * the registry's CDN.
2538
+ */
2539
+ interface TokensNamespace {
2540
+ /**
2541
+ * Fetches metadata for one token. Returns `null` when the registry does not
2542
+ * list the token — the registry is curated, so callers must fall back to
2543
+ * their own display defaults rather than treat this as an error.
2544
+ */
2545
+ get(token: TokenIdentifier): Promise<TokenMetadata | null>;
2546
+ /**
2547
+ * Fetches every token the registry lists, in one request: the complete
2548
+ * snapshot with no `chain`, or one chain's snapshot with it. Prefer this
2549
+ * over calling {@link get} in a loop when displaying a catalogue — two
2550
+ * hundred tokens across three chains is still a single download.
2551
+ *
2552
+ * The complete snapshot spans every chain the registry knows; tokens on
2553
+ * chains this SDK does not model (e.g. Solana) are left out of the result.
2554
+ *
2555
+ * Unlike {@link get}, a missing snapshot throws rather than returning `[]`:
2556
+ * the registry always publishes the complete snapshot and one per chain it
2557
+ * knows, so an absence is a deployment problem, not an empty catalogue.
2558
+ */
2559
+ list(chain?: EthereumChain): Promise<TokenMetadata[]>;
2560
+ }
2561
+ declare class TokensNamespaceImpl implements TokensNamespace {
2562
+ private readonly api;
2563
+ private readonly log;
2564
+ /**
2565
+ * Takes the registry origin rather than a `SharedNamespaceContext`: the
2566
+ * registry is unauthenticated and on its own host, so the frontline sender
2567
+ * and the auth check would both be dead weight here.
2568
+ */
2569
+ constructor(baseUrl: string, logger?: Logger | null);
2570
+ get(token: TokenIdentifier): Promise<TokenMetadata | null>;
2571
+ list(chain?: EthereumChain): Promise<TokenMetadata[]>;
2572
+ }
2573
+
2574
+ interface Config {
2575
+ /** OAuth2 public identifier. */
2576
+ readonly clientId: ClientId;
2577
+ /**
2578
+ * OAuth2 redirect URI. Recommended to point to a frontend page where
2579
+ * {@link CoinListClient#completeOauth} can be called to complete the PKCE
2580
+ * flow on the client side.
2581
+ */
2582
+ readonly redirectUri: RedirectUri;
2583
+ /**
2584
+ * Recommended to leave undefined. Used to change the CoinList environment;
2585
+ * default is production.
2586
+ */
2587
+ readonly baseUrl?: string;
2588
+ /**
2589
+ * Recommended to leave undefined. Overrides the base URL of the public
2590
+ * token registry backing `coinlist.tokens`; default is the production
2591
+ * registry.
2592
+ */
2593
+ readonly tokensBaseUrl?: string;
2594
+ /**
2595
+ * Where the SDK reports what it is doing. **Omit it and the SDK logs nothing
2596
+ * at all** - no `console` fallback, at any level, on any codepath. Supply
2597
+ * one and every request, every classified failure and every hook state
2598
+ * transition is reported at the level your logger asks for.
2599
+ *
2600
+ * Absent, the SDK says nothing at all - there is no fallback to `console`,
2601
+ * at any level, on any codepath.
2602
+ *
2603
+ * **Running the SDK's logging in production is not advised.** The safest
2604
+ * posture is to leave this undefined outside development, staging and
2605
+ * incident reproduction: a seam that emits nothing cannot disclose anything,
2606
+ * and that property does not depend on the SDK continuing to get redaction
2607
+ * right.
2608
+ *
2609
+ * If you do run one there, run it at `'info'` or above and know what that
2610
+ * does and does not buy you. Those levels are **redacted by construction**:
2611
+ * they carry only SDK-authored classification and server-authored
2612
+ * identifiers, and the type system holds that line rather than a convention -
2613
+ * an event at those levels accepts scalar fields only, so a body, a DTO or
2614
+ * an operation's parameters cannot be put on one. What the SDK does **not**
2615
+ * give you is a warranty that the result is safe for your environment. The
2616
+ * mechanism is checkable and stated; the conclusion depends on your sink,
2617
+ * your retention and your threat model, and it is yours to draw.
2618
+ *
2619
+ * **`'debug'` is not.** It reports request and response bodies, full URLs,
2620
+ * headers and operation parameters verbatim - bearer tokens, KYC answers,
2621
+ * tax-document fields, wallet signatures - and **the SDK does not redact**.
2622
+ * Run it on a developer's machine, in tests, and in beta or staging
2623
+ * environments where the data flowing through is not real customer data.
2624
+ * The shipped implementations make that structural: built with
2625
+ * `isDev: false`, `'debug'` does not typecheck. Either way, filtering,
2626
+ * redaction and retention at your sink are yours, not the SDK's.
2627
+ *
2628
+ * Every method you implement here **must be total**: the SDK calls them on
2629
+ * the codepath of the work they report and does not catch them, so a logger
2630
+ * that throws fails the operation it was describing.
2631
+ *
2632
+ * See {@link Logger} for the full contract, and {@link pinoClientLogger} or
2633
+ * {@link pinoServerLogger} for a ready-made implementation over pino.
2634
+ */
2635
+ readonly logger?: Logger;
2636
+ }
2637
+
2638
+ export { type TokenIdentifier as $, AuthorizationCode as A, BlockchainAmount as B, CodeVerifier as C, type RequirementType as D, type Erc20Namespace as E, type RequirementStatusValue as F, OfferOptionAddress as G, RequirementId as H, DocumentSubmission as I, type WalletChallengeType as J, type KycLevelName as K, type Logger as L, type PinoLoggerOptions as M, OndoTradingStatus as N, OfferId as O, Participation as P, AssetDecimals as Q, type RequirementsNamespace as R, type SharedNamespaceContext as S, type TokensNamespace as T, OndoQuote as U, type OrderBookSide as V, type WalletError as W, type OndoQuoteSize as X, type BuildOndoSwapTransactionParams as Y, OfferOptionAddressId as Z, TokenMetadata as _, EthereumChain as a, OfferSlug as a$, type DebugEvent as a0, type FrontlineEventId as a1, HttpError as a2, type HttpResponse as a3, KycToken as a4, type LogBinding as a5, type LogBindings as a6, type LogCause as a7, type LogLevel as a8, type LogScope as a9, ConnectExternalWalletParams as aA, type CreateKycTokenParams as aB, CreateParticipationParams as aC, CreateWalletOwnershipChallengeParams as aD, Cursor as aE, type DocumentFormType as aF, type DocumentSubmissionStatus as aG, type DocumentType as aH, ETHEREUM_CHAINS as aI, Erc20NamespaceImpl as aJ, FaqItem as aK, type GetOndoQuoteParams as aL, type GetOndoTradingStatusParams as aM, type GetSwapAuthorizationParams as aN, type GetSwapPreviewParams as aO, type GetTokenAllowanceParams as aP, type GetTokenBalanceParams as aQ, HexEncodedTransactionData as aR, Iso2CountryCode as aS, Link as aT, type ListOptionAddressesParams as aU, MAX_ASSET_DECIMALS as aV, MAX_UINT_256 as aW, Milestone as aX, OAuthRefreshToken as aY, OfferOption as aZ, OfferOptionSlug as a_, type LogValue as aa, type ProductionLogLevel as ab, RedactedWalletError as ac, type RequestId as ad, type SafeEvent as ae, type SafeFields as af, type UnredactedFields as ag, OAuthSession as ah, ClientCredentialsOAuth as ai, ClientSecret as aj, type Sender as ak, PaginationParams as al, PaginatedResponse as am, type Uint256 as an, KnownAssetSymbol as ao, DecimalString as ap, SwapStatus as aq, type Newtype as ar, type AllowWalletParams as as, AllowWalletResponse as at, Asset as au, AssetCode as av, Blockchain as aw, Chain as ax, ClientId as ay, CodeChallenge as az, EvmContractAddress as b, OfferToken as b0, OffersNamespaceImpl as b1, type OndoQuoteDuration as b2, PKCEState as b3, type PaginatedResponseDto as b4, ParticipationId as b5, type ParticipationStatus as b6, ParticipationsPaginationParams as b7, Pii as b8, PiiAddress as b9, type WalletProtocol as bA, WalletsNamespaceImpl as bB, apiErrorCode as bC, assertUint256 as bD, parseUint256 as bE, PiiJurisdiction as ba, type PiiKind as bb, type QueryParamValue as bc, type QueryParamValues as bd, RedirectUri as be, type RemoveOptionAddressParams as bf, type RequirementActionNeededReason as bg, SOLANA_CHAINS as bh, STABLE_DECIMALS as bi, SolanaChain as bj, type SubmitDocumentParams as bk, SwapAuthorization as bl, type SwapContractRef as bm, SwapPreview as bn, TermItem as bo, Ticker as bp, TokenAllowance as bq, TokenBalance as br, TokenLogo as bs, type TokenLogoImage as bt, TokenLogoUrl as bu, type TokenRole as bv, TokensNamespaceImpl as bw, type Tx as bx, WalletAddress as by, WalletOwnershipChallenge as bz, type CoinListTokenSaleNamespace as c, OfferOptionId as d, AssetId as e, CoinListTokenSaleNamespaceImpl as f, type OndoNamespace as g, AssetSymbol as h, OndoSwapTransaction as i, OndoNamespaceImpl as j, type SuperstateSwapNamespace as k, type WalletsNamespace as l, Bps as m, EvmWalletAddress as n, SuperstateSwapNamespaceImpl as o, Requirement as p, RequirementsNamespaceImpl as q, type Config as r, type OAuthAccessToken as s, type OffersNamespace as t, type Erc20Asset as u, OfferDetail as v, StablecoinSymbol as w, type OfferType as x, Offer as y, RequirementStatusInfo as z };