@totalis/hip4-client 0.124.0 → 0.126.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 +389 -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 +833 -893
  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,395 @@
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.126.0
7
+
8
+ ### Added
9
+
10
+ - `SocialProfile.positions_won` and `positions_lost` (`getSocialPerson`, contract
11
+ `280.0.0-win-rate`): how many of the person's closed positions, singles and
12
+ Combos, ended above and below zero P&L, null while `volume` is. Win rate is
13
+ won over won plus lost.
14
+
15
+ ## 0.125.0
16
+
17
+ ### Added
18
+
19
+ - `issueApiKey` takes `preset: "TAKER"` or `preset: "MAKER"` instead of
20
+ `scopes`. The venue expands it, and the SDK checks that the challenge grants
21
+ exactly that set before the owner signs. `TAKER_SCOPES` and
22
+ `KEY_PRESET_SCOPES` export the sets; `MAKER` is `QUOTING_BOT_SCOPES`.
23
+ - A refused key request is `INVALID_REQUEST` naming the entry in
24
+ `field_violations` (`/scopes/<i>` or `/preset`, under `/request` for a
25
+ challenge), with why in the message.
26
+ - Makers price a cash-out from the chain in one call:
27
+ `createMaker({ ..., chain })` takes a HyperEVM JSON-RPC URL or an EIP-1193
28
+ provider (only `eth_call` is sent), and
29
+ `maker.readCashoutPosition(rfq)` reads the RFQ's position, checks the RFQ's
30
+ `legs` against `tickets(position_id).legsHash`, and returns
31
+ `{ ticket, legsHash, legState }`, `legState` being
32
+ `legStateOf(legs, legStateReadGas)` at the latest block. Bid with
33
+ `maker.bid(rfq, { price, legState: position.legState })`. `./maker` also
34
+ exports it standalone as `readCashoutPosition(chain, deployment, rfq)`,
35
+ with `readTicket`, `readLegState`, their calldata (`ticketsCall`,
36
+ `legStateOfCall`) and `legStateReadGas` (500000, the venue's).
37
+ - `legsHash(legs)` (`./typed-data`, `./maker`): the vault's EIP-712 `Leg[]`
38
+ hash, as `tickets(position_id).legsHash` records it.
39
+ - `openPosition` takes `builderCode`, sent as create RFQ's `builder_code`: it
40
+ credits the partner whose app sent the RFQ with its revenue share, at no
41
+ cost to the taker. It sends `stake` as a decimal string and the legs in
42
+ increasing `outcome_id` order, which the venue requires;
43
+ `rfqLegsInOrder(legs)` (`./partner`) gives that order for a client that
44
+ creates the RFQ itself.
45
+ - `listMarkets(filters?, limit?)` on `createTotalis` and `createMaker`: every
46
+ market `GET /v1/markets` lists under `combo`, `eligibility`, `category` and
47
+ `subcategory`, as an async iterator that reads on past short or empty
48
+ pages while `has_more` is true. `MarketFilters` and `MarketRow` type them.
49
+ - `GET /v1/market-results` reads the exact YES payout and, where recorded,
50
+ the settlement price for up to 100 outcome IDs in one request.
51
+ - `GET /v1/hypercore/positions` pages your own HyperCore positions, open and
52
+ closed, from the holdings ledger: paid, received, value, P&L, result,
53
+ pairs, sellable shares and fee-net To win, on Testnet and Mainnet.
54
+ - `GET /v1/hypercore/orders` reads your open HIP-4 orders and your spot fee
55
+ rates on Testnet and Mainnet.
56
+ - `GET /v1/market-results` items carry `final`: read an item again until it is.
57
+ - `readInvalidated` frames may name `HOLDINGS`: the holdings ledger applied
58
+ new rows of your account wallet, so refetch `GET /v1/hypercore/positions`.
59
+
60
+ ### Changed
61
+
62
+ - `deposit`, `signDeposit` and `returnToCore` work with a participant API key
63
+ that holds `funding:deposit` and `sponsorship:use`, as well as with a
64
+ session. The signer must still be the account wallet of that key's account.
65
+ - A deposit larger than the wallet's available USDC fails with
66
+ `INSUFFICIENT_WALLET_BALANCE` (409, retry `REFRESH`) instead of
67
+ `STATE_CONFLICT`. A deposit under its wallet's minimum is `INVALID_REQUEST`
68
+ naming `/value`, with the minimum in the message.
69
+
70
+ - An RFQ you open without an intent, entry or cash-out, stays open while your
71
+ stream is connected, up to an hour, instead of 20 seconds (30 for a
72
+ cash-out), and closes about two minutes after your last stream disconnects
73
+ (TT-2996). A cash-out RFQ also closes once a leg of its position settles.
74
+ `openPosition` and `cashOut` now cancel their RFQ when they give up without
75
+ a fill, so the RFQ doesn't stay open.
76
+
77
+ ### Breaking
78
+
79
+ - The deposit body is flat, like the withdrawal's: `signDeposit` returns
80
+ `body: { value, valid_after, valid_before, salt, authorization_signature }`
81
+ with no `schema_version`, `request_id`, `sent_at`, `command`, `account` or
82
+ `from`; the venue takes the account from the credential. A `SignedDeposit`
83
+ persisted by an earlier version no longer sends: sign it again.
84
+
85
+ Contract `277.0.0-lean-exits`: the exit bodies are flat and carry only what
86
+ the venue does not already know, the Core exit answers only how far it got,
87
+ and a position read through `/v1/me` leaves out the maker's view.
88
+
89
+ - `POST /v1/core-exits` takes `{ amount, expiry, salt, signature, purpose,
90
+ activation_fee_accepted? }` and `POST /v1/me/run-off-claims` takes
91
+ `{ vault_address, amount, expiry, salt, signature }`: no `schema_version`,
92
+ `request_id`, `sent_at`, `command`, `account` or `to`. The venue takes the
93
+ Exit's `account` from the credential (its account wallet) and its `to` from
94
+ the deployment (the router, or the account itself for a run-off claim), and
95
+ verifies the signature over those terms. `signCoreExit`, `signReturnToCore`
96
+ and `signRunOffClaim` sign the same Exit as before and send the flat body;
97
+ an amount under the minimum names `/amount`. A `SignedCoreExit`,
98
+ `SignedReturnToCore` or signed run-off claim persisted by an earlier version
99
+ still holds `command` and no longer sends: sign it again.
100
+ - A Core exit (create, get, abandon and `GET /v1/me/core-exits`'s `exits`) is
101
+ `{ exit_id, status, purpose, amount, activation_fee_accepted, credit,
102
+ created_at, updated_at }`. `vault_address`, `account`, `router_address`,
103
+ `expiry`, `exit_digest`, `operation` and `sent` are gone; follow an exit by
104
+ its `status` (`waitForCoreExit` does). An `ABANDONED` tombstone has a null
105
+ `purpose` and `amount`. `CORE_EXIT_UPDATED` is unchanged.
106
+ - `GET /v1/me/positions` and `GET /v1/me/positions/{position_id}`, a maker
107
+ key's included, answer `Position` without `owner_username`, `opened_via`,
108
+ `maker_pnl` or `maker_result`. The maker's reads,
109
+ `GET /v1/makers/{maker_id}/positions[/{position_id}]`, answer
110
+ `MakerPosition` (`MakerPositionList`, `MakerPositionDetail`): every
111
+ `Position` field plus those four. The `maker_result` filter is unchanged on
112
+ both.
113
+ - `envelope` stays exported, though no current route takes one.
114
+
115
+ Contract `276.0.0-one-name-accounts`: one name for each idea across the
116
+ account, maker and partner surfaces. Enum values are unchanged; only field
117
+ names move. Signed EIP-712 terms keep their names (the deposit's
118
+ ReceiveWithAuthorization `value`, the permit's `owner`, `value` and
119
+ `deadline`, SellBack's `owner`).
120
+
121
+ - Why something ended is `reason`: `terminal_reason` on `EntryRfq`,
122
+ `CashoutRfq` and the stream's RFQ events; `failure_reason` on `Operation`,
123
+ `OPERATION_UPDATED` and `WalletApprovalRequest`; `failure_code` on
124
+ `CollateralReduction`; `close_reason` on `Position`. `EntryFailure` is
125
+ `NonNullable<Operation["reason"]>` and `entryFailure` takes
126
+ `Pick<Operation, "reason">`.
127
+ - USDC amounts are `amount`: the deposit body (`SignedDeposit.body.amount`)
128
+ and the wallet approval body (`SignedWalletApproval.body.amount`) send it,
129
+ and `WalletApprovalRequest` and a maker capital reservation return it. A
130
+ deposit under the minimum is `INVALID_REQUEST` naming `/amount`. A
131
+ `SignedDeposit` or `SignedWalletApproval` persisted by an earlier version
132
+ still holds `value` and no longer sends: sign it again. `signWalletApproval`
133
+ and `approveWallet` still take `value`.
134
+ - Lifecycle is `status`: `DepositAccepted`, the partner report's payouts,
135
+ `GET /v1/me/maker`'s `ownership`, `CopyAgent`, `ComboCopyAgent`,
136
+ `GoldenTicket`, `GoldenPlacementRead` and the placement answer, and the
137
+ social `SinglePosition` and `ComboPosition`. `makerReadiness` reads
138
+ `ownership.status`; its own `state` is unchanged.
139
+ - Read freshness is `freshness`: `Balance` and its components, `RunOffCash`,
140
+ `AccountValue` (and the `balance.updated` webhook), every account-read
141
+ `context` and `MakerWithdrawal`. `spendableCash` takes
142
+ `Pick<Balance, "amount" | "freshness" | "components" | "pending">`.
143
+ - Positions, not tickets: the partner report's `open_tickets: { tickets,
144
+ stake }` is `open_positions: { positions, stake }`, its fee fields'
145
+ `tickets` is `positions`, and maker performance counts are
146
+ `closed_position_count`, `won_position_count`, `lost_position_count` and
147
+ `even_position_count`.
148
+ - Who controls or signs: `MakerAccess`, `MakerCapital` and `ownership` name
149
+ the maker's wallet `controller`; `KeyCapabilities` and `KeyChallenge` name
150
+ the address that signs issuance `signer`. `checkKeyChallenge` still takes
151
+ `expected.owner` and compares it with `challenge.signer`.
152
+ - A partner webhook event names its kind `kind` (was `type`), in the posted
153
+ body and in `GET /v1/partner/webhook-events`.
154
+ - Also: `GET /v1/me/controlled-makers` names each maker's wallet
155
+ `controller` (was `owner`) and `MakerAccess.owner_version` is
156
+ `controller_version`; maker exposure counts are `open_position_count` and
157
+ `awaiting_position_count`; `GET /v1/me/copy-trades`,
158
+ `GET /v1/me/combo-copies` and `GET /v1/me/referral-bonus` name their
159
+ lifecycle `status` (was `state`); a `checkpoint`'s `projection_state` is
160
+ `freshness` (balances, operations, account value, `balance.updated`); and
161
+ maker telemetry's `telemetry.status` is `telemetry.freshness`.
162
+
163
+ Contract `275.0.0-one-name-markets-streams`:
164
+
165
+ - A market's lifecycle is `status`, not `state`: on `Market`, `Question`,
166
+ every discovery item and its `DiscoveryDisplay` (questions, standalone
167
+ markets, series and games), a past recurring round (`PastRound`) and a
168
+ HyperCore order (`HypercorePortfolioOrder`, `HypercoreHistoryOrder`). The
169
+ values are unchanged.
170
+ - A market's `eligibility` and `combo` name their value `status`:
171
+ `{ status: "ENABLED" }`, `{ status: "DISABLED", reason }`,
172
+ `{ status: "OPEN" }`, `{ status: "CLOSED", reason, opens_at }`. The
173
+ `eligibility` and `combo` query filters of `GET /v1/markets` keep their
174
+ names and values.
175
+ - A recurring round's `series` names its class `kind`
176
+ (`PRICE_BINARY` or `PRICE_BUCKET`).
177
+ - A market-display picture names its variant `kind`:
178
+ `{ kind: "SUBJECT", key }` or `{ kind: "GLYPH", glyph }`.
179
+ - Stream subscriptions are discriminated by `kind`, not `type`, on
180
+ `/v1/stream` and `/v1/market-stream`: send
181
+ `{ method: "subscribe", subscription: { kind: "account" | "maker" | "market", ... } }`,
182
+ and the `subscriptionResponse` echoes `kind`. `createTotalis` and
183
+ `createMaker` send it for you; a `subscription` option no longer takes
184
+ `type`.
185
+ - The market stream's `snapshot` and `delta` frames name each catalog
186
+ market's `status` and `eligibility.status` (`StreamCatalogMarket`), not
187
+ `state`.
188
+
189
+ Contract `274.0.0-lean-maker-confirm`:
190
+
191
+ - The maker's confirm answer (`Acceptance` in `./maker`) has no `deadline`:
192
+ it is `{ quote_id, rfq_id, status, operation_id? }`. The deadline comes
193
+ with `QUOTE_ACCEPTED` (`MakerAcceptance.deadline`), before the answer,
194
+ which is where `createMaker` already reads it.
195
+
196
+ Contract `273.0.0-implicit-accept-funding`:
197
+
198
+ - The accept body is only `{ taker_signature }`: `funding` is gone. When your
199
+ free vault cash is short of an entry's stake, the venue draws the shortfall
200
+ from your wallet's USDC approval to WalletAccept on its own. Approve once
201
+ (`approveWallet`, or let `openPosition` / `prepareEntryFunding` sign the
202
+ permit when the approval left is short) and every entry draws what it
203
+ needs. A scoped key draws the wallet only with `funding:deposit`.
204
+ - The SDK never signs a per-trade USDC authorization for an entry.
205
+ `EntryFunding` and the `funding` option of `openPosition`, `signEntry` and
206
+ `prepareEntryFunding` are gone, as is `PreparedEntryFunding.funding`.
207
+ `signEntry` without `prepared` checks that the approval left covers the
208
+ wallet's part (`WalletApprovalError` `INSUFFICIENT_APPROVAL` otherwise).
209
+ - A HyperCore transfer that funds an entry goes within `fundWindowMs` (4
210
+ seconds) of sending the accept, once it answers `ACCEPTED`: the venue waits
211
+ at least six seconds from the accept's arrival for it. `fund_within_ms` is
212
+ gone from the accept answer and `GET .../acceptance`, and `fund_by` from
213
+ `WALLET_FUNDING_UPDATED`. `sendAcceptance` reads nothing after the answer,
214
+ and `recoverAcceptance` never sends a bridge: an unsent one is discarded, a
215
+ `SENT` one stays `SENT`.
216
+
217
+ Contract `272.0.0-lean-rfq-flow` (TT-3023):
218
+
219
+ - A builder code needs no partner signature: it counts from an account the
220
+ partner admitted, or from a browser on the code's registered origin.
221
+ `attributeRfq`, `rfqAttributionMessage`, `AttributedRfq`, and
222
+ `openPosition`'s `builderAttribution` and `rfqIdempotencyKey` are gone, and
223
+ create RFQ refuses `builder_attribution`.
224
+ - HTTP responses in the RFQ flow carry no clocks. The accept answers only
225
+ what you did not send: `{ status, acceptance_id, operation_id?, reason? }`.
226
+ `GET .../acceptance` keeps `quote_id` and `rfq_id`, and gives a pending
227
+ maker's time left as `confirm_within_ms`. `deadline`, `fund_by` and
228
+ `server_time` are gone from both, and `server_time` from list quotes. The
229
+ result's `outcome` is an `AcceptOutcome`: the answer (`AcceptAnswer`), a
230
+ read (`Acceptance`) or `NotAdmitted`.
231
+ - Quotes carry no `accept_before`, and neither does the maker's create quote
232
+ receipt (`{ quote_id }`). Every listed quote can be accepted: the venue
233
+ renews an entry quote before it lapses, 14 seconds before its signed
234
+ `expiry`, and stops listing it then.
235
+ - Cancel RFQ takes no `Idempotency-Key`; cancelling is safe to repeat.
236
+
237
+ Contract `271.0.0-quote-signing`:
238
+
239
+ - A quote (list quotes, `QUOTE_CREATED`, the account snapshot) leads with
240
+ `quote_id`, `rfq_id`, `kind`, `sequence` and `payout` (entry) or `price`
241
+ (cash-out). The terms you sign move under
242
+ `signing`: `quote.entry` is now `quote.signing.entry` and `quote.sell_back`
243
+ is `quote.signing.sell_back`. `bestQuote` and `bestBid` rank by `payout`
244
+ and `price`, `netPayout` takes a quote or its entry terms, and
245
+ `netCashout(bid, position)` takes the bid itself (`{ kind, price }`, not
246
+ its terms) and the `position` of Get position's read
247
+ (`GET /v1/me/positions/{position_id}` returns `{ context, position }`) for
248
+ its `net_stake` and `fee_bps`.
249
+ - The acceptance (accept, `GET .../acceptance`) names a wallet funding failure
250
+ `reason` instead of `funding_failure_reason`, and declares `status` once.
251
+ The confirm response is the maker's view: `status`, `quote_id`, `rfq_id`,
252
+ `deadline` and `operation_id`.
253
+ - A cash-out RFQ names its owner `taker`, like an entry, and drops
254
+ `legs_hash`, `leg_state` and `decision_block`. `maker.bid(rfq, ...)` takes
255
+ `{ rfq_id, position_id, taker }`; derive the legs hash from `legs` and read
256
+ leg state on chain. Pass `{ price, legState }` to sign only a sell-back at
257
+ the leg state you priced. The `QUOTE_ACCEPTED` you confirm carries every
258
+ `SellBack` term.
259
+ - `openPosition` and `prepareEntryFunding` fund a shortfall with
260
+ `"approval"` by default: the wallet approves WalletAccept once (a permit the
261
+ SDK signs when the approval left is short), and later entries need no
262
+ per-trade authorization. Pass `funding: "wallet"` for a USDC authorization
263
+ per entry. `signEntry` without `prepared` still defaults to `"wallet"`: it
264
+ sends nothing, so it cannot land the permit a first approval entry needs.
265
+
266
+ Contract `270.0.0-builder-attribution`:
267
+
268
+ - Create RFQ drops `builder_authorization_expiry` and `builder_signature`
269
+ (contract 272 drops the signature altogether).
270
+
271
+ Contract `269.0.0-no-intents`:
272
+
273
+ - RFQs have no intents: `openPosition` drops `intent`, and `intent_id` and
274
+ `intent_generation` are gone from create RFQ, RFQ reads and RFQ events.
275
+ Every RFQ you open is held until you accept, cancel or leave.
276
+ - Create cash-out sends no body.
277
+ - A cash-out RFQ no longer carries `decision_read_gas`.
278
+ - Makers quote with a price only: the `{quote_id, entry}` and
279
+ `{quote_id, sell_back}` quote bodies are gone. `maker.quote` and
280
+ `maker.bid` already send `{payout}` and `{price}`.
281
+
282
+ Takers stop timing quotes (TT-2997). A quote or bid stays takeable while it
283
+ is on the book, until its maker or the venue replaces or cancels it, or the
284
+ RFQ ends:
285
+
286
+ - `acceptBefore()` is gone, and so is the UI adapter's `secondsLeft`. Show a
287
+ quote for as long as `watchQuotes` lists it.
288
+ - A `Chooser` takes only the offers: `(offers) => offer | undefined`. The
289
+ second argument, the venue clock, is gone, and `bestQuote` no longer filters
290
+ by `accept_before`. `watchQuotes` listeners get only the quotes, and the UI
291
+ adapter's `QuoteView` drops `serverNowMs`.
292
+ - `openPosition` drops `refreshMs`. After an accept is refused because its
293
+ quote was just replaced (`QUOTE_REPLACED`, `QUOTE_EXPIRED`), or the maker
294
+ declines or does not answer, it takes the next best quote, waiting up to
295
+ `quoteTimeoutMs` for one, until `maxAttempts` accepts were sent.
296
+ - `cashOut` does the same when its bid was just replaced, at no lower a
297
+ price than the first bid it chose, and takes `maxAttempts` (default 4). A
298
+ decline or timeout still ends it.
299
+
300
+ - `maker.quote` returns `{ quoteId }`, like `maker.bid`: `acceptBefore` is
301
+ gone, since the venue keeps the quote takeable until the RFQ closes (TT-2998).
302
+
303
+ Maker confirms by default (TT-2995):
304
+
305
+ - The maker SDK confirms every accept of a quote or bid in its `published`
306
+ store, signing the exact terms; an accept it did not publish is left to the
307
+ process that did. Pass `lastLook` to `createMaker` to decline instead, for
308
+ example because the price moved, and `onConfirmError` to see answers that
309
+ failed. An `onAcceptance` handler, while attached, answers in place of the
310
+ SDK. If you answer with `confirm` from your own listener, attach
311
+ `onAcceptance` instead: the SDK may already have answered. When a separate
312
+ process confirms for a quoter that shares its store, pass
313
+ `autoConfirm: false` to the quoter.
314
+ - `AcceptancePendingError` is gone. `quote` and `bid` on an RFQ where an
315
+ accept of this maker's quote awaits its answer now wait for that answer and
316
+ then publish. A 409 `STATE_CONFLICT` for an accept the stream had not yet
317
+ delivered is retried the same way.
318
+
319
+ Contract `268.0.0-combo-filter` (TT-3017):
320
+
321
+ - `GET /v1/markets` takes `combo` (`OPEN` or `CLOSED`), like `eligibility`:
322
+ `client.GET("/v1/markets", { params: { query: { combo: "OPEN", eligibility: "ENABLED" } } })`
323
+ lists the markets a Combo can include now. The filter applies after paging,
324
+ so a page can be short or empty while `has_more` is true, and the cursor is
325
+ bound to it.
326
+ - `combo.state` closes once a market's event starts (a game's kickoff, a
327
+ policy decision) or its result can be known, with the new reason
328
+ `EVENT_PASSED`, the reason makers refuse such a leg with. A game no longer
329
+ stays open in play. `OUTSIDE_WINDOW` now means only an unknown time or an
330
+ event more than 7 days away.
331
+
332
+ Contract `266.0.0-price-only-bids` (TT-2993):
333
+
334
+ - `maker.bid(rfq, { price })` sends only the price. The venue fills in the
335
+ other sell-back terms (the RFQ's position, owner and leg_state, an expiry
336
+ and salt), with an expiry that outlasts the cash-out RFQ, so the bid stays
337
+ takeable until the RFQ closes or you replace or cancel it. `lifetimeSeconds`
338
+ and `salt` are gone, and the result is `{ quoteId }`; the terms arrive in
339
+ the acceptance.
340
+ - `confirm` signs a cash-out acceptance only at a price this maker bid on that
341
+ RFQ, for its position, owner and leg_state, with an expiry the venue allows.
342
+ A `published` store now holds bids by their priced terms instead of their
343
+ digest.
344
+ - `bestBid(minPrice?)` no longer takes a minimum life: the venue lists only
345
+ bids that can still be accepted. Drop the first argument from
346
+ `bestBid(minLifeSeconds, minPrice)`. The UI adapter's `watchQuotes` drops its
347
+ `minLifeSeconds` argument the same way.
348
+
349
+ Contract `265.0.0-price-only-quotes` (TT-2979):
350
+
351
+ - `maker.quote(rfq, { payout })` sends only the price. The venue fills in the
352
+ other terms (the RFQ's legs, stake and taker, the vault's current fees, an
353
+ expiry and salt) and keeps the quote takeable, renewing its expiry and salt,
354
+ until the RFQ closes or you replace or cancel it. `lifetimeSeconds` and
355
+ `salt` are gone, and the result is `{ quoteId, acceptBefore }`; the terms
356
+ arrive in the acceptance. Each renewal gives the quote a new ID, and
357
+ `cancelQuote` with any of them cancels it.
358
+ - `confirm` signs an entry acceptance only at a price this maker published on
359
+ that RFQ, for this maker, with an expiry the venue allows. A `published`
360
+ store now holds entry quotes by their priced terms instead of their digest.
361
+
362
+ Contract `263.0.0-cancel-all-quotes`:
363
+
364
+ - Removed the quote lease: `renewQuoteLease`, `releaseQuoteLease` and
365
+ `keepQuoteLease`, and `PUT`/`DELETE /v1/makers/{maker_id}/quote-lease`.
366
+ Nothing replaces the renewals. A maker that dies is caught at its first
367
+ missed confirm, which withdraws all its open quotes; publish again to come
368
+ back.
369
+ - `close()` on a maker now cancels all its open quotes before closing the
370
+ stream, and returns a promise: await it before exiting. It never rejects; it
371
+ resolves to `cancelAllQuotes()`'s result, or undefined if that failed.
372
+ - Removed `GET /v1/markets/{outcome_id}/history` and its `MarketHistory`
373
+ type (contract 279). Read `GET /v1/charts/{series}` instead.
374
+
375
+ ### Added
376
+
377
+ - `deposit({ amount, onStarted?, signal? })` deposits wallet USDC into the
378
+ vault in one call (`signDeposit`, then `sendDeposit`) and resolves with its
379
+ operation once it is `COMMITTED`, throwing if it ended any other way, the
380
+ way `withdraw` and `exitToCore` do (TT-2998).
381
+
382
+ Contract `263.0.0-cancel-all-quotes`:
383
+
384
+ - `cancelAllQuotes()` (`DELETE /v1/makers/{maker_id}/quotes`): cancel all of
385
+ this maker's open quotes, answering `{cancelled, pending}`. A quote whose
386
+ acceptance awaits your answer stays and counts in `pending`.
387
+
388
+ Contract `262.0.0-live-marks` (TT-2930), additive:
389
+
390
+ - `getLiveMarks` (`GET /v1/live-marks`): the current mark of every perp a
391
+ listed price market charts (`LiveMark`: `coin`, `px`, `observed_at`, the
392
+ node time of the read that proved it; both null when unknown). For a first render before the
393
+ market stream's `mark_ticks` take over; display only.
394
+
6
395
  ## 0.124.0
7
396
 
8
397
  ### 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.