Vault

This contract is a part of a larger system and is responsible for managing positions, orders, and tokens.

Initialize

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

Vault.initialize(
    address _operators,
    address _vlp,
    address _vusd
);

Set Vault Settings

This function sets the vault settings including the price manager, settings manager, position vault, order vault, and liquidate vault.

Vault.setVaultSettings(
    IPriceManager _priceManager,
    ISettingsManager _settingsManager,
    IPositionVault _positionVault,
    IOrderVault _orderVault,
    ILiquidateVault _liquidateVault
);

Deposit

This function allows a user to deposit a specified amount of a token into the vault. The function checks if the deposit is allowed, transfers the tokens from the user to the vault, and mints vusd tokens for the user.

Vault.deposit(
    address _account,
    address _token,
    uint256 _amount
);

Withdraw

This function allows a user to withdraw a specified amount of a token from the vault. The function checks if the withdrawal is allowed, burns the vusd tokens from the user, and transfers the tokens from the vault to the user.

Vault.withdraw(
    address _token,
    uint256 _amount
);

Stake

This function allows a user to stake a specified amount of a token. The function checks if staking is enabled, transfers the tokens from the user to the vault, and mints vlp tokens for the user.

Vault.stake(
    address _account,
    address _token,
    uint256 _amount
);

Unstake

This function allows a user to unstake a specified amount of a token. The function checks if unstaking is enabled, burns the vlp tokens from the user, and transfers the tokens from the vault to the user.

Vault.unstake(
    address _tokenOut,
    uint256 _vlpAmount
);

New Position Order

This function allows a user to create a new position order. The function checks if the user has enough gas fee, sends the fee to the fee manager, and creates a new position order in the position vault.

Vault.newPositionOrder(
    uint256 _tokenId,          // Token ID
    bool _isLong,              // Long or short
    OrderType _orderType,      // Order type
    uint256[] memory _params,  // Parameters for the order
    address _refer             // Referral address
);

Add Position

This function allows a user to increase the size of an existing position. The function checks if the user has enough gas fee, sends the fee to the fee manager, and creates an add position order in the position vault.

Vault.addPosition(
    uint256 _posId,            // Position ID
    uint256 _collateralDelta,  // Change in collateral
    uint256 _sizeDelta,        // Change in size
    uint256 _allowedPrice      // Allowed price
);

Remove Collateral

This function allows a user to remove collateral from a position, which increases the leverage. The function checks if the user has enough gas fee, sends the fee to the fee manager, and removes the collateral from the position in the position vault.

Vault.removeCollateral(
    uint256 _posId,
    uint256 _amount
);

Decrease Position

This function allows a user to decrease the size of an existing position. The function checks if the user has enough gas fee, sends the fee to the fee manager, and creates a decrease position order in the position vault.

Vault.decreasePosition(
    uint256 _sizeDelta,
    uint256 _allowedPrice,
    uint256 _posId
);

Add Trailing Stop

This function allows a user to add a trailing stop order to a position. The function checks if the user has enough gas fee, sends the fee to the fee manager, and adds the trailing stop order to the position in the order vault.

Vault.addTrailingStop(
    uint256 _posId,
    uint256[] memory _params
);

Cancel Pending Order

This function allows a user to cancel a pending order. The function cancels the pending order in the order vault.

Vault.cancelPendingOrder(
    uint256 _posId
);

Force Close Position

This function allows an operator to force close a user's position if the position's profit exceeds the maximum allowed profit. The function checks if the profit exceeds the maximum allowed, decreases the position in the position vault, burns the exceeded profit from the user, and adds the exceeded profit to the vault.

Vault.forceClosePosition(
    uint256 _posId
);

Get VLP Price

This function returns the price of the VLP token.

Vault.getVLPPrice();

Get Vault USD Balance

This function returns the USD balance of the vault.

Vault.getVaultUSDBalance();

Last updated