@gooddollar/goodprotocol 1.0.3-beta.1 → 1.0.3

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.
Files changed (98) hide show
  1. package/artifacts/contracts/DAOStackInterfaces.sol/Avatar.dbg.json +1 -1
  2. package/artifacts/contracts/DAOStackInterfaces.sol/Controller.dbg.json +1 -1
  3. package/artifacts/contracts/DAOStackInterfaces.sol/GlobalConstraintInterface.dbg.json +1 -1
  4. package/artifacts/contracts/DAOStackInterfaces.sol/IntVoteInterface.dbg.json +1 -1
  5. package/artifacts/contracts/DAOStackInterfaces.sol/ReputationInterface.dbg.json +1 -1
  6. package/artifacts/contracts/DAOStackInterfaces.sol/SchemeRegistrar.dbg.json +1 -1
  7. package/artifacts/contracts/Interfaces.sol/AggregatorV3Interface.dbg.json +1 -1
  8. package/artifacts/contracts/Interfaces.sol/ERC20.dbg.json +1 -1
  9. package/artifacts/contracts/Interfaces.sol/IAaveIncentivesController.dbg.json +1 -1
  10. package/artifacts/contracts/Interfaces.sol/IAdminWallet.dbg.json +1 -1
  11. package/artifacts/contracts/Interfaces.sol/IDonationStaking.dbg.json +1 -1
  12. package/artifacts/contracts/Interfaces.sol/IERC2917.dbg.json +1 -1
  13. package/artifacts/contracts/Interfaces.sol/IFirstClaimPool.dbg.json +1 -1
  14. package/artifacts/contracts/Interfaces.sol/IGoodDollar.dbg.json +1 -1
  15. package/artifacts/contracts/Interfaces.sol/IGoodStaking.dbg.json +1 -1
  16. package/artifacts/contracts/Interfaces.sol/IHasRouter.dbg.json +1 -1
  17. package/artifacts/contracts/Interfaces.sol/IIdentity.dbg.json +1 -1
  18. package/artifacts/contracts/Interfaces.sol/ILendingPool.dbg.json +1 -1
  19. package/artifacts/contracts/Interfaces.sol/INameService.dbg.json +1 -1
  20. package/artifacts/contracts/Interfaces.sol/IUBIScheme.dbg.json +1 -1
  21. package/artifacts/contracts/Interfaces.sol/ProxyAdmin.dbg.json +1 -1
  22. package/artifacts/contracts/Interfaces.sol/Reserve.dbg.json +1 -1
  23. package/artifacts/contracts/Interfaces.sol/Staking.dbg.json +1 -1
  24. package/artifacts/contracts/Interfaces.sol/Uniswap.dbg.json +1 -1
  25. package/artifacts/contracts/Interfaces.sol/UniswapFactory.dbg.json +1 -1
  26. package/artifacts/contracts/Interfaces.sol/UniswapPair.dbg.json +1 -1
  27. package/artifacts/contracts/Interfaces.sol/cERC20.dbg.json +1 -1
  28. package/artifacts/contracts/governance/ClaimersDistribution.sol/ClaimersDistribution.dbg.json +1 -1
  29. package/artifacts/contracts/governance/CompoundVotingMachine.sol/CompoundVotingMachine.dbg.json +1 -1
  30. package/artifacts/contracts/governance/CompoundVotingMachine.sol/CompoundVotingMachine.json +14 -2
  31. package/artifacts/contracts/governance/GReputation.sol/GReputation.dbg.json +1 -1
  32. package/artifacts/contracts/governance/GovarnanceStaking.sol/GovernanceStaking.dbg.json +1 -1
  33. package/artifacts/contracts/governance/MultiBaseGovernanceShareField.sol/MultiBaseGovernanceShareField.dbg.json +1 -1
  34. package/artifacts/contracts/governance/Reputation.sol/Reputation.dbg.json +1 -1
  35. package/artifacts/contracts/governance/StakersDistribution.sol/StakersDistribution.dbg.json +1 -1
  36. package/artifacts/contracts/mocks/AaveMock.sol/AaveMock.dbg.json +1 -1
  37. package/artifacts/contracts/mocks/DAIMock.sol/DAIMock.dbg.json +1 -1
  38. package/artifacts/contracts/mocks/DecimalsMock.sol/DecimalsMock.dbg.json +1 -1
  39. package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.dbg.json +1 -1
  40. package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.dbg.json +1 -1
  41. package/artifacts/contracts/mocks/IncentiveControllerMock.sol/IncentiveControllerMock.dbg.json +1 -1
  42. package/artifacts/contracts/mocks/LendingPoolMock.sol/LendingPoolMock.dbg.json +1 -1
  43. package/artifacts/contracts/mocks/OverMintTester.sol/OverMintTester.dbg.json +1 -1
  44. package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.dbg.json +1 -1
  45. package/artifacts/contracts/mocks/SixteenDecimalsTokenMock.sol/SixteenDecimalsTokenMock.dbg.json +1 -1
  46. package/artifacts/contracts/mocks/SwapHelperTest.sol/SwapHelperTest.dbg.json +1 -1
  47. package/artifacts/contracts/mocks/TwentyDecimalsTokenMock.sol/TwentyDecimalsTokenMock.dbg.json +1 -1
  48. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock.dbg.json +1 -1
  49. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock2.dbg.json +1 -1
  50. package/artifacts/contracts/mocks/UsdcMock.sol/USDCMock.dbg.json +1 -1
  51. package/artifacts/contracts/mocks/cBATMock.sol/cBATMock.dbg.json +1 -1
  52. package/artifacts/contracts/mocks/cDAILowWorthMock.sol/cDAILowWorthMock.dbg.json +1 -1
  53. package/artifacts/contracts/mocks/cDAIMock.sol/cDAIMock.dbg.json +1 -1
  54. package/artifacts/contracts/mocks/cDAINonMintableMock.sol/cDAINonMintableMock.dbg.json +1 -1
  55. package/artifacts/contracts/mocks/cDecimalsMock.sol/cDecimalsMock.dbg.json +1 -1
  56. package/artifacts/contracts/mocks/cSDTMock.sol/cSDTMock.dbg.json +1 -1
  57. package/artifacts/contracts/mocks/cUSDCMock.sol/cUSDCMock.dbg.json +1 -1
  58. package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.dbg.json +1 -1
  59. package/artifacts/contracts/reserve/GoodMarketMaker.sol/GoodMarketMaker.dbg.json +1 -1
  60. package/artifacts/contracts/reserve/GoodReserveCDai.sol/ContributionCalc.dbg.json +1 -1
  61. package/artifacts/contracts/reserve/GoodReserveCDai.sol/GoodReserveCDai.dbg.json +1 -1
  62. package/artifacts/contracts/staking/BaseShareField.sol/BaseShareField.dbg.json +1 -1
  63. package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.dbg.json +1 -1
  64. package/artifacts/contracts/staking/GoodFundManager.sol/GoodFundManager.dbg.json +1 -1
  65. package/artifacts/contracts/staking/SimpleStaking.sol/SimpleStaking.dbg.json +1 -1
  66. package/artifacts/contracts/staking/UniswapV2SwapHelper.sol/UniswapV2SwapHelper.dbg.json +1 -1
  67. package/artifacts/contracts/staking/aave/AaveStakingFactory.sol/AaveStakingFactory.dbg.json +1 -1
  68. package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.dbg.json +1 -1
  69. package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.dbg.json +1 -1
  70. package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.dbg.json +1 -1
  71. package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.dbg.json +1 -1
  72. package/artifacts/contracts/unaudited-foundation/FuseFaucet.sol/FuseFaucet.dbg.json +1 -1
  73. package/artifacts/contracts/unaudited-foundation/InvitesV1.sol/InvitesV1.dbg.json +1 -1
  74. package/artifacts/contracts/unaudited-foundation/InvitesV1.sol/InvitesV1.json +2 -2
  75. package/artifacts/contracts/utils/BancorFormula.sol/BancorFormula.dbg.json +1 -1
  76. package/artifacts/contracts/utils/DAOContract.sol/DAOContract.dbg.json +1 -1
  77. package/artifacts/contracts/utils/DAOUpgradeableContract.sol/DAOUpgradeableContract.dbg.json +1 -1
  78. package/artifacts/contracts/utils/DSMath.sol/DSMath.dbg.json +1 -1
  79. package/artifacts/contracts/utils/DataTypes.sol/DataTypes.dbg.json +1 -1
  80. package/artifacts/contracts/utils/NameService.sol/NameService.dbg.json +1 -1
  81. package/artifacts/contracts/utils/ProtocolUpgrade.sol/OldMarketMaker.dbg.json +1 -1
  82. package/artifacts/contracts/utils/ProtocolUpgrade.sol/ProtocolUpgrade.dbg.json +1 -1
  83. package/artifacts/contracts/utils/ProtocolUpgradeFuse.sol/ProtocolUpgradeFuse.dbg.json +1 -1
  84. package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.dbg.json +1 -1
  85. package/contracts/governance/CompoundVotingMachine.sol +8 -2
  86. package/contracts/unaudited-foundation/InvitesV1.sol +29 -24
  87. package/hardhat.config.ts +3 -1
  88. package/package.json +1 -1
  89. package/releases/deployment.json +24 -24
  90. package/scripts/deployFullDAO.ts +159 -125
  91. package/scripts/keeper/fishInactive.ts +57 -0
  92. package/scripts/upgradeToV2/upgradeToV2.ts +13 -4
  93. package/test/governance/CompoundVotingMachine.delegate.test.ts +0 -4
  94. package/test/governance/CompoundVotingMachine.guardian.test.ts +2 -2
  95. package/test/helpers.ts +3 -10
  96. package/test/reserve/GoodReserveCDai.cap.test.ts +1 -1
  97. package/test/reserve/GoodReserveCDai.test.ts +11 -109
  98. package/test/utils/ProtocolUpgrade.test.ts +8 -0
