@gooddollar/goodprotocol 1.0.18 → 1.0.19-beta.2
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/abis/GReputation.min.json +1 -1
- package/artifacts/abis/GoodAaveStaking.min.json +1 -1
- package/artifacts/abis/GoodAaveStakingV2.min.json +1 -1
- package/artifacts/abis/GoodCompoundStaking.min.json +1 -1
- package/artifacts/abis/GoodCompoundStakingTest.min.json +1 -1
- package/artifacts/abis/GoodCompoundStakingV2.min.json +1 -1
- package/artifacts/abis/UpgradableMock3.min.json +1 -0
- package/artifacts/abis/UpgradableMock4.min.json +1 -0
- 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 +15 -2
- package/artifacts/contracts/governance/GovernanceStaking.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 +2 -2
- 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/AaveUSDMockOracle.sol/AaveUSDMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/BatUSDMockOracle.sol/BatUSDMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/CompUsdMockOracle.sol/CompUSDMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/DAIMock.sol/DAIMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/DaiEthPriceMockOracle.sol/DaiEthPriceMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/DecimalsMock.sol/DecimalsMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/EthUSDMockOracle.sol/EthUSDMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/GasPriceMockOracle.sol/GasPriceMockOracle.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/UpgradableMock.json +2 -2
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock2.dbg.json +1 -1
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock2.json +2 -2
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock3.dbg.json +4 -0
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock3.json +172 -0
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock4.dbg.json +4 -0
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock4.json +172 -0
- 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 +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/SimpleStakingV2.sol/SimpleStakingV2.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 +3 -3
- package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.dbg.json +1 -1
- package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.json +3 -3
- 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/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.dbg.json +1 -1
- package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.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/utils/BancorFormula.sol/BancorFormula.dbg.json +1 -1
- package/artifacts/contracts/utils/BulkProof.sol/BulkProof.dbg.json +1 -1
- package/artifacts/contracts/utils/BulkProof.sol/BulkProof.json +2 -2
- 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/MultiCall.sol/Multicall.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/ProtocolUpgradeFuseRecover.sol/ProtocolUpgradeFuseRecover.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgradeRecover.sol/ProtocolUpgradeRecover.dbg.json +1 -1
- package/artifacts/contracts/utils/ProxyFactory1967.sol/ERC1967Proxy.dbg.json +1 -1
- package/artifacts/contracts/utils/ProxyFactory1967.sol/ProxyFactory1967.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 +8 -0
- package/contracts/governance/Reputation.sol +5 -3
- package/contracts/mocks/UpgradableMocks.sol +18 -0
- package/contracts/staking/SimpleStaking.sol +2 -1
- package/contracts/staking/SimpleStakingV2.sol +2 -1
- package/hardhat.config.ts +63 -8
- package/package.json +7 -5
- package/releases/deployment.json +11 -0
- package/scripts/multichain-deploy/basicdao-deploy.ts +256 -0
- package/scripts/multichain-deploy/helpers.ts +96 -0
- package/test/governance/ClaimersDistribution.test.ts +6 -6
- package/test/governance/CompoundVotingMachine.daoscheme.ts +14 -1
- package/test/governance/CompoundVotingMachine.guardian.test.ts +11 -1
- package/test/governance/GReputation.test.ts +32 -1
- package/test/governance/StakersDistribution.test.ts +62 -1
- package/test/helpers.ts +15 -0
- package/test/reserve/GoodMarketMaker.test.ts +11 -0
- package/test/reserve/GoodReserveCDai.gdx.test.ts +23 -8
- package/test/reserve/GoodReserveCDai.test.ts +37 -2
- package/test/staking/CompoundStakingFactory.test.ts +31 -0
- package/test/staking/DonationsStaking.test.ts +99 -2
- package/test/staking/GoodAaveStakingFactory.test.ts +36 -1
- package/test/staking/SimpleDAIStaking.test.ts +52 -2
- package/test/staking/StakingRewards.test.ts +38 -0
- package/test/staking/UsdcAaveStaking.test.ts +45 -19
- package/test/ubi/UBIScheme.test.ts +68 -0
- package/test/utils/DAOUpgradeableContract.test.ts +47 -0
- package/test/utils/NameService.test.ts +50 -55
- package/test/utils/ProxyFactory.test.ts +17 -0
- package/yarn.lock +607 -119
- package/artifacts/abis/FuseFaucet.min.json +0 -1
- package/artifacts/abis/InvitesV1.min.json +0 -1
- package/artifacts/contracts/unaudited-foundation/FuseFaucet.sol/FuseFaucet.dbg.json +0 -4
- package/artifacts/contracts/unaudited-foundation/FuseFaucet.sol/FuseFaucet.json +0 -200
- package/artifacts/contracts/unaudited-foundation/InvitesV1.sol/InvitesV1.dbg.json +0 -4
- package/artifacts/contracts/unaudited-foundation/InvitesV1.sol/InvitesV1.json +0 -486
- package/contracts/unaudited-foundation/FuseFaucet.sol +0 -120
- package/contracts/unaudited-foundation/InvitesV1.sol +0 -304
package/releases/deployment.json
CHANGED
|
@@ -529,5 +529,16 @@
|
|
|
529
529
|
"ProxyAdmin": "0x57179b2A8eB019157b0C3E761cdB26c82C982a3B",
|
|
530
530
|
"FuseFaucet": "0x01ab5966C1d742Ae0CFF7f14cC0F4D85156e83d9",
|
|
531
531
|
"FuseStaking": "0xA199F0C353E25AdF022378B0c208D600f39a6505"
|
|
532
|
+
},
|
|
533
|
+
"production-celo": {
|
|
534
|
+
"ProxyFactory": "0x99C22e78A579e2176311c736C4c9F0b0D5A47806",
|
|
535
|
+
"GoodDollar": "0xf2283840cE37DAe0a06B40a9A80603977f36fA3F",
|
|
536
|
+
"Avatar": "0xCD5e8a81B1e02c1837A674f87dF327C14f4e5748",
|
|
537
|
+
"Controller": "0x3D0bacBdC06A28971855275D511e6249bE67112d",
|
|
538
|
+
"Identity": "0x96B81f82A29e78C5ba9E2034Ce8490fd641a24eb",
|
|
539
|
+
"NameService": "0x563a80a452264a9e1aa37c6FA0B46D04C3c71b24",
|
|
540
|
+
"GReputation": "0xAC132ECe25217867E318eA8ff63420C90d5a74A6",
|
|
541
|
+
"network": "production-celo",
|
|
542
|
+
"networkId": 42220
|
|
532
543
|
}
|
|
533
544
|
}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { network, ethers, upgrades, run } from "hardhat";
|
|
2
|
+
import { networkNames } from "@openzeppelin/upgrades-core";
|
|
3
|
+
import { isFunction, get, omitBy } from "lodash";
|
|
4
|
+
import { getImplementationAddress } from "@openzeppelin/upgrades-core";
|
|
5
|
+
import pressAnyKey from "press-any-key";
|
|
6
|
+
import { Contract } from "ethers";
|
|
7
|
+
import { range } from "lodash";
|
|
8
|
+
// import DAOCreatorABI from "@gooddollar/goodcontracts/build/contracts/DaoCreatorGoodDollar.json";
|
|
9
|
+
import DAOCreatorABI from "../../../GoodBootstrap/packages/contracts/build/contracts/DaoCreatorGoodDollarWithRep.json";
|
|
10
|
+
// import IdentityABI from "@gooddollar/goodcontracts/build/contracts/Identity.json";
|
|
11
|
+
import IdentityABI from "../../../GoodBootstrap/packages/contracts/build/contracts/IdentityWithOwner.json";
|
|
12
|
+
import FeeFormulaABI from "@gooddollar/goodcontracts/build/contracts/FeeFormula.json";
|
|
13
|
+
// import AddFoundersABI from "@gooddollar/goodcontracts/build/contracts/AddFoundersGoodDollar.json";
|
|
14
|
+
import AddFoundersABI from "../../../GoodBootstrap/packages/contracts/build/contracts/AddFoundersGoodDollarWithRep.json";
|
|
15
|
+
import ContributionCalculation from "@gooddollar/goodcontracts/stakingModel/build/contracts/ContributionCalculation.json";
|
|
16
|
+
import FirstClaimPool from "@gooddollar/goodcontracts/stakingModel/build/contracts/FirstClaimPool.json";
|
|
17
|
+
import BridgeMock from "@gooddollar/goodcontracts/stakingModel/build/contracts/BridgeMock.json";
|
|
18
|
+
import AdminWalletABI from "@gooddollar/goodcontracts/build/contracts/AdminWallet.json";
|
|
19
|
+
import OTPABI from "@gooddollar/goodcontracts/build/contracts/OneTimePayments.json";
|
|
20
|
+
import HomeBridgeABI from "@gooddollar/goodcontracts/build/contracts/DeployHomeBridge.json";
|
|
21
|
+
import ForeignBridgeABI from "@gooddollar/goodcontracts/build/contracts/DeployForeignBridge.json";
|
|
22
|
+
|
|
23
|
+
import { deployDeterministic } from "./helpers";
|
|
24
|
+
import releaser from "../../scripts/releaser";
|
|
25
|
+
import ProtocolSettings from "../../releases/deploy-settings.json";
|
|
26
|
+
import dao from "../../releases/deployment.json";
|
|
27
|
+
import { TransactionResponse } from "@ethersproject/providers";
|
|
28
|
+
|
|
29
|
+
const { name } = network;
|
|
30
|
+
|
|
31
|
+
const printDeploy = async (
|
|
32
|
+
c: Contract | TransactionResponse
|
|
33
|
+
): Promise<Contract | TransactionResponse> => {
|
|
34
|
+
if (c instanceof Contract) {
|
|
35
|
+
await c.deployed();
|
|
36
|
+
console.log("deployed to: ", c.address);
|
|
37
|
+
}
|
|
38
|
+
if (c.wait) {
|
|
39
|
+
await c.wait();
|
|
40
|
+
console.log("tx done:", c.hash);
|
|
41
|
+
}
|
|
42
|
+
return c;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const createDAO = async () => {
|
|
46
|
+
const fusedao = dao[network.name.split("-")[0]];
|
|
47
|
+
const protocolSettings = ProtocolSettings["production"];
|
|
48
|
+
let release: { [key: string]: any } = {};
|
|
49
|
+
|
|
50
|
+
let [root, ...signers] = await ethers.getSigners();
|
|
51
|
+
//generic call permissions
|
|
52
|
+
let schemeMock = root;
|
|
53
|
+
const isMainnet = network.name.includes("main");
|
|
54
|
+
|
|
55
|
+
console.log("got signers:", {
|
|
56
|
+
network,
|
|
57
|
+
root: root.address,
|
|
58
|
+
schemeMock: schemeMock.address,
|
|
59
|
+
balance: await ethers.provider
|
|
60
|
+
.getBalance(root.address)
|
|
61
|
+
.then(_ => _.toString())
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const DAOCreatorFactory = new ethers.ContractFactory(
|
|
65
|
+
DAOCreatorABI.abi,
|
|
66
|
+
DAOCreatorABI.bytecode,
|
|
67
|
+
root
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
const IdentityFactory = new ethers.ContractFactory(
|
|
71
|
+
IdentityABI.abi,
|
|
72
|
+
IdentityABI.bytecode,
|
|
73
|
+
root
|
|
74
|
+
);
|
|
75
|
+
const FeeFormulaFactory = new ethers.ContractFactory(
|
|
76
|
+
FeeFormulaABI.abi,
|
|
77
|
+
FeeFormulaABI.bytecode,
|
|
78
|
+
root
|
|
79
|
+
);
|
|
80
|
+
const AddFoundersFactory = new ethers.ContractFactory(
|
|
81
|
+
AddFoundersABI.abi,
|
|
82
|
+
AddFoundersABI.bytecode,
|
|
83
|
+
root
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const AddFounders = (await AddFoundersFactory.deploy().then(
|
|
87
|
+
printDeploy
|
|
88
|
+
)) as Contract;
|
|
89
|
+
// const AddFounders = await ethers.getContractAt(
|
|
90
|
+
// AddFoundersABI.abi,
|
|
91
|
+
// "0x6F1BAbfF5E119d61F0c6d8653d84E8B284B87091"
|
|
92
|
+
// );
|
|
93
|
+
|
|
94
|
+
const Identity = (await deployDeterministic(
|
|
95
|
+
{
|
|
96
|
+
name: "Identity",
|
|
97
|
+
factory: IdentityFactory
|
|
98
|
+
},
|
|
99
|
+
[root.address]
|
|
100
|
+
).then(printDeploy)) as Contract;
|
|
101
|
+
|
|
102
|
+
// const Identity = await ethers.getContractAt(
|
|
103
|
+
// IdentityABI.abi,
|
|
104
|
+
// release.Identity
|
|
105
|
+
// );
|
|
106
|
+
|
|
107
|
+
const daoCreator = await DAOCreatorFactory.deploy(AddFounders.address);
|
|
108
|
+
|
|
109
|
+
const FeeFormula = (await deployDeterministic(
|
|
110
|
+
{ name: "FeeFormula", factory: FeeFormulaFactory },
|
|
111
|
+
[0]
|
|
112
|
+
).then(printDeploy)) as Contract;
|
|
113
|
+
|
|
114
|
+
const GReputation = (await deployDeterministic(
|
|
115
|
+
{
|
|
116
|
+
name: "GReputation",
|
|
117
|
+
isUpgradable: true,
|
|
118
|
+
initializer: "initialize(address, string, bytes32, uint256)"
|
|
119
|
+
},
|
|
120
|
+
[
|
|
121
|
+
ethers.constants.AddressZero,
|
|
122
|
+
"fuse",
|
|
123
|
+
protocolSettings.governance.gdaoAirdrop, //should fail on real deploy if not set
|
|
124
|
+
protocolSettings.governance.gdaoTotalSupply //should fail on real deploy if not set
|
|
125
|
+
]
|
|
126
|
+
).then(printDeploy)) as Contract;
|
|
127
|
+
|
|
128
|
+
console.log("setting identity auth period");
|
|
129
|
+
await Identity.setAuthenticationPeriod(365).then(printDeploy);
|
|
130
|
+
|
|
131
|
+
console.log("creating dao");
|
|
132
|
+
await daoCreator
|
|
133
|
+
.forgeOrg(
|
|
134
|
+
"GoodDollar",
|
|
135
|
+
"G$",
|
|
136
|
+
0,
|
|
137
|
+
FeeFormula.address,
|
|
138
|
+
Identity.address,
|
|
139
|
+
GReputation.address,
|
|
140
|
+
[],
|
|
141
|
+
0,
|
|
142
|
+
[]
|
|
143
|
+
)
|
|
144
|
+
.then(printDeploy);
|
|
145
|
+
console.log("forgeOrg done ");
|
|
146
|
+
const Avatar = new ethers.Contract(
|
|
147
|
+
await daoCreator.avatar(),
|
|
148
|
+
[
|
|
149
|
+
"function owner() view returns (address)",
|
|
150
|
+
"function nativeToken() view returns (address)"
|
|
151
|
+
],
|
|
152
|
+
root
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
// const Avatar = new ethers.Contract(
|
|
156
|
+
// release.Avatar,
|
|
157
|
+
// [
|
|
158
|
+
// "function owner() view returns (address)",
|
|
159
|
+
// "function nativeToken() view returns (address)"
|
|
160
|
+
// ],
|
|
161
|
+
// root
|
|
162
|
+
// );
|
|
163
|
+
|
|
164
|
+
await Identity.setAvatar(Avatar.address).then(printDeploy);
|
|
165
|
+
|
|
166
|
+
console.log("Done deploying DAO, setting schemes permissions");
|
|
167
|
+
|
|
168
|
+
let schemes = [process.env.DAO_OWNER, Identity.address];
|
|
169
|
+
|
|
170
|
+
const gd = await Avatar.nativeToken();
|
|
171
|
+
|
|
172
|
+
const controller = await Avatar.owner();
|
|
173
|
+
|
|
174
|
+
console.log("setting schemes", schemes);
|
|
175
|
+
|
|
176
|
+
await daoCreator
|
|
177
|
+
.setSchemes(
|
|
178
|
+
Avatar.address,
|
|
179
|
+
schemes,
|
|
180
|
+
schemes.map(_ => ethers.constants.HashZero),
|
|
181
|
+
["0x0000001f", "0x00000001"],
|
|
182
|
+
""
|
|
183
|
+
)
|
|
184
|
+
.then(printDeploy);
|
|
185
|
+
|
|
186
|
+
const NameService = await deployDeterministic(
|
|
187
|
+
{ name: "NameService", isUpgradable: true },
|
|
188
|
+
[
|
|
189
|
+
controller,
|
|
190
|
+
["CONTROLLER", "AVATAR", "IDENTITY", "GOODDOLLAR"].map(_ =>
|
|
191
|
+
ethers.utils.keccak256(ethers.utils.toUtf8Bytes(_))
|
|
192
|
+
),
|
|
193
|
+
[controller, Avatar.address, Identity.address, gd]
|
|
194
|
+
]
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
await (await GReputation.updateDAO(NameService.address)).wait();
|
|
198
|
+
console.log("GRep nameservice:");
|
|
199
|
+
//verifications
|
|
200
|
+
const Controller = await ethers.getContractAt("Controller", controller);
|
|
201
|
+
const GoodDollar = await ethers.getContractAt("IGoodDollar", gd);
|
|
202
|
+
|
|
203
|
+
await GoodDollar.renounceMinter().then(printDeploy);
|
|
204
|
+
await Identity.transferOwnership(process.env.DAO_OWNER).then(printDeploy);
|
|
205
|
+
|
|
206
|
+
const daoOwnerDaoPermissions = await Controller.getSchemePermissions(
|
|
207
|
+
process.env.DAO_OWNER,
|
|
208
|
+
Avatar.address
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
const deployerIsNotGDMinter =
|
|
212
|
+
(await GoodDollar.isMinter(root.address)) === false;
|
|
213
|
+
const avatarIsGDMinter = await GoodDollar.isMinter(Avatar.address);
|
|
214
|
+
|
|
215
|
+
const deployerIsNotRepMinter =
|
|
216
|
+
(await GReputation.hasRole(GReputation.MINTER_ROLE(), root.address)) ===
|
|
217
|
+
false;
|
|
218
|
+
const avatarIsRepMinter = await GReputation.hasRole(
|
|
219
|
+
GReputation.MINTER_ROLE(),
|
|
220
|
+
Avatar.address
|
|
221
|
+
);
|
|
222
|
+
const daoOwnerIsIdentityOwner =
|
|
223
|
+
process.env.DAO_OWNER === (await Identity.owner());
|
|
224
|
+
|
|
225
|
+
//try to modify DAO -> should not succeed
|
|
226
|
+
await (await GReputation.updateDAO(ethers.constants.AddressZero)).wait();
|
|
227
|
+
|
|
228
|
+
const grepHasDAOSet =
|
|
229
|
+
(await GReputation.nameService()) === NameService.address;
|
|
230
|
+
|
|
231
|
+
console.log({
|
|
232
|
+
daoOwnerDaoPermissions,
|
|
233
|
+
deployerIsNotGDMinter,
|
|
234
|
+
deployerIsNotRepMinter,
|
|
235
|
+
avatarIsRepMinter,
|
|
236
|
+
daoOwnerIsIdentityOwner,
|
|
237
|
+
avatarIsGDMinter,
|
|
238
|
+
grepHasDAOSet
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
release = {
|
|
242
|
+
ProxyFactory: "0x99C22e78A579e2176311c736C4c9F0b0D5A47806",
|
|
243
|
+
GoodDollar: gd,
|
|
244
|
+
Avatar: Avatar.address,
|
|
245
|
+
Controller: controller,
|
|
246
|
+
Identity: Identity.address,
|
|
247
|
+
NameService: NameService.address,
|
|
248
|
+
GReputation: GReputation.address
|
|
249
|
+
};
|
|
250
|
+
await releaser(release, network.name, "deployment", false);
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
export const main = async (networkName = name) => {
|
|
254
|
+
await createDAO().catch(console.log);
|
|
255
|
+
};
|
|
256
|
+
main();
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { ContractFactory } from "ethers";
|
|
2
|
+
import { network, ethers, upgrades, run } from "hardhat";
|
|
3
|
+
|
|
4
|
+
let totalGas = 0;
|
|
5
|
+
const gasUsage = {};
|
|
6
|
+
const GAS_SETTINGS = {};
|
|
7
|
+
export const countTotalGas = async (tx, name) => {
|
|
8
|
+
let res = tx;
|
|
9
|
+
if (tx.deployTransaction) tx = tx.deployTransaction;
|
|
10
|
+
if (tx.wait) res = await tx.wait();
|
|
11
|
+
if (res.gasUsed) {
|
|
12
|
+
totalGas += parseInt(res.gasUsed);
|
|
13
|
+
gasUsage[name] = gasUsage[name] || 0;
|
|
14
|
+
gasUsage[name] += parseInt(res.gasUsed);
|
|
15
|
+
} else console.log("no gas data", { res, tx });
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const deployDeterministic = async (
|
|
19
|
+
contract,
|
|
20
|
+
args: any[],
|
|
21
|
+
factoryOpts = {}
|
|
22
|
+
) => {
|
|
23
|
+
try {
|
|
24
|
+
let proxyFactory;
|
|
25
|
+
if (!network.name.startsWith("production")) {
|
|
26
|
+
proxyFactory = await (
|
|
27
|
+
await ethers.getContractFactory("ProxyFactory1967")
|
|
28
|
+
).deploy();
|
|
29
|
+
} else
|
|
30
|
+
proxyFactory = await ethers.getContractAt(
|
|
31
|
+
"ProxyFactory1967",
|
|
32
|
+
"0x99C22e78A579e2176311c736C4c9F0b0D5A47806"
|
|
33
|
+
);
|
|
34
|
+
const Contract =
|
|
35
|
+
(contract.factory as ContractFactory) ||
|
|
36
|
+
(await ethers.getContractFactory(contract.name, factoryOpts));
|
|
37
|
+
|
|
38
|
+
const salt = ethers.BigNumber.from(
|
|
39
|
+
ethers.utils.keccak256(ethers.utils.toUtf8Bytes(contract.name))
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
if (contract.isUpgradable === true) {
|
|
43
|
+
console.log("Deploying:", contract.name, "using proxyfactory");
|
|
44
|
+
const encoded = Contract.interface.encodeFunctionData(
|
|
45
|
+
contract.initializer || "initialize",
|
|
46
|
+
args
|
|
47
|
+
);
|
|
48
|
+
const tx = await Contract.deploy(GAS_SETTINGS);
|
|
49
|
+
const impl = await tx.deployed();
|
|
50
|
+
console.log("implementation deployed:", contract.name, impl.address);
|
|
51
|
+
await countTotalGas(tx, contract.name);
|
|
52
|
+
|
|
53
|
+
const tx2 = await proxyFactory.deployProxy(
|
|
54
|
+
salt,
|
|
55
|
+
impl.address,
|
|
56
|
+
encoded,
|
|
57
|
+
GAS_SETTINGS
|
|
58
|
+
);
|
|
59
|
+
await countTotalGas(tx2, contract.name);
|
|
60
|
+
const deployTx = await tx2
|
|
61
|
+
.wait()
|
|
62
|
+
.catch(e =>
|
|
63
|
+
console.error("failed to deploy proxy, assuming it exists...", e)
|
|
64
|
+
);
|
|
65
|
+
const proxyAddr = await proxyFactory[
|
|
66
|
+
"getDeploymentAddress(uint256,address)"
|
|
67
|
+
](salt, await proxyFactory.signer.getAddress());
|
|
68
|
+
console.log("proxy deployed:", contract.name, proxyAddr);
|
|
69
|
+
return Contract.attach(proxyAddr);
|
|
70
|
+
} else {
|
|
71
|
+
console.log("Deploying:", contract.name, "using proxyfactory code");
|
|
72
|
+
const constructor = Contract.interface.encodeDeploy(args);
|
|
73
|
+
const bytecode = ethers.utils.solidityPack(
|
|
74
|
+
["bytes", "bytes"],
|
|
75
|
+
[Contract.bytecode, constructor]
|
|
76
|
+
);
|
|
77
|
+
const deployTx = await (
|
|
78
|
+
await proxyFactory.deployCode(salt, bytecode, GAS_SETTINGS)
|
|
79
|
+
).wait();
|
|
80
|
+
|
|
81
|
+
const proxyAddr = await proxyFactory[
|
|
82
|
+
"getDeploymentAddress(uint256,address,bytes32)"
|
|
83
|
+
](
|
|
84
|
+
salt,
|
|
85
|
+
await proxyFactory.signer.getAddress(),
|
|
86
|
+
ethers.utils.keccak256(bytecode)
|
|
87
|
+
);
|
|
88
|
+
console.log("proxy deployed:", contract.name, proxyAddr);
|
|
89
|
+
|
|
90
|
+
return Contract.attach(proxyAddr);
|
|
91
|
+
}
|
|
92
|
+
} catch (e) {
|
|
93
|
+
console.log("Failed deploying contract:", { contract });
|
|
94
|
+
throw e;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
@@ -84,9 +84,9 @@ describe("ClaimersDistribution", () => {
|
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
it("should update claim if claimed today", async () => {
|
|
87
|
-
const ts =
|
|
87
|
+
const ts = await ethers.provider.getBlock("latest").then(_ => _.timestamp);
|
|
88
88
|
await ubiScheme.connect(claimer1).claim();
|
|
89
|
-
expect(await cd.lastUpdated(claimer1.address)).gt(
|
|
89
|
+
expect(await cd.lastUpdated(claimer1.address)).gt(ts.toFixed(0));
|
|
90
90
|
expect(await cd.getMonthClaims(claimer1.address)).to.equal(1);
|
|
91
91
|
const monthData = await cd.months(await cd.currentMonth());
|
|
92
92
|
expect(monthData.totalClaims).to.equal(1);
|
|
@@ -102,9 +102,9 @@ describe("ClaimersDistribution", () => {
|
|
|
102
102
|
});
|
|
103
103
|
|
|
104
104
|
it("should update stats after second claimer", async () => {
|
|
105
|
-
const ts =
|
|
105
|
+
const ts = await ethers.provider.getBlock("latest").then(_ => _.timestamp);
|
|
106
106
|
await ubiScheme.connect(claimer2).claim();
|
|
107
|
-
expect(await cd.lastUpdated(claimer2.address)).gt(
|
|
107
|
+
expect(await cd.lastUpdated(claimer2.address)).gt(ts.toFixed(0));
|
|
108
108
|
expect(await cd.getMonthClaims(claimer2.address)).to.equal(1);
|
|
109
109
|
const monthData = await cd.months(await cd.currentMonth());
|
|
110
110
|
expect(monthData.totalClaims).to.equal(2);
|
|
@@ -115,9 +115,9 @@ describe("ClaimersDistribution", () => {
|
|
|
115
115
|
|
|
116
116
|
it("should distribute reputation after a month and update to current monthly distribution", async () => {
|
|
117
117
|
await increaseTime(60 * 60 * 24 * 30);
|
|
118
|
-
const ts =
|
|
118
|
+
const ts = await ethers.provider.getBlock("latest").then(_ => _.timestamp);
|
|
119
119
|
await ubiScheme.connect(claimer2).claim();
|
|
120
|
-
expect(await cd.lastUpdated(claimer2.address)).gt(
|
|
120
|
+
expect(await cd.lastUpdated(claimer2.address)).gt(ts.toFixed(0));
|
|
121
121
|
expect(await cd.getMonthClaims(claimer2.address)).to.equal(1);
|
|
122
122
|
const monthData = await cd.months(await cd.currentMonth());
|
|
123
123
|
expect(monthData.totalClaims).to.equal(1);
|
|
@@ -54,7 +54,7 @@ describe("CompoundVotingMachine#DAOScheme", () => {
|
|
|
54
54
|
|
|
55
55
|
let genericCall, queuePeriod;
|
|
56
56
|
|
|
57
|
-
let avatar, mock, Controller;
|
|
57
|
+
let avatar, mock, Controller, setAddress;
|
|
58
58
|
|
|
59
59
|
before(async () => {
|
|
60
60
|
[root, acct, ...signers] = await ethers.getSigners();
|
|
@@ -79,6 +79,7 @@ describe("CompoundVotingMachine#DAOScheme", () => {
|
|
|
79
79
|
)) as GReputation;
|
|
80
80
|
|
|
81
81
|
gov = votingMachine;
|
|
82
|
+
setAddress = setDAOAddress;
|
|
82
83
|
|
|
83
84
|
//this will give root minter permissions
|
|
84
85
|
setDAOAddress("GDAO_CLAIMERS", root.address);
|
|
@@ -313,4 +314,16 @@ describe("CompoundVotingMachine#DAOScheme", () => {
|
|
|
313
314
|
expect(states[await gov.state(proposalId)]).to.equal("Executed");
|
|
314
315
|
expect(await c.isSchemeRegistered(gov.address, avatar)).to.eq(false);
|
|
315
316
|
});
|
|
317
|
+
|
|
318
|
+
it("should be able to update reputation", async () => {
|
|
319
|
+
const originalRep = await gov.rep();
|
|
320
|
+
const repToSet = root.address;
|
|
321
|
+
await setAddress("REPUTATION", root.address);
|
|
322
|
+
await gov.updateRep();
|
|
323
|
+
const updatedRep = await gov.rep();
|
|
324
|
+
expect(updatedRep).to.not.eq(originalRep);
|
|
325
|
+
expect(updatedRep).to.eq(repToSet);
|
|
326
|
+
await setAddress("REPUTATION", originalRep);
|
|
327
|
+
await gov.updateRep();
|
|
328
|
+
});
|
|
316
329
|
});
|
|
@@ -129,8 +129,18 @@ describe("CompoundVotingMachine#Guardian", () => {
|
|
|
129
129
|
await gov.connect(acct).setGuardian(root.address); //restore
|
|
130
130
|
});
|
|
131
131
|
|
|
132
|
+
it("Should allow set guardian to fix bad guardian deployment", async () => {
|
|
133
|
+
const badAddress = "0x4659176E962763e7C8A4eF965ecfD0fdf9f52057";
|
|
134
|
+
await gov.setGuardian(badAddress);
|
|
135
|
+
expect(await gov.guardian()).to.equal(badAddress);
|
|
136
|
+
|
|
137
|
+
await gov.connect(acct).fixGuardian(root.address);
|
|
138
|
+
expect(await gov.guardian()).to.equal(root.address);
|
|
139
|
+
});
|
|
140
|
+
|
|
132
141
|
it("Should be able to set guardian by avatar if foundation expired", async () => {
|
|
133
|
-
await
|
|
142
|
+
await ethers.provider.send("evm_setNextBlockTimestamp", [1672531201]); //1672531200
|
|
143
|
+
await ethers.provider.send("evm_mine", []);
|
|
134
144
|
|
|
135
145
|
const encoded = gov.interface.encodeFunctionData("setGuardian", [
|
|
136
146
|
acct.address
|
|
@@ -119,7 +119,6 @@ describe("GReputation", () => {
|
|
|
119
119
|
});
|
|
120
120
|
|
|
121
121
|
it("should have avatar as role manager", async () => {
|
|
122
|
-
// const invites = await Invites.deployed();
|
|
123
122
|
expect(await grep.hasRole(await grep.DEFAULT_ADMIN_ROLE(), avatar)).to.be
|
|
124
123
|
.true;
|
|
125
124
|
});
|
|
@@ -742,6 +741,25 @@ describe("GReputation", () => {
|
|
|
742
741
|
);
|
|
743
742
|
});
|
|
744
743
|
|
|
744
|
+
it("it should be able to get totalSupplyLocal for particular block", async () => {
|
|
745
|
+
let currentBlock = await ethers.provider.getBlockNumber();
|
|
746
|
+
const totalSupplyLocalBefore = await grep["totalSupplyLocal(uint256)"](currentBlock);
|
|
747
|
+
await grepWithOwner["mint(address,uint256)"](
|
|
748
|
+
founder,
|
|
749
|
+
ethers.utils.parseEther("1")
|
|
750
|
+
);
|
|
751
|
+
currentBlock = await ethers.provider.getBlockNumber();
|
|
752
|
+
const totalSupplyLocalAfter = await grep["totalSupplyLocal(uint256)"](currentBlock);
|
|
753
|
+
expect(totalSupplyLocalAfter).to.equal(
|
|
754
|
+
totalSupplyLocalBefore.add(ethers.utils.parseEther("1"))
|
|
755
|
+
);
|
|
756
|
+
|
|
757
|
+
await grepWithOwner["burn(address,uint256)"](
|
|
758
|
+
founder,
|
|
759
|
+
ethers.utils.parseEther("1")
|
|
760
|
+
);
|
|
761
|
+
});
|
|
762
|
+
|
|
745
763
|
it("it should return 0 when particular blockchain state is empty", async () => {
|
|
746
764
|
let state = await grep["getVotesAtBlockchain(bytes32,address,uint256)"](
|
|
747
765
|
ethers.utils.keccak256(ethers.utils.toUtf8Bytes("notExist")),
|
|
@@ -844,5 +862,18 @@ describe("GReputation", () => {
|
|
|
844
862
|
expect(await grep.balanceOfLocal(repTarget)).to.equal(111);
|
|
845
863
|
expect(await grep.balanceOfLocal(rep3)).to.equal(startBalance.add(111));
|
|
846
864
|
});
|
|
865
|
+
|
|
866
|
+
it("should get accurate prior votes", async () => {
|
|
867
|
+
await grep.connect(signers[3]).undelegate();
|
|
868
|
+
const selectedBlock = await ethers.provider.getBlockNumber();
|
|
869
|
+
const selectedBlockVotes = await grep.getCurrentVotes(rep2);
|
|
870
|
+
await advanceBlocks(1);
|
|
871
|
+
await (await grepWithOwner["mint(address,uint256)"](rep2, 1)).wait();
|
|
872
|
+
await advanceBlocks(1);
|
|
873
|
+
const priorSelectedBlockVotes = await grep.getPriorVotes(rep2, selectedBlock);
|
|
874
|
+
const votesAfterAdvancing = await grep.getCurrentVotes(rep2);
|
|
875
|
+
expect(priorSelectedBlockVotes).to.eq(selectedBlockVotes);
|
|
876
|
+
expect(priorSelectedBlockVotes).to.be.not.eq(votesAfterAdvancing);
|
|
877
|
+
});
|
|
847
878
|
});
|
|
848
879
|
});
|
|
@@ -859,4 +859,65 @@ describe("StakersDistribution - staking with GD and get Rewards in GDAO", () =>
|
|
|
859
859
|
expect(usdcStakingPendingGdaos).to.be.gt(0);
|
|
860
860
|
expect(usdcStakingPendingGdaos.toString().length).to.be.gt(18);
|
|
861
861
|
});
|
|
862
|
-
|
|
862
|
+
|
|
863
|
+
it("should get user minted and pending rewards", async () => {
|
|
864
|
+
const goodFundManagerFactory = await ethers.getContractFactory(
|
|
865
|
+
"GoodFundManager"
|
|
866
|
+
);
|
|
867
|
+
|
|
868
|
+
const simpleStaking1 = await deployDaiStaking();
|
|
869
|
+
const ictrl = await ethers.getContractAt(
|
|
870
|
+
"Controller",
|
|
871
|
+
controller,
|
|
872
|
+
schemeMock
|
|
873
|
+
);
|
|
874
|
+
const currentBlockNumber = await ethers.provider.getBlockNumber();
|
|
875
|
+
let encodedData = goodFundManagerFactory.interface.encodeFunctionData(
|
|
876
|
+
"setStakingReward",
|
|
877
|
+
[
|
|
878
|
+
"100000",
|
|
879
|
+
simpleStaking1.address,
|
|
880
|
+
currentBlockNumber - 5,
|
|
881
|
+
currentBlockNumber + 20,
|
|
882
|
+
false
|
|
883
|
+
] // set 10 gd per block
|
|
884
|
+
);
|
|
885
|
+
await ictrl.genericCall(goodFundManager.address, encodedData, avatar, 0);
|
|
886
|
+
|
|
887
|
+
let [userMintedRewardBeforeStake, userPendingRewardBeforeStake] =
|
|
888
|
+
await getUserMintedAndPendingRewards(staker.address, simpleStaking1.address);
|
|
889
|
+
expect(userMintedRewardBeforeStake).to.eq('0');
|
|
890
|
+
expect(userPendingRewardBeforeStake).to.eq('0');
|
|
891
|
+
|
|
892
|
+
const stakingAmount = ethers.utils.parseEther("1000");
|
|
893
|
+
await dai["mint(address,uint256)"](staker.address, stakingAmount);
|
|
894
|
+
await dai.connect(staker).approve(simpleStaking1.address, stakingAmount);
|
|
895
|
+
await simpleStaking1.connect(staker).stake(stakingAmount, 0, false);
|
|
896
|
+
await advanceBlocks(5); //should accumulate some gdao rewards
|
|
897
|
+
|
|
898
|
+
let [userMintedRewardAfterStake, userPendingRewardAfterStake] =
|
|
899
|
+
await getUserMintedAndPendingRewards(staker.address, simpleStaking1.address);
|
|
900
|
+
expect(userMintedRewardAfterStake.eq(0));
|
|
901
|
+
expect(userPendingRewardAfterStake.gt(0));
|
|
902
|
+
|
|
903
|
+
await stakersDistribution.claimReputation(staker.address, [
|
|
904
|
+
simpleStaking1.address
|
|
905
|
+
]);
|
|
906
|
+
|
|
907
|
+
let [userMintedRewardAfterClaim, userPendingRewardAfterClaim] =
|
|
908
|
+
await getUserMintedAndPendingRewards(staker.address, simpleStaking1.address);
|
|
909
|
+
expect(userMintedRewardAfterClaim.gt(0));
|
|
910
|
+
expect(userPendingRewardAfterClaim.eq(0));
|
|
911
|
+
});
|
|
912
|
+
|
|
913
|
+
async function getUserMintedAndPendingRewards(stakerAddress, stakingContractAddress) {
|
|
914
|
+
const userMintedAndPending = await stakersDistribution.getUserMintedAndPending(
|
|
915
|
+
[stakingContractAddress],
|
|
916
|
+
stakerAddress
|
|
917
|
+
);
|
|
918
|
+
const userMintedReward = userMintedAndPending[0];
|
|
919
|
+
const userPendingReward = userMintedAndPending[1];
|
|
920
|
+
|
|
921
|
+
return [userMintedReward, userPendingReward];
|
|
922
|
+
}
|
|
923
|
+
});
|
package/test/helpers.ts
CHANGED
|
@@ -222,6 +222,20 @@ export const createDAO = async () => {
|
|
|
222
222
|
await ictrl.genericCall(nameService.address, encoded, Avatar.address, 0);
|
|
223
223
|
};
|
|
224
224
|
|
|
225
|
+
const runAsAvatarOnly = async (contract, functionAbi, ...parameters) => {
|
|
226
|
+
const funcNameEnd = functionAbi.indexOf('(');;
|
|
227
|
+
expect(funcNameEnd).to.be.gt(-1);
|
|
228
|
+
const functionName = functionAbi.substring(0, funcNameEnd);
|
|
229
|
+
|
|
230
|
+
const tx = await contract[functionAbi](...parameters).catch(e=>e);
|
|
231
|
+
expect(tx.message.toUpperCase()).to.contain("AVATAR");
|
|
232
|
+
const encoded = contract.interface.encodeFunctionData(functionName, [
|
|
233
|
+
...parameters
|
|
234
|
+
]);
|
|
235
|
+
|
|
236
|
+
await ictrl.genericCall(contract.address, encoded, Avatar.address, 0);
|
|
237
|
+
};
|
|
238
|
+
|
|
225
239
|
const setReserveToken = async (token, gdReserve, tokenReserve, RR) => {
|
|
226
240
|
const encoded = marketMaker.interface.encodeFunctionData(
|
|
227
241
|
"initializeToken",
|
|
@@ -296,6 +310,7 @@ export const createDAO = async () => {
|
|
|
296
310
|
identityDeployed: Identity,
|
|
297
311
|
nameService,
|
|
298
312
|
setDAOAddress,
|
|
313
|
+
runAsAvatarOnly,
|
|
299
314
|
setSchemes,
|
|
300
315
|
setReserveToken,
|
|
301
316
|
genericCall,
|
|
@@ -597,4 +597,15 @@ describe("GoodMarketMaker - calculate gd value at reserve", () => {
|
|
|
597
597
|
expect(gdPriceAfter.gt(gdPriceBefore));
|
|
598
598
|
expect(reserveRatioAfter).to.be.equal(reserveRatioBefore);
|
|
599
599
|
});
|
|
600
|
+
|
|
601
|
+
it("should not set reserve ratio daily expansion with illigal values", async () => {
|
|
602
|
+
const invalidZeroDenominator = 0;
|
|
603
|
+
await expect(marketMaker.setReserveRatioDailyExpansion(1, invalidZeroDenominator)).to.be.
|
|
604
|
+
revertedWith("denominator must be above 0");
|
|
605
|
+
|
|
606
|
+
const denominator = 1;
|
|
607
|
+
const nominatorHigherThanDenom = 2;
|
|
608
|
+
await expect(marketMaker.setReserveRatioDailyExpansion(nominatorHigherThanDenom, denominator)).to.be.
|
|
609
|
+
revertedWith("Invalid nom or denom value");
|
|
610
|
+
});
|
|
600
611
|
});
|