-
Notifications
You must be signed in to change notification settings - Fork 1
Oracle
The price oracle implements the PriceOracleInterface, and provides an interface for other contracts to access external data such as price feed for given assets.
The getPrice functions returns price feed for a given asset.
function getPrice(address addr) external view returns (uint)
-
addr
: the account of an asset e.g. fToken -
return
: price feed for given asset
Our simple price oracle implementation implements the PriceOracleInterface, PriceFeederRole and PriceOracleConfig.
In our getPrice function implementation, we provided extra level of security to resist potential attacks.
The smart contract will find the median price amongst prices provided by all active prices feeder.
The change between two prices are capped by the oracleDeltaLastLimit
. The change between this price and the snapshot price which is taken every oracleDeltaSnapshotTime
are further capped by the oracleDeltaSnapshotLimit
.
Still, any compromised oracle is able to influence the price but to a very limited degree with both median price taking and price capping.
function setOracleDeltaLastLimit(uint limit) public onlyOwner
function setOracleDeltaSnapshotLimit(uint limit) public onlyOwner
function setOracleDeltaSnapshotTime(uint time) public onlyOwner
function feedPrice(address key, uint price) external onlyPriceFeeder
function addPriceFeeder(address account) public onlyOwner
function removePriceFeeder(address account) public onlyOwner