Skip to main content

Orders

Users can create limit or market orders, modify orders, and cancel orders. The BalanceManager must have the necessary funds to process orders. DeepBookV3 has four order options and three self matching options. If you set the pay_with_deep flag to true, trading fees are paid with the DEEP token. If you set the pay_with_deep flag to false, trading fees are paid with the input token.

Users can modify their existing order, reducing the size, lowering the expiration time, or both. Users cannot modify their order to increase their size or increase their expiration time. To do that, they must cancel the original order and place a new order.

Users can cancel a single order or cancel all of their orders.

API

Following are the order related endpoints that Pool exposes.

Click to open
Order options

The following constants define the options available for orders.

Click to open
Self-matching options

The following constants define the options available for self-matching orders.

Click to open
OrderInfo struct

Placing a limit order or a market order creates and returns an OrderInfo object. DeepBookV3 automatically drops this object after the order completes or is placed in the book. Use OrderInfo to inspect the execution details of the request as it represents all order information. DeepBookV3 does not catch any errors, so if there's a failure of any kind, then the entire transaction fails.

Click to open
OrderDeepPrice struct

The OrderDeepPrice struct represents the conversion rate of DEEP at the time the order was placed.

Click to open
Fill struct

The Fill struct represents the results of a match between two orders. Use this struct to update the state.

Click to open
Place limit order

Place a limit order. Quantity is in base asset terms. For current version pay_with_deep must be true, so the fee is paid with DEEP tokens.

You must combine a BalanceManager call of generating a TradeProof before placing orders.

Click to open
Place market order

Place a market order. Quantity is in base asset terms. Calls place_limit_order with a price of MAX_PRICE for bids and MIN_PRICE for asks. DeepBookV3 cancels the order for any quantity not filled.

Click to open
Modify order

Modifies an order given order_id and new_quantity. New quantity must be less than the original quantity and more than the filled quantity. Order must not have already expired.

The modify_order function does not return anything. If the transaction is successful, then assume the modification was successful.

Click to open
Cancel order

Cancel an order. The order must be owned by the balance_manager. The order is removed from the book and the balance_manager open orders. The balance_manager balance is updated with the order's remaining quantity.

Similar to modify, cancel_order does not return anything. DeepBookV3 emits OrderCanceled event.

Click to open
Cancel multiple orders

Cancel multiple orders within a vector. The orders must be owned by the balance_manager. The orders are removed from the book and the balance_manager open orders. If any order fails to cancel, no orders will be cancelled (atomic operation).

Click to open
Cancel all orders

Cancel all open orders placed by the balance manager in the pool. This is a convenience function that cancels every order associated with the balance manager.

Click to open
Withdraw settled amounts

Withdraw settled amounts to the balance_manager. All orders automatically withdraw settled amounts. This can be called explicitly to withdraw all settled funds from the pool.

Click to open
Withdraw settled amounts permissionless

Withdraw settled amounts to the balance_manager without requiring a TradeProof. This is a permissionless version that anyone can call to settle a balance manager's funds.

Events

Click to open
OrderFilled

Emitted when a maker order is filled.

Click to open
OrderCanceled

Emitted when a maker order is canceled.

Click to open
OrderModified

Emitted when a maker order is modified.

Click to open
OrderPlaced

Emitted when a maker order is placed into the order book.

DeepBookV3 repository

The DeepBookV3 repository on GitHub.