Skip to main content

Off-chain interfaces

Registry events

Econia emits two types of registry events:

EventEvent handleField name

Event handles for registry events are created via the @econia package account, and are stored as fields in key-able resources stored under the @econia account. Hence they can be easily queried via the Aptos node events by event handle API.

Market events

Econia emits two types of market events:

EventEvent handleField name

Unlike registry event handles, market event handles are created via a resource account, since the @econia signature is not available each time a new OrderBook is permissionlessly initialized. Each OrderBook is stored as a table entry in the OrderBooks map stored under the resource account, such that market events should be queried via the Aptos node events by creation number API.


The signing capability for the resource account is stored under the @econia account in a SignerCapabilityStore, such that the account number can be easily queried off chain.

Since the resource account is initialized with an aptos_framework::account::Account, event stream creation numbers 0 and 1 are reserved for coin_register_events and key_rotation_events handles. Hence, for 1-indexed market id nn, maker events have creation number 2n2n and taker events have creation number 2n+12n + 1:

Market IDMakerEvent handle creation numberTakerEvent handle creation number
nn2n2n2n+12n + 1

move-to-ts hooks

Econia is designed for use with Hippo's move-to-ts tool, which auto-generates a TypeScript software development kit (SDK) from Move source code. As such, Econia's Move source code contains assorted #[cmd] attributes on public entry functions and #[app] attributes on public getter functions for SDK generation. Additionally, index_orders_sdk() contains a #[query] attribute for off-chain OrderBook indexing.

The index_orders_sdk() function requires the signature of the @econia package account, such that malicious actors are unable to invoke the function during run time: the function is only intended for use during transaction simulation mode (which does not require the private key of @econia), via Hippo's move-to-ts tool #[query] interface. Here, the simulation might fail for a large OrderBook due to transaction gas limits, and it may be necessary to run a custom node, for example with a high maximum transaction gas limit and a low minimum transaction gas unit price, so the simulation can process the entire data structure.


If you are trying to run in simulation mode, see the welcome page for the @econia package account and public key listings.

Order book indexing

A suggested method for indexing an OrderBook in real time involves the index_orders_sdk() interface and event monitoring:

  1. Run index_orders_sdk() to build up a local copy of an OrderBook.
  2. Read and apply all MakerEvent and TakerEvent emissions since the index operation.

Alternatively, all MakerEvent and TakerEvent emissions since the inception of the market can be applied consecutively.