@totalis/hip4-client 0.124.0 → 0.125.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 (41) hide show
  1. package/CHANGELOG.md +380 -0
  2. package/README.md +9 -5
  3. package/dist/api-keys.d.ts +21 -2
  4. package/dist/api-keys.js +12 -10
  5. package/dist/audience-contract.d.ts +1 -2
  6. package/dist/client.d.ts +1 -1
  7. package/dist/client.js +1 -1
  8. package/dist/flow-errors.d.ts +1 -1
  9. package/dist/flow-errors.js +1 -1
  10. package/dist/generated/account-read.d.ts +150 -126
  11. package/dist/generated/api-keys.d.ts +19 -10
  12. package/dist/generated/browse.d.ts +12 -12
  13. package/dist/generated/client.d.ts +5 -2
  14. package/dist/generated/errors.d.ts +15 -8
  15. package/dist/generated/errors.js +47 -35
  16. package/dist/generated/maker.d.ts +3 -4
  17. package/dist/generated/openapi.d.ts +828 -892
  18. package/dist/generated/realtime.d.ts +66 -93
  19. package/dist/generated/vault-abi.d.ts +57 -0
  20. package/dist/generated/vault-abi.js +77 -0
  21. package/dist/generated/version.d.ts +16 -16
  22. package/dist/generated/version.js +20 -18
  23. package/dist/maker.d.ts +134 -54
  24. package/dist/maker.js +257 -147
  25. package/dist/money.d.ts +8 -6
  26. package/dist/money.js +7 -7
  27. package/dist/partner.d.ts +2 -0
  28. package/dist/partner.js +2 -1
  29. package/dist/request.d.ts +11 -2
  30. package/dist/request.js +7 -2
  31. package/dist/totalis.d.ts +147 -232
  32. package/dist/totalis.js +290 -269
  33. package/dist/typed-data.d.ts +6 -0
  34. package/dist/typed-data.js +8 -0
  35. package/dist/ui.d.ts +6 -10
  36. package/dist/ui.js +15 -13
  37. package/dist/vault-reads.d.ts +46 -0
  38. package/dist/vault-reads.js +72 -0
  39. package/examples/browser-wallet.mjs +1 -1
  40. package/examples/node-bot.mjs +15 -12
  41. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,386 @@
