From d4320ae360285f45724dde04e3aaa19e5af6f8e9 Mon Sep 17 00:00:00 2001 From: mingda Date: Tue, 8 Sep 2020 20:17:18 +0800 Subject: [PATCH] oracles --- ...l => ChainlinkEthUSDCPriceOracleProxy.sol} | 0 .../ChainlinkEthUSDTPriceOracleProxy.sol | 25 +++++++++++++++ .../ChainlinkYFIUSDCPriceOracleProxy.sol | 32 +++++++++++++++++++ 3 files changed, 57 insertions(+) rename contracts/helper/{ChainlinkEthPriceOracleProxy.sol => ChainlinkEthUSDCPriceOracleProxy.sol} (100%) create mode 100644 contracts/helper/ChainlinkEthUSDTPriceOracleProxy.sol create mode 100644 contracts/helper/ChainlinkYFIUSDCPriceOracleProxy.sol diff --git a/contracts/helper/ChainlinkEthPriceOracleProxy.sol b/contracts/helper/ChainlinkEthUSDCPriceOracleProxy.sol similarity index 100% rename from contracts/helper/ChainlinkEthPriceOracleProxy.sol rename to contracts/helper/ChainlinkEthUSDCPriceOracleProxy.sol diff --git a/contracts/helper/ChainlinkEthUSDTPriceOracleProxy.sol b/contracts/helper/ChainlinkEthUSDTPriceOracleProxy.sol new file mode 100644 index 0000000..6d27f7a --- /dev/null +++ b/contracts/helper/ChainlinkEthUSDTPriceOracleProxy.sol @@ -0,0 +1,25 @@ +/* + + Copyright 2020 DODO ZOO. + SPDX-License-Identifier: Apache-2.0 + +*/ + +pragma solidity 0.6.9; +pragma experimental ABIEncoderV2; + + +interface IChainlink { + function latestAnswer() external view returns (uint256); +} + + +// for WETH-USDT(decimals=6) price convert + +contract ChainlinkETHUSDTPriceOracleProxy { + address public chainlink = 0xEe9F2375b4bdF6387aa8265dD4FB8F16512A1d46; + + function getPrice() external view returns (uint256) { + return 10**24 / IChainlink(chainlink).latestAnswer(); + } +} diff --git a/contracts/helper/ChainlinkYFIUSDCPriceOracleProxy.sol b/contracts/helper/ChainlinkYFIUSDCPriceOracleProxy.sol new file mode 100644 index 0000000..b2d071d --- /dev/null +++ b/contracts/helper/ChainlinkYFIUSDCPriceOracleProxy.sol @@ -0,0 +1,32 @@ +/* + + Copyright 2020 DODO ZOO. + SPDX-License-Identifier: Apache-2.0 + +*/ + +pragma solidity 0.6.9; +pragma experimental ABIEncoderV2; + +import {SafeMath} from "../lib/SafeMath.sol"; + + +interface IChainlink { + function latestAnswer() external view returns (uint256); +} + + +// for YFI-USDC(decimals=6) price convert + +contract ChainlinkYFIUSDCPriceOracleProxy { + using SafeMath for uint256; + + address public yfiEth = 0x7c5d4F8345e66f68099581Db340cd65B078C41f4; + address public EthUsd = 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419; + + function getPrice() external view returns (uint256) { + uint256 yfiEthPrice = IChainlink(yfiEth).latestAnswer(); + uint256 EthUsdPrice = IChainlink(EthUsd).latestAnswer(); + return yfiEthPrice.mul(EthUsdPrice).div(10**20); + } +}