-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path04_01_baoETH.js
300 lines (259 loc) · 11.7 KB
/
04_01_baoETH.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
const SAFE = '0xFC69e0a5823E2AfCBEb8a35d33588360F1496a00'
const MINT_LIMIT = "1000000000000000000000"
const BALLAST_SUPPLY = "200000000000000000000"
module.exports = async ({getNamedAccounts, deployments, ethers}) => {
const { deployer } = await getNamedAccounts()
const p = ethers.getDefaultProvider()
console.log("balance", ethers.utils.formatEther(await p.getBalance(deployer)))
let tx
// comptroller and unitroller
const comptrollerDeploy = await deployments.deploy('comptroller-baoETH', {
from: deployer,
contract: 'Comptroller',
args: [],
log: true,
})
let comptroller = new ethers.Contract(comptrollerDeploy.address, comptrollerDeploy.abi, await ethers.getSigner(deployer))
const unitrollerDeploy = await deployments.deploy('unitroller-baoETH', {
from: deployer,
contract: 'contracts/markets/Comptroller/Unitroller.sol:Unitroller',
args: [],
log: true,
})
const unitroller = new ethers.Contract(unitrollerDeploy.address, unitrollerDeploy.abi, await ethers.getSigner(deployer))
//console.log("Becoming the unitroller as the comptroller...")
//tx = await unitroller._setPendingImplementation(comptroller.address)
//await tx.wait()
//tx = await comptroller._become(unitroller.address)
//await tx.wait()
//console.log("... became!")
//comptroller = new ethers.Contract(unitrollerDeploy.address, comptrollerDeploy.abi, await ethers.getSigner(deployer))
const oracleDeploy = await deployments.deploy('oracle-baoETH', {
from: deployer,
contract: 'contracts/InverseFinance/Oracle.sol:Oracle',
args: [],
log: true,
})
const oracle = new ethers.Contract(oracleDeploy.address, oracleDeploy.abi, await ethers.getSigner(deployer))
// baoETH
const baoETHDeploy = await deployments.deploy('baoETH', {
from: deployer,
contract: 'contracts/markets/ERC20.sol:ERC20',
args: ['Bao ETH', 'baoETH', 18],
log: true,
})
const baoETH = new ethers.Contract(baoETHDeploy.address, baoETHDeploy.abi, await ethers.getSigner(deployer))
//console.log("Setting baoETH's admin to be the DAO treasury...")
//tx = await baoETH.setPendingOperator(SAFE)
//await tx.wait()
//console.log("... set! Now the treasury must call claimOperator().")
const jumpRateModelDeploy = await deployments.deploy('JumpRateModelV2', {
from: deployer,
contract: 'JumpRateModelV2',
args: [
"0", //uint baseRatePerYear
"49999999998268800", //uint multiplierPerYear
"1089999999998841600", //uint jumpMultiplierPerYear
"800000000000000000", //uint kink_
],
log: true,
})
const jumpRateModel = new ethers.Contract(jumpRateModelDeploy.address, jumpRateModelDeploy.abi, await ethers.getSigner(deployer))
const whitePaperModelDeploy = await deployments.deploy('WhitePaperInterestRateModel', {
from: deployer,
contract: 'WhitePaperInterestRateModel',
args: [
"19999999999728000", //uint baseRatePerYear
"99999999998640000", //uint multiplierPerYear
],
log: true,
})
const whitePaperModel = new ethers.Contract(whitePaperModelDeploy.address, whitePaperModelDeploy.abi, await ethers.getSigner(deployer))
// bao deposited baoETH - bdbaoETH
const bdbaoETHDeploy = await deployments.deploy('bdbaoETH', {
from: deployer,
contract: 'CErc20Delegator',
args: [
baoETHDeploy.address, // underlying
unitrollerDeploy.address, // unitroller
jumpRateModelDeploy.address, // interest rate model (JumpRateModelV2)
'200000000000000000', // initial exchange rate mantissa
'bao deposited baoETH', // name
'bdbaoETH', // symbol
'8', // decimals
'0xDb3401beF8f66E7f6CD95984026c26a4F47eEe84', // delegate implementation
0, // become implementation data
],
log: true,
})
const bdbaoETH = new ethers.Contract(bdbaoETHDeploy.address, bdbaoETHDeploy.abi, await ethers.getSigner(deployer))
const bdEtherDeploy = await deployments.deploy('bdETH', {
from: deployer,
contract: 'CEther',
args: [
unitrollerDeploy.address, // unitroller
whitePaperModelDeploy.address, // interest rate model (WhitePaperInterestRateModel)
'200000000000000000', // initial exchange rate mantissa
'bao deposited Ether', // name
'bdETH', // symbol
'8', // decimals
],
log: true,
})
const bdEther = new ethers.Contract(bdEtherDeploy.address, bdEtherDeploy.abi, await ethers.getSigner(deployer))
const bdbETHDeploy = await deployments.deploy('bdbETH', {
from: deployer,
contract: 'CErc20Delegator',
args: [
'0xa1e3F062CE5825c1e19207cd93CEFdaD82A8A631', // underlying
unitrollerDeploy.address, // unitroller
whitePaperModelDeploy.address, // interest rate model (WhitePaperInterestRateModel)
'200000000000000000', // initial exchange rate mantissa
'bao deposited bETH', // name
'bdbETH', // symbol
'8', // decimals
'0xDb3401beF8f66E7f6CD95984026c26a4F47eEe84', // delegate implementation
0, // become implementation data
],
log: true,
})
const bdbETH = new ethers.Contract(bdbETHDeploy.address, bdbETHDeploy.abi, await ethers.getSigner(deployer))
const bdbSTBLDeploy = await deployments.deploy('bdbSTBL', {
from: deployer,
contract: 'CErc20Delegator',
args: [
'0x5ee08f40b637417bcC9d2C51B62F4820ec9cF5D8', // underlying
unitrollerDeploy.address, // unitroller
jumpRateModelDeploy.address, // interest rate model (WhitePaperInterestRateModel)
'200000000000000000', // initial exchange rate mantissa
'bao deposited bSTBL', // name
'bdbSTBL', // symbol
'8', // decimals
'0xDb3401beF8f66E7f6CD95984026c26a4F47eEe84', // delegate implementation
0, // become implementation data
],
log: true,
})
const bdbSTBL = new ethers.Contract(bdbSTBLDeploy.address, bdbSTBLDeploy.abi, await ethers.getSigner(deployer))
//console.log("Setting up price oracle...")
//tx = await oracle.setFeed(bdbaoETH.address, "0x5f4ec3df9cbd43714fe2740f5e3616155c5b8419", "18");
//await tx.wait();
//tx = await oracle.setFeed(bdEther.address, "0x5f4ec3df9cbd43714fe2740f5e3616155c5b8419", "18");
//await tx.wait();
//tx = await oracle.setFeed(bdbSTBL.address, "0x4626CEB86aBF6B239e3306382Cca44e5B7113160", "18");
//await tx.wait();
//console.log("Setting up baoETH market with collateral of [ETH, bETH, bSTBL]...")
//tx = await comptroller._setPriceOracle(oracle.address)
//await tx.wait()
//tx = await comptroller._setCloseFactor("500000000000000000")
//await tx.wait()
//tx = await comptroller._setLiquidationIncentive("1100000000000000000")
//await tx.wait()
//tx = await comptroller._supportMarket(bdbaoETH.address)
//await tx.wait()
//tx = await comptroller._supportMarket(bdEther.address)
//await tx.wait()
//tx = await comptroller._supportMarket(bdbETH.address)
//await tx.wait()
//tx = await comptroller._supportMarket(bdbSTBL.address)
//await tx.wait()
//tx = await comptroller._setCollateralFactor(bdbaoETH.address, "250000000000000000")
//await tx.wait()
//tx = await comptroller._setCollateralFactor(bdEther.address, "900000000000000000")
//await tx.wait()
//tx = await comptroller._setCollateralFactor(bdbETH.address, "900000000000000000")
//await tx.wait()
//tx = await comptroller._setCollateralFactor(bdbSTBL.address, "750000000000000000")
//await tx.wait()
//tx = await comptroller._setIMFFactor(bdbaoETH.address, "40000000000000000")
//await tx.wait()
//tx = await comptroller._setIMFFactor(bdEther.address, "40000000000000000")
//await tx.wait()
//tx = await comptroller._setIMFFactor(bdbETH.address, "40000000000000000")
//await tx.wait()
//tx = await comptroller._setIMFFactor(bdbSTBL.address, "40000000000000000")
//await tx.wait()
//tx = await comptroller._setMarketBorrowCaps([bdbaoETH.address], [MINT_LIMIT])
//await tx.wait()
//tx = await comptroller._setBorrowRestriction([bdbaoETH.address], [false])
//await tx.wait()
//console.log("... supported!")
//console.log("Setting unitroller admin...")
//tx = await unitroller._setPendingAdmin(SAFE)
//await tx.wait()
//console.log("... set!")
//console.log("Setting reserve factors...")
//tx = await bdbaoETH._setReserveFactor("500000000000000000")
//await tx.wait()
//tx = await bdEther._setReserveFactor("500000000000000000")
//await tx.wait()
//tx = await bdbETH._setReserveFactor("500000000000000000")
//await tx.wait()
//tx = await bdbSTBL._setReserveFactor("500000000000000000")
//await tx.wait()
//console.log("... set!")
//console.log("Setting the bdTokens' admin to be the DAO treasury...")
//tx = await bdbaoETH._setPendingAdmin(SAFE)
//await tx.wait()
//tx = await bdEther._setPendingAdmin(SAFE)
//await tx.wait()
//tx = await bdbETH._setPendingAdmin(SAFE)
//await tx.wait()
//tx = await bdbSTBL._setPendingAdmin(SAFE)
//await tx.wait()
//console.log("... set! Now the treasury must call _acceptAdmin().")
const fedDeploy = await deployments.deploy('Fed-bdbaoETH', {
from: deployer,
contract: 'contracts/markets/Fed2.sol:Fed',
args: [bdbaoETHDeploy.address, "0x0000000000000000000000000000000000000000"],
log: true,
})
const fed = new ethers.Contract(fedDeploy.address, fedDeploy.abi, await ethers.getSigner(deployer))
//console.log("Adding the fed as a minter...")
//tx = await baoETH.addMinter(fedDeploy.address)
//await tx.wait()
//console.log("... added!")
//console.log("Expanding the fed")
//tx = await fed.expansion(MINT_LIMIT)
//await tx.wait()
//console.log("... expanded!")
console.log("Accruing interest...")
tx = await bdbaoETH.accrueInterest()
await tx.wait()
tx = await bdEther.accrueInterest()
await tx.wait()
console.log("... accrued!")
console.log("Setting fed admin...")
tx = await fed.changeChair(SAFE)
await tx.wait()
tx = await fed.changeGov(SAFE)
await tx.wait()
console.log("... set!")
const ballastDeploy = await deployments.deploy('Ballast-baoETH', {
from: deployer,
contract: 'Stabilizer',
args: [
baoETHDeploy.address, // synthetic
'0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', // non-synth
100, // buy fee (1%)
100, // sell fee (1%)
BALLAST_SUPPLY, // supply cap
],
log: true,
})
console.table([
{ name: 'comptroller', address: comptrollerDeploy .address },
{ name: 'unitroller' , address: unitrollerDeploy .address },
{ name: 'oracle' , address: oracleDeploy .address },
{ name: 'baoETH' , address: baoETHDeploy .address },
{ name: 'fed' , address: fedDeploy .address },
{ name: 'ballast' , address: ballastDeploy .address },
{ name: 'bdbaoETH' , address: bdbaoETHDeploy .address },
{ name: 'bdEther' , address: bdEtherDeploy .address },
{ name: 'bdbETH' , address: bdbETHDeploy .address },
{ name: 'bdbSTBL' , address: bdbSTBLDeploy .address },
])
console.log("balance", await p.getBalance(deployer))
}
module.exports.tags = ['Phase4', 'baoETH']
module.exports.dependencies = []