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 Finn Exchange Web Application and sent for matching to the Finn Exchange 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:
the size of the position in terms of the underlying asset (x1e8)
the average entry price
0 or 1 (1 - long, 0 - short)
the average entry block for the position
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);