Execution semantic

The selection of different parameters for an order influences its semantic execution, dictating how the order will be processed and fulfilled. Below are some examples

Note that both base_qty and quote_qty cant be set to 0 in the parameters

Pure passive orders in the Ecosystem Book and the Router Books

If a user wishes to provide liquidity in the Ecosystem Book or Router Book at a specified level, the parameters are:

  • post_only = true

  • price = specify the price of the quote asset at which the user is willing for its order to be filled at

  • base_qty = specify the amount in base asset, the user wants to be filled, if 0 ignored

  • quote_qty = specify the amount in quote asset, the user wants to be filled, if 0 ignored

  • is_market_order = false

Example: A User wants to buy/sell 100 USD worth of ETH at market ETH/USDC in the Router Book at $1000. Then his flags and parameters will be as follows:

  • price = 1000, base_qty = 0, quote_qty = 100; or

  • price = 1000, base_qty = 0.1, quote_qty = 0


Pure non-passive orders in the Router Book

If a user wishes to remove liquidity from the Router Book, the parameters are:

  • post_only = false

  • price = this is the protection price, which is the worst-case price at which the user is willing to be filled. This should be always specified

  • base_qty = specify the amount in base asset, the user wants to be filled, if 0 ignored

  • quote_qty = specify the amount in quote asset, the user wants to be filled, if 0 ignored

  • is_market_order = true

  • stp = 0 as for Router orders it makes no sense to have self-trade prevention because Router orders and Ecosystem orders are guaranteed to be performed by different parties

  • to_ecosystem_book = false

  • number_of_swaps_allowed = amount of trades allowed to happen with this taker order

  • router_signer = address of Router signer who directed this taker liquidity to Router Book

  • min_receive_amount = the minimum amount of tokens that the user wants to receive after completion of his order (used as slippage). If this is not satisfied, the matching engine will reject the order

Additionally, user can also specify following parameters:

  • best_level_only = guarantees that all fills only happen at top of the book, unfilled amounts not touched

  • full_fill_only = guarantees that fills happen only for the full specified amount, or else no match happens

Examples:

  • User see see that the price of ETH is 1000 USDC, they wants to buy whatever amount of ETH for 100 USDC with slippage as 1%. The parameters will be as follows:

    • price = 1010, base_qty = 0, quote_qty = 100, min_receive_amount = 0.099

  • User see see that the price of ETH is 1000 USDC, they wants to sell 0.1 ETH, with slippage as 1%. The parameters will be as follows:

    • price = 0, base_qty = 0.1, quote_qty = 0, min_receive_amount = 99.9

  • User see see that the price of ETH is 1000 USDC, they wants to sell at most 0.1 ETH with price for fills being no worse than 999 USDC. The parameters will be as follows:

    • price=999, base_qty = 0.1, quote_qty = 0, min_receive_amount = 0

  • User see see that the price for ETH is 1000 USDC, they wants to buy up to 0.1 ETH for whatever amount of SUDC with price being no worse than 1001 USDC spending at most X USDC. Note that the user may leave quote_qty as 0. The parameters will be as follows:

    • price = 1001, base_qty = 0.1, quote_qty = x, min_receive_amount = 0

  • User see see that the price of ETH is 1000 USDC, he wants to sell whatever amount of ETH for 100usdc with slippage 1pct:

    • base_qty = 0.101, quote_qty =100, min_receive_amount = 100, price = some reasonable value can be 0


Pure non-passive orders in the Ecosystem Book

If a user wishes to remove liquidity from the Ecosystem Book, the parameters are:

  • post_only = false

  • price = this is the protection price, which is the worst-case price at which the user is willing to be filled. This should be always specified

  • base_qty = specify the amount in base asset, the user wants to be filled, if 0 ignored

  • quote_qty = specify the amount in quote asset, the user wants to be filled, if 0 ignored

  • is_market_order = true

  • stp = select mode, referring to self trade prevention mode

  • to_ecosystem_book = true

  • number_of_swaps_allowed = amount of trades allowed to happen with this taker order

  • router_signer = NULL_ADDRESS

  • min_receive_amount = 0

Additionally, the user can specify the following parameters:

  • best_level_only = guarantees that all fills only happen at the top of the book, unfilled amounts are not touched

  • full_fill_only = guarantees that fills happen only for the full specified amount else no match happens. Note that this only works when STP set to NONE

Example:

  • User see see that the price of ETH is 1000 USDC, he wants to buy whatever amount of ETH for up to 100 USDC with the price being no worse then 1100. The parameters will be as follows:

    • price = 1100, base_qty = 0, quote_qty = 100

  • User see see that the price of ETH is 1000 USDC, he wants to sell up to 0.1 ETH, with the price being no worse then 990. The parameters will be as follows:

    • price = 990, base_qty = 0.1, quote_qty = 0

  • User see see that the price of ETH is 1000 USDC, he wants to buy up to 0.1 ETH for whatever amount of USDC with price being no worse than 1000 USDC, spending at most x usdc. Note that user may leave quote_qty as 0 then the Exchange will expect the user to have price*qty of the quote token to process the order. The parameters will be as follows:

    • price = 1000, base_qty = 0.1, quote_qty = x

  • User see see that the price of ETH is 1000 USDC, he wants to sell up to 100 USDC worth of ETH, with the price being no worse than 1000 USDC. The parameters will be as follows:

    • price = 1000, base_qty = 0, quote_qty = 100


Passive orders in the Ecosystem Book

If a user wishes to remove liquidity from the Ecosystem Book and for the remaining part to be placed into the last traded price of the order, the parameters are:

  • post_only = false

  • is_market_order = false

  • price = this is the protection price, which is the worst case price at which the user is willing to be filled. This should always be specified. The remaining part of the order will be placed at the protection price on the opposite side of the book

  • base_qty = specify the amount in base asset, the user wants to be filled, if 0 ignored

  • quote_qty = specify the amount in quote asset, the user wants to be filled, if 0 ignored

  • stp = self trade prevention mode selected - this will be used when the order is treated as a taker order

  • to_ecosystem_book = True

  • number_of_swaps_allowed = amount of trades allowed to happen when the order is considered a taker order

  • router_signer = NULL_ADDRESS

  • min_receive_amount = 0

  • full_fill_only = False

Additionally, the user can specify :

  • best_level_only = This guarantees that all fills only happen at the top of the book, the unfilled amount placed at the opposite side at the last traded price of this order

Behaves the same as non-passive order but the remaining part is placed on the opposite side of the order book

Last updated