@gooddollar/goodprotocol 1.0.5 → 1.0.6-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gooddollar/goodprotocol",
3
- "version": "1.0.5",
3
+ "version": "1.0.6-beta.0",
4
4
  "description": "GoodDollar Protocol",
5
5
  "scripts": {
6
6
  "build": "scripts/build.sh deploy",
@@ -16,7 +16,8 @@
16
16
  "runNode": "hardhat node &",
17
17
  "testDAOUpgrade": "yarn runNode && yarn compile && yarn deployOldDAO --network develop-mainnet && yarn daoUpgrade --network develop-mainnet",
18
18
  "testDAOUpgradeFuse": "yarn runNode && yarn compile && yarn deployOldDAO --network develop && yarn daoUpgrade --network develop",
19
- "deployTest": "yarn runNode && yarn compile && hardhat run scripts/test/singleOldDaoDeploy.ts --network dapptest && yarn daoUpgrade --network dapptest && yarn daoUpgrade --network dapptest-mainnet && hardhat run scripts/test/simulateInterest.ts --network dapptest"
19
+ "deployTestOld": "yarn runNode && yarn compile && hardhat run scripts/test/singleOldDaoDeploy.ts --network dapptest && yarn daoUpgrade --network dapptest && yarn daoUpgrade --network dapptest-mainnet && hardhat run scripts/test/simulateInterest.ts --network dapptest",
20
+ "deployTest": "yarn runNode && yarn compile && hardhat run scripts/deployFullDAO.ts --network dapptest && hardhat run scripts/deployFullDAO.ts --network dapptest-mainnet && hardhat run scripts/test/simulateInterest.ts --network dapptest"
20
21
  },
