forked from bokkypoobah/FxxxLandRush
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MakerDAOPriceFeedAdaptor.sol
45 lines (38 loc) · 1.77 KB
/
MakerDAOPriceFeedAdaptor.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
pragma solidity ^0.4.25;
// ----------------------------------------------------------------------------
// Adaptor to convert MakerDAO's "pip" price feed into BokkyPooBah's Pricefeed
//
// Used to convert MakerDAO ETH/USD pricefeed on the Ethereum mainnet at
// https://etherscan.io/address/0x729D19f657BD0614b4985Cf1D82531c67569197B
// to be a slightly more useable form
//
// Deployed to: 0xF31AA1dFbEd873Ab957896a0204a016F5E123e02
//
// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018. The MIT Licence.
// ----------------------------------------------------------------------------
import "PriceFeedInterface.sol";
// ----------------------------------------------------------------------------
// See https://github.com/bokkypoobah/MakerDAOSaiContractAudit/tree/master/audit#pip-and-pep-price-feeds
// ----------------------------------------------------------------------------
contract MakerDAOPriceFeedInterface {
function peek() public view returns (bytes32 _value, bool _hasValue);
}
// ----------------------------------------------------------------------------
// Pricefeed with interface compatible with MakerDAO's "pip" PriceFeed
// ----------------------------------------------------------------------------
contract MakerDAOPriceFeedAdaptor is PriceFeedInterface {
string private _name;
MakerDAOPriceFeedInterface public makerDAOPriceFeed;
constructor(string name, address _makerDAOPriceFeed) public {
_name = name;
makerDAOPriceFeed = MakerDAOPriceFeedInterface(_makerDAOPriceFeed);
}
function name() public view returns (string) {
return _name;
}
function getRate() public view returns (uint _rate, bool _live) {
bytes32 value;
(value, _live) = makerDAOPriceFeed.peek();
_rate = uint(value);
}
}