Open/Increase a market Position
In order to create or increase a position:
Approve the Order Manager Contract for the token and the amount you want to use as collateral in order to open a position.
Call OrderManager.createIncreasePosition() with the following parameters:
_collateralToken: address of the collateral token
_indexToken: address of the token you want to long or short.
_amountIn: specifies the amount of collateral tokens.
_sizeDelta: USD value of the size you want to open a position.
_isLong: whether the position is long or short.
_acceptablePrice: price at which you want your position request to get executed.
takeProfitPrice: If you want to open a take profit while placing a market order, pass the TP price in this parameter; otherwise, leave it as 0.
stopLossPrice: Similar to takeProfitPrice, if you want to specify a stop loss for the position while placing a market order, pass the SL price in this parameter; otherwise, leave it as 0.
_executionFee
If placing a market order, this should be >= OrderManager.minExecutionFeeMarketOrder.
If placing a tp or sl order, _executionFee should be >= OrderManager.minExecutionFeeMarketOrder + OrderManager.minExecutionFeeLimitOrder
If placing a tp and sl order along with the market order, _executionFee >= minExecutionFeeMarketOrder + 2 * minExecutionFeeLimitOrder
After this transaction, a request to create your position will be created, and a keeper will execute your request. Note that a request can either be executed or fail.
If the position cannot be increased due to factors like the unfulfilled acceptable price, the request will be terminated, and the funds will be returned to the sender (msg.sender)
Last updated