@gooddollar/goodprotocol 1.0.28 → 1.0.29-beta.1
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/BulkProof.min.json +1 -1
- package/artifacts/abis/DistributionBridgeMock.min.json +1 -0
- package/artifacts/abis/DistributionHelper.min.json +1 -0
- package/artifacts/abis/DistributionHelperTest.min.json +1 -0
- package/artifacts/abis/DistributionHelperTestHelper.min.json +1 -0
- package/artifacts/abis/ERC20.min.json +1 -1
- package/artifacts/abis/GoodDollarMintBurnWrapper.min.json +1 -0
- package/artifacts/abis/GoodDollarStaking.min.json +1 -0
- package/artifacts/abis/GoodDollarStakingMock.min.json +1 -0
- package/artifacts/abis/GoodReserveCDai.min.json +1 -1
- package/artifacts/abis/IERC2917.min.json +1 -1
- package/artifacts/abis/IGoodDollarStakingTest.min.json +1 -0
- package/artifacts/abis/IMultichainRouter.min.json +1 -0
- package/artifacts/abis/IRouter.min.json +1 -0
- package/artifacts/abis/IWrapper.min.json +1 -0
- package/artifacts/abis/Math64x64.min.json +1 -0
- package/artifacts/abis/MultichainBridgeHelper.min.json +1 -0
- package/artifacts/abis/MultichainRouterMock.min.json +1 -0
- package/artifacts/abis/OverMintTester.min.json +1 -1
- package/artifacts/abis/PausableControl.min.json +1 -0
- package/artifacts/abis/RewardsMinter.min.json +1 -0
- package/artifacts/abis/StakingMockFixedAPY.min.json +1 -0
- package/artifacts/abis/StakingRewardsFixedAPY.min.json +1 -0
- package/artifacts/abis/TokenOperation.min.json +1 -0
- package/artifacts/abis/cERC20.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/ERC20.json +13 -0
- 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/IERC2917.json +13 -0
- package/artifacts/contracts/Interfaces.sol/IFirstClaimPool.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IGoodDollar.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IGoodStaking.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IHasRouter.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IIdentity.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/ILendingPool.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IMultichainRouter.dbg.json +4 -0
- package/artifacts/contracts/Interfaces.sol/IMultichainRouter.json +67 -0
- 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/Interfaces.sol/cERC20.json +13 -0
- package/artifacts/contracts/fuseFaucet/FuseFaucet.sol/FuseFaucet.dbg.json +1 -1
- package/artifacts/contracts/fuseFaucet/FuseFaucet.sol/FuseFaucet.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 +4 -0
- package/artifacts/contracts/governance/GoodDollarStaking.sol/GoodDollarStaking.json +1322 -0
- package/artifacts/contracts/governance/GoodDollarStaking.sol/RewardsMinter.dbg.json +4 -0
- package/artifacts/contracts/governance/GoodDollarStaking.sol/RewardsMinter.json +35 -0
- 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/invite/InvitesV1.sol/InvitesV1.dbg.json +1 -1
- package/artifacts/contracts/invite/InvitesV1.sol/InvitesV1.json +2 -2
- package/artifacts/contracts/mocks/AaveMock.sol/AaveMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/DAIMock.sol/DAIMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/DecimalsMock.sol/DecimalsMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/DistributionBridgeMock.sol/DistributionBridgeMock.dbg.json +4 -0
- package/artifacts/contracts/mocks/DistributionBridgeMock.sol/DistributionBridgeMock.json +152 -0
- package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTest.dbg.json +4 -0
- package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTest.json +662 -0
- package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTestHelper.dbg.json +4 -0
- package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTestHelper.json +680 -0
- package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.json +2 -2
- package/artifacts/contracts/mocks/GoodDollarStakingMock.sol/GoodDollarStakingMock.dbg.json +4 -0
- package/artifacts/contracts/mocks/GoodDollarStakingMock.sol/GoodDollarStakingMock.json +1322 -0
- 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/IncentiveControllerMock.sol/IncentiveControllerMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/LendingPoolMock.sol/LendingPoolMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/MultichainRouterMock.sol/IWrapper.dbg.json +4 -0
- package/artifacts/contracts/mocks/MultichainRouterMock.sol/IWrapper.json +59 -0
- package/artifacts/contracts/mocks/MultichainRouterMock.sol/MultichainRouterMock.dbg.json +4 -0
- package/artifacts/contracts/mocks/MultichainRouterMock.sol/MultichainRouterMock.json +81 -0
- package/artifacts/contracts/mocks/OverMintTester.sol/IGoodDollarStakingTest.dbg.json +4 -0
- package/artifacts/contracts/mocks/OverMintTester.sol/IGoodDollarStakingTest.json +49 -0
- package/artifacts/contracts/mocks/OverMintTester.sol/OverMintTester.dbg.json +1 -1
- package/artifacts/contracts/mocks/OverMintTester.sol/OverMintTester.json +4 -4
- package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.dbg.json +1 -1
- package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.json +2 -2
- package/artifacts/contracts/mocks/SixteenDecimalsTokenMock.sol/SixteenDecimalsTokenMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/StakingMockFixedAPY.sol/StakingMockFixedAPY.dbg.json +4 -0
- package/artifacts/contracts/mocks/StakingMockFixedAPY.sol/StakingMockFixedAPY.json +682 -0
- 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/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/cBATMock.sol/cBATMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cDAILowWorthMock.sol/cDAILowWorthMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cDAIMock.sol/cDAIMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cDAINonMintableMock.sol/cDAINonMintableMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cDecimalsMock.sol/cDecimalsMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cSDTMock.sol/cSDTMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cUSDCMock.sol/cUSDCMock.dbg.json +1 -1
- package/artifacts/contracts/reserve/DistributionHelper.sol/DistributionHelper.dbg.json +4 -0
- package/artifacts/contracts/reserve/DistributionHelper.sol/DistributionHelper.json +662 -0
- 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 +75 -35
- 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 +4 -0
- package/artifacts/contracts/staking/utils/Math64X64.sol/Math64x64.json +10 -0
- package/artifacts/contracts/staking/utils/StakingRewardsFixedAPY.sol/StakingRewardsFixedAPY.dbg.json +4 -0
- package/artifacts/contracts/staking/utils/StakingRewardsFixedAPY.sol/StakingRewardsFixedAPY.json +268 -0
- package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.dbg.json +1 -1
- package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.json +2 -2
- package/artifacts/contracts/utils/AdminWallet.sol/AdminWallet.dbg.json +1 -1
- package/artifacts/contracts/utils/AdminWallet.sol/AdminWallet.json +2 -2
- package/artifacts/contracts/utils/BancorFormula.sol/BancorFormula.dbg.json +1 -1
- package/artifacts/contracts/utils/BulkProof.sol/BulkProof.dbg.json +1 -1
- package/artifacts/contracts/utils/BulkProof.sol/BulkProof.json +3 -34
- 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/DataTypes.sol/DataTypes.dbg.json +1 -1
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/GoodDollarMintBurnWrapper.dbg.json +4 -0
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/GoodDollarMintBurnWrapper.json +1263 -0
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/IRouter.dbg.json +4 -0
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/IRouter.json +59 -0
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/PausableControl.dbg.json +4 -0
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/PausableControl.json +69 -0
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/TokenOperation.dbg.json +4 -0
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/TokenOperation.json +10 -0
- package/artifacts/contracts/utils/MultichainBridgeHelper.sol/MultichainBridgeHelper.dbg.json +4 -0
- package/artifacts/contracts/utils/MultichainBridgeHelper.sol/MultichainBridgeHelper.json +79 -0
- package/artifacts/contracts/utils/NameService.sol/NameService.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgrade.sol/OldMarketMaker.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgrade.sol/ProtocolUpgrade.dbg.json +1 -1
- package/artifacts/contracts/utils/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/ProxyFactory1967.dbg.json +1 -1
- package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.dbg.json +1 -1
- package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.json +2 -2
- package/contracts/Interfaces.sol +20 -0
- package/contracts/governance/GoodDollarStaking.sol +510 -0
- package/contracts/governance/MultiBaseGovernanceShareField.sol +1 -0
- package/contracts/mocks/DistributionBridgeMock.sol +50 -0
- package/contracts/mocks/DistributionHelperTest.sol +22 -0
- package/contracts/mocks/GoodDollarStakingMock.sol +24 -0
- package/contracts/mocks/MultichainRouterMock.sol +38 -0
- package/contracts/mocks/OverMintTester.sol +39 -25
- package/contracts/mocks/StakingMockFixedAPY.sol +78 -0
- package/contracts/reserve/DistributionHelper.sol +142 -0
- package/contracts/reserve/GoodReserveCDai.sol +95 -41
- package/contracts/staking/utils/Math64X64.sol +268 -0
- package/contracts/staking/utils/StakingRewardsFixedAPY.sol +336 -0
- package/contracts/utils/BulkProof.sol +10 -10
- package/contracts/utils/GoodDollarMintBurnWrapper.sol +638 -0
- package/contracts/utils/MultichainBridgeHelper.sol +39 -0
- package/hardhat.config.ts +5 -3
- package/package.json +7 -4
- package/patches/@openzeppelin+hardhat-upgrades+1.7.0.patch.depracate +67 -0
- package/releases/deployment.json +10 -3
- package/releases/olddao.json +1 -1
- package/scripts/analytics/activeUsersCount.ts +65 -0
- package/scripts/analytics/activeWalletsStats.ts +150 -0
- package/scripts/analytics/claimIncidentStats.ts +117 -0
- package/scripts/analytics/faucetStats.ts +103 -0
- package/scripts/analytics/goodHolders.ts +50 -0
- package/scripts/{misc → analytics}/goodgiveback.ts +0 -0
- package/scripts/governance/airdropCalculation.ts +1 -0
- package/scripts/multichain-deploy/basicdao-deploy.ts +20 -5
- package/scripts/multichain-deploy/gdSavings-deploy.ts +232 -0
- package/scripts/multichain-deploy/helpers.ts +73 -8
- package/scripts/multichain-deploy/multichainWrapper-deploy.ts +56 -0
- package/scripts/multichain-deploy/nonubiDistribution-deploy.ts +170 -0
- package/scripts/voltageswaps.ts +47 -0
- package/test/governance/ClaimersDistribution.test.ts +1 -1
- package/test/governance/GoodDollarStaking.gd.test.ts +559 -0
- package/test/governance/GoodDollarStaking.good.test.ts +998 -0
- package/test/governance/GovernanceStaking.test.ts +43 -0
- package/test/helpers.ts +9 -12
- package/test/reserve/DistributionHelper.test.ts +394 -0
- package/test/reserve/GoodReserveCDai.distribution.test.ts +296 -0
- package/test/reserve/GoodReserveCDai.gdx.test.ts +21 -16
- package/test/reserve/GoodReserveCDai.pause.test.ts +116 -0
- package/test/staking/StakingRewardsFixedAPY.test.ts +900 -0
- package/test/utils/AdminWallet.test.ts +35 -6
- package/test/utils/GoodDollarMintBurnWrapper.test.ts +796 -0
- package/tsconfig.json +4 -9
- package/types/AccessControl.ts +361 -0
- package/types/CERC20.ts +25 -0
- package/types/DistributionBridgeMock.ts +251 -0
- package/types/DistributionHelper.ts +908 -0
- package/types/DistributionHelperTest.ts +909 -0
- package/types/DistributionHelperTestHelper.ts +945 -0
- package/types/ERC165.ts +104 -0
- package/types/ERC20.ts +101 -49
- package/types/GoodDollarMintBurnWrapper.ts +1806 -0
- package/types/GoodDollarStaking.ts +1855 -0
- package/types/GoodDollarStakingMock.ts +1855 -0
- package/types/GoodReserveCDai.ts +90 -55
- package/types/IAccessControl.ts +306 -0
- package/types/IERC165.ts +104 -0
- package/types/IERC20.ts +300 -0
- package/types/IERC20Metadata.ts +339 -0
- package/types/IERC2917.ts +25 -0
- package/types/IGoodDollarStakingTest.ts +160 -0
- package/types/IMultichainRouter.ts +166 -0
- package/types/IRouter.ts +143 -0
- package/types/IWrapper.ts +143 -0
- package/types/MultichainBridgeHelper.ts +170 -0
- package/types/MultichainRouterMock.ts +141 -0
- package/types/Pausable.ts +103 -0
- package/types/PausableControl.ts +125 -0
- package/types/{BulkProof.ts → RewardsMinter.ts} +24 -28
- package/types/StakingMockFixedAPY.ts +995 -0
- package/types/StakingRewardsFixedAPY.ts +428 -0
- package/types/factories/AaveStakingFactory__factory.ts +1 -1
- package/types/factories/AccessControl__factory.ts +227 -0
- package/types/factories/AdminWallet__factory.ts +1 -1
- package/types/factories/BaseShareFieldV2__factory.ts +1 -1
- package/types/factories/BaseShareField__factory.ts +1 -1
- package/types/factories/CERC20__factory.ts +13 -0
- package/types/factories/ClaimersDistribution__factory.ts +1 -1
- package/types/factories/CompoundStakingFactory__factory.ts +1 -1
- package/types/factories/CompoundVotingMachine__factory.ts +1 -1
- package/types/factories/DAOContract__factory.ts +1 -1
- package/types/factories/DAOUpgradeableContract__factory.ts +1 -1
- package/types/factories/DistributionBridgeMock__factory.ts +207 -0
- package/types/factories/DistributionHelperTestHelper__factory.ts +737 -0
- package/types/factories/DistributionHelperTest__factory.ts +717 -0
- package/types/factories/DistributionHelper__factory.ts +713 -0
- package/types/factories/DonationsStaking__factory.ts +1 -1
- package/types/factories/ERC165__factory.ts +39 -0
- package/types/factories/ERC20__factory.ts +13 -0
- package/types/factories/ExchangeHelper__factory.ts +1 -1
- package/types/factories/FuseFaucet__factory.ts +1 -1
- package/types/factories/FuseStakingV3__factory.ts +1 -1
- package/types/factories/GReputation__factory.ts +1 -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 +1318 -0
- package/types/factories/GoodDollarStakingMock__factory.ts +1404 -0
- package/types/factories/GoodDollarStaking__factory.ts +1400 -0
- 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 +74 -34
- package/types/factories/GovernanceStaking__factory.ts +1 -1
- package/types/factories/IAccessControl__factory.ts +198 -0
- package/types/factories/IERC165__factory.ts +42 -0
- package/types/factories/IERC20Metadata__factory.ts +248 -0
- package/types/factories/IERC20__factory.ts +203 -0
- package/types/factories/IERC2917__factory.ts +13 -0
- package/types/factories/IGoodDollarStakingTest__factory.ts +68 -0
- package/types/factories/IMultichainRouter__factory.ts +82 -0
- package/types/factories/IRouter__factory.ts +71 -0
- package/types/factories/IWrapper__factory.ts +71 -0
- package/types/factories/InvitesV1__factory.ts +1 -1
- package/types/factories/MultichainBridgeHelper__factory.ts +134 -0
- package/types/factories/MultichainRouterMock__factory.ts +141 -0
- package/types/factories/OverMintTesterRegularStake__factory.ts +1 -1
- package/types/factories/OverMintTester__factory.ts +3 -3
- package/types/factories/PausableControl__factory.ts +84 -0
- package/types/factories/Pausable__factory.ts +62 -0
- 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/ReputationTestHelper__factory.ts +1 -1
- package/types/factories/Reputation__factory.ts +1 -1
- package/types/factories/RewardsMinter__factory.ts +47 -0
- package/types/factories/StakersDistribution__factory.ts +1 -1
- package/types/factories/StakingMockFixedAPY__factory.ts +745 -0
- package/types/factories/StakingRewardsFixedAPY__factory.ts +287 -0
- package/types/factories/SwapHelperTest__factory.ts +1 -1
- package/types/factories/UBIScheme__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 +225 -9
- package/types/index.ts +50 -4
- package/yarn.lock +180 -104
- package/types/factories/BulkProof__factory.ts +0 -89
|
@@ -0,0 +1,510 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity >=0.8.0;
|
|
4
|
+
|
|
5
|
+
import { ERC20 as ERC20_OZ } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
|
6
|
+
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
|
|
7
|
+
import "@openzeppelin/contracts/security/Pausable.sol";
|
|
8
|
+
import "@openzeppelin/contracts/access/AccessControl.sol";
|
|
9
|
+
import "../utils/DAOContract.sol";
|
|
10
|
+
import "../utils/NameService.sol";
|
|
11
|
+
import "../Interfaces.sol";
|
|
12
|
+
import "../DAOStackInterfaces.sol";
|
|
13
|
+
import "./MultiBaseGovernanceShareField.sol";
|
|
14
|
+
import "../staking/utils/StakingRewardsFixedAPY.sol";
|
|
15
|
+
|
|
16
|
+
interface RewardsMinter {
|
|
17
|
+
function sendOrMint(address to, uint256 amount) external returns (uint256);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @title Staking contract that allows citizens to stake G$ to get GOOD + G$ rewards
|
|
22
|
+
* it implements
|
|
23
|
+
*/
|
|
24
|
+
contract GoodDollarStaking is
|
|
25
|
+
ERC20_OZ,
|
|
26
|
+
MultiBaseGovernanceShareField,
|
|
27
|
+
DAOContract,
|
|
28
|
+
ReentrancyGuard,
|
|
29
|
+
Pausable,
|
|
30
|
+
StakingRewardsFixedAPY
|
|
31
|
+
{
|
|
32
|
+
// Token address
|
|
33
|
+
ERC20 public token;
|
|
34
|
+
|
|
35
|
+
uint128 public numberOfBlocksPerYear; //required for getChainBlocksPerMonth for GOOD rewards calculations
|
|
36
|
+
|
|
37
|
+
uint128 public createdAt; //required for upgrade process
|
|
38
|
+
uint32 public daysUntilUpgrade; //required for upgrade process
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @dev Emitted when `staker` earns an `amount` of GOOD tokens
|
|
42
|
+
*/
|
|
43
|
+
event ReputationEarned(address indexed staker, uint256 amount);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @dev Emitted when `staker` stakes an `amount` of GoodDollars
|
|
47
|
+
*/
|
|
48
|
+
event Staked(address indexed staker, uint256 amount);
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @dev Emitted when `staker` withdraws an `amount` of staked GoodDollars
|
|
52
|
+
*/
|
|
53
|
+
event StakeWithdraw(
|
|
54
|
+
address indexed staker,
|
|
55
|
+
uint256 actualSharesRedeemed, //shares withdrawn , if not all rewards minted then this can be lower than sharesRequested
|
|
56
|
+
uint256 amount, //amount withdrawn including actualRewardsSent
|
|
57
|
+
uint256 sharesRequested, //shares requested to redeem
|
|
58
|
+
uint256 goodRewards,
|
|
59
|
+
uint256 gdRewards,
|
|
60
|
+
uint256 actualRewardsSent //maybe rewards could not be minted
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @dev Emitted when `staker` withdraws but MintBurnWrapper could not allocate/mint the rewards
|
|
65
|
+
*/
|
|
66
|
+
event RewardsNotSent(
|
|
67
|
+
address indexed staker,
|
|
68
|
+
uint256 gdRewards,
|
|
69
|
+
uint256 actualRewardsSent //rewards not minted
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
event APYSet(uint128 newAPY);
|
|
73
|
+
|
|
74
|
+
event GOODRewardsSet(uint256 newMonthlyRewards);
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @dev Constructor
|
|
78
|
+
* @param _ns The address of the INameService contract
|
|
79
|
+
* @param _interestRatePerBlock G$ rewards fixed APY in 1e18 precision
|
|
80
|
+
* @param _numberOfBlocksPerYear blockchain approx blocks per year for GOOD rewards
|
|
81
|
+
* @param _daysUntilUpgrade when it is allowed to upgrade from older GovernanceStaking
|
|
82
|
+
*/
|
|
83
|
+
constructor(
|
|
84
|
+
INameService _ns,
|
|
85
|
+
uint128 _interestRatePerBlock,
|
|
86
|
+
uint128 _numberOfBlocksPerYear,
|
|
87
|
+
uint32 _daysUntilUpgrade
|
|
88
|
+
) ERC20_OZ("G$ Savings", "svG$") {
|
|
89
|
+
require(_daysUntilUpgrade <= 60, "max two months until upgrade");
|
|
90
|
+
_setAPY(_interestRatePerBlock);
|
|
91
|
+
setDAO(_ns);
|
|
92
|
+
numberOfBlocksPerYear = _numberOfBlocksPerYear;
|
|
93
|
+
token = ERC20(nameService.getAddress("GOODDOLLAR"));
|
|
94
|
+
rewardsPerBlock[address(this)] = 0;
|
|
95
|
+
createdAt = uint128(block.timestamp);
|
|
96
|
+
daysUntilUpgrade = _daysUntilUpgrade;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @notice return approx chain blocks per month
|
|
101
|
+
* @return blocksPerMonth approx blocks per month
|
|
102
|
+
*/
|
|
103
|
+
function getChainBlocksPerMonth()
|
|
104
|
+
public
|
|
105
|
+
view
|
|
106
|
+
override
|
|
107
|
+
returns (uint256 blocksPerMonth)
|
|
108
|
+
{
|
|
109
|
+
return numberOfBlocksPerYear / 12;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @dev Allows a staker to deposit Tokens. Notice that `approve` is
|
|
114
|
+
* needed to be executed before the execution of this method.
|
|
115
|
+
* Can be executed only when the contract is not paused.
|
|
116
|
+
* @param _amount The amount of GD to stake
|
|
117
|
+
*/
|
|
118
|
+
function stake(uint256 _amount) external {
|
|
119
|
+
require(
|
|
120
|
+
token.transferFrom(msg.sender, address(this), _amount),
|
|
121
|
+
"transferFrom failed, make sure you approved token transfer"
|
|
122
|
+
);
|
|
123
|
+
_stakeFrom(msg.sender, _amount);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @dev helper for staking
|
|
128
|
+
* @param _from address of staker
|
|
129
|
+
* @param _amount The amount of GD to stake
|
|
130
|
+
*/
|
|
131
|
+
function _stakeFrom(address _from, uint256 _amount) internal whenNotPaused {
|
|
132
|
+
/* G$ rewards updates */
|
|
133
|
+
uint256 shares = _stake(_from, _amount); //this will validate _amount
|
|
134
|
+
_mint(_from, shares); // mint Staking token for staker
|
|
135
|
+
|
|
136
|
+
/* GOOD rewards Updates */
|
|
137
|
+
_increaseProductivity(address(this), _from, shares, 0, block.number);
|
|
138
|
+
_mintGOODRewards(_from);
|
|
139
|
+
/* end GOOD rewards Updates */
|
|
140
|
+
|
|
141
|
+
emit Staked(_from, _amount);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @notice helper for staking through G$ transferAndCall without approve
|
|
146
|
+
* @param _from address of sender
|
|
147
|
+
* @param _amount The amount of GD to stake
|
|
148
|
+
*/
|
|
149
|
+
function onTokenTransfer(
|
|
150
|
+
address _from,
|
|
151
|
+
uint256 _amount,
|
|
152
|
+
bytes calldata
|
|
153
|
+
) external returns (bool success) {
|
|
154
|
+
require(msg.sender == address(token), "unsupported token");
|
|
155
|
+
|
|
156
|
+
_stakeFrom(_from, _amount);
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* @notice Withdraws _amount from the staker principle
|
|
162
|
+
* in _withdraw we use getPrinciple and not getProductivity because the user can have more G$ to withdraw than he staked
|
|
163
|
+
* @param _shares amount to withdraw
|
|
164
|
+
* @return goodRewards how much GOOD rewards were transfered to staker
|
|
165
|
+
* @return gdRewards out of withdrawn amount how much was taken from earned interest (amount-gdRewards = taken from deposit)
|
|
166
|
+
*/
|
|
167
|
+
function withdrawStake(uint256 _shares)
|
|
168
|
+
public
|
|
169
|
+
nonReentrant
|
|
170
|
+
returns (uint256 goodRewards, uint256 gdRewards)
|
|
171
|
+
{
|
|
172
|
+
uint256 depositComponent;
|
|
173
|
+
|
|
174
|
+
//in case amount is 0 this will just withdraw the GOOD rewards, this is required for withdrawRewards
|
|
175
|
+
uint256 originalBalance = sharesOf(msg.sender);
|
|
176
|
+
if (_shares > 0) {
|
|
177
|
+
/* G$ rewards update */
|
|
178
|
+
//we get the relative part user is withdrawing from his original deposit, his principle is composed of deposit+earned interest
|
|
179
|
+
(depositComponent, gdRewards) = _withdraw(msg.sender, _shares);
|
|
180
|
+
/* Good rewards update */
|
|
181
|
+
_decreaseProductivity(
|
|
182
|
+
address(this),
|
|
183
|
+
msg.sender,
|
|
184
|
+
_shares,
|
|
185
|
+
0,
|
|
186
|
+
block.number
|
|
187
|
+
);
|
|
188
|
+
_burn(msg.sender, _shares); // burn their staking tokens
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// console.log(
|
|
192
|
+
// "withdraStake: fromDeposit: %s, fromRewards: %s",
|
|
193
|
+
// depositComponent,
|
|
194
|
+
// gdRewards
|
|
195
|
+
// );
|
|
196
|
+
|
|
197
|
+
goodRewards = _mintGOODRewards(msg.sender);
|
|
198
|
+
|
|
199
|
+
//rewards are paid via the rewards distribution contract
|
|
200
|
+
uint256 actualRewardsSent;
|
|
201
|
+
if (gdRewards > 0) {
|
|
202
|
+
actualRewardsSent = _mintGDRewards(msg.sender, gdRewards);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
uint256 actualSharesRedeemed = originalBalance - sharesOf(msg.sender);
|
|
206
|
+
|
|
207
|
+
//stake is withdrawn from original deposit sent to this contract
|
|
208
|
+
if (depositComponent > 0) {
|
|
209
|
+
require(
|
|
210
|
+
token.transfer(msg.sender, depositComponent),
|
|
211
|
+
"withdraw transfer failed"
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
emit StakeWithdraw(
|
|
215
|
+
msg.sender,
|
|
216
|
+
actualSharesRedeemed,
|
|
217
|
+
depositComponent + actualRewardsSent,
|
|
218
|
+
_shares,
|
|
219
|
+
goodRewards,
|
|
220
|
+
gdRewards,
|
|
221
|
+
actualRewardsSent
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* @notice helper to mint/send G$ rewards from fixed APY
|
|
227
|
+
* @param _to address of recipient
|
|
228
|
+
* @param _amount how much to mint/send
|
|
229
|
+
* @return actualSent how much rewards were actually minted/sent. If RewardsMinter is passed its limit it could be that not all requested amount was awarded.
|
|
230
|
+
*/
|
|
231
|
+
function _mintGDRewards(address _to, uint256 _amount)
|
|
232
|
+
internal
|
|
233
|
+
returns (uint256 actualSent)
|
|
234
|
+
{
|
|
235
|
+
//make sure RewardsMinter failure doesnt prevent withdrawl of stake
|
|
236
|
+
//console.log("_mintGDRewards: sending amount: %s to: %s", _amount, _to);
|
|
237
|
+
address minter = nameService.getAddress("MINTBURN_WRAPPER");
|
|
238
|
+
if (minter != address(0)) {
|
|
239
|
+
try
|
|
240
|
+
RewardsMinter(nameService.getAddress("MINTBURN_WRAPPER")).sendOrMint(
|
|
241
|
+
_to,
|
|
242
|
+
_amount
|
|
243
|
+
)
|
|
244
|
+
returns (uint256 _res) {
|
|
245
|
+
//console.log("sendOrMint result: %s", _res);
|
|
246
|
+
actualSent = _res;
|
|
247
|
+
} catch {
|
|
248
|
+
//console.log("sendOrMint threw an error");
|
|
249
|
+
actualSent = 0;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
//it could be that rewards minter doesnt have enough or passed cap
|
|
254
|
+
//so we keep track of debt to user
|
|
255
|
+
if (actualSent < _amount) {
|
|
256
|
+
// console.log(
|
|
257
|
+
// "Actually sent: %s, will undo %s",
|
|
258
|
+
// actualSent,
|
|
259
|
+
// _amount - actualSent
|
|
260
|
+
// );
|
|
261
|
+
uint256 shares = _undoReward(_to, _amount - actualSent);
|
|
262
|
+
_increaseProductivity(address(this), _to, shares, 0, block.number); //increase productivity back for GOOD rewards
|
|
263
|
+
_mint(_to, shares); //mint shares worth of undone rewards
|
|
264
|
+
emit RewardsNotSent(_to, _amount, actualSent);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* @dev Stakers can withdraw their rewards without withdrawing their stake
|
|
270
|
+
* @return goodRewards recieved GOOD rewards
|
|
271
|
+
* @return gdRewards recieved G$ rewards
|
|
272
|
+
*/
|
|
273
|
+
function withdrawRewards()
|
|
274
|
+
public
|
|
275
|
+
returns (uint256 goodRewards, uint256 gdRewards)
|
|
276
|
+
{
|
|
277
|
+
uint256 gdRewardsShares = amountToShares(earned(msg.sender));
|
|
278
|
+
|
|
279
|
+
//this will trigger a withdraw only of rewards part
|
|
280
|
+
return withdrawStake(gdRewardsShares);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* @dev Mint GOOD rewards of the staker
|
|
285
|
+
* @param user Receipent address of the rewards
|
|
286
|
+
* @return amount of the minted rewards
|
|
287
|
+
* emits 'ReputationEarned' event for staker earned GOOD amount
|
|
288
|
+
*/
|
|
289
|
+
function _mintGOODRewards(address user) internal returns (uint256 amount) {
|
|
290
|
+
//try to mint only if have minter permission, so user can always withdraw his funds without this reverting
|
|
291
|
+
if (
|
|
292
|
+
nameService.getAddress("GDAO_STAKING") == address(this) ||
|
|
293
|
+
AccessControl(nameService.getAddress("REPUTATION")).hasRole(
|
|
294
|
+
keccak256("MINTER_ROLE"),
|
|
295
|
+
address(this)
|
|
296
|
+
)
|
|
297
|
+
) {
|
|
298
|
+
amount = _issueEarnedRewards(address(this), user, 0, block.number);
|
|
299
|
+
if (amount > 0) {
|
|
300
|
+
ERC20(nameService.getAddress("REPUTATION")).mint(user, amount);
|
|
301
|
+
emit ReputationEarned(msg.sender, amount);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return amount;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* @dev Returns the number of decimals used for the staking reciept token precision
|
|
309
|
+
*/
|
|
310
|
+
function decimals() public view virtual override returns (uint8) {
|
|
311
|
+
return 18; //SHARE_PERCISION
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function sharesOf(address _account)
|
|
315
|
+
public
|
|
316
|
+
view
|
|
317
|
+
virtual
|
|
318
|
+
override
|
|
319
|
+
returns (uint256)
|
|
320
|
+
{
|
|
321
|
+
return balanceOf(_account);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function sharesSupply() public view virtual override returns (uint256) {
|
|
325
|
+
return totalSupply();
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* @dev override _transfer to handle rewards calculations when transfer the stake
|
|
330
|
+
* @notice transfer may fail if value < sharePrice()
|
|
331
|
+
*/
|
|
332
|
+
function _transfer(
|
|
333
|
+
address from,
|
|
334
|
+
address to,
|
|
335
|
+
uint256 shares
|
|
336
|
+
) internal override {
|
|
337
|
+
_decreaseProductivity(address(this), from, shares, 0, block.number);
|
|
338
|
+
//the recipient sent G$ are considered like he is staking them, so they will also earn GOOD rewards
|
|
339
|
+
_increaseProductivity(address(this), to, shares, 0, block.number);
|
|
340
|
+
|
|
341
|
+
//recipient inherits the rewards part also, this is important so deposit part is sent from contract balance and rewards from rewards contract
|
|
342
|
+
uint256 recipientShares = balanceOf(to);
|
|
343
|
+
stakersInfo[to].lastSharePrice = uint128(
|
|
344
|
+
((stakersInfo[to].lastSharePrice * recipientShares) +
|
|
345
|
+
(stakersInfo[from].lastSharePrice * shares)) /
|
|
346
|
+
(recipientShares + shares)
|
|
347
|
+
);
|
|
348
|
+
|
|
349
|
+
//mint GOOD rewards
|
|
350
|
+
_mintGOODRewards(from);
|
|
351
|
+
_mintGOODRewards(to);
|
|
352
|
+
|
|
353
|
+
super._transfer(from, to, shares);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* @dev Calculate rewards per block from monthly amount of rewards and set it
|
|
358
|
+
* @param _monthlyAmount total rewards which will distribute monthly
|
|
359
|
+
*/
|
|
360
|
+
function setMonthlyGOODRewards(uint256 _monthlyAmount) external {
|
|
361
|
+
_onlyAvatar();
|
|
362
|
+
_setMonthlyRewards(address(this), _monthlyAmount);
|
|
363
|
+
emit GOODRewardsSet(_monthlyAmount);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* @dev interest rate per one block in 1e18 precision.
|
|
368
|
+
* for example APY=5% then per block = nroot(1+0.05,numberOfBlocksPerYear)
|
|
369
|
+
* nroot(1.05,6000000) = 1.000000008131694
|
|
370
|
+
* in 1e18 = 1000000008131694000
|
|
371
|
+
* @param _interestRatePerBlock nth blocks per year root of APY - nroot(1+0.05,numberOfBlocksPerYear)
|
|
372
|
+
*/
|
|
373
|
+
function setGdApy(uint128 _interestRatePerBlock) public {
|
|
374
|
+
_onlyAvatar();
|
|
375
|
+
_setAPY(_interestRatePerBlock);
|
|
376
|
+
require(
|
|
377
|
+
Math64x64.mulu(
|
|
378
|
+
Math64x64.pow(interestRatePerBlockX64, numberOfBlocksPerYear),
|
|
379
|
+
1e4
|
|
380
|
+
) < 12000
|
|
381
|
+
);
|
|
382
|
+
|
|
383
|
+
emit APYSet(_interestRatePerBlock);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* @dev returns both GOOD and G$ rewards rate
|
|
388
|
+
* @return _goodRewardPerBlock GOOD nominal reward rate per block
|
|
389
|
+
* @return _gdInterestRatePerBlock the G$ interest rate per block in 1e18 precision
|
|
390
|
+
*/
|
|
391
|
+
function getRewardsPerBlock()
|
|
392
|
+
external
|
|
393
|
+
view
|
|
394
|
+
returns (uint256 _goodRewardPerBlock, uint256 _gdInterestRatePerBlock)
|
|
395
|
+
{
|
|
396
|
+
_goodRewardPerBlock = rewardsPerBlock[address(this)];
|
|
397
|
+
_gdInterestRatePerBlock = Math64x64.mulu(interestRatePerBlockX64, 1e18);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* @dev returns the user original deposit amount as registered in MultiBaseShare. should equal stakersInfo.deposit
|
|
402
|
+
* @return userStake user deposit amount
|
|
403
|
+
* @return totalStaked total deposits
|
|
404
|
+
*/
|
|
405
|
+
function getStaked(address _user)
|
|
406
|
+
external
|
|
407
|
+
view
|
|
408
|
+
returns (uint256 userStake, uint256 totalStaked)
|
|
409
|
+
{
|
|
410
|
+
return getProductivity(address(this), _user);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* @dev returns user pending GOOD and G$ rewards
|
|
415
|
+
* @return goodReward GOOD nominal rewards pending
|
|
416
|
+
* @return gdReward the G$ nominal rewards earned from interest rate
|
|
417
|
+
*/
|
|
418
|
+
function getUserPendingReward(address _user)
|
|
419
|
+
external
|
|
420
|
+
view
|
|
421
|
+
returns (uint256 goodReward, uint256 gdReward)
|
|
422
|
+
{
|
|
423
|
+
// GOOD rewards
|
|
424
|
+
goodReward = getUserPendingReward(address(this), 0, block.number, _user);
|
|
425
|
+
|
|
426
|
+
gdReward = earned(_user);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* @dev returns accumulated rewards per share
|
|
431
|
+
* @return _goodRewardPerShare GOOD accumulated rewards
|
|
432
|
+
* @return _gdRewardPerShare G$ accumulated rewards
|
|
433
|
+
*/
|
|
434
|
+
function totalRewardsPerShare()
|
|
435
|
+
external
|
|
436
|
+
view
|
|
437
|
+
returns (uint256 _goodRewardPerShare, uint256 _gdRewardPerShare)
|
|
438
|
+
{
|
|
439
|
+
_goodRewardPerShare = super.totalRewardsPerShare(address(this));
|
|
440
|
+
|
|
441
|
+
_gdRewardPerShare = totalSupply() == 0
|
|
442
|
+
? 0
|
|
443
|
+
: ((_compound() - stats.totalStaked * PRECISION) * SHARE_PRECISION) /
|
|
444
|
+
(totalSupply() * PRECISION);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/// @dev helper function for multibase
|
|
448
|
+
/// @return userInfo staker info related to GOOD rewards
|
|
449
|
+
function goodStakerInfo(address _user)
|
|
450
|
+
external
|
|
451
|
+
view
|
|
452
|
+
returns (UserInfo memory userInfo)
|
|
453
|
+
{
|
|
454
|
+
return contractToUsers[address(this)][_user];
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/// @notice after 1 month move GOOD permissions minting to this contract from previous GovernanceStaking
|
|
458
|
+
function upgrade() external virtual {
|
|
459
|
+
require(
|
|
460
|
+
block.timestamp > createdAt + (daysUntilUpgrade * 1 days) &&
|
|
461
|
+
dao.isSchemeRegistered(address(this), avatar),
|
|
462
|
+
"not deadline or not scheme"
|
|
463
|
+
);
|
|
464
|
+
_setMonthlyRewards(address(this), 2 ether * 1e6); //2M monthly GOOD
|
|
465
|
+
emit GOODRewardsSet(2 ether * 1e6);
|
|
466
|
+
|
|
467
|
+
//this will make sure rewards are set at 0, so no withdraw issue will happen.
|
|
468
|
+
//on governacnestaking anyone withdrawing from now on will get 0 GOOD, not matter how long he has been staking
|
|
469
|
+
(bool ok, ) = dao.genericCall(
|
|
470
|
+
nameService.getAddress("GDAO_STAKING"),
|
|
471
|
+
abi.encodeWithSignature("setMonthlyRewards(uint256)", 0),
|
|
472
|
+
avatar,
|
|
473
|
+
0
|
|
474
|
+
);
|
|
475
|
+
require(ok, "calling setMonthlyRewards failed");
|
|
476
|
+
|
|
477
|
+
//this will set this contract as the GDAO_STAKING contract and give us minting rights on the reputation token
|
|
478
|
+
(ok, ) = dao.genericCall(
|
|
479
|
+
address(nameService),
|
|
480
|
+
abi.encodeWithSignature(
|
|
481
|
+
"setAddress(string,address)",
|
|
482
|
+
"GDAO_STAKING",
|
|
483
|
+
address(this)
|
|
484
|
+
),
|
|
485
|
+
avatar,
|
|
486
|
+
0
|
|
487
|
+
);
|
|
488
|
+
require(ok, "calling setAddress failed");
|
|
489
|
+
dao.unregisterSelf(avatar); // make sure we cant call this again;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* @dev Pause staking and also set APY, usually when paused we want the APY to be 0
|
|
494
|
+
* updateReward is called to accrue interest until pause event
|
|
495
|
+
* @param _paused whether to pause on unpause
|
|
496
|
+
* @param _interestRatePerBlock the interest rate to set when pausing/unpausing (see setGdApy)
|
|
497
|
+
*/
|
|
498
|
+
function pause(bool _paused, uint128 _interestRatePerBlock)
|
|
499
|
+
external
|
|
500
|
+
updateReward
|
|
501
|
+
{
|
|
502
|
+
_onlyAvatar();
|
|
503
|
+
if (_paused) {
|
|
504
|
+
_pause();
|
|
505
|
+
} else {
|
|
506
|
+
_unpause();
|
|
507
|
+
}
|
|
508
|
+
setGdApy(_interestRatePerBlock);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
@@ -39,6 +39,7 @@ abstract contract MultiBaseGovernanceShareField is DSMath {
|
|
|
39
39
|
function _setMonthlyRewards(address _contract, uint256 _monthlyAmount)
|
|
40
40
|
internal
|
|
41
41
|
{
|
|
42
|
+
_update(_contract, 0, block.number); //we need to accrue rewards before we change the rewards rate
|
|
42
43
|
rewardsPerBlock[_contract] = _monthlyAmount / getChainBlocksPerMonth();
|
|
43
44
|
}
|
|
44
45
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity ^0.8;
|
|
4
|
+
|
|
5
|
+
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
6
|
+
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
|
7
|
+
import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol";
|
|
8
|
+
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
|
9
|
+
import "@openzeppelin/contracts/utils/math/Math.sol";
|
|
10
|
+
|
|
11
|
+
import "../utils/DAOUpgradeableContract.sol";
|
|
12
|
+
|
|
13
|
+
import "hardhat/console.sol";
|
|
14
|
+
|
|
15
|
+
contract DistributionBridgeMock {
|
|
16
|
+
event AnySwap(
|
|
17
|
+
address token,
|
|
18
|
+
address recipient,
|
|
19
|
+
uint256 amount,
|
|
20
|
+
uint256 chainId
|
|
21
|
+
);
|
|
22
|
+
event OnToken(address sender, uint256 amount, bytes data);
|
|
23
|
+
|
|
24
|
+
function anySwapOut(
|
|
25
|
+
address token,
|
|
26
|
+
address recipient,
|
|
27
|
+
uint256 amount,
|
|
28
|
+
uint256 chainId
|
|
29
|
+
) external {
|
|
30
|
+
emit AnySwap(token, recipient, amount, chainId);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function anySwapOutUnderlying(
|
|
34
|
+
address token,
|
|
35
|
+
address recipient,
|
|
36
|
+
uint256 amount,
|
|
37
|
+
uint256 chainId
|
|
38
|
+
) external {
|
|
39
|
+
emit AnySwap(token, recipient, amount, chainId);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function onTokenTransfer(
|
|
43
|
+
address sender,
|
|
44
|
+
uint256 amount,
|
|
45
|
+
bytes memory data
|
|
46
|
+
) external returns (bool) {
|
|
47
|
+
emit OnToken(sender, amount, data);
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
pragma solidity >=0.8;
|
|
2
|
+
|
|
3
|
+
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
4
|
+
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
|
5
|
+
import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol";
|
|
6
|
+
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
|
7
|
+
import "@openzeppelin/contracts/utils/math/Math.sol";
|
|
8
|
+
|
|
9
|
+
import "../reserve/DistributionHelper.sol";
|
|
10
|
+
|
|
11
|
+
contract DistributionHelperTest is DistributionHelper {
|
|
12
|
+
function onDistribution(uint256 _amount) external override {
|
|
13
|
+
revert();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
contract DistributionHelperTestHelper is DistributionHelper {
|
|
18
|
+
function setBridges(address _fuseBridge, address _multiBridge) external {
|
|
19
|
+
fuseBridge = _fuseBridge;
|
|
20
|
+
multiChainBridge = IMultichainRouter(_multiBridge);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity >=0.8.0;
|
|
3
|
+
|
|
4
|
+
import "../governance/GoodDollarStaking.sol";
|
|
5
|
+
|
|
6
|
+
contract GoodDollarStakingMock is GoodDollarStaking {
|
|
7
|
+
constructor(
|
|
8
|
+
INameService _ns,
|
|
9
|
+
uint128 _interestRatePerBlock,
|
|
10
|
+
uint128 _numberOfBlocksPerYear,
|
|
11
|
+
uint32 _daysUntilUpgrade
|
|
12
|
+
)
|
|
13
|
+
GoodDollarStaking(
|
|
14
|
+
_ns,
|
|
15
|
+
_interestRatePerBlock,
|
|
16
|
+
_numberOfBlocksPerYear,
|
|
17
|
+
_daysUntilUpgrade
|
|
18
|
+
)
|
|
19
|
+
{}
|
|
20
|
+
|
|
21
|
+
function upgrade() external override {
|
|
22
|
+
_setMonthlyRewards(address(this), 2 ether * 1e6); //2M monthly GOOD
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity ^0.8;
|
|
4
|
+
|
|
5
|
+
import "../Interfaces.sol";
|
|
6
|
+
|
|
7
|
+
import "hardhat/console.sol";
|
|
8
|
+
|
|
9
|
+
interface IWrapper {
|
|
10
|
+
function mint(address to, uint256 amount) external returns (bool);
|
|
11
|
+
|
|
12
|
+
function burn(address from, uint256 amount) external returns (bool);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
contract MultichainRouterMock {
|
|
16
|
+
IWrapper wrapper;
|
|
17
|
+
|
|
18
|
+
constructor(IWrapper _wrapper) {
|
|
19
|
+
wrapper = _wrapper;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
event AnySwap(
|
|
23
|
+
address token,
|
|
24
|
+
address recipient,
|
|
25
|
+
uint256 amount,
|
|
26
|
+
uint256 chainId
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
function anySwapOut(
|
|
30
|
+
address token,
|
|
31
|
+
address recipient,
|
|
32
|
+
uint256 amount,
|
|
33
|
+
uint256 chainId
|
|
34
|
+
) external {
|
|
35
|
+
wrapper.burn(msg.sender, amount);
|
|
36
|
+
emit AnySwap(token, recipient, amount, chainId);
|
|
37
|
+
}
|
|
38
|
+
}
|