APIs
Open a Position
This function opens a new leverage position for a product. If there's an existing position for the product with the same direction, this trade will increase the existing position.
Name | Type | Description |
---|---|---|
productId | uint256 | the ID representing the product. The mapping of IDs and products is the the table below. |
margin | uint256 | the amount of token used as collateral for the position(need to multiply 1e8). |
isLong | bool | True means Long and False means short. |
leverage | uint256 | the intended leverage for the position(need to multiply 1e8). |
positionId | uint256 | the id representing the position. |
Below is the mapping between productId and product. The list will grow as more product is added.
productId | Product |
---|---|
1 | ETH-USD |
2 | BTC-USD |
3 | LINK-USD |
4 | SNX-USD |
Close a Position
There are two functions available to close a position owned by the sender:
Name | Type | Description |
---|---|---|
productId | uint256 | the ID representing the product |
margin | uint256 | the amount of collateral to close for the position. The position can be fully or partially closed.(need to multiply 1e) |
isLong | bool | True means Long and False means short |
positionId | uint256 | the id of the position to close |
Get Open Positions
Get the information given the list of positionIds.
Get the information for a user's position for a product with certain direction.
Name | Type | Description |
---|---|---|
positionIds | uint256[] | a list of position ids |
account | address | a user's wallet address |
productId | uint256 | the ID representing the produt |
isLong | bool | True means Long and False means short |
position | Position | the struct consist of positionId, leverage, entry price, orace price at the opening, margin, owner, timestamp, direction |
Last updated