@gooddollar/goodprotocol 1.0.13-beta.0 → 1.0.13

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 (129) 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/GReputation.sol/GReputation.dbg.json +1 -1
  31. package/artifacts/contracts/governance/GovarnanceStaking.sol/GovernanceStaking.dbg.json +1 -1
  32. package/artifacts/contracts/governance/MultiBaseGovernanceShareField.sol/MultiBaseGovernanceShareField.dbg.json +1 -1
  33. package/artifacts/contracts/governance/Reputation.sol/Reputation.dbg.json +1 -1
  34. package/artifacts/contracts/governance/StakersDistribution.sol/StakersDistribution.dbg.json +1 -1
  35. package/artifacts/contracts/governance/StakersDistribution.sol/StakersDistribution.json +2 -2
  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/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.json +2 -2
  41. package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.dbg.json +1 -1
  42. package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.json +2 -2
  43. package/artifacts/contracts/mocks/IncentiveControllerMock.sol/IncentiveControllerMock.dbg.json +1 -1
  44. package/artifacts/contracts/mocks/LendingPoolMock.sol/LendingPoolMock.dbg.json +1 -1
  45. package/artifacts/contracts/mocks/OverMintTester.sol/OverMintTester.dbg.json +1 -1
  46. package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.dbg.json +1 -1
  47. package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.json +2 -2
  48. package/artifacts/contracts/mocks/SixteenDecimalsTokenMock.sol/SixteenDecimalsTokenMock.dbg.json +1 -1
  49. package/artifacts/contracts/mocks/SwapHelperTest.sol/SwapHelperTest.dbg.json +1 -1
  50. package/artifacts/contracts/mocks/TwentyDecimalsTokenMock.sol/TwentyDecimalsTokenMock.dbg.json +1 -1
  51. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock.dbg.json +1 -1
  52. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock2.dbg.json +1 -1
  53. package/artifacts/contracts/mocks/UsdcMock.sol/USDCMock.dbg.json +1 -1
  54. package/artifacts/contracts/mocks/cBATMock.sol/cBATMock.dbg.json +1 -1
  55. package/artifacts/contracts/mocks/cDAILowWorthMock.sol/cDAILowWorthMock.dbg.json +1 -1
  56. package/artifacts/contracts/mocks/cDAIMock.sol/cDAIMock.dbg.json +1 -1
  57. package/artifacts/contracts/mocks/cDAINonMintableMock.sol/cDAINonMintableMock.dbg.json +1 -1
  58. package/artifacts/contracts/mocks/cDecimalsMock.sol/cDecimalsMock.dbg.json +1 -1
  59. package/artifacts/contracts/mocks/cSDTMock.sol/cSDTMock.dbg.json +1 -1
  60. package/artifacts/contracts/mocks/cUSDCMock.sol/cUSDCMock.dbg.json +1 -1
  61. package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.dbg.json +1 -1
  62. package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.json +2 -2
  63. package/artifacts/contracts/reserve/GoodMarketMaker.sol/GoodMarketMaker.dbg.json +1 -1
  64. package/artifacts/contracts/reserve/GoodMarketMaker.sol/GoodMarketMaker.json +7 -2
  65. package/artifacts/contracts/reserve/GoodReserveCDai.sol/ContributionCalc.dbg.json +1 -1
  66. package/artifacts/contracts/reserve/GoodReserveCDai.sol/GoodReserveCDai.dbg.json +1 -1
  67. package/artifacts/contracts/reserve/GoodReserveCDai.sol/GoodReserveCDai.json +15 -2
  68. package/artifacts/contracts/staking/BaseShareField.sol/BaseShareField.dbg.json +1 -1
  69. package/artifacts/contracts/staking/BaseShareFieldV2.sol/BaseShareFieldV2.dbg.json +1 -1
  70. package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.dbg.json +1 -1
  71. package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.json +6 -6
  72. package/artifacts/contracts/staking/GoodFundManager.sol/GoodFundManager.dbg.json +1 -1
  73. package/artifacts/contracts/staking/GoodFundManager.sol/GoodFundManager.json +2 -2
  74. package/artifacts/contracts/staking/SimpleStaking.sol/SimpleStaking.dbg.json +1 -1
  75. package/artifacts/contracts/staking/SimpleStakingV2.sol/SimpleStakingV2.dbg.json +1 -1
  76. package/artifacts/contracts/staking/UniswapV2SwapHelper.sol/UniswapV2SwapHelper.dbg.json +1 -1
  77. package/artifacts/contracts/staking/aave/AaveStakingFactory.sol/AaveStakingFactory.dbg.json +1 -1
  78. package/artifacts/contracts/staking/aave/AaveStakingFactory.sol/AaveStakingFactory.json +2 -2
  79. package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.dbg.json +1 -1
  80. package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.json +2 -2
  81. package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.dbg.json +1 -1
  82. package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.json +2 -2
  83. package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.dbg.json +1 -1
  84. package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.json +2 -2
  85. package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.dbg.json +1 -1
  86. package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.json +2 -2
  87. package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.dbg.json +1 -1
  88. package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.json +2 -2
  89. package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.dbg.json +1 -1
  90. package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.json +60 -2
  91. package/artifacts/contracts/unaudited-foundation/FuseFaucet.sol/FuseFaucet.dbg.json +1 -1
  92. package/artifacts/contracts/unaudited-foundation/InvitesV1.sol/InvitesV1.dbg.json +1 -1
  93. package/artifacts/contracts/utils/BancorFormula.sol/BancorFormula.dbg.json +1 -1
  94. package/artifacts/contracts/utils/DAOContract.sol/DAOContract.dbg.json +1 -1
  95. package/artifacts/contracts/utils/DAOUpgradeableContract.sol/DAOUpgradeableContract.dbg.json +1 -1
  96. package/artifacts/contracts/utils/DSMath.sol/DSMath.dbg.json +1 -1
  97. package/artifacts/contracts/utils/DataTypes.sol/DataTypes.dbg.json +1 -1
  98. package/artifacts/contracts/utils/NameService.sol/NameService.dbg.json +1 -1
  99. package/artifacts/contracts/utils/ProtocolUpgrade.sol/OldMarketMaker.dbg.json +1 -1
  100. package/artifacts/contracts/utils/ProtocolUpgrade.sol/ProtocolUpgrade.dbg.json +1 -1
  101. package/artifacts/contracts/utils/ProtocolUpgrade.sol/ProtocolUpgrade.json +2 -2
  102. package/artifacts/contracts/utils/ProtocolUpgradeFuse.sol/ProtocolUpgradeFuse.dbg.json +1 -1
  103. package/artifacts/contracts/utils/ProtocolUpgradeFuseRecover.sol/ProtocolUpgradeFuseRecover.dbg.json +4 -0
  104. package/artifacts/contracts/utils/ProtocolUpgradeFuseRecover.sol/ProtocolUpgradeFuseRecover.json +83 -0
  105. package/artifacts/contracts/utils/ProtocolUpgradeRecover.sol/ProtocolUpgradeRecover.dbg.json +4 -0
  106. package/artifacts/contracts/utils/ProtocolUpgradeRecover.sol/ProtocolUpgradeRecover.json +121 -0
  107. package/artifacts/contracts/utils/ProxyFactory1967.sol/ERC1967Proxy.dbg.json +1 -1
  108. package/artifacts/contracts/utils/ProxyFactory1967.sol/ERC1967Proxy.json +2 -2
  109. package/artifacts/contracts/utils/ProxyFactory1967.sol/ProxyFactory1967.dbg.json +1 -1
  110. package/artifacts/contracts/utils/ProxyFactory1967.sol/ProxyFactory1967.json +2 -2
  111. package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.dbg.json +1 -1
  112. package/contracts/reserve/GoodMarketMaker.sol +3 -2
  113. package/contracts/reserve/GoodReserveCDai.sol +25 -21
  114. package/contracts/staking/DonationsStaking.sol +1 -0
  115. package/contracts/ubi/UBIScheme.sol +32 -4
  116. package/contracts/utils/ProtocolUpgrade.sol +3 -2
  117. package/contracts/utils/ProtocolUpgradeFuseRecover.sol +116 -0
  118. package/contracts/utils/ProtocolUpgradeRecover.sol +198 -0
  119. package/contracts/utils/ProxyFactory1967.sol +1 -0
  120. package/package.json +1 -1
  121. package/releases/deployment.json +65 -2
  122. package/scripts/deployFullDAO.ts +2 -1
  123. package/scripts/upgradeToV2/upgradeToV2Recover.ts +947 -0
  124. package/test/helpers.ts +1 -1
  125. package/test/reserve/GoodMarketMaker.test.ts +6 -5
  126. package/test/staking/DonationsStaking.test.ts +32 -19
  127. package/test/ubi/UBIScheme.e2e.test.ts +1 -1
  128. package/test/ubi/UBIScheme.test.ts +4 -4
  129. package/test/utils/ProxyFactory.test.ts +31 -0
