2020-05-29 16:45:37 +00:00
|
|
|
// SPDX-License-Identifier: agpl-3.0
|
2020-11-20 10:41:58 +00:00
|
|
|
pragma solidity ^0.6.12;
|
2020-05-29 16:45:37 +00:00
|
|
|
|
2020-08-20 10:44:51 +00:00
|
|
|
import {IPriceOracle} from '../../interfaces/IPriceOracle.sol';
|
2020-05-29 16:45:37 +00:00
|
|
|
|
|
|
|
contract PriceOracle is IPriceOracle {
|
2020-07-13 08:54:08 +00:00
|
|
|
mapping(address => uint256) prices;
|
|
|
|
uint256 ethPriceUsd;
|
|
|
|
|
|
|
|
event AssetPriceUpdated(address _asset, uint256 _price, uint256 timestamp);
|
|
|
|
event EthPriceUpdated(uint256 _price, uint256 timestamp);
|
|
|
|
|
|
|
|
function getAssetPrice(address _asset) external override view returns (uint256) {
|
|
|
|
return prices[_asset];
|
|
|
|
}
|
|
|
|
|
|
|
|
function setAssetPrice(address _asset, uint256 _price) external override {
|
|
|
|
prices[_asset] = _price;
|
|
|
|
emit AssetPriceUpdated(_asset, _price, block.timestamp);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getEthUsdPrice() external view returns (uint256) {
|
|
|
|
return ethPriceUsd;
|
|
|
|
}
|
|
|
|
|
|
|
|
function setEthUsdPrice(uint256 _price) external {
|
|
|
|
ethPriceUsd = _price;
|
|
|
|
emit EthPriceUpdated(_price, block.timestamp);
|
|
|
|
}
|
|
|
|
}
|