@gooddollar/goodprotocol 2.0.21 → 2.0.22-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/abis/ISuperToken.min.json +1 -1
- package/artifacts/abis/SuperGoodDollar.min.json +1 -1
- package/artifacts/abis/SuperToken.min.json +1 -1
- 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/IIdentityV2.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/ILendingPool.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IMultichainRouter.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/fuseFaucet/Faucet.sol/Faucet.dbg.json +1 -1
- package/artifacts/contracts/fuseFaucet/FuseFaucet.sol/FuseFaucet.dbg.json +1 -1
- package/artifacts/contracts/fuseFaucet/FuseFaucetV2.sol/FuseFaucetV2.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/GoodDollarStaking.sol/GoodDollarStaking.dbg.json +1 -1
- package/artifacts/contracts/governance/GoodDollarStaking.sol/IGovernanceStaking.dbg.json +1 -1
- package/artifacts/contracts/governance/GoodDollarStaking.sol/IStakingUpgrade.dbg.json +1 -1
- package/artifacts/contracts/governance/GoodDollarStaking.sol/RewardsMinter.dbg.json +1 -1
- 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/StakersDistribution.sol/StakersDistribution.dbg.json +1 -1
- package/artifacts/contracts/identity/IdentityV2.sol/IdentityV2.dbg.json +1 -1
- package/artifacts/contracts/invite/InvitesFuseV2.sol/InvitesFuseV2.dbg.json +1 -1
- package/artifacts/contracts/invite/InvitesV1.sol/InvitesV1.dbg.json +1 -1
- package/artifacts/contracts/invite/InvitesV2.sol/InvitesV2.dbg.json +1 -1
- 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/DistributionBridgeMock.sol/DistributionBridgeMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTestHelper.dbg.json +1 -1
- package/artifacts/contracts/mocks/EthUSDMockOracle.sol/EthUSDMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/FeesFormularMock.sol/FeesFormulaMock.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/GoodDollarStakingMock.sol/GoodDollarStakingMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/IdentityMock.sol/IdentityMock.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/MultichainRouterMock.sol/IWrapper.dbg.json +1 -1
- package/artifacts/contracts/mocks/MultichainRouterMock.sol/MultichainRouterMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/OverMintTester.sol/IGoodDollarStakingTest.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/PayableMock.sol/PayableMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/SixteenDecimalsTokenMock.sol/SixteenDecimalsTokenMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/StakingMockFixedAPY.sol/StakingMockFixedAPY.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/UpgradableMocks.sol/UpgradableMock3.dbg.json +1 -1
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock4.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/DistributionHelper.sol/DistributionHelper.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/FuseStakingV3.sol/FuseStakingV3.dbg.json +1 -1
- package/artifacts/contracts/staking/FuseStakingV3.sol/IConsensus.dbg.json +1 -1
- package/artifacts/contracts/staking/FuseStakingV3.sol/PegSwap.dbg.json +1 -1
- 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/GoodAaveStaking.sol/GoodAaveStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.dbg.json +1 -1
- package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.dbg.json +1 -1
- package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.dbg.json +1 -1
- package/artifacts/contracts/staking/utils/Math64X64.sol/Math64x64.dbg.json +1 -1
- package/artifacts/contracts/staking/utils/StakingRewardsFixedAPY.sol/StakingRewardsFixedAPY.dbg.json +1 -1
- package/artifacts/contracts/token/ERC20PresetMinterPauserUpgradeable.sol/ERC20PresetMinterPauserUpgradeable.dbg.json +1 -1
- package/artifacts/contracts/token/ERC677.sol/ERC677.dbg.json +1 -1
- package/artifacts/contracts/token/ERC677.sol/ERC677Receiver.dbg.json +1 -1
- package/artifacts/contracts/token/GoodDollar.sol/GoodDollar.dbg.json +1 -1
- package/artifacts/contracts/token/IFeesFormula.sol/IFeesFormula.dbg.json +1 -1
- package/artifacts/contracts/token/MultichainFeeFormula.sol/MultichainFeeFormula.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/ERC20Permit.sol/ERC20Permit.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/ERC20Permit.sol/SelfApprove.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/ISuperGoodDollar.sol/IGoodDollarCustom.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/ISuperGoodDollar.sol/ISuperGoodDollar.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/ISuperToken.sol/ISuperToken.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/ISuperToken.sol/ISuperToken.json +5 -0
- package/artifacts/contracts/token/superfluid/SuperGoodDollar.sol/SuperGoodDollar.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/SuperGoodDollar.sol/SuperGoodDollar.json +25 -2
- package/artifacts/contracts/token/superfluid/SuperToken.sol/SuperToken.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/SuperToken.sol/SuperToken.json +7 -2
- package/artifacts/contracts/token/superfluid/SuperfluidToken.sol/SuperfluidToken.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/UUPSProxiable.sol/UUPSProxiable.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/UUPSProxy.sol/Proxy.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/UUPSProxy.sol/UUPSProxy.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/UUPSProxy.sol/UUPSUtils.dbg.json +1 -1
- package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.dbg.json +1 -1
- package/artifacts/contracts/ubi/UBISchemeV2.sol/UBISchemeV2.dbg.json +1 -1
- package/artifacts/contracts/utils/AdminWallet.sol/AdminWallet.dbg.json +1 -1
- package/artifacts/contracts/utils/AdminWalletFuse.sol/AdminWalletFuse.dbg.json +1 -1
- 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/BuyAndBridgeHelper.sol/BuyAndBridgeHelper.dbg.json +1 -1
- package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDClone.dbg.json +1 -1
- package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDCloneFactory.dbg.json +1 -1
- package/artifacts/contracts/utils/BuyGDClone.sol/DonateGDClone.dbg.json +1 -1
- package/artifacts/contracts/utils/BuyGDClone.sol/IQuoterV2.dbg.json +1 -1
- package/artifacts/contracts/utils/BuyGDClone.sol/ISwapRouter.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/GDFaucet.sol/GDFaucet.dbg.json +1 -1
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/GoodDollarMintBurnWrapper.dbg.json +1 -1
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/IRouter.dbg.json +1 -1
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/PausableControl.dbg.json +1 -1
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/TokenOperation.dbg.json +1 -1
- package/artifacts/contracts/utils/IdentityFix.sol/IdentityFix.dbg.json +1 -1
- package/artifacts/contracts/utils/MultiCall.sol/Multicall.dbg.json +1 -1
- package/artifacts/contracts/utils/MultichainBridgeHelper.sol/MultichainBridgeHelper.dbg.json +1 -1
- package/artifacts/contracts/utils/NameService.sol/NameService.dbg.json +1 -1
- package/artifacts/contracts/utils/OneTimePayments.sol/OneTimePayments.dbg.json +1 -1
- package/artifacts/contracts/utils/OneTimePaymentsV2.sol/OneTimePaymentsV2.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/contracts/token/superfluid/ISuperToken.sol +1 -0
- package/contracts/token/superfluid/SuperGoodDollar.sol +11 -2
- package/contracts/token/superfluid/SuperToken.sol +8 -0
- package/dist/artifacts/contracts/token/superfluid/SuperGoodDollar.sol/SuperGoodDollar.json +25 -2
- package/hardhat.config.ts +1 -1
- package/package.json +4 -3
- package/scripts/blockchainTestSetup.sh +1 -1
- package/test/faucet/Faucet.test.ts +63 -19
- package/test/faucet/FuseFaucet.test.ts +43 -14
- package/test/governance/ClaimersDistribution.test.ts +3 -3
- package/test/governance/CompoundVotingMachine.castvote.test.ts +3 -6
- package/test/governance/CompoundVotingMachine.crossblockchain.ts +2 -2
- package/test/governance/CompoundVotingMachine.daoscheme.ts +1 -1
- package/test/governance/CompoundVotingMachine.guardian.test.ts +4 -4
- package/test/governance/CompoundVotingMachine.propose.test.ts +8 -8
- package/test/governance/CompoundVotingMachine.state.test.ts +4 -4
- package/test/governance/GReputation.test.ts +6 -6
- package/test/governance/GoodDollarStaking.gd.test.ts +44 -71
- package/test/governance/GoodDollarStaking.good.test.ts +52 -73
- package/test/governance/GovernanceStaking.test.ts +1 -1
- package/test/governance/Reputation.test.ts +2 -2
- package/test/helpers.ts +1 -1
- package/test/identity/IdentityV2.test.ts +12 -12
- package/test/invite/InvitesV1.test.ts +6 -6
- package/test/invite/InvitesV2.test.ts +272 -81
- package/test/reserve/DistributionHelper.test.ts +232 -139
- package/test/reserve/GoodMarketMaker.test.ts +17 -17
- package/test/reserve/GoodReserveCDai.cap.test.ts +4 -4
- package/test/reserve/GoodReserveCDai.distribution.test.ts +64 -42
- package/test/reserve/GoodReserveCDai.gdx.test.ts +1 -1
- package/test/reserve/GoodReserveCDai.pause.test.ts +8 -8
- package/test/reserve/GoodReserveCDai.test.ts +307 -101
- package/test/reserve/GoodReserveCDai.uniswap.test.ts +1 -1
- package/test/staking/DonationsStaking.test.ts +2 -2
- package/test/staking/FuseStaking.test.ts +3 -3
- package/test/staking/GoodAaveStakingFactory.test.ts +2 -2
- package/test/staking/StakingRewards.test.ts +913 -320
- package/test/staking/StakingRewardsFixedAPY.test.ts +62 -66
- package/test/token/CeloGasToken.test.ts +2 -2
- package/test/token/GoodDollar.test.ts +5 -5
- package/test/token/SuperGoodDollar.test.ts +17 -13
- package/test/ubi/UBIScheme.test.ts +1 -1
- package/test/utils/AdminWallet.test.ts +10 -10
- package/test/utils/BuyAndBridgeHelper.test.ts +33 -9
- package/test/utils/GoodDollarMintBurnWrapper.test.ts +265 -113
- package/test/utils/NameService.test.ts +1 -1
- package/test/utils/ProxyFactory.test.ts +2 -2
- package/types/contracts/token/superfluid/SuperGoodDollar.ts +26 -0
- package/types/factories/contracts/token/superfluid/ISuperToken__factory.ts +5 -0
- package/types/factories/contracts/token/superfluid/SuperGoodDollar__factory.ts +24 -1
- package/types/factories/contracts/token/superfluid/SuperToken__factory.ts +6 -1
- package/yarn.lock +635 -253
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { expect } from "chai";
|
|
2
|
-
import { ethers
|
|
2
|
+
import { ethers } from "hardhat";
|
|
3
3
|
import { loadFixture } from "@nomicfoundation/hardhat-network-helpers";
|
|
4
4
|
import { createDAO, advanceBlocks } from "../helpers";
|
|
5
5
|
import { StakingMockFixedAPY } from "../../types";
|
|
@@ -72,30 +72,27 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
72
72
|
goodDollar = await ethers.getContractAt("IGoodDollar", gd);
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
-
const fixture_initOnly = async (
|
|
76
|
-
const staking: StakingMockFixedAPY = (await
|
|
77
|
-
|
|
78
|
-
StakingABI,
|
|
75
|
+
const fixture_initOnly = async () => {
|
|
76
|
+
const staking: StakingMockFixedAPY = (await ethers.deployContract(
|
|
77
|
+
"StakingMockFixedAPY",
|
|
79
78
|
[INTEREST_RATE_5APY_X64]
|
|
80
79
|
)) as StakingMockFixedAPY;
|
|
81
80
|
|
|
82
81
|
return { staking };
|
|
83
82
|
};
|
|
84
83
|
|
|
85
|
-
const fixture_2 = async (
|
|
86
|
-
const staking: StakingMockFixedAPY = (await
|
|
87
|
-
|
|
88
|
-
StakingABI,
|
|
84
|
+
const fixture_2 = async () => {
|
|
85
|
+
const staking: StakingMockFixedAPY = (await ethers.deployContract(
|
|
86
|
+
"StakingMockFixedAPY",
|
|
89
87
|
[INTEREST_RATE_5APY_X64]
|
|
90
88
|
)) as StakingMockFixedAPY;
|
|
91
89
|
|
|
92
90
|
return { staking };
|
|
93
91
|
};
|
|
94
92
|
|
|
95
|
-
const fixture_1year = async (
|
|
96
|
-
const staking: StakingMockFixedAPY = (await
|
|
97
|
-
|
|
98
|
-
StakingABI,
|
|
93
|
+
const fixture_1year = async () => {
|
|
94
|
+
const staking: StakingMockFixedAPY = (await ethers.deployContract(
|
|
95
|
+
"StakingMockFixedAPY",
|
|
99
96
|
[INTEREST_RATE_5APY_X64]
|
|
100
97
|
)) as StakingMockFixedAPY;
|
|
101
98
|
|
|
@@ -107,10 +104,9 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
107
104
|
return { staking };
|
|
108
105
|
};
|
|
109
106
|
|
|
110
|
-
const fixture_1year_single = async (
|
|
111
|
-
const staking: StakingMockFixedAPY = (await
|
|
112
|
-
|
|
113
|
-
StakingABI,
|
|
107
|
+
const fixture_1year_single = async () => {
|
|
108
|
+
const staking: StakingMockFixedAPY = (await ethers.deployContract(
|
|
109
|
+
"StakingMockFixedAPY",
|
|
114
110
|
[INTEREST_RATE_5APY_X64]
|
|
115
111
|
)) as StakingMockFixedAPY;
|
|
116
112
|
|
|
@@ -121,7 +117,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
121
117
|
};
|
|
122
118
|
|
|
123
119
|
it("should set APY successfully", async () => {
|
|
124
|
-
const { staking } = await
|
|
120
|
+
const { staking } = await loadFixture(fixture_initOnly);
|
|
125
121
|
|
|
126
122
|
const beforeSetInterestRateIn128 = await staking.interestRatePerBlockX64();
|
|
127
123
|
|
|
@@ -136,7 +132,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
136
132
|
});
|
|
137
133
|
|
|
138
134
|
it("should update staker info after stake operation", async () => {
|
|
139
|
-
const { staking } = await
|
|
135
|
+
const { staking } = await loadFixture(fixture_initOnly);
|
|
140
136
|
|
|
141
137
|
await stake(staker1, 9000, staking);
|
|
142
138
|
|
|
@@ -157,7 +153,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
157
153
|
});
|
|
158
154
|
|
|
159
155
|
it("should handle stake/withdraw the minimal amount of 1", async () => {
|
|
160
|
-
const { staking } = await
|
|
156
|
+
const { staking } = await loadFixture(fixture_initOnly);
|
|
161
157
|
|
|
162
158
|
await stake(staker4, 1, staking);
|
|
163
159
|
|
|
@@ -194,46 +190,46 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
194
190
|
staker4.address,
|
|
195
191
|
(await staking.amountToShares(1)).sub(1)
|
|
196
192
|
)
|
|
197
|
-
).revertedWith(
|
|
193
|
+
).revertedWith(/min shares/);
|
|
198
194
|
});
|
|
199
195
|
|
|
200
196
|
it("should fail on staking 0", async () => {
|
|
201
|
-
const { staking } = await
|
|
202
|
-
await expect(stake(staker4, 0, staking)).to.be.revertedWith(
|
|
197
|
+
const { staking } = await loadFixture(fixture_initOnly);
|
|
198
|
+
await expect(stake(staker4, 0, staking)).to.be.revertedWith(/stake 0/);
|
|
203
199
|
});
|
|
204
200
|
|
|
205
201
|
xit("should fail on staking with donationRatio > 100", async () => {
|
|
206
|
-
const { staking } = await
|
|
202
|
+
const { staking } = await loadFixture(fixture_initOnly);
|
|
207
203
|
await expect(stake(staker4, 1, 101, staking)).to.be.revertedWith(
|
|
208
|
-
|
|
204
|
+
/donation/
|
|
209
205
|
);
|
|
210
206
|
});
|
|
211
207
|
|
|
212
|
-
|
|
213
|
-
const { staking } = await
|
|
214
|
-
await expect(stake(staker4,
|
|
208
|
+
xit("should fail on staking less than minimal amount of 1", async () => {
|
|
209
|
+
const { staking } = await loadFixture(fixture_initOnly);
|
|
210
|
+
await expect(stake(staker4, 1, staking)).to.be.reverted;
|
|
215
211
|
});
|
|
216
212
|
|
|
217
213
|
it("Should fail to withdraw exceeding amount", async () => {
|
|
218
|
-
const { staking } = await
|
|
214
|
+
const { staking } = await loadFixture(fixture_initOnly);
|
|
219
215
|
await stake(staker1, 1000, staking);
|
|
220
216
|
|
|
221
217
|
const shares = await staking.balanceOf(staker1.address);
|
|
222
218
|
await expect(staking.withdraw(staker1.address, shares.add(1))).revertedWith(
|
|
223
|
-
|
|
219
|
+
/no balance/
|
|
224
220
|
);
|
|
225
221
|
});
|
|
226
222
|
|
|
227
223
|
it("Should fail to withdraw when empty balance", async () => {
|
|
228
|
-
const { staking } = await
|
|
224
|
+
const { staking } = await loadFixture(fixture_initOnly);
|
|
229
225
|
|
|
230
226
|
await expect(staking.withdraw(staker1.address, 0)).revertedWith(
|
|
231
|
-
|
|
227
|
+
/no balance/
|
|
232
228
|
);
|
|
233
229
|
});
|
|
234
230
|
|
|
235
231
|
it("should update global stats after stake operation", async () => {
|
|
236
|
-
const { staking } = await
|
|
232
|
+
const { staking } = await loadFixture(fixture_initOnly);
|
|
237
233
|
const statsBefore = await staking.stats();
|
|
238
234
|
const PRECISION = await staking.PRECISION();
|
|
239
235
|
|
|
@@ -250,7 +246,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
250
246
|
});
|
|
251
247
|
|
|
252
248
|
it("should update staker info after withdraw operation", async () => {
|
|
253
|
-
const { staking } = await
|
|
249
|
+
const { staking } = await loadFixture(fixture_initOnly);
|
|
254
250
|
await stake(staker1, 9000, staking);
|
|
255
251
|
await advanceBlocks(BLOCKS_ONE_YEAR);
|
|
256
252
|
|
|
@@ -281,7 +277,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
281
277
|
});
|
|
282
278
|
|
|
283
279
|
it("should update global stats after withdraw operation", async () => {
|
|
284
|
-
const { staking } = await
|
|
280
|
+
const { staking } = await loadFixture(fixture_initOnly);
|
|
285
281
|
await stake(staker1, 9000, staking);
|
|
286
282
|
const statsBefore = await staking.stats();
|
|
287
283
|
await advanceBlocks(BLOCKS_ONE_YEAR);
|
|
@@ -301,7 +297,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
301
297
|
});
|
|
302
298
|
|
|
303
299
|
it("should compound savings over period", async () => {
|
|
304
|
-
const { staking } = await
|
|
300
|
+
const { staking } = await loadFixture(fixture_1year);
|
|
305
301
|
console.log(
|
|
306
302
|
"shares:",
|
|
307
303
|
await staking.balanceOf(staker1.address),
|
|
@@ -336,7 +332,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
336
332
|
});
|
|
337
333
|
|
|
338
334
|
it("should compound savings over 2 years and new staker after 1 year", async () => {
|
|
339
|
-
const { staking } = await
|
|
335
|
+
const { staking } = await loadFixture(fixture_1year);
|
|
340
336
|
|
|
341
337
|
//add staker after first year
|
|
342
338
|
await stake(staker4, 125125, staking);
|
|
@@ -353,7 +349,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
353
349
|
});
|
|
354
350
|
|
|
355
351
|
it("should withdraw full amount", async () => {
|
|
356
|
-
const { staking } = await
|
|
352
|
+
const { staking } = await loadFixture(fixture_1year);
|
|
357
353
|
const balance = await staking.sharesOf(staker1.address);
|
|
358
354
|
await staking.withdraw(staker1.address, balance);
|
|
359
355
|
const info = await staking.stakersInfo(staker1.address);
|
|
@@ -364,7 +360,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
364
360
|
});
|
|
365
361
|
|
|
366
362
|
it("should withdraw partial amount and calculate savings correctly after 1 year", async () => {
|
|
367
|
-
const { staking } = await
|
|
363
|
+
const { staking } = await loadFixture(fixture_1year);
|
|
368
364
|
const sharesBefore = await staking.sharesOf(staker3.address);
|
|
369
365
|
//9500 withdraw / sharePrice = shares to reduce
|
|
370
366
|
const expectedSharesRedeemed = await staking.amountToShares(9500);
|
|
@@ -387,7 +383,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
387
383
|
});
|
|
388
384
|
|
|
389
385
|
xit("should withdraw partial amount when partially donating and calculate savings correctly after 1 year", async () => {
|
|
390
|
-
const { staking } = await
|
|
386
|
+
const { staking } = await loadFixture(fixture_1year);
|
|
391
387
|
const infoBefore = await staking.stakersInfo(staker2.address);
|
|
392
388
|
const expectedSharesRedeemed = await getExpectedSharesChange(
|
|
393
389
|
9500 + 125,
|
|
@@ -426,7 +422,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
426
422
|
});
|
|
427
423
|
|
|
428
424
|
xit("should withdraw partial amount when donating 100% and calculate savings correctly after 1 year", async () => {
|
|
429
|
-
const { staking } = await
|
|
425
|
+
const { staking } = await loadFixture(fixture_1year);
|
|
430
426
|
const infoBefore = await staking.stakersInfo(staker1.address);
|
|
431
427
|
const expectedSharesRedeemed = await getExpectedSharesChange(
|
|
432
428
|
9500 + 500,
|
|
@@ -465,7 +461,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
465
461
|
});
|
|
466
462
|
|
|
467
463
|
xit("should withdraw rewards from rewards only", async () => {
|
|
468
|
-
const { staking } = await
|
|
464
|
+
const { staking } = await loadFixture(fixture_1year);
|
|
469
465
|
const infoBefore = await staking.stakersInfo(staker3.address);
|
|
470
466
|
const balance = await staking.getSavings(staker3.address);
|
|
471
467
|
|
|
@@ -485,7 +481,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
485
481
|
});
|
|
486
482
|
|
|
487
483
|
xit("should update avgDonationRatio after second stake", async () => {
|
|
488
|
-
const { staking } = await
|
|
484
|
+
const { staking } = await loadFixture(fixture_1year);
|
|
489
485
|
const infoBefore = await staking.stakersInfo(staker1.address);
|
|
490
486
|
const statsBefore = await staking.stats();
|
|
491
487
|
|
|
@@ -510,7 +506,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
510
506
|
});
|
|
511
507
|
|
|
512
508
|
xit("should update avgDonationRatio after partial withdraw", async () => {
|
|
513
|
-
const { staking } = await
|
|
509
|
+
const { staking } = await loadFixture(fixture_1year);
|
|
514
510
|
const infoBeforeWithdraw = await staking.stakersInfo(staker1.address);
|
|
515
511
|
const statsBeforeWithdraw = await staking.stats();
|
|
516
512
|
const expectedSharesRedeemed = await getExpectedSharesChange(
|
|
@@ -536,7 +532,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
536
532
|
});
|
|
537
533
|
|
|
538
534
|
it("should calculate correct share price after savings has grown", async () => {
|
|
539
|
-
const { staking } = await
|
|
535
|
+
const { staking } = await loadFixture(fixture_1year);
|
|
540
536
|
const SHARE_PRECISION = await staking.SHARE_PRECISION();
|
|
541
537
|
|
|
542
538
|
const savingsBefore = await staking.compound();
|
|
@@ -561,7 +557,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
561
557
|
});
|
|
562
558
|
|
|
563
559
|
it("should check compound function compounds savings correctly", async () => {
|
|
564
|
-
const { staking } = await
|
|
560
|
+
const { staking } = await loadFixture(fixture_1year);
|
|
565
561
|
const PRECISION = await staking.PRECISION();
|
|
566
562
|
|
|
567
563
|
const expectedCompoundBefore = 3 * 10000 * 1.05; // 3 stakers of 10000 with 5 APY, after one year
|
|
@@ -577,7 +573,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
577
573
|
});
|
|
578
574
|
|
|
579
575
|
it("should calculate earned rewards in period", async () => {
|
|
580
|
-
const { staking } = await
|
|
576
|
+
const { staking } = await loadFixture(fixture_1year);
|
|
581
577
|
let earnedRewards1 = await staking.earned(staker1.address);
|
|
582
578
|
let earnedRewards2 = await staking.earned(staker2.address);
|
|
583
579
|
let earnedRewards3 = await staking.earned(staker3.address);
|
|
@@ -597,7 +593,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
597
593
|
});
|
|
598
594
|
|
|
599
595
|
it("Should undo reward part and update staker info", async () => {
|
|
600
|
-
const { staking } = await
|
|
596
|
+
const { staking } = await loadFixture(fixture_1year);
|
|
601
597
|
|
|
602
598
|
const initialInfo = await staking.stakersInfo(staker3.address);
|
|
603
599
|
const sharesToWithdraw = await staking.amountToShares(500);
|
|
@@ -613,7 +609,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
613
609
|
});
|
|
614
610
|
|
|
615
611
|
it("Should undo reward and keep global stats the same", async () => {
|
|
616
|
-
const { staking } = await
|
|
612
|
+
const { staking } = await loadFixture(fixture_1year);
|
|
617
613
|
|
|
618
614
|
const initialStats = await staking.stats();
|
|
619
615
|
|
|
@@ -636,7 +632,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
636
632
|
});
|
|
637
633
|
|
|
638
634
|
xit("Should undo reward when part of them is donated and keep info and global stats the same", async () => {
|
|
639
|
-
const { staking } = await
|
|
635
|
+
const { staking } = await loadFixture(fixture_1year);
|
|
640
636
|
|
|
641
637
|
const initialStats = await staking.stats();
|
|
642
638
|
const initialInfo = await staking.stakersInfo(staker2.address);
|
|
@@ -674,7 +670,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
674
670
|
});
|
|
675
671
|
|
|
676
672
|
it("Should undo reward when withdrawing partial rewards keep info and global stats the same", async () => {
|
|
677
|
-
const { staking } = await
|
|
673
|
+
const { staking } = await loadFixture(fixture_1year);
|
|
678
674
|
|
|
679
675
|
const initialInfo = await staking.stakersInfo(staker2.address);
|
|
680
676
|
const initialSavings = await staking.getSavings(staker2.address);
|
|
@@ -706,7 +702,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
706
702
|
|
|
707
703
|
//helper test
|
|
708
704
|
// it.only("Should not suffer from endless precission loss", async () => {
|
|
709
|
-
// const { staking } = await
|
|
705
|
+
// const { staking } = await loadFixture(fixture_1year_single);
|
|
710
706
|
|
|
711
707
|
// const initialShares = await staking.sharesOf(staker3.address);
|
|
712
708
|
// const maxLoss = await staking.amountToShares(1);
|
|
@@ -724,7 +720,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
724
720
|
xit("Should undo reward when withdrawing rewards + deposit and update deposit info and stats correctly", async () => {});
|
|
725
721
|
|
|
726
722
|
it("Should be able to withdraw right after staking", async () => {
|
|
727
|
-
const { staking } = await
|
|
723
|
+
const { staking } = await loadFixture(fixture_1year);
|
|
728
724
|
await stake(staker4, 10000, staking);
|
|
729
725
|
await expect(
|
|
730
726
|
staking.withdraw(
|
|
@@ -742,7 +738,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
742
738
|
});
|
|
743
739
|
|
|
744
740
|
it("should calculate savings correctly after set APY ", async () => {
|
|
745
|
-
const { staking } = await
|
|
741
|
+
const { staking } = await loadFixture(fixture_1year);
|
|
746
742
|
await stake(staker4, 125125, staking);
|
|
747
743
|
|
|
748
744
|
// before set, APY is 5%
|
|
@@ -769,7 +765,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
769
765
|
});
|
|
770
766
|
|
|
771
767
|
it("should handle first stake big, followed by smaller actions", async () => {
|
|
772
|
-
const { staking } = await
|
|
768
|
+
const { staking } = await loadFixture(fixture_2);
|
|
773
769
|
|
|
774
770
|
await stake(staker4, 10000000, staking);
|
|
775
771
|
|
|
@@ -787,7 +783,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
787
783
|
expect(sharesAfterSmallStake).gt(0);
|
|
788
784
|
|
|
789
785
|
const onegdShares = await staking.amountToShares(1);
|
|
790
|
-
await expect(staking.withdraw(staker4.address, 1000)).revertedWith(
|
|
786
|
+
await expect(staking.withdraw(staker4.address, 1000)).revertedWith(/min/);
|
|
791
787
|
|
|
792
788
|
await expect(staking.withdraw(staker4.address, onegdShares)).not.reverted;
|
|
793
789
|
await expect(
|
|
@@ -805,7 +801,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
805
801
|
});
|
|
806
802
|
|
|
807
803
|
it("should handle first stake small, followed by 100 Billion stake", async () => {
|
|
808
|
-
const { staking } = await
|
|
804
|
+
const { staking } = await loadFixture(fixture_2);
|
|
809
805
|
|
|
810
806
|
await stake(signers[0], 5, staking);
|
|
811
807
|
await stake(staker4, 1e13, staking);
|
|
@@ -822,7 +818,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
822
818
|
});
|
|
823
819
|
|
|
824
820
|
it("should handle first 100 Billion stake, followed by a small", async () => {
|
|
825
|
-
const { staking } = await
|
|
821
|
+
const { staking } = await loadFixture(fixture_2);
|
|
826
822
|
|
|
827
823
|
await stake(staker4, 1e13, staking);
|
|
828
824
|
await stake(signers[0], 5, staking);
|
|
@@ -838,8 +834,8 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
838
834
|
});
|
|
839
835
|
|
|
840
836
|
xit("should withdraw all when amount=max uint", async () => {
|
|
841
|
-
const { staking } = await
|
|
842
|
-
await expect(staking.withdraw(staker3.address, 0)).revertedWith(
|
|
837
|
+
const { staking } = await loadFixture(fixture_1year);
|
|
838
|
+
await expect(staking.withdraw(staker3.address, 0)).revertedWith(/balance/);
|
|
843
839
|
await staking.withdraw(staker3.address, ethers.constants.MaxUint256);
|
|
844
840
|
const info = await staking.stakersInfo(staker3.address);
|
|
845
841
|
|
|
@@ -849,7 +845,7 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
849
845
|
});
|
|
850
846
|
|
|
851
847
|
it("should be able to get rewards debt (ie savings - deposits - donated rewards)", async () => {
|
|
852
|
-
const { staking } = await
|
|
848
|
+
const { staking } = await loadFixture(fixture_1year);
|
|
853
849
|
const debt = (await staking.getRewardsDebt()).div(
|
|
854
850
|
ethers.utils.parseEther("1")
|
|
855
851
|
); //debt is in 1e18 precision
|
|
@@ -857,23 +853,23 @@ describe("StakingRewardsFixedAPY - generic staking for fixed APY rewards contrac
|
|
|
857
853
|
});
|
|
858
854
|
|
|
859
855
|
it("should not be able to stake less than share price", async () => {
|
|
860
|
-
const { staking } = await
|
|
856
|
+
const { staking } = await loadFixture(fixture_1year);
|
|
861
857
|
await advanceBlocks(BLOCKS_TEN_YEARS * 20);
|
|
862
858
|
|
|
863
|
-
await expect(stake(staker1, 1, staking)).to.revertedWith(
|
|
859
|
+
await expect(stake(staker1, 1, staking)).to.revertedWith(/share/);
|
|
864
860
|
await expect(stake(staker1, 2, staking)).to.not.reverted;
|
|
865
861
|
});
|
|
866
862
|
|
|
867
863
|
it("should not be able to withdraw less than share price", async () => {
|
|
868
|
-
const { staking } = await
|
|
864
|
+
const { staking } = await loadFixture(fixture_1year);
|
|
869
865
|
await advanceBlocks(BLOCKS_TEN_YEARS * 10);
|
|
870
866
|
|
|
871
867
|
const sharePrice = await staking.sharePrice();
|
|
872
|
-
await expect(staking.withdraw(staker3.address, 1)).to.revertedWith(
|
|
868
|
+
await expect(staking.withdraw(staker3.address, 1)).to.revertedWith(/share/);
|
|
873
869
|
});
|
|
874
870
|
|
|
875
871
|
it("should handle stake/withdraw for 1 Trillion staked for 50 years", async () => {
|
|
876
|
-
const { staking } = await
|
|
872
|
+
const { staking } = await loadFixture(fixture_1year);
|
|
877
873
|
await stake(staker3, 100000000000000, staking);
|
|
878
874
|
await advanceBlocks(BLOCKS_TEN_YEARS * 5);
|
|
879
875
|
|
|
@@ -91,7 +91,7 @@ describe("Celo Gas Token", () => {
|
|
|
91
91
|
|
|
92
92
|
await expect(
|
|
93
93
|
token.debitGasFees(founder.address, BigNumber.from(1))
|
|
94
|
-
).revertedWith(
|
|
94
|
+
).revertedWith(/VM/);
|
|
95
95
|
await expect(
|
|
96
96
|
token.creditGasFees(
|
|
97
97
|
founder.address,
|
|
@@ -103,6 +103,6 @@ describe("Celo Gas Token", () => {
|
|
|
103
103
|
1,
|
|
104
104
|
1
|
|
105
105
|
)
|
|
106
|
-
).revertedWith(
|
|
106
|
+
).revertedWith(/VM/);
|
|
107
107
|
});
|
|
108
108
|
});
|
|
@@ -235,14 +235,14 @@ describe("GoodDollar Token", () => {
|
|
|
235
235
|
it("should not let non owner set identity and formula", async () => {
|
|
236
236
|
await expect(
|
|
237
237
|
newtoken.connect(signers[0]).setFormula(ethers.constants.AddressZero)
|
|
238
|
-
).revertedWith(
|
|
238
|
+
).revertedWith(/not owner/);
|
|
239
239
|
await expect(
|
|
240
240
|
newtoken.connect(signers[0]).setIdentity(ethers.constants.AddressZero)
|
|
241
|
-
).revertedWith(
|
|
241
|
+
).revertedWith(/not owner/);
|
|
242
242
|
});
|
|
243
243
|
|
|
244
244
|
it("should fail transfer", async () => {
|
|
245
|
-
let data = "
|
|
245
|
+
let data = "0x";
|
|
246
246
|
|
|
247
247
|
await expect(
|
|
248
248
|
token
|
|
@@ -260,7 +260,7 @@ describe("GoodDollar Token", () => {
|
|
|
260
260
|
|
|
261
261
|
await expect(
|
|
262
262
|
token.transferAndCall(receiver.address, 1000, data)
|
|
263
|
-
).revertedWith(
|
|
263
|
+
).revertedWith(/Contract Fallback failed/);
|
|
264
264
|
expect(await receiver.wasCalled()).false;
|
|
265
265
|
});
|
|
266
266
|
|
|
@@ -309,7 +309,7 @@ describe("GoodDollar Token", () => {
|
|
|
309
309
|
await expect(unCappedToken.mint(founder.address, 1000)).not.reverted;
|
|
310
310
|
|
|
311
311
|
await expect(cappedToken.mint(founder.address, 1200)).revertedWith(
|
|
312
|
-
|
|
312
|
+
/Cannot increase supply beyond cap/
|
|
313
313
|
);
|
|
314
314
|
});
|
|
315
315
|
|
|
@@ -159,8 +159,10 @@ describe("SuperGoodDollar", async function () {
|
|
|
159
159
|
it("pauseable", async function () {
|
|
160
160
|
await loadFixture(initialState);
|
|
161
161
|
await sgd.connect(founder).pause();
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
|
|
163
|
+
await expect(sgd.transfer(bob.address, tenDollars)).revertedWithCustomError(
|
|
164
|
+
sgd,
|
|
165
|
+
"SUPER_GOODDOLLAR_PAUSED"
|
|
164
166
|
);
|
|
165
167
|
|
|
166
168
|
await expect(
|
|
@@ -169,12 +171,14 @@ describe("SuperGoodDollar", async function () {
|
|
|
169
171
|
superToken: sgd.address,
|
|
170
172
|
sender: alice.address,
|
|
171
173
|
receiver: bob.address,
|
|
172
|
-
flowRate: tenDollarsPerDay
|
|
174
|
+
flowRate: tenDollarsPerDay,
|
|
175
|
+
overrides: { gasLimit: 1000000 }
|
|
173
176
|
})
|
|
174
177
|
.exec(alice)
|
|
175
|
-
).reverted;
|
|
178
|
+
).reverted; // createflow should revert when paused
|
|
176
179
|
|
|
177
180
|
await sgd.connect(founder).unpause();
|
|
181
|
+
|
|
178
182
|
await sgd.transfer(bob.address, tenDollars);
|
|
179
183
|
});
|
|
180
184
|
|
|
@@ -186,7 +190,7 @@ describe("SuperGoodDollar", async function () {
|
|
|
186
190
|
|
|
187
191
|
await expect(
|
|
188
192
|
sgd.connect(alice).transfer(bob.address, tenDollars)
|
|
189
|
-
).revertedWith(
|
|
193
|
+
).revertedWith(/Not enough balance to pay TX fee/);
|
|
190
194
|
|
|
191
195
|
// mint the extra amount needed for 10% fees
|
|
192
196
|
await sgd.mint(alice.address, oneDollar);
|
|
@@ -215,7 +219,7 @@ describe("SuperGoodDollar", async function () {
|
|
|
215
219
|
|
|
216
220
|
await expect(
|
|
217
221
|
sgd.connect(founder).transferFrom(alice.address, bob.address, tenDollars)
|
|
218
|
-
).revertedWith(
|
|
222
|
+
).revertedWith(/Not enough balance to pay TX fee/);
|
|
219
223
|
|
|
220
224
|
// mint the extra amount needed for 10% fees
|
|
221
225
|
await sgd.connect(founder).mint(alice.address, oneDollar);
|
|
@@ -258,7 +262,7 @@ describe("SuperGoodDollar", async function () {
|
|
|
258
262
|
ethers.constants.AddressZero,
|
|
259
263
|
ethers.constants.AddressZero
|
|
260
264
|
)
|
|
261
|
-
).revertedWith(
|
|
265
|
+
).revertedWith(/Initializable: contract is already initialized/);
|
|
262
266
|
|
|
263
267
|
await expect(
|
|
264
268
|
sgd["initialize(address,uint8,string,string)"](
|
|
@@ -267,7 +271,7 @@ describe("SuperGoodDollar", async function () {
|
|
|
267
271
|
"GD",
|
|
268
272
|
"GD"
|
|
269
273
|
)
|
|
270
|
-
).revertedWith(
|
|
274
|
+
).revertedWith(/Initializable: contract is not initializing/);
|
|
271
275
|
});
|
|
272
276
|
|
|
273
277
|
it("update the GoodDollar logic", async function () {
|
|
@@ -286,7 +290,7 @@ describe("SuperGoodDollar", async function () {
|
|
|
286
290
|
|
|
287
291
|
await expect(
|
|
288
292
|
sgdProxiable.connect(eve).updateCode(newLogic.address)
|
|
289
|
-
).revertedWith(
|
|
293
|
+
).revertedWith(/not owner/);
|
|
290
294
|
|
|
291
295
|
await sgdProxiable.connect(founder).updateCode(newLogic.address);
|
|
292
296
|
|
|
@@ -313,7 +317,7 @@ describe("SuperGoodDollar", async function () {
|
|
|
313
317
|
ethers.constants.AddressZero,
|
|
314
318
|
ethers.constants.AddressZero
|
|
315
319
|
)
|
|
316
|
-
).revertedWith(
|
|
320
|
+
).revertedWith(/Initializable: contract is already initialized/);
|
|
317
321
|
});
|
|
318
322
|
|
|
319
323
|
describe("ERC20Permit", () => {
|
|
@@ -392,7 +396,7 @@ describe("SuperGoodDollar", async function () {
|
|
|
392
396
|
|
|
393
397
|
await expect(
|
|
394
398
|
sgd.permit(owner, bob.address, value, maxDeadline, v, r, s)
|
|
395
|
-
).revertedWith(
|
|
399
|
+
).revertedWith(/ERC20Permit: invalid signature/);
|
|
396
400
|
});
|
|
397
401
|
|
|
398
402
|
it("rejects other signature", async function () {
|
|
@@ -407,7 +411,7 @@ describe("SuperGoodDollar", async function () {
|
|
|
407
411
|
|
|
408
412
|
await expect(
|
|
409
413
|
sgd.permit(owner, bob.address, value, maxDeadline, v, r, s)
|
|
410
|
-
).revertedWith(
|
|
414
|
+
).revertedWith(/ERC20Permit: invalid signature/);
|
|
411
415
|
});
|
|
412
416
|
|
|
413
417
|
it("rejects expired permit", async function () {
|
|
@@ -424,7 +428,7 @@ describe("SuperGoodDollar", async function () {
|
|
|
424
428
|
|
|
425
429
|
await expect(
|
|
426
430
|
sgd.permit(owner, bob.address, value, deadline, v, r, s)
|
|
427
|
-
).revertedWith(
|
|
431
|
+
).revertedWith(/ERC20Permit: expired deadline/);
|
|
428
432
|
});
|
|
429
433
|
});
|
|
430
434
|
});
|
|
@@ -99,7 +99,7 @@ describe("UBIScheme", () => {
|
|
|
99
99
|
|
|
100
100
|
await expect(
|
|
101
101
|
ubi1.initialize(nameService.address, firstClaimPool.address, 0)
|
|
102
|
-
).revertedWith(
|
|
102
|
+
).revertedWith(/Max inactive days cannot be zero/);
|
|
103
103
|
});
|
|
104
104
|
|
|
105
105
|
it("should deploy the ubi", async () => {
|
|
@@ -100,7 +100,7 @@ describe("AdminWallet", () => {
|
|
|
100
100
|
|
|
101
101
|
it("should not top admin list when empty", async () => {
|
|
102
102
|
await expect(adminWallet["topAdmins(uint256)"](0)).revertedWith(
|
|
103
|
-
|
|
103
|
+
/Admin list is empty/
|
|
104
104
|
);
|
|
105
105
|
});
|
|
106
106
|
|
|
@@ -183,7 +183,7 @@ describe("AdminWallet", () => {
|
|
|
183
183
|
adminWallet
|
|
184
184
|
.connect(stranger)
|
|
185
185
|
["whitelist(address,string)"](whitelisted.address, "did:test")
|
|
186
|
-
).revertedWith(
|
|
186
|
+
).revertedWith(/Caller is not admin/);
|
|
187
187
|
expect(await identity.isWhitelisted(whitelisted.address)).to.false;
|
|
188
188
|
await adminWallet
|
|
189
189
|
.connect(admin)
|
|
@@ -191,7 +191,7 @@ describe("AdminWallet", () => {
|
|
|
191
191
|
expect(await identity.isWhitelisted(whitelisted.address)).to.true;
|
|
192
192
|
await expect(
|
|
193
193
|
adminWallet.connect(stranger).removeWhitelist(whitelisted.address)
|
|
194
|
-
).revertedWith(
|
|
194
|
+
).revertedWith(/Caller is not admin/);
|
|
195
195
|
expect(await identity.isWhitelisted(whitelisted.address)).to.true;
|
|
196
196
|
});
|
|
197
197
|
|
|
@@ -208,13 +208,13 @@ describe("AdminWallet", () => {
|
|
|
208
208
|
expect(await identity.isBlacklisted(blacklisted.address)).to.false;
|
|
209
209
|
await expect(
|
|
210
210
|
adminWallet.connect(stranger).blacklist(blacklisted.address)
|
|
211
|
-
).revertedWith(
|
|
211
|
+
).revertedWith(/Caller is not admin/);
|
|
212
212
|
expect(await identity.isBlacklisted(blacklisted.address)).to.false;
|
|
213
213
|
await adminWallet.connect(admin).blacklist(blacklisted.address);
|
|
214
214
|
expect(await identity.isBlacklisted(blacklisted.address)).to.true;
|
|
215
215
|
await expect(
|
|
216
216
|
adminWallet.connect(stranger).removeBlacklist(blacklisted.address)
|
|
217
|
-
).revertedWith(
|
|
217
|
+
).revertedWith(/Caller is not admin/);
|
|
218
218
|
expect(await identity.isBlacklisted(blacklisted.address)).to.true;
|
|
219
219
|
await adminWallet.connect(admin).removeBlacklist(blacklisted.address);
|
|
220
220
|
expect(await identity.isBlacklisted(blacklisted.address)).to.false;
|
|
@@ -224,14 +224,14 @@ describe("AdminWallet", () => {
|
|
|
224
224
|
const walletBalance = await ethers.provider.getBalance(adminWallet.address);
|
|
225
225
|
await expect(
|
|
226
226
|
adminWallet.connect(admin).topWallet(whitelisted.address)
|
|
227
|
-
).revertedWith(
|
|
227
|
+
).revertedWith(/hasBalance/);
|
|
228
228
|
});
|
|
229
229
|
|
|
230
230
|
it("should not allow to top wallet if user gd balance unchanged", async () => {
|
|
231
231
|
expect(await ethers.provider.getBalance(newUser.address)).eq(0);
|
|
232
232
|
await expect(
|
|
233
233
|
adminWallet.connect(admin).topWallet(newUser.address)
|
|
234
|
-
).revertedWith(
|
|
234
|
+
).revertedWith(/User has not used G\$/);
|
|
235
235
|
});
|
|
236
236
|
|
|
237
237
|
it("should allow to top wallet if user gd balance changed", async () => {
|
|
@@ -266,7 +266,7 @@ describe("AdminWallet", () => {
|
|
|
266
266
|
await gooddollar.mint(newUser.address, 1);
|
|
267
267
|
await expect(
|
|
268
268
|
adminWallet.connect(admin).topWallet(newUser.address)
|
|
269
|
-
).revertedWith(
|
|
269
|
+
).revertedWith(/User wallet has been topped too many times today/);
|
|
270
270
|
});
|
|
271
271
|
|
|
272
272
|
it("should whitelist user", async () => {
|
|
@@ -282,13 +282,13 @@ describe("AdminWallet", () => {
|
|
|
282
282
|
adminWallet
|
|
283
283
|
.connect(admin2)
|
|
284
284
|
["whitelist(address,string)"](stranger.address, "did:test")
|
|
285
|
-
).revertedWith(
|
|
285
|
+
).revertedWith(/DID already registered/);
|
|
286
286
|
});
|
|
287
287
|
|
|
288
288
|
it("should not allow anyone to upgrade", async () => {
|
|
289
289
|
await expect(
|
|
290
290
|
adminWallet.connect(admin2).upgradeTo(adminWallet.address)
|
|
291
|
-
).revertedWith(
|
|
291
|
+
).revertedWith(/not owner/);
|
|
292
292
|
});
|
|
293
293
|
|
|
294
294
|
it("should allow owner to upgrade", async () => {
|