drift-labs/protocol-v2

Maker-Friendly Instructions

Closed this issue · 3 comments

Drift is interested in adding instructions to the smart contract in order to facilitate a smoother experience for current & prospective market makers.

We are looking for input on what sort of instructions people might find useful.
Current instructions to be added:

  • PlaceOrders that does not revert all orders if you run out of margin during the ix.

For example, if you intended to place 5 orders and would fail the margin check on the 5th order, currently no orders would be placed. This instruction would silently fail to place the fifth order and allow the transaction to succeed, placing four out of the five orders on chain.

  • CancelOrders that accepts a “maximum_price” or “minimum_price” parameter in conjuction with “direction” to cancel all orders up to a certain price on either longs or shorts.

For example, if you had 4 buy / long orders placed on XYZ-PERP at $9, $10, $11, and $12, and sent an instruction with maximum_price: 10 and direction: PositionDirection.Long, the orders at $11 & $12 would be canceled, while the orders for $11 and $12 would remain on the book. Similarly, if you provided minimum_price: 11 and direction: PositionDirection.Long, the orders at $9 and $10 would be canceled, while the orders for $11 and $12 would remain on chain. The same logic would follow for sell / short orders. (edited)

Good ideas. For CancelOrders, it would also be useful to be able to cancel orders within +/- an oracle delta (since not all market maker orders will be at fixed limit prices).

Drift is interested in adding instructions to the smart contract in order to facilitate a smoother experience for current & prospective market makers.

We are looking for input on what sort of instructions people might find useful. Current instructions to be added:

  • PlaceOrders that does not revert all orders if you run out of margin during the ix.

For example, if you intended to place 5 orders and would fail the margin check on the 5th order, currently no orders would be placed. This instruction would silently fail to place the fifth order and allow the transaction to succeed, placing four out of the five orders on chain.

  • CancelOrders that accepts a “maximum_price” or “minimum_price” parameter in conjuction with “direction” to cancel all orders up to a certain price on either longs or shorts.

For example, if you had 4 buy / long orders placed on XYZ-PERP at $9, $10, $11, and $12, and sent an instruction with maximum_price: 10 and direction: PositionDirection.Long, the orders at $11 & $12 would be canceled, while the orders for $11 and $12 would remain on the book. Similarly, if you provided minimum_price: 11 and direction: PositionDirection.Long, the orders at $9 and $10 would be canceled, while the orders for $11 and $12 would remain on chain. The same logic would follow for sell / short orders. (edited)

have they already been implemented?

I implement the cancel 。#1197