Order
IOrderBookDomain
Addresses
| Chain | Address |
|---|
Types
ActionType
The type of an Action
Values
| Name | Description |
|---|---|
INCREASE_SIZE | call DomFiPerp.increasePosition |
DECREASE_SIZE | call DomFiPerp.decreasePositionWithId |
ADD_MARGIN | call DomFiPerp.increasePosition with 0 size |
REMOVE_MARGIN | call DomFiPerp.removeMargin |
enum ActionType {
INCREASE_SIZE,
DECREASE_SIZE,
ADD_MARGIN,
REMOVE_MARGIN
}
TriggerType
The type of a Trigger
Values
| Name | Description |
|---|---|
INVALID | Revert if encountered. Guards against accidental 0x00 |
PRICE | Compare price of a product vs a specified price |
PNL_RATE | Compare PnL of a position vs a specified % |
enum TriggerType {
INVALID,
PRICE,
PNL_RATE
}
TriggerCondition
Whether a trigger should activate below or above a value
Values
| Name | Description |
|---|---|
LTE | Activate if the current value is <= the target value |
GTE | Activate if the current value is >= the target value |
enum TriggerCondition {
LTE,
GTE
}
TriggerDetails
Details for an order's execution criteria
Fields
| Name | Type | Description |
|---|---|---|
triggerType | enum IOrderBookDomain.TriggerType | The type of comparison to make |
triggerCondition | enum IOrderBookDomain.TriggerCondition | should trigger >= or <= threshold? |
triggerPnLRate | FPSigned | Target PnL rate, a position's PnL divided by its margin, to be compared with conditions on chain. |
triggerPrice | FPUnsigned | Target price, to be compared with on-chain product price. |
struct TriggerDetails {
enum IOrderBookDomain.TriggerType triggerType;
enum IOrderBookDomain.TriggerCondition triggerCondition;
FPSigned triggerPnLRate;
FPUnsigned triggerPrice;
}
OrderDetails
The action taken when an order is executed. Each OrderDetails instance must contain only the relevant fields for its trigger and action types.
Fields
| Name | Type | Description |
|---|---|---|
leverage | FPUnsigned | Unused (legacy) |
margin | uint256 | This slot is:
|
tradeFee | uint256 | For INCREASE_SIZE only; pre-collected trade fee. |
size | FPUnsigned | For INCREASE_SIZE and DECREASE_SIZE only; size to change by |
removeMarginFactor | FPUnsigned | This slot is:
|
struct OrderDetails {
FPUnsigned leverage;
uint256 margin;
uint256 tradeFee;
FPUnsigned size;
FPUnsigned removeMarginFactor;
}
Order
A user order on the exchange.
Fields
| Name | Type | Description |
|---|---|---|
executionFee | uint256 | Amount of network token reimbursed to order executor |
submittedAt | uint64 | Unix timestamp, in seconds, of last update. |
canceledAt | uint64 | Unix timestamp, in seconds, of cancelation. 0 if not yet canceled. |
executedAt | uint64 | Unix timestamp, in seconds, of execution. 0 if not yet executed. |
executionDeadline | uint64 | |
productId | ProductId | |
actionType | enum IOrderBookDomain.ActionType | See OrderBook.ActionType |
action | struct IOrderBookDomain.OrderDetails | Action that will be taken when the order executes. |
triggerDetails | struct IOrderBookDomain.TriggerDetails | |
isLong | bool | Required for INCREASE_SIZE only, since we might be creating a new position |
owner | address payable | The creator and beneficiary of this order. |
accountPositionId | PositionLabel | |
userData | bytes | User-specified data to attach to the order. |
struct Order {
uint256 executionFee;
uint64 submittedAt;
uint64 canceledAt;
uint64 executedAt;
uint64 executionDeadline;
ProductId productId;
enum IOrderBookDomain.ActionType actionType;
struct IOrderBookDomain.OrderDetails action;
struct IOrderBookDomain.TriggerDetails triggerDetails;
bool isLong;
address payable owner;
PositionLabel accountPositionId;
bytes userData;
}
OrderParams
Parameters to create an order. The same thing as Order,
except it does not include owner (set to msg.sender) or any of the
timestamp fields (which users cannot modify directly).
struct OrderParams {
PositionLabel accountPositionId;
ProductId productId;
bool isLong;
enum IOrderBookDomain.ActionType actionType;
struct IOrderBookDomain.OrderDetails action;
struct IOrderBookDomain.TriggerDetails triggerDetails;
uint256 executionFee;
uint64 executionDeadline;
bytes userData;
}