@gooddollar/goodprotocol 1.0.7 → 1.0.8
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/artifacts/contracts/DAOStackInterfaces.sol/Avatar.dbg.json +1 -1
- package/artifacts/contracts/DAOStackInterfaces.sol/Controller.dbg.json +1 -1
- package/artifacts/contracts/DAOStackInterfaces.sol/GlobalConstraintInterface.dbg.json +1 -1
- package/artifacts/contracts/DAOStackInterfaces.sol/IntVoteInterface.dbg.json +1 -1
- package/artifacts/contracts/DAOStackInterfaces.sol/ReputationInterface.dbg.json +1 -1
- package/artifacts/contracts/DAOStackInterfaces.sol/SchemeRegistrar.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/AggregatorV3Interface.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/ERC20.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IAaveIncentivesController.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IAdminWallet.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IDonationStaking.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IERC2917.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IFirstClaimPool.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IGoodDollar.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IGoodStaking.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IHasRouter.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IIdentity.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/ILendingPool.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/INameService.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IUBIScheme.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/ProxyAdmin.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/Reserve.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/Staking.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/Uniswap.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/UniswapFactory.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/UniswapPair.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/cERC20.dbg.json +1 -1
- package/artifacts/contracts/governance/ClaimersDistribution.sol/ClaimersDistribution.dbg.json +1 -1
- package/artifacts/contracts/governance/ClaimersDistribution.sol/ClaimersDistribution.json +2 -2
- package/artifacts/contracts/governance/CompoundVotingMachine.sol/CompoundVotingMachine.dbg.json +1 -1
- package/artifacts/contracts/governance/GReputation.sol/GReputation.dbg.json +1 -1
- package/artifacts/contracts/governance/GReputation.sol/GReputation.json +62 -4
- package/artifacts/contracts/governance/GovarnanceStaking.sol/GovernanceStaking.dbg.json +1 -1
- package/artifacts/contracts/governance/MultiBaseGovernanceShareField.sol/MultiBaseGovernanceShareField.dbg.json +1 -1
- package/artifacts/contracts/governance/Reputation.sol/Reputation.dbg.json +1 -1
- package/artifacts/contracts/governance/Reputation.sol/Reputation.json +17 -17
- package/artifacts/contracts/governance/StakersDistribution.sol/StakersDistribution.dbg.json +1 -1
- package/artifacts/contracts/governance/StakersDistribution.sol/StakersDistribution.json +2 -2
- package/artifacts/contracts/mocks/AaveMock.sol/AaveMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/DAIMock.sol/DAIMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/DecimalsMock.sol/DecimalsMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.json +2 -2
- package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/IncentiveControllerMock.sol/IncentiveControllerMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/LendingPoolMock.sol/LendingPoolMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/OverMintTester.sol/OverMintTester.dbg.json +1 -1
- package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.dbg.json +1 -1
- package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.json +2 -2
- package/artifacts/contracts/mocks/SixteenDecimalsTokenMock.sol/SixteenDecimalsTokenMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/SwapHelperTest.sol/SwapHelperTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/TwentyDecimalsTokenMock.sol/TwentyDecimalsTokenMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock2.dbg.json +1 -1
- package/artifacts/contracts/mocks/UsdcMock.sol/USDCMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cBATMock.sol/cBATMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cDAILowWorthMock.sol/cDAILowWorthMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cDAIMock.sol/cDAIMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cDAINonMintableMock.sol/cDAINonMintableMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cDecimalsMock.sol/cDecimalsMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cSDTMock.sol/cSDTMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cUSDCMock.sol/cUSDCMock.dbg.json +1 -1
- package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.dbg.json +1 -1
- package/artifacts/contracts/reserve/GoodMarketMaker.sol/GoodMarketMaker.dbg.json +1 -1
- package/artifacts/contracts/reserve/GoodReserveCDai.sol/ContributionCalc.dbg.json +1 -1
- package/artifacts/contracts/reserve/GoodReserveCDai.sol/GoodReserveCDai.dbg.json +1 -1
- package/artifacts/contracts/staking/BaseShareField.sol/BaseShareField.dbg.json +1 -1
- package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.json +2 -2
- package/artifacts/contracts/staking/GoodFundManager.sol/GoodFundManager.dbg.json +1 -1
- package/artifacts/contracts/staking/SimpleStaking.sol/SimpleStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/UniswapV2SwapHelper.sol/UniswapV2SwapHelper.dbg.json +1 -1
- package/artifacts/contracts/staking/aave/AaveStakingFactory.sol/AaveStakingFactory.dbg.json +1 -1
- package/artifacts/contracts/staking/aave/AaveStakingFactory.sol/AaveStakingFactory.json +2 -2
- package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.json +2 -2
- package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.dbg.json +1 -1
- package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.json +2 -2
- package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.json +2 -2
- package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.dbg.json +1 -1
- package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.json +2 -2
- package/artifacts/contracts/unaudited-foundation/FuseFaucet.sol/FuseFaucet.dbg.json +1 -1
- package/artifacts/contracts/unaudited-foundation/InvitesV1.sol/InvitesV1.dbg.json +1 -1
- package/artifacts/contracts/utils/BancorFormula.sol/BancorFormula.dbg.json +1 -1
- package/artifacts/contracts/utils/DAOContract.sol/DAOContract.dbg.json +1 -1
- package/artifacts/contracts/utils/DAOUpgradeableContract.sol/DAOUpgradeableContract.dbg.json +1 -1
- package/artifacts/contracts/utils/DSMath.sol/DSMath.dbg.json +1 -1
- package/artifacts/contracts/utils/DataTypes.sol/DataTypes.dbg.json +1 -1
- package/artifacts/contracts/utils/NameService.sol/NameService.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgrade.sol/OldMarketMaker.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgrade.sol/ProtocolUpgrade.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgradeFuse.sol/ProtocolUpgradeFuse.dbg.json +1 -1
- package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.dbg.json +1 -1
- package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.json +2 -2
- package/contracts/governance/GReputation.sol +53 -14
- package/contracts/governance/Reputation.sol +13 -25
- package/package.json +1 -1
- package/releases/deployment.json +45 -45
- package/releases/olddao.json +1 -1
- package/scripts/misc/goodgiveback.ts +4 -5
- package/test/governance/ClaimersDistribution.test.ts +5 -5
- package/test/governance/CompoundVotingMachine.castvote.test.ts +1 -1
- package/test/governance/CompoundVotingMachine.daoscheme.ts +1 -1
- package/test/governance/CompoundVotingMachine.guardian.test.ts +1 -1
- package/test/governance/GReputation.test.ts +49 -18
- package/test/governance/GovernanceStaking.test.ts +71 -47
- package/test/governance/Reputation.test.ts +52 -51
- package/test/governance/StakersDistribution.test.ts +12 -8
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
CERC20,
|
|
8
8
|
GoodReserveCDai,
|
|
9
9
|
SimpleStaking,
|
|
10
|
-
GReputation
|
|
10
|
+
GReputation
|
|
11
11
|
} from "../../types";
|
|
12
12
|
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address";
|
|
13
13
|
import { createDAO, increaseTime, advanceBlocks } from "../helpers";
|
|
@@ -64,7 +64,7 @@ describe("GovernanceStaking - staking with GD and get Rewards in GDAO", () => {
|
|
|
64
64
|
cdaiAddress,
|
|
65
65
|
reserve,
|
|
66
66
|
reputation,
|
|
67
|
-
setReserveToken
|
|
67
|
+
setReserveToken
|
|
68
68
|
} = await createDAO();
|
|
69
69
|
dai = await ethers.getContractAt("DAIMock", daiAddress);
|
|
70
70
|
cDAI = await ethers.getContractAt("cDAIMock", cdaiAddress);
|
|
@@ -79,7 +79,7 @@ describe("GovernanceStaking - staking with GD and get Rewards in GDAO", () => {
|
|
|
79
79
|
gd,
|
|
80
80
|
identity,
|
|
81
81
|
controller,
|
|
82
|
-
avatar
|
|
82
|
+
avatar
|
|
83
83
|
});
|
|
84
84
|
goodFundManager = await upgrades.deployProxy(
|
|
85
85
|
goodFundManagerFactory,
|
|
@@ -91,7 +91,7 @@ describe("GovernanceStaking - staking with GD and get Rewards in GDAO", () => {
|
|
|
91
91
|
reputation
|
|
92
92
|
)) as GReputation;
|
|
93
93
|
console.log("Deployed goodfund manager", {
|
|
94
|
-
manager: goodFundManager.address
|
|
94
|
+
manager: goodFundManager.address
|
|
95
95
|
});
|
|
96
96
|
goodDollar = await ethers.getContractAt("IGoodDollar", gd);
|
|
97
97
|
contribution = await ethers.getContractAt(
|
|
@@ -102,7 +102,7 @@ describe("GovernanceStaking - staking with GD and get Rewards in GDAO", () => {
|
|
|
102
102
|
marketMaker = mm;
|
|
103
103
|
|
|
104
104
|
console.log("deployed contribution, deploying reserve...", {
|
|
105
|
-
founder: founder.address
|
|
105
|
+
founder: founder.address
|
|
106
106
|
});
|
|
107
107
|
|
|
108
108
|
console.log("setting permissions...");
|
|
@@ -125,7 +125,7 @@ describe("GovernanceStaking - staking with GD and get Rewards in GDAO", () => {
|
|
|
125
125
|
await goodDollar.approve(governanceStaking.address, "100");
|
|
126
126
|
await governanceStaking.stake("100");
|
|
127
127
|
await advanceBlocks(5);
|
|
128
|
-
const error = await governanceStaking.withdrawStake("100").catch(
|
|
128
|
+
const error = await governanceStaking.withdrawStake("100").catch(e => e);
|
|
129
129
|
expect(error.message).to.have.string(
|
|
130
130
|
"GReputation: need minter role or be GDAO contract"
|
|
131
131
|
);
|
|
@@ -133,9 +133,11 @@ describe("GovernanceStaking - staking with GD and get Rewards in GDAO", () => {
|
|
|
133
133
|
|
|
134
134
|
it("Should be able mint rewards after set GDAO staking contract", async () => {
|
|
135
135
|
await setDAOAddress("GDAO_STAKING", governanceStaking.address);
|
|
136
|
-
const GDAOBalanceBeforeWithdraw = await grep.
|
|
136
|
+
const GDAOBalanceBeforeWithdraw = await grep.balanceOfLocal(
|
|
137
|
+
founder.address
|
|
138
|
+
);
|
|
137
139
|
await governanceStaking.withdrawStake("100");
|
|
138
|
-
const GDAOBalanceAfterWithdraw = await grep.
|
|
140
|
+
const GDAOBalanceAfterWithdraw = await grep.balanceOfLocal(founder.address);
|
|
139
141
|
|
|
140
142
|
expect(GDAOBalanceAfterWithdraw).to.gt(GDAOBalanceBeforeWithdraw);
|
|
141
143
|
});
|
|
@@ -163,10 +165,12 @@ describe("GovernanceStaking - staking with GD and get Rewards in GDAO", () => {
|
|
|
163
165
|
const stakeBlockNumber = (await ethers.provider.getBlockNumber()) + 1;
|
|
164
166
|
await governanceStaking.stake("100");
|
|
165
167
|
await advanceBlocks(4);
|
|
166
|
-
const GDAOBalanceBeforeWithdraw = await grep.
|
|
168
|
+
const GDAOBalanceBeforeWithdraw = await grep.balanceOfLocal(
|
|
169
|
+
founder.address
|
|
170
|
+
);
|
|
167
171
|
await governanceStaking.withdrawStake("100");
|
|
168
172
|
const withdrawBlockNumber = await ethers.provider.getBlockNumber();
|
|
169
|
-
const GDAOBalanceAfterWithdraw = await grep.
|
|
173
|
+
const GDAOBalanceAfterWithdraw = await grep.balanceOfLocal(founder.address);
|
|
170
174
|
const multiplier = withdrawBlockNumber - stakeBlockNumber;
|
|
171
175
|
const calculatedReward = rewardsPerBlock.mul(multiplier); // We calculate user rewards since it's the only staker so gets whole rewards so rewardsPerBlock * multipler(block that passed between stake and withdraw)
|
|
172
176
|
expect(GDAOBalanceAfterWithdraw).to.be.equal(
|
|
@@ -186,18 +190,20 @@ describe("GovernanceStaking - staking with GD and get Rewards in GDAO", () => {
|
|
|
186
190
|
const stakeBlockNumber = (await ethers.provider.getBlockNumber()) + 1;
|
|
187
191
|
await governanceStaking.stake("100");
|
|
188
192
|
await advanceBlocks(4);
|
|
189
|
-
const GDAOBalanceBeforeWithdraw = await grep.
|
|
193
|
+
const GDAOBalanceBeforeWithdraw = await grep.balanceOfLocal(
|
|
194
|
+
founder.address
|
|
195
|
+
);
|
|
190
196
|
const transaction = await (
|
|
191
197
|
await governanceStaking.withdrawRewards()
|
|
192
198
|
).wait();
|
|
193
199
|
const withdrawBlockNumber = await ethers.provider.getBlockNumber();
|
|
194
|
-
const GDAOBalanceAfterWithdraw = await grep.
|
|
200
|
+
const GDAOBalanceAfterWithdraw = await grep.balanceOfLocal(founder.address);
|
|
195
201
|
const multiplier = withdrawBlockNumber - stakeBlockNumber;
|
|
196
202
|
const calculatedReward = rewardsPerBlock.mul(multiplier); // We calculate user rewards since it's the only staker so gets whole rewards so rewardsPerBlock * multipler(block that passed between stake and withdraw)
|
|
197
203
|
expect(GDAOBalanceAfterWithdraw).to.be.equal(
|
|
198
204
|
GDAOBalanceBeforeWithdraw.add(calculatedReward)
|
|
199
205
|
);
|
|
200
|
-
expect(transaction.events.find(
|
|
206
|
+
expect(transaction.events.find(_ => _.event === "ReputationEarned")).to.be
|
|
201
207
|
.not.empty;
|
|
202
208
|
await governanceStaking.withdrawStake("100");
|
|
203
209
|
});
|
|
@@ -209,9 +215,11 @@ describe("GovernanceStaking - staking with GD and get Rewards in GDAO", () => {
|
|
|
209
215
|
await advanceBlocks(4);
|
|
210
216
|
await governanceStaking.connect(staker).transfer(founder.address, "100");
|
|
211
217
|
await governanceStaking.connect(staker).withdrawRewards();
|
|
212
|
-
const gdaoBalanceBeforeWithdraw = await grep.
|
|
218
|
+
const gdaoBalanceBeforeWithdraw = await grep.balanceOfLocal(
|
|
219
|
+
founder.address
|
|
220
|
+
);
|
|
213
221
|
await governanceStaking.withdrawStake("100");
|
|
214
|
-
const gdaoBalanceAfterWithdraw = await grep.
|
|
222
|
+
const gdaoBalanceAfterWithdraw = await grep.balanceOfLocal(founder.address);
|
|
215
223
|
expect(gdaoBalanceAfterWithdraw).to.gt(gdaoBalanceBeforeWithdraw);
|
|
216
224
|
});
|
|
217
225
|
|
|
@@ -219,7 +227,7 @@ describe("GovernanceStaking - staking with GD and get Rewards in GDAO", () => {
|
|
|
219
227
|
let transaction = await governanceStaking
|
|
220
228
|
.connect(staker)
|
|
221
229
|
.withdrawStake("100")
|
|
222
|
-
.catch(
|
|
230
|
+
.catch(e => e);
|
|
223
231
|
expect(transaction.message).to.have.string("Not enough token staked");
|
|
224
232
|
});
|
|
225
233
|
|
|
@@ -243,10 +251,12 @@ describe("GovernanceStaking - staking with GD and get Rewards in GDAO", () => {
|
|
|
243
251
|
const stakeBlockNumber = (await ethers.provider.getBlockNumber()) + 1;
|
|
244
252
|
await governanceStaking.stake("100");
|
|
245
253
|
await advanceBlocks(4);
|
|
246
|
-
const GDAOBalanceBeforeWithdraw = await grep.
|
|
254
|
+
const GDAOBalanceBeforeWithdraw = await grep.balanceOfLocal(
|
|
255
|
+
founder.address
|
|
256
|
+
);
|
|
247
257
|
await governanceStaking.withdrawStake("100");
|
|
248
258
|
const withdrawBlockNumber = await ethers.provider.getBlockNumber();
|
|
249
|
-
const GDAOBalanceAfterWithdraw = await grep.
|
|
259
|
+
const GDAOBalanceAfterWithdraw = await grep.balanceOfLocal(founder.address);
|
|
250
260
|
const multiplier = withdrawBlockNumber - stakeBlockNumber;
|
|
251
261
|
const calculatedReward = rewardsPerBlock.mul(multiplier); // We calculate user rewards since it's the only staker so gets whole rewards so rewardsPerBlock * multipler(block that passed between stake and withdraw)
|
|
252
262
|
expect(GDAOBalanceAfterWithdraw).to.be.equal(
|
|
@@ -277,9 +287,11 @@ describe("GovernanceStaking - staking with GD and get Rewards in GDAO", () => {
|
|
|
277
287
|
](founder.address);
|
|
278
288
|
expect(userProductivity[0]).to.be.equal(BN.from("100"));
|
|
279
289
|
await advanceBlocks(4);
|
|
280
|
-
const GDAOBalanceBeforeWithdraw = await grep.
|
|
290
|
+
const GDAOBalanceBeforeWithdraw = await grep.balanceOfLocal(
|
|
291
|
+
founder.address
|
|
292
|
+
);
|
|
281
293
|
await governanceStaking.withdrawStake("100");
|
|
282
|
-
const GDAOBalanceAfterWithdraw = await grep.
|
|
294
|
+
const GDAOBalanceAfterWithdraw = await grep.balanceOfLocal(founder.address);
|
|
283
295
|
expect(GDAOBalanceAfterWithdraw.sub(GDAOBalanceBeforeWithdraw)).to.equal(0);
|
|
284
296
|
encodedCall = governanceStakingFactory.interface.encodeFunctionData(
|
|
285
297
|
"setMonthlyRewards",
|
|
@@ -325,10 +337,12 @@ describe("GovernanceStaking - staking with GD and get Rewards in GDAO", () => {
|
|
|
325
337
|
const stakeBlockNumber = (await ethers.provider.getBlockNumber()) + 1;
|
|
326
338
|
await governanceStaking.stake("1000000000000");
|
|
327
339
|
await advanceBlocks(4);
|
|
328
|
-
const GDAOBalanceBeforeWithdraw = await grep.
|
|
340
|
+
const GDAOBalanceBeforeWithdraw = await grep.balanceOfLocal(
|
|
341
|
+
founder.address
|
|
342
|
+
);
|
|
329
343
|
await governanceStaking.withdrawStake("1000000000000");
|
|
330
344
|
const withdrawBlockNumber = await ethers.provider.getBlockNumber();
|
|
331
|
-
const GDAOBalanceAfterWithdraw = await grep.
|
|
345
|
+
const GDAOBalanceAfterWithdraw = await grep.balanceOfLocal(founder.address);
|
|
332
346
|
const multiplier = withdrawBlockNumber - stakeBlockNumber;
|
|
333
347
|
const calculatedReward = rewardsPerBlock.mul(multiplier); // We calculate user rewards since it's the only staker so gets whole rewards so rewardsPerBlock * multipler(block that passed between stake and withdraw)
|
|
334
348
|
expect(GDAOBalanceAfterWithdraw).to.be.equal(
|
|
@@ -347,15 +361,15 @@ describe("GovernanceStaking - staking with GD and get Rewards in GDAO", () => {
|
|
|
347
361
|
(await ethers.provider.getBlockNumber()) + 1;
|
|
348
362
|
await governanceStaking.connect(staker).stake("200");
|
|
349
363
|
await advanceBlocks(4);
|
|
350
|
-
const GDAOBalanceBeforeWithdraw = await grep.
|
|
351
|
-
const FounderGDAOBalanceBeforeWithdraw = await grep.
|
|
364
|
+
const GDAOBalanceBeforeWithdraw = await grep.balanceOfLocal(staker.address);
|
|
365
|
+
const FounderGDAOBalanceBeforeWithdraw = await grep.balanceOfLocal(
|
|
352
366
|
founder.address
|
|
353
367
|
);
|
|
354
368
|
await governanceStaking.withdrawStake("800");
|
|
355
369
|
const founderWithdrawBlockNumber = await ethers.provider.getBlockNumber();
|
|
356
370
|
await governanceStaking.connect(staker).withdrawStake("200");
|
|
357
|
-
const GDAOBalanceAfterWithdraw = await grep.
|
|
358
|
-
const FounderGDAOBalanceAfterWithdraw = await grep.
|
|
371
|
+
const GDAOBalanceAfterWithdraw = await grep.balanceOfLocal(staker.address);
|
|
372
|
+
const FounderGDAOBalanceAfterWithdraw = await grep.balanceOfLocal(
|
|
359
373
|
founder.address
|
|
360
374
|
);
|
|
361
375
|
const founderCalculatedRewards = rewardsPerBlock.add(
|
|
@@ -558,7 +572,7 @@ describe("GovernanceStaking - staking with GD and get Rewards in GDAO", () => {
|
|
|
558
572
|
});
|
|
559
573
|
|
|
560
574
|
it("Stake amount should be positive", async () => {
|
|
561
|
-
const tx = await governanceStaking.stake("0").catch(
|
|
575
|
+
const tx = await governanceStaking.stake("0").catch(e => e);
|
|
562
576
|
expect(tx.message).to.have.string(
|
|
563
577
|
"You need to stake a positive token amount"
|
|
564
578
|
);
|
|
@@ -567,7 +581,7 @@ describe("GovernanceStaking - staking with GD and get Rewards in GDAO", () => {
|
|
|
567
581
|
it("It should approve stake amount in order to stake", async () => {
|
|
568
582
|
const tx = await governanceStaking
|
|
569
583
|
.stake(ethers.utils.parseEther("10000000"))
|
|
570
|
-
.catch(
|
|
584
|
+
.catch(e => e);
|
|
571
585
|
expect(tx.message).not.to.be.empty;
|
|
572
586
|
});
|
|
573
587
|
|
|
@@ -594,10 +608,14 @@ describe("GovernanceStaking - staking with GD and get Rewards in GDAO", () => {
|
|
|
594
608
|
const stakeBlockNumber = (await ethers.provider.getBlockNumber()) + 1;
|
|
595
609
|
await governanceStaking.stake("100");
|
|
596
610
|
await advanceBlocks(5);
|
|
597
|
-
const gdaoBalanceBeforeGetRewards = await grep.
|
|
611
|
+
const gdaoBalanceBeforeGetRewards = await grep.balanceOfLocal(
|
|
612
|
+
founder.address
|
|
613
|
+
);
|
|
598
614
|
await governanceStaking.stake("100");
|
|
599
615
|
const getRewardsBlockNumber = await ethers.provider.getBlockNumber();
|
|
600
|
-
const gdaoBalanceAfterGetRewards = await grep.
|
|
616
|
+
const gdaoBalanceAfterGetRewards = await grep.balanceOfLocal(
|
|
617
|
+
founder.address
|
|
618
|
+
);
|
|
601
619
|
const multiplier = getRewardsBlockNumber - stakeBlockNumber;
|
|
602
620
|
const calculatedReward = rewardsPerBlock.mul(multiplier); // We calculate user rewards since it's the only staker so gets whole rewards so rewardsPerBlock * multipler(block that passed between stake and withdraw)
|
|
603
621
|
await governanceStaking.withdrawStake("200");
|
|
@@ -624,43 +642,45 @@ describe("GovernanceStaking - staking with GD and get Rewards in GDAO", () => {
|
|
|
624
642
|
.connect(signers[1])
|
|
625
643
|
.approve(governanceStaking.address, stakingAmount);
|
|
626
644
|
await governanceStaking.stake(stakingAmount);
|
|
627
|
-
const stakerOneGDAOBalanceAfterStake = await grep.
|
|
645
|
+
const stakerOneGDAOBalanceAfterStake = await grep.balanceOfLocal(
|
|
628
646
|
founder.address
|
|
629
647
|
);
|
|
630
648
|
await governanceStaking.connect(staker).stake(stakingAmount.div(10));
|
|
631
|
-
const stakerTwoGDAOBalanceAfterStake = await grep.
|
|
649
|
+
const stakerTwoGDAOBalanceAfterStake = await grep.balanceOfLocal(
|
|
650
|
+
staker.address
|
|
651
|
+
);
|
|
632
652
|
await governanceStaking.connect(signers[0]).stake(stakingAmount.div(4));
|
|
633
|
-
const stakerThreeGDAOBalanceAfterStake = await grep.
|
|
653
|
+
const stakerThreeGDAOBalanceAfterStake = await grep.balanceOfLocal(
|
|
634
654
|
signers[0].address
|
|
635
655
|
);
|
|
636
656
|
const stakerFourStakeBlockNumber =
|
|
637
657
|
(await ethers.provider.getBlockNumber()) + 1;
|
|
638
658
|
await governanceStaking.connect(signers[1]).stake(stakingAmount.div(5));
|
|
639
|
-
const stakerFourGDAOBalanceAfterStake = await grep.
|
|
659
|
+
const stakerFourGDAOBalanceAfterStake = await grep.balanceOfLocal(
|
|
640
660
|
signers[1].address
|
|
641
661
|
);
|
|
642
662
|
await advanceBlocks(10);
|
|
643
663
|
await governanceStaking.withdrawStake(stakingAmount);
|
|
644
664
|
const stakerOneWithdrawBlockNumber = await ethers.provider.getBlockNumber();
|
|
645
|
-
const stakerOneGDAOBalanceAfterWithdraw = await grep.
|
|
665
|
+
const stakerOneGDAOBalanceAfterWithdraw = await grep.balanceOfLocal(
|
|
646
666
|
founder.address
|
|
647
667
|
);
|
|
648
668
|
await governanceStaking
|
|
649
669
|
.connect(staker)
|
|
650
670
|
.withdrawStake(stakingAmount.div(10));
|
|
651
|
-
const stakerTwoGDAOBalanceAfterWithdraw = await grep.
|
|
671
|
+
const stakerTwoGDAOBalanceAfterWithdraw = await grep.balanceOfLocal(
|
|
652
672
|
staker.address
|
|
653
673
|
);
|
|
654
674
|
await governanceStaking
|
|
655
675
|
.connect(signers[0])
|
|
656
676
|
.withdrawStake(stakingAmount.div(4));
|
|
657
|
-
const stakerThreeGDAOBalanceAfterWithdraw = await grep.
|
|
677
|
+
const stakerThreeGDAOBalanceAfterWithdraw = await grep.balanceOfLocal(
|
|
658
678
|
signers[0].address
|
|
659
679
|
);
|
|
660
680
|
await governanceStaking
|
|
661
681
|
.connect(signers[1])
|
|
662
682
|
.withdrawStake(stakingAmount.div(5));
|
|
663
|
-
const stakerFourGDAOBalanceAfterWithdraw = await grep.
|
|
683
|
+
const stakerFourGDAOBalanceAfterWithdraw = await grep.balanceOfLocal(
|
|
664
684
|
signers[1].address
|
|
665
685
|
);
|
|
666
686
|
const stakerOneRewardsCalculated = rewardsPerBlock
|
|
@@ -729,13 +749,15 @@ describe("GovernanceStaking - staking with GD and get Rewards in GDAO", () => {
|
|
|
729
749
|
.connect(staker)
|
|
730
750
|
.approve(governanceStaking.address, stakingAmount);
|
|
731
751
|
await governanceStaking.stake(stakingAmount);
|
|
732
|
-
const stakerOneGDAOBalanceAfterStake = await grep.
|
|
752
|
+
const stakerOneGDAOBalanceAfterStake = await grep.balanceOfLocal(
|
|
733
753
|
founder.address
|
|
734
754
|
);
|
|
735
755
|
const stakerTwoStakeBlockNumber =
|
|
736
756
|
(await ethers.provider.getBlockNumber()) + 1;
|
|
737
757
|
await governanceStaking.connect(staker).stake(stakingAmount.div(10000));
|
|
738
|
-
const stakerTwoGDAOBalanceAfterStake = await grep.
|
|
758
|
+
const stakerTwoGDAOBalanceAfterStake = await grep.balanceOfLocal(
|
|
759
|
+
staker.address
|
|
760
|
+
);
|
|
739
761
|
await advanceBlocks(10);
|
|
740
762
|
|
|
741
763
|
await governanceStaking
|
|
@@ -744,10 +766,10 @@ describe("GovernanceStaking - staking with GD and get Rewards in GDAO", () => {
|
|
|
744
766
|
const stakerTwoWithdrawBlockNumber = await ethers.provider.getBlockNumber();
|
|
745
767
|
await governanceStaking.withdrawStake(stakingAmount);
|
|
746
768
|
|
|
747
|
-
const stakerOneGDAOBalanceAfterWithdraw = await grep.
|
|
769
|
+
const stakerOneGDAOBalanceAfterWithdraw = await grep.balanceOfLocal(
|
|
748
770
|
founder.address
|
|
749
771
|
);
|
|
750
|
-
const stakerTwoGDAOBalanceAfterWithdraw = await grep.
|
|
772
|
+
const stakerTwoGDAOBalanceAfterWithdraw = await grep.balanceOfLocal(
|
|
751
773
|
staker.address
|
|
752
774
|
);
|
|
753
775
|
const calculatedRewardsStakerOne = rewardsPerBlock
|
|
@@ -785,11 +807,11 @@ describe("GovernanceStaking - staking with GD and get Rewards in GDAO", () => {
|
|
|
785
807
|
|
|
786
808
|
const stakeBlockNumber = (await ethers.provider.getBlockNumber()) + 1;
|
|
787
809
|
await simpleGovernanceStaking.stake("200");
|
|
788
|
-
const GDAOBalanceAfterStake = await grep.
|
|
810
|
+
const GDAOBalanceAfterStake = await grep.balanceOfLocal(founder.address);
|
|
789
811
|
await advanceBlocks(100);
|
|
790
812
|
await simpleGovernanceStaking.withdrawRewards();
|
|
791
813
|
const withdrawRewardsBlockNumber = await ethers.provider.getBlockNumber();
|
|
792
|
-
const GDAOBalanceAfterWithdraw = await grep.
|
|
814
|
+
const GDAOBalanceAfterWithdraw = await grep.balanceOfLocal(founder.address);
|
|
793
815
|
|
|
794
816
|
expect(GDAOBalanceAfterWithdraw).to.be.equal(
|
|
795
817
|
GDAOBalanceAfterStake.add(
|
|
@@ -819,18 +841,20 @@ describe("GovernanceStaking - staking with GD and get Rewards in GDAO", () => {
|
|
|
819
841
|
const rewardsPerBlock = await simpleGovernanceStaking.getRewardsPerBlock();
|
|
820
842
|
const stakeBlockNumber = (await ethers.provider.getBlockNumber()) + 1;
|
|
821
843
|
await overMintTester.stake();
|
|
822
|
-
const GDAOBalanceAfterStake = await grep.
|
|
844
|
+
const GDAOBalanceAfterStake = await grep.balanceOfLocal(
|
|
845
|
+
overMintTester.address
|
|
846
|
+
);
|
|
823
847
|
await advanceBlocks(100);
|
|
824
848
|
await overMintTester.overMintTest();
|
|
825
849
|
const withdrawRewardsBlockNumber = await ethers.provider.getBlockNumber();
|
|
826
|
-
const GDAOBalanceAfterWithdrawReward = await grep.
|
|
850
|
+
const GDAOBalanceAfterWithdrawReward = await grep.balanceOfLocal(
|
|
827
851
|
overMintTester.address
|
|
828
852
|
);
|
|
829
853
|
await advanceBlocks(20);
|
|
830
854
|
await overMintTester.overMintTest();
|
|
831
855
|
const secondWithdrawRewardsBlockNumber =
|
|
832
856
|
await ethers.provider.getBlockNumber();
|
|
833
|
-
const GDAOBalanceAfterSecondWithdrawReward = await grep.
|
|
857
|
+
const GDAOBalanceAfterSecondWithdrawReward = await grep.balanceOfLocal(
|
|
834
858
|
overMintTester.address
|
|
835
859
|
);
|
|
836
860
|
|
|
@@ -31,7 +31,7 @@ describe("Reputation", () => {
|
|
|
31
31
|
let value;
|
|
32
32
|
await reputation.mint(acct.address, 3131);
|
|
33
33
|
|
|
34
|
-
value = await reputation.
|
|
34
|
+
value = await reputation.balanceOfLocal(acct.address);
|
|
35
35
|
expect(value).to.equal(3131);
|
|
36
36
|
});
|
|
37
37
|
|
|
@@ -50,10 +50,10 @@ describe("Reputation", () => {
|
|
|
50
50
|
await expect(reputation.connect(signers[2]).mint(signers[2], 1000)).to
|
|
51
51
|
.reverted;
|
|
52
52
|
|
|
53
|
-
let account0Rep = await reputation.
|
|
54
|
-
let account1Rep = await reputation.
|
|
55
|
-
let account2Rep = await reputation.
|
|
56
|
-
let totalRep = await reputation.
|
|
53
|
+
let account0Rep = await reputation.balanceOfLocal(signers[0].address);
|
|
54
|
+
let account1Rep = await reputation.balanceOfLocal(signers[1].address);
|
|
55
|
+
let account2Rep = await reputation.balanceOfLocal(signers[2].address);
|
|
56
|
+
let totalRep = await reputation.totalSupplyLocal();
|
|
57
57
|
|
|
58
58
|
expect(account1Rep).to.equal(1000, "account 1 reputation should be 1000");
|
|
59
59
|
expect(account2Rep).to.equal(0, "account 2 reputation should be 0");
|
|
@@ -71,9 +71,9 @@ describe("Reputation", () => {
|
|
|
71
71
|
await reputation.mint(signers[2].address, 3000);
|
|
72
72
|
|
|
73
73
|
// this tx should have no effect
|
|
74
|
-
let account0Rep = await reputation.
|
|
75
|
-
let account1Rep = await reputation.
|
|
76
|
-
let account2Rep = await reputation.
|
|
74
|
+
let account0Rep = await reputation.balanceOfLocal(signers[0].address);
|
|
75
|
+
let account1Rep = await reputation.balanceOfLocal(signers[1].address);
|
|
76
|
+
let account2Rep = await reputation.balanceOfLocal(signers[2].address);
|
|
77
77
|
|
|
78
78
|
// expect(account0Rep, 2001, "account 0 reputation should be 2000");
|
|
79
79
|
expect(account1Rep).to.equal(
|
|
@@ -82,7 +82,7 @@ describe("Reputation", () => {
|
|
|
82
82
|
);
|
|
83
83
|
expect(account2Rep).to.equal(3000, "account 2 reputation should be 3000");
|
|
84
84
|
|
|
85
|
-
let totalRep = await reputation.
|
|
85
|
+
let totalRep = await reputation.totalSupplyLocal();
|
|
86
86
|
|
|
87
87
|
expect(totalRep).to.equal(
|
|
88
88
|
account0Rep.add(account1Rep).add(account2Rep),
|
|
@@ -96,23 +96,22 @@ describe("Reputation", () => {
|
|
|
96
96
|
.catch(e => e);
|
|
97
97
|
expect(tx.message).to.have.string("Reputation: need minter role");
|
|
98
98
|
});
|
|
99
|
-
it("user should be able to burn their own reputation",async()=>{
|
|
100
|
-
await reputation
|
|
101
|
-
|
|
99
|
+
it("user should be able to burn their own reputation", async () => {
|
|
100
|
+
await reputation
|
|
101
|
+
.connect(signers[0])
|
|
102
|
+
.burn(signers[0].address, ethers.utils.parseEther("1"));
|
|
103
|
+
});
|
|
102
104
|
it("check total reputation overflow", async () => {
|
|
103
105
|
let BigNumber = ethers.BigNumber;
|
|
104
|
-
let bigNum = BigNumber.from(2)
|
|
105
|
-
.pow(128)
|
|
106
|
-
.sub(1)
|
|
107
|
-
.toString();
|
|
106
|
+
let bigNum = BigNumber.from(2).pow(128).sub(1).toString();
|
|
108
107
|
|
|
109
108
|
await reputation.mint(signers[0].address, bigNum);
|
|
110
109
|
|
|
111
|
-
let totalRepBefore = await reputation.
|
|
110
|
+
let totalRepBefore = await reputation.totalSupplyLocal();
|
|
112
111
|
|
|
113
112
|
await expect(reputation.mint(signers[1].address, 1)).to.reverted;
|
|
114
113
|
|
|
115
|
-
let totalRepAfter = await reputation.
|
|
114
|
+
let totalRepAfter = await reputation.totalSupplyLocal();
|
|
116
115
|
|
|
117
116
|
expect(totalRepBefore).to.equal(totalRepAfter);
|
|
118
117
|
});
|
|
@@ -122,15 +121,15 @@ describe("Reputation", () => {
|
|
|
122
121
|
await reputation.mint(signers[1].address, 1500);
|
|
123
122
|
await reputation.burn(signers[1].address, 500);
|
|
124
123
|
|
|
125
|
-
value = await reputation.
|
|
126
|
-
let totalRepSupply = await reputation.
|
|
124
|
+
value = await reputation.balanceOfLocal(signers[1].address);
|
|
125
|
+
let totalRepSupply = await reputation.totalSupplyLocal();
|
|
127
126
|
|
|
128
127
|
expect(value).to.equal(1000);
|
|
129
128
|
expect(totalRepSupply).to.equal(1000);
|
|
130
129
|
});
|
|
131
130
|
|
|
132
131
|
it("totalSupply is 0 on init", async () => {
|
|
133
|
-
const totalSupply = await reputation.
|
|
132
|
+
const totalSupply = await reputation.totalSupplyLocal();
|
|
134
133
|
|
|
135
134
|
expect(totalSupply).to.equal(0);
|
|
136
135
|
});
|
|
@@ -163,12 +162,12 @@ describe("Reputation", () => {
|
|
|
163
162
|
|
|
164
163
|
it("mint (plus) should be reflected in totalSupply", async () => {
|
|
165
164
|
await reputation.mint(signers[1].address, 1000);
|
|
166
|
-
let totalSupply = await reputation.
|
|
165
|
+
let totalSupply = await reputation.totalSupplyLocal();
|
|
167
166
|
|
|
168
167
|
expect(totalSupply).to.equal(1000);
|
|
169
168
|
|
|
170
169
|
await reputation.mint(signers[2].address, 500);
|
|
171
|
-
totalSupply = await reputation.
|
|
170
|
+
totalSupply = await reputation.totalSupplyLocal();
|
|
172
171
|
|
|
173
172
|
expect(totalSupply).to.equal(1500);
|
|
174
173
|
});
|
|
@@ -176,22 +175,22 @@ describe("Reputation", () => {
|
|
|
176
175
|
it("mint (plus) should be reflected in balances", async () => {
|
|
177
176
|
await reputation.mint(signers[1].address, 1000);
|
|
178
177
|
|
|
179
|
-
const amount = await reputation.
|
|
178
|
+
const amount = await reputation.balanceOfLocal(signers[1].address);
|
|
180
179
|
|
|
181
180
|
expect(amount).to.equal(1000);
|
|
182
181
|
});
|
|
183
182
|
|
|
184
183
|
it("mint (minus) should be reflected in totalSupply", async () => {
|
|
185
184
|
await reputation.mint(signers[1].address, 1000);
|
|
186
|
-
let totalSupply = await reputation.
|
|
185
|
+
let totalSupply = await reputation.totalSupplyLocal();
|
|
187
186
|
expect(totalSupply).to.equal(1000);
|
|
188
187
|
|
|
189
188
|
await reputation.burn(signers[1].address, 500);
|
|
190
|
-
totalSupply = await reputation.
|
|
189
|
+
totalSupply = await reputation.totalSupplyLocal();
|
|
191
190
|
expect(totalSupply).to.equal(500);
|
|
192
191
|
|
|
193
192
|
await reputation.burn(signers[1].address, 700);
|
|
194
|
-
totalSupply = await reputation.
|
|
193
|
+
totalSupply = await reputation.totalSupplyLocal();
|
|
195
194
|
expect(totalSupply).to.equal(0);
|
|
196
195
|
});
|
|
197
196
|
|
|
@@ -199,31 +198,31 @@ describe("Reputation", () => {
|
|
|
199
198
|
await reputation.mint(signers[1].address, 1000);
|
|
200
199
|
await reputation.burn(signers[1].address, 500);
|
|
201
200
|
|
|
202
|
-
let amount = await reputation.
|
|
201
|
+
let amount = await reputation.balanceOfLocal(signers[1].address);
|
|
203
202
|
|
|
204
203
|
expect(amount).to.equal(500);
|
|
205
204
|
|
|
206
205
|
await reputation.burn(signers[1].address, 700);
|
|
207
|
-
amount = await reputation.
|
|
206
|
+
amount = await reputation.balanceOfLocal(signers[1].address);
|
|
208
207
|
expect(amount).to.equal(0);
|
|
209
208
|
});
|
|
210
209
|
|
|
211
210
|
it("account balance cannot be negative", async () => {
|
|
212
211
|
await reputation.mint(signers[1].address, 1);
|
|
213
212
|
|
|
214
|
-
let amount = await reputation.
|
|
213
|
+
let amount = await reputation.balanceOfLocal(signers[1].address);
|
|
215
214
|
expect(amount).to.equal(1);
|
|
216
215
|
await reputation.burn(signers[1].address, 2);
|
|
217
|
-
let rep = await reputation.
|
|
216
|
+
let rep = await reputation.balanceOfLocal(signers[1].address);
|
|
218
217
|
expect(rep).to.equal(0);
|
|
219
218
|
});
|
|
220
219
|
|
|
221
220
|
it("totalSupply cannot be negative", async () => {
|
|
222
221
|
await reputation.mint(signers[1].address, 1);
|
|
223
|
-
let amount = await reputation.
|
|
222
|
+
let amount = await reputation.totalSupplyLocal();
|
|
224
223
|
expect(amount).to.equal(1);
|
|
225
224
|
await reputation.burn(signers[1].address, 2);
|
|
226
|
-
let rep = await reputation.
|
|
225
|
+
let rep = await reputation.totalSupplyLocal();
|
|
227
226
|
expect(rep).to.equal(0);
|
|
228
227
|
});
|
|
229
228
|
|
|
@@ -236,9 +235,9 @@ describe("Reputation", () => {
|
|
|
236
235
|
await reputation.mint(signers[2].address, rep2);
|
|
237
236
|
await reputation.mint(signers[3].address, rep3);
|
|
238
237
|
|
|
239
|
-
const balanceOf1 = await reputation.
|
|
240
|
-
const balanceOf2 = await reputation.
|
|
241
|
-
const balanceOf3 = await reputation.
|
|
238
|
+
const balanceOf1 = await reputation.balanceOfLocal(signers[1].address);
|
|
239
|
+
const balanceOf2 = await reputation.balanceOfLocal(signers[2].address);
|
|
240
|
+
const balanceOf3 = await reputation.balanceOfLocal(signers[3].address);
|
|
242
241
|
|
|
243
242
|
expect(balanceOf1).to.equal(rep1);
|
|
244
243
|
expect(balanceOf2).to.equal(rep2);
|
|
@@ -250,19 +249,21 @@ describe("Reputation", () => {
|
|
|
250
249
|
await reputation.mint(signers[1].address, rep1);
|
|
251
250
|
var tx = await (await reputation.mint(signers[1].address, rep1)).wait();
|
|
252
251
|
await reputation.mint(signers[3].address, rep1);
|
|
253
|
-
expect(await reputation.
|
|
254
|
-
expect(await reputation.
|
|
252
|
+
expect(await reputation.totalSupplyLocal()).to.equal(rep1 + rep1 + rep1);
|
|
253
|
+
expect(await reputation.totalSupplyLocalAt(tx.blockNumber)).to.equal(
|
|
255
254
|
rep1 + rep1
|
|
256
255
|
);
|
|
257
|
-
expect(await reputation.
|
|
256
|
+
expect(await reputation.totalSupplyLocalAt(tx.blockNumber - 1)).to.equal(
|
|
257
|
+
rep1
|
|
258
|
+
);
|
|
258
259
|
expect(
|
|
259
|
-
await reputation.
|
|
260
|
+
await reputation.balanceOfLocalAt(signers[1].address, tx.blockNumber)
|
|
260
261
|
).to.equal(rep1 + rep1);
|
|
261
262
|
expect(
|
|
262
|
-
await reputation.
|
|
263
|
+
await reputation.balanceOfLocalAt(signers[1].address, tx.blockNumber - 1)
|
|
263
264
|
).to.equal(rep1);
|
|
264
265
|
expect(
|
|
265
|
-
await reputation.
|
|
266
|
+
await reputation.balanceOfLocalAt(signers[3].address, tx.blockNumber)
|
|
266
267
|
).to.equal(0);
|
|
267
268
|
});
|
|
268
269
|
|
|
@@ -281,28 +282,28 @@ describe("Reputation", () => {
|
|
|
281
282
|
var times = 3;
|
|
282
283
|
|
|
283
284
|
await reputationTestHelper.multipleMint(signers[1].address, rep, times);
|
|
284
|
-
expect(await reputation.
|
|
285
|
-
expect(await reputation.
|
|
285
|
+
expect(await reputation.totalSupplyLocal()).to.equal(rep * times);
|
|
286
|
+
expect(await reputation.balanceOfLocal(signers[1].address)).to.equal(
|
|
286
287
|
rep * times
|
|
287
288
|
);
|
|
288
289
|
|
|
289
290
|
await reputationTestHelper.multipleBurn(signers[1].address, rep, 2);
|
|
290
|
-
expect(await reputation.
|
|
291
|
-
expect(await reputation.
|
|
291
|
+
expect(await reputation.totalSupplyLocal()).to.equal(rep);
|
|
292
|
+
expect(await reputation.balanceOfLocal(signers[1].address)).to.equal(rep);
|
|
292
293
|
});
|
|
293
294
|
|
|
294
295
|
it("balanceOfAt before first mint should be 0 ", async () => {
|
|
295
296
|
const rep1 = Math.floor(Math.random() * 1e6);
|
|
296
297
|
var tx = await (await reputation.mint(signers[1].address, rep1)).wait();
|
|
297
|
-
expect(await reputation.
|
|
298
|
-
expect(await reputation.
|
|
299
|
-
expect(await reputation.
|
|
298
|
+
expect(await reputation.totalSupplyLocal()).to.equal(rep1);
|
|
299
|
+
expect(await reputation.totalSupplyLocalAt(tx.blockNumber)).to.equal(rep1);
|
|
300
|
+
expect(await reputation.totalSupplyLocalAt(tx.blockNumber - 1)).to.equal(0);
|
|
300
301
|
|
|
301
302
|
expect(
|
|
302
|
-
await reputation.
|
|
303
|
+
await reputation.balanceOfLocalAt(signers[1].address, tx.blockNumber)
|
|
303
304
|
).to.equal(rep1);
|
|
304
305
|
expect(
|
|
305
|
-
await reputation.
|
|
306
|
+
await reputation.balanceOfLocalAt(signers[1].address, tx.blockNumber - 1)
|
|
306
307
|
).to.equal(0);
|
|
307
308
|
});
|
|
308
309
|
});
|
|
@@ -381,18 +381,22 @@ describe("StakersDistribution - staking with GD and get Rewards in GDAO", () =>
|
|
|
381
381
|
await simpleStaking.connect(staker).stake(stakingAmount, 0, false);
|
|
382
382
|
await advanceBlocks(40);
|
|
383
383
|
await increaseTime(86700 * 30); // Increase one month
|
|
384
|
-
const stakerGDAOBalanceBeforeStake = await grep.
|
|
384
|
+
const stakerGDAOBalanceBeforeStake = await grep.balanceOfLocal(
|
|
385
|
+
staker.address
|
|
386
|
+
);
|
|
385
387
|
await simpleStaking.connect(staker).stake(stakingAmount, 0, false);
|
|
386
|
-
const stakerGDAOBalanceAfterStake = await grep.
|
|
388
|
+
const stakerGDAOBalanceAfterStake = await grep.balanceOfLocal(
|
|
389
|
+
staker.address
|
|
390
|
+
);
|
|
387
391
|
await simpleStaking.connect(staker).withdrawRewards();
|
|
388
392
|
|
|
389
393
|
const rewardsPerBlockAfterStake = await stakersDistribution.rewardsPerBlock(
|
|
390
394
|
simpleStaking.address
|
|
391
395
|
);
|
|
392
|
-
const GDAOBalanceBeforeWithdraw = await grep.
|
|
396
|
+
const GDAOBalanceBeforeWithdraw = await grep.balanceOfLocal(staker.address);
|
|
393
397
|
await advanceBlocks(10);
|
|
394
398
|
await simpleStaking.connect(staker).withdrawStake(stakingAmount, false);
|
|
395
|
-
const GDAOBalanceAfterWithdraw = await grep.
|
|
399
|
+
const GDAOBalanceAfterWithdraw = await grep.balanceOfLocal(staker.address);
|
|
396
400
|
expect(rewardsPerBlockAfterStake).to.be.equal(rewardsPerBlockBeforeStake); // Should not update rewards per block since simplestaking blockend passed
|
|
397
401
|
expect(GDAOBalanceBeforeWithdraw).to.be.equal(GDAOBalanceAfterWithdraw); // Should not earn any GDAO since simplestaking blockend passed
|
|
398
402
|
expect(stakerGDAOBalanceAfterStake.gt(stakerGDAOBalanceBeforeStake)).to.be
|
|
@@ -432,10 +436,10 @@ describe("StakersDistribution - staking with GD and get Rewards in GDAO", () =>
|
|
|
432
436
|
const blockNumberOfStake = (await ethers.provider.getBlockNumber()) + 1;
|
|
433
437
|
await simpleStaking.connect(staker).stake(stakingAmount, 0, false);
|
|
434
438
|
await advanceBlocks(30);
|
|
435
|
-
const GDAOBalanceBeforeWithdraw = await grep.
|
|
439
|
+
const GDAOBalanceBeforeWithdraw = await grep.balanceOfLocal(staker.address);
|
|
436
440
|
await simpleStaking.connect(staker).withdrawStake(stakingAmount, false);
|
|
437
441
|
|
|
438
|
-
const GDAOBalanceAfterWithdraw = await grep.
|
|
442
|
+
const GDAOBalanceAfterWithdraw = await grep.balanceOfLocal(staker.address);
|
|
439
443
|
expect(GDAOBalanceAfterWithdraw).to.be.gt(GDAOBalanceBeforeWithdraw);
|
|
440
444
|
|
|
441
445
|
expect(GDAOBalanceAfterWithdraw).to.be.equal(
|
|
@@ -750,12 +754,12 @@ describe("StakersDistribution - staking with GD and get Rewards in GDAO", () =>
|
|
|
750
754
|
const daiStakingRewardsPerBlock = await stakersDistribution.rewardsPerBlock(
|
|
751
755
|
simpleStaking.address
|
|
752
756
|
);
|
|
753
|
-
const gdaoBalanceBeforeWithdraw = await grep.
|
|
757
|
+
const gdaoBalanceBeforeWithdraw = await grep.balanceOfLocal(staker.address);
|
|
754
758
|
await simpleUsdcStaking
|
|
755
759
|
.connect(staker)
|
|
756
760
|
.withdrawStake(stakingAmountUsdc, false);
|
|
757
761
|
await simpleStaking.connect(staker).withdrawStake(stakingAmountDai, false);
|
|
758
|
-
const gdaoBalanceAfterWithdraw = await grep.
|
|
762
|
+
const gdaoBalanceAfterWithdraw = await grep.balanceOfLocal(staker.address);
|
|
759
763
|
expect(gdaoBalanceAfterWithdraw.sub(gdaoBalanceBeforeWithdraw)).to.be.equal(
|
|
760
764
|
UserPendingGdaos.add(usdcStakingRewardsPerBlock).add(
|
|
761
765
|
daiStakingRewardsPerBlock.mul(2)
|