Position Vault

This contract is a position vault that manages positions and orders for a trading system. It allows users to open and close positions, execute orders, and manage collateral.
Initialize
This function initializes the contract with the operators, vlp, and vusd addresses.
function initialize(address _operators, address _vlp, address _vusd) public {
__ReentrancyGuard_init();
operators = IOperators(_operators);
vlp = IVLP(_vlp);
vusd = IVUSD(_vusd);
}
NewPositionOrder
This function allows the vault to create a new position order.
function newPositionOrder(
address _account,
uint256 _tokenId,
bool _isLong,
OrderType _orderType,
uint256[] memory _params,
address _refer
)
AddOrRemoveCollateral
This function allows the vault to add or remove collateral from a position.
function addOrRemoveCollateral(
address _account,
uint256 _posId,
bool isPlus,
uint256 _amount
)
CreateAddPositionOrder
This function allows the vault to create an order to add to a position.
function createAddPositionOrder(
address _account,
uint256 _posId,
uint256 _collateralDelta,
uint256 _sizeDelta,
uint256 _allowedPrice
)
CreateDecreasePositionOrder
This function allows the vault to create an order to decrease a position.
function createDecreasePositionOrder(
uint256 _posId,
address _account,
uint256 _sizeDelta,
uint256 _allowedPrice
)
SelfExecuteDecreasePositionOrder
This function allows users to self-execute a decrease position order after the selfExecuteCooldown period has passed.
function selfExecuteDecreasePositionOrder(uint256 _posId)
ExecuteRemoveCollateral
This function allows the vault to execute the removal of collateral from a position.
function executeRemoveCollateral(uint256 _posId)
ExecuteOpenMarketOrder
This function allows the vault to execute an open market order.
function executeOpenMarketOrder(uint256 _posId)
ExecuteAddPositionOrder
This function allows the vault to execute an add position order.
function executeAddPositionOrder(uint256 _posId)
ExecuteDecreasePositionOrder
This function allows the vault to execute a decrease position order.
function executeDecreasePositionOrder(uint256 _posId)
ExecuteOrders
This function allows the vault to execute a batch of orders also this function executes a batch of orders. The numOfOrders parameter specifies the number of orders to execute. The onlyOperator(1) modifier ensures that only an operator with level 1 can call this function.
function executeOrders(uint256 numOfOrders)
IncreasePosition
This function is called by the Order Vault contract to increase a position.
function increasePosition(
uint256 _posId,
address _account,
uint256 _tokenId,
bool _isLong,
uint256 _price,
uint256 _collateralDelta,
uint256 _sizeDelta,
uint256 _fee
)
DecreasePosition
This function is called by the Vault contract to decrease a position.
function decreasePosition(
uint256 _posId,
uint256 _price,
uint256 _sizeDelta
)
DecreasePositionByOrderVault
This function is called by the Order Vault contract to decrease a position.
function decreasePositionByOrderVault(
uint256 _posId,
uint256 _price,
uint256 _sizeDelta
)