# Position Vault

**Initialize**

This function initializes the contract with the operators, vlp, and vusd addresses.

```solidity
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.

```solidity
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.

```solidity
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.

```solidity
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.

```solidity
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.

```solidity
function selfExecuteDecreasePositionOrder(uint256 _posId)
```

**ExecuteRemoveCollateral**

This function allows the vault to execute the removal of collateral from a position.

```solidity
function executeRemoveCollateral(uint256 _posId)
```

**ExecuteOpenMarketOrder**

This function allows the vault to execute an open market order.

```solidity
function executeOpenMarketOrder(uint256 _posId)
```

**ExecuteAddPositionOrder**

This function allows the vault to execute an add position order.

```solidity
function executeAddPositionOrder(uint256 _posId)
```

**ExecuteDecreasePositionOrder**

This function allows the vault to execute a decrease position order.

```solidity
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.

```solidity
function executeOrders(uint256 numOfOrders)
```

**IncreasePosition**

This function is called by the Order Vault contract to increase a position.

```solidity
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.

```solidity
function decreasePosition(
    uint256 _posId,
    uint256 _price,
    uint256 _sizeDelta
)
```

**DecreasePositionByOrderVault**

This function is called by the Order Vault contract to decrease a position.

```solidity
function decreasePositionByOrderVault(
    uint256 _posId,
    uint256 _price,
    uint256 _sizeDelta
)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.vela.exchange/vela-knowledge-base/developers/contract-functions/position-vault.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