3
3
  `@totalis/hip4-client` follows [semantic versioning](https://semver.org).
4
4
  The contract version the generated types come from is `sdkVersion` in `./version`.
5
5
 
6
+ ## 0.125.0
7
+
8
+ ### Added
9
+
10
+ - `issueApiKey` takes `preset: "TAKER"` or `preset: "MAKER"` instead of
11
+ `scopes`. The venue expands it, and the SDK checks that the challenge grants
12
+ exactly that set before the owner signs. `TAKER_SCOPES` and
13
+ `KEY_PRESET_SCOPES` export the sets; `MAKER` is `QUOTING_BOT_SCOPES`.
14
+ - A refused key request is `INVALID_REQUEST` naming the entry in
15
+ `field_violations` (`/scopes/<i>` or `/preset`, under `/request` for a
16
+ challenge), with why in the message.
17
+ - Makers price a cash-out from the chain in one call:
18
+ `createMaker({ ..., chain })` takes a HyperEVM JSON-RPC URL or an EIP-1193
19
+ provider (only `eth_call` is sent), and
20
+ `maker.readCashoutPosition(rfq)` reads the RFQ's position, checks the RFQ's
21
+ `legs` against `tickets(position_id).legsHash`, and returns
22
+ `{ ticket, legsHash, legState }`, `legState` being
23
+ `legStateOf(legs, legStateReadGas)` at the latest block. Bid with
24
+ `maker.bid(rfq, { price, legState: position.legState })`. `./maker` also
25
+ exports it standalone as `readCashoutPosition(chain, deployment, rfq)`,
26
+ with `readTicket`, `readLegState`, their calldata (`ticketsCall`,
27
+ `legStateOfCall`) and `legStateReadGas` (500000, the venue's).
28
+ - `legsHash(legs)` (`./typed-data`, `./maker`): the vault's EIP-712 `Leg[]`
29
+ hash, as `tickets(position_id).legsHash` records it.
30
+ - `openPosition` takes `builderCode`, sent as create RFQ's `builder_code`: it
31
+ credits the partner whose app sent the RFQ with its revenue share, at no
32
+ cost to the taker. It sends `stake` as a decimal string and the legs in
33
+ increasing `outcome_id` order, which the venue requires;
34
+ `rfqLegsInOrder(legs)` (`./partner`) gives that order for a client that
35
+ creates the RFQ itself.
36
+ - `listMarkets(filters?, limit?)` on `createTotalis` and `createMaker`: every
37
+ market `GET /v1/markets` lists under `combo`, `eligibility`, `category` and
38
+ `subcategory`, as an async iterator that reads on past short or empty
39
+ pages while `has_more` is true. `MarketFilters` and `MarketRow` type them.
40
+ - `GET /v1/market-results` reads the exact YES payout and, where recorded,
41
+ the settlement price for up to 100 outcome IDs in one request.
42
+ - `GET /v1/hypercore/positions` pages your own HyperCore positions, open and
43
+ closed, from the holdings ledger: paid, received, value, P&L, result,
44
+ pairs, sellable shares and fee-net To win, on Testnet and Mainnet.
45
+ - `GET /v1/hypercore/orders` reads your open HIP-4 orders and your spot fee
46
+ rates on Testnet and Mainnet.
47
+ - `GET /v1/market-results` items carry `final`: read an item again until it is.
48
+ - `readInvalidated` frames may name `HOLDINGS`: the holdings ledger applied
49
+ new rows of your account wallet, so refetch `GET /v1/hypercore/positions`.
50
+
51
+ ### Changed
52
+
53
+ - `deposit`, `signDeposit` and `returnToCore` work with a participant API key
54
+ that holds `funding:deposit` and `sponsorship:use`, as well as with a
55
+ session. The signer must still be the account wallet of that key's account.
56
+ - A deposit larger than the wallet's available USDC fails with
57
+ `INSUFFICIENT_WALLET_BALANCE` (409, retry `REFRESH`) instead of
58
+ `STATE_CONFLICT`. A deposit under its wallet's minimum is `INVALID_REQUEST`
59
+ naming `/value`, with the minimum in the message.
60
+
61
+ - An RFQ you open without an intent, entry or cash-out, stays open while your
62
+ stream is connected, up to an hour, instead of 20 seconds (30 for a
63
+ cash-out), and closes about two minutes after your last stream disconnects
64
+ (TT-2996). A cash-out RFQ also closes once a leg of its position settles.
65
+ `openPosition` and `cashOut` now cancel their RFQ when they give up without
66
+ a fill, so the RFQ doesn't stay open.
67
+
68
+ ### Breaking
69
+
70
+ - The deposit body is flat, like the withdrawal's: `signDeposit` returns
71
+ `body: { value, valid_after, valid_before, salt, authorization_signature }`
72
+ with no `schema_version`, `request_id`, `sent_at`, `command`, `account` or
73
+ `from`; the venue takes the account from the credential. A `SignedDeposit`
74
+ persisted by an earlier version no longer sends: sign it again.
75
+
76
+ Contract `277.0.0-lean-exits`: the exit bodies are flat and carry only what
77
+ the venue does not already know, the Core exit answers only how far it got,
78
+ and a position read through `/v1/me` leaves out the maker's view.
79
+
80
+ - `POST /v1/core-exits` takes `{ amount, expiry, salt, signature, purpose,
81
+ activation_fee_accepted? }` and `POST /v1/me/run-off-claims` takes
82
+ `{ vault_address, amount, expiry, salt, signature }`: no `schema_version`,
83
+ `request_id`, `sent_at`, `command`, `account` or `to`. The venue takes the
84
+ Exit's `account` from the credential (its account wallet) and its `to` from
85
+ the deployment (the router, or the account itself for a run-off claim), and
86
+ verifies the signature over those terms. `signCoreExit`, `signReturnToCore`
87
+ and `signRunOffClaim` sign the same Exit as before and send the flat body;
88
+ an amount under the minimum names `/amount`. A `SignedCoreExit`,
89
+ `SignedReturnToCore` or signed run-off claim persisted by an earlier version
90
+ still holds `command` and no longer sends: sign it again.
91
+ - A Core exit (create, get, abandon and `GET /v1/me/core-exits`'s `exits`) is
92
+ `{ exit_id, status, purpose, amount, activation_fee_accepted, credit,
93
+ created_at, updated_at }`. `vault_address`, `account`, `router_address`,
94
+ `expiry`, `exit_digest`, `operation` and `sent` are gone; follow an exit by
95
+ its `status` (`waitForCoreExit` does). An `ABANDONED` tombstone has a null
96
+ `purpose` and `amount`. `CORE_EXIT_UPDATED` is unchanged.
97
+ - `GET /v1/me/positions` and `GET /v1/me/positions/{position_id}`, a maker
98
+ key's included, answer `Position` without `owner_username`, `opened_via`,
99
+ `maker_pnl` or `maker_result`. The maker's reads,
100
+ `GET /v1/makers/{maker_id}/positions[/{position_id}]`, answer
101
+ `MakerPosition` (`MakerPositionList`, `MakerPositionDetail`): every
102
+ `Position` field plus those four. The `maker_result` filter is unchanged on
103
+ both.
104
+ - `envelope` stays exported, though no current route takes one.
105
+
106
+ Contract `276.0.0-one-name-accounts`: one name for each idea across the
107
+ account, maker and partner surfaces. Enum values are unchanged; only field
108
+ names move. Signed EIP-712 terms keep their names (the deposit's
109
+ ReceiveWithAuthorization `value`, the permit's `owner`, `value` and
110
+ `deadline`, SellBack's `owner`).
111
+
112
+ - Why something ended is `reason`: `terminal_reason` on `EntryRfq`,
113
+ `CashoutRfq` and the stream's RFQ events; `failure_reason` on `Operation`,
114
+ `OPERATION_UPDATED` and `WalletApprovalRequest`; `failure_code` on
115
+ `CollateralReduction`; `close_reason` on `Position`. `EntryFailure` is
116
+ `NonNullable<Operation["reason"]>` and `entryFailure` takes
117
+ `Pick<Operation, "reason">`.
118
+ - USDC amounts are `amount`: the deposit body (`SignedDeposit.body.amount`)
119
+ and the wallet approval body (`SignedWalletApproval.body.amount`) send it,
120
+ and `WalletApprovalRequest` and a maker capital reservation return it. A
121
+ deposit under the minimum is `INVALID_REQUEST` naming `/amount`. A
122
+ `SignedDeposit` or `SignedWalletApproval` persisted by an earlier version
123
+ still holds `value` and no longer sends: sign it again. `signWalletApproval`
124
+ and `approveWallet` still take `value`.
125
+ - Lifecycle is `status`: `DepositAccepted`, the partner report's payouts,
126
+ `GET /v1/me/maker`'s `ownership`, `CopyAgent`, `ComboCopyAgent`,
127
+ `GoldenTicket`, `GoldenPlacementRead` and the placement answer, and the
128
+ social `SinglePosition` and `ComboPosition`. `makerReadiness` reads
129
+ `ownership.status`; its own `state` is unchanged.
130
+ - Read freshness is `freshness`: `Balance` and its components, `RunOffCash`,
131
+ `AccountValue` (and the `balance.updated` webhook), every account-read
132
+ `context` and `MakerWithdrawal`. `spendableCash` takes
133
+ `Pick<Balance, "amount" | "freshness" | "components" | "pending">`.
134
+ - Positions, not tickets: the partner report's `open_tickets: { tickets,
135
+ stake }` is `open_positions: { positions, stake }`, its fee fields'
136
+ `tickets` is `positions`, and maker performance counts are
137
+ `closed_position_count`, `won_position_count`, `lost_position_count` and
138
+ `even_position_count`.
139
+ - Who controls or signs: `MakerAccess`, `MakerCapital` and `ownership` name
140
+ the maker's wallet `controller`; `KeyCapabilities` and `KeyChallenge` name
141
+ the address that signs issuance `signer`. `checkKeyChallenge` still takes
142
+ `expected.owner` and compares it with `challenge.signer`.
143
+ - A partner webhook event names its kind `kind` (was `type`), in the posted
144
+ body and in `GET /v1/partner/webhook-events`.
145
+ - Also: `GET /v1/me/controlled-makers` names each maker's wallet
146
+ `controller` (was `owner`) and `MakerAccess.owner_version` is
147
+ `controller_version`; maker exposure counts are `open_position_count` and
148
+ `awaiting_position_count`; `GET /v1/me/copy-trades`,
149
+ `GET /v1/me/combo-copies` and `GET /v1/me/referral-bonus` name their
150
+ lifecycle `status` (was `state`); a `checkpoint`'s `projection_state` is
151
+ `freshness` (balances, operations, account value, `balance.updated`); and
152
+ maker telemetry's `telemetry.status` is `telemetry.freshness`.
153
+
154
+ Contract `275.0.0-one-name-markets-streams`:
155
+
156
+ - A market's lifecycle is `status`, not `state`: on `Market`, `Question`,
157
+ every discovery item and its `DiscoveryDisplay` (questions, standalone
158
+ markets, series and games), a past recurring round (`PastRound`) and a
159
+ HyperCore order (`HypercorePortfolioOrder`, `HypercoreHistoryOrder`). The
160
+ values are unchanged.
161
+ - A market's `eligibility` and `combo` name their value `status`:
162
+ `{ status: "ENABLED" }`, `{ status: "DISABLED", reason }`,
163
+ `{ status: "OPEN" }`, `{ status: "CLOSED", reason, opens_at }`. The
164
+ `eligibility` and `combo` query filters of `GET /v1/markets` keep their
165
+ names and values.
166
+ - A recurring round's `series` names its class `kind`
167
+ (`PRICE_BINARY` or `PRICE_BUCKET`).
168
+ - A market-display picture names its variant `kind`:
169
+ `{ kind: "SUBJECT", key }` or `{ kind: "GLYPH", glyph }`.
170
+ - Stream subscriptions are discriminated by `kind`, not `type`, on
171
+ `/v1/stream` and `/v1/market-stream`: send
172
+ `{ method: "subscribe", subscription: { kind: "account" | "maker" | "market", ... } }`,
173
+ and the `subscriptionResponse` echoes `kind`. `createTotalis` and
174
+ `createMaker` send it for you; a `subscription` option no longer takes
175
+ `type`.
176
+ - The market stream's `snapshot` and `delta` frames name each catalog
177
+ market's `status` and `eligibility.status` (`StreamCatalogMarket`), not
178
+ `state`.
179
+
180
+ Contract `274.0.0-lean-maker-confirm`:
181
+
182
+ - The maker's confirm answer (`Acceptance` in `./maker`) has no `deadline`:
183
+ it is `{ quote_id, rfq_id, status, operation_id? }`. The deadline comes
184
+ with `QUOTE_ACCEPTED` (`MakerAcceptance.deadline`), before the answer,
185
+ which is where `createMaker` already reads it.
186
+
187
+ Contract `273.0.0-implicit-accept-funding`:
188
+
189
+ - The accept body is only `{ taker_signature }`: `funding` is gone. When your
190
+ free vault cash is short of an entry's stake, the venue draws the shortfall
191
+ from your wallet's USDC approval to WalletAccept on its own. Approve once
192
+ (`approveWallet`, or let `openPosition` / `prepareEntryFunding` sign the
193
+ permit when the approval left is short) and every entry draws what it
194
+ needs. A scoped key draws the wallet only with `funding:deposit`.
195
+ - The SDK never signs a per-trade USDC authorization for an entry.
196
+ `EntryFunding` and the `funding` option of `openPosition`, `signEntry` and
197
+ `prepareEntryFunding` are gone, as is `PreparedEntryFunding.funding`.
198
+ `signEntry` without `prepared` checks that the approval left covers the
199
+ wallet's part (`WalletApprovalError` `INSUFFICIENT_APPROVAL` otherwise).
200
+ - A HyperCore transfer that funds an entry goes within `fundWindowMs` (4
201
+ seconds) of sending the accept, once it answers `ACCEPTED`: the venue waits
202
+ at least six seconds from the accept's arrival for it. `fund_within_ms` is
203
+ gone from the accept answer and `GET .../acceptance`, and `fund_by` from
204
+ `WALLET_FUNDING_UPDATED`. `sendAcceptance` reads nothing after the answer,
205
+ and `recoverAcceptance` never sends a bridge: an unsent one is discarded, a
206
+ `SENT` one stays `SENT`.
207
+
208
+ Contract `272.0.0-lean-rfq-flow` (TT-3023):
209
+
210
+ - A builder code needs no partner signature: it counts from an account the
211
+ partner admitted, or from a browser on the code's registered origin.
212
+ `attributeRfq`, `rfqAttributionMessage`, `AttributedRfq`, and
213
+ `openPosition`'s `builderAttribution` and `rfqIdempotencyKey` are gone, and
214
+ create RFQ refuses `builder_attribution`.
215
+ - HTTP responses in the RFQ flow carry no clocks. The accept answers only
216
+ what you did not send: `{ status, acceptance_id, operation_id?, reason? }`.
217
+ `GET .../acceptance` keeps `quote_id` and `rfq_id`, and gives a pending
218
+ maker's time left as `confirm_within_ms`. `deadline`, `fund_by` and
219
+ `server_time` are gone from both, and `server_time` from list quotes. The
220
+ result's `outcome` is an `AcceptOutcome`: the answer (`AcceptAnswer`), a
221
+ read (`Acceptance`) or `NotAdmitted`.
222
+ - Quotes carry no `accept_before`, and neither does the maker's create quote
223
+ receipt (`{ quote_id }`). Every listed quote can be accepted: the venue
224
+ renews an entry quote before it lapses, 14 seconds before its signed
225
+ `expiry`, and stops listing it then.
226
+ - Cancel RFQ takes no `Idempotency-Key`; cancelling is safe to repeat.
227
+
228
+ Contract `271.0.0-quote-signing`:
229
+
230
+ - A quote (list quotes, `QUOTE_CREATED`, the account snapshot) leads with
231
+ `quote_id`, `rfq_id`, `kind`, `sequence` and `payout` (entry) or `price`
232
+ (cash-out). The terms you sign move under
233
+ `signing`: `quote.entry` is now `quote.signing.entry` and `quote.sell_back`
234
+ is `quote.signing.sell_back`. `bestQuote` and `bestBid` rank by `payout`
235
+ and `price`, `netPayout` takes a quote or its entry terms, and
236
+ `netCashout(bid, position)` takes the bid itself (`{ kind, price }`, not
237
+ its terms) and the `position` of Get position's read
238
+ (`GET /v1/me/positions/{position_id}` returns `{ context, position }`) for
239
+ its `net_stake` and `fee_bps`.
240
+ - The acceptance (accept, `GET .../acceptance`) names a wallet funding failure
241
+ `reason` instead of `funding_failure_reason`, and declares `status` once.
242
+ The confirm response is the maker's view: `status`, `quote_id`, `rfq_id`,
243
+ `deadline` and `operation_id`.
244
+ - A cash-out RFQ names its owner `taker`, like an entry, and drops
245
+ `legs_hash`, `leg_state` and `decision_block`. `maker.bid(rfq, ...)` takes
246
+ `{ rfq_id, position_id, taker }`; derive the legs hash from `legs` and read
247
+ leg state on chain. Pass `{ price, legState }` to sign only a sell-back at
248
+ the leg state you priced. The `QUOTE_ACCEPTED` you confirm carries every
249
+ `SellBack` term.
250
+ - `openPosition` and `prepareEntryFunding` fund a shortfall with
251
+ `"approval"` by default: the wallet approves WalletAccept once (a permit the
252
+ SDK signs when the approval left is short), and later entries need no
253
+ per-trade authorization. Pass `funding: "wallet"` for a USDC authorization
254
+ per entry. `signEntry` without `prepared` still defaults to `"wallet"`: it
255
+ sends nothing, so it cannot land the permit a first approval entry needs.
256
+
257
+ Contract `270.0.0-builder-attribution`:
258
+
259
+ - Create RFQ drops `builder_authorization_expiry` and `builder_signature`
260
+ (contract 272 drops the signature altogether).
261
+
262
+ Contract `269.0.0-no-intents`:
263
+
264
+ - RFQs have no intents: `openPosition` drops `intent`, and `intent_id` and
265
+ `intent_generation` are gone from create RFQ, RFQ reads and RFQ events.
266
+ Every RFQ you open is held until you accept, cancel or leave.
267
+ - Create cash-out sends no body.
268
+ - A cash-out RFQ no longer carries `decision_read_gas`.
269
+ - Makers quote with a price only: the `{quote_id, entry}` and
270
+ `{quote_id, sell_back}` quote bodies are gone. `maker.quote` and
271
+ `maker.bid` already send `{payout}` and `{price}`.
272
+
273
+ Takers stop timing quotes (TT-2997). A quote or bid stays takeable while it
274
+ is on the book, until its maker or the venue replaces or cancels it, or the
275
+ RFQ ends:
276
+
277
+ - `acceptBefore()` is gone, and so is the UI adapter's `secondsLeft`. Show a
278
+ quote for as long as `watchQuotes` lists it.
279
+ - A `Chooser` takes only the offers: `(offers) => offer | undefined`. The
280
+ second argument, the venue clock, is gone, and `bestQuote` no longer filters
281
+ by `accept_before`. `watchQuotes` listeners get only the quotes, and the UI
282
+ adapter's `QuoteView` drops `serverNowMs`.
283
+ - `openPosition` drops `refreshMs`. After an accept is refused because its
284
+ quote was just replaced (`QUOTE_REPLACED`, `QUOTE_EXPIRED`), or the maker
285
+ declines or does not answer, it takes the next best quote, waiting up to
286
+ `quoteTimeoutMs` for one, until `maxAttempts` accepts were sent.
287
+ - `cashOut` does the same when its bid was just replaced, at no lower a
288
+ price than the first bid it chose, and takes `maxAttempts` (default 4). A
289
+ decline or timeout still ends it.
290
+
291
+ - `maker.quote` returns `{ quoteId }`, like `maker.bid`: `acceptBefore` is
292
+ gone, since the venue keeps the quote takeable until the RFQ closes (TT-2998).
293
+
294
+ Maker confirms by default (TT-2995):
295
+
296
+ - The maker SDK confirms every accept of a quote or bid in its `published`
297
+ store, signing the exact terms; an accept it did not publish is left to the
298
+ process that did. Pass `lastLook` to `createMaker` to decline instead, for
299
+ example because the price moved, and `onConfirmError` to see answers that
300
+ failed. An `onAcceptance` handler, while attached, answers in place of the
301
+ SDK. If you answer with `confirm` from your own listener, attach
302
+ `onAcceptance` instead: the SDK may already have answered. When a separate
303
+ process confirms for a quoter that shares its store, pass
304
+ `autoConfirm: false` to the quoter.
305
+ - `AcceptancePendingError` is gone. `quote` and `bid` on an RFQ where an
306
+ accept of this maker's quote awaits its answer now wait for that answer and
307
+ then publish. A 409 `STATE_CONFLICT` for an accept the stream had not yet
308
+ delivered is retried the same way.
309
+
310
+ Contract `268.0.0-combo-filter` (TT-3017):
311
+
312
+ - `GET /v1/markets` takes `combo` (`OPEN` or `CLOSED`), like `eligibility`:
313
+ `client.GET("/v1/markets", { params: { query: { combo: "OPEN", eligibility: "ENABLED" } } })`
314
+ lists the markets a Combo can include now. The filter applies after paging,
315
+ so a page can be short or empty while `has_more` is true, and the cursor is
316
+ bound to it.
317
+ - `combo.state` closes once a market's event starts (a game's kickoff, a
318
+ policy decision) or its result can be known, with the new reason
319
+ `EVENT_PASSED`, the reason makers refuse such a leg with. A game no longer
320
+ stays open in play. `OUTSIDE_WINDOW` now means only an unknown time or an
321
+ event more than 7 days away.
322
+
323
+ Contract `266.0.0-price-only-bids` (TT-2993):
324
+
325
+ - `maker.bid(rfq, { price })` sends only the price. The venue fills in the
326
+ other sell-back terms (the RFQ's position, owner and leg_state, an expiry
327
+ and salt), with an expiry that outlasts the cash-out RFQ, so the bid stays
328
+ takeable until the RFQ closes or you replace or cancel it. `lifetimeSeconds`
329
+ and `salt` are gone, and the result is `{ quoteId }`; the terms arrive in
330
+ the acceptance.
331
+ - `confirm` signs a cash-out acceptance only at a price this maker bid on that
332
+ RFQ, for its position, owner and leg_state, with an expiry the venue allows.
333
+ A `published` store now holds bids by their priced terms instead of their
334
+ digest.
335
+ - `bestBid(minPrice?)` no longer takes a minimum life: the venue lists only
336
+ bids that can still be accepted. Drop the first argument from
337
+ `bestBid(minLifeSeconds, minPrice)`. The UI adapter's `watchQuotes` drops its
338
+ `minLifeSeconds` argument the same way.
339
+
340
+ Contract `265.0.0-price-only-quotes` (TT-2979):
341
+
342
+ - `maker.quote(rfq, { payout })` sends only the price. The venue fills in the
343
+ other terms (the RFQ's legs, stake and taker, the vault's current fees, an
344
+ expiry and salt) and keeps the quote takeable, renewing its expiry and salt,
345
+ until the RFQ closes or you replace or cancel it. `lifetimeSeconds` and
346
+ `salt` are gone, and the result is `{ quoteId, acceptBefore }`; the terms
347
+ arrive in the acceptance. Each renewal gives the quote a new ID, and
348
+ `cancelQuote` with any of them cancels it.
349
+ - `confirm` signs an entry acceptance only at a price this maker published on
350
+ that RFQ, for this maker, with an expiry the venue allows. A `published`
351
+ store now holds entry quotes by their priced terms instead of their digest.
352
+
353
+ Contract `263.0.0-cancel-all-quotes`:
354
+
355
+ - Removed the quote lease: `renewQuoteLease`, `releaseQuoteLease` and
356
+ `keepQuoteLease`, and `PUT`/`DELETE /v1/makers/{maker_id}/quote-lease`.
357
+ Nothing replaces the renewals. A maker that dies is caught at its first
358
+ missed confirm, which withdraws all its open quotes; publish again to come
359
+ back.
360
+ - `close()` on a maker now cancels all its open quotes before closing the
361
+ stream, and returns a promise: await it before exiting. It never rejects; it
362
+ resolves to `cancelAllQuotes()`'s result, or undefined if that failed.
363
+ - Removed `GET /v1/markets/{outcome_id}/history` and its `MarketHistory`
364
+ type (contract 279). Read `GET /v1/charts/{series}` instead.
365
+
366
+ ### Added
367
+
368
+ - `deposit({ amount, onStarted?, signal? })` deposits wallet USDC into the
369
+ vault in one call (`signDeposit`, then `sendDeposit`) and resolves with its
370
+ operation once it is `COMMITTED`, throwing if it ended any other way, the
371
+ way `withdraw` and `exitToCore` do (TT-2998).
372
+
373
+ Contract `263.0.0-cancel-all-quotes`:
374
+
375
+ - `cancelAllQuotes()` (`DELETE /v1/makers/{maker_id}/quotes`): cancel all of
376
+ this maker's open quotes, answering `{cancelled, pending}`. A quote whose
377
+ acceptance awaits your answer stays and counts in `pending`.
378
+
379
+ Contract `262.0.0-live-marks` (TT-2930), additive:
380
+
381
+ - `getLiveMarks` (`GET /v1/live-marks`): the current mark of every perp a
382
+ listed price market charts (`LiveMark`: `coin`, `px`, `observed_at`, the
383
+ node time of the read that proved it; both null when unknown). For a first render before the
384
+ market stream's `mark_ticks` take over; display only.
385
+
6
386
  ## 0.124.0
7
387
 
8
388
  ### Added
package/README.md CHANGED
@@ -154,11 +154,15 @@ sign orders with that. The agent can trade but never withdraw. `singleOrderActio
154
154
  import { createMaker, type MakerAcceptance } from "@totalis/hip4-client/maker";
155
155
  import { privateKeyToAccount } from "viem/accounts";
156
156
 
157
+ // Optional: re-check your price and capital before you commit. This placeholder always confirms.
158
+ const stillGood = async (_acceptance: MakerAcceptance) => true;
159
+
157
160
  const maker = createMaker({
158
161
  environment: "production",
159
162
  apiKey: process.env.TOTALIS_MAKER_KEY!,
160
163
  makerId: process.env.TOTALIS_MAKER_ID!,
161
164
  signer: privateKeyToAccount(process.env.TOTALIS_WALLET_KEY as `0x${string}`),
165
+ lastLook: async (acceptance) => ((await stillGood(acceptance)) ? "CONFIRM" : "DECLINE"),
162
166
  });
163
167
 
164
168
  maker.onRfq(async (rfq) => {
@@ -166,13 +170,13 @@ maker.onRfq(async (rfq) => {
166
170
  await maker.quote(rfq, { payout: (BigInt(rfq.stake) * 18n) / 10n }); // placeholder price
167
171
  }
168
172
  });
169
-
170
- // Re-check your price and capital before you commit. This placeholder only checks the deadline.
171
- const stillGood = async (acceptance: MakerAcceptance) => Date.parse(acceptance.deadline) > maker.stream.serverNow();
172
-
173
- maker.onAcceptance(async (acceptance) => ((await stillGood(acceptance)) ? "CONFIRM" : "DECLINE"));
174
173
  ```
175
174
 
175
+ When a taker accepts a quote, the SDK checks the terms against the price you published and signs them
176
+ within the 2-second deadline. You write no confirm code. `lastLook` is optional; leave it out to confirm every
177
+ accept. A new `quote` or `bid` while an accept of your quote is being answered waits for that answer, then
178
+ publishes. If a separate process confirms for this one, pass `autoConfirm: false` here.
179
+
176
180
  Set up the maker first ([Market making](https://docs.totalis.trade/hyperliquid/guides/market-making)).
177
181
  `examples/onboard.mjs` onboards a maker headless, and `examples/node-bot.mjs` is a fuller bot.
178
182
 
@@ -16,6 +16,7 @@ export type KeyAccount = {
16
16
  readonly maker?: string;
17
17
  };
18
18
  export type KeyScope = Schemas["Scope"];
19
+ export type KeyPreset = Schemas["KeyPreset"];
19
20
  export type KeyMetadata = Schemas["KeyMetadata"];
20
21
  /**
21
22
  * The maker scopes for a quoting bot: it reads RFQs, quotes and confirms, and
@@ -23,11 +24,22 @@ export type KeyMetadata = Schemas["KeyMetadata"];
23
24
  * quote but never withdraw.
24
25
  */
25
26
  export declare const QUOTING_BOT_SCOPES: readonly ["rfq:read", "quote:read", "quote:write", "replay:read", "vault:read"];
27
+ /**
28
+ * The personal scopes for a taker bot: it opens and cashes out positions,
29
+ * funds them from the wallet, deposits and withdraws, and reads its account.
30
+ * Issue it as `preset: "TAKER"`.
31
+ */
32
+ export declare const TAKER_SCOPES: readonly ["identity:read", "account:read", "account:stream", "replay:read", "rfq:write", "quote:read", "quote:accept", "position:cashout", "sponsorship:use", "funding:deposit", "funding:withdraw"];
33
+ /** The scopes each `preset` grants, as the venue expands it: `MAKER` is `QUOTING_BOT_SCOPES`. */
34
+ export declare const KEY_PRESET_SCOPES: {
35
+ readonly TAKER: readonly ["identity:read", "account:read", "account:stream", "replay:read", "rfq:write", "quote:read", "quote:accept", "position:cashout", "sponsorship:use", "funding:deposit", "funding:withdraw"];
36
+ readonly MAKER: readonly ["rfq:read", "quote:read", "quote:write", "replay:read", "vault:read"];
37
+ };
26
38
  /** The maker scopes for lowering collateral (`reduceCollateral`). Keep this key apart from the quoting bot's. */
27
39
  export declare const COLLATERAL_SCOPES: readonly ["vault:read", "vault:write", "operations:submit"];
28
40
  /**
29
41
  * Check a challenge before the owner signs it: the exact issue_key template,
30
- * signed by the expected owner, for this account and action, granting exactly
42
+ * whose `signer` is the expected owner, for this account and action, granting exactly
31
43
  * `scopes` when given, and not expired.
32
44
  */
33
45
  export declare function checkKeyChallenge(challenge: KeyChallenge, expected: {
@@ -43,7 +55,14 @@ export declare function checkKeyChallenge(challenge: KeyChallenge, expected: {
43
55
  * create the key. The secret is returned once; a lost response surfaces
44
56
  * SECRET_UNAVAILABLE (list, revoke and replace, never retry).
45
57
  */
46
- export declare function issueApiKey(client: ApiKeyClient, owner: TotalisSigner, request: Schemas["UnsignedCreateKeyRequest"] & KeyAccount): Promise<{
58
+ export type IssueApiKeyRequest = Omit<Schemas["UnsignedCreateKeyRequest"], "scopes" | "preset"> & KeyAccount & ({
59
+ readonly scopes: Schemas["ScopeList"];
60
+ readonly preset?: never;
61
+ } | {
62
+ readonly preset: KeyPreset;
63
+ readonly scopes?: never;
64
+ });
65
+ export declare function issueApiKey(client: ApiKeyClient, owner: TotalisSigner, request: IssueApiKeyRequest): Promise<{
47
66
  readonly key: {
48
67
  readonly id: components["schemas"]["Uuid"];
49
68
  readonly account: {
package/dist/api-keys.js CHANGED
@@ -16,11 +16,19 @@ export function createApiKeyClient(environment, options) {
16
16
  * quote but never withdraw.
17
17
  */
18
18
  export const QUOTING_BOT_SCOPES = ["rfq:read", "quote:read", "quote:write", "replay:read", "vault:read"];
19
+ /**
20
+ * The personal scopes for a taker bot: it opens and cashes out positions,
21
+ * funds them from the wallet, deposits and withdraws, and reads its account.
22
+ * Issue it as `preset: "TAKER"`.
23
+ */
24
+ export const TAKER_SCOPES = ["identity:read", "account:read", "account:stream", "replay:read", "rfq:write", "quote:read", "quote:accept", "position:cashout", "sponsorship:use", "funding:deposit", "funding:withdraw"];
25
+ /** The scopes each `preset` grants, as the venue expands it: `MAKER` is `QUOTING_BOT_SCOPES`. */
26
+ export const KEY_PRESET_SCOPES = { TAKER: TAKER_SCOPES, MAKER: QUOTING_BOT_SCOPES };
19
27
  /** The maker scopes for lowering collateral (`reduceCollateral`). Keep this key apart from the quoting bot's. */
20
28
  export const COLLATERAL_SCOPES = ["vault:read", "vault:write", "operations:submit"];
21
29
  /**
22
30
  * Check a challenge before the owner signs it: the exact issue_key template,
23
- * signed by the expected owner, for this account and action, granting exactly
31
+ * whose `signer` is the expected owner, for this account and action, granting exactly
24
32
  * `scopes` when given, and not expired.
25
33
  */
26
34
  export function checkKeyChallenge(challenge, expected, now = Date.now()) {
@@ -30,8 +38,8 @@ export function checkKeyChallenge(challenge, expected, now = Date.now()) {
30
38
  const granted = message.resources.filter((resource) => resource.startsWith(scopePrefix)).map((resource) => resource.slice(scopePrefix.length)).sort().join(" ");
31
39
  const wanted = expected.scopes && [...expected.scopes].sort().join(" ");
32
40
  const problems = [
33
- message.address.toLowerCase() !== challenge.owner && "message address is not the challenge owner",
34
- challenge.owner !== expected.owner.toLowerCase() && `challenge owner ${challenge.owner} is not the signer ${expected.owner}`,
41
+ message.address.toLowerCase() !== challenge.signer && "message address is not the challenge signer",
42
+ challenge.signer !== expected.owner.toLowerCase() && `challenge signer ${challenge.signer} is not ${expected.owner}`,
35
43
  !message.uri.endsWith(path) && `message is for ${message.uri}, not ${path}`,
36
44
  expected.maker !== undefined && !message.resources.includes(`urn:totalis:account:maker:${expected.maker}`) && "message is for another account",
37
45
  !message.resources.includes(`urn:totalis:action:${expected.action}`) && `message is not for ${expected.action}`,
@@ -55,16 +63,10 @@ async function ownerProof(client, owner, maker, request) {
55
63
  checkKeyChallenge(challenge, {
56
64
  owner: await owner.address(), action: request.action === "CREATE" ? "create" : "rotate", maker,
57
65
  keyId: request.action === "ROTATE" ? request.key_id : undefined,
58
- scopes: request.action === "CREATE" ? request.request.scopes : undefined,
66
+ scopes: request.action === "CREATE" ? request.request.scopes ?? (request.request.preset === undefined ? undefined : KEY_PRESET_SCOPES[request.request.preset]) : undefined,
59
67
  });
60
68
  return { challenge_id: challenge.challenge_id, signature: await owner.signMessage(challenge.message) };
61
69
  }
62
- /**
63
- * Issue a scoped `ttk_` key through the owner-signed challenge (TT-1791): ask
64
- * for a challenge, check it, personal_sign it with the account owner, then
65
- * create the key. The secret is returned once; a lost response surfaces
66
- * SECRET_UNAVAILABLE (list, revoke and replace, never retry).
67
- */
68
70
  export async function issueApiKey(client, owner, request) {
69
71
  const { maker, ...body } = request;
70
72
  const proof = await ownerProof(client, owner, maker, { action: "CREATE", request: body });
@@ -25,8 +25,7 @@ type OperatorContract = [
25
25
  Assert<Excludes<OperatorOperations, "listMarkets">>
26
26
  ];
27
27
  type CashoutContract = Assert<OpenApiComponents["schemas"]["CashoutRfq"] extends {
28
- readonly decision_block: string;
29
- readonly decision_read_gas: "500000";
28
+ readonly taker: string;
30
29
  readonly net_stake: string;
31
30
  readonly payout: string;
32
31
  } ? true : false>;
package/dist/client.d.ts CHANGED
@@ -5,7 +5,7 @@ export type { components, operations, paths } from "./generated/client.js";
5
5
  export type { AccessToken, ApiClientOptions, PublicEnvironment } from "./base.js";
6
6
  /** The typed HTTP client for the `client` audience. `createTotalis` adds the flows. */
7
7
  export declare function createClient(environment: PublicEnvironment, options?: ApiClientOptions): import("openapi-fetch").Client<paths, `${string}/${string}`>;
8
- export { bestBid, bestQuote, createTotalis, defaultWalletApproval, EntryError, entryFailure, follow, WalletApprovalError, type Acceptance, type AcceptanceResult, type Amount, type ApprovalListener, type BridgeState, type ComboCash, type CashoutBid, type Chooser, type Deployment, type DepositAccepted, type EntryCash, type EntryFailure, type EntryFunding, type EntryQuote, type KnownWalletApproval, type LandedWalletApproval, type SignedWalletApproval, type WalletApproval, type WalletApprovalRequest, type CoreExit, type LegacySignedEntry, type Leg, type PreparedEntryFunding, type NotAdmitted, type RecordListener, type Operation, type Quote, type ResponseOf, type SellBackQuote, type SignedAcceptance, type SignedCashout, type SignedCoreExit, type SignedDeposit, type SignedEntry, type SignedReturnToCore, type Totalis, type TotalisOptions, type WalletCall, type Withdrawal, } from "./totalis.js";
8
+ export { bestBid, bestQuote, createTotalis, defaultWalletApproval, EntryError, entryFailure, follow, fundWindowMs, WalletApprovalError, type Acceptance, type AcceptanceResult, type Amount, type ApprovalListener, type BridgeState, type ComboCash, type CashoutBid, type Chooser, type Deployment, type DepositAccepted, type EntryCash, type EntryFailure, type EntryQuote, type KnownWalletApproval, type LandedWalletApproval, type SignedWalletApproval, type WalletApproval, type WalletApprovalRequest, type CoreExit, type LegacySignedEntry, type Leg, type MarketFilters, type MarketRow, type PreparedEntryFunding, type NotAdmitted, type RecordListener, type Operation, type Quote, type ResponseOf, type SellBackQuote, type SignedAcceptance, type SignedCashout, type SignedCoreExit, type SignedDeposit, type SignedEntry, type SignedReturnToCore, type Totalis, type TotalisOptions, type WalletCall, type Withdrawal, } from "./totalis.js";
9
9
  export { bridgeAction, bridgeGasBuffer, classifyHypercoreAnswer, coreSetupFee, hyperevmUsdcBridge, hyperliquidExchange, hyperliquidInfo, hyperliquidNetwork, hypercoreNonce, hypercoreSignature, readCoreCash, sendAssetTypedData, settleHypercore, signSendAsset, submitHypercore, usdcText, type BridgedCash, type CoreAccountMode, type CoreCash, type HypercoreAnswer, type HyperliquidInfo, type HypercoreSignature, type HypercoreTransport, type HyperliquidNetwork, type SendAssetAction, type SignedSendAsset, } from "./hypercore.js";
10
10
  export { approveAgentAction, approveAgentTypedData, approveBuilderFeeTypedData, approveHyperliquidAgent, approveTotalisBuilder, approveTotalisBuilderAction, cancelSingles, l1ActionHash, l1TypedData, outcomeAsset, outcomeCoin, placeSingle, readSingleOrder, readTotalisBuilderFee, signL1Action, singleCancelAction, singleCancelAnswers, singleCloid, singleOrderAction, singleOrderAnswer, submitSingleCancel, submitSingleOrder, totalisBuilder, type ApproveAgentAction, type ApproveBuilderFeeAction, type CancelByCloidAction, type CancelByOidAction, type ExchangeOptions, type L1Options, type OutcomeSide, type SignedL1Action, type SignedUserAction, type SingleAction, type SingleCancel, type SingleCancelAction, type SingleCancelAnswer, type SingleOrder, type SingleOrderAction, type SingleOrderAnswer, type SingleOrderStatus, type SingleTif, } from "./singles.js";
11
11
  export { ApiError, envelope, NetworkError, randomBytes32, rawBody, retryingFetch, sendOnce, unwrap, uuidv7, type Fetch, type Repaired, type RetryPolicy } from "./request.js";
package/dist/client.js CHANGED
@@ -4,7 +4,7 @@ export { publicServers, publicStreamServers } from "./base.js";
4
4
  export function createClient(environment, options) {
5
5
  return audienceClient(environment, options);
6
6
  }
7
- export { bestBid, bestQuote, createTotalis, defaultWalletApproval, EntryError, entryFailure, follow, WalletApprovalError, } from "./totalis.js";
7
+ export { bestBid, bestQuote, createTotalis, defaultWalletApproval, EntryError, entryFailure, follow, fundWindowMs, WalletApprovalError, } from "./totalis.js";
8
8
  export { bridgeAction, bridgeGasBuffer, classifyHypercoreAnswer, coreSetupFee, hyperevmUsdcBridge, hyperliquidExchange, hyperliquidInfo, hyperliquidNetwork, hypercoreNonce, hypercoreSignature, readCoreCash, sendAssetTypedData, settleHypercore, signSendAsset, submitHypercore, usdcText, } from "./hypercore.js";
9
9
  export { approveAgentAction, approveAgentTypedData, approveBuilderFeeTypedData, approveHyperliquidAgent, approveTotalisBuilder, approveTotalisBuilderAction, cancelSingles, l1ActionHash, l1TypedData, outcomeAsset, outcomeCoin, placeSingle, readSingleOrder, readTotalisBuilderFee, signL1Action, singleCancelAction, singleCancelAnswers, singleCloid, singleOrderAction, singleOrderAnswer, submitSingleCancel, submitSingleOrder, totalisBuilder, } from "./singles.js";
10
10
  export { ApiError, envelope, NetworkError, randomBytes32, rawBody, retryingFetch, sendOnce, unwrap, uuidv7 } from "./request.js";
@@ -37,7 +37,7 @@ export declare class ExitUnavailableError extends Error {
37
37
  /**
38
38
  * The wallet approval to WalletAccept did not become what was asked.
39
39
  * `PERMIT_EXPIRED`, `PERMIT_NONCE_USED` and `PERMIT_REVERTED` are the permit
40
- * request's `failure_reason`: it changed nothing. On `PERMIT_NONCE_USED` read
40
+ * request's `reason`: it changed nothing. On `PERMIT_NONCE_USED` read
41
41
  * the approval first, as another permit may already have set it; never sign
42
42
  * the old intent again automatically. `APPROVAL_UNKNOWN`: the approval or its
43
43
  * nonce could not be read, so no permit was signed; read again.
@@ -44,7 +44,7 @@ export class ExitUnavailableError extends Error {
44
44
  /**
45
45
  * The wallet approval to WalletAccept did not become what was asked.
46
46
  * `PERMIT_EXPIRED`, `PERMIT_NONCE_USED` and `PERMIT_REVERTED` are the permit
47
- * request's `failure_reason`: it changed nothing. On `PERMIT_NONCE_USED` read
47
+ * request's `reason`: it changed nothing. On `PERMIT_NONCE_USED` read
48
48
  * the approval first, as another permit may already have set it; never sign
49
49
  * the old intent again automatically. `APPROVAL_UNKNOWN`: the approval or its
50
50
  * nonce could not be read, so no permit was signed; read again.