@totalis/hip4-client 0.0.0-stage → 0.73.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/CHANGELOG.md +1903 -0
  2. package/LICENSE +202 -0
  3. package/README.md +143 -2
  4. package/dist/api-keys.d.ts +118 -0
  5. package/dist/api-keys.js +104 -0
  6. package/dist/audience-contract.d.ts +52 -0
  7. package/dist/audience-contract.js +1 -0
  8. package/dist/base.d.ts +41 -0
  9. package/dist/base.js +60 -0
  10. package/dist/client.d.ts +16 -0
  11. package/dist/client.js +15 -0
  12. package/dist/controller.d.ts +53 -0
  13. package/dist/controller.js +63 -0
  14. package/dist/errors.d.ts +3 -0
  15. package/dist/errors.js +3 -0
  16. package/dist/flow-errors.d.ts +62 -0
  17. package/dist/flow-errors.js +70 -0
  18. package/dist/generated/account-read.d.ts +2015 -0
  19. package/dist/generated/account-read.js +1 -0
  20. package/dist/generated/api-keys.d.ts +1303 -0
  21. package/dist/generated/api-keys.js +1 -0
  22. package/dist/generated/browse.d.ts +965 -0
  23. package/dist/generated/browse.js +1 -0
  24. package/dist/generated/client.d.ts +104 -0
  25. package/dist/generated/client.js +1 -0
  26. package/dist/generated/errors.d.ts +467 -0
  27. package/dist/generated/errors.js +1792 -0
  28. package/dist/generated/maker.d.ts +47 -0
  29. package/dist/generated/maker.js +1 -0
  30. package/dist/generated/openapi.d.ts +10867 -0
  31. package/dist/generated/openapi.js +1 -0
  32. package/dist/generated/operator.d.ts +7 -0
  33. package/dist/generated/operator.js +1 -0
  34. package/dist/generated/realtime.d.ts +1486 -0
  35. package/dist/generated/realtime.js +1 -0
  36. package/dist/generated/vault-abi.d.ts +49 -0
  37. package/dist/generated/vault-abi.js +70 -0
  38. package/dist/generated/version.d.ts +24 -0
  39. package/dist/generated/version.js +183 -0
  40. package/dist/hypercore.d.ts +111 -0
  41. package/dist/hypercore.js +132 -0
  42. package/dist/maker.d.ts +206 -0
  43. package/dist/maker.js +608 -0
  44. package/dist/money.d.ts +59 -0
  45. package/dist/money.js +66 -0
  46. package/dist/operator.d.ts +4 -0
  47. package/dist/operator.js +4 -0
  48. package/dist/pagination.d.ts +20 -0
  49. package/dist/pagination.js +27 -0
  50. package/dist/partner.d.ts +71 -0
  51. package/dist/partner.js +66 -0
  52. package/dist/realtime.d.ts +19 -0
  53. package/dist/realtime.js +10 -0
  54. package/dist/request.d.ts +115 -0
  55. package/dist/request.js +190 -0
  56. package/dist/signer.d.ts +51 -0
  57. package/dist/signer.js +90 -0
  58. package/dist/stream.d.ts +142 -0
  59. package/dist/stream.js +331 -0
  60. package/dist/totalis.d.ts +719 -0
  61. package/dist/totalis.js +1251 -0
  62. package/dist/typed-data.d.ts +330 -0
  63. package/dist/typed-data.js +340 -0
  64. package/dist/ui.d.ts +54 -0
  65. package/dist/ui.js +77 -0
  66. package/dist/wallet-session.d.ts +52 -0
  67. package/dist/wallet-session.js +63 -0
  68. package/examples/browser-wallet.html +69 -0
  69. package/examples/browser-wallet.mjs +57 -0
  70. package/examples/node-bot.mjs +57 -0
  71. package/examples/onboard.mjs +132 -0
  72. package/examples/partner-frontend.mjs +44 -0
  73. package/examples/partner-server.mjs +22 -0
  74. package/package.json +105 -4