package/test/helpers.ts CHANGED
@@ -225,7 +225,7 @@ export const createDAO = async () => {
225
225
  const setReserveToken = async (token, gdReserve, tokenReserve, RR) => {
226
226
  const encoded = marketMaker.interface.encodeFunctionData(
227
227
  "initializeToken",
228
- [token, gdReserve, tokenReserve, RR]
228
+ [token, gdReserve, tokenReserve, RR, 0]
229
229
  );
230
230
 
231
231
  await ictrl.genericCall(marketMaker.address, encoded, Avatar.address, 0);
@@ -55,7 +55,7 @@ describe("GoodMarketMaker - calculate gd value at reserve", () => {
55
55
  marketMaker: mm,
56
56
  setSchemes,
57
57
  setReserveToken,
58
- setDAOAddress,
58
+ setDAOAddress
59
59
  } = await createDAO();
60
60
  avatar = av;
61
61
  marketMaker = mm.connect(fakeReserve);
@@ -144,7 +144,7 @@ describe("GoodMarketMaker - calculate gd value at reserve", () => {
144
144
  expect(
145
145
  await marketMaker
146
146
  .reserveTokens(cdai)
147
- .then((_) => _["reserveRatio"].toString())
147
+ .then(_ => _["reserveRatio"].toString())
148
148
  ).to.be.equal("994511"); // 998777 * 0.999388834642296000000000000^7
149
149
  });
150
150
 
@@ -165,13 +165,14 @@ describe("GoodMarketMaker - calculate gd value at reserve", () => {
165
165
  const marketMaker1 = await upgrades.deployProxy(MM, [
166
166
  await marketMaker.nameService(),
167
167
  999388834642296,
168
- 1e15,
168
+ 1e15
169
169
  ]);
170
170
  await marketMaker1.initializeToken(
171
171
  dai,
172
172
  "100", //1gd
173
173
  ethers.utils.parseEther("0.0001"),
174
- "800000" //80% rr
174
+ "800000", //80% rr,
175
+ 0
175
176
  );
176
177
  const res = marketMaker1.sellWithContribution(
177
178
  dai,
@@ -188,7 +189,7 @@ describe("GoodMarketMaker - calculate gd value at reserve", () => {
188
189
  await marketMaker.mintInterest(cdai, BN.from(1e8));
189
190
  expect(
190
191
  Math.floor(
191
- (await marketMaker.currentPrice(cdai).then((_) => _.toNumber())) / 100
192
+ (await marketMaker.currentPrice(cdai).then(_ => _.toNumber())) / 100
192
193
  ).toString()
193
194
  ).to.be.equal(Math.floor(priceBefore.toNumber() / 100).toString());
194
195
  });
@@ -218,6 +218,7 @@ describe("DonationsStaking - DonationStaking contract that receives funds in ETH
218
218
  expect(totalStakedBeforeStake).to.be.equal(0);
219
219
  expect(totalStakedAfterStake).to.be.gt(totalStakedBeforeStake);
220
220
  });
221
+
221
222
  it("it should stake donations with DAI", async () => {
222
223
  let stakeAmount = ethers.utils.parseEther("10");
223
224
  await dai["mint(address,uint256)"](donationsStaking.address, stakeAmount);
@@ -228,6 +229,13 @@ describe("DonationsStaking - DonationStaking contract that receives funds in ETH
228
229
  stakeAmount
229
230
  );
230
231
  });
232
+
233
+ it("it should reverted when there is no token to stake", async () => {
234
+ await expect(donationsStaking.stakeDonations()).to.be.revertedWith(
235
+ "no stakingToken to stake"
236
+ );
237
+ });
238
+
231
239
  it("it should stake donations with ETH according to 0.3% of pool", async () => {
232
240
  let stakeAmount = ethers.utils.parseEther("20");
233
241
  const pairContract = await ethers.getContractAt(
@@ -263,6 +271,7 @@ describe("DonationsStaking - DonationStaking contract that receives funds in ETH
263
271
  expect(stakeAmount).to.be.gt(maxAmount);
264
272
  expect(stakeAmount.sub(maxAmount)).to.be.equal(ethBalanceAfterStake); // check leftover ETH in contract
265
273
  });
274
+
266
275
  it("withdraw should reverted if caller not avatar", async () => {
267
276
  const tx = await donationsStaking
268
277
  .connect(staker)
@@ -270,6 +279,7 @@ describe("DonationsStaking - DonationStaking contract that receives funds in ETH
270
279
  .catch(e => e);
271
280
  expect(tx.message).to.have.string("only avatar can call this method");
272
281
  });
282
+
273
283
  it("it should withdraw donationStaking when caller is avatar and return funds to avatar", async () => {
274
284
  const totalStakedBeforeEnd = await donationsStaking.totalStaked();
275
285
  const avatarDaiBalanceBeforeEnd = await dai.balanceOf(avatar);
@@ -305,16 +315,9 @@ describe("DonationsStaking - DonationStaking contract that receives funds in ETH
305
315
 
306
316
  expect(totalStakedAfterEnd).to.be.equal(0);
307
317
  });
318
+
308
319
  it("it should set stakingContract when avatar call it ", async () => {
309
320
  let stakeAmount = ethers.utils.parseEther("6000"); // Max swap amount is around 5964 with current liquidity level so we should set it to higher number in order to test functionality
310
- const donationsStakingFactory = await ethers.getContractFactory(
311
- "DonationsStaking",
312
- {
313
- libraries: {
314
- UniswapV2SwapHelper: swapHelper.address
315
- }
316
- }
317
- );
318
321
 
319
322
  await dai["mint(address,uint256)"](donationsStaking.address, stakeAmount);
320
323
  await donationsStaking.stakeDonations();
@@ -342,7 +345,7 @@ describe("DonationsStaking - DonationStaking contract that receives funds in ETH
342
345
  .then(async contract => {
343
346
  await contract.init(
344
347
  bat.address,
345
- cDAI.address,
348
+ cBat.address,
346
349
  nameService.address,
347
350
  "Good BAT",
348
351
  "gBAT",
@@ -353,16 +356,21 @@ describe("DonationsStaking - DonationStaking contract that receives funds in ETH
353
356
  );
354
357
  return contract;
355
358
  });
356
- //let encodedData = donationsStakingFactory.interface.encodeFunctionData(
357
- // "setStakingContract",
358
- // [simpleStaking.address, [NULL_ADDRESS, bat.address]]
359
- //);
360
- //
361
- //await genericCall(donationsStaking.address, encodedData);
362
- await donationsStaking.setStakingContract(simpleStaking.address, [
363
- NULL_ADDRESS,
364
- bat.address
365
- ]);
359
+
360
+ //not avatar
361
+ await expect(
362
+ donationsStaking.setStakingContract(simpleStaking.address, [
363
+ NULL_ADDRESS,
364
+ bat.address
365
+ ])
366
+ ).to.be.reverted;
367
+
368
+ let encodedData = donationsStaking.interface.encodeFunctionData(
369
+ "setStakingContract",
370
+ [simpleStaking.address, [NULL_ADDRESS, bat.address]]
371
+ );
372
+ await genericCall(donationsStaking.address, encodedData);
373
+
366
374
  const avatarDaiBalanceAfterSet = await dai.balanceOf(avatar);
367
375
  const stakingAmountAfterSet = await goodCompoundStaking.balanceOf(
368
376
  donationsStaking.address
@@ -390,4 +398,9 @@ describe("DonationsStaking - DonationStaking contract that receives funds in ETH
390
398
  ); // It should send leftover stakingToken to avatar after swap to ETH in safeAmount
391
399
  expect(stakingAmountBeforeSet).to.be.gt(safeAmount); // maxSafeAmount must be smaller than actualstaking amount so we can verify that we hit the limit for transaction amount at once
392
400
  });
401
+
402
+ it("it should return version of DonationsStaking properly", async () => {
403
+ const version = await donationsStaking.getVersion();
404
+ expect(version).to.be.equal("2.0.0");
405
+ });
393
406
  });
@@ -226,7 +226,7 @@ describe("UBIScheme - network e2e tests", () => {
226
226
  it("should award a new user with the award amount on first time execute claim", async () => {
227
227
  await increaseTime(86400);
228
228
  let claimerBalance1 = await goodDollar.balanceOf(claimer.address);
229
- let ce = await ubi.connect(claimer).checkEntitlement();
229
+ let ce = await ubi.connect(claimer)["checkEntitlement()"]();
230
230
  await ubi.connect(claimer).claim();
231
231
  let claimerBalance2 = await goodDollar.balanceOf(claimer.address);
232
232
  expect(claimerBalance2.sub(claimerBalance1).toNumber()).to.be.equal(
@@ -281,7 +281,7 @@ describe("UBIScheme", () => {
281
281
  });
282
282
 
283
283
  it("should return the reward value for entitlement user", async () => {
284
- let amount = await ubi.connect(claimer4).checkEntitlement();
284
+ let amount = await ubi.connect(claimer4)["checkEntitlement()"]();
285
285
  let claimAmount = await firstClaimPool.claimAmount();
286
286
  expect(amount.toString()).to.be.equal(claimAmount.toString());
287
287
  });
@@ -324,13 +324,13 @@ describe("UBIScheme", () => {
324
324
  it("should return the daily ubi for entitlement user", async () => {
325
325
  // claimer3 hasn't claimed during that interval so that user
326
326
  // may have the dailyUbi
327
- let amount = await ubi.connect(claimer3).checkEntitlement();
327
+ let amount = await ubi.connect(claimer3)["checkEntitlement()"]();
328
328
  let dailyUbi = await ubi.dailyUbi();
329
329
  expect(amount.toString()).to.be.equal(dailyUbi.toString());
330
330
  });
331
331
  it("should return 0 for entitlement if the user has already claimed for today", async () => {
332
332
  await ubi.connect(claimer4).claim();
333
- let amount = await ubi.connect(claimer4).checkEntitlement();
333
+ let amount = await ubi.connect(claimer4)["checkEntitlement()"]();
334
334
  expect(amount.toString()).to.be.equal("0");
335
335
  });
336
336
 
@@ -548,7 +548,7 @@ describe("UBIScheme", () => {
548
548
  await increaseTime(ONE_DAY);
549
549
  await ubi.connect(claimer1).claim();
550
550
  await increaseTime(ONE_DAY);
551
- let amount = await ubi.connect(claimer1).checkEntitlement();
551
+ let amount = await ubi.connect(claimer1)["checkEntitlement()"]();
552
552
  let balance2 = await goodDollar.balanceOf(ubi.address);
553
553
  let estimated = await ubi.estimateNextDailyUBI();
554
554
  expect(amount).to.be.equal(estimated);
@@ -99,4 +99,35 @@ describe("proxyfactory", () => {
99
99
  proxy = await ethers.getContractAt("UpgradableMock", proxyAddr);
100
100
  expect(await proxy.owner()).to.eq(signers[2].address);
101
101
  });
102
+
103
+ it("should not be able to re-initialize proxy", async () => {
104
+ const c1 = await (
105
+ await ethers.getContractFactory("UpgradableMock")
106
+ ).deploy();
107
+ const encoded = c1.interface.encodeFunctionData("initialize", [
108
+ signers[2].address
109
+ ]);
110
+
111
+ const deployTX = await (
112
+ await factory.deployProxy(4, c1.address, encoded)
113
+ ).wait();
114
+ const proxyAddr = deployTX.events.find(_ => _.event === "ProxyCreated").args
115
+ .proxy;
116
+ let proxy = await ethers.getContractAt("ERC1967Proxy", proxyAddr);
117
+
118
+ const c2 = await (
119
+ await ethers.getContractFactory("UpgradableMock")
120
+ ).deploy();
121
+
122
+ const encoded2 = c1.interface.encodeFunctionData("initialize", [
123
+ signers[3].address
124
+ ]);
125
+
126
+ await expect(
127
+ proxy["initialize(address,bytes)"](c2.address, encoded)
128
+ ).revertedWith("initialized");
129
+
130
+ let orgproxy = await ethers.getContractAt("UpgradableMock", proxyAddr);
131
+ expect(await orgproxy.owner()).to.eq(signers[2].address);
132
+ });
102
133
  });