Settings Manager

This is a contract for Vault Settings.

Initialize

This function initializes the PriceManager contract with the addresses of the Operators contract and the Pyth contract.

initialize(address _operators, address _pyth)

Set Asset

This function allows an operator with level 3 to set the information for a specific asset. It takes parameters such as the asset ID, symbol, Pyth ID, price, allowed staleness (in seconds), allowed deviation (in basis points), and maximum leverage.

setAsset(
uint256 _assetId, 
string calldata _symbol, 
bytes32 _pythId, 
uint256 _price, 
uint256 _allowedStaleness, 
uint256 _allowedDeviation, 
uint256 _maxLeverage
) external onlyOperator(3)

Set Usd Asset

This function allows an operator with level 3 to set the information for a USD stablecoin asset. It takes parameters such as the token address, asset ID, symbol, Pyth ID, price, allowed staleness (in seconds), allowed deviation (in basis points), and token decimals.

setUsdAsset(
address _tokenAddress, 
uint256 _assetId, 
string calldata _symbol, 
bytes32 _pythId, 
uint256 _price, 
uint256 _allowedStaleness, 
uint256 _allowedDeviation, 
uint256 _tokenDecimals
)

Get Last Price

This function retrieves the last recorded price of an asset based on its asset ID. It returns the price as a uint256 value.

getLastPrice(uint256 _assetId) public view override returns (uint256)

Token To Usd

This function converts a given token amount to an equivalent USD amount based on the asset's price and token decimals. It takes the token address and token amount as parameters and returns the equivalent USD amount as a uint256 value.

tokenToUsd(address _token, uint256 _tokenAmount) 
    external view override returns (uint256)

Usd To Token

This function converts a given USD amount to an equivalent token amount based on the asset's price and token decimals. It takes the token address and USD amount as parameters and returns the equivalent token amount as a uint256 value.

usdToToken(
address _token, 
uint256 _usdAmount
) external view override returns (uint256)

Last updated