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.

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.

Update Order

This function updates the information of an order, including its position type, collateral, size, and 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.

Cancel Add Position Order

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

Delete Add Position Order

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

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.

Delete Decrease Position Order

This function deletes a decrease position order.

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.

Last updated