Order structure


order_scheme = {
    "maker": str,
    "price": {"type": int, 'min': 0},
    "qty": {
        "base_qty":{"type": int, 'min': 0},
        "quote_qty":{"type": int, 'min': 0}
    },
    "ticker": {"type": list, "min": 2, "max": 2, 'item_schema': {'type': str}},
    "fee": {"type": dict, 'fields': order_fee_scheme},
    "constraints": {
        "number_of_swaps_allowed": {'type': int, 'min': 0},
        "duration_valid": {'type': int, 'min': 0},
        "created_at": {"type": int, "min": 0},
        "stp":{type=int, "min":0, "max":3},
        "nonce": {'type': int, 'min': 0},
        "min_receive_amount": {"type": int, "min": 0},
        "router_signer": str,
    },
    "salt": {"type": int, "min": 0},
    "flags": {"type": dict, 'fields': {
        'full_fill_only': bool,
        'best_level_only': bool,
        'post_only': bool,
        'is_sell_side': bool,
        'is_market_order': bool,
        'to_ecosystem_book': bool,
        'external_funds':bool
        }
    },
    "source":str,
    "sign": {"type": list, "min_size": 2, 'item_schema': {'type': int, 'min': 0}},
    "router_sign": {"type": list, "min_size": 2, 'item_schema': {'type': int, 'min': 0}},
}

Order fee structure
{
  "trade_fee": {"type": "FixedFee"},
  "router_fee": {"type": "FixedFee"},
  "gas_fee":{"type": "GasFee"}
}
  • price: price of the quote asset (for example 2801.23)

    • if the order is passive, the order will be placed into the book at this price

    • if the order removes liquidity from the book (ie. is non-passive), the order will be matched against orders in the book till the protection price (slippage).

  • quantity: matchable amount of order

    • can be expressed as the quantity of the base token (base_qty) or quote token (quote_qty)

  • maker: address of the trader

  • constraints:

    • number_of_swaps_allowed: specify the maximum amount of trades the taker order can allow after it becomes unmatchable

    • duration_valid: amount of seconds after created_time order is valid

    • created_time: epoch time in seconds for when the order was created

As each trade will cost gas, this number_of_swaps_allowed limitation allows the taker to limit gas consumption by specifying the maximum amount of swaps allowed on their order. Currently the max number clients can set equals to 255

Exchange doesn't accept stale orders or orders that have created_time in the future. If you encounter issues please check if your machine clock aligned with the world clock

  • stp:

    • NONE = 0

    • EXPIRE_TAKER = 1

    • EXPIRE_MAKER = 2

    • EXPIRE_BOTH = 3

  • nonce:

    • orders that have nonces lower than the one defined by the user in the contract are considered invalid and cannot be matched (contract will fail to match it on rollup phase)

  • min_receive_amount: slippage semantic, applicable only for taker Router orders

  • router_signer: address that signs this order on behalf of the Router, set to 0x0 in case of no router

  • flags:

    • full_fill_only: specify if the order must be fully filled or it will be cancelled

    • best_level_only: specify if the order can be filled only on the current best level

    • post_only: can order be passive

    • is_sell_side: order side

    • is_market_order: is the order a limit order or a market order

    • to_ecosystem_book:

      • True -> order matchable only in the Ecosystem Book

      • False -> order matchable only in the Router Book

    • external_funds: source of funds to perform the trade:

      • True -> funds are from the balance of erc20 token

      • False -> funds are from the balance on the Exhcange

  • ticker: ticker

    • the first symbol corresponds to the base token

    • the second symbol corresponds to the quote token

  • fee: order fees

    • specify how much taker/maker fixed fees goes to the Exchange

    • specify how much taker fixed fees goes to the Router

    • specify how much gas fees goes to the Exchange for taker orders

Note: passive orders do not incur any gas fees

  • salt: random salt provided by the user

  • sign: sign of order hash of its typed message by order_signer private key

  • router_sign: sign of order hash of its typed message by router_signer private key

  • source: order origin, from where order originates (for example "layerakira" or any other frontend)

Last updated