Skip to content

Commit fbdcf20

Browse files
committed
deeploy: ganache
1 parent 9b77251 commit fbdcf20

File tree

8 files changed

+192
-57
lines changed

8 files changed

+192
-57
lines changed

migrations/2_deploy_contracts.js

Lines changed: 0 additions & 41 deletions
This file was deleted.

migrations/2_deploy_oracle.js

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
const MockAggregator = artifacts.require('MockChainlinkAggregatorV3')
2+
const ChainlinkOracle = artifacts.require('ChainlinkOracle')
3+
const MockUniswapAnchoredView = artifacts.require('MockUniswapAnchoredView')
4+
const CompoundOracle = artifacts.require('CompoundOpenOracle')
5+
const MockUniswapV2Pair = artifacts.require('MockUniswapV2Pair')
6+
const UniswapOracle = artifacts.require('OurUniswapV2SpotOracle')
7+
const MockCompositeOracle = artifacts.require('MockCompositeOracle')
8+
const CompositeOracle = artifacts.require('CompositeOracle')
9+
10+
module.exports = async function(deployer, network) {
11+
12+
const chainlinkAddresses = {
13+
'mainnet' : '0x',
14+
'ropsten' : '0x30B5068156688f818cEa0874B580206dFe081a03',
15+
'rinkeby' : '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e',
16+
'kovan' : '0x9326BFA02ADD2366b30bacB125260Af641031331'
17+
}
18+
const compoundAddresses = {
19+
'mainnet' : '0x',
20+
'ropsten' : '0x30B5068156688f818cEa0874B580206dFe081a03',
21+
'rinkeby' : '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e',
22+
'kovan' : '0x9326BFA02ADD2366b30bacB125260Af641031331'
23+
}
24+
const uniswapAddresses = {
25+
'mainnet' : '0x',
26+
'ropsten' : '0x30B5068156688f818cEa0874B580206dFe081a03',
27+
'rinkeby' : '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e',
28+
'kovan' : '0x9326BFA02ADD2366b30bacB125260Af641031331'
29+
}
30+
31+
const shift = '18'
32+
const chainlinkShift = '8'
33+
const compoundShift = '6'
34+
const uniswapShift = '18'
35+
36+
if (network === 'development') {
37+
const chainlinkPrice = '38598000000'
38+
const compoundPrice = '414174999'
39+
const uniswapReserve0 = '646310144553926227215994'
40+
const uniswapReserve1 = '254384028636585'
41+
const uniswapReverseOrder = false
42+
const uniswapScalePriceBy = '1000000000000000000000000000000'
43+
44+
await deployer.deploy(MockAggregator)
45+
aggregator = await MockAggregator.deployed()
46+
await aggregator.set(chainlinkPrice)
47+
await deployer.deploy(ChainlinkOracle, aggregator.address, chainlinkShift)
48+
chainlink = await ChainlinkOracle.deployed()
49+
50+
await deployer.deploy(MockUniswapAnchoredView)
51+
anchoredView = await MockUniswapAnchoredView.deployed()
52+
await anchoredView.set(compoundPrice)
53+
await deployer.deploy(CompoundOracle, anchoredView.address, compoundShift)
54+
compound = await CompoundOracle.deployed()
55+
56+
await deployer.deploy(MockUniswapV2Pair)
57+
pair = await MockUniswapV2Pair.deployed()
58+
await pair.set(uniswapReserve0, uniswapReserve1);
59+
await deployer.deploy(UniswapOracle, pair.address, uniswapReverseOrder, uniswapShift, uniswapScalePriceBy)
60+
uniswap = await UniswapOracle.deployed()
61+
62+
await deployer.deploy(MockCompositeOracle, [chainlink.address, compound.address, uniswap.address], shift)
63+
oracle = await MockCompositeOracle.deployed()
64+
}
65+
else {
66+
await deployer.deploy(ChainlinkOracle, chainlinkAddresses[network], chainlinkShift)
67+
chainlink = await ChainlinkOracle.deployed()
68+
69+
await deployer.deploy(CompoundOracle, compoundAddresses[network], compoundShift)
70+
compound = await CompoundOracle.deployed()
71+
72+
await deployer.deploy(UniswapOracle, uniswapAddresses[network], uniswapReverseOrder, uniswapShift, uniswapScalePriceBy)
73+
uniswap = await UniswapOracle.deployed()
74+
75+
await deployer.deploy(CompositeOracle, [chainlink.address, compound.address, uniswap.address], shift)
76+
oracle = await CompositeOracle.deployed()
77+
}
78+
}

migrations/3_deploy_usmfum.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const USM = artifacts.require("USM");
2+
const WETH9 = artifacts.require("WETH9");
3+
const Proxy = artifacts.require("Proxy");
4+
const MockCompositeOracle = artifacts.require('MockCompositeOracle')
5+
const CompositeOracle = artifacts.require('CompositeOracle')
6+
7+
const wethAddresses = {
8+
'mainnet' : '0x',
9+
'ropsten' : '0x',
10+
'rinkeby' : '0x',
11+
'kovan' : '0x'
12+
}
13+
14+
module.exports = async function(deployer, network) {
15+
let oracle
16+
let weth
17+
18+
if (network === 'development') {
19+
oracle = await MockCompositeOracle.deployed()
20+
21+
await deployer.deploy(WETH9);
22+
weth = await WETH9.deployed()
23+
}
24+
else {
25+
oracle = await CompositeOracle.deployed()
26+
weth = await WETH9.at(wethAddresses[network])
27+
}
28+
29+
await deployer.deploy(USM, oracle.address, weth.address);
30+
}

