VELA Knowledge Base
  • Exchange
    • Platform Overview
    • Account Setup
      • Deposit & Withdraw
      • 1-Click Trading
    • Staking
      • $VLP
      • $VELA and $esVELA
      • Rewards
      • Hyper VLP
        • Hyper VLP Legacy
        • Hyper VLP 2.0
    • Trading
      • Positions
        • Profit, Loss, and ROI
        • Increase Collateral/ Leverage
        • Add to Position
        • Triggered Orders
        • Edit Triggered Orders
        • Close Position
      • Chart Trading
      • Mobile
    • Platform Mechanics
      • Fees
      • Price Feeds
      • Risk Mitigation
    • Tokenomics
    • Restricted Countries
  • Community
    • Grand Prix Trading Competition
      • Credits
      • Missions & Streaks
      • Nitro Boost
    • Social Features
      • Referrals
      • Share Trade
      • Leaderboards
      • AstraBit Guide
      • Previous Events
        • Pirate's Loot Trading Competition
    • NFTs
  • Support
    • Resources (Links)
    • Brand Kit
    • Gnosis Safe Management
  • Developers
    • APIs
      • The Graph API
      • Trade Bots API
      • Market Maker API
    • Asset Pairs and VelaId
    • Contracts
      • Arbitrum Mainnet
      • Arbitrum Testnet
      • Base Mainnet
      • Base Testnet
    • Contract Functions
      • Vault
      • Position Vault
      • Liquidate Vault
      • Order Vault
      • Price Manager
      • Settings Manager
      • Multicall
    • Audit
Powered by GitBook
On this page
  1. Developers
  2. Contract Functions

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
)
PreviousVaultNextLiquidate Vault

Last updated 1 year ago