@gooddollar/goodprotocol 1.0.7 → 1.0.10
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/BaseShareFieldV2.sol/BaseShareFieldV2.dbg.json +4 -0
- package/artifacts/contracts/staking/BaseShareFieldV2.sol/BaseShareFieldV2.json +256 -0
- 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/SimpleStakingV2.sol/SimpleStakingV2.dbg.json +4 -0
- package/artifacts/contracts/staking/SimpleStakingV2.sol/SimpleStakingV2.json +1033 -0
- 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/AaveStakingFactoryV2.sol/AaveStakingFactoryV2.dbg.json +4 -0
- package/artifacts/contracts/staking/aave/AaveStakingFactoryV2.sol/AaveStakingFactoryV2.json +148 -0
- 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/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.dbg.json +4 -0
- package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.json +1224 -0
- 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/contracts/staking/BaseShareFieldV2.sol +319 -0
- package/contracts/staking/SimpleStakingV2.sol +522 -0
- package/contracts/staking/aave/AaveStakingFactoryV2.sol +93 -0
- package/contracts/staking/aave/GoodAaveStakingV2.sol +263 -0
- package/package.json +1 -1
- package/releases/deployment.json +47 -47
- package/releases/olddao.json +1 -1
- package/scripts/deployFullDAO.ts +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
- package/test/helpers.ts +5 -1
- package/test/staking/GoodAaveStakingFactoryV2.test.ts +122 -0
- package/test/staking/UsdcAaveStaking.test.ts +5 -1
- package/test/staking/UsdcAaveStakingV2.test.ts +291 -0
|
@@ -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)
|
package/test/helpers.ts
CHANGED
|
@@ -18,7 +18,11 @@ import { GoodMarketMaker, CompoundVotingMachine } from "../types";
|
|
|
18
18
|
import { Contract } from "ethers";
|
|
19
19
|
|
|
20
20
|
export const getStakingFactory = async (
|
|
21
|
-
factory:
|
|
21
|
+
factory:
|
|
22
|
+
| "GoodCompoundStaking"
|
|
23
|
+
| "GoodAaveStaking"
|
|
24
|
+
| "GoodCompoundStakingTest"
|
|
25
|
+
| "GoodAaveStakingV2"
|
|
22
26
|
) => {
|
|
23
27
|
let swapHelper = await ethers
|
|
24
28
|
.getContractFactory("UniswapV2SwapHelper")
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { default as hre, ethers, upgrades } from "hardhat";
|
|
2
|
+
import { deployMockContract, MockContract } from "ethereum-waffle";
|
|
3
|
+
import { expect } from "chai";
|
|
4
|
+
import { CERC20, GoodAaveStaking, AaveStakingFactory } from "../../types";
|
|
5
|
+
import { createDAO, deployUniswap } from "../helpers";
|
|
6
|
+
import { Contract } from "ethers";
|
|
7
|
+
|
|
8
|
+
const BN = ethers.BigNumber;
|
|
9
|
+
export const NULL_ADDRESS = ethers.constants.AddressZero;
|
|
10
|
+
|
|
11
|
+
let cdai: CERC20;
|
|
12
|
+
|
|
13
|
+
describe("AaveStakingFactoryV2", () => {
|
|
14
|
+
let founder,
|
|
15
|
+
signers,
|
|
16
|
+
cdai,
|
|
17
|
+
usdc,
|
|
18
|
+
aave,
|
|
19
|
+
incentiveController,
|
|
20
|
+
aaveUsdOracle: Contract,
|
|
21
|
+
dai,
|
|
22
|
+
dao,
|
|
23
|
+
stakingFactory: AaveStakingFactory,
|
|
24
|
+
lendingPool: Contract;
|
|
25
|
+
|
|
26
|
+
before(async () => {
|
|
27
|
+
[founder, ...signers] = await ethers.getSigners();
|
|
28
|
+
dao = await createDAO();
|
|
29
|
+
const usdcFactory = await ethers.getContractFactory("USDCMock");
|
|
30
|
+
const lendingPoolFactory = await ethers.getContractFactory(
|
|
31
|
+
"LendingPoolMock"
|
|
32
|
+
);
|
|
33
|
+
aave = await (await ethers.getContractFactory("AaveMock")).deploy();
|
|
34
|
+
incentiveController = await (
|
|
35
|
+
await ethers.getContractFactory("IncentiveControllerMock")
|
|
36
|
+
).deploy(aave.address);
|
|
37
|
+
usdc = await usdcFactory.deploy();
|
|
38
|
+
lendingPool = await lendingPoolFactory.deploy(usdc.address);
|
|
39
|
+
aaveUsdOracle = await (
|
|
40
|
+
await ethers.getContractFactory("AaveUSDMockOracle")
|
|
41
|
+
).deploy();
|
|
42
|
+
dai = dao.daiAddress;
|
|
43
|
+
cdai = dao.cdaiAddress;
|
|
44
|
+
const uniswap = await deployUniswap(
|
|
45
|
+
dao.COMP,
|
|
46
|
+
await ethers.getContractAt("DAIMock", dai)
|
|
47
|
+
);
|
|
48
|
+
const router = uniswap.router;
|
|
49
|
+
await dao.setDAOAddress("UNISWAP_ROUTER", router.address);
|
|
50
|
+
await dao.setDAOAddress("AAVE", aave.address);
|
|
51
|
+
let swapHelper = await ethers
|
|
52
|
+
.getContractFactory("UniswapV2SwapHelper")
|
|
53
|
+
.then(_ => _.deploy());
|
|
54
|
+
|
|
55
|
+
stakingFactory = (await ethers
|
|
56
|
+
.getContractFactory("AaveStakingFactoryV2", {
|
|
57
|
+
libraries: { UniswapV2SwapHelper: swapHelper.address }
|
|
58
|
+
})
|
|
59
|
+
.then(_ => _.deploy())) as AaveStakingFactory;
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("should create proxy clone", async () => {
|
|
63
|
+
const res = await (
|
|
64
|
+
await stakingFactory.clone(usdc.address, ethers.constants.HashZero)
|
|
65
|
+
).wait();
|
|
66
|
+
const log = res.events.find(_ => _.event === "Deployed");
|
|
67
|
+
const detAddress = await stakingFactory.predictAddress(
|
|
68
|
+
usdc.address,
|
|
69
|
+
ethers.constants.HashZero
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
expect(log).to.not.empty;
|
|
73
|
+
expect(log.args.proxy).to.equal(detAddress);
|
|
74
|
+
expect(log.args.token).to.equal(usdc.address);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("should create and initialize clone", async () => {
|
|
78
|
+
const ns = await ethers
|
|
79
|
+
.getContractFactory("NameService")
|
|
80
|
+
.then(_ => _.deploy());
|
|
81
|
+
const res = await (
|
|
82
|
+
await stakingFactory.cloneAndInit(
|
|
83
|
+
usdc.address,
|
|
84
|
+
lendingPool.address,
|
|
85
|
+
dao.nameService.address,
|
|
86
|
+
5760,
|
|
87
|
+
stakingFactory.address,
|
|
88
|
+
incentiveController.address,
|
|
89
|
+
aaveUsdOracle.address,
|
|
90
|
+
[usdc.address, dai]
|
|
91
|
+
)
|
|
92
|
+
).wait();
|
|
93
|
+
const log = res.events.find(_ => _.event === "Deployed");
|
|
94
|
+
const detAddress = await stakingFactory.predictAddress(
|
|
95
|
+
usdc.address,
|
|
96
|
+
ethers.utils.solidityKeccak256(
|
|
97
|
+
["address", "address", "uint64", "address", "address", "address"],
|
|
98
|
+
[
|
|
99
|
+
lendingPool.address,
|
|
100
|
+
dao.nameService.address,
|
|
101
|
+
5760,
|
|
102
|
+
stakingFactory.address,
|
|
103
|
+
incentiveController.address,
|
|
104
|
+
aaveUsdOracle.address
|
|
105
|
+
]
|
|
106
|
+
)
|
|
107
|
+
);
|
|
108
|
+
expect(log).to.not.empty;
|
|
109
|
+
expect(log.args.proxy).to.equal(detAddress);
|
|
110
|
+
expect(log.args.token).to.equal(usdc.address);
|
|
111
|
+
|
|
112
|
+
//check initialization
|
|
113
|
+
const staking: GoodAaveStaking = (await ethers.getContractAt(
|
|
114
|
+
"GoodAaveStaking",
|
|
115
|
+
detAddress
|
|
116
|
+
)) as GoodAaveStaking;
|
|
117
|
+
expect(await staking.iToken()).to.equal(lendingPool.address);
|
|
118
|
+
expect(await staking.token()).to.equal(usdc.address);
|
|
119
|
+
expect(await staking.name()).to.equal("GoodAaveStakingV2 aUSDC");
|
|
120
|
+
expect(await staking.symbol()).to.equal("gaUSDC");
|
|
121
|
+
});
|
|
122
|
+
});
|
|
@@ -29,6 +29,7 @@ describe("UsdcAaveStaking - staking with USDC mocks to AAVE interface", () => {
|
|
|
29
29
|
lendingPool,
|
|
30
30
|
setDAOAddress,
|
|
31
31
|
genericCall,
|
|
32
|
+
goodReserve,
|
|
32
33
|
goodAaveStakingFactory;
|
|
33
34
|
before(async () => {
|
|
34
35
|
[founder, staker, ...signers] = await ethers.getSigners();
|
|
@@ -55,8 +56,10 @@ describe("UsdcAaveStaking - staking with USDC mocks to AAVE interface", () => {
|
|
|
55
56
|
marketMaker: mm,
|
|
56
57
|
daiAddress,
|
|
57
58
|
genericCall: gc,
|
|
58
|
-
COMP
|
|
59
|
+
COMP,
|
|
60
|
+
reserve
|
|
59
61
|
} = await createDAO();
|
|
62
|
+
goodReserve = reserve;
|
|
60
63
|
dai = await ethers.getContractAt("DAIMock", daiAddress);
|
|
61
64
|
avatar = av;
|
|
62
65
|
controller = ctrl;
|
|
@@ -275,6 +278,7 @@ describe("UsdcAaveStaking - staking with USDC mocks to AAVE interface", () => {
|
|
|
275
278
|
);
|
|
276
279
|
expect(currentGainsAfterEarnRewards[4]).to.be.equal(0); // stkAAVE rewards shouldnt count as gain
|
|
277
280
|
expect(currentGainsAfterCollectInterest[4]).to.be.equal("0");
|
|
281
|
+
expect(await aave.balanceOf(goodReserve.address)).gt(0);
|
|
278
282
|
});
|
|
279
283
|
async function addLiquidity(
|
|
280
284
|
token0: Contract,
|