Price Manager
This contract implements functionality related to managing asset prices, conversions between tokens and USD, and retrieving asset-related information.
Initialize
This function initializes the PriceManager
contract with the addresses of the operators
and pyth
contracts.
Set Asset
This function sets the details of an asset, such as its symbol, Pyth ID, price, allowed staleness, allowed deviation, and maximum leverage.
Set Usd Asset
This function sets the details of a USD stablecoin asset, including its token address, symbol, Pyth ID, price, allowed staleness, allowed deviation, and token decimals.
Get Pyth Last Price
This function retrieves the last price of an asset from the Pyth network. It takes the asset ID and a flag indicating whether freshness is required. It returns the last price as a uint256 value.
Get Last Price
This function returns the last price of an asset. If the price is still fresh (within the allowed staleness), it returns the stored price. Otherwise, it queries the Pyth network for the last price.
Set Price
This function sets the price of an asset. If the asset has a Pyth ID, it checks the deviation between the proposed price and the price from the Pyth network.
Token To Usd
This function converts the specified amount of tokens to an equivalent USD value. It takes the token address and the token amount and returns the USD value as a uint256 value.
Usd To Token
This function converts the specified USD amount to an equivalent amount of tokens. It takes the token address and the USD amount and returns the token amount as a uint256 value.
Get Current Time
This function returns the current timestamp as a uint256 value.
Max Leverage
This function returns the maximum leverage allowed for the specified asset ID.
Get Valid Asset Ids
This function returns an array of valid asset IDs.
Last updated