21
22
  "files": [
22
23
  "artifacts/contracts",
@@ -179,12 +179,15 @@ export const createDAO = async () => {
179
179
  Controller: controller,
180
180
  GoodDollar: gd,
181
181
  Identity: Identity.address,
182
- FeeFormula: FeeFormula.address
182
+ FeeFormula: FeeFormula.address,
183
+ BancorFormula: BancorFormula.address
183
184
  };
184
185
 
185
186
  if (isMainnet) {
186
187
  mainnet = await deployMainnet(Avatar, Identity);
187
- Object.entries(mainnet).forEach(([k, v]) => (release[k] = v.address));
188
+ Object.entries(mainnet)
189
+ .filter(([k, v]) => v)
190
+ .forEach(([k, v]) => (release[k] = v.address));
188
191
  }
189
192
 
190
193
  let sidechain: { [key: string]: any } = {};
@@ -209,24 +212,26 @@ export const createDAO = async () => {
209
212
  release = { ...release, ...bridgeRelease };
210
213
  await releaser(release, network.name);
211
214
 
212
- await pressAnyKey();
215
+ // await pressAnyKey();
213
216
  // deploy v2 mainnet/sidechain contracts, returns their addresses
214
- const v2 = await deployV2(network.name, false, {
217
+ const olddao = {
215
218
  FirstClaimPool: release.FirstClaimPool,
216
219
  BancorFormula: release.BancorFormula,
217
220
  Avatar: release.Avatar,
218
221
  Controller: release.Controller,
219
- DAIUsdOracle: ethers.constants.AddressZero,
220
- COMPUsdOracle: ethers.constants.AddressZero,
221
- USDCUsdOracle: ethers.constants.AddressZero,
222
- AAVEUsdOracle: ethers.constants.AddressZero,
222
+ DAIUsdOracle: release.DAIUsdOracle || ethers.constants.AddressZero,
223
+ COMPUsdOracle: release.COMPUsdOracle || ethers.constants.AddressZero,
224
+ USDCUsdOracle: release.USDCUsdOracle || ethers.constants.AddressZero,
225
+ AAVEUsdOracle: release.AAVEUsdOracle || ethers.constants.AddressZero,
223
226
  AaveLendingPool: ethers.constants.AddressZero,
224
227
  AaveIncentiveController: ethers.constants.AddressZero,
225
- GasPriceOracle: ethers.constants.AddressZero,
228
+ GasPriceOracle: release.GasPriceOracle || ethers.constants.AddressZero,
226
229
  cDAI: release.cDAI || ethers.constants.AddressZero,
227
230
  DAI: release.DAI || ethers.constants.AddressZero,
228
231
  COMP: release.COMP || ethers.constants.AddressZero,
229
232
  USDC: ethers.constants.AddressZero,
233
+ DAIEthOracle: release.DAIEthOracle || ethers.constants.AddressZero,
234
+ ETHUsdOracle: release.ETHUsdOracle || ethers.constants.AddressZero,
230
235
  Identity: release.Identity,
231
236
  GoodDollar: release.GoodDollar,
232
237
  Contribution: release.Contribution,
@@ -235,10 +240,12 @@ export const createDAO = async () => {
235
240
  ForeignBridge: release.ForeignBridge,
236
241
  SchemeRegistrar: ethers.constants.AddressZero,
237
242
  UpgradeScheme: ethers.constants.AddressZero
238
- });
243
+ };
244
+
245
+ const v2 = await deployV2(network.name, false, olddao);
239
246
  release = { ...v2, ...release };
240
247
  await releaser(release, network.name);
241
- await pressAnyKey();
248
+ // await pressAnyKey();
242
249
  if (isMainnet) {
243
250
  await setSchemes([release.ProtocolUpgrade]);
244
251
  await performUpgrade(release, fusedao.UBIScheme);
@@ -329,6 +336,27 @@ const deployMainnet = async (Avatar, Identity) => {
329
336
  const daiAddr = ProtocolSettings[network.name]?.compound?.dai;
330
337
  const cdaiAddr = ProtocolSettings[network.name]?.compound?.cdai;
331
338
  const COMPAddr = ProtocolSettings[network.name]?.compound?.comp;
339
+ const daiEthOracleAddr = ProtocolSettings[network.name]?.chainlink?.dai_eth;
340
+ const ethUsdOracleAddr = ProtocolSettings[network.name]?.chainlink?.eth_usd;
341
+
342
+ let DAIUsdOracle, COMPUsdOracle, USDCUsdOracle, AAVEUsdOracle, GasPriceOracle;
343
+ if (name.includes("test")) {
344
+ const tokenUsdOracleFactory = await ethers.getContractFactory(
345
+ "BatUSDMockOracle"
346
+ );
347
+ DAIUsdOracle = await tokenUsdOracleFactory.deploy();
348
+ USDCUsdOracle = await tokenUsdOracleFactory.deploy();
349
+
350
+ COMPUsdOracle = await (
351
+ await ethers.getContractFactory("CompUSDMockOracle")
352
+ ).deploy();
353
+ AAVEUsdOracle = await (
354
+ await ethers.getContractFactory("AaveUSDMockOracle")
355
+ ).deploy();
356
+ GasPriceOracle = await (
357
+ await ethers.getContractFactory("GasPriceMockOracle")
358
+ ).deploy();
359
+ }
332
360
 
333
361
  let DAI = daiAddr
334
362
  ? await ethers.getContractAt("DAIMock", daiAddr)
@@ -351,16 +379,31 @@ const deployMainnet = async (Avatar, Identity) => {
351
379
  const Contribution = (await ccFactory
352
380
  .deploy(Avatar.address, 0, 1e15)
353
381
  .then(printDeploy)) as Contract;
354
- // const contribution = await ethers.getContractAt(
355
- // ContributionCalculation.abi,
356
- // "0xc3171409dB6827A68294B3A0D40a31310E83eD6B"
357
- // );
382
+
383
+ let DAIEthOracle = daiEthOracleAddr
384
+ ? await ethers.getContractAt("DaiEthPriceMockOracle", daiEthOracleAddr)
385
+ : ((await (await ethers.getContractFactory("DaiEthPriceMockOracle"))
386
+ .deploy()
387
+ .then(printDeploy)) as Contract);
388
+
389
+ let ETHUsdOracle = ethUsdOracleAddr
390
+ ? await ethers.getContractAt("EthUSDMockOracle", ethUsdOracleAddr)
391
+ : ((await (await ethers.getContractFactory("EthUSDMockOracle"))
392
+ .deploy()
393
+ .then(printDeploy)) as Contract);
358
394
 
359
395
  return {
360
396
  Contribution,
361
397
  DAI,
362
398
  COMP,
363
- cDAI
399
+ cDAI,
400
+ ETHUsdOracle,
401
+ DAIEthOracle,
402
+ DAIUsdOracle,
403
+ COMPUsdOracle,
404
+ USDCUsdOracle,
405
+ AAVEUsdOracle,
406
+ GasPriceOracle
364
407
  };
365
408
  };
366
409
 
@@ -14,12 +14,11 @@ const waitTX = async tx => {
14
14
  };
15
15
  const simulate = async function () {
16
16
  const network = networkData.name;
17
- const networkSettings = { ...settings["default"], ...settings[network] };
18
17
  const accounts = await ethers.getSigners();
19
18
 
20
19
  let addresses = deployment[network];
21
20
  let mainnetAddresses = deployment[`${network}-mainnet`];
22
- console.log({ addresses, network });
21
+ console.log({ addresses, mainnetAddresses, network });
23
22
  const identity = await ethers.getContractAt("IIdentity", addresses.Identity);
24
23
  await Promise.all(
25
24
  accounts.slice(0, 10).map(a =>
@@ -66,7 +65,11 @@ const simulate = async function () {
66
65
  .balanceOf(simpleStaking)
67
66
  .then(_ => _.toString());
68
67
 
69
- console.log("collecting interest...", { stakingBalance });
68
+ console.log("collecting interest...", {
69
+ stakingBalance,
70
+ gfm: goodFundManager.address,
71
+ simpleStaking
72
+ });
70
73
 
71
74
  await goodFundManager.collectInterest([simpleStaking], false);
72
75
 
@@ -89,7 +89,7 @@ export const main = async (
89
89
  }
90
90
 
91
91
  const isBackendTest = networkName.startsWith("dapptest");
92
- const isTest = network.name === "hardhat";
92
+ const isTest = network.name === "hardhat" || isBackendTest;
93
93
  const isCoverage = process.env.CODE_COVERAGE;
94
94
  const isDevelop = !isProduction;
95
95
  const isMainnet = networkName.includes("mainnet");
@@ -97,7 +97,13 @@ export const main = async (
97
97
  ...ProtocolSettings["default"],
98
98
  ...ProtocolSettings[networkName]
99
99
  };
100
- console.log(`networkName ${networkName}`);
100
+ console.log(`networkName ${networkName}`, {
101
+ isTest,
102
+ isBackendTest,
103
+ isCoverage,
104
+ isMainnet,
105
+ isDevelop
106
+ });
101
107
  const dao = olddao || OldDAO[networkName];
102
108
  const fse = require("fs-extra");
103
109
  const ProtocolAddresses = await fse.readJson("releases/deployment.json");
@@ -656,7 +662,7 @@ export const main = async (
656
662
  //extract just the addresses without the rewards
657
663
  // release.StakingContracts = release.StakingContracts.map((_) => _[0]);
658
664
 
659
- if (isProduction || isBackendTest) {
665
+ if (isProduction) {
660
666
  console.log(
661
667
  "SKIPPING GOVERNANCE UPGRADE FOR PRODUCTION. RUN IT MANUALLY"
662
668
  );
@@ -708,7 +714,7 @@ export const main = async (
708
714
  )
709
715
  .then(_ => countTotalGas(_, "fuse basic upgrade"));
710
716
 
711
- if (isProduction || isBackendTest) {
717
+ if (isProduction) {
712
718
  console.log(
713
719
  "SKIPPING GOVERNANCE UPGRADE FOR PRODUCTION. RUN IT MANUALLY"
714
720
  );