Order Vault

The contract maintains a mapping of orders, addPositionOrders, and decreasePositionOrders, which store information about different types of orders.

Initialize

This function initializes the OrderVault contract.

initialize()

Init

This function initializes the OrderVault contract with various dependencies, including the priceManager, positionVault, settingsManager, vault, and operators contracts.

init(
IPriceManager _priceManager, 
IPositionVault _positionVault, 
ISettingsManager _settingsManager, 
IVault _vault, 
IOperators _operators
)

Create New Order

This function is used by the positionVault contract to create a new order for opening a position. It takes parameters such as the position ID, account address, position type, token ID, position size and collateral, limit and stop prices, and referral address.

createNewOrder(
uint256 _posId, 
address _account, 
bool _isLong, 
uint256 _tokenId, 
uint256 _positionType, 
uint256[] memory _params, 
address _refer
) external

Cancel Market Order

This function cancels a market order for a position. It sets the order's status to CANCELED and emits a FinishOrder event.

cancelMarketOrder(uint256 _posId) public

Cancel Pending Order

This function cancels a pending order by setting its status to canceled. It requires the caller to be the owner of the position and the order to be in the pending status.

cancelPendingOrder(address _account, uint256 _posId) external

Update Order

This function updates the information of an order, including its position type, collateral, size, and status.

updateOrder(
uint256 _posId, 
uint256 _positionType, 
uint256 _collateral, 
uint256 _size, 
OrderStatus _status
) public status);

Create Add Position Order

This function creates an add position order for a position. It sets the owner, collateral delta, size delta, allowed price, timestamp, and fee for the add position order.

createAddPositionOrder(
address _owner, 
uint256 _posId, 
uint256 _collateralDelta, 
uint256 _sizeDelta, 
uint256 _allowedPrice, 
uint256 _fee) external

Cancel Add Position Order

This function cancels an add position order by refunding the collateral and fee associated with the order.

cancelAddPositionOrder(uint256 _posId) external

Delete Add Position Order

This function deletes an add position order without refunding the collateral or fee.

deleteAddPositionOrder(uint256 _posId) external

Create Decrease Position Order

This function creates a decrease position order, which decreases the size of a position. It requires the order not to already exist for the given position ID.

createDecreasePositionOrder(
uint256 _posId, 
uint256 _sizeDelta, 
uint256 _allowedPrice
) external

Delete Decrease Position Order

This function deletes a decrease position order.

deleteDecreasePositionOrder(uint256 _posId) external

Add Trigger Orders

This function adds trigger orders to a position for take-profit and stop-loss purposes. It takes arrays of booleans indicating the type of trigger order, prices at which to trigger, and amount percentages to close.

addTriggerOrders(
uint256 _posId, 
address _account, 
bool[] memory _isTPs, 
uint256[] memory _prices, 
uint256[] memory _amountPercents
) external

Last updated