migrations/4_deploy_proxy.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const USM = artifacts.require("USM");
2+
const WETH9 = artifacts.require("USM");
3+
const Proxy = artifacts.require("Proxy");
4+
5+
const wethAddresses = {
6+
'mainnet' : '0x',
7+
'ropsten' : '0x',
8+
'rinkeby' : '0x',
9+
'kovan' : '0x'
10+
}
11+
12+
module.exports = async function(deployer, network) {
13+
let weth
14+
15+
if (network === 'development') {
16+
weth = await WETH9.deployed()
17+
}
18+
else {
19+
weth = await WETH9.at(wethAddresses[network])
20+
}
21+
22+
const usm = await USM.deployed()
23+
await deployer.deploy(Proxy, usm.address, weth.address)
24+
}

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
"test": "buidler test test/*.js",
1212
"coverage": "buidler coverage --network coverage --temp build --testfiles 'test/*.js'",
1313
"lint:js": "prettier ./test/**/*.js --write",
14-
"lint:sol": "solhint -f table contracts/**/*.sol"
14+
"lint:sol": "solhint -f table contracts/**/*.sol",
15+
"ganache": "./scripts/ganache.sh",
16+
"deploy:ganache": "yarn ganache && truffle migrate",
17+
"mainnet-ganache": "./scripts/mainnet-ganache.sh"
1518
},
1619
"author": "Alex Roan",
1720
"license": "GPL-3.0-or-later",

scripts/ganache.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env sh
2+
3+
# move to subfolder
4+
# cd scripts
5+
6+
# create db directory
7+
# [ ! -d "./db_ganache" ] && mkdir db_ganache
8+
9+
# start ganache
10+
npx ganache-cli \
11+
--mnemonic "all your mnemonic are belong to us seed me up scotty over" \
12+
--defaultBalanceEther 1000000 \
13+
--gasLimit 0xfffffffffff \
14+
--gasPrice 0 \
15+
--port 8545 \
16+
--networkId 5777 \
17+
--host 0.0.0.0 &

scripts/mainnet-ganache.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env sh
2+
3+
# move to subfolder
4+
# cd scripts
5+
6+
# create db directory
7+
# [ ! -d "./db_ganache" ] && mkdir db_ganache
8+
9+
# start ganache
10+
npx ganache-cli \
11+
--mnemonic "how are you gentlemen all your mnemonic are belong to us" \
12+
--defaultBalanceEther 1000000 \
13+
--gasLimit 0xfffffffffff \
14+
--gasPrice 0 \
15+
--port 8545 \
16+
--networkId 1 \
17+
--host 0.0.0.0 \
18+
--fork https://mainnet.infura.io/v3/`cat .infuraKey` &

truffle-config.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,6 @@ module.exports = {
5959
gas: 0x6691b7
6060
},
6161

62-
63-
// Another network with more advanced options...
64-
// advanced: {
65-
// port: 8777, // Custom port
66-
// network_id: 1342, // Custom network
67-
// gas: 8500000, // Gas sent with each transaction (default: ~6700000)
68-
// gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei)
69-
// from: <address>, // Account to send txs from (default: accounts[0])
70-
// websockets: true // Enable EventEmitter interface for web3 (default: false)
71-
// },
72-
73-
// Useful for deploying to a public network.
74-
// NB: It's important to wrap the provider as a function.
75-
7662
kovan: {
7763
provider: () => getProvider("kovan"),
7864
network_id: 42, // Kovan's id
@@ -110,6 +96,26 @@ module.exports = {
11096
skipDryRun: false // Skip dry run before migrations? (default: false for public nets )
11197
},
11298

99+
"mainnet-ganache": {
100+
host: "127.0.0.1", // Localhost (default: none)
101+
port: 8545, // Standard Ethereum port (default: none)
102+
network_id: 1, // Any network (default: none)
103+
gas: 10000000,
104+
confirmations: 0, // # of confs to wait between deployments. (default: 0)
105+
timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50)
106+
gasPrice: 10000000000, // 10 gwei
107+
skipDryRun: true // Skip dry run before migrations? (default: false for public nets )
108+
},
109+
110+
mainnet: {
111+
provider: () => getProvider("mainnet"),
112+
network_id: 1, // Mainnet's id
113+
confirmations: 0, // # of confs to wait between deployments. (default: 0)
114+
timeoutBlocks: 1000, // # of blocks before a deployment times out (minimum/default: 50)
115+
gasPrice: 90000000000, // 90 gwei
116+
skipDryRun: false // Skip dry run before migrations? (default: false for public nets )
117+
},
118+
113119
// Useful for private networks
114120
// private: {
115121
// provider: () => new HDWalletProvider(mnemonic, `https://network.io`),
@@ -127,7 +133,7 @@ module.exports = {
127133
// Configure your compilers
128134
compilers: {
129135
solc: {
130-
version: "0.6.7",
136+
version: "0.6.6",
131137
settings: { // See the solidity docs for advice about optimization and evmVersion
132138
optimizer: {
133139
enabled: true,

0 commit comments

Comments
 (0)