Skip to main content

Stream events

createTotalis and createMaker start their own stream. To follow an account or a maker without them, use TotalisStream directly:
The stream applies the snapshot or replay, drops duplicates, and reconnects from the last applied cursor.
  • status is live only while it is caught up.
  • serverNow() is the venue clock.
  • On close it follows the close reason’s retry: BACKOFF resumes, REFRESH (or a reset frame) emits reset and takes a fresh snapshot, and NEVER ends it with StreamClosedError.
  • In a browser it authenticates with the auth.<token> subprotocol and the page’s origin. In Node and React Native it sends the bearer header (Connection).
What each event means is on Real time.

Page through lists

items walks every page of a list route and yields one item at a time. pages yields whole pages.

Money helpers

For example, a 3 USDC stake quoted at 9.18 USDC, with a 20 bps entry fee and a 100 bps profit fee, has a netPayout of 9.118140 USDC.

UI adapter

createUiAdapter(totalis, { onInvalidate, onCatalogStale }) gives a frontend what it needs without tying it to a framework:
  • live quotes, with the best one picked
  • the venue clock, as serverNow and secondsLeft
  • account invalidations, to refresh a query cache
  • a catalog refresh, only when catalog_generation moves