@gooddollar/goodprotocol 1.0.10 → 1.0.11
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/CompoundVotingMachine.sol/CompoundVotingMachine.dbg.json +1 -1
- package/artifacts/contracts/governance/GReputation.sol/GReputation.dbg.json +1 -1
- 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/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 +1 -1
- package/artifacts/contracts/staking/BaseShareFieldV2.sol/BaseShareFieldV2.json +48 -104
- 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/SimpleStakingV2.sol/SimpleStakingV2.json +48 -123
- 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 +65 -12
- 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 +1 -1
- package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.json +52 -127
- package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.dbg.json +1 -1
- package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.json +57 -14
- package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.json +6 -6
- package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.dbg.json +4 -0
- package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.json +1092 -0
- package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.dbg.json +1 -1
- 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/contracts/staking/BaseShareFieldV2.sol +45 -21
- package/contracts/staking/SimpleStaking.sol +0 -7
- package/contracts/staking/SimpleStakingV2.sol +10 -44
- package/contracts/staking/aave/AaveStakingFactory.sol +45 -19
- package/contracts/staking/aave/GoodAaveStaking.sol +1 -1
- package/contracts/staking/aave/GoodAaveStakingV2.sol +2 -2
- package/contracts/staking/compound/CompoundStakingFactory.sol +41 -18
- package/contracts/staking/compound/GoodCompoundStaking.sol +1 -1
- package/contracts/staking/compound/GoodCompoundStakingV2.sol +315 -0
- package/package.json +1 -1
- package/releases/deployment.json +55 -47
- package/scripts/upgradeToV2/upgradeToV2.ts +7 -3
- package/test/governance/StakersDistribution.test.ts +43 -14
- package/test/helpers.ts +1 -0
- package/test/staking/CompoundStakingFactory.test.ts +24 -21
- package/test/staking/DifferentStakingTokens.test.ts +3 -1
- package/test/staking/DonationsStaking.test.ts +3 -1
- package/test/staking/GoodAaveStakingFactory.test.ts +26 -23
- package/test/staking/SimpleDAIStaking.test.ts +3 -11
- package/test/staking/StakingRewards.test.ts +20 -14
- package/test/staking/SwapHelper.test.ts +4 -1
- package/test/staking/UsdcAaveStaking.test.ts +23 -8
- package/test/ubi/UBIScheme.e2e.test.ts +1 -1
- package/test/utils/ProtocolUpgrade.test.ts +1 -1
- package/artifacts/contracts/staking/aave/AaveStakingFactoryV2.sol/AaveStakingFactoryV2.dbg.json +0 -4
- package/artifacts/contracts/staking/aave/AaveStakingFactoryV2.sol/AaveStakingFactoryV2.json +0 -148
- package/contracts/staking/aave/AaveStakingFactoryV2.sol +0 -93
- package/test/staking/GoodAaveStakingFactoryV2.test.ts +0 -122
- package/test/staking/UsdcAaveStakingV2.test.ts +0 -291
|
@@ -4,7 +4,7 @@ import { expect } from "chai";
|
|
|
4
4
|
import {
|
|
5
5
|
CERC20,
|
|
6
6
|
GoodCompoundStaking,
|
|
7
|
-
CompoundStakingFactory
|
|
7
|
+
CompoundStakingFactory
|
|
8
8
|
} from "../../types";
|
|
9
9
|
import { createDAO, deployUniswap } from "../helpers";
|
|
10
10
|
import { Contract } from "ethers";
|
|
@@ -46,33 +46,35 @@ describe("CompoundStakingFactory", () => {
|
|
|
46
46
|
await dao.setDAOAddress("UNISWAP_ROUTER", router.address);
|
|
47
47
|
let swapHelper = await ethers
|
|
48
48
|
.getContractFactory("UniswapV2SwapHelper")
|
|
49
|
-
.then(
|
|
49
|
+
.then(_ => _.deploy());
|
|
50
50
|
|
|
51
51
|
stakingFactory = (await ethers
|
|
52
52
|
.getContractFactory("CompoundStakingFactory", {
|
|
53
|
-
libraries: { UniswapV2SwapHelper: swapHelper.address }
|
|
53
|
+
libraries: { UniswapV2SwapHelper: swapHelper.address }
|
|
54
54
|
})
|
|
55
|
-
.then(
|
|
55
|
+
.then(_ => _.deploy())) as CompoundStakingFactory;
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
it("should create proxy clone", async () => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
});
|
|
58
|
+
// it("should create proxy clone", async () => {
|
|
59
|
+
// const res = await (
|
|
60
|
+
// await stakingFactory.clone(cdai, ethers.constants.HashZero)
|
|
61
|
+
// ).wait();
|
|
62
|
+
// const log = res.events.find(_ => _.event === "Deployed");
|
|
63
|
+
// const detAddress = await stakingFactory.predictAddress(
|
|
64
|
+
// cdai,
|
|
65
|
+
// ethers.constants.HashZero
|
|
66
|
+
// );
|
|
67
|
+
// expect(log).to.not.empty;
|
|
68
|
+
// expect(log.args.proxy).to.equal(detAddress);
|
|
69
|
+
// expect(log.args.cToken).to.equal(cdai);
|
|
70
|
+
// });
|
|
71
71
|
|
|
72
72
|
it("should create and initialize clone", async () => {
|
|
73
73
|
console.log(await dao.nameService.getAddress("UNISWAP_ROUTER"));
|
|
74
74
|
const res = await (
|
|
75
|
-
await stakingFactory
|
|
75
|
+
await stakingFactory[
|
|
76
|
+
"cloneAndInit(address,address,uint64,address,address,address[])"
|
|
77
|
+
](
|
|
76
78
|
cdai,
|
|
77
79
|
dao.nameService.address,
|
|
78
80
|
5760,
|
|
@@ -81,8 +83,9 @@ describe("CompoundStakingFactory", () => {
|
|
|
81
83
|
[]
|
|
82
84
|
)
|
|
83
85
|
).wait();
|
|
84
|
-
const log = res.events.find(
|
|
86
|
+
const log = res.events.find(_ => _.event === "Deployed");
|
|
85
87
|
const detAddress = await stakingFactory.predictAddress(
|
|
88
|
+
await stakingFactory.impl(),
|
|
86
89
|
cdai,
|
|
87
90
|
ethers.utils.solidityKeccak256(
|
|
88
91
|
["address", "uint64", "address", "address[]"],
|
|
@@ -95,12 +98,12 @@ describe("CompoundStakingFactory", () => {
|
|
|
95
98
|
|
|
96
99
|
//check initialization
|
|
97
100
|
const staking: GoodCompoundStaking = (await ethers.getContractAt(
|
|
98
|
-
"
|
|
101
|
+
"GoodCompoundStakingV2",
|
|
99
102
|
detAddress
|
|
100
103
|
)) as GoodCompoundStaking;
|
|
101
104
|
expect(await staking.iToken()).to.equal(cdai);
|
|
102
105
|
expect(await staking.token()).to.equal(dai);
|
|
103
|
-
expect(await staking.name()).to.equal("
|
|
106
|
+
expect(await staking.name()).to.equal("GoodCompoundStakingV2 Compound DAI");
|
|
104
107
|
expect(await staking.symbol()).to.equal("gcDAI");
|
|
105
108
|
});
|
|
106
109
|
});
|
|
@@ -90,7 +90,9 @@ describe("Different decimals staking token", () => {
|
|
|
90
90
|
goodDollar = await ethers.getContractAt("IGoodDollar", gd);
|
|
91
91
|
|
|
92
92
|
tokenUsdOracleFactory = await ethers.getContractFactory("BatUSDMockOracle");
|
|
93
|
-
goodCompoundStakingFactory = await getStakingFactory(
|
|
93
|
+
goodCompoundStakingFactory = await getStakingFactory(
|
|
94
|
+
"GoodCompoundStakingV2"
|
|
95
|
+
);
|
|
94
96
|
|
|
95
97
|
tokenFactory = await ethers.getContractFactory("DecimalsMock");
|
|
96
98
|
cTokenFactory = await ethers.getContractFactory("cDecimalsMock");
|
|
@@ -57,7 +57,9 @@ describe("DonationsStaking - DonationStaking contract that receives funds in ETH
|
|
|
57
57
|
const goodFundManagerFactory = await ethers.getContractFactory(
|
|
58
58
|
"GoodFundManager"
|
|
59
59
|
);
|
|
60
|
-
goodCompoundStakingFactory = await getStakingFactory(
|
|
60
|
+
goodCompoundStakingFactory = await getStakingFactory(
|
|
61
|
+
"GoodCompoundStakingV2"
|
|
62
|
+
);
|
|
61
63
|
|
|
62
64
|
const daiFactory = await ethers.getContractFactory("DAIMock");
|
|
63
65
|
let {
|
|
@@ -50,36 +50,38 @@ describe("AaveStakingFactory", () => {
|
|
|
50
50
|
await dao.setDAOAddress("AAVE", aave.address);
|
|
51
51
|
let swapHelper = await ethers
|
|
52
52
|
.getContractFactory("UniswapV2SwapHelper")
|
|
53
|
-
.then(
|
|
53
|
+
.then(_ => _.deploy());
|
|
54
54
|
|
|
55
55
|
stakingFactory = (await ethers
|
|
56
56
|
.getContractFactory("AaveStakingFactory", {
|
|
57
|
-
libraries: { UniswapV2SwapHelper: swapHelper.address }
|
|
57
|
+
libraries: { UniswapV2SwapHelper: swapHelper.address }
|
|
58
58
|
})
|
|
59
|
-
.then(
|
|
59
|
+
.then(_ => _.deploy())) as AaveStakingFactory;
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
it("should create proxy clone", async () => {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
});
|
|
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
76
|
|
|
77
77
|
it("should create and initialize clone", async () => {
|
|
78
78
|
const ns = await ethers
|
|
79
79
|
.getContractFactory("NameService")
|
|
80
|
-
.then(
|
|
80
|
+
.then(_ => _.deploy());
|
|
81
81
|
const res = await (
|
|
82
|
-
await stakingFactory
|
|
82
|
+
await stakingFactory[
|
|
83
|
+
"cloneAndInit(address,address,address,uint64,address,address,address,address[])"
|
|
84
|
+
](
|
|
83
85
|
usdc.address,
|
|
84
86
|
lendingPool.address,
|
|
85
87
|
dao.nameService.address,
|
|
@@ -90,8 +92,9 @@ describe("AaveStakingFactory", () => {
|
|
|
90
92
|
[usdc.address, dai]
|
|
91
93
|
)
|
|
92
94
|
).wait();
|
|
93
|
-
const log = res.events.find(
|
|
95
|
+
const log = res.events.find(_ => _.event === "Deployed");
|
|
94
96
|
const detAddress = await stakingFactory.predictAddress(
|
|
97
|
+
await stakingFactory.impl(),
|
|
95
98
|
usdc.address,
|
|
96
99
|
ethers.utils.solidityKeccak256(
|
|
97
100
|
["address", "address", "uint64", "address", "address", "address"],
|
|
@@ -101,7 +104,7 @@ describe("AaveStakingFactory", () => {
|
|
|
101
104
|
5760,
|
|
102
105
|
stakingFactory.address,
|
|
103
106
|
incentiveController.address,
|
|
104
|
-
aaveUsdOracle.address
|
|
107
|
+
aaveUsdOracle.address
|
|
105
108
|
]
|
|
106
109
|
)
|
|
107
110
|
);
|
|
@@ -111,12 +114,12 @@ describe("AaveStakingFactory", () => {
|
|
|
111
114
|
|
|
112
115
|
//check initialization
|
|
113
116
|
const staking: GoodAaveStaking = (await ethers.getContractAt(
|
|
114
|
-
"
|
|
117
|
+
"GoodAaveStakingV2",
|
|
115
118
|
detAddress
|
|
116
119
|
)) as GoodAaveStaking;
|
|
117
120
|
expect(await staking.iToken()).to.equal(lendingPool.address);
|
|
118
121
|
expect(await staking.token()).to.equal(usdc.address);
|
|
119
|
-
expect(await staking.name()).to.equal("
|
|
120
|
-
expect(await staking.symbol()).to.equal("
|
|
122
|
+
expect(await staking.name()).to.equal("GoodAaveStakingV2 USDC");
|
|
123
|
+
expect(await staking.symbol()).to.equal("gaUSDC");
|
|
121
124
|
});
|
|
122
125
|
});
|
|
@@ -97,7 +97,9 @@ describe("SimpleDAISTAking - staking with cDAI mocks", () => {
|
|
|
97
97
|
);
|
|
98
98
|
compUsdOracle = await compUsdOracleFactory.deploy();
|
|
99
99
|
|
|
100
|
-
goodCompoundStakingFactory = await getStakingFactory(
|
|
100
|
+
goodCompoundStakingFactory = await getStakingFactory(
|
|
101
|
+
"GoodCompoundStakingV2"
|
|
102
|
+
);
|
|
101
103
|
|
|
102
104
|
deployStaking = async (token, itoken) => {
|
|
103
105
|
return goodCompoundStakingFactory.deploy().then(async contract => {
|
|
@@ -1256,16 +1258,6 @@ describe("SimpleDAISTAking - staking with cDAI mocks", () => {
|
|
|
1256
1258
|
);
|
|
1257
1259
|
});
|
|
1258
1260
|
|
|
1259
|
-
it("should not withdraw interest if the recipient specified by the owner is the staking contract", async () => {
|
|
1260
|
-
await advanceBlocks(BLOCK_INTERVAL);
|
|
1261
|
-
await setDAOAddress("FUND_MANAGER", founder.address);
|
|
1262
|
-
const error = await goodCompoundStaking
|
|
1263
|
-
.collectUBIInterest(goodCompoundStaking.address)
|
|
1264
|
-
.catch(e => e);
|
|
1265
|
-
await setDAOAddress("FUND_MANAGER", goodFundManager.address);
|
|
1266
|
-
expect(error.message).to.be.not.empty;
|
|
1267
|
-
});
|
|
1268
|
-
|
|
1269
1261
|
it("should pause the contract", async () => {
|
|
1270
1262
|
let encodedCall = goodCompoundStakingFactory.interface.encodeFunctionData(
|
|
1271
1263
|
"pause",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ethers, upgrades } from "hardhat";
|
|
2
2
|
import { BigNumber, Contract } from "ethers";
|
|
3
3
|
import { expect } from "chai";
|
|
4
|
-
import { GoodMarketMaker
|
|
4
|
+
import { GoodMarketMaker } from "../../types";
|
|
5
5
|
import {
|
|
6
6
|
createDAO,
|
|
7
7
|
increaseTime,
|
|
@@ -56,7 +56,9 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
56
56
|
const goodFundManagerFactory = await ethers.getContractFactory(
|
|
57
57
|
"GoodFundManager"
|
|
58
58
|
);
|
|
59
|
-
goodCompoundStakingFactory = await getStakingFactory(
|
|
59
|
+
goodCompoundStakingFactory = await getStakingFactory(
|
|
60
|
+
"GoodCompoundStakingV2"
|
|
61
|
+
);
|
|
60
62
|
goodCompoundStakingTestFactory = await getStakingFactory(
|
|
61
63
|
"GoodCompoundStakingTest"
|
|
62
64
|
);
|
|
@@ -307,11 +309,13 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
307
309
|
await dai
|
|
308
310
|
.connect(staker)
|
|
309
311
|
.approve(goodCompoundStaking.address, stakingAmount);
|
|
310
|
-
const totalEffectiveStakesBeforeStake =
|
|
311
|
-
|
|
312
|
+
const totalEffectiveStakesBeforeStake = await goodCompoundStaking
|
|
313
|
+
.getStats()
|
|
314
|
+
.then(_ => _[3]);
|
|
312
315
|
await goodCompoundStaking.connect(staker).stake(stakingAmount, 100, false);
|
|
313
|
-
const totalEffectiveStakesAfterStake =
|
|
314
|
-
|
|
316
|
+
const totalEffectiveStakesAfterStake = await goodCompoundStaking
|
|
317
|
+
.getStats()
|
|
318
|
+
.then(_ => _[3]);
|
|
315
319
|
await goodCompoundStaking
|
|
316
320
|
.connect(staker)
|
|
317
321
|
.withdrawStake(stakingAmount, false);
|
|
@@ -326,11 +330,13 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
326
330
|
await dai
|
|
327
331
|
.connect(staker)
|
|
328
332
|
.approve(goodCompoundStaking.address, stakingAmount);
|
|
329
|
-
const totalEffectiveStakesBeforeStake =
|
|
330
|
-
|
|
333
|
+
const totalEffectiveStakesBeforeStake = await goodCompoundStaking
|
|
334
|
+
.getStats()
|
|
335
|
+
.then(_ => _[3]);
|
|
331
336
|
await goodCompoundStaking.connect(staker).stake(stakingAmount, 0, false);
|
|
332
|
-
const totalEffectiveStakesAfterStake =
|
|
333
|
-
|
|
337
|
+
const totalEffectiveStakesAfterStake = await goodCompoundStaking
|
|
338
|
+
.getStats()
|
|
339
|
+
.then(_ => _[3]);
|
|
334
340
|
await goodCompoundStaking
|
|
335
341
|
.connect(staker)
|
|
336
342
|
.withdrawStake(stakingAmount, false);
|
|
@@ -1452,7 +1458,7 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1452
1458
|
expect(activeContractsCount).to.be.equal(activeContractsCountAfterRemoved);
|
|
1453
1459
|
});
|
|
1454
1460
|
it("it should distribute rewards correctly when there is multiple stakers", async () => {
|
|
1455
|
-
const simpleStaking1 =
|
|
1461
|
+
const simpleStaking1 = await goodCompoundStakingTestFactory.deploy(
|
|
1456
1462
|
bat.address,
|
|
1457
1463
|
cBat.address,
|
|
1458
1464
|
nameService.address,
|
|
@@ -1462,7 +1468,7 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1462
1468
|
batUsdOracle.address,
|
|
1463
1469
|
compUsdOracle.address,
|
|
1464
1470
|
[bat.address, dai.address]
|
|
1465
|
-
)
|
|
1471
|
+
);
|
|
1466
1472
|
const currentBlock = await ethers.provider.getBlockNumber();
|
|
1467
1473
|
const rewardsPerBlock = BN.from("1000");
|
|
1468
1474
|
let encodedData = goodFundManager.interface.encodeFunctionData(
|
|
@@ -1624,7 +1630,7 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1624
1630
|
await genericCall(goodFundManager.address, encodedData, avatar, 0);
|
|
1625
1631
|
});
|
|
1626
1632
|
it("it should get staking reward even reward amount is too low", async () => {
|
|
1627
|
-
const simpleStaking1 =
|
|
1633
|
+
const simpleStaking1 = await goodCompoundStakingTestFactory.deploy(
|
|
1628
1634
|
bat.address,
|
|
1629
1635
|
cBat.address,
|
|
1630
1636
|
nameService.address,
|
|
@@ -1634,7 +1640,7 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1634
1640
|
batUsdOracle.address,
|
|
1635
1641
|
compUsdOracle.address,
|
|
1636
1642
|
[bat.address, dai.address]
|
|
1637
|
-
)
|
|
1643
|
+
);
|
|
1638
1644
|
|
|
1639
1645
|
const currentBlock = await ethers.provider.getBlockNumber();
|
|
1640
1646
|
const rewardsPerBlock = BN.from("100");
|
|
@@ -46,7 +46,9 @@ describe("SwapHelper - Helper library for swap on the Uniswap", () => {
|
|
|
46
46
|
const swapHelperTestFactory = await ethers.getContractFactory(
|
|
47
47
|
"SwapHelperTest"
|
|
48
48
|
);
|
|
49
|
-
goodCompoundStakingFactory = await getStakingFactory(
|
|
49
|
+
goodCompoundStakingFactory = await getStakingFactory(
|
|
50
|
+
"GoodCompoundStakingV2"
|
|
51
|
+
);
|
|
50
52
|
goodCompoundStakingTestFactory = await getStakingFactory(
|
|
51
53
|
"GoodCompoundStakingTest"
|
|
52
54
|
);
|
|
@@ -210,6 +212,7 @@ describe("SwapHelper - Helper library for swap on the Uniswap", () => {
|
|
|
210
212
|
["100", simpleStaking.address, 0, 10000, true]
|
|
211
213
|
);
|
|
212
214
|
await genericCall(goodFundManager.address, encodedData, avatar, 0);
|
|
215
|
+
console.log({ redeemedAmount, safeAmount });
|
|
213
216
|
expect(reserve[0].sub(currentReserve[0])).to.be.lt(currentGains[1]);
|
|
214
217
|
expect(currentReserve[0].sub(reserve[0])).to.be.equal(redeemedAmount);
|
|
215
218
|
});
|
|
@@ -8,7 +8,7 @@ import { createDAO, deployUniswap, getStakingFactory } from "../helpers";
|
|
|
8
8
|
const BN = ethers.BigNumber;
|
|
9
9
|
export const NULL_ADDRESS = ethers.constants.AddressZero;
|
|
10
10
|
|
|
11
|
-
describe("
|
|
11
|
+
describe("UsdcAaveStakingV2 - staking with USDC mocks to AAVE interface", () => {
|
|
12
12
|
let dai: Contract;
|
|
13
13
|
let usdc: Contract;
|
|
14
14
|
let pair: Contract, uniswapRouter: Contract;
|
|
@@ -29,7 +29,6 @@ describe("UsdcAaveStaking - staking with USDC mocks to AAVE interface", () => {
|
|
|
29
29
|
lendingPool,
|
|
30
30
|
setDAOAddress,
|
|
31
31
|
genericCall,
|
|
32
|
-
goodReserve,
|
|
33
32
|
goodAaveStakingFactory;
|
|
34
33
|
before(async () => {
|
|
35
34
|
[founder, staker, ...signers] = await ethers.getSigners();
|
|
@@ -39,7 +38,7 @@ describe("UsdcAaveStaking - staking with USDC mocks to AAVE interface", () => {
|
|
|
39
38
|
const goodFundManagerFactory = await ethers.getContractFactory(
|
|
40
39
|
"GoodFundManager"
|
|
41
40
|
);
|
|
42
|
-
goodAaveStakingFactory = await getStakingFactory("
|
|
41
|
+
goodAaveStakingFactory = await getStakingFactory("GoodAaveStakingV2");
|
|
43
42
|
|
|
44
43
|
const lendingPoolFactory = await ethers.getContractFactory(
|
|
45
44
|
"LendingPoolMock"
|
|
@@ -56,10 +55,8 @@ describe("UsdcAaveStaking - staking with USDC mocks to AAVE interface", () => {
|
|
|
56
55
|
marketMaker: mm,
|
|
57
56
|
daiAddress,
|
|
58
57
|
genericCall: gc,
|
|
59
|
-
COMP
|
|
60
|
-
reserve
|
|
58
|
+
COMP
|
|
61
59
|
} = await createDAO();
|
|
62
|
-
goodReserve = reserve;
|
|
63
60
|
dai = await ethers.getContractAt("DAIMock", daiAddress);
|
|
64
61
|
avatar = av;
|
|
65
62
|
controller = ctrl;
|
|
@@ -240,8 +237,9 @@ describe("UsdcAaveStaking - staking with USDC mocks to AAVE interface", () => {
|
|
|
240
237
|
expect(gdBalanceAfterCollectInterest.gt(gdBalanceBeforeCollectInterest));
|
|
241
238
|
});
|
|
242
239
|
|
|
243
|
-
it("it should
|
|
240
|
+
it("it should collect stkAAVE to Avatar when collecting interest", async () => {
|
|
244
241
|
const stakingAmount = ethers.utils.parseUnits("100", 6);
|
|
242
|
+
const avatarBalance = await aave.balanceOf(avatar);
|
|
245
243
|
await goodAaveStaking.stake(stakingAmount, "0", false);
|
|
246
244
|
const currentGainsAfterStake = await goodAaveStaking.currentGains(
|
|
247
245
|
false,
|
|
@@ -278,7 +276,24 @@ describe("UsdcAaveStaking - staking with USDC mocks to AAVE interface", () => {
|
|
|
278
276
|
);
|
|
279
277
|
expect(currentGainsAfterEarnRewards[4]).to.be.equal(0); // stkAAVE rewards shouldnt count as gain
|
|
280
278
|
expect(currentGainsAfterCollectInterest[4]).to.be.equal("0");
|
|
281
|
-
expect(await aave.balanceOf(
|
|
279
|
+
expect(await aave.balanceOf(avatar)).gt(avatarBalance);
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
it("should be able to transfer staked tokens", async () => {
|
|
283
|
+
const stakingAmount = ethers.utils.parseUnits("100", 6);
|
|
284
|
+
|
|
285
|
+
await goodAaveStaking.connect(staker).stake(stakingAmount, 0, false);
|
|
286
|
+
|
|
287
|
+
await lendingPool.giveInterestToUser("1500", goodAaveStaking.address); // increase interest by calling giveInterestToUser
|
|
288
|
+
|
|
289
|
+
await expect(
|
|
290
|
+
goodAaveStaking
|
|
291
|
+
.connect(staker)
|
|
292
|
+
.transfer(signers[0].address, stakingAmount)
|
|
293
|
+
).not.reverted;
|
|
294
|
+
expect(await goodAaveStaking.balanceOf(signers[0].address)).to.eq(
|
|
295
|
+
stakingAmount
|
|
296
|
+
);
|
|
282
297
|
});
|
|
283
298
|
async function addLiquidity(
|
|
284
299
|
token0: Contract,
|
|
@@ -197,7 +197,7 @@ describe("ProtocolUpgrade - Upgrade old protocol contracts to new ones", () => {
|
|
|
197
197
|
deployment["test-mainnet"].GoodReserveCDai
|
|
198
198
|
);
|
|
199
199
|
newStakingContract = await ethers.getContractAt(
|
|
200
|
-
"
|
|
200
|
+
"GoodCompoundStakingV2",
|
|
201
201
|
deployment["test-mainnet"].StakingContracts[0][0]
|
|
202
202
|
);
|
|
203
203
|
stakingAmountOfNewDonationStaking =
|