StructPriceOracle
Inherits: IStructPriceOracle, Ownable
Author: Struct Finance
This contract uses Chainlink's price feed to fetch the latest price of the given assets
State Variables
assetsSources
Asset -> ChainlinkSourceAddress mapping
mapping(address => AggregatorV3Interface) private assetsSources;
Functions
constructor
constructor(address[] memory assets, AggregatorV3Interface[] memory sources);
Parameters
Name | Type | Description |
---|---|---|
assets | address[] | The addresses of the assets |
sources | AggregatorV3Interface[] | The address of the Chainlink aggregator of each asset |
setAssetSources
Used to set or replace sources for the assets
function setAssetSources(address[] calldata assets, AggregatorV3Interface[] calldata sources) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
assets | address[] | The addresses of the assets |
sources | AggregatorV3Interface[] | The address of the source of each asset |
_setAssetsSources
function _setAssetsSources(address[] memory assets, AggregatorV3Interface[] memory sources) internal;
getAssetPrice
Gets an asset price by address
function getAssetPrice(address asset) public view override returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
asset | address | The asset address |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The asset price in 18 decimals |
getAssetsPrices
Gets a list of prices from a list of assets addresses
function getAssetsPrices(address[] calldata assets) external view returns (uint256[] memory);
Parameters
Name | Type | Description |
---|---|---|
assets | address[] | The list of assets addresses |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256[] | prices The list of asset prices in 18 decimals |
getSourceOfAsset
Gets the address of the source for an asset address
function getSourceOfAsset(address asset) external view returns (address);
Parameters
Name | Type | Description |
---|---|---|
asset | address | The address of the asset |
Returns
Name | Type | Description |
---|---|---|
<none> | address | address The address of the source |
Events
AssetSourceUpdated
event AssetSourceUpdated(address indexed asset, address indexed source);