Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Price feed governable addition #545

Merged
merged 23 commits into from
Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions solidity/migrations/2_deploy_contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ const Deposit = artifacts.require("Deposit")
const VendingMachine = artifacts.require("VendingMachine")

// price feed
const BTCETHPriceFeed = artifacts.require("BTCETHPriceFeed")
const BTCUSDPriceFeed = artifacts.require("BTCUSDPriceFeed")
const ETHUSDPriceFeed = artifacts.require("ETHUSDPriceFeed")
const MockBTCETHPriceFeed = artifacts.require("BTCETHPriceFeedMock")
const prices = require("./prices")

const MockRelay = artifacts.require("MockRelay")
Expand Down Expand Up @@ -83,18 +81,13 @@ module.exports = (deployer, network, accounts) => {
let difficultyRelay
// price feeds
if (network !== "mainnet") {
// On mainnet, we use the MakerDAO-deployed price feeds.
// On mainnet, we use the MakerDAO-deployed price feed.
// See: https://github.com/makerdao/oracles-v2#live-mainnet-oracles
// Otherwise, we deploy our own mock price feeds, which are simpler
// to maintain.
await deployer.deploy(BTCUSDPriceFeed)
await deployer.deploy(ETHUSDPriceFeed)

const btcPriceFeed = await BTCUSDPriceFeed.deployed()
const ethPriceFeed = await ETHUSDPriceFeed.deployed()

await btcPriceFeed.setValue(web3.utils.toWei(prices.BTCUSD))
await ethPriceFeed.setValue(web3.utils.toWei(prices.ETHUSD))
await deployer.deploy(MockBTCETHPriceFeed)
const btcEthPriceFeed = await MockBTCETHPriceFeed.deployed()
await btcEthPriceFeed.setValue(prices.BTCETH)

// On mainnet, we use the Summa-provided relay; see
// https://github.com/summa-tx/relays . On testnet, we use a local mock.
Expand Down
21 changes: 5 additions & 16 deletions solidity/migrations/3_initialize.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const TBTCSystem = artifacts.require("TBTCSystem")

const BTCETHPriceFeed = artifacts.require("BTCETHPriceFeed")
const MockBTCUSDPriceFeed = artifacts.require("BTCUSDPriceFeed")
const MockETHUSDPriceFeed = artifacts.require("ETHUSDPriceFeed")
const MockBTCETHPriceFeed = artifacts.require("BTCETHPriceFeedMock")

const DepositFactory = artifacts.require("DepositFactory")
const Deposit = artifacts.require("Deposit")
Expand All @@ -11,11 +10,7 @@ const TBTCDepositToken = artifacts.require("TBTCDepositToken")
const FeeRebateToken = artifacts.require("FeeRebateToken")
const VendingMachine = artifacts.require("VendingMachine")

const {
BondedECDSAKeepVendorAddress,
BTCUSDPriceFeed,
ETHUSDPriceFeed,
} = require("./externals")
const {BondedECDSAKeepVendorAddress, BTCETHMedianizer} = require("./externals")

module.exports = async function(deployer, network) {
// Don't enact this setup during unit testing.
Expand Down Expand Up @@ -57,19 +52,13 @@ module.exports = async function(deployer, network) {
const btcEthPriceFeed = await BTCETHPriceFeed.deployed()
if (network === "mainnet") {
// Inject mainnet price feeds.
await btcEthPriceFeed.initialize(
tbtcSystem.address,
BTCUSDPriceFeed,
ETHUSDPriceFeed,
)
await btcEthPriceFeed.initialize(tbtcSystem.address, BTCETHMedianizer)
} else {
// Inject mock price feeds.
const mockBtcPriceFeed = await MockBTCUSDPriceFeed.deployed()
const mockEthPriceFeed = await MockETHUSDPriceFeed.deployed()
const mockBtcEthPriceFeed = await MockBTCETHPriceFeed.deployed()
await btcEthPriceFeed.initialize(
tbtcSystem.address,
mockBtcPriceFeed.address,
mockEthPriceFeed.address,
mockBtcEthPriceFeed.address,
)
}
}
6 changes: 2 additions & 4 deletions solidity/migrations/externals.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ const BondedECDSAKeepVendorAddress = "0xZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
// Medianized price feeds.
// These are deployed and maintained by Maker.
// See: https://github.com/makerdao/oracles-v2#live-mainnet-oracles
const BTCUSDPriceFeed = "0xe0F30cb149fAADC7247E953746Be9BbBB6B5751f"
const ETHUSDPriceFeed = "0x64de91f5a373cd4c28de3600cb34c7c6ce410c85"
const BTCETHMedianizer = "0xABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE"

module.exports = {
BondedECDSAKeepVendorAddress,
BTCUSDPriceFeed,
ETHUSDPriceFeed,
BTCETHMedianizer,
}
3 changes: 1 addition & 2 deletions solidity/migrations/prices.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"BTCUSD": "7152.55",
"ETHUSD": "142.28"
"BTCETH": "502709446162"
Shadowfiend marked this conversation as resolved.
Show resolved Hide resolved
}