@gooddollar/goodprotocol 1.0.7-beta.2 → 1.0.9-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +6 -6
- 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 +3 -3
- 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 +4 -4
- 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 +4 -4
- 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/GoodAaveStaking.sol +4 -3
- package/contracts/staking/aave/GoodAaveStakingV2.sol +263 -0
- package/contracts/staking/compound/GoodCompoundStaking.sol +4 -3
- package/contracts/ubi/UBIScheme.sol +2 -2
- package/package.json +1 -1
- package/releases/deployment.json +108 -97
- package/releases/olddao.json +1 -406
- package/scripts/deployFullDAO.ts +7 -7
- package/scripts/misc/goodgiveback.ts +64 -0
- package/scripts/verify.ts +60 -47
- 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
- package/truffle-config.js +12 -0
package/scripts/verify.ts
CHANGED
|
@@ -1,54 +1,67 @@
|
|
|
1
|
-
import fs from "fs"
|
|
2
|
-
import { isArray } from "lodash"
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import { isArray } from "lodash";
|
|
3
3
|
import type EthersT from "ethers";
|
|
4
|
-
import type HreT from "hardhat"
|
|
5
|
-
import { HardhatEthersHelpers } from "@nomiclabs/hardhat-ethers/types"
|
|
6
|
-
import { execSync } from "child_process"
|
|
7
|
-
type Ethers = typeof EthersT.ethers & HardhatEthersHelpers
|
|
8
|
-
type HRE = typeof HreT
|
|
4
|
+
import type HreT from "hardhat";
|
|
5
|
+
import { HardhatEthersHelpers } from "@nomiclabs/hardhat-ethers/types";
|
|
6
|
+
import { execSync } from "child_process";
|
|
7
|
+
type Ethers = typeof EthersT.ethers & HardhatEthersHelpers;
|
|
8
|
+
type HRE = typeof HreT;
|
|
9
9
|
|
|
10
|
-
let ethers:Ethers
|
|
10
|
+
let ethers: Ethers;
|
|
11
11
|
export const verify = async (hre: HRE) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if(isArray(entry[1]))
|
|
22
|
-
return
|
|
23
|
-
const addr = await getImplementationAddress(entry[1])
|
|
24
|
-
return entry[0]+'@'+addr
|
|
25
|
-
}))).filter(_ => _)
|
|
12
|
+
console.log("truffle compiling....");
|
|
13
|
+
const Verify = require("truffle-plugin-verify"); //not imported because of bug
|
|
14
|
+
const truffleOutput = execSync("npx truffle compile").toString("utf8");
|
|
15
|
+
console.log({ truffleOutput });
|
|
16
|
+
ethers = hre.ethers;
|
|
17
|
+
const deployed = JSON.parse(
|
|
18
|
+
fs.readFileSync("releases/deployment.json").toString()
|
|
19
|
+
);
|
|
20
|
+
const contracts = deployed[hre.network.name];
|
|
26
21
|
|
|
27
|
-
|
|
22
|
+
const contractPairs = (
|
|
23
|
+
await Promise.all(
|
|
24
|
+
Object.entries(contracts).map(async entry => {
|
|
25
|
+
if (isArray(entry[1])) return;
|
|
26
|
+
if (
|
|
27
|
+
typeof entry[1] !== "string" ||
|
|
28
|
+
(entry[1] as string).startsWith("0x") === false
|
|
29
|
+
)
|
|
30
|
+
return;
|
|
31
|
+
const addr = await getImplementationAddress(entry[1]);
|
|
32
|
+
return entry[0] + "@" + addr;
|
|
33
|
+
})
|
|
34
|
+
)
|
|
35
|
+
).filter(_ => _);
|
|
28
36
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
contractPairs.unshift();
|
|
38
|
+
|
|
39
|
+
const config = {
|
|
40
|
+
debug: false,
|
|
41
|
+
network_id: hre.network.config.chainId,
|
|
42
|
+
api_keys: {
|
|
43
|
+
etherscan: hre.config.etherscan.apiKey
|
|
44
|
+
},
|
|
45
|
+
working_directory: ".",
|
|
46
|
+
contracts_build_directory: "build/contracts",
|
|
47
|
+
_: contractPairs
|
|
48
|
+
};
|
|
49
|
+
return Verify(config);
|
|
40
50
|
};
|
|
41
51
|
|
|
42
|
-
const getImplementationAddress = async
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
52
|
+
const getImplementationAddress = async addr => {
|
|
53
|
+
console.log("finding impl for:", addr);
|
|
54
|
+
let proxy = await ethers.provider.getStorageAt(
|
|
55
|
+
addr,
|
|
56
|
+
"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc"
|
|
57
|
+
);
|
|
58
|
+
let res = addr;
|
|
59
|
+
if (proxy != ethers.constants.HashZero) res = "0x" + proxy.slice(-40);
|
|
60
|
+
else {
|
|
61
|
+
const code = await ethers.getDefaultProvider().getCode(addr);
|
|
62
|
+
if (code.startsWith("0x363d3d373d3d3d363d73"))
|
|
63
|
+
res = "0x" + code.slice(22, 62);
|
|
64
|
+
}
|
|
65
|
+
console.log("impl address for:", addr, res);
|
|
66
|
+
return res;
|
|
67
|
+
};
|
|
@@ -132,7 +132,7 @@ describe("ClaimersDistribution", () => {
|
|
|
132
132
|
"GReputation",
|
|
133
133
|
reputation
|
|
134
134
|
)) as GReputation;
|
|
135
|
-
expect(await rep.
|
|
135
|
+
expect(await rep.balanceOfLocal(claimer2.address)).to.equal(
|
|
136
136
|
ethers.utils.parseEther("2000000")
|
|
137
137
|
); //half of reputation since he claimed once out of 2 claims
|
|
138
138
|
});
|
|
@@ -149,7 +149,7 @@ describe("ClaimersDistribution", () => {
|
|
|
149
149
|
"GReputation",
|
|
150
150
|
reputation
|
|
151
151
|
)) as GReputation;
|
|
152
|
-
expect(await rep.
|
|
152
|
+
expect(await rep.balanceOfLocal(claimer1.address)).to.equal(
|
|
153
153
|
ethers.utils.parseEther("2000000")
|
|
154
154
|
); //half of reputation since he claimed once out of 2 claims
|
|
155
155
|
});
|
|
@@ -167,9 +167,9 @@ describe("ClaimersDistribution", () => {
|
|
|
167
167
|
"GReputation",
|
|
168
168
|
reputation
|
|
169
169
|
)) as GReputation;
|
|
170
|
-
const startrep = await rep.
|
|
170
|
+
const startrep = await rep.balanceOfLocal(claimer1.address);
|
|
171
171
|
await expect(cd.claimReputation(claimer1.address)).to.not.reverted;
|
|
172
|
-
const endrep = await rep.
|
|
172
|
+
const endrep = await rep.balanceOfLocal(claimer1.address);
|
|
173
173
|
expect(startrep).to.equal(endrep);
|
|
174
174
|
});
|
|
175
175
|
|
|
@@ -183,7 +183,7 @@ describe("ClaimersDistribution", () => {
|
|
|
183
183
|
"GReputation",
|
|
184
184
|
reputation
|
|
185
185
|
)) as GReputation;
|
|
186
|
-
expect(await rep.
|
|
186
|
+
expect(await rep.balanceOfLocal(claimer3.address)).to.equal(0);
|
|
187
187
|
});
|
|
188
188
|
|
|
189
189
|
it("should be able to claim every day", async () => {
|
|
@@ -121,7 +121,7 @@ describe("CompoundVotingMachine#CastVote", () => {
|
|
|
121
121
|
|
|
122
122
|
await grep.mint(actor.address, ethers.BigNumber.from("100001"));
|
|
123
123
|
console.log(
|
|
124
|
-
await grep.
|
|
124
|
+
await grep.balanceOfLocal(actor.address).then(_ => _.toString())
|
|
125
125
|
);
|
|
126
126
|
let tx = await gov
|
|
127
127
|
.connect(actor)
|
|
@@ -249,7 +249,7 @@ describe("CompoundVotingMachine#DAOScheme", () => {
|
|
|
249
249
|
expect(states[await gov.state(proposalId)]).to.equal("Executed");
|
|
250
250
|
|
|
251
251
|
//acct should now have 1M after proposal minted rep
|
|
252
|
-
expect(await grep.
|
|
252
|
+
expect(await grep.balanceOfLocal(acct.address)).to.equal(
|
|
253
253
|
ethers.BigNumber.from("1000000")
|
|
254
254
|
);
|
|
255
255
|
});
|
|
@@ -205,7 +205,7 @@ describe("CompoundVotingMachine#Guardian", () => {
|
|
|
205
205
|
grep.address,
|
|
206
206
|
await grep.totalSupply().then(_ => _.toString()),
|
|
207
207
|
await (await grep.getVotes(root.address)).toString(),
|
|
208
|
-
await (await grep.
|
|
208
|
+
await (await grep.balanceOfLocal(root.address)).toString(),
|
|
209
209
|
await gov.rep()
|
|
210
210
|
);
|
|
211
211
|
let targets = [gov.address];
|
|
@@ -7,6 +7,7 @@ import { expect } from "chai";
|
|
|
7
7
|
import { GReputation } from "../../types";
|
|
8
8
|
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address";
|
|
9
9
|
import { advanceBlocks, createDAO, increaseTime } from "../helpers";
|
|
10
|
+
import { TextDecoder } from "util";
|
|
10
11
|
|
|
11
12
|
const BN = ethers.BigNumber;
|
|
12
13
|
export const NULL_ADDRESS = ethers.constants.AddressZero;
|
|
@@ -130,7 +131,7 @@ describe("GReputation", () => {
|
|
|
130
131
|
});
|
|
131
132
|
|
|
132
133
|
it("should get balanceOf", async () => {
|
|
133
|
-
const repBalance = await grep.
|
|
134
|
+
const repBalance = await grep.balanceOfLocal(founder);
|
|
134
135
|
expect(repBalance.toNumber()).to.be.equal(0);
|
|
135
136
|
});
|
|
136
137
|
|
|
@@ -162,7 +163,7 @@ describe("GReputation", () => {
|
|
|
162
163
|
await grep.proveBalanceOfAtBlockchain("rootState", rep1, 1, proof, 1);
|
|
163
164
|
|
|
164
165
|
//root states changes the core balance
|
|
165
|
-
const newRep = await grep.
|
|
166
|
+
const newRep = await grep.balanceOfLocal(rep1);
|
|
166
167
|
expect(newRep.toNumber()).to.be.equal(1);
|
|
167
168
|
|
|
168
169
|
const newVotes = await grep.getVotes(rep1);
|
|
@@ -199,10 +200,12 @@ describe("GReputation", () => {
|
|
|
199
200
|
|
|
200
201
|
describe("delegation", async () => {
|
|
201
202
|
it("should allow delegation", async () => {
|
|
202
|
-
expect(await grep.
|
|
203
|
+
expect(await grep.balanceOfLocal(rep3)).to.be.eq(BN.from(0));
|
|
203
204
|
await grep.connect(signers[2]).delegateTo(rep3); //rep1 -> rep3
|
|
204
205
|
|
|
205
|
-
expect(await grep.getVotes(rep3)).to.be.eq(
|
|
206
|
+
expect(await grep.getVotes(rep3)).to.be.eq(
|
|
207
|
+
await grep.balanceOfLocal(rep1)
|
|
208
|
+
); //with delegation
|
|
206
209
|
expect(
|
|
207
210
|
await grep.getVotes(rep1),
|
|
208
211
|
"delegator should now have 0 votes"
|
|
@@ -238,7 +241,7 @@ describe("GReputation", () => {
|
|
|
238
241
|
});
|
|
239
242
|
|
|
240
243
|
it("should allow to change delegate", async () => {
|
|
241
|
-
expect(await grep.
|
|
244
|
+
expect(await grep.balanceOfLocal(rep1)).to.be.eq(BN.from(1)); //proof was submitted
|
|
242
245
|
await grep.connect(signers[3]).delegateTo(rep1); //rep2 -> rep1
|
|
243
246
|
expect(await grep.getVotes(rep3)).to.be.eq(BN.from(1)); //previous delegate should now be 1 bcause it has only rep1
|
|
244
247
|
expect(await grep.getVotes(rep1)).to.be.eq(
|
|
@@ -251,10 +254,10 @@ describe("GReputation", () => {
|
|
|
251
254
|
|
|
252
255
|
it("should allow undelegation", async () => {
|
|
253
256
|
await grep.connect(signers[2]).undelegate(); //rep1 -> remove delegattion to rep3
|
|
254
|
-
expect(await grep.
|
|
257
|
+
expect(await grep.balanceOfLocal(rep3)).to.be.eq(BN.from(0));
|
|
255
258
|
expect(await grep.getVotes(rep3)).to.be.eq(BN.from(0));
|
|
256
259
|
expect(await grep.getVotes(rep1)).to.be.eq(BN.from(3)); //rep2 delegating to rep1 + rep1 votes
|
|
257
|
-
expect(await grep.
|
|
260
|
+
expect(await grep.balanceOfLocal(rep1)).to.be.eq(BN.from(1));
|
|
258
261
|
|
|
259
262
|
expect(await grep.delegates(rep1)).to.be.eq(rep1);
|
|
260
263
|
});
|
|
@@ -409,20 +412,30 @@ describe("GReputation", () => {
|
|
|
409
412
|
["fuse", "0x" + merkleRoot.toString("hex"), 200]
|
|
410
413
|
);
|
|
411
414
|
|
|
415
|
+
const totalSupply = await grep.totalSupply();
|
|
412
416
|
await expect(avatarGenericCall(grep.address, encodedCall)).to.not.be
|
|
413
417
|
.reverted;
|
|
418
|
+
const totalAfterSupply = await grep.totalSupply();
|
|
419
|
+
expect(totalAfterSupply).to.eq(totalSupply.add(200));
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
it("should modify only local totalSupply on burn mint", async () => {
|
|
423
|
+
const totalSupply = await grep.totalSupply();
|
|
424
|
+
await grepWithOwner["mint(address,uint256)"](founder, 155);
|
|
425
|
+
const totalSupplyAfter = await grep.totalSupply();
|
|
426
|
+
expect(totalSupplyAfter).to.eq(totalSupply.add(155));
|
|
414
427
|
});
|
|
415
428
|
|
|
416
429
|
it("should not reset core balance", async () => {
|
|
417
430
|
//before proving new rep in new root balance should be 0
|
|
418
|
-
const newRep = await grep.
|
|
431
|
+
const newRep = await grep.balanceOfLocal(rep1);
|
|
419
432
|
expect(newRep.toNumber()).to.be.gt(0);
|
|
420
|
-
const newRep2 = await grep.
|
|
433
|
+
const newRep2 = await grep.balanceOfLocal(rep2);
|
|
421
434
|
expect(newRep2.toNumber()).to.be.gt(0);
|
|
422
435
|
});
|
|
423
436
|
|
|
424
437
|
it("should prove balance in new state", async () => {
|
|
425
|
-
const prevRep = await grep.
|
|
438
|
+
const prevRep = await grep.balanceOfLocal(rep2);
|
|
426
439
|
const prevVotes = await grep.getVotes(rep2);
|
|
427
440
|
const { proof } = getMerkleAndProof(
|
|
428
441
|
[
|
|
@@ -435,17 +448,29 @@ describe("GReputation", () => {
|
|
|
435
448
|
);
|
|
436
449
|
|
|
437
450
|
await grep.proveBalanceOfAtBlockchain("fuse", rep2, 200, proof, 2);
|
|
438
|
-
const newRep = await grep.
|
|
451
|
+
const newRep = await grep.balanceOfLocal(rep2);
|
|
439
452
|
expect(newRep).to.be.equal(prevRep); //core rep should not change
|
|
440
453
|
const newVotes = await grep.getVotes(rep2);
|
|
441
454
|
|
|
442
455
|
expect(newVotes).to.be.equal(prevVotes.add(200));
|
|
443
456
|
});
|
|
444
457
|
|
|
445
|
-
it("should
|
|
458
|
+
it("should keep active votes (local balance) correctly after mint/burn", async () => {
|
|
459
|
+
await grep.connect(signers[3]).undelegate();
|
|
460
|
+
const totalSupply = await grep.getCurrentVotes(rep2);
|
|
461
|
+
const tx = await grepWithOwner["mint(address,uint256)"](rep2, 155);
|
|
462
|
+
const result = await tx.wait();
|
|
463
|
+
const totalSupplyAfter = await grep.getVotes(rep2);
|
|
464
|
+
expect(totalSupplyAfter).to.eq(totalSupply.add(155));
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
it("should only delegate core balance and not new state balance", async () => {
|
|
446
468
|
expect(await grep.getVotes(rep3)).to.be.eq(BN.from(0));
|
|
447
469
|
await grep.connect(signers[3]).delegateTo(rep3); //rep2=signers[3]
|
|
448
|
-
expect(await grep.getVotes(rep3)).to.be.eq(
|
|
470
|
+
expect(await grep.getVotes(rep3)).to.be.eq(
|
|
471
|
+
await grep.balanceOfLocal(rep2)
|
|
472
|
+
);
|
|
473
|
+
expect(await grep.getVotes(rep3)).to.be.lt(await grep.getVotes(rep2));
|
|
449
474
|
});
|
|
450
475
|
|
|
451
476
|
it("should not effect delegate balance after new state hash", async () => {
|
|
@@ -680,12 +705,18 @@ describe("GReputation", () => {
|
|
|
680
705
|
|
|
681
706
|
it("it should be able to get totalSupply for particular block", async () => {
|
|
682
707
|
let currentSupply = await grep["totalSupply()"]();
|
|
708
|
+
let localSupply = await grep.totalSupplyLocalAt(
|
|
709
|
+
await ethers.provider.getBlockNumber()
|
|
710
|
+
);
|
|
683
711
|
await grepWithOwner["mint(address,uint256)"](
|
|
684
712
|
founder,
|
|
685
713
|
ethers.utils.parseEther("1")
|
|
686
714
|
);
|
|
687
715
|
let currentBlock = await ethers.provider.getBlockNumber();
|
|
688
|
-
let totalSupply = await grep.
|
|
716
|
+
let totalSupply = await grep.totalSupplyAt(currentBlock);
|
|
717
|
+
expect(await grep.totalSupplyLocalAt(currentBlock)).to.equal(
|
|
718
|
+
localSupply.add(ethers.utils.parseEther("1"))
|
|
719
|
+
);
|
|
689
720
|
expect(
|
|
690
721
|
totalSupply
|
|
691
722
|
.sub(currentSupply)
|
|
@@ -785,11 +816,11 @@ describe("GReputation", () => {
|
|
|
785
816
|
await grep.connect(signers[4]).setReputationRecipient(repTarget);
|
|
786
817
|
expect(await grep.reputationRecipients(rep3)).to.equal(repTarget);
|
|
787
818
|
await grepWithOwner.mint(rep3, 111);
|
|
788
|
-
expect(await grep.
|
|
819
|
+
expect(await grep.balanceOfLocal(repTarget)).to.equal(111);
|
|
789
820
|
});
|
|
790
821
|
|
|
791
822
|
it("user should be able to unset recipient", async () => {
|
|
792
|
-
const startBalance = await grep.
|
|
823
|
+
const startBalance = await grep.balanceOfLocal(rep3);
|
|
793
824
|
await grep
|
|
794
825
|
.connect(signers[4])
|
|
795
826
|
.setReputationRecipient(ethers.constants.AddressZero);
|
|
@@ -797,8 +828,8 @@ describe("GReputation", () => {
|
|
|
797
828
|
ethers.constants.AddressZero
|
|
798
829
|
);
|
|
799
830
|
await grepWithOwner.mint(rep3, 111);
|
|
800
|
-
expect(await grep.
|
|
801
|
-
expect(await grep.
|
|
831
|
+
expect(await grep.balanceOfLocal(repTarget)).to.equal(111);
|
|
832
|
+
expect(await grep.balanceOfLocal(rep3)).to.equal(startBalance.add(111));
|
|
802
833
|
});
|
|
803
834
|
});
|
|
804
835
|
});
|