@@ -0,0 +1,57 @@
1
+ import { range, chunk } from "lodash";
2
+ import { ethers as Ethers } from "hardhat";
3
+ import fetch from "node-fetch";
4
+
5
+ const ONE_DAY = 24 * 60 * 60;
6
+
7
+ const main = async () => {
8
+ const signer = (await Ethers.getSigners())[0];
9
+ console.log("signer:", signer.address);
10
+ const ubiScheme = new Ethers.Contract(
11
+ "0xD7aC544F8A570C4d8764c3AAbCF6870CBD960D0D",
12
+ ["function fishMulti(address[] tofish)"]
13
+ ).connect(signer);
14
+ const twoWeeksAgo =
15
+ parseInt((Date.now() / 1000).toFixed(0)) - 24 * 60 * 60 * 14;
16
+
17
+ const daysAgo: number[] = range(0, 180, 1);
18
+ let curDay = twoWeeksAgo;
19
+ for (let day of daysAgo) {
20
+ const query = `
21
+ {
22
+ walletStats(first:1000, where: { lastClaimed_lt: ${curDay},lastClaimed_gt: ${
23
+ curDay - 24 * 60 * 60
24
+ } isActiveUser: true }) {
25
+ id
26
+ }
27
+ }
28
+ `;
29
+
30
+ console.log(
31
+ "fetching inactive users since:",
32
+ { curDay, day },
33
+ JSON.stringify({ query })
34
+ );
35
+ const { walletStats } = await fetch(
36
+ "https://api.thegraph.com/subgraphs/name/gooddollar/gooddollarfuse",
37
+ {
38
+ method: "post",
39
+ body: JSON.stringify({ query }),
40
+ headers: { "Content-Type": "application/json" }
41
+ }
42
+ ).then(_ => _.json());
43
+
44
+ console.log("got inactive wallets:", walletStats.length);
45
+ const accounts = walletStats.map(_ => _.id);
46
+ for (let tofish of chunk(accounts, 50)) {
47
+ const tx = await ubiScheme.fishMulti(tofish, { gasLimit: 2000000 });
48
+ console.log("fishing tx:", tx, tofish);
49
+ const res = await tx.wait();
50
+ console.log("fishing tx result:", res);
51
+ }
52
+
53
+ curDay = curDay - ONE_DAY;
54
+ }
55
+ };
56
+
57
+ main();
@@ -74,7 +74,7 @@ export const main = async (
74
74
  if (isProduction && networkName.includes("mainnet")) {
75
75
  GAS_SETTINGS.gasLimit = 6000000;
76
76
  GAS_SETTINGS.maxFeePerGas = ethers.utils.parseUnits("80", "gwei");
77
- } else if (!networkName.includes("mainnet")) {
77
+ } else if (network.config.chainId === 122) {
78
78
  //case we are on fusefuse
79
79
  GAS_SETTINGS = {
80
80
  gasLimit: 6000000,
@@ -108,6 +108,10 @@ export const main = async (
108
108
 
109
109
  const founders = await getFounders(networkName);
110
110
 
111
+ console.log(
112
+ `root: ${root.address} founders: ${founders.map(_ => _.address)}`
113
+ );
114
+
111
115
  const compoundTokens = [
112
116
  {
113
117
  name: "cdai",
@@ -216,7 +220,8 @@ export const main = async (
216
220
  args: [
217
221
  () => get(release, "NameService", newdao.NameService),
218
222
  protocolSettings.governance.proposalVotingPeriod,
219
- protocolSettings.governance.guardian || root.address
223
+ protocolSettings.governance.guardian || root.address,
224
+ () => get(release, "GReputation", newdao.GReputation)
220
225
  ]
221
226
  },
222
227
  {
@@ -355,6 +360,7 @@ export const main = async (
355
360
 
356
361
  if (contract.isUpgradable !== false) {
357
362
  if (isCoverage) {
363
+ console.log("Deploying:", contract.name, "using proxy");
358
364
  //coverage has large contracts doesnt work with proxy factory
359
365
  const tx = await upgrades.deployProxy(Contract, args, {
360
366
  initializer: contract.initializer,
@@ -364,6 +370,7 @@ export const main = async (
364
370
  await countTotalGas(tx, contract.name);
365
371
  return tx;
366
372
  }
373
+ console.log("Deploying:", contract.name, "using proxyfactory");
367
374
  const encoded = Contract.interface.encodeFunctionData(
368
375
  contract.initializer || "initialize",
369
376
  args
@@ -394,6 +401,7 @@ export const main = async (
394
401
  } else {
395
402
  //for some reason deploying with link library via proxy doesnt work on hardhat test env
396
403
  if (isTest === false) {
404
+ console.log("Deploying:", contract.name, "using proxyfactory code");
397
405
  const constructor = Contract.interface.encodeDeploy(args);
398
406
  const bytecode = ethers.utils.solidityPack(
399
407
  ["bytes", "bytes"],
@@ -411,6 +419,7 @@ export const main = async (
411
419
  )
412
420
  );
413
421
  } else {
422
+ console.log("Deploying:", contract.name, "using regular");
414
423
  const tx = await Contract.deploy(...args, GAS_SETTINGS);
415
424
  await countTotalGas(tx, contract.name);
416
425
  const impl = await tx.deployed();
@@ -944,7 +953,7 @@ export const main = async (
944
953
  !isMainnet && (await performUpgradeFuse(release));
945
954
  console.log("upgraded contracts", { totalGas });
946
955
  }
947
- if (!isTest && !isCoverage) {
956
+ if (isMainnet && !isTest && !isCoverage) {
948
957
  await verifyContracts(release);
949
958
  }
950
959
 
@@ -952,7 +961,7 @@ export const main = async (
952
961
  return release;
953
962
  // await proveNewRep();
954
963
  };
955
- if (network.name !== "hardhat") {
964
+ if (network.name !== "hardhat" && process.argv[1].includes("upgradeToV2.ts")) {
956
965
  main(name, false)
957
966
  .catch(e => {
958
967
  console.log(e);
@@ -62,10 +62,6 @@ describe("CompoundVotingMachine#Delegation", () => {
62
62
  before(async () => {
63
63
  [root, acct, ...signers] = await ethers.getSigners();
64
64
 
65
- const CompoundVotingMachine = await ethers.getContractFactory(
66
- "CompoundVotingMachine"
67
- );
68
-
69
65
  let {
70
66
  daoCreator,
71
67
  reputation,
@@ -93,7 +93,7 @@ describe("CompoundVotingMachine#Guardian", () => {
93
93
  it("should set guardian from initializer", async () => {
94
94
  const votingMachine = (await upgrades.deployProxy(
95
95
  await ethers.getContractFactory("CompoundVotingMachine"),
96
- [nameService.address, 5760, signers[2].address],
96
+ [nameService.address, 5760, signers[2].address, NULL_ADDRESS],
97
97
  { kind: "uups" }
98
98
  )) as unknown as CompoundVotingMachine;
99
99
  expect(await votingMachine.guardian()).to.equal(signers[2].address);
@@ -151,7 +151,7 @@ describe("CompoundVotingMachine#Guardian", () => {
151
151
 
152
152
  const gov2 = (await upgrades.deployProxy(
153
153
  CompoundVotingMachine,
154
- [nameService.address, 5760, root.address],
154
+ [nameService.address, 5760, root.address, NULL_ADDRESS],
155
155
  { kind: "uups" }
156
156
  )) as CompoundVotingMachine;
157
157
 
package/test/helpers.ts CHANGED
@@ -14,15 +14,8 @@ import IUniswapV2Pair from "@uniswap/v2-core/build/IUniswapV2Pair.json";
14
14
  import UniswapV2Factory from "@uniswap/v2-core/build/UniswapV2Factory.json";
15
15
  import WETH9 from "@uniswap/v2-periphery/build/WETH9.json";
16
16
  import UniswapV2Router02 from "@uniswap/v2-periphery/build/UniswapV2Router02.json";
17
- import {
18
- Controller,
19
- GoodMarketMaker,
20
- CompoundVotingMachine,
21
- GoodCompoundStaking,
22
- GoodAaveStaking
23
- } from "../types";
24
- import { Contract } from "@ethersproject/contracts";
25
- import { BigNumber } from "@ethersproject/bignumber";
17
+ import { GoodMarketMaker, CompoundVotingMachine } from "../types";
18
+ import { Contract } from "ethers";
26
19
 
27
20
  export const getStakingFactory = async (
28
21
  factory: "GoodCompoundStaking" | "GoodAaveStaking" | "GoodCompoundStakingTest"
@@ -285,7 +278,7 @@ export const createDAO = async () => {
285
278
  );
286
279
  const votingMachine = (await upgrades.deployProxy(
287
280
  await ethers.getContractFactory("CompoundVotingMachine"),
288
- [nameService.address, 5760, root.address],
281
+ [nameService.address, 5760, root.address, reputation.address],
289
282
  { kind: "uups" }
290
283
  )) as unknown as CompoundVotingMachine;
291
284
  return {
@@ -2,7 +2,7 @@ import { default as hre, ethers, upgrades } from "hardhat";
2
2
  import { expect } from "chai";
3
3
  import { GoodMarketMaker, CERC20, GoodReserveCDai } from "../../types";
4
4
  import { createDAO, increaseTime, advanceBlocks } from "../helpers";
5
- import { Contract } from "@ethersproject/contracts";
5
+ import { Contract } from "ethers";
6
6
 
7
7
  const BN = ethers.BigNumber;
8
8
  export const NULL_ADDRESS = ethers.constants.AddressZero;
@@ -175,7 +175,7 @@ describe("GoodReserve - staking with cDAI mocks", () => {
175
175
  // // await goodDollar.addMinter(goodReserve.address);
176
176
  // });
177
177
 
178
- xit("should mint UBI correctly for 18 decimals precision and no interest", async () => {
178
+ it("should mint UBI correctly for 18 decimals precision and no interest", async () => {
179
179
  let reserveToken = await marketMaker.reserveTokens(cDAI.address);
180
180
  let reserveBalanceBefore = reserveToken.reserveSupply;
181
181
  let supplyBefore = reserveToken.gdSupply;
@@ -191,7 +191,7 @@ describe("GoodReserve - staking with cDAI mocks", () => {
191
191
 
192
192
  await dai["mint(address,uint256)"](goodReserve.address, daiAmount);
193
193
  const tx = await (
194
- await goodReserve.mintUBI(1, ethers.utils.parseEther("0.1"), cDAI.address)
194
+ await goodReserve.mintUBI(daiAmount, 0, cDAI.address)
195
195
  ).wait();
196
196
  const gdBalanceFund = await goodDollar.balanceOf(founder.address);
197
197
  const gdPriceAfter = await goodReserve["currentPrice()"]();
@@ -214,7 +214,7 @@ describe("GoodReserve - staking with cDAI mocks", () => {
214
214
  // expected that the new reserve balance will include
215
215
  // the new 1e18 cdai which transferred
216
216
  expect(reserveBalanceAfter).to.be.equal(
217
- reserveBalanceBefore.add(BN.from("10").pow(17)).sub(BN.from("1"))
217
+ reserveBalanceBefore.add(BN.from("10").pow(17))
218
218
  );
219
219
  // the new reserve ratio should be effected from the mintExpansion by:
220
220
  // the daily change that was set up in the constructor (999388834642296)
@@ -228,115 +228,17 @@ describe("GoodReserve - staking with cDAI mocks", () => {
228
228
  .toString()
229
229
  );
230
230
  });
231
- /*
232
- it("should mint UBI correctly for 18 decimals precision and partial interest", async () => {
233
- let reserveToken = await marketMaker.reserveTokens(cDAI.address);
234
- let reserveBalanceBefore = reserveToken.reserveSupply;
235
- let supplyBefore = reserveToken.gdSupply;
236
- const gdBalanceFundBefore = await goodDollar.balanceOf(founder.address);
237
- const gdBalanceAvatarBefore = await goodDollar.balanceOf(avatar);
238
- const gdPriceBefore = await goodReserve["currentPrice()"]();
239
- const tx = await (
240
- await goodReserve.mintInterestAndUBI(
241
- cDAI.address,
242
- ethers.utils.parseUnits("10000", "gwei"),
243
- "10000"
244
- )
245
- ).wait(); // interest is 0.0001 cDai which equal to 1 gd
246
- const gdBalanceFundAfter = await goodDollar.balanceOf(founder.address);
247
- const gdBalanceAvatarAfter = await goodDollar.balanceOf(avatar);
248
- const gdPriceAfter = await goodReserve["currentPrice()"]();
249
- reserveToken = await marketMaker.reserveTokens(cDAI.address);
250
- let reserveBalanceAfter = reserveToken.reserveSupply;
251
- let supplyAfter = reserveToken.gdSupply;
252
- let rrAfter = reserveToken.reserveRatio;
253
- let et = BN.from(ethers.utils.parseUnits("10000", "gwei"));
254
- console.log(
255
- gdPriceBefore.toNumber(),
256
- supplyAfter.toNumber(),
257
- supplyBefore.toNumber()
258
- );
259
- const mintEvent = tx.events.find(_ => _.event === "UBIMinted");
260
- const toMint = mintEvent.args.gdInterestMinted.add(
261
- mintEvent.args.gdExpansionMinted
262
- );
263
- expect(reserveBalanceAfter.toString()).to.be.equal(
264
- et.add(reserveBalanceBefore).toString(),
265
- "reserve balance has changed"
266
- );
267
- expect(supplyAfter.toString()).to.be.equal(
268
- toMint.add(supplyBefore).toString(),
269
- "supply has changed"
270
- );
271
- expect(gdPriceAfter.toString()).to.be.equal(
272
- gdPriceBefore.toString(),
273
- "price has changed"
274
- );
275
- expect(
276
- (gdBalanceAvatarAfter - gdBalanceAvatarBefore).toString()
277
- ).to.be.equal("0"); // 1 gd
278
- expect(gdBalanceFundAfter.sub(gdBalanceFundBefore)).to.be.equal(
279
- toMint,
280
- "ubi minted mismatch"
281
- );
282
- expect(rrAfter.toString()).to.be.equal("999388");
231
+
232
+ it("should not mint UBI if the reserve is not cDAI", async () => {
233
+ let error = await goodReserve.mintUBI(1, 0, dai.address).catch(e => e);
234
+ expect(error.message).not.to.be.empty;
283
235
  });
284
- */
285
- // it("should not mint UBI if the reserve is not cDAI", async () => {
286
- // let error = await goodReserve
287
- // .mintInterestAndUBI(dai.address, ethers.utils.parseEther("1"), "0")
288
- // .catch(e => e);
289
- // expect(error.message).not.to.be.empty;
290
- // });
291
236
 
292
- xit("should not mint UBI if the caller is not the fund manager", async () => {
293
- let tx = goodReserve
294
- .connect(staker)
295
- .mintUBI(1, ethers.utils.parseEther("1"), cDAI.address);
237
+ it("should not mint UBI if the caller is not the fund manager", async () => {
238
+ let tx = goodReserve.connect(staker).mintUBI(0, 0, cDAI.address);
296
239
  await expect(tx).to.be.revertedWith("GoodReserve: not a minter");
297
240
  });
298
241
 
299
- // it("should set block interval by avatar", async () => {
300
- // let encodedCall = web3.eth.abi.encodeFunctionCall(
301
- // {
302
- // name: "setBlockInterval",
303
- // type: "function",
304
- // inputs: [
305
- // {
306
- // type: "uint256",
307
- // name: "_blockInterval"
308
- // }
309
- // ]
310
- // },
311
- // [100]
312
- // );
313
- // await controller.genericCall(
314
- // goodReserve.address,
315
- // encodedCall,
316
- // avatar,
317
- // 0
318
- // );
319
- // const newBI = await goodReserve.blockInterval();
320
- // expect(newBI.toString()).to.be.equal("100");
321
- // });
322
-
323
- // it("should not mint UBI if not in the interval", async () => {
324
- // const gdBalanceFundBefore = await goodDollar.balanceOf(founder.address);
325
- // const gdBalanceAvatarBefore = await goodDollar.balanceOf(avatar);
326
- // const error = await goodReserve
327
- // .mintInterestAndUBI(
328
- // cDAI.address,
329
- // ethers.utils.parseUnits("10000", "gwei"),
330
- // "10000"
331
- // )
332
- // .catch(e => e);
333
- // const gdBalanceFundAfter = await goodDollar.balanceOf(founder.address);
334
- // const gdBalanceAvatarAfter = await goodDollar.balanceOf(avatar);
335
- // expect(error.message).to.have.string("wait for the next interval");
336
- // expect(gdBalanceFundAfter).to.be.equal(gdBalanceFundBefore);
337
- // expect(gdBalanceAvatarAfter).to.be.equal(gdBalanceAvatarBefore);
338
- // });
339
-
340
242
  it("should be able to buy gd with DAI", async () => {
341
243
  let daiAmount = ethers.utils.parseEther("100");
342
244
  const cdaiRateStored = await cDAI.exchangeRateStored();
@@ -1086,8 +988,8 @@ describe("GoodReserve - staking with cDAI mocks", () => {
1086
988
  (1 - amount.toNumber() / parseInt(supply.toString())) **
1087
989
  (1000000 / reserveToken.reserveRatio));
1088
990
 
1089
- // expected = Math.ceil((0.8 * expected) / 100) * 100; //deduct 20% contribution, allow 2 points precission mismatch (due to bancor pow estimation?), match solidity no floating point
1090
- expected = Math.floor(0.8 * expected);
991
+ expected = Math.ceil((0.8 * expected) / 100) * 100; //deduct 20% contribution, allow 5 points precission mismatch (due to bancor pow estimation?), match solidity no floating point
992
+ //expected = Math.floor(0.8 * expected);
1091
993
  expect(cDAIBalanceAfter.sub(cDAIBalanceBefore)).to.be.equal(expected);
1092
994
  expect(cDAIBalanceReserveBefore.sub(cDAIBalanceReserveAfter)).to.be.equal(
1093
995
  expected
@@ -417,6 +417,14 @@ describe("ProtocolUpgrade - Upgrade old protocol contracts to new ones", () => {
417
417
  );
418
418
  });
419
419
 
420
+ it("should initialize reputation address", async () => {
421
+ const cvm = await ethers.getContractAt(
422
+ "CompoundVotingMachine",
423
+ deployment["test-mainnet"].CompoundVotingMachine
424
+ );
425
+ expect(await cvm.rep()).to.equal(deployment["test-mainnet"].GReputation);
426
+ });
427
+
420
428
  it("it should set fuse nameservice variables properly", async () => {
421
429
  const fse = require("fs-extra");
422
430
  const deployment = await fse.readJson("releases/deployment.json");