@gooddollar/goodprotocol 2.0.13 → 2.0.14-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/DistributionBridgeMock.min.json +1 -1
- package/artifacts/abis/DistributionHelper.min.json +1 -1
- package/artifacts/abis/DistributionHelperTest.min.json +1 -1
- package/artifacts/abis/DistributionHelperTestHelper.min.json +1 -1
- package/artifacts/abis/GasPriceMockOracle.min.json +1 -1
- package/artifacts/abis/GoodCompoundStakingTest.min.json +1 -1
- package/artifacts/abis/GoodReserveCDai.min.json +1 -1
- package/artifacts/abis/IFeesFormula.min.json +1 -1
- package/artifacts/abis/ISuperGoodDollar.min.json +1 -1
- package/artifacts/abis/ISuperToken.min.json +1 -0
- package/artifacts/abis/MultichainFeeFormula.min.json +1 -0
- package/artifacts/abis/SuperGoodDollar.min.json +1 -1
- package/artifacts/abis/SuperToken.min.json +1 -1
- package/artifacts/abis/UBIScheme.min.json +1 -1
- package/artifacts/abis/UBISchemeV2.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/Faucet.sol/Faucet.json +2 -2
- package/artifacts/contracts/fuseFaucet/FuseFaucet.sol/FuseFaucet.dbg.json +1 -1
- package/artifacts/contracts/fuseFaucet/FuseFaucet.sol/FuseFaucet.json +2 -2
- package/artifacts/contracts/fuseFaucet/FuseFaucetV2.sol/FuseFaucetV2.dbg.json +1 -1
- package/artifacts/contracts/fuseFaucet/FuseFaucetV2.sol/FuseFaucetV2.json +2 -2
- 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/CompoundVotingMachine.sol/CompoundVotingMachine.json +2 -2
- package/artifacts/contracts/governance/GReputation.sol/GReputation.dbg.json +1 -1
- package/artifacts/contracts/governance/GReputation.sol/GReputation.json +2 -2
- package/artifacts/contracts/governance/GoodDollarStaking.sol/GoodDollarStaking.dbg.json +1 -1
- package/artifacts/contracts/governance/GoodDollarStaking.sol/GoodDollarStaking.json +2 -2
- 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/GovernanceStaking.sol/GovernanceStaking.json +2 -2
- 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/identity/IdentityV2.sol/IdentityV2.dbg.json +1 -1
- package/artifacts/contracts/identity/IdentityV2.sol/IdentityV2.json +2 -2
- package/artifacts/contracts/invite/InvitesFuseV2.sol/InvitesFuseV2.dbg.json +1 -1
- package/artifacts/contracts/invite/InvitesFuseV2.sol/InvitesFuseV2.json +2 -2
- package/artifacts/contracts/invite/InvitesV1.sol/InvitesV1.dbg.json +1 -1
- package/artifacts/contracts/invite/InvitesV1.sol/InvitesV1.json +2 -2
- package/artifacts/contracts/invite/InvitesV2.sol/InvitesV2.dbg.json +1 -1
- package/artifacts/contracts/invite/InvitesV2.sol/InvitesV2.json +2 -2
- package/artifacts/contracts/mocks/AaveMock.sol/AaveMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/AaveMock.sol/AaveMock.json +2 -2
- package/artifacts/contracts/mocks/AaveUSDMockOracle.sol/AaveUSDMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/AaveUSDMockOracle.sol/AaveUSDMockOracle.json +2 -2
- package/artifacts/contracts/mocks/BatUSDMockOracle.sol/BatUSDMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/BatUSDMockOracle.sol/BatUSDMockOracle.json +2 -2
- package/artifacts/contracts/mocks/CompUsdMockOracle.sol/CompUSDMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/CompUsdMockOracle.sol/CompUSDMockOracle.json +2 -2
- package/artifacts/contracts/mocks/DAIMock.sol/DAIMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/DAIMock.sol/DAIMock.json +2 -2
- package/artifacts/contracts/mocks/DaiEthPriceMockOracle.sol/DaiEthPriceMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/DaiEthPriceMockOracle.sol/DaiEthPriceMockOracle.json +2 -2
- package/artifacts/contracts/mocks/DecimalsMock.sol/DecimalsMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/DecimalsMock.sol/DecimalsMock.json +2 -2
- package/artifacts/contracts/mocks/DistributionBridgeMock.sol/DistributionBridgeMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/DistributionBridgeMock.sol/DistributionBridgeMock.json +122 -17
- package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTest.json +242 -17
- package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTestHelper.dbg.json +1 -1
- package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTestHelper.json +256 -18
- package/artifacts/contracts/mocks/EthUSDMockOracle.sol/EthUSDMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/EthUSDMockOracle.sol/EthUSDMockOracle.json +2 -2
- package/artifacts/contracts/mocks/FeesFormularMock.sol/FeesFormulaMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/FeesFormularMock.sol/FeesFormulaMock.json +2 -2
- package/artifacts/contracts/mocks/GasPriceMockOracle.sol/GasPriceMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/GasPriceMockOracle.sol/GasPriceMockOracle.json +15 -2
- 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/GoodDollarStakingMock.sol/GoodDollarStakingMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/GoodDollarStakingMock.sol/GoodDollarStakingMock.json +2 -2
- package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.json +2 -2
- package/artifacts/contracts/mocks/IdentityMock.sol/IdentityMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/IdentityMock.sol/IdentityMock.json +2 -2
- package/artifacts/contracts/mocks/IncentiveControllerMock.sol/IncentiveControllerMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/IncentiveControllerMock.sol/IncentiveControllerMock.json +2 -2
- package/artifacts/contracts/mocks/LendingPoolMock.sol/LendingPoolMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/LendingPoolMock.sol/LendingPoolMock.json +2 -2
- 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/MultichainRouterMock.sol/MultichainRouterMock.json +2 -2
- 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/OverMintTester.sol/OverMintTester.json +2 -2
- 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/PayableMock.sol/PayableMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/PayableMock.sol/PayableMock.json +2 -2
- package/artifacts/contracts/mocks/SixteenDecimalsTokenMock.sol/SixteenDecimalsTokenMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/SixteenDecimalsTokenMock.sol/SixteenDecimalsTokenMock.json +2 -2
- package/artifacts/contracts/mocks/StakingMockFixedAPY.sol/StakingMockFixedAPY.dbg.json +1 -1
- package/artifacts/contracts/mocks/StakingMockFixedAPY.sol/StakingMockFixedAPY.json +2 -2
- package/artifacts/contracts/mocks/SwapHelperTest.sol/SwapHelperTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/SwapHelperTest.sol/SwapHelperTest.json +2 -2
- package/artifacts/contracts/mocks/TwentyDecimalsTokenMock.sol/TwentyDecimalsTokenMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/TwentyDecimalsTokenMock.sol/TwentyDecimalsTokenMock.json +2 -2
- 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 +1 -1
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock3.json +2 -2
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock4.dbg.json +1 -1
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock4.json +2 -2
- package/artifacts/contracts/mocks/UsdcMock.sol/USDCMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/UsdcMock.sol/USDCMock.json +2 -2
- package/artifacts/contracts/mocks/cBATMock.sol/cBATMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cBATMock.sol/cBATMock.json +2 -2
- package/artifacts/contracts/mocks/cDAILowWorthMock.sol/cDAILowWorthMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cDAILowWorthMock.sol/cDAILowWorthMock.json +2 -2
- package/artifacts/contracts/mocks/cDAIMock.sol/cDAIMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cDAIMock.sol/cDAIMock.json +2 -2
- package/artifacts/contracts/mocks/cDAINonMintableMock.sol/cDAINonMintableMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cDAINonMintableMock.sol/cDAINonMintableMock.json +2 -2
- package/artifacts/contracts/mocks/cDecimalsMock.sol/cDecimalsMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cDecimalsMock.sol/cDecimalsMock.json +2 -2
- package/artifacts/contracts/mocks/cSDTMock.sol/cSDTMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cSDTMock.sol/cSDTMock.json +2 -2
- package/artifacts/contracts/mocks/cUSDCMock.sol/cUSDCMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cUSDCMock.sol/cUSDCMock.json +2 -2
- package/artifacts/contracts/reserve/DistributionHelper.sol/DistributionHelper.dbg.json +1 -1
- package/artifacts/contracts/reserve/DistributionHelper.sol/DistributionHelper.json +242 -17
- package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.dbg.json +1 -1
- package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.json +2 -2
- package/artifacts/contracts/reserve/GoodMarketMaker.sol/GoodMarketMaker.dbg.json +1 -1
- package/artifacts/contracts/reserve/GoodMarketMaker.sol/GoodMarketMaker.json +2 -2
- 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/reserve/GoodReserveCDai.sol/GoodReserveCDai.json +45 -19
- package/artifacts/contracts/staking/BaseShareField.sol/BaseShareField.dbg.json +1 -1
- package/artifacts/contracts/staking/BaseShareField.sol/BaseShareField.json +2 -2
- package/artifacts/contracts/staking/BaseShareFieldV2.sol/BaseShareFieldV2.dbg.json +1 -1
- package/artifacts/contracts/staking/BaseShareFieldV2.sol/BaseShareFieldV2.json +2 -2
- 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/FuseStakingV3.sol/FuseStakingV3.dbg.json +1 -1
- package/artifacts/contracts/staking/FuseStakingV3.sol/FuseStakingV3.json +2 -2
- 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/GoodFundManager.sol/GoodFundManager.json +2 -2
- 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/UniswapV2SwapHelper.sol/UniswapV2SwapHelper.json +2 -2
- 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 +2 -2
- package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.dbg.json +1 -1
- package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.json +2 -2
- package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.dbg.json +1 -1
- package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.json +2 -2
- package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.json +2 -2
- package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.dbg.json +1 -1
- package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.json +2 -2
- package/artifacts/contracts/staking/utils/Math64X64.sol/Math64x64.dbg.json +1 -1
- package/artifacts/contracts/staking/utils/Math64X64.sol/Math64x64.json +2 -2
- 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/ERC20PresetMinterPauserUpgradeable.sol/ERC20PresetMinterPauserUpgradeable.json +2 -2
- 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/GoodDollar.sol/GoodDollar.json +2 -2
- package/artifacts/contracts/token/IFeesFormula.sol/IFeesFormula.dbg.json +4 -0
- package/artifacts/contracts/token/{FeesFormula.sol → IFeesFormula.sol}/IFeesFormula.json +1 -1
- package/artifacts/contracts/token/MultichainFeeFormula.sol/MultichainFeeFormula.dbg.json +4 -0
- package/artifacts/contracts/token/MultichainFeeFormula.sol/MultichainFeeFormula.json +58 -0
- 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/ISuperGoodDollar.sol/ISuperGoodDollar.json +159 -5
- package/artifacts/contracts/token/superfluid/ISuperToken.sol/ISuperToken.dbg.json +4 -0
- package/artifacts/contracts/token/superfluid/ISuperToken.sol/ISuperToken.json +1609 -0
- package/artifacts/contracts/token/superfluid/SuperGoodDollar.sol/SuperGoodDollar.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/SuperGoodDollar.sol/SuperGoodDollar.json +233 -190
- package/artifacts/contracts/token/superfluid/SuperToken.sol/SuperToken.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/SuperToken.sol/SuperToken.json +198 -193
- 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/UUPSProxy.json +2 -2
- package/artifacts/contracts/token/superfluid/UUPSProxy.sol/UUPSUtils.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/UUPSProxy.sol/UUPSUtils.json +2 -2
- package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.dbg.json +1 -1
- package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.json +20 -2
- package/artifacts/contracts/ubi/UBISchemeV2.sol/UBISchemeV2.dbg.json +1 -1
- package/artifacts/contracts/ubi/UBISchemeV2.sol/UBISchemeV2.json +20 -2
- package/artifacts/contracts/utils/AdminWallet.sol/AdminWallet.dbg.json +1 -1
- package/artifacts/contracts/utils/AdminWallet.sol/AdminWallet.json +2 -2
- package/artifacts/contracts/utils/AdminWalletFuse.sol/AdminWalletFuse.dbg.json +1 -1
- package/artifacts/contracts/utils/AdminWalletFuse.sol/AdminWalletFuse.json +2 -2
- package/artifacts/contracts/utils/BancorFormula.sol/BancorFormula.dbg.json +1 -1
- package/artifacts/contracts/utils/BancorFormula.sol/BancorFormula.json +2 -2
- 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/BuyAndBridgeHelper.sol/BuyAndBridgeHelper.dbg.json +1 -1
- package/artifacts/contracts/utils/BuyAndBridgeHelper.sol/BuyAndBridgeHelper.json +2 -2
- package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDClone.dbg.json +1 -1
- package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDClone.json +2 -2
- package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDCloneFactory.dbg.json +1 -1
- package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDCloneFactory.json +2 -2
- 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/DAOContract.sol/DAOContract.json +2 -2
- package/artifacts/contracts/utils/DAOUpgradeableContract.sol/DAOUpgradeableContract.dbg.json +1 -1
- package/artifacts/contracts/utils/DAOUpgradeableContract.sol/DAOUpgradeableContract.json +2 -2
- package/artifacts/contracts/utils/DSMath.sol/DSMath.dbg.json +1 -1
- package/artifacts/contracts/utils/DSMath.sol/DSMath.json +2 -2
- package/artifacts/contracts/utils/DataTypes.sol/DataTypes.dbg.json +1 -1
- package/artifacts/contracts/utils/DataTypes.sol/DataTypes.json +2 -2
- package/artifacts/contracts/utils/GDFaucet.sol/GDFaucet.dbg.json +1 -1
- package/artifacts/contracts/utils/GDFaucet.sol/GDFaucet.json +2 -2
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/GoodDollarMintBurnWrapper.dbg.json +1 -1
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/GoodDollarMintBurnWrapper.json +2 -2
- 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/GoodDollarMintBurnWrapper.sol/TokenOperation.json +2 -2
- package/artifacts/contracts/utils/IdentityFix.sol/IdentityFix.dbg.json +1 -1
- package/artifacts/contracts/utils/IdentityFix.sol/IdentityFix.json +2 -2
- package/artifacts/contracts/utils/MultiCall.sol/Multicall.dbg.json +1 -1
- package/artifacts/contracts/utils/MultiCall.sol/Multicall.json +2 -2
- package/artifacts/contracts/utils/MultichainBridgeHelper.sol/MultichainBridgeHelper.dbg.json +1 -1
- package/artifacts/contracts/utils/MultichainBridgeHelper.sol/MultichainBridgeHelper.json +2 -2
- package/artifacts/contracts/utils/NameService.sol/NameService.dbg.json +1 -1
- package/artifacts/contracts/utils/NameService.sol/NameService.json +2 -2
- package/artifacts/contracts/utils/OneTimePayments.sol/OneTimePayments.dbg.json +1 -1
- package/artifacts/contracts/utils/OneTimePayments.sol/OneTimePayments.json +2 -2
- package/artifacts/contracts/utils/OneTimePaymentsV2.sol/OneTimePaymentsV2.dbg.json +1 -1
- package/artifacts/contracts/utils/OneTimePaymentsV2.sol/OneTimePaymentsV2.json +2 -2
- 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/ProtocolUpgrade.sol/ProtocolUpgrade.json +2 -2
- package/artifacts/contracts/utils/ProtocolUpgradeFuse.sol/ProtocolUpgradeFuse.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgradeFuse.sol/ProtocolUpgradeFuse.json +2 -2
- package/artifacts/contracts/utils/ProtocolUpgradeFuseRecover.sol/ProtocolUpgradeFuseRecover.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgradeFuseRecover.sol/ProtocolUpgradeFuseRecover.json +2 -2
- package/artifacts/contracts/utils/ProtocolUpgradeRecover.sol/ProtocolUpgradeRecover.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgradeRecover.sol/ProtocolUpgradeRecover.json +2 -2
- package/artifacts/contracts/utils/ProxyFactory1967.sol/ERC1967Proxy.dbg.json +1 -1
- package/artifacts/contracts/utils/ProxyFactory1967.sol/ERC1967Proxy.json +2 -2
- package/artifacts/contracts/utils/ProxyFactory1967.sol/ProxyFactory1967.dbg.json +1 -1
- package/artifacts/contracts/utils/ProxyFactory1967.sol/ProxyFactory1967.json +2 -2
- package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.dbg.json +1 -1
- package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.json +2 -2
- package/contracts/invite/InvitesFuseV2.sol +3 -2
- package/contracts/mocks/DistributionBridgeMock.sol +42 -15
- package/contracts/mocks/DistributionHelperTest.sol +6 -2
- package/contracts/mocks/FeesFormularMock.sol +14 -14
- package/contracts/mocks/GasPriceMockOracle.sol +7 -1
- package/contracts/reserve/DistributionHelper.sol +147 -23
- package/contracts/reserve/GoodReserveCDai.sol +39 -47
- package/contracts/staking/GoodFundManager.sol +18 -37
- package/contracts/token/GoodDollar.sol +11 -16
- package/contracts/token/MultichainFeeFormula.sol +34 -0
- package/contracts/token/superfluid/ConstantFlowNFTs.sol +3 -0
- package/contracts/token/superfluid/ISuperGoodDollar.sol +4 -5
- package/contracts/token/superfluid/ISuperToken.sol +464 -0
- package/contracts/token/superfluid/SuperGoodDollar.sol +408 -376
- package/contracts/token/superfluid/SuperToken.sol +144 -144
- package/contracts/ubi/UBIScheme.sol +9 -5
- package/contracts/ubi/UBISchemeV2.sol +6 -0
- package/contracts/utils/AdminWallet.sol +2 -1
- package/contracts/utils/AdminWalletFuse.sol +2 -1
- package/contracts/utils/BuyAndBridgeHelper.sol +13 -13
- package/contracts/utils/MultiCall.sol +8 -10
- package/dist/artifacts/contracts/identity/IdentityV2.sol/IdentityV2.json +2 -2
- package/dist/artifacts/contracts/token/superfluid/SuperGoodDollar.sol/SuperGoodDollar.json +233 -190
- package/dist/artifacts/contracts/token/superfluid/UUPSProxy.sol/UUPSProxy.json +2 -2
- package/dist/artifacts/contracts/utils/ProxyFactory1967.sol/ERC1967Proxy.json +2 -2
- package/hardhat.config.ts +46 -15
- package/package.json +7 -7
- package/releases/deploy-settings.json +3 -1
- package/releases/deployment.json +6 -2
- package/scripts/analytics/faucetStats.ts +19 -15
- package/scripts/fv.ts +305 -0
- package/scripts/multichain-deploy/1_basicdao-deploy.ts +18 -9
- package/scripts/multichain-deploy/helpers.ts +204 -64
- package/scripts/proposals/gip-15.ts +427 -0
- package/scripts/upgrades/multichain-formula-upgrade.ts +140 -0
- package/scripts/upgrades/restoreFunds.ts +91 -0
- package/scripts/upgrades/superfluid-nft-celo-gas-token.ts +159 -0
- package/scripts/utils.ts +15 -0
- package/test/helpers.ts +73 -10
- package/test/reserve/DistributionHelper.test.ts +183 -218
- package/test/reserve/GoodReserveCDai.distribution.test.ts +21 -144
- package/test/reserve/GoodReserveCDai.test.ts +98 -302
- package/test/staking/StakingRewards.test.ts +324 -936
- package/test/token/CeloGasToken.test.ts +108 -0
- package/test/token/SuperGoodDollar.test.ts +15 -6
- package/test/utils/AdminWallet.test.ts +97 -38
- package/test/utils/BuyAndBridgeHelper.test.ts +9 -33
- package/truffle-config.js +24 -6
- package/types/ConstantInflowNFT.ts +969 -0
- package/types/ConstantOutflowNFT.ts +1031 -0
- package/types/DistributionBridgeMock.ts +203 -70
- package/types/DistributionHelper.ts +325 -30
- package/types/DistributionHelperTest.ts +325 -30
- package/types/DistributionHelperTestHelper.ts +355 -35
- package/types/FlowNFTBase.ts +887 -0
- package/types/GasPriceMockOracle.ts +29 -0
- package/types/GoodReserveCDai.ts +79 -20
- package/types/IConstantFlowAgreementV1.ts +1391 -0
- package/types/IConstantInflowNFT.ts +772 -0
- package/types/IConstantOutflowNFT.ts +834 -0
- package/types/IERC721.ts +487 -0
- package/types/IERC721Metadata.ts +538 -0
- package/types/IFlowNFTBase.ts +711 -0
- package/types/IInstantDistributionAgreementV1.ts +1183 -0
- package/types/ILayerZeroFeeEstimator.ts +136 -0
- package/types/IMessagePassingBridge.ts +774 -0
- package/types/ISETH.ts +2668 -0
- package/types/ISETHCustom.ts +161 -0
- package/types/ISuperGoodDollar.ts +277 -25
- package/types/ISuperToken.ts +202 -346
- package/types/ISuperfluid.ts +7 -2
- package/types/ISuperfluidGovernance.ts +40 -5
- package/types/MultichainFeeFormula.ts +130 -0
- package/types/SuperGoodDollar.ts +383 -349
- package/types/SuperToken.ts +319 -344
- package/types/UBIScheme.ts +36 -0
- package/types/UBISchemeV2.ts +36 -0
- package/types/factories/AaveMock__factory.ts +1 -1
- package/types/factories/AaveStakingFactory__factory.ts +1 -1
- package/types/factories/AaveUSDMockOracle__factory.ts +1 -1
- package/types/factories/AdminWalletFuse__factory.ts +1 -1
- package/types/factories/AdminWallet__factory.ts +1 -1
- package/types/factories/BancorFormula__factory.ts +1 -1
- package/types/factories/BaseShareFieldV2__factory.ts +1 -1
- package/types/factories/BaseShareField__factory.ts +1 -1
- package/types/factories/BatUSDMockOracle__factory.ts +1 -1
- package/types/factories/BuyAndBridgeHelper__factory.ts +1 -1
- package/types/factories/BuyGDCloneFactory__factory.ts +1 -1
- package/types/factories/BuyGDClone__factory.ts +1 -1
- package/types/factories/CBATMock__factory.ts +1 -1
- package/types/factories/CDAILowWorthMock__factory.ts +1 -1
- package/types/factories/CDAIMock__factory.ts +1 -1
- package/types/factories/CDAINonMintableMock__factory.ts +1 -1
- package/types/factories/CDecimalsMock__factory.ts +1 -1
- package/types/factories/CSDTMock__factory.ts +1 -1
- package/types/factories/CUSDCMock__factory.ts +1 -1
- package/types/factories/ClaimersDistribution__factory.ts +1 -1
- package/types/factories/CompUSDMockOracle__factory.ts +1 -1
- package/types/factories/CompoundStakingFactory__factory.ts +1 -1
- package/types/factories/CompoundVotingMachine__factory.ts +1 -1
- package/types/factories/ConstantInflowNFT__factory.ts +758 -0
- package/types/factories/ConstantOutflowNFT__factory.ts +817 -0
- package/types/factories/DAIMock__factory.ts +1 -1
- package/types/factories/DAOContract__factory.ts +1 -1
- package/types/factories/DAOUpgradeableContract__factory.ts +1 -1
- package/types/factories/DaiEthPriceMockOracle__factory.ts +1 -1
- package/types/factories/DecimalsMock__factory.ts +1 -1
- package/types/factories/DistributionBridgeMock__factory.ts +121 -16
- package/types/factories/DistributionHelperTestHelper__factory.ts +255 -17
- package/types/factories/DistributionHelperTest__factory.ts +241 -16
- package/types/factories/DistributionHelper__factory.ts +241 -16
- package/types/factories/DonationsStaking__factory.ts +1 -1
- package/types/factories/ERC1967Proxy__factory.ts +1 -1
- package/types/factories/ERC20PresetMinterPauserUpgradeable__factory.ts +1 -1
- package/types/factories/ERC20Upgradeable__factory.ts +1 -1
- package/types/factories/EthUSDMockOracle__factory.ts +1 -1
- package/types/factories/EventsEmitter__factory.ts +1 -1
- package/types/factories/ExchangeHelper__factory.ts +1 -1
- package/types/factories/Faucet__factory.ts +1 -1
- package/types/factories/FeesFormulaMock__factory.ts +1 -1
- package/types/factories/FlowNFTBase__factory.ts +642 -0
- package/types/factories/FuseFaucetV2__factory.ts +1 -1
- package/types/factories/FuseFaucet__factory.ts +1 -1
- package/types/factories/FuseStakingV3__factory.ts +1 -1
- package/types/factories/GDFaucet__factory.ts +1 -1
- package/types/factories/GReputation__factory.ts +1 -1
- package/types/factories/GasPriceMockOracle__factory.ts +14 -1
- package/types/factories/GoodAaveStakingV2__factory.ts +1 -1
- package/types/factories/GoodAaveStaking__factory.ts +1 -1
- package/types/factories/GoodCompoundStakingTest__factory.ts +1 -1
- package/types/factories/GoodCompoundStakingV2__factory.ts +1 -1
- package/types/factories/GoodCompoundStaking__factory.ts +1 -1
- package/types/factories/GoodDollarMintBurnWrapper__factory.ts +1 -1
- package/types/factories/GoodDollarStakingMock__factory.ts +1 -1
- package/types/factories/GoodDollarStaking__factory.ts +1 -1
- package/types/factories/GoodDollar__factory.ts +1 -1
- package/types/factories/GoodFundManagerTest__factory.ts +1 -1
- package/types/factories/GoodFundManager__factory.ts +1 -1
- package/types/factories/GoodMarketMaker__factory.ts +1 -1
- package/types/factories/GoodReserveCDai__factory.ts +44 -18
- package/types/factories/GovernanceStaking__factory.ts +1 -1
- package/types/factories/IConstantFlowAgreementV1__factory.ts +1064 -0
- package/types/factories/IConstantInflowNFT__factory.ts +551 -0
- package/types/factories/IConstantOutflowNFT__factory.ts +614 -0
- package/types/factories/IERC721Metadata__factory.ts +356 -0
- package/types/factories/IERC721__factory.ts +308 -0
- package/types/factories/IFlowNFTBase__factory.ts +512 -0
- package/types/factories/IInstantDistributionAgreementV1__factory.ts +1015 -0
- package/types/factories/ILayerZeroFeeEstimator__factory.ts +79 -0
- package/types/factories/IMessagePassingBridge__factory.ts +446 -0
- package/types/factories/ISETHCustom__factory.ts +56 -0
- package/types/factories/ISETH__factory.ts +1866 -0
- package/types/factories/ISuperGoodDollar__factory.ts +159 -5
- package/types/factories/ISuperTokenFactory__factory.ts +5 -0
- package/types/factories/ISuperToken__factory.ts +130 -191
- package/types/factories/ISuperfluidGovernance__factory.ts +23 -5
- package/types/factories/ISuperfluid__factory.ts +10 -0
- package/types/factories/IdentityFix__factory.ts +1 -1
- package/types/factories/IdentityMock__factory.ts +1 -1
- package/types/factories/IdentityV2__factory.ts +1 -1
- package/types/factories/IncentiveControllerMock__factory.ts +1 -1
- package/types/factories/InvitesFuseV2__factory.ts +1 -1
- package/types/factories/InvitesV1__factory.ts +1 -1
- package/types/factories/InvitesV2__factory.ts +1 -1
- package/types/factories/LendingPoolMock__factory.ts +1 -1
- package/types/factories/Multicall__factory.ts +1 -1
- package/types/factories/MultichainBridgeHelper__factory.ts +1 -1
- package/types/factories/MultichainFeeFormula__factory.ts +113 -0
- package/types/factories/MultichainRouterMock__factory.ts +1 -1
- package/types/factories/NameService__factory.ts +1 -1
- package/types/factories/OneTimePaymentsV2__factory.ts +1 -1
- package/types/factories/OneTimePayments__factory.ts +1 -1
- package/types/factories/OverMintTesterRegularStake__factory.ts +1 -1
- package/types/factories/OverMintTester__factory.ts +1 -1
- package/types/factories/PayableMock__factory.ts +1 -1
- package/types/factories/ProtocolUpgradeFuseRecover__factory.ts +1 -1
- package/types/factories/ProtocolUpgradeFuse__factory.ts +1 -1
- package/types/factories/ProtocolUpgradeRecover__factory.ts +1 -1
- package/types/factories/ProtocolUpgrade__factory.ts +1 -1
- package/types/factories/ProxyFactory1967__factory.ts +1 -1
- package/types/factories/ReputationTestHelper__factory.ts +1 -1
- package/types/factories/Reputation__factory.ts +1 -1
- package/types/factories/SixteenDecimalsTokenMock__factory.ts +1 -1
- package/types/factories/StakersDistribution__factory.ts +1 -1
- package/types/factories/StakingMockFixedAPY__factory.ts +1 -1
- package/types/factories/SuperGoodDollar__factory.ts +230 -187
- package/types/factories/SuperToken__factory.ts +197 -192
- package/types/factories/SwapHelperTest__factory.ts +1 -1
- package/types/factories/TwentyDecimalsTokenMock__factory.ts +1 -1
- package/types/factories/UBISchemeV2__factory.ts +19 -1
- package/types/factories/UBIScheme__factory.ts +19 -1
- package/types/factories/USDCMock__factory.ts +1 -1
- package/types/factories/UUPSProxy__factory.ts +1 -1
- package/types/factories/UniswapV2SwapHelper__factory.ts +1 -1
- package/types/factories/UpgradableMock2__factory.ts +1 -1
- package/types/factories/UpgradableMock3__factory.ts +1 -1
- package/types/factories/UpgradableMock4__factory.ts +1 -1
- package/types/factories/UpgradableMock__factory.ts +1 -1
- package/types/hardhat.d.ts +166 -4
- package/types/index.ts +34 -4
- package/yarn.lock +1288 -719
- package/artifacts/contracts/token/FeesFormula.sol/IFeesFormula.dbg.json +0 -4
- /package/contracts/token/{FeesFormula.sol → IFeesFormula.sol} +0 -0
|
@@ -3,13 +3,7 @@ import { loadFixture } from "@nomicfoundation/hardhat-network-helpers";
|
|
|
3
3
|
import { BigNumber, Contract } from "ethers";
|
|
4
4
|
import { expect } from "chai";
|
|
5
5
|
import { GoodMarketMaker } from "../../types";
|
|
6
|
-
import {
|
|
7
|
-
createDAO,
|
|
8
|
-
increaseTime,
|
|
9
|
-
advanceBlocks,
|
|
10
|
-
deployUniswap,
|
|
11
|
-
getStakingFactory
|
|
12
|
-
} from "../helpers";
|
|
6
|
+
import { createDAO, increaseTime, advanceBlocks, deployUniswap, getStakingFactory } from "../helpers";
|
|
13
7
|
import ContributionCalculation from "@gooddollar/goodcontracts/stakingModel/build/contracts/ContributionCalculation.json";
|
|
14
8
|
import IUniswapV2Pair from "@uniswap/v2-core/build/IUniswapV2Pair.json";
|
|
15
9
|
const BN = ethers.BigNumber;
|
|
@@ -72,15 +66,9 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
72
66
|
|
|
73
67
|
const cdaiFactory = await ethers.getContractFactory("cDAIMock");
|
|
74
68
|
const cBatFactory = await ethers.getContractFactory("cBATMock");
|
|
75
|
-
const goodFundManagerFactory = await ethers.getContractFactory(
|
|
76
|
-
|
|
77
|
-
);
|
|
78
|
-
goodCompoundStakingFactory = await getStakingFactory(
|
|
79
|
-
"GoodCompoundStakingV2"
|
|
80
|
-
);
|
|
81
|
-
goodCompoundStakingTestFactory = await getStakingFactory(
|
|
82
|
-
"GoodCompoundStakingTest"
|
|
83
|
-
);
|
|
69
|
+
const goodFundManagerFactory = await ethers.getContractFactory("GoodFundManager");
|
|
70
|
+
goodCompoundStakingFactory = await getStakingFactory("GoodCompoundStakingV2");
|
|
71
|
+
goodCompoundStakingTestFactory = await getStakingFactory("GoodCompoundStakingTest");
|
|
84
72
|
|
|
85
73
|
const daiFactory = await ethers.getContractFactory("DAIMock");
|
|
86
74
|
|
|
@@ -105,13 +93,9 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
105
93
|
controller,
|
|
106
94
|
avatar
|
|
107
95
|
});
|
|
108
|
-
goodFundManager = await upgrades.deployProxy(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
{
|
|
112
|
-
kind: "uups"
|
|
113
|
-
}
|
|
114
|
-
);
|
|
96
|
+
goodFundManager = await upgrades.deployProxy(goodFundManagerFactory, [nameService.address], {
|
|
97
|
+
kind: "uups"
|
|
98
|
+
});
|
|
115
99
|
await setDAOAddress("FUND_MANAGER", goodFundManager.address);
|
|
116
100
|
console.log("Deployed goodfund manager", {
|
|
117
101
|
manager: goodFundManager.address
|
|
@@ -129,15 +113,11 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
129
113
|
});
|
|
130
114
|
|
|
131
115
|
console.log("setting permissions...");
|
|
132
|
-
const tokenUsdOracleFactory = await ethers.getContractFactory(
|
|
133
|
-
"BatUSDMockOracle"
|
|
134
|
-
);
|
|
116
|
+
const tokenUsdOracleFactory = await ethers.getContractFactory("BatUSDMockOracle");
|
|
135
117
|
await setDAOAddress("UNISWAP_ROUTER", uniswapRouter.address);
|
|
136
118
|
|
|
137
119
|
daiUsdOracle = await tokenUsdOracleFactory.deploy();
|
|
138
|
-
const compUsdOracleFactory = await ethers.getContractFactory(
|
|
139
|
-
"CompUSDMockOracle"
|
|
140
|
-
);
|
|
120
|
+
const compUsdOracleFactory = await ethers.getContractFactory("CompUSDMockOracle");
|
|
141
121
|
compUsdOracle = await compUsdOracleFactory.deploy();
|
|
142
122
|
|
|
143
123
|
deployStaking = (token, itoken, blocksThreashold = "50") =>
|
|
@@ -161,13 +141,9 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
161
141
|
console.log("initializing marketmaker...");
|
|
162
142
|
|
|
163
143
|
cDAI1 = await cdaiFactory.deploy(dai.address);
|
|
164
|
-
const cdaiLowWorthFactory = await ethers.getContractFactory(
|
|
165
|
-
"cDAILowWorthMock"
|
|
166
|
-
);
|
|
144
|
+
const cdaiLowWorthFactory = await ethers.getContractFactory("cDAILowWorthMock");
|
|
167
145
|
cDAI2 = await cdaiLowWorthFactory.deploy(dai.address);
|
|
168
|
-
const cdaiNonMintableFactory = await ethers.getContractFactory(
|
|
169
|
-
"cDAINonMintableMock"
|
|
170
|
-
);
|
|
146
|
+
const cdaiNonMintableFactory = await ethers.getContractFactory("cDAINonMintableMock");
|
|
171
147
|
cDAI3 = await cdaiNonMintableFactory.deploy(dai.address);
|
|
172
148
|
bat = await daiFactory.deploy(); // Another erc20 token for uniswap router test
|
|
173
149
|
cBat = await cBatFactory.deploy(bat.address);
|
|
@@ -192,82 +168,45 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
192
168
|
|
|
193
169
|
await factory.createPair(bat.address, dai.address); // Create tokenA and dai pair
|
|
194
170
|
const pairAddress = factory.getPair(bat.address, dai.address);
|
|
195
|
-
pair = new Contract(
|
|
196
|
-
pairAddress,
|
|
197
|
-
JSON.stringify(IUniswapV2Pair.abi),
|
|
198
|
-
staker
|
|
199
|
-
).connect(founder);
|
|
171
|
+
pair = new Contract(pairAddress, JSON.stringify(IUniswapV2Pair.abi), staker).connect(founder);
|
|
200
172
|
await setDAOAddress("CDAI", cDAI.address);
|
|
201
173
|
await setDAOAddress("DAI", dai.address);
|
|
202
174
|
|
|
203
175
|
batUsdOracle = await tokenUsdOracleFactory.deploy();
|
|
204
176
|
|
|
205
|
-
await dai["mint(address,uint256)"](
|
|
206
|
-
|
|
207
|
-
ethers.utils.parseEther("2000000")
|
|
208
|
-
);
|
|
209
|
-
await bat["mint(address,uint256)"](
|
|
210
|
-
founder.address,
|
|
211
|
-
ethers.utils.parseEther("2000000")
|
|
212
|
-
);
|
|
177
|
+
await dai["mint(address,uint256)"](founder.address, ethers.utils.parseEther("2000000"));
|
|
178
|
+
await bat["mint(address,uint256)"](founder.address, ethers.utils.parseEther("2000000"));
|
|
213
179
|
|
|
214
|
-
await addLiquidity(
|
|
215
|
-
ethers.utils.parseEther("2000000"),
|
|
216
|
-
ethers.utils.parseEther("2000000")
|
|
217
|
-
);
|
|
180
|
+
await addLiquidity(ethers.utils.parseEther("2000000"), ethers.utils.parseEther("2000000"));
|
|
218
181
|
|
|
219
|
-
gasFeeOracle = await ethers.getContractAt(
|
|
220
|
-
|
|
221
|
-
await nameService.getAddress("GAS_PRICE_ORACLE")
|
|
222
|
-
);
|
|
223
|
-
daiEthOracle = await ethers.getContractAt(
|
|
224
|
-
"DaiEthPriceMockOracle",
|
|
225
|
-
await nameService.getAddress("DAI_ETH_ORACLE")
|
|
226
|
-
);
|
|
182
|
+
gasFeeOracle = await ethers.getContractAt("GasPriceMockOracle", await nameService.getAddress("GAS_PRICE_ORACLE"));
|
|
183
|
+
daiEthOracle = await ethers.getContractAt("DaiEthPriceMockOracle", await nameService.getAddress("DAI_ETH_ORACLE"));
|
|
227
184
|
await setDAOAddress("MARKET_MAKER", marketMaker.address);
|
|
228
185
|
});
|
|
229
186
|
|
|
230
187
|
it("should be set rewards per block for particular stacking contract", async () => {
|
|
231
|
-
const goodFundManagerFactory = await ethers.getContractFactory(
|
|
232
|
-
"GoodFundManager"
|
|
233
|
-
);
|
|
188
|
+
const goodFundManagerFactory = await ethers.getContractFactory("GoodFundManager");
|
|
234
189
|
const currentBlockNumber = await ethers.provider.getBlockNumber();
|
|
235
190
|
const encodedData = goodFundManagerFactory.interface.encodeFunctionData(
|
|
236
191
|
"setStakingReward",
|
|
237
|
-
[
|
|
238
|
-
"1000",
|
|
239
|
-
goodCompoundStaking.address,
|
|
240
|
-
currentBlockNumber - 5,
|
|
241
|
-
currentBlockNumber + 10,
|
|
242
|
-
false
|
|
243
|
-
] // set 10 gd per block
|
|
192
|
+
["1000", goodCompoundStaking.address, currentBlockNumber - 5, currentBlockNumber + 10, false] // set 10 gd per block
|
|
244
193
|
);
|
|
245
194
|
await genericCall(goodFundManager.address, encodedData, avatar, 0);
|
|
246
|
-
let rewardPerBlock = await goodFundManager.rewardsForStakingContract(
|
|
247
|
-
goodCompoundStaking.address
|
|
248
|
-
);
|
|
195
|
+
let rewardPerBlock = await goodFundManager.rewardsForStakingContract(goodCompoundStaking.address);
|
|
249
196
|
expect(rewardPerBlock[0].toString()).to.be.equal("1000");
|
|
250
|
-
expect(rewardPerBlock[1].toString()).to.be.equal(
|
|
251
|
-
|
|
252
|
-
);
|
|
253
|
-
expect(rewardPerBlock[2].toString()).to.be.equal(
|
|
254
|
-
(currentBlockNumber + 10).toString()
|
|
255
|
-
);
|
|
197
|
+
expect(rewardPerBlock[1].toString()).to.be.equal((currentBlockNumber - 5).toString());
|
|
198
|
+
expect(rewardPerBlock[2].toString()).to.be.equal((currentBlockNumber + 10).toString());
|
|
256
199
|
expect(rewardPerBlock[3]).to.be.equal(false);
|
|
257
200
|
});
|
|
258
201
|
|
|
259
202
|
it("should be able to earn rewards after some block passed", async () => {
|
|
260
203
|
let stakingAmount = ethers.utils.parseEther("100");
|
|
261
204
|
await dai["mint(address,uint256)"](staker.address, stakingAmount);
|
|
262
|
-
await dai
|
|
263
|
-
.connect(staker)
|
|
264
|
-
.approve(goodCompoundStaking.address, stakingAmount);
|
|
205
|
+
await dai.connect(staker).approve(goodCompoundStaking.address, stakingAmount);
|
|
265
206
|
await goodCompoundStaking.connect(staker).stake(stakingAmount, 0, false);
|
|
266
207
|
let gdBalanceBeforeWithdraw = await goodDollar.balanceOf(staker.address);
|
|
267
208
|
await advanceBlocks(4);
|
|
268
|
-
await goodCompoundStaking
|
|
269
|
-
.connect(staker)
|
|
270
|
-
.withdrawStake(stakingAmount, false);
|
|
209
|
+
await goodCompoundStaking.connect(staker).withdrawStake(stakingAmount, false);
|
|
271
210
|
let gdBalancerAfterWithdraw = await goodDollar.balanceOf(staker.address);
|
|
272
211
|
expect(gdBalancerAfterWithdraw.toString()).to.be.equal("2500");
|
|
273
212
|
});
|
|
@@ -276,142 +215,78 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
276
215
|
const stakingAmount = ethers.utils.parseEther("100");
|
|
277
216
|
|
|
278
217
|
await dai["mint(address,uint256)"](staker.address, stakingAmount);
|
|
279
|
-
await dai
|
|
280
|
-
.connect(staker)
|
|
281
|
-
.approve(goodCompoundStaking.address, stakingAmount.mul(BN.from("2")));
|
|
218
|
+
await dai.connect(staker).approve(goodCompoundStaking.address, stakingAmount.mul(BN.from("2")));
|
|
282
219
|
|
|
283
220
|
await goodCompoundStaking.connect(staker).stake(stakingAmount, 0, false);
|
|
284
221
|
await goodCompoundStaking.connect(staker).stake(stakingAmount, 100, false);
|
|
285
|
-
const userStakeInfoBeforeWithdraw = await goodCompoundStaking.users(
|
|
286
|
-
|
|
287
|
-
);
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
);
|
|
291
|
-
expect(userStakeInfoBeforeWithdraw.amount).to.be.equal(
|
|
292
|
-
stakingAmount.mul(BN.from("2"))
|
|
293
|
-
);
|
|
294
|
-
await goodCompoundStaking
|
|
295
|
-
.connect(staker)
|
|
296
|
-
.withdrawStake(stakingAmount, false);
|
|
297
|
-
const userStakeInfoAfterWithdraw = await goodCompoundStaking.users(
|
|
298
|
-
staker.address
|
|
299
|
-
);
|
|
300
|
-
expect(userStakeInfoAfterWithdraw.effectiveStakes).to.be.equal(
|
|
301
|
-
stakingAmount.div(BN.from("2"))
|
|
302
|
-
); // should be half of the stakes that staked initially
|
|
222
|
+
const userStakeInfoBeforeWithdraw = await goodCompoundStaking.users(staker.address);
|
|
223
|
+
expect(userStakeInfoBeforeWithdraw.effectiveStakes).to.be.equal(stakingAmount);
|
|
224
|
+
expect(userStakeInfoBeforeWithdraw.amount).to.be.equal(stakingAmount.mul(BN.from("2")));
|
|
225
|
+
await goodCompoundStaking.connect(staker).withdrawStake(stakingAmount, false);
|
|
226
|
+
const userStakeInfoAfterWithdraw = await goodCompoundStaking.users(staker.address);
|
|
227
|
+
expect(userStakeInfoAfterWithdraw.effectiveStakes).to.be.equal(stakingAmount.div(BN.from("2"))); // should be half of the stakes that staked initially
|
|
303
228
|
expect(userStakeInfoAfterWithdraw.amount).to.be.equal(stakingAmount);
|
|
304
|
-
await goodCompoundStaking
|
|
305
|
-
.connect(staker)
|
|
306
|
-
.withdrawStake(stakingAmount, false);
|
|
229
|
+
await goodCompoundStaking.connect(staker).withdrawStake(stakingAmount, false);
|
|
307
230
|
});
|
|
308
231
|
it("it should not increase totalEffectiveStakes when staked amount's rewards are donated", async () => {
|
|
309
232
|
const stakingAmount = ethers.utils.parseEther("100");
|
|
310
233
|
|
|
311
234
|
await dai["mint(address,uint256)"](staker.address, stakingAmount);
|
|
312
|
-
await dai
|
|
313
|
-
|
|
314
|
-
.approve(goodCompoundStaking.address, stakingAmount);
|
|
315
|
-
const totalEffectiveStakesBeforeStake = await goodCompoundStaking
|
|
316
|
-
.getStats()
|
|
317
|
-
.then(_ => _[3]);
|
|
235
|
+
await dai.connect(staker).approve(goodCompoundStaking.address, stakingAmount);
|
|
236
|
+
const totalEffectiveStakesBeforeStake = await goodCompoundStaking.getStats().then(_ => _[3]);
|
|
318
237
|
await goodCompoundStaking.connect(staker).stake(stakingAmount, 100, false);
|
|
319
|
-
const totalEffectiveStakesAfterStake = await goodCompoundStaking
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
await goodCompoundStaking
|
|
323
|
-
.connect(staker)
|
|
324
|
-
.withdrawStake(stakingAmount, false);
|
|
325
|
-
expect(totalEffectiveStakesAfterStake).to.be.equal(
|
|
326
|
-
totalEffectiveStakesBeforeStake
|
|
327
|
-
);
|
|
238
|
+
const totalEffectiveStakesAfterStake = await goodCompoundStaking.getStats().then(_ => _[3]);
|
|
239
|
+
await goodCompoundStaking.connect(staker).withdrawStake(stakingAmount, false);
|
|
240
|
+
expect(totalEffectiveStakesAfterStake).to.be.equal(totalEffectiveStakesBeforeStake);
|
|
328
241
|
});
|
|
329
242
|
it("it should increase totalEffectiveStakes when staked without donation", async () => {
|
|
330
243
|
const stakingAmount = ethers.utils.parseEther("100");
|
|
331
244
|
|
|
332
245
|
await dai["mint(address,uint256)"](staker.address, stakingAmount);
|
|
333
|
-
await dai
|
|
334
|
-
|
|
335
|
-
.approve(goodCompoundStaking.address, stakingAmount);
|
|
336
|
-
const totalEffectiveStakesBeforeStake = await goodCompoundStaking
|
|
337
|
-
.getStats()
|
|
338
|
-
.then(_ => _[3]);
|
|
246
|
+
await dai.connect(staker).approve(goodCompoundStaking.address, stakingAmount);
|
|
247
|
+
const totalEffectiveStakesBeforeStake = await goodCompoundStaking.getStats().then(_ => _[3]);
|
|
339
248
|
await goodCompoundStaking.connect(staker).stake(stakingAmount, 0, false);
|
|
340
|
-
const totalEffectiveStakesAfterStake = await goodCompoundStaking
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
await goodCompoundStaking
|
|
344
|
-
.connect(staker)
|
|
345
|
-
.withdrawStake(stakingAmount, false);
|
|
346
|
-
expect(totalEffectiveStakesAfterStake).to.be.gt(
|
|
347
|
-
totalEffectiveStakesBeforeStake
|
|
348
|
-
);
|
|
249
|
+
const totalEffectiveStakesAfterStake = await goodCompoundStaking.getStats().then(_ => _[3]);
|
|
250
|
+
await goodCompoundStaking.connect(staker).withdrawStake(stakingAmount, false);
|
|
251
|
+
expect(totalEffectiveStakesAfterStake).to.be.gt(totalEffectiveStakesBeforeStake);
|
|
349
252
|
});
|
|
350
253
|
it("it should withdraw effective and stakes according to ratio", async () => {
|
|
351
254
|
const stakingAmount = ethers.utils.parseEther("100");
|
|
352
255
|
|
|
353
256
|
await dai["mint(address,uint256)"](staker.address, stakingAmount);
|
|
354
|
-
await dai
|
|
355
|
-
.connect(staker)
|
|
356
|
-
.approve(goodCompoundStaking.address, stakingAmount);
|
|
257
|
+
await dai.connect(staker).approve(goodCompoundStaking.address, stakingAmount);
|
|
357
258
|
|
|
358
|
-
await goodCompoundStaking
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
await goodCompoundStaking
|
|
362
|
-
.connect(staker)
|
|
363
|
-
.stake(stakingAmount.mul(20).div(100), 100, false);
|
|
364
|
-
const userStakeInfoBeforeWithdraw = await goodCompoundStaking.users(
|
|
365
|
-
staker.address
|
|
366
|
-
);
|
|
259
|
+
await goodCompoundStaking.connect(staker).stake(stakingAmount.mul(80).div(100), 0, false);
|
|
260
|
+
await goodCompoundStaking.connect(staker).stake(stakingAmount.mul(20).div(100), 100, false);
|
|
261
|
+
const userStakeInfoBeforeWithdraw = await goodCompoundStaking.users(staker.address);
|
|
367
262
|
const withdrawAmount = stakingAmount.mul(20).div(100);
|
|
368
263
|
const withdrawFromEffectiveStake = withdrawAmount
|
|
369
264
|
.mul(userStakeInfoBeforeWithdraw.effectiveStakes)
|
|
370
265
|
.div(userStakeInfoBeforeWithdraw.amount);
|
|
371
266
|
const withdrawFromDonation = withdrawAmount.sub(withdrawFromEffectiveStake);
|
|
372
|
-
await goodCompoundStaking
|
|
373
|
-
|
|
374
|
-
.withdrawStake(withdrawAmount, false);
|
|
375
|
-
const userStakeInfoAfterWithdraw = await goodCompoundStaking.users(
|
|
376
|
-
staker.address
|
|
377
|
-
);
|
|
267
|
+
await goodCompoundStaking.connect(staker).withdrawStake(withdrawAmount, false);
|
|
268
|
+
const userStakeInfoAfterWithdraw = await goodCompoundStaking.users(staker.address);
|
|
378
269
|
expect(userStakeInfoBeforeWithdraw.effectiveStakes).to.be.gt(0);
|
|
379
270
|
expect(userStakeInfoAfterWithdraw.effectiveStakes).to.be.equal(
|
|
380
|
-
userStakeInfoBeforeWithdraw.effectiveStakes.sub(
|
|
381
|
-
withdrawFromEffectiveStake
|
|
382
|
-
)
|
|
271
|
+
userStakeInfoBeforeWithdraw.effectiveStakes.sub(withdrawFromEffectiveStake)
|
|
383
272
|
);
|
|
384
|
-
expect(
|
|
385
|
-
|
|
386
|
-
userStakeInfoAfterWithdraw.effectiveStakes
|
|
387
|
-
)
|
|
388
|
-
).to.be.equal(
|
|
389
|
-
userStakeInfoBeforeWithdraw.amount
|
|
390
|
-
.sub(userStakeInfoBeforeWithdraw.effectiveStakes)
|
|
391
|
-
.sub(withdrawFromDonation)
|
|
273
|
+
expect(userStakeInfoAfterWithdraw.amount.sub(userStakeInfoAfterWithdraw.effectiveStakes)).to.be.equal(
|
|
274
|
+
userStakeInfoBeforeWithdraw.amount.sub(userStakeInfoBeforeWithdraw.effectiveStakes).sub(withdrawFromDonation)
|
|
392
275
|
);
|
|
393
|
-
await goodCompoundStaking
|
|
394
|
-
.connect(staker)
|
|
395
|
-
.withdrawStake(stakingAmount.sub(withdrawAmount), false); // withdraw left amount
|
|
276
|
+
await goodCompoundStaking.connect(staker).withdrawStake(stakingAmount.sub(withdrawAmount), false); // withdraw left amount
|
|
396
277
|
});
|
|
397
278
|
it("shouldn't be able to earn rewards after rewards blockend passed", async () => {
|
|
398
279
|
let stakingAmount = ethers.utils.parseEther("100");
|
|
399
280
|
await dai["mint(address,uint256)"](staker.address, stakingAmount);
|
|
400
|
-
await dai
|
|
401
|
-
.connect(staker)
|
|
402
|
-
.approve(goodCompoundStaking.address, stakingAmount);
|
|
281
|
+
await dai.connect(staker).approve(goodCompoundStaking.address, stakingAmount);
|
|
403
282
|
await goodCompoundStaking.connect(staker).stake(stakingAmount, 0, false);
|
|
404
283
|
|
|
405
284
|
let gdBalanceBeforeWithdraw = await goodDollar.balanceOf(staker.address);
|
|
406
285
|
advanceBlocks(5);
|
|
407
|
-
await goodCompoundStaking
|
|
408
|
-
.connect(staker)
|
|
409
|
-
.withdrawStake(stakingAmount, false);
|
|
286
|
+
await goodCompoundStaking.connect(staker).withdrawStake(stakingAmount, false);
|
|
410
287
|
let gdBalancerAfterWithdraw = await goodDollar.balanceOf(staker.address);
|
|
411
288
|
|
|
412
|
-
expect(gdBalancerAfterWithdraw.toString()).to.be.equal(
|
|
413
|
-
gdBalanceBeforeWithdraw.toString()
|
|
414
|
-
);
|
|
289
|
+
expect(gdBalancerAfterWithdraw.toString()).to.be.equal(gdBalanceBeforeWithdraw.toString());
|
|
415
290
|
});
|
|
416
291
|
|
|
417
292
|
it("shouldn't be able to mint reward when staking contract is blacklisted", async () => {
|
|
@@ -425,9 +300,7 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
425
300
|
|
|
426
301
|
let stakingAmount = ethers.utils.parseEther("100");
|
|
427
302
|
await dai["mint(address,uint256)"](staker.address, stakingAmount);
|
|
428
|
-
await dai
|
|
429
|
-
.connect(staker)
|
|
430
|
-
.approve(goodCompoundStaking2.address, stakingAmount);
|
|
303
|
+
await dai.connect(staker).approve(goodCompoundStaking2.address, stakingAmount);
|
|
431
304
|
await goodCompoundStaking2.connect(staker).stake(stakingAmount, 0, false);
|
|
432
305
|
|
|
433
306
|
let gdBalanceBeforeWithdraw = await goodDollar.balanceOf(staker.address);
|
|
@@ -439,9 +312,7 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
439
312
|
);
|
|
440
313
|
await genericCall(goodFundManager.address, encodedDataTwo);
|
|
441
314
|
|
|
442
|
-
await goodCompoundStaking2
|
|
443
|
-
.connect(staker)
|
|
444
|
-
.withdrawStake(stakingAmount, false);
|
|
315
|
+
await goodCompoundStaking2.connect(staker).withdrawStake(stakingAmount, false);
|
|
445
316
|
let gdBalancerAfterWithdraw = await goodDollar.balanceOf(staker.address);
|
|
446
317
|
|
|
447
318
|
expect(gdBalancerAfterWithdraw).to.be.equal(gdBalanceBeforeWithdraw);
|
|
@@ -488,34 +359,20 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
488
359
|
it("it should send staker's productivity to some other user", async () => {
|
|
489
360
|
let stakingAmount = ethers.utils.parseEther("100");
|
|
490
361
|
await dai["mint(address,uint256)"](staker.address, stakingAmount);
|
|
491
|
-
await dai
|
|
492
|
-
.connect(staker)
|
|
493
|
-
.approve(goodCompoundStaking.address, stakingAmount);
|
|
362
|
+
await dai.connect(staker).approve(goodCompoundStaking.address, stakingAmount);
|
|
494
363
|
await goodCompoundStaking.connect(staker).stake(stakingAmount, 100, false);
|
|
495
|
-
let stakersProductivityBefore = await goodCompoundStaking.getProductivity(
|
|
496
|
-
|
|
497
|
-
);
|
|
498
|
-
await goodCompoundStaking
|
|
499
|
-
.connect(staker)
|
|
500
|
-
.transfer(founder.address, stakingAmount);
|
|
501
|
-
let stakersProductivityAfter = await goodCompoundStaking
|
|
502
|
-
.connect(staker)
|
|
503
|
-
.getProductivity(staker.address);
|
|
504
|
-
let foundersProductivity = await goodCompoundStaking.getProductivity(
|
|
505
|
-
founder.address
|
|
506
|
-
);
|
|
364
|
+
let stakersProductivityBefore = await goodCompoundStaking.getProductivity(staker.address);
|
|
365
|
+
await goodCompoundStaking.connect(staker).transfer(founder.address, stakingAmount);
|
|
366
|
+
let stakersProductivityAfter = await goodCompoundStaking.connect(staker).getProductivity(staker.address);
|
|
367
|
+
let foundersProductivity = await goodCompoundStaking.getProductivity(founder.address);
|
|
507
368
|
|
|
508
369
|
expect(stakersProductivityAfter[0].toString()).to.be.equal("0");
|
|
509
|
-
expect(foundersProductivity[0].toString()).to.be.equals(
|
|
510
|
-
stakingAmount.toString()
|
|
511
|
-
);
|
|
370
|
+
expect(foundersProductivity[0].toString()).to.be.equals(stakingAmount.toString());
|
|
512
371
|
});
|
|
513
372
|
|
|
514
373
|
it("it shouldn't be able to withdraw stake when staker sent it to another user", async () => {
|
|
515
374
|
const stakingAmount = ethers.utils.parseEther("100");
|
|
516
|
-
await expect(
|
|
517
|
-
goodCompoundStaking.connect(staker).withdrawStake(stakingAmount, false)
|
|
518
|
-
).to.be.reverted;
|
|
375
|
+
await expect(goodCompoundStaking.connect(staker).withdrawStake(stakingAmount, false)).to.be.reverted;
|
|
519
376
|
});
|
|
520
377
|
|
|
521
378
|
it("it should be able to withdraw their stake when got staking tokens from somebody else", async () => {
|
|
@@ -523,9 +380,7 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
523
380
|
|
|
524
381
|
await goodCompoundStaking.withdrawStake(stakingAmount, false);
|
|
525
382
|
|
|
526
|
-
const foundersProductivity = await goodCompoundStaking.getProductivity(
|
|
527
|
-
founder.address
|
|
528
|
-
);
|
|
383
|
+
const foundersProductivity = await goodCompoundStaking.getProductivity(founder.address);
|
|
529
384
|
expect(foundersProductivity[0].toString()).to.be.equal("0");
|
|
530
385
|
expect(foundersProductivity[1].toString()).to.be.equal("0"); // Total productivity also should equal 0
|
|
531
386
|
});
|
|
@@ -534,73 +389,43 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
534
389
|
const stakingAmount = ethers.utils.parseEther("100");
|
|
535
390
|
|
|
536
391
|
await dai["mint(address,uint256)"](staker.address, stakingAmount);
|
|
537
|
-
await dai
|
|
538
|
-
.connect(staker)
|
|
539
|
-
.approve(goodCompoundStaking.address, stakingAmount);
|
|
392
|
+
await dai.connect(staker).approve(goodCompoundStaking.address, stakingAmount);
|
|
540
393
|
await goodCompoundStaking.connect(staker).stake(stakingAmount, 100, false);
|
|
541
394
|
|
|
542
|
-
await dai["mint(address,uint256)"](
|
|
543
|
-
|
|
544
|
-
ethers.utils.parseEther("1000000")
|
|
545
|
-
);
|
|
546
|
-
await dai
|
|
547
|
-
.connect(staker)
|
|
548
|
-
.transfer(cDAI.address, ethers.utils.parseEther("1000000")); // We should put extra DAI to mock cDAI contract in order to provide interest
|
|
395
|
+
await dai["mint(address,uint256)"](staker.address, ethers.utils.parseEther("1000000"));
|
|
396
|
+
await dai.connect(staker).transfer(cDAI.address, ethers.utils.parseEther("1000000")); // We should put extra DAI to mock cDAI contract in order to provide interest
|
|
549
397
|
await cDAI.increasePriceWithMultiplier("1500"); // increase interest by calling exchangeRateCurrent
|
|
550
398
|
|
|
551
|
-
const currentUBIInterestBeforeWithdraw =
|
|
552
|
-
|
|
553
|
-
await
|
|
554
|
-
|
|
555
|
-
.withdrawStake(stakingAmount, false);
|
|
556
|
-
const gdBalanceBeforeCollectInterest = await goodDollar.balanceOf(
|
|
557
|
-
staker.address
|
|
558
|
-
);
|
|
559
|
-
const contractAddressesToBeCollected =
|
|
560
|
-
await goodFundManager.calcSortedContracts();
|
|
399
|
+
const currentUBIInterestBeforeWithdraw = await goodCompoundStaking.currentGains(false, true);
|
|
400
|
+
await goodCompoundStaking.connect(staker).withdrawStake(stakingAmount, false);
|
|
401
|
+
const gdBalanceBeforeCollectInterest = await goodDollar.balanceOf(staker.address);
|
|
402
|
+
const contractAddressesToBeCollected = await goodFundManager.calcSortedContracts();
|
|
561
403
|
const addressesToCollect = contractAddressesToBeCollected.map(x => x[0]);
|
|
562
|
-
await goodFundManager
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
const gdBalanceAfterCollectInterest = await goodDollar.balanceOf(
|
|
566
|
-
staker.address
|
|
567
|
-
);
|
|
568
|
-
const currentUBIInterestAfterWithdraw =
|
|
569
|
-
await goodCompoundStaking.currentGains(false, true);
|
|
404
|
+
await goodFundManager.connect(staker).collectInterest(addressesToCollect, false);
|
|
405
|
+
const gdBalanceAfterCollectInterest = await goodDollar.balanceOf(staker.address);
|
|
406
|
+
const currentUBIInterestAfterWithdraw = await goodCompoundStaking.currentGains(false, true);
|
|
570
407
|
expect(currentUBIInterestBeforeWithdraw[0].toString()).to.not.be.equal("0");
|
|
571
408
|
expect(currentUBIInterestAfterWithdraw[0].toString()).to.be.equal("0");
|
|
572
409
|
expect(gdBalanceAfterCollectInterest.gt(gdBalanceBeforeCollectInterest));
|
|
573
410
|
});
|
|
574
411
|
|
|
575
412
|
it("it should get rewards with updated values", async () => {
|
|
576
|
-
const goodFundManagerFactory = await ethers.getContractFactory(
|
|
577
|
-
"GoodFundManager"
|
|
578
|
-
);
|
|
413
|
+
const goodFundManagerFactory = await ethers.getContractFactory("GoodFundManager");
|
|
579
414
|
const currentBlockNumber = await ethers.provider.getBlockNumber();
|
|
580
415
|
const encodedDataTwo = goodFundManagerFactory.interface.encodeFunctionData(
|
|
581
416
|
"setStakingReward",
|
|
582
|
-
[
|
|
583
|
-
"1000",
|
|
584
|
-
goodCompoundStaking.address,
|
|
585
|
-
currentBlockNumber,
|
|
586
|
-
currentBlockNumber + 5000,
|
|
587
|
-
false
|
|
588
|
-
] // set 10 gd per block
|
|
417
|
+
["1000", goodCompoundStaking.address, currentBlockNumber, currentBlockNumber + 5000, false] // set 10 gd per block
|
|
589
418
|
);
|
|
590
419
|
await genericCall(goodFundManager.address, encodedDataTwo, avatar, 0);
|
|
591
420
|
|
|
592
421
|
const stakingAmount = ethers.utils.parseEther("100");
|
|
593
422
|
|
|
594
423
|
await dai["mint(address,uint256)"](staker.address, stakingAmount);
|
|
595
|
-
await dai
|
|
596
|
-
.connect(staker)
|
|
597
|
-
.approve(goodCompoundStaking.address, stakingAmount);
|
|
424
|
+
await dai.connect(staker).approve(goodCompoundStaking.address, stakingAmount);
|
|
598
425
|
await goodCompoundStaking.connect(staker).stake(stakingAmount, 0, false);
|
|
599
426
|
|
|
600
427
|
await advanceBlocks(4);
|
|
601
|
-
const stakingContractVals = await goodFundManager.rewardsForStakingContract(
|
|
602
|
-
goodCompoundStaking.address
|
|
603
|
-
);
|
|
428
|
+
const stakingContractVals = await goodFundManager.rewardsForStakingContract(goodCompoundStaking.address);
|
|
604
429
|
let rewardsEarned = await goodCompoundStaking.getUserPendingReward(
|
|
605
430
|
staker.address,
|
|
606
431
|
stakingContractVals[0],
|
|
@@ -608,71 +433,46 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
608
433
|
stakingContractVals[2]
|
|
609
434
|
);
|
|
610
435
|
//baseshare rewards is in 18 decimals
|
|
611
|
-
expect(rewardsEarned.toString()).to.be.equal(
|
|
612
|
-
ethers.utils.parseUnits("20", 18)
|
|
613
|
-
); // Each block reward is 10gd so total reward 40gd but since multiplier is 0.5 for first month should get 20gd
|
|
436
|
+
expect(rewardsEarned.toString()).to.be.equal(ethers.utils.parseUnits("20", 18)); // Each block reward is 10gd so total reward 40gd but since multiplier is 0.5 for first month should get 20gd
|
|
614
437
|
|
|
615
|
-
await goodCompoundStaking
|
|
616
|
-
.connect(staker)
|
|
617
|
-
.withdrawStake(stakingAmount, false);
|
|
438
|
+
await goodCompoundStaking.connect(staker).withdrawStake(stakingAmount, false);
|
|
618
439
|
});
|
|
619
440
|
|
|
620
441
|
it("should get user minted and pending rewards", async () => {
|
|
621
|
-
const goodFundManagerFactory = await ethers.getContractFactory(
|
|
622
|
-
"GoodFundManager"
|
|
623
|
-
);
|
|
442
|
+
const goodFundManagerFactory = await ethers.getContractFactory("GoodFundManager");
|
|
624
443
|
const currentBlockNumber = await ethers.provider.getBlockNumber();
|
|
625
444
|
const encodedData = goodFundManagerFactory.interface.encodeFunctionData(
|
|
626
445
|
"setStakingReward",
|
|
627
|
-
[
|
|
628
|
-
"1000",
|
|
629
|
-
goodCompoundStaking.address,
|
|
630
|
-
currentBlockNumber,
|
|
631
|
-
currentBlockNumber + 5000,
|
|
632
|
-
false
|
|
633
|
-
] // set 10 gd per block
|
|
446
|
+
["1000", goodCompoundStaking.address, currentBlockNumber, currentBlockNumber + 5000, false] // set 10 gd per block
|
|
634
447
|
);
|
|
635
448
|
await genericCall(goodFundManager.address, encodedData, avatar, 0);
|
|
636
449
|
|
|
637
450
|
const stakingAmount = ethers.utils.parseEther("100");
|
|
638
451
|
|
|
639
452
|
await dai["mint(address,uint256)"](staker.address, stakingAmount);
|
|
640
|
-
await dai
|
|
641
|
-
.connect(staker)
|
|
642
|
-
.approve(goodCompoundStaking.address, stakingAmount);
|
|
453
|
+
await dai.connect(staker).approve(goodCompoundStaking.address, stakingAmount);
|
|
643
454
|
await goodCompoundStaking.connect(staker).stake(stakingAmount, 0, false);
|
|
644
455
|
|
|
645
456
|
await advanceBlocks(4);
|
|
646
457
|
|
|
647
|
-
const userMintedAndPending =
|
|
648
|
-
await goodCompoundStaking.getUserMintedAndPending(staker.address);
|
|
458
|
+
const userMintedAndPending = await goodCompoundStaking.getUserMintedAndPending(staker.address);
|
|
649
459
|
const userMintedReward = userMintedAndPending[0].toString();
|
|
650
460
|
const userPendingReward = userMintedAndPending[1].toString();
|
|
651
461
|
expect(userMintedReward).to.equal("5000");
|
|
652
462
|
expect(userPendingReward).to.equal("2000");
|
|
653
463
|
|
|
654
|
-
await goodCompoundStaking
|
|
655
|
-
.connect(staker)
|
|
656
|
-
.withdrawStake(stakingAmount, false);
|
|
464
|
+
await goodCompoundStaking.connect(staker).withdrawStake(stakingAmount, false);
|
|
657
465
|
});
|
|
658
466
|
|
|
659
467
|
it("it should get rewards with 1x multiplier for after threshold pass", async () => {
|
|
660
|
-
const goodFundManagerFactory = await ethers.getContractFactory(
|
|
661
|
-
"GoodFundManager"
|
|
662
|
-
);
|
|
468
|
+
const goodFundManagerFactory = await ethers.getContractFactory("GoodFundManager");
|
|
663
469
|
|
|
664
470
|
const simpleStaking = await await deployStaking();
|
|
665
471
|
|
|
666
472
|
const currentBlockNumber = await ethers.provider.getBlockNumber();
|
|
667
473
|
let encodedDataTwo = goodFundManagerFactory.interface.encodeFunctionData(
|
|
668
474
|
"setStakingReward",
|
|
669
|
-
[
|
|
670
|
-
"1000",
|
|
671
|
-
simpleStaking.address,
|
|
672
|
-
currentBlockNumber,
|
|
673
|
-
currentBlockNumber + 100,
|
|
674
|
-
false
|
|
675
|
-
] // set 10 gd per block
|
|
475
|
+
["1000", simpleStaking.address, currentBlockNumber, currentBlockNumber + 100, false] // set 10 gd per block
|
|
676
476
|
);
|
|
677
477
|
await genericCall(goodFundManager.address, encodedDataTwo, avatar, 0);
|
|
678
478
|
|
|
@@ -680,29 +480,17 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
680
480
|
|
|
681
481
|
await dai["mint(address,uint256)"](staker.address, stakingAmount);
|
|
682
482
|
await dai.connect(staker).approve(simpleStaking.address, stakingAmount);
|
|
683
|
-
let gdBalanceStakerBeforeWithdraw = await goodDollar.balanceOf(
|
|
684
|
-
staker.address
|
|
685
|
-
);
|
|
483
|
+
let gdBalanceStakerBeforeWithdraw = await goodDollar.balanceOf(staker.address);
|
|
686
484
|
await simpleStaking.connect(staker).stake(stakingAmount, 0, false);
|
|
687
485
|
|
|
688
486
|
await advanceBlocks(54);
|
|
689
487
|
await simpleStaking.connect(staker).withdrawStake(stakingAmount, false);
|
|
690
|
-
let gdBalanceStakerAfterWithdraw = await goodDollar.balanceOf(
|
|
691
|
-
staker.address
|
|
692
|
-
);
|
|
488
|
+
let gdBalanceStakerAfterWithdraw = await goodDollar.balanceOf(staker.address);
|
|
693
489
|
|
|
694
|
-
expect(
|
|
695
|
-
gdBalanceStakerAfterWithdraw.sub(gdBalanceStakerBeforeWithdraw).toString()
|
|
696
|
-
).to.be.equal("30000"); // 50 blocks reward worth 500gd but since it's with the 0.5x multiplier so 250gd then there is 5 blocks which gets full reward so total reward is 300gd
|
|
490
|
+
expect(gdBalanceStakerAfterWithdraw.sub(gdBalanceStakerBeforeWithdraw).toString()).to.be.equal("30000"); // 50 blocks reward worth 500gd but since it's with the 0.5x multiplier so 250gd then there is 5 blocks which gets full reward so total reward is 300gd
|
|
697
491
|
encodedDataTwo = goodFundManagerFactory.interface.encodeFunctionData(
|
|
698
492
|
"setStakingReward",
|
|
699
|
-
[
|
|
700
|
-
"1000",
|
|
701
|
-
simpleStaking.address,
|
|
702
|
-
currentBlockNumber,
|
|
703
|
-
currentBlockNumber + 100,
|
|
704
|
-
true
|
|
705
|
-
] // set 10 gd per block
|
|
493
|
+
["1000", simpleStaking.address, currentBlockNumber, currentBlockNumber + 100, true] // set 10 gd per block
|
|
706
494
|
);
|
|
707
495
|
await genericCall(goodFundManager.address, encodedDataTwo, avatar, 0);
|
|
708
496
|
});
|
|
@@ -711,27 +499,15 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
711
499
|
const stakingAmount = ethers.utils.parseEther("100");
|
|
712
500
|
|
|
713
501
|
await dai["mint(address,uint256)"](staker.address, stakingAmount);
|
|
714
|
-
await dai
|
|
715
|
-
.connect(staker)
|
|
716
|
-
.approve(goodCompoundStaking.address, stakingAmount);
|
|
502
|
+
await dai.connect(staker).approve(goodCompoundStaking.address, stakingAmount);
|
|
717
503
|
|
|
718
504
|
await goodCompoundStaking.connect(staker).stake(stakingAmount, 100, false);
|
|
719
|
-
await goodCompoundStaking
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
const
|
|
723
|
-
await goodCompoundStaking.balanceOf(founder.address);
|
|
724
|
-
await goodCompoundStaking.transferFrom(
|
|
725
|
-
staker.address,
|
|
726
|
-
founder.address,
|
|
727
|
-
stakingAmount
|
|
728
|
-
);
|
|
729
|
-
const stakingTokenBalanceAfterTransfer =
|
|
730
|
-
await goodCompoundStaking.balanceOf(founder.address);
|
|
505
|
+
await goodCompoundStaking.connect(staker).approve(founder.address, stakingAmount);
|
|
506
|
+
const stakingTokenBalanceBeforeTransfer = await goodCompoundStaking.balanceOf(founder.address);
|
|
507
|
+
await goodCompoundStaking.transferFrom(staker.address, founder.address, stakingAmount);
|
|
508
|
+
const stakingTokenBalanceAfterTransfer = await goodCompoundStaking.balanceOf(founder.address);
|
|
731
509
|
|
|
732
|
-
expect(
|
|
733
|
-
stakingTokenBalanceAfterTransfer.gt(stakingTokenBalanceBeforeTransfer)
|
|
734
|
-
).to.be.true;
|
|
510
|
+
expect(stakingTokenBalanceAfterTransfer.gt(stakingTokenBalanceBeforeTransfer)).to.be.true;
|
|
735
511
|
await goodCompoundStaking.withdrawStake(stakingAmount, false);
|
|
736
512
|
});
|
|
737
513
|
|
|
@@ -739,37 +515,28 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
739
515
|
const stakingAmount = ethers.utils.parseEther("100");
|
|
740
516
|
|
|
741
517
|
await dai["mint(address,uint256)"](staker.address, stakingAmount);
|
|
742
|
-
await dai
|
|
743
|
-
.connect(staker)
|
|
744
|
-
.approve(goodCompoundStaking.address, stakingAmount);
|
|
518
|
+
await dai.connect(staker).approve(goodCompoundStaking.address, stakingAmount);
|
|
745
519
|
|
|
746
520
|
await goodCompoundStaking.connect(staker).stake(stakingAmount, 0, false);
|
|
747
521
|
await advanceBlocks(5);
|
|
748
|
-
const stakingContractVals = await goodFundManager.rewardsForStakingContract(
|
|
749
|
-
|
|
522
|
+
const stakingContractVals = await goodFundManager.rewardsForStakingContract(goodCompoundStaking.address);
|
|
523
|
+
const earnedRewardBeforeWithdrawReward = await goodCompoundStaking.getUserPendingReward(
|
|
524
|
+
staker.address,
|
|
525
|
+
stakingContractVals[0],
|
|
526
|
+
stakingContractVals[1],
|
|
527
|
+
stakingContractVals[2]
|
|
750
528
|
);
|
|
751
|
-
const earnedRewardBeforeWithdrawReward =
|
|
752
|
-
await goodCompoundStaking.getUserPendingReward(
|
|
753
|
-
staker.address,
|
|
754
|
-
stakingContractVals[0],
|
|
755
|
-
stakingContractVals[1],
|
|
756
|
-
stakingContractVals[2]
|
|
757
|
-
);
|
|
758
529
|
await goodCompoundStaking.connect(staker).withdrawRewards();
|
|
759
|
-
const earnedRewardAfterWithdrawReward =
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
);
|
|
530
|
+
const earnedRewardAfterWithdrawReward = await goodCompoundStaking.getUserPendingReward(
|
|
531
|
+
staker.address,
|
|
532
|
+
stakingContractVals[0],
|
|
533
|
+
stakingContractVals[1],
|
|
534
|
+
stakingContractVals[2]
|
|
535
|
+
);
|
|
766
536
|
|
|
767
|
-
expect(earnedRewardAfterWithdrawReward.lt(earnedRewardBeforeWithdrawReward))
|
|
768
|
-
.to.be.true;
|
|
537
|
+
expect(earnedRewardAfterWithdrawReward.lt(earnedRewardBeforeWithdrawReward)).to.be.true;
|
|
769
538
|
expect(earnedRewardAfterWithdrawReward.toString()).to.be.equal("0");
|
|
770
|
-
await goodCompoundStaking
|
|
771
|
-
.connect(staker)
|
|
772
|
-
.withdrawStake(stakingAmount, false);
|
|
539
|
+
await goodCompoundStaking.connect(staker).withdrawStake(stakingAmount, false);
|
|
773
540
|
});
|
|
774
541
|
it("it should not mint reward when staking contract is not registered", async () => {
|
|
775
542
|
const simpleStaking = await deployStaking();
|
|
@@ -778,45 +545,27 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
778
545
|
expect(tx.message).to.not.be.empty;
|
|
779
546
|
});
|
|
780
547
|
it("it should be able to distribute rewards when blockEnd passed but last Reward block was before blockend", async () => {
|
|
781
|
-
const goodFundManagerFactory = await ethers.getContractFactory(
|
|
782
|
-
"GoodFundManager"
|
|
783
|
-
);
|
|
548
|
+
const goodFundManagerFactory = await ethers.getContractFactory("GoodFundManager");
|
|
784
549
|
const currentBlockNumber = await ethers.provider.getBlockNumber();
|
|
785
550
|
let encodedData = goodFundManagerFactory.interface.encodeFunctionData(
|
|
786
551
|
"setStakingReward",
|
|
787
|
-
[
|
|
788
|
-
"1000",
|
|
789
|
-
goodCompoundStaking.address,
|
|
790
|
-
currentBlockNumber - 10,
|
|
791
|
-
currentBlockNumber + 50,
|
|
792
|
-
false
|
|
793
|
-
] // set 10 gd per block
|
|
552
|
+
["1000", goodCompoundStaking.address, currentBlockNumber - 10, currentBlockNumber + 50, false] // set 10 gd per block
|
|
794
553
|
);
|
|
795
554
|
await genericCall(goodFundManager.address, encodedData);
|
|
796
555
|
const stakingAmount = ethers.utils.parseEther("100");
|
|
797
556
|
const initialGdBalance = await goodDollar.balanceOf(staker.address);
|
|
798
557
|
await dai["mint(address,uint256)"](staker.address, stakingAmount);
|
|
799
|
-
await dai
|
|
800
|
-
.connect(staker)
|
|
801
|
-
.approve(goodCompoundStaking.address, stakingAmount);
|
|
558
|
+
await dai.connect(staker).approve(goodCompoundStaking.address, stakingAmount);
|
|
802
559
|
const stakeBlockNumber = (await ethers.provider.getBlockNumber()) + 1;
|
|
803
560
|
await goodCompoundStaking.connect(staker).stake(stakingAmount, 0, false);
|
|
804
561
|
await advanceBlocks(5);
|
|
805
|
-
await goodCompoundStaking
|
|
806
|
-
|
|
807
|
-
.withdrawStake(stakingAmount.div(2), false);
|
|
808
|
-
const gdBalanceAfterFirstWithdraw = await goodDollar.balanceOf(
|
|
809
|
-
staker.address
|
|
810
|
-
);
|
|
562
|
+
await goodCompoundStaking.connect(staker).withdrawStake(stakingAmount.div(2), false);
|
|
563
|
+
const gdBalanceAfterFirstWithdraw = await goodDollar.balanceOf(staker.address);
|
|
811
564
|
const firstWithdrawBlockNumber = await ethers.provider.getBlockNumber();
|
|
812
565
|
await advanceBlocks(60);
|
|
813
566
|
|
|
814
|
-
await goodCompoundStaking
|
|
815
|
-
|
|
816
|
-
.withdrawStake(stakingAmount.div(2), false);
|
|
817
|
-
const gdBalanceAfterSecondWithdraw = await goodDollar.balanceOf(
|
|
818
|
-
staker.address
|
|
819
|
-
);
|
|
567
|
+
await goodCompoundStaking.connect(staker).withdrawStake(stakingAmount.div(2), false);
|
|
568
|
+
const gdBalanceAfterSecondWithdraw = await goodDollar.balanceOf(staker.address);
|
|
820
569
|
expect(gdBalanceAfterFirstWithdraw).to.be.gt(initialGdBalance);
|
|
821
570
|
expect(gdBalanceAfterFirstWithdraw.sub(initialGdBalance)).to.be.equal(
|
|
822
571
|
BN.from("1000")
|
|
@@ -824,9 +573,7 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
824
573
|
.div(2)
|
|
825
574
|
);
|
|
826
575
|
expect(gdBalanceAfterSecondWithdraw).to.be.gt(gdBalanceAfterFirstWithdraw);
|
|
827
|
-
expect(
|
|
828
|
-
gdBalanceAfterSecondWithdraw.sub(gdBalanceAfterFirstWithdraw)
|
|
829
|
-
).to.be.equal(
|
|
576
|
+
expect(gdBalanceAfterSecondWithdraw.sub(gdBalanceAfterFirstWithdraw)).to.be.equal(
|
|
830
577
|
BN.from("1000")
|
|
831
578
|
.mul(currentBlockNumber + 50 - firstWithdrawBlockNumber)
|
|
832
579
|
.div(2)
|
|
@@ -834,32 +581,20 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
834
581
|
); // sub 1 due to precision loss
|
|
835
582
|
});
|
|
836
583
|
it("it should not earn rewards when currentBlock < blockStart", async () => {
|
|
837
|
-
const goodFundManagerFactory = await ethers.getContractFactory(
|
|
838
|
-
"GoodFundManager"
|
|
839
|
-
);
|
|
584
|
+
const goodFundManagerFactory = await ethers.getContractFactory("GoodFundManager");
|
|
840
585
|
const currentBlockNumber = await ethers.provider.getBlockNumber();
|
|
841
586
|
let encodedData = goodFundManagerFactory.interface.encodeFunctionData(
|
|
842
587
|
"setStakingReward",
|
|
843
|
-
[
|
|
844
|
-
"1000",
|
|
845
|
-
goodCompoundStaking.address,
|
|
846
|
-
currentBlockNumber + 100,
|
|
847
|
-
currentBlockNumber + 500,
|
|
848
|
-
false
|
|
849
|
-
] // set 10 gd per block
|
|
588
|
+
["1000", goodCompoundStaking.address, currentBlockNumber + 100, currentBlockNumber + 500, false] // set 10 gd per block
|
|
850
589
|
);
|
|
851
590
|
await genericCall(goodFundManager.address, encodedData);
|
|
852
591
|
const stakingAmount = ethers.utils.parseEther("100");
|
|
853
592
|
const initialGdBalance = await goodDollar.balanceOf(staker.address);
|
|
854
593
|
await dai["mint(address,uint256)"](staker.address, stakingAmount);
|
|
855
|
-
await dai
|
|
856
|
-
.connect(staker)
|
|
857
|
-
.approve(goodCompoundStaking.address, stakingAmount);
|
|
594
|
+
await dai.connect(staker).approve(goodCompoundStaking.address, stakingAmount);
|
|
858
595
|
await goodCompoundStaking.connect(staker).stake(stakingAmount, 0, false);
|
|
859
596
|
await advanceBlocks(50);
|
|
860
|
-
await goodCompoundStaking
|
|
861
|
-
.connect(staker)
|
|
862
|
-
.withdrawStake(stakingAmount, false);
|
|
597
|
+
await goodCompoundStaking.connect(staker).withdrawStake(stakingAmount, false);
|
|
863
598
|
const gdBalanceAfterWithdraw = await goodDollar.balanceOf(staker.address);
|
|
864
599
|
|
|
865
600
|
expect(initialGdBalance).to.be.gt(0);
|
|
@@ -867,32 +602,20 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
867
602
|
});
|
|
868
603
|
|
|
869
604
|
it("it should earn rewards when they stake before blockStart but keep their stake until after blockStart", async () => {
|
|
870
|
-
const goodFundManagerFactory = await ethers.getContractFactory(
|
|
871
|
-
"GoodFundManager"
|
|
872
|
-
);
|
|
605
|
+
const goodFundManagerFactory = await ethers.getContractFactory("GoodFundManager");
|
|
873
606
|
const currentBlockNumber = await ethers.provider.getBlockNumber();
|
|
874
607
|
let encodedData = goodFundManagerFactory.interface.encodeFunctionData(
|
|
875
608
|
"setStakingReward",
|
|
876
|
-
[
|
|
877
|
-
"1000",
|
|
878
|
-
goodCompoundStaking.address,
|
|
879
|
-
currentBlockNumber + 30,
|
|
880
|
-
currentBlockNumber + 500,
|
|
881
|
-
false
|
|
882
|
-
] // set 10 gd per block
|
|
609
|
+
["1000", goodCompoundStaking.address, currentBlockNumber + 30, currentBlockNumber + 500, false] // set 10 gd per block
|
|
883
610
|
);
|
|
884
611
|
await genericCall(goodFundManager.address, encodedData);
|
|
885
612
|
const stakingAmount = ethers.utils.parseEther("100");
|
|
886
613
|
const initialGdBalance = await goodDollar.balanceOf(staker.address);
|
|
887
614
|
await dai["mint(address,uint256)"](staker.address, stakingAmount);
|
|
888
|
-
await dai
|
|
889
|
-
.connect(staker)
|
|
890
|
-
.approve(goodCompoundStaking.address, stakingAmount);
|
|
615
|
+
await dai.connect(staker).approve(goodCompoundStaking.address, stakingAmount);
|
|
891
616
|
await goodCompoundStaking.connect(staker).stake(stakingAmount, 0, false);
|
|
892
617
|
await advanceBlocks(50);
|
|
893
|
-
await goodCompoundStaking
|
|
894
|
-
.connect(staker)
|
|
895
|
-
.withdrawStake(stakingAmount, false);
|
|
618
|
+
await goodCompoundStaking.connect(staker).withdrawStake(stakingAmount, false);
|
|
896
619
|
const withdrawBlockNumber = await ethers.provider.getBlockNumber();
|
|
897
620
|
const gdBalanceAfterWithdraw = await goodDollar.balanceOf(staker.address);
|
|
898
621
|
expect(initialGdBalance).to.be.gt(0);
|
|
@@ -905,78 +628,42 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
905
628
|
);
|
|
906
629
|
});
|
|
907
630
|
it("should be able earn to 50% of rewards when owns 50% of total productivity", async () => {
|
|
908
|
-
const goodFundManagerFactory = await ethers.getContractFactory(
|
|
909
|
-
|
|
910
|
-
);
|
|
911
|
-
const ictrl = await ethers.getContractAt(
|
|
912
|
-
"Controller",
|
|
913
|
-
controller,
|
|
914
|
-
schemeMock
|
|
915
|
-
);
|
|
631
|
+
const goodFundManagerFactory = await ethers.getContractFactory("GoodFundManager");
|
|
632
|
+
const ictrl = await ethers.getContractAt("Controller", controller, schemeMock);
|
|
916
633
|
const currentBlockNumber = await ethers.provider.getBlockNumber();
|
|
917
634
|
let encodedDataTwo = goodFundManagerFactory.interface.encodeFunctionData(
|
|
918
635
|
"setStakingReward",
|
|
919
|
-
[
|
|
920
|
-
"1000",
|
|
921
|
-
goodCompoundStaking.address,
|
|
922
|
-
currentBlockNumber - 10,
|
|
923
|
-
currentBlockNumber + 100,
|
|
924
|
-
false
|
|
925
|
-
] // set 10 gd per block
|
|
636
|
+
["1000", goodCompoundStaking.address, currentBlockNumber - 10, currentBlockNumber + 100, false] // set 10 gd per block
|
|
926
637
|
);
|
|
927
638
|
|
|
928
639
|
const stakingAmount = ethers.utils.parseEther("100");
|
|
929
640
|
|
|
930
641
|
await dai["mint(address,uint256)"](staker.address, stakingAmount);
|
|
931
642
|
await dai["mint(address,uint256)"](signers[0].address, stakingAmount); // We use some different signer than founder since founder also UBI INTEREST collector
|
|
932
|
-
await dai
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
await dai
|
|
936
|
-
.connect(staker)
|
|
937
|
-
.approve(goodCompoundStaking.address, stakingAmount);
|
|
938
|
-
let stakerTwoGDAmountBeforeStake = await goodDollar.balanceOf(
|
|
939
|
-
signers[0].address
|
|
940
|
-
);
|
|
643
|
+
await dai.connect(signers[0]).approve(goodCompoundStaking.address, stakingAmount);
|
|
644
|
+
await dai.connect(staker).approve(goodCompoundStaking.address, stakingAmount);
|
|
645
|
+
let stakerTwoGDAmountBeforeStake = await goodDollar.balanceOf(signers[0].address);
|
|
941
646
|
let stakerGDAmountBeforeStake = await goodDollar.balanceOf(staker.address);
|
|
942
647
|
|
|
943
648
|
await goodCompoundStaking.connect(staker).stake(stakingAmount, 100, false);
|
|
944
|
-
await goodCompoundStaking
|
|
945
|
-
.connect(signers[0])
|
|
946
|
-
.stake(stakingAmount, 100, false);
|
|
649
|
+
await goodCompoundStaking.connect(signers[0]).stake(stakingAmount, 100, false);
|
|
947
650
|
await advanceBlocks(5);
|
|
948
651
|
|
|
949
|
-
await goodCompoundStaking
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
await goodCompoundStaking
|
|
953
|
-
.connect(signers[0])
|
|
954
|
-
.withdrawStake(stakingAmount, false);
|
|
955
|
-
let stakerTwoGDAmountAfterStake = await goodDollar.balanceOf(
|
|
956
|
-
signers[0].address
|
|
957
|
-
);
|
|
652
|
+
await goodCompoundStaking.connect(staker).withdrawStake(stakingAmount, false);
|
|
653
|
+
await goodCompoundStaking.connect(signers[0]).withdrawStake(stakingAmount, false);
|
|
654
|
+
let stakerTwoGDAmountAfterStake = await goodDollar.balanceOf(signers[0].address);
|
|
958
655
|
let stakerGDAmountAfterStake = await goodDollar.balanceOf(staker.address);
|
|
959
|
-
expect(
|
|
960
|
-
stakerTwoGDAmountAfterStake.sub(stakerTwoGDAmountBeforeStake).toString()
|
|
961
|
-
).to.be.equal(
|
|
656
|
+
expect(stakerTwoGDAmountAfterStake.sub(stakerTwoGDAmountBeforeStake).toString()).to.be.equal(
|
|
962
657
|
stakerGDAmountAfterStake.sub(stakerGDAmountBeforeStake).toString()
|
|
963
658
|
);
|
|
964
659
|
});
|
|
965
660
|
it("Accumulated per share has enough precision when reward << totalproductivity", async () => {
|
|
966
|
-
const goodFundManagerFactory = await ethers.getContractFactory(
|
|
967
|
-
"GoodFundManager"
|
|
968
|
-
);
|
|
661
|
+
const goodFundManagerFactory = await ethers.getContractFactory("GoodFundManager");
|
|
969
662
|
|
|
970
663
|
const currentBlockNumber = await ethers.provider.getBlockNumber();
|
|
971
664
|
let encodedDataTwo = goodFundManagerFactory.interface.encodeFunctionData(
|
|
972
665
|
"setStakingReward",
|
|
973
|
-
[
|
|
974
|
-
"1000",
|
|
975
|
-
goodCompoundStaking.address,
|
|
976
|
-
currentBlockNumber - 10,
|
|
977
|
-
currentBlockNumber + 100,
|
|
978
|
-
false
|
|
979
|
-
] // set 10 gd per block
|
|
666
|
+
["1000", goodCompoundStaking.address, currentBlockNumber - 10, currentBlockNumber + 100, false] // set 10 gd per block
|
|
980
667
|
);
|
|
981
668
|
await genericCall(goodFundManager.address, encodedDataTwo, avatar, 0);
|
|
982
669
|
const stakingAmount = ethers.utils.parseEther("1000000000");
|
|
@@ -987,32 +674,24 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
987
674
|
const gdBalanceBeforeWithdraw = await goodDollar.balanceOf(founder.address);
|
|
988
675
|
await goodCompoundStaking.withdrawStake(stakingAmount, false);
|
|
989
676
|
const gdBalanceAfterWithdraw = await goodDollar.balanceOf(founder.address);
|
|
990
|
-
expect(
|
|
991
|
-
gdBalanceAfterWithdraw.sub(gdBalanceBeforeWithdraw).toString()
|
|
992
|
-
).to.be.equal("2500");
|
|
677
|
+
expect(gdBalanceAfterWithdraw.sub(gdBalanceBeforeWithdraw).toString()).to.be.equal("2500");
|
|
993
678
|
});
|
|
994
679
|
|
|
995
680
|
it("it should not get any reward when donationPer set to 100", async () => {
|
|
996
681
|
const stakingAmount = ethers.utils.parseEther("100");
|
|
997
682
|
await dai["mint(address,uint256)"](staker.address, stakingAmount);
|
|
998
683
|
let stakerGDAmountBeforeStake = await goodDollar.balanceOf(staker.address);
|
|
999
|
-
await dai
|
|
1000
|
-
.connect(staker)
|
|
1001
|
-
.approve(goodCompoundStaking.address, stakingAmount);
|
|
684
|
+
await dai.connect(staker).approve(goodCompoundStaking.address, stakingAmount);
|
|
1002
685
|
await goodCompoundStaking.connect(staker).stake(stakingAmount, 100, false);
|
|
1003
686
|
await advanceBlocks(4);
|
|
1004
|
-
await goodCompoundStaking
|
|
1005
|
-
.connect(staker)
|
|
1006
|
-
.withdrawStake(stakingAmount, false);
|
|
687
|
+
await goodCompoundStaking.connect(staker).withdrawStake(stakingAmount, false);
|
|
1007
688
|
let stakerGDAmountAfterStake = await goodDollar.balanceOf(staker.address);
|
|
1008
689
|
expect(stakerGDAmountAfterStake).to.be.equal(stakerGDAmountBeforeStake);
|
|
1009
690
|
});
|
|
1010
691
|
it("it should be reverted when donation per set to different than 0 or 100", async () => {
|
|
1011
692
|
const stakingAmount = ethers.utils.parseEther("100");
|
|
1012
693
|
await dai["mint(address,uint256)"](staker.address, stakingAmount);
|
|
1013
|
-
await dai
|
|
1014
|
-
.connect(staker)
|
|
1015
|
-
.approve(goodCompoundStaking.address, stakingAmount);
|
|
694
|
+
await dai.connect(staker).approve(goodCompoundStaking.address, stakingAmount);
|
|
1016
695
|
const tx = await goodCompoundStaking
|
|
1017
696
|
.connect(staker)
|
|
1018
697
|
.stake(stakingAmount, 55, false)
|
|
@@ -1024,9 +703,7 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1024
703
|
const stakingAmount = ethers.utils.parseEther("100");
|
|
1025
704
|
|
|
1026
705
|
await dai["mint(address,uint256)"](staker.address, stakingAmount);
|
|
1027
|
-
await dai
|
|
1028
|
-
.connect(staker)
|
|
1029
|
-
.approve(goodCompoundStaking.address, stakingAmount);
|
|
706
|
+
await dai.connect(staker).approve(goodCompoundStaking.address, stakingAmount);
|
|
1030
707
|
|
|
1031
708
|
await goodCompoundStaking.connect(staker).stake(stakingAmount, 100, false);
|
|
1032
709
|
|
|
@@ -1036,13 +713,14 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1036
713
|
|
|
1037
714
|
const simpleStaking1 = await deployStaking();
|
|
1038
715
|
|
|
1039
|
-
const goodFundManagerFactory = await ethers.getContractFactory(
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
716
|
+
const goodFundManagerFactory = await ethers.getContractFactory("GoodFundManager");
|
|
717
|
+
let encodedData = goodFundManagerFactory.interface.encodeFunctionData("setStakingReward", [
|
|
718
|
+
"100",
|
|
719
|
+
simpleStaking.address,
|
|
720
|
+
0,
|
|
721
|
+
10,
|
|
722
|
+
false
|
|
723
|
+
]);
|
|
1046
724
|
await genericCall(goodFundManager.address, encodedData, avatar, 0);
|
|
1047
725
|
await dai["mint(address,uint256)"](staker.address, stakingAmount);
|
|
1048
726
|
await dai.connect(staker).approve(simpleStaking.address, stakingAmount);
|
|
@@ -1057,96 +735,59 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1057
735
|
expect(addressesToCollect[0]).to.be.equal(simpleStaking.address);
|
|
1058
736
|
expect(addressesToCollect[1]).to.be.equal(goodCompoundStaking.address);
|
|
1059
737
|
|
|
1060
|
-
await goodCompoundStaking
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
738
|
+
await goodCompoundStaking.connect(staker).withdrawStake(stakingAmount, false);
|
|
739
|
+
encodedData = goodFundManagerFactory.interface.encodeFunctionData("setStakingReward", [
|
|
740
|
+
"100",
|
|
741
|
+
simpleStaking.address,
|
|
742
|
+
0,
|
|
743
|
+
10,
|
|
744
|
+
true
|
|
745
|
+
]);
|
|
1067
746
|
await genericCall(goodFundManager.address, encodedData, avatar, 0);
|
|
1068
747
|
});
|
|
1069
748
|
|
|
1070
749
|
it("It should not collect interest when interest is lower than gas cost [ @skip-on-coverage ]", async () => {
|
|
1071
|
-
await
|
|
1072
|
-
|
|
1073
|
-
.
|
|
1074
|
-
|
|
1075
|
-
const stakingAmount = ethers.utils.parseEther("100");
|
|
1076
|
-
|
|
1077
|
-
await dai["mint(address,uint256)"](staker.address, stakingAmount);
|
|
1078
|
-
await dai
|
|
1079
|
-
.connect(staker)
|
|
1080
|
-
.approve(goodCompoundStaking.address, stakingAmount);
|
|
1081
|
-
|
|
1082
|
-
await goodCompoundStaking.connect(staker).stake(stakingAmount, 100, false);
|
|
1083
|
-
const transaction = await goodFundManager
|
|
1084
|
-
.collectInterest([goodCompoundStaking.address], false, {
|
|
750
|
+
await gasFeeOracle.setPrice(ethers.constants.WeiPerEther); //increase gas price so costs is more than ubi minted
|
|
751
|
+
await expect(
|
|
752
|
+
goodFundManager.collectInterest([], false, {
|
|
1085
753
|
gasLimit: 770000
|
|
1086
754
|
})
|
|
1087
|
-
|
|
1088
|
-
await
|
|
1089
|
-
.connect(staker)
|
|
1090
|
-
.withdrawStake(stakingAmount, false);
|
|
1091
|
-
expect(transaction.message).to.have.string(
|
|
1092
|
-
"Collected interest value should be interestMultiplier x gas costs"
|
|
1093
|
-
);
|
|
755
|
+
).revertedWith("X*gas costs");
|
|
756
|
+
await gasFeeOracle.setPrice(25e8); //undo gas price
|
|
1094
757
|
});
|
|
1095
758
|
|
|
1096
759
|
it("It should always collect interest without rewards when forced", async () => {
|
|
1097
|
-
await goodFundManager
|
|
1098
|
-
.collectInterest([goodCompoundStaking.address], false)
|
|
1099
|
-
.catch(e => e); // make sure there is no interest left
|
|
760
|
+
await goodFundManager.collectInterest([goodCompoundStaking.address], false).catch(e => e); // make sure there is no interest left
|
|
1100
761
|
|
|
1101
762
|
const stakingAmount = ethers.utils.parseEther("100");
|
|
1102
763
|
|
|
1103
764
|
await dai["mint(address,uint256)"](staker.address, stakingAmount);
|
|
1104
|
-
await dai
|
|
1105
|
-
.connect(staker)
|
|
1106
|
-
.approve(goodCompoundStaking.address, stakingAmount);
|
|
765
|
+
await dai.connect(staker).approve(goodCompoundStaking.address, stakingAmount);
|
|
1107
766
|
|
|
1108
767
|
await goodCompoundStaking.connect(staker).stake(stakingAmount, 100, false);
|
|
1109
|
-
const transaction = goodFundManager.collectInterest(
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
{
|
|
1113
|
-
gasLimit: 770000
|
|
1114
|
-
}
|
|
1115
|
-
);
|
|
768
|
+
const transaction = goodFundManager.collectInterest([goodCompoundStaking.address], true, {
|
|
769
|
+
gasLimit: 770000
|
|
770
|
+
});
|
|
1116
771
|
|
|
1117
772
|
await expect(transaction).to.emit(goodFundManager, "FundsTransferred");
|
|
1118
773
|
const tx = await (await transaction).wait();
|
|
1119
774
|
const event = tx.events.find(e => e.event === "FundsTransferred");
|
|
1120
775
|
expect(event.args.gdReward).to.equal(0);
|
|
1121
776
|
|
|
1122
|
-
await goodCompoundStaking
|
|
1123
|
-
.connect(staker)
|
|
1124
|
-
.withdrawStake(stakingAmount, false);
|
|
777
|
+
await goodCompoundStaking.connect(staker).withdrawStake(stakingAmount, false);
|
|
1125
778
|
});
|
|
1126
779
|
|
|
1127
780
|
it("It should sort array from lowest to highest ", async () => {
|
|
1128
|
-
const goodFundManagerTestFactory = await ethers.getContractFactory(
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
const goodFundManagerTest = await goodFundManagerTestFactory.deploy(
|
|
1132
|
-
nameService.address
|
|
1133
|
-
);
|
|
1134
|
-
const addresses = [
|
|
1135
|
-
founder.address,
|
|
1136
|
-
staker.address,
|
|
1137
|
-
cDAI.address,
|
|
1138
|
-
cDAI1.address
|
|
1139
|
-
];
|
|
781
|
+
const goodFundManagerTestFactory = await ethers.getContractFactory("GoodFundManagerTest");
|
|
782
|
+
const goodFundManagerTest = await goodFundManagerTestFactory.deploy(nameService.address);
|
|
783
|
+
const addresses = [founder.address, staker.address, cDAI.address, cDAI1.address];
|
|
1140
784
|
const balances = [
|
|
1141
785
|
ethers.utils.parseEther("100"),
|
|
1142
786
|
ethers.utils.parseEther("85"),
|
|
1143
787
|
ethers.utils.parseEther("90"),
|
|
1144
788
|
ethers.utils.parseEther("30")
|
|
1145
789
|
];
|
|
1146
|
-
const sortedArrays = await goodFundManagerTest.testSorting(
|
|
1147
|
-
balances,
|
|
1148
|
-
addresses
|
|
1149
|
-
);
|
|
790
|
+
const sortedArrays = await goodFundManagerTest.testSorting(balances, addresses);
|
|
1150
791
|
expect(sortedArrays[0][0]).to.be.equal(ethers.utils.parseEther("30"));
|
|
1151
792
|
expect(sortedArrays[0][3]).to.be.equal(ethers.utils.parseEther("100"));
|
|
1152
793
|
expect(sortedArrays[1][3]).to.be.equal(founder.address);
|
|
@@ -1154,21 +795,24 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1154
795
|
});
|
|
1155
796
|
|
|
1156
797
|
it("It should not be able to calc and sort array when there is no active staking contract", async () => {
|
|
1157
|
-
const goodFundManagerFactory = await ethers.getContractFactory(
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
798
|
+
const goodFundManagerFactory = await ethers.getContractFactory("GoodFundManager");
|
|
799
|
+
let encodedData = goodFundManagerFactory.interface.encodeFunctionData("setStakingReward", [
|
|
800
|
+
"100",
|
|
801
|
+
goodCompoundStaking.address,
|
|
802
|
+
0,
|
|
803
|
+
10,
|
|
804
|
+
true
|
|
805
|
+
]);
|
|
1164
806
|
await genericCall(goodFundManager.address, encodedData, avatar, 0);
|
|
1165
|
-
const contractsToInterestCollected =
|
|
1166
|
-
await goodFundManager.calcSortedContracts();
|
|
807
|
+
const contractsToInterestCollected = await goodFundManager.calcSortedContracts();
|
|
1167
808
|
expect(contractsToInterestCollected.length).to.be.equal(0);
|
|
1168
|
-
encodedData = goodFundManagerFactory.interface.encodeFunctionData(
|
|
1169
|
-
"
|
|
1170
|
-
|
|
1171
|
-
|
|
809
|
+
encodedData = goodFundManagerFactory.interface.encodeFunctionData("setStakingReward", [
|
|
810
|
+
"100",
|
|
811
|
+
goodCompoundStaking.address,
|
|
812
|
+
100,
|
|
813
|
+
1000,
|
|
814
|
+
false
|
|
815
|
+
]);
|
|
1172
816
|
await genericCall(goodFundManager.address, encodedData, avatar, 0);
|
|
1173
817
|
});
|
|
1174
818
|
|
|
@@ -1176,107 +820,72 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1176
820
|
const currentBlockNumber = await ethers.provider.getBlockNumber();
|
|
1177
821
|
const currentBlock = await ethers.provider.getBlock(currentBlockNumber);
|
|
1178
822
|
|
|
1179
|
-
await ethers.provider.send("evm_setNextBlockTimestamp", [
|
|
1180
|
-
currentBlock.timestamp + 5185020
|
|
1181
|
-
]);
|
|
823
|
+
await ethers.provider.send("evm_setNextBlockTimestamp", [currentBlock.timestamp + 5185020]);
|
|
1182
824
|
await ethers.provider.send("evm_mine", []);
|
|
1183
|
-
const collectableContracts = await goodFundManager
|
|
1184
|
-
|
|
1185
|
-
.catch(e => e);
|
|
1186
|
-
const tx = await goodFundManager
|
|
1187
|
-
.collectInterest([goodCompoundStaking.address], false)
|
|
1188
|
-
.catch(e => e);
|
|
1189
|
-
expect(tx.message).to.have.string(
|
|
1190
|
-
"Collected interest value should be larger than spent gas costs"
|
|
1191
|
-
);
|
|
825
|
+
const collectableContracts = await goodFundManager.calcSortedContracts().catch(e => e);
|
|
826
|
+
await expect(goodFundManager.collectInterest([goodCompoundStaking.address], false)).revertedWith("< gas costs");
|
|
1192
827
|
});
|
|
1193
828
|
|
|
1194
829
|
it("Avatar should be able to set gd minting gas amount", async () => {
|
|
1195
|
-
const goodFundManagerFactory = await ethers.getContractFactory(
|
|
1196
|
-
|
|
1197
|
-
);
|
|
1198
|
-
let encodedData = goodFundManagerFactory.interface.encodeFunctionData(
|
|
1199
|
-
"setGasCost",
|
|
1200
|
-
["140000"]
|
|
1201
|
-
);
|
|
830
|
+
const goodFundManagerFactory = await ethers.getContractFactory("GoodFundManager");
|
|
831
|
+
let encodedData = goodFundManagerFactory.interface.encodeFunctionData("setGasCost", ["140000"]);
|
|
1202
832
|
await genericCall(goodFundManager.address, encodedData, avatar, 0);
|
|
1203
833
|
});
|
|
1204
834
|
it("Avatar should be able to set collectInterestTimeThreshold", async () => {
|
|
1205
|
-
const goodFundManagerFactory = await ethers.getContractFactory(
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
"setCollectInterestTimeThreshold",
|
|
1210
|
-
["5184000"]
|
|
1211
|
-
);
|
|
835
|
+
const goodFundManagerFactory = await ethers.getContractFactory("GoodFundManager");
|
|
836
|
+
let encodedData = goodFundManagerFactory.interface.encodeFunctionData("setCollectInterestTimeThreshold", [
|
|
837
|
+
"5184000"
|
|
838
|
+
]);
|
|
1212
839
|
await genericCall(goodFundManager.address, encodedData, avatar, 0);
|
|
1213
840
|
});
|
|
1214
841
|
it("Avatar should be able set interestMultiplier", async () => {
|
|
1215
|
-
const goodFundManagerFactory = await ethers.getContractFactory(
|
|
1216
|
-
|
|
1217
|
-
);
|
|
1218
|
-
let encodedData = goodFundManagerFactory.interface.encodeFunctionData(
|
|
1219
|
-
"setInterestMultiplier",
|
|
1220
|
-
["4"]
|
|
1221
|
-
);
|
|
842
|
+
const goodFundManagerFactory = await ethers.getContractFactory("GoodFundManager");
|
|
843
|
+
let encodedData = goodFundManagerFactory.interface.encodeFunctionData("setInterestMultiplier", ["4"]);
|
|
1222
844
|
await genericCall(goodFundManager.address, encodedData, avatar, 0);
|
|
1223
845
|
});
|
|
1224
846
|
it("Avatar should be able set gasCostExceptInterestCollect", async () => {
|
|
1225
|
-
const goodFundManagerFactory = await ethers.getContractFactory(
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
"setGasCostExceptInterestCollect",
|
|
1230
|
-
["650000"]
|
|
1231
|
-
);
|
|
847
|
+
const goodFundManagerFactory = await ethers.getContractFactory("GoodFundManager");
|
|
848
|
+
let encodedData = goodFundManagerFactory.interface.encodeFunctionData("setGasCostExceptInterestCollect", [
|
|
849
|
+
"650000"
|
|
850
|
+
]);
|
|
1232
851
|
await genericCall(goodFundManager.address, encodedData, avatar, 0);
|
|
1233
852
|
});
|
|
1234
853
|
|
|
1235
854
|
it("It should be able to collect Interest from non DAI or cDAI staking contract [ @skip-on-coverage ]", async () => {
|
|
1236
|
-
const goodFundManagerFactory = await ethers.getContractFactory(
|
|
1237
|
-
|
|
1238
|
-
)
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
[bat.address, dai.address]
|
|
1253
|
-
);
|
|
1254
|
-
return contract;
|
|
1255
|
-
});
|
|
855
|
+
const goodFundManagerFactory = await ethers.getContractFactory("GoodFundManager");
|
|
856
|
+
|
|
857
|
+
const simpleStaking = await goodCompoundStakingFactory.deploy().then(async contract => {
|
|
858
|
+
await contract.init(
|
|
859
|
+
bat.address,
|
|
860
|
+
cBat.address,
|
|
861
|
+
nameService.address,
|
|
862
|
+
"Good BaT",
|
|
863
|
+
"gBAT",
|
|
864
|
+
"50",
|
|
865
|
+
batUsdOracle.address,
|
|
866
|
+
compUsdOracle.address,
|
|
867
|
+
[bat.address, dai.address]
|
|
868
|
+
);
|
|
869
|
+
return contract;
|
|
870
|
+
});
|
|
1256
871
|
|
|
1257
|
-
let encodedData = goodFundManagerFactory.interface.encodeFunctionData(
|
|
1258
|
-
"
|
|
1259
|
-
|
|
1260
|
-
|
|
872
|
+
let encodedData = goodFundManagerFactory.interface.encodeFunctionData("setStakingReward", [
|
|
873
|
+
"100",
|
|
874
|
+
simpleStaking.address,
|
|
875
|
+
10,
|
|
876
|
+
10000,
|
|
877
|
+
false
|
|
878
|
+
]);
|
|
1261
879
|
await genericCall(goodFundManager.address, encodedData, avatar, 0);
|
|
1262
|
-
encodedData = goodCompoundStakingFactory.interface.encodeFunctionData(
|
|
1263
|
-
"
|
|
1264
|
-
|
|
1265
|
-
);
|
|
880
|
+
encodedData = goodCompoundStakingFactory.interface.encodeFunctionData("setcollectInterestGasCostParams", [
|
|
881
|
+
"250000",
|
|
882
|
+
"150000"
|
|
883
|
+
]);
|
|
1266
884
|
await genericCall(simpleStaking.address, encodedData, avatar, 0);
|
|
1267
|
-
await bat["mint(address,uint256)"](
|
|
1268
|
-
founder.address,
|
|
1269
|
-
ethers.utils.parseEther("1001000")
|
|
1270
|
-
);
|
|
885
|
+
await bat["mint(address,uint256)"](founder.address, ethers.utils.parseEther("1001000"));
|
|
1271
886
|
await bat.transfer(cBat.address, ethers.utils.parseEther("1000000")); // We should put extra BAT to mock cBAT contract in order to provide interest
|
|
1272
|
-
await dai["mint(address,uint256)"](
|
|
1273
|
-
|
|
1274
|
-
ethers.utils.parseEther("1000000")
|
|
1275
|
-
);
|
|
1276
|
-
await dai.approve(
|
|
1277
|
-
goodCompoundStaking.address,
|
|
1278
|
-
ethers.utils.parseEther("100")
|
|
1279
|
-
);
|
|
887
|
+
await dai["mint(address,uint256)"](founder.address, ethers.utils.parseEther("1000000"));
|
|
888
|
+
await dai.approve(goodCompoundStaking.address, ethers.utils.parseEther("100"));
|
|
1280
889
|
await goodCompoundStaking.stake(ethers.utils.parseEther("100"), 100, false);
|
|
1281
890
|
await bat.approve(simpleStaking.address, ethers.utils.parseEther("100"));
|
|
1282
891
|
await simpleStaking.stake(ethers.utils.parseEther("100"), 100, false);
|
|
@@ -1291,15 +900,10 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1291
900
|
gasLimit: 1500000
|
|
1292
901
|
});
|
|
1293
902
|
await simpleStaking.withdrawStake(ethers.utils.parseEther("100"), false);
|
|
1294
|
-
await goodCompoundStaking.withdrawStake(
|
|
1295
|
-
ethers.utils.parseEther("100"),
|
|
1296
|
-
false
|
|
1297
|
-
);
|
|
903
|
+
await goodCompoundStaking.withdrawStake(ethers.utils.parseEther("100"), false);
|
|
1298
904
|
});
|
|
1299
905
|
it("It should redeem underlying token to DAI", async () => {
|
|
1300
|
-
const goodFundManagerFactory = await ethers.getContractFactory(
|
|
1301
|
-
"GoodFundManager"
|
|
1302
|
-
);
|
|
906
|
+
const goodFundManagerFactory = await ethers.getContractFactory("GoodFundManager");
|
|
1303
907
|
|
|
1304
908
|
const simpleStaking = await goodCompoundStakingTestFactory.deploy(
|
|
1305
909
|
bat.address,
|
|
@@ -1313,18 +917,10 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1313
917
|
[bat.address, dai.address]
|
|
1314
918
|
);
|
|
1315
919
|
await setDAOAddress("RESERVE", simpleStaking.address);
|
|
1316
|
-
await bat["mint(address,uint256)"](
|
|
1317
|
-
|
|
1318
|
-
ethers.utils.parseEther("1000")
|
|
1319
|
-
);
|
|
1320
|
-
await cBat["mint(address,uint256)"](
|
|
1321
|
-
simpleStaking.address,
|
|
1322
|
-
ethers.utils.parseUnits("1000", 8)
|
|
1323
|
-
);
|
|
920
|
+
await bat["mint(address,uint256)"](cBat.address, ethers.utils.parseEther("1000"));
|
|
921
|
+
await cBat["mint(address,uint256)"](simpleStaking.address, ethers.utils.parseUnits("1000", 8));
|
|
1324
922
|
const balanceBeforeRedeem = await dai.balanceOf(simpleStaking.address);
|
|
1325
|
-
await simpleStaking.redeemUnderlyingToDAITest(
|
|
1326
|
-
ethers.utils.parseUnits("10", 8)
|
|
1327
|
-
);
|
|
923
|
+
await simpleStaking.redeemUnderlyingToDAITest(ethers.utils.parseUnits("10", 8));
|
|
1328
924
|
await setDAOAddress("RESERVE", goodReserve.address);
|
|
1329
925
|
const balanceAfterRedeem = await dai.balanceOf(simpleStaking.address);
|
|
1330
926
|
const accAmountPerShare = await simpleStaking.accAmountPerShare();
|
|
@@ -1332,9 +928,7 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1332
928
|
expect(balanceAfterRedeem.gt(balanceBeforeRedeem)).to.be.true;
|
|
1333
929
|
});
|
|
1334
930
|
it("it should reverted when someone trying to call rewardsMinted function beside fundmanager", async () => {
|
|
1335
|
-
const tx = await goodCompoundStaking
|
|
1336
|
-
.rewardsMinted(founder.address, "1000", 50, 100)
|
|
1337
|
-
.catch(e => e);
|
|
931
|
+
const tx = await goodCompoundStaking.rewardsMinted(founder.address, "1000", 50, 100).catch(e => e);
|
|
1338
932
|
expect(tx.message).to.not.empty;
|
|
1339
933
|
});
|
|
1340
934
|
|
|
@@ -1350,12 +944,7 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1350
944
|
compUsdOracle.address,
|
|
1351
945
|
[bat.address, dai.address]
|
|
1352
946
|
);
|
|
1353
|
-
await expect(
|
|
1354
|
-
simpleStaking.decreaseProductivityTest(
|
|
1355
|
-
founder.address,
|
|
1356
|
-
ethers.utils.parseEther("100")
|
|
1357
|
-
)
|
|
1358
|
-
).reverted;
|
|
947
|
+
await expect(simpleStaking.decreaseProductivityTest(founder.address, ethers.utils.parseEther("100"))).reverted;
|
|
1359
948
|
});
|
|
1360
949
|
|
|
1361
950
|
it("User pending reward should be zero when there is no stake of user", async () => {
|
|
@@ -1370,15 +959,12 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1370
959
|
compUsdOracle.address,
|
|
1371
960
|
[bat.address, dai.address]
|
|
1372
961
|
);
|
|
1373
|
-
let encodedData =
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
);
|
|
962
|
+
let encodedData = goodCompoundStakingTestFactory.interface.encodeFunctionData("setcollectInterestGasCostParams", [
|
|
963
|
+
"250000",
|
|
964
|
+
"150000"
|
|
965
|
+
]);
|
|
1378
966
|
await genericCall(simpleStaking.address, encodedData, avatar, 0);
|
|
1379
|
-
const stakingContractVals = await goodFundManager.rewardsForStakingContract(
|
|
1380
|
-
goodCompoundStaking.address
|
|
1381
|
-
);
|
|
967
|
+
const stakingContractVals = await goodFundManager.rewardsForStakingContract(goodCompoundStaking.address);
|
|
1382
968
|
const pendingReward = await simpleStaking.getUserPendingReward(
|
|
1383
969
|
founder.address,
|
|
1384
970
|
stakingContractVals[0],
|
|
@@ -1399,16 +985,11 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1399
985
|
compUsdOracle.address,
|
|
1400
986
|
[bat.address, dai.address]
|
|
1401
987
|
);
|
|
1402
|
-
const tx = await simpleStaking
|
|
1403
|
-
.transfer(staker.address, "10000")
|
|
1404
|
-
.catch(e => e);
|
|
988
|
+
const tx = await simpleStaking.transfer(staker.address, "10000").catch(e => e);
|
|
1405
989
|
expect(tx.message).to.have.string("ERC20: transfer amount exceeds balance");
|
|
1406
990
|
});
|
|
1407
991
|
|
|
1408
|
-
async function addLiquidity(
|
|
1409
|
-
token0Amount: BigNumber,
|
|
1410
|
-
token1Amount: BigNumber
|
|
1411
|
-
) {
|
|
992
|
+
async function addLiquidity(token0Amount: BigNumber, token1Amount: BigNumber) {
|
|
1412
993
|
await bat.transfer(pair.address, token0Amount);
|
|
1413
994
|
await dai.transfer(pair.address, token1Amount);
|
|
1414
995
|
await pair.mint(founder.address);
|
|
@@ -1420,9 +1001,7 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1420
1001
|
["1000", signers[0].address, 10, 1000, true] // set 10 gd per block
|
|
1421
1002
|
);
|
|
1422
1003
|
await genericCall(goodFundManager.address, encodedData);
|
|
1423
|
-
let data = await goodFundManager.rewardsForStakingContract(
|
|
1424
|
-
signers[0].address
|
|
1425
|
-
);
|
|
1004
|
+
let data = await goodFundManager.rewardsForStakingContract(signers[0].address);
|
|
1426
1005
|
expect(data.isBlackListed).to.equal(true);
|
|
1427
1006
|
|
|
1428
1007
|
encodedData = goodFundManager.interface.encodeFunctionData(
|
|
@@ -1451,8 +1030,7 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1451
1030
|
["1000", simpleStaking1.address, 10, 1000, false] // set 10 gd per block
|
|
1452
1031
|
);
|
|
1453
1032
|
await genericCall(goodFundManager.address, encodedData, avatar, 0);
|
|
1454
|
-
const activeContractsCount =
|
|
1455
|
-
await goodFundManager.getActiveContractsCount();
|
|
1033
|
+
const activeContractsCount = await goodFundManager.getActiveContractsCount();
|
|
1456
1034
|
|
|
1457
1035
|
const simpleStaking = await goodCompoundStakingTestFactory.deploy(
|
|
1458
1036
|
bat.address,
|
|
@@ -1470,8 +1048,7 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1470
1048
|
["1000", simpleStaking.address, 10, 1000, false] // set 10 gd per block
|
|
1471
1049
|
);
|
|
1472
1050
|
await genericCall(goodFundManager.address, encodedData, avatar, 0);
|
|
1473
|
-
const activeContractsCountAfterAdded =
|
|
1474
|
-
await goodFundManager.getActiveContractsCount();
|
|
1051
|
+
const activeContractsCountAfterAdded = await goodFundManager.getActiveContractsCount();
|
|
1475
1052
|
|
|
1476
1053
|
expect(activeContractsCountAfterAdded).equal(activeContractsCount.add(1));
|
|
1477
1054
|
|
|
@@ -1481,16 +1058,13 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1481
1058
|
);
|
|
1482
1059
|
await genericCall(goodFundManager.address, encodedData, avatar, 0);
|
|
1483
1060
|
|
|
1484
|
-
const activeContractsCountAfterRemoved =
|
|
1485
|
-
await goodFundManager.getActiveContractsCount();
|
|
1061
|
+
const activeContractsCountAfterRemoved = await goodFundManager.getActiveContractsCount();
|
|
1486
1062
|
const lastActiveContractAfterRemove = await goodFundManager.activeContracts(
|
|
1487
1063
|
activeContractsCountAfterRemoved.sub(1)
|
|
1488
1064
|
);
|
|
1489
1065
|
|
|
1490
1066
|
expect(lastActiveContractAfterRemove).to.be.equal(simpleStaking.address);
|
|
1491
|
-
expect(activeContractsCountAfterAdded).to.be.eq(
|
|
1492
|
-
activeContractsCountAfterRemoved
|
|
1493
|
-
);
|
|
1067
|
+
expect(activeContractsCountAfterAdded).to.be.eq(activeContractsCountAfterRemoved);
|
|
1494
1068
|
|
|
1495
1069
|
expect(activeContractsCount).to.be.lt(activeContractsCountAfterRemoved);
|
|
1496
1070
|
});
|
|
@@ -1511,13 +1085,7 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1511
1085
|
const rewardsPerBlock = BN.from("1000");
|
|
1512
1086
|
let encodedData = goodFundManager.interface.encodeFunctionData(
|
|
1513
1087
|
"setStakingReward",
|
|
1514
|
-
[
|
|
1515
|
-
rewardsPerBlock,
|
|
1516
|
-
simpleStaking1.address,
|
|
1517
|
-
currentBlock - 10,
|
|
1518
|
-
currentBlock + 1000,
|
|
1519
|
-
false
|
|
1520
|
-
] // set 10 gd per block
|
|
1088
|
+
[rewardsPerBlock, simpleStaking1.address, currentBlock - 10, currentBlock + 1000, false] // set 10 gd per block
|
|
1521
1089
|
);
|
|
1522
1090
|
await genericCall(goodFundManager.address, encodedData, avatar, 0);
|
|
1523
1091
|
const stakingAmount = ethers.utils.parseEther("100");
|
|
@@ -1525,79 +1093,34 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1525
1093
|
await bat["mint(address,uint256)"](staker.address, stakingAmount);
|
|
1526
1094
|
await bat["mint(address,uint256)"](signers[0].address, stakingAmount);
|
|
1527
1095
|
await bat["mint(address,uint256)"](signers[1].address, stakingAmount);
|
|
1528
|
-
await bat["approve(address,uint256)"](
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
);
|
|
1532
|
-
await
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
await
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
await
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
const
|
|
1542
|
-
|
|
1543
|
-
await
|
|
1544
|
-
stakingAmount,
|
|
1545
|
-
"0",
|
|
1546
|
-
false
|
|
1547
|
-
);
|
|
1548
|
-
const stakerOneGdBalanceAfterStake = await goodDollar.balanceOf(
|
|
1549
|
-
founder.address
|
|
1550
|
-
);
|
|
1551
|
-
const stakerTwoStakeBlockNumber =
|
|
1552
|
-
(await ethers.provider.getBlockNumber()) + 1;
|
|
1553
|
-
await simpleStaking1
|
|
1554
|
-
.connect(staker)
|
|
1555
|
-
["stake(uint256,uint256,bool)"](stakingAmount.div(5), "0", false);
|
|
1556
|
-
const stakerTwoGdBalanceAfterStake = await goodDollar.balanceOf(
|
|
1557
|
-
staker.address
|
|
1558
|
-
);
|
|
1559
|
-
const stakerThreeStakeBlockNumber =
|
|
1560
|
-
(await ethers.provider.getBlockNumber()) + 1;
|
|
1561
|
-
await simpleStaking1
|
|
1562
|
-
.connect(signers[0])
|
|
1563
|
-
["stake(uint256,uint256,bool)"](stakingAmount.div(4), "0", false);
|
|
1564
|
-
const stakerThreeGdBalanceAfterStake = await goodDollar.balanceOf(
|
|
1565
|
-
signers[0].address
|
|
1566
|
-
);
|
|
1567
|
-
const stakerFourStakeBlockNumber =
|
|
1568
|
-
(await ethers.provider.getBlockNumber()) + 1;
|
|
1569
|
-
await simpleStaking1
|
|
1570
|
-
.connect(signers[1])
|
|
1571
|
-
["stake(uint256,uint256,bool)"](stakingAmount.div(10), "0", false);
|
|
1572
|
-
const stakerFourGdBalanceAfterStake = await goodDollar.balanceOf(
|
|
1573
|
-
signers[1].address
|
|
1574
|
-
);
|
|
1096
|
+
await bat["approve(address,uint256)"](simpleStaking1.address, stakingAmount);
|
|
1097
|
+
await bat.connect(staker)["approve(address,uint256)"](simpleStaking1.address, stakingAmount);
|
|
1098
|
+
await bat.connect(signers[0])["approve(address,uint256)"](simpleStaking1.address, stakingAmount);
|
|
1099
|
+
await bat.connect(signers[1])["approve(address,uint256)"](simpleStaking1.address, stakingAmount);
|
|
1100
|
+
const stakerOneStakeBlockNumber = (await ethers.provider.getBlockNumber()) + 1;
|
|
1101
|
+
await simpleStaking1["stake(uint256,uint256,bool)"](stakingAmount, "0", false);
|
|
1102
|
+
const stakerOneGdBalanceAfterStake = await goodDollar.balanceOf(founder.address);
|
|
1103
|
+
const stakerTwoStakeBlockNumber = (await ethers.provider.getBlockNumber()) + 1;
|
|
1104
|
+
await simpleStaking1.connect(staker)["stake(uint256,uint256,bool)"](stakingAmount.div(5), "0", false);
|
|
1105
|
+
const stakerTwoGdBalanceAfterStake = await goodDollar.balanceOf(staker.address);
|
|
1106
|
+
const stakerThreeStakeBlockNumber = (await ethers.provider.getBlockNumber()) + 1;
|
|
1107
|
+
await simpleStaking1.connect(signers[0])["stake(uint256,uint256,bool)"](stakingAmount.div(4), "0", false);
|
|
1108
|
+
const stakerThreeGdBalanceAfterStake = await goodDollar.balanceOf(signers[0].address);
|
|
1109
|
+
const stakerFourStakeBlockNumber = (await ethers.provider.getBlockNumber()) + 1;
|
|
1110
|
+
await simpleStaking1.connect(signers[1])["stake(uint256,uint256,bool)"](stakingAmount.div(10), "0", false);
|
|
1111
|
+
const stakerFourGdBalanceAfterStake = await goodDollar.balanceOf(signers[1].address);
|
|
1575
1112
|
await advanceBlocks(10);
|
|
1576
1113
|
await simpleStaking1["withdrawStake(uint256,bool)"](stakingAmount, false);
|
|
1577
1114
|
const stakerOneWithdrawBlockNumber = await ethers.provider.getBlockNumber();
|
|
1578
|
-
const stakerOneGdBalanceAfterWithdraw = await goodDollar.balanceOf(
|
|
1579
|
-
|
|
1580
|
-
);
|
|
1581
|
-
await simpleStaking1
|
|
1582
|
-
.connect(staker)
|
|
1583
|
-
["withdrawStake(uint256,bool)"](stakingAmount.div(5), false);
|
|
1115
|
+
const stakerOneGdBalanceAfterWithdraw = await goodDollar.balanceOf(founder.address);
|
|
1116
|
+
await simpleStaking1.connect(staker)["withdrawStake(uint256,bool)"](stakingAmount.div(5), false);
|
|
1584
1117
|
const stakerTwoWithdrawBlockNumber = await ethers.provider.getBlockNumber();
|
|
1585
|
-
const stakerTwoGdBalanceAfterWithdraw = await goodDollar.balanceOf(
|
|
1586
|
-
|
|
1587
|
-
);
|
|
1588
|
-
await simpleStaking1
|
|
1589
|
-
.connect(signers[0])
|
|
1590
|
-
["withdrawStake(uint256,bool)"](stakingAmount.div(4), false);
|
|
1118
|
+
const stakerTwoGdBalanceAfterWithdraw = await goodDollar.balanceOf(staker.address);
|
|
1119
|
+
await simpleStaking1.connect(signers[0])["withdrawStake(uint256,bool)"](stakingAmount.div(4), false);
|
|
1591
1120
|
|
|
1592
|
-
const stakerThreeGdBalanceAfterWithdraw = await goodDollar.balanceOf(
|
|
1593
|
-
|
|
1594
|
-
);
|
|
1595
|
-
await simpleStaking1
|
|
1596
|
-
.connect(signers[1])
|
|
1597
|
-
["withdrawStake(uint256,bool)"](stakingAmount.div(10), false);
|
|
1598
|
-
const stakerFourGdBalanceAfterWithdraw = await goodDollar.balanceOf(
|
|
1599
|
-
signers[1].address
|
|
1600
|
-
);
|
|
1121
|
+
const stakerThreeGdBalanceAfterWithdraw = await goodDollar.balanceOf(signers[0].address);
|
|
1122
|
+
await simpleStaking1.connect(signers[1])["withdrawStake(uint256,bool)"](stakingAmount.div(10), false);
|
|
1123
|
+
const stakerFourGdBalanceAfterWithdraw = await goodDollar.balanceOf(signers[1].address);
|
|
1601
1124
|
const stakerOneCalculatedReward = rewardsPerBlock
|
|
1602
1125
|
.add(rewardsPerBlock.mul(100).div(120)) // there is new staker so total stake units are 120 if call full stakingamount is 100
|
|
1603
1126
|
.add(rewardsPerBlock.mul(100).div(145)) // there is new staker so total stake units are 145
|
|
@@ -1643,27 +1166,15 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1643
1166
|
.add(rewardsPerBlock)
|
|
1644
1167
|
.div(BN.from("2"))
|
|
1645
1168
|
.add("1");
|
|
1646
|
-
expect(stakerOneGdBalanceAfterWithdraw).to.be.equal(
|
|
1647
|
-
|
|
1648
|
-
);
|
|
1649
|
-
expect(stakerTwoGdBalanceAfterWithdraw).to.be.equal(
|
|
1650
|
-
stakerTwoGdBalanceAfterStake.add(stakerTwoCalculatedReward)
|
|
1651
|
-
);
|
|
1169
|
+
expect(stakerOneGdBalanceAfterWithdraw).to.be.equal(stakerOneGdBalanceAfterStake.add(stakerOneCalculatedReward));
|
|
1170
|
+
expect(stakerTwoGdBalanceAfterWithdraw).to.be.equal(stakerTwoGdBalanceAfterStake.add(stakerTwoCalculatedReward));
|
|
1652
1171
|
expect(stakerThreeGdBalanceAfterWithdraw).to.be.equal(
|
|
1653
1172
|
stakerThreeGdBalanceAfterStake.add(stakerThreeCalculatedReward)
|
|
1654
1173
|
);
|
|
1655
|
-
expect(stakerFourGdBalanceAfterWithdraw).to.be.equal(
|
|
1656
|
-
stakerFourGdBalanceAfterStake.add(stakerFourCalculatedReward)
|
|
1657
|
-
);
|
|
1174
|
+
expect(stakerFourGdBalanceAfterWithdraw).to.be.equal(stakerFourGdBalanceAfterStake.add(stakerFourCalculatedReward));
|
|
1658
1175
|
encodedData = goodFundManager.interface.encodeFunctionData(
|
|
1659
1176
|
"setStakingReward",
|
|
1660
|
-
[
|
|
1661
|
-
rewardsPerBlock,
|
|
1662
|
-
simpleStaking1.address,
|
|
1663
|
-
currentBlock - 10,
|
|
1664
|
-
currentBlock + 1000,
|
|
1665
|
-
true
|
|
1666
|
-
] // set 10 gd per block
|
|
1177
|
+
[rewardsPerBlock, simpleStaking1.address, currentBlock - 10, currentBlock + 1000, true] // set 10 gd per block
|
|
1667
1178
|
);
|
|
1668
1179
|
await genericCall(goodFundManager.address, encodedData, avatar, 0);
|
|
1669
1180
|
});
|
|
@@ -1684,53 +1195,26 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1684
1195
|
const rewardsPerBlock = BN.from("100");
|
|
1685
1196
|
let encodedData = goodFundManager.interface.encodeFunctionData(
|
|
1686
1197
|
"setStakingReward",
|
|
1687
|
-
[
|
|
1688
|
-
rewardsPerBlock,
|
|
1689
|
-
simpleStaking1.address,
|
|
1690
|
-
currentBlock - 10,
|
|
1691
|
-
currentBlock + 1000,
|
|
1692
|
-
false
|
|
1693
|
-
] // set 1 gd per block
|
|
1198
|
+
[rewardsPerBlock, simpleStaking1.address, currentBlock - 10, currentBlock + 1000, false] // set 1 gd per block
|
|
1694
1199
|
);
|
|
1695
1200
|
await genericCall(goodFundManager.address, encodedData, avatar, 0);
|
|
1696
1201
|
const stakingAmount = ethers.utils.parseEther("100");
|
|
1697
1202
|
await bat["mint(address,uint256)"](founder.address, stakingAmount);
|
|
1698
1203
|
await bat["mint(address,uint256)"](staker.address, stakingAmount);
|
|
1699
|
-
await bat["approve(address,uint256)"](
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
);
|
|
1703
|
-
await bat
|
|
1704
|
-
.connect(staker)
|
|
1705
|
-
["approve(address,uint256)"](simpleStaking1.address, stakingAmount);
|
|
1706
|
-
await simpleStaking1["stake(uint256,uint256,bool)"](
|
|
1707
|
-
stakingAmount,
|
|
1708
|
-
"0",
|
|
1709
|
-
false
|
|
1710
|
-
);
|
|
1711
|
-
const founderGdBalanceAfterStake = await goodDollar.balanceOf(
|
|
1712
|
-
founder.address
|
|
1713
|
-
);
|
|
1204
|
+
await bat["approve(address,uint256)"](simpleStaking1.address, stakingAmount);
|
|
1205
|
+
await bat.connect(staker)["approve(address,uint256)"](simpleStaking1.address, stakingAmount);
|
|
1206
|
+
await simpleStaking1["stake(uint256,uint256,bool)"](stakingAmount, "0", false);
|
|
1207
|
+
const founderGdBalanceAfterStake = await goodDollar.balanceOf(founder.address);
|
|
1714
1208
|
const stakerStakeBlockNumber = (await ethers.provider.getBlockNumber()) + 1;
|
|
1715
|
-
await simpleStaking1
|
|
1716
|
-
|
|
1717
|
-
["stake(uint256,uint256,bool)"](stakingAmount.div(20), "0", false); // should get ~0.009 gd each block
|
|
1718
|
-
const stakerGdBalanceAfterStake = await goodDollar.balanceOf(
|
|
1719
|
-
staker.address
|
|
1720
|
-
);
|
|
1209
|
+
await simpleStaking1.connect(staker)["stake(uint256,uint256,bool)"](stakingAmount.div(20), "0", false); // should get ~0.009 gd each block
|
|
1210
|
+
const stakerGdBalanceAfterStake = await goodDollar.balanceOf(staker.address);
|
|
1721
1211
|
await advanceBlocks(100);
|
|
1722
|
-
await simpleStaking1
|
|
1723
|
-
.connect(staker)
|
|
1724
|
-
["withdrawStake(uint256,bool)"](stakingAmount.div(20), false);
|
|
1212
|
+
await simpleStaking1.connect(staker)["withdrawStake(uint256,bool)"](stakingAmount.div(20), false);
|
|
1725
1213
|
const stakerWithdrawBlockNumber = await ethers.provider.getBlockNumber();
|
|
1726
|
-
const stakerGdBalanceAfterWithdraw = await goodDollar.balanceOf(
|
|
1727
|
-
staker.address
|
|
1728
|
-
);
|
|
1214
|
+
const stakerGdBalanceAfterWithdraw = await goodDollar.balanceOf(staker.address);
|
|
1729
1215
|
await simpleStaking1["withdrawStake(uint256,bool)"](stakingAmount, false);
|
|
1730
1216
|
const founderWithdrawBlockNumber = await ethers.provider.getBlockNumber();
|
|
1731
|
-
const founderGdBalanceAfterWithdraw = await goodDollar.balanceOf(
|
|
1732
|
-
founder.address
|
|
1733
|
-
);
|
|
1217
|
+
const founderGdBalanceAfterWithdraw = await goodDollar.balanceOf(founder.address);
|
|
1734
1218
|
const stakerCalculatedRewards = rewardsPerBlock
|
|
1735
1219
|
.mul(5)
|
|
1736
1220
|
.mul(stakerWithdrawBlockNumber - stakerStakeBlockNumber)
|
|
@@ -1746,12 +1230,8 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1746
1230
|
.div(105)
|
|
1747
1231
|
)
|
|
1748
1232
|
.div(BN.from("2"));
|
|
1749
|
-
expect(
|
|
1750
|
-
|
|
1751
|
-
).to.be.equal(stakerCalculatedRewards);
|
|
1752
|
-
expect(
|
|
1753
|
-
founderGdBalanceAfterWithdraw.sub(founderGdBalanceAfterStake)
|
|
1754
|
-
).to.be.equal(founderCalculatedRewards);
|
|
1233
|
+
expect(stakerGdBalanceAfterWithdraw.sub(stakerGdBalanceAfterStake)).to.be.equal(stakerCalculatedRewards);
|
|
1234
|
+
expect(founderGdBalanceAfterWithdraw.sub(founderGdBalanceAfterStake)).to.be.equal(founderCalculatedRewards);
|
|
1755
1235
|
});
|
|
1756
1236
|
it("it should calculate price of spent gas in DAI properly", async () => {
|
|
1757
1237
|
const gasAmount = BN.from("1100000"); // 1.1M
|
|
@@ -1761,10 +1241,7 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1761
1241
|
.mul(BN.from("10").pow(18)) // we multiply with 1e18 so when we divide it to DAI/ETH rate we would get result in 18 decimals
|
|
1762
1242
|
.div(daiToEthRate) // we divide gas price to DAI/ETH rate so we can get gas price in DAI
|
|
1763
1243
|
.mul(gasAmount); // Result is in DAI and we accept 1$ = 1DAI
|
|
1764
|
-
const onChainResult = await goodFundManager.getGasPriceIncDAIorDAI(
|
|
1765
|
-
gasAmount,
|
|
1766
|
-
true
|
|
1767
|
-
);
|
|
1244
|
+
const onChainResult = await goodFundManager.getGasPriceIncDAIorDAI(gasAmount, true);
|
|
1768
1245
|
expect(calculatedResult).to.be.gt(0);
|
|
1769
1246
|
expect(onChainResult).to.be.equal(calculatedResult);
|
|
1770
1247
|
});
|
|
@@ -1778,10 +1255,7 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1778
1255
|
.mul(BN.from("10").pow(28)) // we multiply it with mantissa which is 18 + tokenDecimals - cTokenDecimals so token is in 18 decimals and cToken is in 8 decimals therefore difference is 10 for more detail https://compound.finance/docs#protocol-math
|
|
1779
1256
|
.div(await cDAI.exchangeRateStored()); // then we divide it exchange rate in order to get result
|
|
1780
1257
|
const calculatedResult = gasPriceInCdai.mul(gasAmount);
|
|
1781
|
-
const onChainResult = await goodFundManager.getGasPriceIncDAIorDAI(
|
|
1782
|
-
gasAmount,
|
|
1783
|
-
false
|
|
1784
|
-
);
|
|
1258
|
+
const onChainResult = await goodFundManager.getGasPriceIncDAIorDAI(gasAmount, false);
|
|
1785
1259
|
expect(calculatedResult).to.be.gt(0);
|
|
1786
1260
|
expect(onChainResult).to.be.equal(calculatedResult);
|
|
1787
1261
|
});
|
|
@@ -1808,14 +1282,8 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1808
1282
|
await bat.approve(simpleStaking.address, stakingAmount);
|
|
1809
1283
|
await simpleStaking.stake(stakingAmount, "0", false);
|
|
1810
1284
|
await cBat.increasePriceWithMultiplier(100);
|
|
1811
|
-
const currentGainsWithBothFalse = await simpleStaking.currentGains(
|
|
1812
|
-
|
|
1813
|
-
false
|
|
1814
|
-
);
|
|
1815
|
-
const currentGainsWithBothTrue = await simpleStaking.currentGains(
|
|
1816
|
-
true,
|
|
1817
|
-
true
|
|
1818
|
-
);
|
|
1285
|
+
const currentGainsWithBothFalse = await simpleStaking.currentGains(false, false);
|
|
1286
|
+
const currentGainsWithBothTrue = await simpleStaking.currentGains(true, true);
|
|
1819
1287
|
await simpleStaking.withdrawStake(stakingAmount, false);
|
|
1820
1288
|
expect(currentGainsWithBothFalse[3]).to.be.equal(0);
|
|
1821
1289
|
expect(currentGainsWithBothFalse[4]).to.be.equal(0);
|
|
@@ -1830,13 +1298,7 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1830
1298
|
|
|
1831
1299
|
it("it should collectInterest when there is comp rewards but there is no interest from interest token for nonDAI-cDAI staking contract", async () => {
|
|
1832
1300
|
const stakingAmount = ethers.utils.parseEther("100");
|
|
1833
|
-
let { simpleStaking } = await compTestHelper(
|
|
1834
|
-
bat,
|
|
1835
|
-
cBat,
|
|
1836
|
-
batUsdOracle,
|
|
1837
|
-
stakingAmount,
|
|
1838
|
-
false
|
|
1839
|
-
);
|
|
1301
|
+
let { simpleStaking } = await compTestHelper(bat, cBat, batUsdOracle, stakingAmount, false);
|
|
1840
1302
|
|
|
1841
1303
|
const currentGains = await simpleStaking.currentGains(false, true);
|
|
1842
1304
|
expect(currentGains[4]).to.be.equal("0");
|
|
@@ -1851,13 +1313,7 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1851
1313
|
|
|
1852
1314
|
it("it should collectInterest from interest token along with comp rewards for nonDAI-cDAI staking contract [ @skip-on-coverage ]", async () => {
|
|
1853
1315
|
const stakingAmount = ethers.utils.parseEther("100");
|
|
1854
|
-
let { simpleStaking } = await compTestHelper(
|
|
1855
|
-
bat,
|
|
1856
|
-
cBat,
|
|
1857
|
-
batUsdOracle,
|
|
1858
|
-
stakingAmount,
|
|
1859
|
-
true
|
|
1860
|
-
);
|
|
1316
|
+
let { simpleStaking } = await compTestHelper(bat, cBat, batUsdOracle, stakingAmount, true);
|
|
1861
1317
|
|
|
1862
1318
|
const currentGains = await simpleStaking.currentGains(false, true);
|
|
1863
1319
|
expect(currentGains[4]).to.be.equal("4"); // it's not equal due to precision loss
|
|
@@ -1872,13 +1328,7 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1872
1328
|
|
|
1873
1329
|
it("it should collectInterest when there is comp rewards but there is no interest from interest token for DAI-cDAI staking contract", async () => {
|
|
1874
1330
|
const stakingAmount = ethers.utils.parseEther("100");
|
|
1875
|
-
let { simpleStaking } = await compTestHelper(
|
|
1876
|
-
dai,
|
|
1877
|
-
cDAI,
|
|
1878
|
-
daiUsdOracle,
|
|
1879
|
-
stakingAmount,
|
|
1880
|
-
false
|
|
1881
|
-
);
|
|
1331
|
+
let { simpleStaking } = await compTestHelper(dai, cDAI, daiUsdOracle, stakingAmount, false);
|
|
1882
1332
|
|
|
1883
1333
|
const currentGains = await simpleStaking.currentGains(false, true);
|
|
1884
1334
|
expect(currentGains[4]).to.be.equal("0");
|
|
@@ -1892,13 +1342,7 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1892
1342
|
});
|
|
1893
1343
|
it("it should collectInterest from interest token along with comp rewards for DAI-cDAI staking contract [ @skip-on-coverage ]", async () => {
|
|
1894
1344
|
const stakingAmount = ethers.utils.parseEther("100");
|
|
1895
|
-
let { simpleStaking } = await compTestHelper(
|
|
1896
|
-
dai,
|
|
1897
|
-
cDAI,
|
|
1898
|
-
daiUsdOracle,
|
|
1899
|
-
stakingAmount,
|
|
1900
|
-
true
|
|
1901
|
-
);
|
|
1345
|
+
let { simpleStaking } = await compTestHelper(dai, cDAI, daiUsdOracle, stakingAmount, true);
|
|
1902
1346
|
|
|
1903
1347
|
const currentGains = await simpleStaking.currentGains(false, true);
|
|
1904
1348
|
expect(currentGains[4]).to.be.lt("200"); //should be equal 0 but due to precision loss give some offset so make sure less than 200
|
|
@@ -1925,13 +1369,7 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1925
1369
|
);
|
|
1926
1370
|
let encodedData = goodFundManager.interface.encodeFunctionData(
|
|
1927
1371
|
"setStakingReward",
|
|
1928
|
-
[
|
|
1929
|
-
"1000",
|
|
1930
|
-
simpleStaking.address,
|
|
1931
|
-
currentBlockNumber - 5,
|
|
1932
|
-
currentBlockNumber + 1000,
|
|
1933
|
-
false
|
|
1934
|
-
] // set 10 gd per block
|
|
1372
|
+
["1000", simpleStaking.address, currentBlockNumber - 5, currentBlockNumber + 1000, false] // set 10 gd per block
|
|
1935
1373
|
);
|
|
1936
1374
|
await genericCall(goodFundManager.address, encodedData);
|
|
1937
1375
|
const rewardsPerBlock = BN.from("1000");
|
|
@@ -1948,21 +1386,11 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1948
1386
|
const GDBalanceAfterWithdraw = await goodDollar.balanceOf(founder.address);
|
|
1949
1387
|
|
|
1950
1388
|
expect(GDBalanceAfterWithdraw).to.be.equal(
|
|
1951
|
-
GDBalanceAfterStake.add(
|
|
1952
|
-
rewardsPerBlock
|
|
1953
|
-
.mul(withdrawRewardsBlockNumber - stakeBlockNumber)
|
|
1954
|
-
.div(BN.from("2"))
|
|
1955
|
-
)
|
|
1389
|
+
GDBalanceAfterStake.add(rewardsPerBlock.mul(withdrawRewardsBlockNumber - stakeBlockNumber).div(BN.from("2")))
|
|
1956
1390
|
);
|
|
1957
1391
|
encodedData = goodFundManager.interface.encodeFunctionData(
|
|
1958
1392
|
"setStakingReward",
|
|
1959
|
-
[
|
|
1960
|
-
"1000",
|
|
1961
|
-
simpleStaking.address,
|
|
1962
|
-
currentBlockNumber - 5,
|
|
1963
|
-
currentBlockNumber + 1000,
|
|
1964
|
-
true
|
|
1965
|
-
] // set 10 gd per block
|
|
1393
|
+
["1000", simpleStaking.address, currentBlockNumber - 5, currentBlockNumber + 1000, true] // set 10 gd per block
|
|
1966
1394
|
);
|
|
1967
1395
|
await genericCall(goodFundManager.address, encodedData);
|
|
1968
1396
|
});
|
|
@@ -1981,70 +1409,37 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
1981
1409
|
);
|
|
1982
1410
|
let encodedData = goodFundManager.interface.encodeFunctionData(
|
|
1983
1411
|
"setStakingReward",
|
|
1984
|
-
[
|
|
1985
|
-
"1000",
|
|
1986
|
-
simpleStaking.address,
|
|
1987
|
-
currentBlockNumber - 5,
|
|
1988
|
-
currentBlockNumber + 1000,
|
|
1989
|
-
false
|
|
1990
|
-
] // set 10 gd per block
|
|
1991
|
-
);
|
|
1992
|
-
const overMintTestFactory = await ethers.getContractFactory(
|
|
1993
|
-
"OverMintTesterRegularStake"
|
|
1994
|
-
);
|
|
1995
|
-
const overMintTester = await overMintTestFactory.deploy(
|
|
1996
|
-
bat.address,
|
|
1997
|
-
simpleStaking.address,
|
|
1998
|
-
goodDollar.address
|
|
1412
|
+
["1000", simpleStaking.address, currentBlockNumber - 5, currentBlockNumber + 1000, false] // set 10 gd per block
|
|
1999
1413
|
);
|
|
1414
|
+
const overMintTestFactory = await ethers.getContractFactory("OverMintTesterRegularStake");
|
|
1415
|
+
const overMintTester = await overMintTestFactory.deploy(bat.address, simpleStaking.address, goodDollar.address);
|
|
2000
1416
|
await genericCall(goodFundManager.address, encodedData);
|
|
2001
1417
|
const stakingAmount = ethers.utils.parseEther("100");
|
|
2002
1418
|
await bat["mint(address,uint256)"](overMintTester.address, stakingAmount);
|
|
2003
1419
|
const rewardsPerBlock = BN.from("1000");
|
|
2004
1420
|
const stakeBlockNumber = (await ethers.provider.getBlockNumber()) + 1;
|
|
2005
1421
|
await overMintTester.stake();
|
|
2006
|
-
const GDBalanceAfterStake = await goodDollar.balanceOf(
|
|
2007
|
-
overMintTester.address
|
|
2008
|
-
);
|
|
1422
|
+
const GDBalanceAfterStake = await goodDollar.balanceOf(overMintTester.address);
|
|
2009
1423
|
await advanceBlocks(100);
|
|
2010
1424
|
await overMintTester.overMintTest();
|
|
2011
1425
|
const withdrawRewardsBlockNumber = await ethers.provider.getBlockNumber();
|
|
2012
|
-
const GDBalanceAfterWithdrawReward = await goodDollar.balanceOf(
|
|
2013
|
-
overMintTester.address
|
|
2014
|
-
);
|
|
1426
|
+
const GDBalanceAfterWithdrawReward = await goodDollar.balanceOf(overMintTester.address);
|
|
2015
1427
|
await advanceBlocks(20);
|
|
2016
1428
|
await overMintTester.overMintTest();
|
|
2017
|
-
const secondWithdrawRewardsBlockNumber =
|
|
2018
|
-
|
|
2019
|
-
const GDBalanceAfterSecondWithdrawReward = await goodDollar.balanceOf(
|
|
2020
|
-
overMintTester.address
|
|
2021
|
-
);
|
|
1429
|
+
const secondWithdrawRewardsBlockNumber = await ethers.provider.getBlockNumber();
|
|
1430
|
+
const GDBalanceAfterSecondWithdrawReward = await goodDollar.balanceOf(overMintTester.address);
|
|
2022
1431
|
|
|
2023
1432
|
expect(GDBalanceAfterWithdrawReward).to.be.gt(GDBalanceAfterStake);
|
|
2024
1433
|
expect(GDBalanceAfterWithdrawReward.sub(GDBalanceAfterStake)).to.be.equal(
|
|
2025
|
-
rewardsPerBlock
|
|
2026
|
-
.mul(withdrawRewardsBlockNumber - stakeBlockNumber)
|
|
2027
|
-
.div(BN.from("2"))
|
|
2028
|
-
);
|
|
2029
|
-
expect(GDBalanceAfterSecondWithdrawReward).to.be.gt(
|
|
2030
|
-
GDBalanceAfterWithdrawReward
|
|
1434
|
+
rewardsPerBlock.mul(withdrawRewardsBlockNumber - stakeBlockNumber).div(BN.from("2"))
|
|
2031
1435
|
);
|
|
2032
|
-
expect(
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
rewardsPerBlock
|
|
2036
|
-
.mul(secondWithdrawRewardsBlockNumber - withdrawRewardsBlockNumber)
|
|
2037
|
-
.div(BN.from("2"))
|
|
1436
|
+
expect(GDBalanceAfterSecondWithdrawReward).to.be.gt(GDBalanceAfterWithdrawReward);
|
|
1437
|
+
expect(GDBalanceAfterSecondWithdrawReward.sub(GDBalanceAfterWithdrawReward)).to.be.equal(
|
|
1438
|
+
rewardsPerBlock.mul(secondWithdrawRewardsBlockNumber - withdrawRewardsBlockNumber).div(BN.from("2"))
|
|
2038
1439
|
);
|
|
2039
1440
|
encodedData = goodFundManager.interface.encodeFunctionData(
|
|
2040
1441
|
"setStakingReward",
|
|
2041
|
-
[
|
|
2042
|
-
"1000",
|
|
2043
|
-
simpleStaking.address,
|
|
2044
|
-
currentBlockNumber - 5,
|
|
2045
|
-
currentBlockNumber + 1000,
|
|
2046
|
-
true
|
|
2047
|
-
] // set 10 gd per block
|
|
1442
|
+
["1000", simpleStaking.address, currentBlockNumber - 5, currentBlockNumber + 1000, true] // set 10 gd per block
|
|
2048
1443
|
);
|
|
2049
1444
|
await genericCall(goodFundManager.address, encodedData);
|
|
2050
1445
|
});
|
|
@@ -2077,22 +1472,15 @@ describe("StakingRewards - staking with cDAI mocks and get Rewards in GoodDollar
|
|
|
2077
1472
|
await simpleStaking.stake(stakingAmount, "0", false);
|
|
2078
1473
|
let currentGains = await simpleStaking.currentGains(false, true);
|
|
2079
1474
|
expect(currentGains[4]).to.be.equal("0");
|
|
2080
|
-
await comp["mint(address,uint256)"](
|
|
2081
|
-
simpleStaking.address,
|
|
2082
|
-
ethers.utils.parseEther("10")
|
|
2083
|
-
);
|
|
1475
|
+
await comp["mint(address,uint256)"](simpleStaking.address, ethers.utils.parseEther("10"));
|
|
2084
1476
|
currentGains = await simpleStaking.currentGains(false, true);
|
|
2085
1477
|
const compPriceInDollar = await compUsdOracle.latestAnswer();
|
|
2086
|
-
expect(currentGains[4]).to.be.equal(
|
|
2087
|
-
BigNumber.from("10").mul(compPriceInDollar)
|
|
2088
|
-
);
|
|
1478
|
+
expect(currentGains[4]).to.be.equal(BigNumber.from("10").mul(compPriceInDollar));
|
|
2089
1479
|
if (increasePriceOfCtoken) {
|
|
2090
1480
|
await cToken.increasePriceWithMultiplier("1000");
|
|
2091
1481
|
}
|
|
2092
1482
|
|
|
2093
|
-
const contractAddressesToBeCollected = await goodFundManager
|
|
2094
|
-
.connect(staker)
|
|
2095
|
-
.calcSortedContracts();
|
|
1483
|
+
const contractAddressesToBeCollected = await goodFundManager.connect(staker).calcSortedContracts();
|
|
2096
1484
|
const addressesToCollect = contractAddressesToBeCollected.map(x => x[0]);
|
|
2097
1485
|
await goodFundManager.collectInterest(addressesToCollect, false);
|
|
2098
1486
|
return { simpleStaking };
|