forked from compound-finance/open-oracle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
saddle.config.js
158 lines (154 loc) · 5.29 KB
/
saddle.config.js
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
module.exports = {
// solc: "solc", // Solc command to run
// solc_args: [], // Extra solc args
build_dir: process.env['SADDLE_BUILD'] || ".build", // Directory to place built contracts
contracts: process.env['SADDLE_CONTRACTS'] || "contracts/*.sol contracts/**/*.sol tests/contracts/*.sol", // Glob to match contract files
tests: ['**/tests/*Test.js'], // Glob to match test files
networks: { // Define configuration for each network
ropsten: {
providers: [
{env: "PROVIDER"},
{file: "~/.ethereum/ropsten-url"}, // Load from given file with contents as the URL (e.g. https://infura.io/api-key)
],
web3: {
gas: [
{env: "GAS"},
{default: "8000000"}
],
gas_price: [
{env: "GAS_PRICE"},
{default: "12000000000"}
],
options: {
transactionConfirmationBlocks: 1,
transactionBlockTimeout: 5
}
},
accounts: [
{env: "ACCOUNT"},
{file: "~/.ethereum/ropsten"} // Load from given file with contents as the private key (e.g. 0x...)
]
},
development: {
providers: [ // How to load provider (processed in order)
{ env: "PROVIDER" }, // Try to load Http provider from `PROVIDER` env variable (e.g. env PROVIDER=http://...)
{ http: "http://127.0.0.1:8545" } // Fallback to localhost provider
],
web3: { // Web3 options for immediate confirmation in development mode
gas: [
{ env: "GAS" },
{ default: "4600000" }
],
gas_price: [
{ env: "GAS_PRICE" },
{ default: "12000000000" }
],
options: {
transactionConfirmationBlocks: 1,
transactionBlockTimeout: 5
}
},
accounts: [ // How to load default account for transactions
{ env: "ACCOUNT" }, // Load from `ACCOUNT` env variable (e.g. env ACCOUNT=0x...)
{ unlocked: 0 } // Else, try to grab first "unlocked" account from provider
]
},
test: {
providers: [
{ env: "PROVIDER" },
{
ganache: {
gasLimit: 80000000
}
}, // In test mode, connect to a new ganache provider. Any options will be passed to ganache
],
web3: {
gas: [
{ env: "GAS" },
{ default: "8000000" }
],
gas_price: [
{ env: "GAS_PRICE" },
{ default: "12000000000" }
],
options: {
transactionConfirmationBlocks: 1,
transactionBlockTimeout: 5
}
},
accounts: [
{ env: "ACCOUNT" },
{ unlocked: 0 }
]
},
rinkeby: {
providers: [
{ env: "PROVIDER" },
{ file: "~/.ethereum/rinkeby-url" }, // Load from given file with contents as the URL (e.g. https://infura.io/api-key)
{ http: "https://rinkeby-eth.compound.finance" }
],
web3: {
gas: [
{ env: "GAS" },
{ default: "4600000" }
],
gas_price: [
{ env: "GAS_PRICE" },
{ default: "12000000000" }
],
options: {
transactionConfirmationBlocks: 1,
transactionBlockTimeout: 5
}
},
accounts: [
{ env: "ACCOUNT" },
{ file: "~/.ethereum/rinkeby" } // Load from given file with contents as the private key (e.g. 0x...)
]
},
mainnet: {
providers: [
{ env: "PROVIDER" },
{ file: "~/.ethereum/mainnet-url" }, // Load from given file with contents as the URL (e.g. https://infura.io/api-key)
{ http: "https://mainnet-eth.compound.finance" }
],
web3: {
gas: [
{ env: "GAS" },
{ default: "4600000" }
],
gas_price: [
{ env: "GAS_PRICE" },
{ default: "6000000000" }
],
options: {
transactionConfirmationBlocks: 1,
transactionBlockTimeout: 5
}
},
accounts: [
{ env: "ACCOUNT" },
{ file: "~/.ethereum/mainnet" } // Load from given file with contents as the private key (e.g. 0x...)
]
}
},
get_network_file: (network) => {
return null;
},
read_network_file: (network) => {
const fs = require('fs');
const path = require('path');
const util = require('util');
const networkFile = path.join(process.cwd(), 'compound-config', 'networks', `${network}.json`);
return util.promisify(fs.readFile)(networkFile).then((json) => {
const contracts = JSON.parse(json)['Contracts'] || {};
return Object.fromEntries(Object.entries(contracts).map(([contract, address]) => {
const mapper = {
PriceFeed: 'UniswapAnchoredView',
PriceData: 'OpenOraclePriceData'
};
return [mapper[contract] || contract, address];
}));
});
}
};