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.
Set Vault Settings
This function sets the vault settings including the price manager, settings manager, position vault, order vault, and liquidate vault.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Cancel Pending Order
This function allows a user to cancel a pending order. The function cancels the pending order in the order vault.
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.
Get VLP Price
This function returns the price of the VLP token.
Get Vault USD Balance
This function returns the USD balance of the vault.
Last updated