Position

The position object is the one that holds the information about a position and is crucial in managing reserved funds and profit/loss calculations.

Depending on the parameters of the order (leverage, expiration date) the appropriate futures contract hash is generated by the DMEX Web Application and sent for matching to the DMEX server.

The matching is performed as is usually done on an exchange, buy orders and sell orders are matched against one another and if the price condition matches, a new trade is created. The trade is then sent to the Smart Contract and a position is opened.

A position contains the following parameters:

Parameter

Type

Description

size

uint64

the size of the position in terms of the underlying asset (x1e8)

price

uint64

the average entry price

side

uint16

0 or 1 (1 - long, 0 - short)

entryBlock

uint48

the average entry block for the position

collateral

uint64

the amount of collateral (margin) reserved for the position

Each position has its unique hash comprised from the user address, futures contract hash and side.

function generatePositionHash (address user, bytes32 futuresContractHash, bool side) public view returns (bytes32)
{
    return keccak256(this, user, futuresContractHash, side);
}

Last updated