@@ -0,0 +1,719 @@
1
+ import { issueApiKey, rotateApiKey } from "./api-keys.js";
2
+ import { type AccessToken, type ApiClientOptions, type PublicEnvironment } from "./base.js";
3
+ import type { paths } from "./generated/client.js";
4
+ import { type BridgedCash, type HypercoreAnswer, type HypercoreTransport, type SignedSendAsset } from "./hypercore.js";
5
+ import { BalanceUnknownError, EntryError, ExitUnavailableError } from "./flow-errors.js";
6
+ import { ApiError, NetworkError, type RetryPolicy } from "./request.js";
7
+ import { type SignerInput } from "./signer.js";
8
+ import { TotalisStream, type StreamEvent, type StreamOptions, type StreamSubscription } from "./stream.js";
9
+ import { type Hex } from "./typed-data.js";
10
+ type Json<T> = T extends {
11
+ readonly content: {
12
+ readonly "application/json": infer Body;
13
+ };
14
+ } ? Body : never;
15
+ export type ResponseOf<Paths, P extends keyof Paths, M extends keyof Paths[P], S extends number> = Paths[P][M] extends {
16
+ readonly responses: infer R;
17
+ } ? S extends keyof R ? Json<R[S]> : never : never;
18
+ type Ok<P extends keyof paths, M extends keyof paths[P], S extends number = 200> = ResponseOf<paths, P, M, S>;
19
+ export type RequestOf<Paths, P extends keyof Paths, M extends keyof Paths[P]> = Paths[P][M] extends {
20
+ readonly requestBody?: infer B;
21
+ } ? Json<NonNullable<B>> : never;
22
+ type CommandOf<P extends keyof paths, M extends keyof paths[P] = "post" & keyof paths[P]> = RequestOf<paths, P, M>;
23
+ type AcceptCommand = CommandOf<"/v1/quotes/{quote_id}/accept">;
24
+ type Funding = NonNullable<AcceptCommand["funding"]>;
25
+ type CoreExitRequest = {
26
+ readonly amount: Amount;
27
+ readonly purpose?: "ORDER" | "WITHDRAW";
28
+ readonly exitId?: string;
29
+ readonly activationFeeAccepted?: boolean;
30
+ };
31
+ export type Deployment = Ok<"/v1/deployment", "get">;
32
+ /** One live unsigned quote, told apart by `kind`: `ENTRY` (`entry`), `SELL_BACK` (`sell_back`) or `TRANSFER` (`transfer`). */
33
+ export type Quote = Ok<"/v1/rfqs/{rfq_id}/quotes", "get">["quotes"][number];
34
+ export type EntryQuote = Extract<Quote, {
35
+ readonly kind: "ENTRY";
36
+ }>;
37
+ /** A cash-out quote from the maker that backs the position: it buys the position back. */
38
+ export type SellBackQuote = Extract<Quote, {
39
+ readonly kind: "SELL_BACK";
40
+ }>;
41
+ /** A cash-out quote from another maker: it takes over the position. */
42
+ export type TransferQuote = Extract<Quote, {
43
+ readonly kind: "TRANSFER";
44
+ }>;
45
+ /** A cash-out quote: a sell-back or a transfer. */
46
+ export type CashoutBid = SellBackQuote | TransferQuote;
47
+ export type Acceptance = Ok<"/v1/quotes/{quote_id}/acceptance", "get">;
48
+ /** An accept whose response was lost and that the venue never admitted: cancel fenced the RFQ first. Nothing traded. */
49
+ export type NotAdmitted = {
50
+ readonly status: "NOT_ADMITTED";
51
+ readonly quote_id: string;
52
+ readonly rfq_id: string;
53
+ };
54
+ export type Operation = Ok<"/v1/me/operations/{operation_id}", "get">["operation"];
55
+ export type Withdrawal = Ok<"/v1/me/withdrawals/{withdrawal_id}", "get">;
56
+ export type CoreExit = Ok<"/v1/core-exits/{exit_id}", "get">;
57
+ /** A transaction the wallet sends itself, paying its own gas. */
58
+ export type WalletCall = {
59
+ readonly to: Hex;
60
+ readonly data: Hex;
61
+ };
62
+ /** One leg of a combo: a decimal `outcome_id` and the side, YES or NO. */
63
+ export type Leg = EntryQuote["entry"]["legs"][number];
64
+ /** Money is integer USDC base units (6 decimals), as a bigint or decimal string. */
65
+ export type Amount = bigint | string;
66
+ /** The cash an entry is planned from, as `spendableCash` reads it: free vault cash and available wallet USDC, `null` where unknown. */
67
+ export type EntryCash = {
68
+ readonly vault: Amount | null;
69
+ readonly wallet: Amount | null;
70
+ };
71
+ export type DepositAccepted = Ok<"/v1/me/deposits", "post", 202>;
72
+ /** Who signed an acceptance record, and for which vault; a record is only sent or recovered by the same account on the same deployment. */
73
+ type RecordScope = {
74
+ readonly acceptanceId: string;
75
+ readonly rfqId: string;
76
+ readonly quoteId: string;
77
+ readonly account: Hex;
78
+ readonly chainId: string;
79
+ readonly vault: Hex;
80
+ };
81
+ /**
82
+ * Where an entry's bridge stands; absent until the accept is answered.
83
+ * `SENT`: recorded before the first send, Hyperliquid's answer unknown.
84
+ * `LANDED` (Hyperliquid's `ok`), `PROCESSED` (the nonce is spent, its outcome
85
+ * on the ledger) and `REFUSED` (it can never land) are its answer.
86
+ * `DISCARDED`: never sent, and never will be.
87
+ */
88
+ export type BridgeState = "SENT" | "LANDED" | "PROCESSED" | "REFUSED" | "DISCARDED";
89
+ /**
90
+ * A signed Combo entry, plain JSON. Persist it before `sendAcceptance`: after
91
+ * a lost answer or a restart, `recoverAcceptance` finishes it without signing
92
+ * again. `bridge` is the Core to HyperEVM `sendAsset`, sent only once the
93
+ * acceptance is `ACCEPTED` and before its `fund_by`; it lands at most once.
94
+ * `onRecord` hands back the record with each new `bridgeState`: persist it
95
+ * over this one.
96
+ */
97
+ export type SignedEntry = RecordScope & {
98
+ readonly kind: "ENTRY";
99
+ readonly version: 2;
100
+ /** The quote's expiry, Unix seconds. */
101
+ readonly expiry: string;
102
+ readonly command: AcceptCommand;
103
+ readonly bridge?: SignedSendAsset;
104
+ readonly bridgeState?: BridgeState;
105
+ };
106
+ /** An entry record from SDK 0.63 or older, which sent its bridge before the accept: `recoverAcceptance` reads it and sends nothing, and `sendAcceptance` refuses it. */
107
+ export type LegacySignedEntry = Omit<SignedEntry, "version" | "bridgeState">;
108
+ /** A signed cash-out acceptance, plain JSON: persist it before `sendAcceptance`. */
109
+ export type SignedCashout = RecordScope & {
110
+ readonly kind: "CASHOUT";
111
+ readonly positionId: string;
112
+ readonly command: AcceptCommand;
113
+ };
114
+ export type SignedAcceptance = SignedEntry | SignedCashout;
115
+ /** Awaited with an entry record whose `bridgeState` changed; persist it over the stored one. */
116
+ export type RecordListener = (record: SignedEntry) => void | Promise<void>;
117
+ /**
118
+ * Where an acceptance ended. `ACCEPTED` carries `operationId`; so do
119
+ * `FILLED` (it committed) and `FAILED` (it reverted or expired unexecuted;
120
+ * the operation's `failure_reason` says why when it is known), which a later read, such as
121
+ * `recoverAcceptance`'s, can return. `NOT_ADMITTED` means the venue never
122
+ * took the accept and nothing traded. `bridged` is set
123
+ * for an entry whose bridge was sent: unless its operation `COMMITTED`, that
124
+ * cash is in the HyperEVM wallet, not on HyperCore. `bridging` is set when
125
+ * this call sent the bridge, which never holds up the result.
126
+ */
127
+ export type AcceptanceResult = {
128
+ readonly acceptanceId: string;
129
+ readonly rfqId: string;
130
+ readonly quoteId: string;
131
+ /** An entry's position is named by its quote. */
132
+ readonly positionId: string;
133
+ readonly status: (Acceptance | NotAdmitted)["status"];
134
+ readonly operationId: string | undefined;
135
+ readonly outcome: Acceptance | NotAdmitted;
136
+ /** Read as the bridge stands now: `landed` turns `yes` once Hyperliquid's `ok` is recorded, and a bridge refused or discarded unsent reads undefined. */
137
+ readonly bridged?: BridgedCash;
138
+ /**
139
+ * Hyperliquid's answer to the bridge, once `onRecord` has recorded it;
140
+ * `unknown` when none came before `fund_by`. Rejects with `onRecord`'s
141
+ * error; when that was the record before the first send, nothing was sent.
142
+ */
143
+ readonly bridging?: Promise<HypercoreAnswer>;
144
+ };
145
+ /**
146
+ * Why an entry did not trade, as the user should hear it, from its operation
147
+ * (or an `OPERATION_UPDATED` payload) and its latest record. `INSUFFICIENT_CASH`:
148
+ * its Cash fell short, including when its Core cash did reach the wallet.
149
+ * `CORE_MOVE_MISSED`: it fell short with Core cash planned to cover it that
150
+ * Hyperliquid never confirmed moving in time (never sent, discarded, refused,
151
+ * or sent without an `ok`); that cash is on HyperCore or, if `bridged`, in
152
+ * the wallet. Any other value is the operation's own `failure_reason`, such as
153
+ * `DEADLINE_BEFORE_CLAIM` when the venue reached it too late; nothing traded
154
+ * and its cash stayed where it was.
155
+ */
156
+ export type EntryFailure = "CORE_MOVE_MISSED" | NonNullable<Operation["failure_reason"]>;
157
+ /**
158
+ * An entry's `EntryFailure`; undefined unless its operation ended with a
159
+ * `failure_reason`. Pass the record as `onRecord` last handed it back (or
160
+ * `openPosition`'s `record`): only `LANDED` shows the Core cash moved before
161
+ * `fund_by`. `PROCESSED` only says the nonce is spent, which a refused or
162
+ * expired send also does, so it does not show the move.
163
+ */
164
+ export declare function entryFailure(record: SignedEntry | LegacySignedEntry, operation: Pick<Operation, "failure_reason">): EntryFailure | undefined;
165
+ /** When an entry quote stops being acceptable, in ms on the venue clock: its `accept_before`. A quote without a readable one never is. */
166
+ export declare function acceptBefore(quote: EntryQuote): number;
167
+ /**
168
+ * Chooses among current offers; return undefined to wait for the quotes to
169
+ * change. `serverNowMs` is the venue clock. It is called on every change and
170
+ * may be asked about a later time, so it must depend only on its arguments.
171
+ */
172
+ export type Chooser<Offer> = (offers: readonly Offer[], serverNowMs: number) => Offer | undefined;
173
+ /** The highest payout among quotes still before their `accept_before` (ties go to the earliest). */
174
+ export declare function bestQuote(): Chooser<EntryQuote>;
175
+ /**
176
+ * The highest price with at least `minLifeSeconds` left (execution needs 20 s
177
+ * after confirmation) and, given `minPrice` in USDC base units, no lower than it.
178
+ */
179
+ export declare function bestBid(minLifeSeconds?: number, minPrice?: bigint): Chooser<CashoutBid>;
180
+ export type TotalisOptions = Omit<ApiClientOptions, "accessToken"> & {
181
+ readonly environment: PublicEnvironment;
182
+ /** The WebSocket origin for the stream. Defaults to `baseUrl` if set, else the environment's stream host (`wss://hip4-ws.totalis.trade` in production). */
183
+ readonly streamBaseUrl?: string;
184
+ /** The session (a Privy access token or a wallet session from `signInWithWallet`) or a scoped `ttk_` key. A function is called for each request and connection. */
185
+ readonly accessToken: AccessToken;
186
+ /** The account's signer (GET /v1/me `wallet`); required for flows that sign. Never stored. */
187
+ readonly signer?: SignerInput;
188
+ /** Stream options; `subscription` adds account subscription fields such as `open_rfqs`. */
189
+ readonly stream?: Omit<StreamOptions, "subscription" | "accessToken" | "environment" | "baseUrl" | "streamBaseUrl"> & {
190
+ readonly subscription?: Omit<Extract<StreamSubscription, {
191
+ readonly type: "account";
192
+ }>, "type">;
193
+ };
194
+ };
195
+ /**
196
+ * Follow a resource: read it, then read again only when the stream says it
197
+ * changed (`wake`) or after a reconnect, until `done`. Reads made while the
198
+ * stream is not live never settle it, so quotes read while disconnected are stale.
199
+ * A read that fails transiently is retried with `retry`'s backoff, not
200
+ * rejected; a wake during the backoff reads at once.
201
+ */
202
+ export declare function follow<T, Done extends T = T>(stream: TotalisStream, read: (signal: AbortSignal) => Promise<T>, done: (value: T) => value is Done, wake: (event: StreamEvent) => boolean, signal?: AbortSignal, retry?: RetryPolicy): Promise<Done>;
203
+ /**
204
+ * The taker SDK: the same public client surface the Totalis app and third-party
205
+ * clients use. Quotes, operations and acceptances are followed on the account
206
+ * stream; HTTP reads recover after a reconnect or answer a doorbell.
207
+ */
208
+ export declare function createTotalis(options: TotalisOptions): {
209
+ /** The typed HTTP client over the same credential, for reads the flows do not cover. */
210
+ client: import("openapi-fetch").Client<paths, `${string}/${string}`>;
211
+ /** The account stream. Flows start it on first use; `close()` it when done. */
212
+ stream: TotalisStream;
213
+ deployment: () => Promise<{
214
+ readonly chain_id: import("./generated/openapi.js").components["schemas"]["UInt64String"];
215
+ readonly vault_address: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
216
+ readonly source_revision: string;
217
+ readonly audit_status: "PRE_AUDIT" | "AUDITED";
218
+ readonly fee_bps: number | null;
219
+ readonly taker_fee_bps: number | null;
220
+ readonly usdc: {
221
+ readonly address: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
222
+ readonly eip712_domain: {
223
+ readonly name: "USDC";
224
+ readonly version: "2";
225
+ readonly chain_id: import("./generated/openapi.js").components["schemas"]["UInt64String"];
226
+ readonly verifying_contract: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
227
+ };
228
+ };
229
+ }>;
230
+ /** Spendable Totalis cash from a fresh balances read (`spendableCash`): `{ vault, wallet, total }`, each `null` while unknown, never 0. */
231
+ spendableCash: (signal?: AbortSignal) => Promise<{
232
+ readonly vault: bigint | null;
233
+ readonly wallet: bigint | null;
234
+ readonly total: bigint | null;
235
+ }>;
236
+ openPosition: (request: {
237
+ readonly legs: readonly Leg[];
238
+ readonly stake: Amount;
239
+ readonly choose?: Chooser<EntryQuote>;
240
+ /** How long quotes may keep arriving after the first one `choose` would take, before it picks; 0 takes it at once. */
241
+ readonly collectMs?: number;
242
+ /** `"wallet"` (default) plans the shortfall from the wallet and `core`; `"none"` never funds; or pass a funding command. */
243
+ readonly funding?: "wallet" | "none" | Funding;
244
+ /** Core USDC offered for a bridge, in USDC base units; `null` when unread (see `signEntry`). */
245
+ readonly core?: Amount | null;
246
+ readonly sourceDex?: "spot" | "";
247
+ readonly transport?: HypercoreTransport;
248
+ /** The cash to plan from (see `signEntry`); left out, the balances are read while the quotes arrive. */
249
+ readonly cash?: EntryCash;
250
+ /** Awaited with the signed record before anything is sent, then with each change to its bridge (`onRecord`): persist it to `recoverAcceptance` after a restart. */
251
+ readonly onSigned?: RecordListener;
252
+ /** Automatic-quote intent identity, as the Totalis app sends it. */
253
+ readonly intent?: {
254
+ readonly intent_id: string;
255
+ readonly intent_generation: string;
256
+ };
257
+ readonly quoteTimeoutMs?: number;
258
+ readonly signal?: AbortSignal;
259
+ }) => Promise<{
260
+ entry: {
261
+ readonly maker_id: import("./generated/openapi.js").components["schemas"]["NonZeroUInt64String"];
262
+ readonly legs: readonly import("./generated/openapi.js").components["schemas"]["$defs-Leg"][];
263
+ readonly stake: import("./generated/openapi.js").components["schemas"]["$defs-Amount"];
264
+ readonly payout: import("./generated/openapi.js").components["schemas"]["$defs-Amount"];
265
+ readonly fee_bps: number;
266
+ readonly taker_fee_bps: number;
267
+ readonly taker: string;
268
+ readonly expiry: import("./generated/openapi.js").components["schemas"]["UInt64String"];
269
+ readonly salt: import("./generated/openapi.js").components["schemas"]["Uint256"];
270
+ };
271
+ bridged: BridgedCash | undefined;
272
+ record: SignedEntry;
273
+ acceptanceId: string;
274
+ rfqId: string;
275
+ quoteId: string;
276
+ positionId: string;
277
+ status: (Acceptance | NotAdmitted)["status"];
278
+ operationId: string | undefined;
279
+ outcome: Acceptance | NotAdmitted;
280
+ bridging?: Promise<HypercoreAnswer>;
281
+ }>;
282
+ cashOut: (request: {
283
+ readonly positionId: string;
284
+ readonly choose?: Chooser<CashoutBid>;
285
+ /** As in `openPosition`. */
286
+ readonly collectMs?: number;
287
+ readonly onSigned?: (signed: SignedCashout) => void | Promise<void>;
288
+ readonly quoteTimeoutMs?: number;
289
+ readonly signal?: AbortSignal;
290
+ }) => Promise<AcceptanceResult>;
291
+ signEntry: (request: {
292
+ readonly quote: EntryQuote;
293
+ readonly core?: Amount | null;
294
+ readonly cash?: EntryCash;
295
+ readonly sourceDex?: "spot" | "";
296
+ readonly acceptanceId?: string;
297
+ readonly hypercoreNonce?: number;
298
+ }) => Promise<SignedEntry>;
299
+ signCashout: (request: {
300
+ readonly quote: CashoutBid;
301
+ readonly acceptanceId?: string;
302
+ }) => Promise<SignedCashout>;
303
+ sendAcceptance: (signed: SignedAcceptance, options?: {
304
+ readonly transport?: HypercoreTransport;
305
+ readonly signal?: AbortSignal;
306
+ readonly onRecord?: RecordListener;
307
+ }) => Promise<AcceptanceResult>;
308
+ recoverAcceptance: (signed: SignedAcceptance | LegacySignedEntry, options?: {
309
+ readonly wait?: boolean;
310
+ readonly transport?: HypercoreTransport;
311
+ readonly onRecord?: RecordListener;
312
+ }) => Promise<AcceptanceResult>;
313
+ signWithdrawal: (request: {
314
+ readonly destination: string;
315
+ readonly amount: Amount;
316
+ readonly idempotencyKey?: string;
317
+ }) => Promise<{
318
+ idempotencyKey: string;
319
+ account: `0x${string}`;
320
+ body: {
321
+ readonly destination: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
322
+ readonly amount: import("./generated/openapi.js").components["schemas"]["$defs-Amount"];
323
+ readonly vault_withdrawal?: import("./generated/openapi.js").components["schemas"]["VaultWithdrawal"];
324
+ readonly payout_authorization: {
325
+ readonly valid_after: import("./generated/openapi.js").components["schemas"]["UInt64String"];
326
+ readonly valid_before: import("./generated/openapi.js").components["schemas"]["UInt64String"];
327
+ readonly authorization_signature: import("./generated/openapi.js").components["schemas"]["Signature65"];
328
+ };
329
+ };
330
+ }>;
331
+ sendWithdrawal: (signed: {
332
+ idempotencyKey: string;
333
+ account: `0x${string}`;
334
+ body: {
335
+ readonly destination: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
336
+ readonly amount: import("./generated/openapi.js").components["schemas"]["$defs-Amount"];
337
+ readonly vault_withdrawal?: import("./generated/openapi.js").components["schemas"]["VaultWithdrawal"];
338
+ readonly payout_authorization: {
339
+ readonly valid_after: import("./generated/openapi.js").components["schemas"]["UInt64String"];
340
+ readonly valid_before: import("./generated/openapi.js").components["schemas"]["UInt64String"];
341
+ readonly authorization_signature: import("./generated/openapi.js").components["schemas"]["Signature65"];
342
+ };
343
+ };
344
+ }, options?: {
345
+ /** Awaited once the venue admits the withdrawal: persist the ID to `waitForWithdrawal` after a restart. */
346
+ readonly onStarted?: (withdrawalId: string) => void | Promise<void>;
347
+ readonly signal?: AbortSignal;
348
+ }) => Promise<Withdrawal>;
349
+ withdraw: (request: {
350
+ readonly destination: string;
351
+ readonly amount: Amount;
352
+ /** Awaited once the venue admits the withdrawal: persist the ID to `waitForWithdrawal` after a restart. */
353
+ readonly onStarted?: (withdrawalId: string) => void | Promise<void>;
354
+ readonly signal?: AbortSignal;
355
+ }) => Promise<Withdrawal>;
356
+ waitForWithdrawal: (withdrawalId: string, signal?: AbortSignal) => Promise<Withdrawal>;
357
+ waitForOperation: (operationId: string, signal?: AbortSignal) => Promise<Operation>;
358
+ signCoreExit: (request: CoreExitRequest) => Promise<{
359
+ exitId: string;
360
+ account: `0x${string}`;
361
+ body: {
362
+ readonly schema_version: 1;
363
+ readonly request_id: import("./generated/openapi.js").components["schemas"]["Uuid"];
364
+ readonly sent_at: import("./generated/openapi.js").components["schemas"]["$defs-Timestamp"];
365
+ readonly command: {
366
+ readonly account: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
367
+ readonly to: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
368
+ readonly amount: import("./generated/openapi.js").components["schemas"]["$defs-Amount"];
369
+ readonly expiry: import("./generated/openapi.js").components["schemas"]["UInt64String"];
370
+ readonly salt: import("./generated/openapi.js").components["schemas"]["Uint"];
371
+ readonly signature: import("./generated/openapi.js").components["schemas"]["ContractSignature"];
372
+ readonly purpose: "ORDER" | "WITHDRAW" | "SWEEP";
373
+ readonly activation_fee_accepted?: boolean;
374
+ };
375
+ };
376
+ }>;
377
+ signRunOffClaim: (request: {
378
+ readonly vaultAddress: string;
379
+ readonly claimId?: string;
380
+ }) => Promise<{
381
+ claimId: string;
382
+ account: `0x${string}`;
383
+ body: {
384
+ readonly schema_version: 1;
385
+ readonly request_id: import("./generated/openapi.js").components["schemas"]["Uuid"];
386
+ readonly sent_at: import("./generated/openapi.js").components["schemas"]["$defs-Timestamp"];
387
+ readonly command: {
388
+ readonly vault_address: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
389
+ readonly account: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
390
+ readonly to: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
391
+ readonly amount: import("./generated/openapi.js").components["schemas"]["$defs-Amount"];
392
+ readonly expiry: import("./generated/openapi.js").components["schemas"]["UInt64String"];
393
+ readonly salt: import("./generated/openapi.js").components["schemas"]["Uint"];
394
+ readonly signature: import("./generated/openapi.js").components["schemas"]["ContractSignature"];
395
+ };
396
+ };
397
+ }>;
398
+ sendRunOffClaim: (signed: Awaited<ReturnType<(request: {
399
+ readonly vaultAddress: string;
400
+ readonly claimId?: string;
401
+ }) => Promise<{
402
+ claimId: string;
403
+ account: `0x${string}`;
404
+ body: {
405
+ readonly schema_version: 1;
406
+ readonly request_id: import("./generated/openapi.js").components["schemas"]["Uuid"];
407
+ readonly sent_at: import("./generated/openapi.js").components["schemas"]["$defs-Timestamp"];
408
+ readonly command: {
409
+ readonly vault_address: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
410
+ readonly account: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
411
+ readonly to: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
412
+ readonly amount: import("./generated/openapi.js").components["schemas"]["$defs-Amount"];
413
+ readonly expiry: import("./generated/openapi.js").components["schemas"]["UInt64String"];
414
+ readonly salt: import("./generated/openapi.js").components["schemas"]["Uint"];
415
+ readonly signature: import("./generated/openapi.js").components["schemas"]["ContractSignature"];
416
+ };
417
+ };
418
+ }>>>) => Promise<{
419
+ readonly vault_address: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
420
+ readonly operation: {
421
+ readonly operation_id: import("./generated/openapi.js").components["schemas"]["Bytes32"];
422
+ readonly kind: string;
423
+ readonly amount: import("./generated/openapi.js").components["schemas"]["$defs-Amount"] | null;
424
+ readonly status: import("./generated/openapi.js").components["schemas"]["OperationState"];
425
+ readonly transaction_hash: import("./generated/openapi.js").components["schemas"]["Bytes32"] | null;
426
+ readonly failure_reason?: import("./generated/openapi.js").components["schemas"]["OperationFailureReason"];
427
+ readonly created_at: import("./generated/openapi.js").components["schemas"]["$defs-Timestamp"];
428
+ readonly updated_at: import("./generated/openapi.js").components["schemas"]["$defs-Timestamp"];
429
+ };
430
+ }>;
431
+ sendCoreExit: (signed: {
432
+ exitId: string;
433
+ account: `0x${string}`;
434
+ body: {
435
+ readonly schema_version: 1;
436
+ readonly request_id: import("./generated/openapi.js").components["schemas"]["Uuid"];
437
+ readonly sent_at: import("./generated/openapi.js").components["schemas"]["$defs-Timestamp"];
438
+ readonly command: {
439
+ readonly account: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
440
+ readonly to: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
441
+ readonly amount: import("./generated/openapi.js").components["schemas"]["$defs-Amount"];
442
+ readonly expiry: import("./generated/openapi.js").components["schemas"]["UInt64String"];
443
+ readonly salt: import("./generated/openapi.js").components["schemas"]["Uint"];
444
+ readonly signature: import("./generated/openapi.js").components["schemas"]["ContractSignature"];
445
+ readonly purpose: "ORDER" | "WITHDRAW" | "SWEEP";
446
+ readonly activation_fee_accepted?: boolean;
447
+ };
448
+ };
449
+ }) => Promise<CoreExit>;
450
+ exitToCore: (request: Parameters<(request: CoreExitRequest) => Promise<{
451
+ exitId: string;
452
+ account: `0x${string}`;
453
+ body: {
454
+ readonly schema_version: 1;
455
+ readonly request_id: import("./generated/openapi.js").components["schemas"]["Uuid"];
456
+ readonly sent_at: import("./generated/openapi.js").components["schemas"]["$defs-Timestamp"];
457
+ readonly command: {
458
+ readonly account: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
459
+ readonly to: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
460
+ readonly amount: import("./generated/openapi.js").components["schemas"]["$defs-Amount"];
461
+ readonly expiry: import("./generated/openapi.js").components["schemas"]["UInt64String"];
462
+ readonly salt: import("./generated/openapi.js").components["schemas"]["Uint"];
463
+ readonly signature: import("./generated/openapi.js").components["schemas"]["ContractSignature"];
464
+ readonly purpose: "ORDER" | "WITHDRAW" | "SWEEP";
465
+ readonly activation_fee_accepted?: boolean;
466
+ };
467
+ };
468
+ }>>[0]) => Promise<CoreExit>;
469
+ waitForCoreExit: (exitId: string, signal?: AbortSignal) => Promise<CoreExit>;
470
+ signDeposit: (request: {
471
+ readonly amount: Amount;
472
+ readonly depositId?: string;
473
+ }) => Promise<{
474
+ depositId: string;
475
+ account: `0x${string}`;
476
+ body: {
477
+ readonly schema_version: 1;
478
+ readonly request_id: import("./generated/openapi.js").components["schemas"]["Uuid"];
479
+ readonly sent_at: import("./generated/openapi.js").components["schemas"]["$defs-Timestamp"];
480
+ readonly command: {
481
+ readonly account: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
482
+ readonly from: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
483
+ readonly value: import("./generated/openapi.js").components["schemas"]["$defs-Amount"];
484
+ readonly valid_after: import("./generated/openapi.js").components["schemas"]["UInt64String"];
485
+ readonly valid_before: import("./generated/openapi.js").components["schemas"]["UInt64String"];
486
+ readonly salt: import("./generated/openapi.js").components["schemas"]["Bytes32"];
487
+ readonly authorization_signature: import("./generated/openapi.js").components["schemas"]["Signature65"];
488
+ };
489
+ };
490
+ }>;
491
+ sendDeposit: (signed: {
492
+ depositId: string;
493
+ account: `0x${string}`;
494
+ body: {
495
+ readonly schema_version: 1;
496
+ readonly request_id: import("./generated/openapi.js").components["schemas"]["Uuid"];
497
+ readonly sent_at: import("./generated/openapi.js").components["schemas"]["$defs-Timestamp"];
498
+ readonly command: {
499
+ readonly account: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
500
+ readonly from: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
501
+ readonly value: import("./generated/openapi.js").components["schemas"]["$defs-Amount"];
502
+ readonly valid_after: import("./generated/openapi.js").components["schemas"]["UInt64String"];
503
+ readonly valid_before: import("./generated/openapi.js").components["schemas"]["UInt64String"];
504
+ readonly salt: import("./generated/openapi.js").components["schemas"]["Bytes32"];
505
+ readonly authorization_signature: import("./generated/openapi.js").components["schemas"]["Signature65"];
506
+ };
507
+ };
508
+ }) => Promise<DepositAccepted>;
509
+ signReturnToCore: (request?: {
510
+ readonly purpose?: "ORDER" | "WITHDRAW";
511
+ readonly activationFeeAccepted?: boolean;
512
+ readonly exitId?: string;
513
+ readonly depositId?: string;
514
+ }) => Promise<{
515
+ exit: {
516
+ exitId: string;
517
+ account: `0x${string}`;
518
+ body: {
519
+ readonly schema_version: 1;
520
+ readonly request_id: import("./generated/openapi.js").components["schemas"]["Uuid"];
521
+ readonly sent_at: import("./generated/openapi.js").components["schemas"]["$defs-Timestamp"];
522
+ readonly command: {
523
+ readonly account: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
524
+ readonly to: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
525
+ readonly amount: import("./generated/openapi.js").components["schemas"]["$defs-Amount"];
526
+ readonly expiry: import("./generated/openapi.js").components["schemas"]["UInt64String"];
527
+ readonly salt: import("./generated/openapi.js").components["schemas"]["Uint"];
528
+ readonly signature: import("./generated/openapi.js").components["schemas"]["ContractSignature"];
529
+ readonly purpose: "ORDER" | "WITHDRAW" | "SWEEP";
530
+ readonly activation_fee_accepted?: boolean;
531
+ };
532
+ };
533
+ };
534
+ deposit?: {
535
+ depositId: string;
536
+ account: `0x${string}`;
537
+ body: {
538
+ readonly schema_version: 1;
539
+ readonly request_id: import("./generated/openapi.js").components["schemas"]["Uuid"];
540
+ readonly sent_at: import("./generated/openapi.js").components["schemas"]["$defs-Timestamp"];
541
+ readonly command: {
542
+ readonly account: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
543
+ readonly from: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
544
+ readonly value: import("./generated/openapi.js").components["schemas"]["$defs-Amount"];
545
+ readonly valid_after: import("./generated/openapi.js").components["schemas"]["UInt64String"];
546
+ readonly valid_before: import("./generated/openapi.js").components["schemas"]["UInt64String"];
547
+ readonly salt: import("./generated/openapi.js").components["schemas"]["Bytes32"];
548
+ readonly authorization_signature: import("./generated/openapi.js").components["schemas"]["Signature65"];
549
+ };
550
+ };
551
+ };
552
+ }>;
553
+ sendReturnToCore: (signed: {
554
+ exit: {
555
+ exitId: string;
556
+ account: `0x${string}`;
557
+ body: {
558
+ readonly schema_version: 1;
559
+ readonly request_id: import("./generated/openapi.js").components["schemas"]["Uuid"];
560
+ readonly sent_at: import("./generated/openapi.js").components["schemas"]["$defs-Timestamp"];
561
+ readonly command: {
562
+ readonly account: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
563
+ readonly to: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
564
+ readonly amount: import("./generated/openapi.js").components["schemas"]["$defs-Amount"];
565
+ readonly expiry: import("./generated/openapi.js").components["schemas"]["UInt64String"];
566
+ readonly salt: import("./generated/openapi.js").components["schemas"]["Uint"];
567
+ readonly signature: import("./generated/openapi.js").components["schemas"]["ContractSignature"];
568
+ readonly purpose: "ORDER" | "WITHDRAW" | "SWEEP";
569
+ readonly activation_fee_accepted?: boolean;
570
+ };
571
+ };
572
+ };
573
+ deposit?: {
574
+ depositId: string;
575
+ account: `0x${string}`;
576
+ body: {
577
+ readonly schema_version: 1;
578
+ readonly request_id: import("./generated/openapi.js").components["schemas"]["Uuid"];
579
+ readonly sent_at: import("./generated/openapi.js").components["schemas"]["$defs-Timestamp"];
580
+ readonly command: {
581
+ readonly account: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
582
+ readonly from: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
583
+ readonly value: import("./generated/openapi.js").components["schemas"]["$defs-Amount"];
584
+ readonly valid_after: import("./generated/openapi.js").components["schemas"]["UInt64String"];
585
+ readonly valid_before: import("./generated/openapi.js").components["schemas"]["UInt64String"];
586
+ readonly salt: import("./generated/openapi.js").components["schemas"]["Bytes32"];
587
+ readonly authorization_signature: import("./generated/openapi.js").components["schemas"]["Signature65"];
588
+ };
589
+ };
590
+ };
591
+ }, options?: {
592
+ readonly signal?: AbortSignal;
593
+ }) => Promise<CoreExit>;
594
+ returnToCore: (request?: Parameters<(request?: {
595
+ readonly purpose?: "ORDER" | "WITHDRAW";
596
+ readonly activationFeeAccepted?: boolean;
597
+ readonly exitId?: string;
598
+ readonly depositId?: string;
599
+ }) => Promise<{
600
+ exit: {
601
+ exitId: string;
602
+ account: `0x${string}`;
603
+ body: {
604
+ readonly schema_version: 1;
605
+ readonly request_id: import("./generated/openapi.js").components["schemas"]["Uuid"];
606
+ readonly sent_at: import("./generated/openapi.js").components["schemas"]["$defs-Timestamp"];
607
+ readonly command: {
608
+ readonly account: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
609
+ readonly to: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
610
+ readonly amount: import("./generated/openapi.js").components["schemas"]["$defs-Amount"];
611
+ readonly expiry: import("./generated/openapi.js").components["schemas"]["UInt64String"];
612
+ readonly salt: import("./generated/openapi.js").components["schemas"]["Uint"];
613
+ readonly signature: import("./generated/openapi.js").components["schemas"]["ContractSignature"];
614
+ readonly purpose: "ORDER" | "WITHDRAW" | "SWEEP";
615
+ readonly activation_fee_accepted?: boolean;
616
+ };
617
+ };
618
+ };
619
+ deposit?: {
620
+ depositId: string;
621
+ account: `0x${string}`;
622
+ body: {
623
+ readonly schema_version: 1;
624
+ readonly request_id: import("./generated/openapi.js").components["schemas"]["Uuid"];
625
+ readonly sent_at: import("./generated/openapi.js").components["schemas"]["$defs-Timestamp"];
626
+ readonly command: {
627
+ readonly account: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
628
+ readonly from: import("./generated/openapi.js").components["schemas"]["LowercaseNonZeroAddress"];
629
+ readonly value: import("./generated/openapi.js").components["schemas"]["$defs-Amount"];
630
+ readonly valid_after: import("./generated/openapi.js").components["schemas"]["UInt64String"];
631
+ readonly valid_before: import("./generated/openapi.js").components["schemas"]["UInt64String"];
632
+ readonly salt: import("./generated/openapi.js").components["schemas"]["Bytes32"];
633
+ readonly authorization_signature: import("./generated/openapi.js").components["schemas"]["Signature65"];
634
+ };
635
+ };
636
+ };
637
+ }>>[0] & {
638
+ readonly signal?: AbortSignal;
639
+ }) => Promise<CoreExit>;
640
+ directDepositCalls: (amount: Amount) => Promise<readonly WalletCall[]>;
641
+ /** Render an RFQ's live quotes (entry or cash-out) from the stream; `[]` while the stream is down. */
642
+ watchQuotes: (rfqId: string, listener: (quotes: readonly Quote[], serverNowMs: number) => void) => () => void;
643
+ /** Issue a personal `ttk_` key; the signer must be the account wallet (embedded, or a wallet-only account's own). */
644
+ issueApiKey: (request: Parameters<typeof issueApiKey>[2]) => Promise<{
645
+ readonly key: {
646
+ readonly id: import("./api-keys.js").components["schemas"]["Uuid"];
647
+ readonly account: {
648
+ readonly kind: "PARTICIPANT";
649
+ readonly id: import("./api-keys.js").components["schemas"]["Uuid"];
650
+ };
651
+ readonly environment: "development" | "staging" | "production";
652
+ readonly label: import("./api-keys.js").components["schemas"]["KeyLabel"];
653
+ readonly scopes: readonly ("identity:read" | "account:read" | "account:stream" | "rfq:read" | "rfq:write" | "quote:write" | "quote:read" | "replay:read" | "vault:read" | "vault:write" | "quote:accept" | "position:cashout" | "funding:deposit" | "funding:withdraw" | "sponsorship:use" | "maker:access:read" | "operations:read" | "operations:submit")[];
654
+ readonly status: "ACTIVE";
655
+ readonly created_at: import("./api-keys.js").components["schemas"]["Timestamp"];
656
+ readonly expires_at: import("./api-keys.js").components["schemas"]["Timestamp"] | null;
657
+ };
658
+ readonly secret: string;
659
+ } | {
660
+ readonly key: {
661
+ readonly id: import("./api-keys.js").components["schemas"]["Uuid"];
662
+ readonly account: {
663
+ readonly kind: "MAKER";
664
+ readonly id: import("./api-keys.js").components["schemas"]["NonZeroUInt64String"];
665
+ readonly chain_id: "998" | "999";
666
+ readonly vault_address: import("./api-keys.js").components["schemas"]["LowercaseNonZeroAddress"];
667
+ };
668
+ readonly environment: "development" | "staging" | "production";
669
+ readonly label: import("./api-keys.js").components["schemas"]["KeyLabel"];
670
+ readonly scopes: readonly ("identity:read" | "account:read" | "account:stream" | "rfq:read" | "rfq:write" | "quote:write" | "quote:read" | "replay:read" | "vault:read" | "vault:write" | "quote:accept" | "position:cashout" | "funding:deposit" | "funding:withdraw" | "sponsorship:use" | "maker:access:read" | "operations:read" | "operations:submit")[];
671
+ readonly status: "ACTIVE";
672
+ readonly created_at: import("./api-keys.js").components["schemas"]["Timestamp"];
673
+ readonly expires_at: import("./api-keys.js").components["schemas"]["Timestamp"] | null;
674
+ };
675
+ readonly secret: string;
676
+ }>;
677
+ rotateApiKey: (keyId: string, request?: Parameters<typeof rotateApiKey>[3]) => Promise<{
678
+ readonly key: {
679
+ readonly id: import("./api-keys.js").components["schemas"]["Uuid"];
680
+ readonly account: {
681
+ readonly kind: "PARTICIPANT";
682
+ readonly id: import("./api-keys.js").components["schemas"]["Uuid"];
683
+ };
684
+ readonly environment: "development" | "staging" | "production";
685
+ readonly label: import("./api-keys.js").components["schemas"]["KeyLabel"];
686
+ readonly scopes: readonly ("identity:read" | "account:read" | "account:stream" | "rfq:read" | "rfq:write" | "quote:write" | "quote:read" | "replay:read" | "vault:read" | "vault:write" | "quote:accept" | "position:cashout" | "funding:deposit" | "funding:withdraw" | "sponsorship:use" | "maker:access:read" | "operations:read" | "operations:submit")[];
687
+ readonly status: "ACTIVE";
688
+ readonly created_at: import("./api-keys.js").components["schemas"]["Timestamp"];
689
+ readonly expires_at: import("./api-keys.js").components["schemas"]["Timestamp"] | null;
690
+ readonly rotated_from: string;
691
+ };
692
+ readonly secret: string;
693
+ } | {
694
+ readonly key: {
695
+ readonly id: import("./api-keys.js").components["schemas"]["Uuid"];
696
+ readonly account: {
697
+ readonly kind: "MAKER";
698
+ readonly id: import("./api-keys.js").components["schemas"]["NonZeroUInt64String"];
699
+ readonly chain_id: "998" | "999";
700
+ readonly vault_address: import("./api-keys.js").components["schemas"]["LowercaseNonZeroAddress"];
701
+ };
702
+ readonly environment: "development" | "staging" | "production";
703
+ readonly label: import("./api-keys.js").components["schemas"]["KeyLabel"];
704
+ readonly scopes: readonly ("identity:read" | "account:read" | "account:stream" | "rfq:read" | "rfq:write" | "quote:write" | "quote:read" | "replay:read" | "vault:read" | "vault:write" | "quote:accept" | "position:cashout" | "funding:deposit" | "funding:withdraw" | "sponsorship:use" | "maker:access:read" | "operations:read" | "operations:submit")[];
705
+ readonly status: "ACTIVE";
706
+ readonly created_at: import("./api-keys.js").components["schemas"]["Timestamp"];
707
+ readonly expires_at: import("./api-keys.js").components["schemas"]["Timestamp"] | null;
708
+ readonly rotated_from: string;
709
+ };
710
+ readonly secret: string;
711
+ }>;
712
+ close: () => void;
713
+ };
714
+ export type Totalis = ReturnType<typeof createTotalis>;
715
+ export { BalanceUnknownError, EntryError, ExitUnavailableError };
716
+ export { ApiError, NetworkError };
717
+ export type SignedCoreExit = Awaited<ReturnType<Totalis["signCoreExit"]>>;
718
+ export type SignedDeposit = Awaited<ReturnType<Totalis["signDeposit"]>>;
719
+ export type SignedReturnToCore = Awaited<ReturnType<Totalis["signReturnToCore"]>>;