Skip to main content

Events

Registry events

Econia emits two types of registry events:

EventEvent handleField name
MarketRegistrationEventRegistrymarket_registration_events
RecognizedMarketEventRecognizedMarketsrecognized_market_events

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

Schemas

Econia emits the following market events:

Unlike limit orders and market orders which are associated with a market account, swaps are not affiliated with a market account, and can be executed without a signature.

Hence to ensure comprehensive emission of events, Econia provides event handles as follows:

Handle wrapperAssociated tableTable indexed by
user::MarketEventHandlesForMarketAccountuser::MarketEventHandlesMarket account ID
market::MarketEventHandlesForMarketmarket::MarketEventHandlesMarket ID
market::SwapperEventHandlesForMarketmarket::SwapperEventHandlesMarket ID

Since these event handles are stored inside tables they cannot be queried via the events by event handle API, and as such must be queried via the events by creation number API. Hence Econia provides associated event handle lookup view functions as follows:

Handle wrapperCreation info view function
user::MarketEventHandlesForMarketAccountuser::get_market_event_handle_creation_numbers
market::MarketEventHandlesForMarketmarket::get_market_event_handle_creation_info
market::SwapperEventHandlesForMarketmarket::get_swapper_event_handle_creation_numbers

Placing a limit order

When a signing user or a custodian places a limit order, a user::PlaceLimitOrderEvent is emitted to the associated user::MarketEventHandlesForMarketAccount.

If the order fills across the spread then for each fill a user::FillEvent is emitted to the user::MarketEventHandlesForMarketAccount for both the maker and taker side.

If the limit order does not entirely fill during the function call in which it was placed, and if it is ineligible to post to the book, a user::CancelOrderEvent is emitted to the associated user::MarketEventHandlesForMarketAccount with one of the following cancel reasons:

Cancel reasonDescription
CANCEL_REASON_SELF_MATCH_TAKERA self match required cancelling the remaining order size
CANCEL_REASON_IMMEDIATE_OR_CANCELAn immediate-or-cancel order did not fill completely across the spread
CANCEL_REASON_MAX_QUOTE_TRADEDNo more quote coins can be traded even though there is still base asset to fill across the spread

If the order posts to the book and evicts the order with the lowest price time priority, then the evicted order is cancelled and a user::CancelOrderEvent is emitted to the associated user::MarketEventHandlesForMarketAccount with CANCEL_REASON_EVICTION.

Placing a market order

When a signing user or a custodian places a market order, a user::PlaceMarketOrderEvent is emitted to the associated user::MarketEventHandlesForMarketAccount.

For each fill a user::FillEvent is emitted to the user::MarketEventHandlesForMarketAccount for both the maker and taker side.

If the market order does not entirely fill during the function call in which it was placed, a user::CancelOrderEvent is emitted to the associated user::MarketEventHandlesForMarketAccount with one of the following cancel reasons:

Cancel reasonDescription
CANCEL_REASON_SELF_MATCH_TAKERA self match required cancelling the remaining order size
CANCEL_REASON_NOT_ENOUGH_LIQUIDITYAll liquidity on the book was taken by the order
CANCEL_REASON_MAX_QUOTE_TRADEDNo more quote coins can be traded even though there is still base asset to fill across the spread

Placing a swap order (signing swapper)

When a signing swapper places a swap order, a market::PlaceSwapOrderEvent is emitted to the associated market::SwapperEventHandlesForMarket.

For each fill a user::FillEvent is emitted to the user::MarketEventHandlesForMarketAccount for the maker side, and to the market::SwapperEventHandlesForMarket for the taker side.

If the swap order does not fill the maximum specified base amount during the function call in which it was placed, a user::CancelOrderEvent is emitted to the associated market::SwapperEventHandlesForMarket with the same reasons as for a market order, as well as two additional cancel reasons that only apply to swaps:

Cancel reasonDescription
CANCEL_REASON_TOO_SMALL_TO_FILL_LOTNo more base asset can be traded because the amount left to trade is less than one lot
CANCEL_REASON_VIOLATED_LIMIT_PRICEThe next order on the book to match against violated the swap order limit price

Placing a swap order (non-signing swapper)

When a swap order is not placed by a signing swapper, a market::PlaceSwapOrderEvent is emitted to the associated market::MarketEventHandlesForMarket.

For each fill a user::FillEvent is emitted to the user::MarketEventHandlesForMarketAccount for the maker side only.

If the swap order does not fill the maximum specified base amount during the function call in which it was placed, a user::CancelOrderEvent is emitted to the associated market::MarketEventHandlesForMarket with the same reasons as for a swap order with a signing swapper.

Maker self cancel

If, during a self match, the maker side of the order gets cancelled, a user::CancelOrderEvent is emitted to the associated user::MarketEventHandlesForMarketAccount with CANCEL_REASON_SELF_MATCH_MAKER.

Changing order size

When a signing user or a custodian manually changes the size of an open order, a user::ChangeOrderSizeEvent is emitted to the associated user::MarketEventHandlesForMarketAccount.

Manual order cancel

When a signing user or a custodian manually cancels an open order, a user::CancelOrderEvent is emitted to the associated user::MarketEventHandlesForMarketAccount with CANCEL_REASON_MANUAL_CANCEL.