Events
Registry events
Econia emits two types of registry events:
Event | Event handle | Field name |
---|---|---|
MarketRegistrationEvent | Registry | market_registration_events |
RecognizedMarketEvent | RecognizedMarkets | recognized_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:
user::CancelOrderEvent
user::ChangeOrderSizeEvent
user::FillEvent
user::PlaceLimitOrderEvent
user::PlaceMarketOrderEvent
market::PlaceSwapOrderEvent
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:
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:
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 reason | Description |
---|---|
CANCEL_REASON_SELF_MATCH_TAKER | A self match required cancelling the remaining order size |
CANCEL_REASON_IMMEDIATE_OR_CANCEL | An immediate-or-cancel order did not fill completely across the spread |
CANCEL_REASON_MAX_QUOTE_TRADED | No 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 reason | Description |
---|---|
CANCEL_REASON_SELF_MATCH_TAKER | A self match required cancelling the remaining order size |
CANCEL_REASON_NOT_ENOUGH_LIQUIDITY | All liquidity on the book was taken by the order |
CANCEL_REASON_MAX_QUOTE_TRADED | No 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 reason | Description |
---|---|
CANCEL_REASON_TOO_SMALL_TO_FILL_LOT | No more base asset can be traded because the amount left to trade is less than one lot |
CANCEL_REASON_VIOLATED_LIMIT_PRICE | The 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
.