@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,268 @@
|
|
|
1
|
+
// SPDX-License-Identifier: BSD-4-Clause
|
|
2
|
+
/*
|
|
3
|
+
* ABDK Math 64.64 Smart Contract Library. Copyright © 2019 by ABDK Consulting.
|
|
4
|
+
* Author: Mikhail Vladimirov <mikhail.vladimirov@gmail.com>
|
|
5
|
+
*/
|
|
6
|
+
pragma solidity ^0.8.0;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Smart contract library of mathematical functions operating with signed
|
|
10
|
+
* 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is
|
|
11
|
+
* basically a simple fraction whose numerator is signed 128-bit integer and
|
|
12
|
+
* denominator is 2^64. As long as denominator is always the same, there is no
|
|
13
|
+
* need to store it, thus in Solidity signed 64.64-bit fixed point numbers are
|
|
14
|
+
* represented by int128 type holding only the numerator.
|
|
15
|
+
*/
|
|
16
|
+
library Math64x64 {
|
|
17
|
+
/*
|
|
18
|
+
* Minimum value signed 64.64-bit fixed point number may have.
|
|
19
|
+
*/
|
|
20
|
+
int128 private constant MIN_64x64 = -0x80000000000000000000000000000000;
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
* Maximum value signed 64.64-bit fixed point number may have.
|
|
24
|
+
*/
|
|
25
|
+
int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Convert unsigned 256-bit integer number into signed 64.64-bit fixed point
|
|
29
|
+
* number. Revert on overflow.
|
|
30
|
+
*
|
|
31
|
+
* @param x unsigned 256-bit integer number
|
|
32
|
+
* @return signed 64.64-bit fixed point number
|
|
33
|
+
*/
|
|
34
|
+
function fromUInt(uint256 x) internal pure returns (int128) {
|
|
35
|
+
unchecked {
|
|
36
|
+
require(x <= 0x7FFFFFFFFFFFFFFF);
|
|
37
|
+
return int128(int256(x << 64));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Convert signed 64.64 fixed point number into unsigned 64-bit integer
|
|
43
|
+
* number rounding down. Revert on underflow.
|
|
44
|
+
*
|
|
45
|
+
* @param x signed 64.64-bit fixed point number
|
|
46
|
+
* @return unsigned 64-bit integer number
|
|
47
|
+
*/
|
|
48
|
+
function toUInt(int128 x) internal pure returns (uint64) {
|
|
49
|
+
unchecked {
|
|
50
|
+
require(x >= 0);
|
|
51
|
+
return uint64(uint128(x >> 64));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Calculate x * y rounding down, where x is signed 64.64 fixed point number
|
|
57
|
+
* and y is unsigned 256-bit integer number. Revert on overflow.
|
|
58
|
+
*
|
|
59
|
+
* @param x signed 64.64 fixed point number
|
|
60
|
+
* @param y unsigned 256-bit integer number
|
|
61
|
+
* @return unsigned 256-bit integer number
|
|
62
|
+
*/
|
|
63
|
+
function mulu(int128 x, uint256 y) internal pure returns (uint256) {
|
|
64
|
+
unchecked {
|
|
65
|
+
if (y == 0) return 0;
|
|
66
|
+
|
|
67
|
+
require(x >= 0);
|
|
68
|
+
|
|
69
|
+
uint256 lo = (uint256(int256(x)) *
|
|
70
|
+
(y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;
|
|
71
|
+
uint256 hi = uint256(int256(x)) * (y >> 128);
|
|
72
|
+
|
|
73
|
+
require(hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
|
|
74
|
+
hi <<= 64;
|
|
75
|
+
|
|
76
|
+
require(
|
|
77
|
+
hi <=
|
|
78
|
+
0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -
|
|
79
|
+
lo
|
|
80
|
+
);
|
|
81
|
+
return hi + lo;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Calculate x / y rounding towards zero, where x and y are unsigned 256-bit
|
|
87
|
+
* integer numbers. Revert on overflow or when y is zero.
|
|
88
|
+
*
|
|
89
|
+
* @param x unsigned 256-bit integer number
|
|
90
|
+
* @param y unsigned 256-bit integer number
|
|
91
|
+
* @return signed 64.64-bit fixed point number
|
|
92
|
+
*/
|
|
93
|
+
function divu(uint256 x, uint256 y) internal pure returns (int128) {
|
|
94
|
+
unchecked {
|
|
95
|
+
require(y != 0);
|
|
96
|
+
uint128 result = divuu(x, y);
|
|
97
|
+
require(result <= uint128(MAX_64x64));
|
|
98
|
+
return int128(result);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Calculate x^y assuming 0^0 is 1, where x is signed 64.64 fixed point number
|
|
104
|
+
* and y is unsigned 256-bit integer number. Revert on overflow.
|
|
105
|
+
*
|
|
106
|
+
* @param x signed 64.64-bit fixed point number
|
|
107
|
+
* @param y uint256 value
|
|
108
|
+
* @return signed 64.64-bit fixed point number
|
|
109
|
+
*/
|
|
110
|
+
function pow(int128 x, uint256 y) internal pure returns (int128) {
|
|
111
|
+
unchecked {
|
|
112
|
+
bool negative = x < 0 && y & 1 == 1;
|
|
113
|
+
|
|
114
|
+
uint256 absX = uint128(x < 0 ? -x : x);
|
|
115
|
+
uint256 absResult;
|
|
116
|
+
absResult = 0x100000000000000000000000000000000;
|
|
117
|
+
|
|
118
|
+
if (absX <= 0x10000000000000000) {
|
|
119
|
+
absX <<= 63;
|
|
120
|
+
while (y != 0) {
|
|
121
|
+
if (y & 0x1 != 0) {
|
|
122
|
+
absResult = (absResult * absX) >> 127;
|
|
123
|
+
}
|
|
124
|
+
absX = (absX * absX) >> 127;
|
|
125
|
+
|
|
126
|
+
if (y & 0x2 != 0) {
|
|
127
|
+
absResult = (absResult * absX) >> 127;
|
|
128
|
+
}
|
|
129
|
+
absX = (absX * absX) >> 127;
|
|
130
|
+
|
|
131
|
+
if (y & 0x4 != 0) {
|
|
132
|
+
absResult = (absResult * absX) >> 127;
|
|
133
|
+
}
|
|
134
|
+
absX = (absX * absX) >> 127;
|
|
135
|
+
|
|
136
|
+
if (y & 0x8 != 0) {
|
|
137
|
+
absResult = (absResult * absX) >> 127;
|
|
138
|
+
}
|
|
139
|
+
absX = (absX * absX) >> 127;
|
|
140
|
+
|
|
141
|
+
y >>= 4;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
absResult >>= 64;
|
|
145
|
+
} else {
|
|
146
|
+
uint256 absXShift = 63;
|
|
147
|
+
if (absX < 0x1000000000000000000000000) {
|
|
148
|
+
absX <<= 32;
|
|
149
|
+
absXShift -= 32;
|
|
150
|
+
}
|
|
151
|
+
if (absX < 0x10000000000000000000000000000) {
|
|
152
|
+
absX <<= 16;
|
|
153
|
+
absXShift -= 16;
|
|
154
|
+
}
|
|
155
|
+
if (absX < 0x1000000000000000000000000000000) {
|
|
156
|
+
absX <<= 8;
|
|
157
|
+
absXShift -= 8;
|
|
158
|
+
}
|
|
159
|
+
if (absX < 0x10000000000000000000000000000000) {
|
|
160
|
+
absX <<= 4;
|
|
161
|
+
absXShift -= 4;
|
|
162
|
+
}
|
|
163
|
+
if (absX < 0x40000000000000000000000000000000) {
|
|
164
|
+
absX <<= 2;
|
|
165
|
+
absXShift -= 2;
|
|
166
|
+
}
|
|
167
|
+
if (absX < 0x80000000000000000000000000000000) {
|
|
168
|
+
absX <<= 1;
|
|
169
|
+
absXShift -= 1;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
uint256 resultShift = 0;
|
|
173
|
+
while (y != 0) {
|
|
174
|
+
require(absXShift < 64);
|
|
175
|
+
|
|
176
|
+
if (y & 0x1 != 0) {
|
|
177
|
+
absResult = (absResult * absX) >> 127;
|
|
178
|
+
resultShift += absXShift;
|
|
179
|
+
if (absResult > 0x100000000000000000000000000000000) {
|
|
180
|
+
absResult >>= 1;
|
|
181
|
+
resultShift += 1;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
absX = (absX * absX) >> 127;
|
|
185
|
+
absXShift <<= 1;
|
|
186
|
+
if (absX >= 0x100000000000000000000000000000000) {
|
|
187
|
+
absX >>= 1;
|
|
188
|
+
absXShift += 1;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
y >>= 1;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
require(resultShift < 64);
|
|
195
|
+
absResult >>= 64 - resultShift;
|
|
196
|
+
}
|
|
197
|
+
int256 result = negative ? -int256(absResult) : int256(absResult);
|
|
198
|
+
require(result >= MIN_64x64 && result <= MAX_64x64);
|
|
199
|
+
return int128(result);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Calculate x / y rounding towards zero, where x and y are unsigned 256-bit
|
|
205
|
+
* integer numbers. Revert on overflow or when y is zero.
|
|
206
|
+
*
|
|
207
|
+
* @param x unsigned 256-bit integer number
|
|
208
|
+
* @param y unsigned 256-bit integer number
|
|
209
|
+
* @return unsigned 64.64-bit fixed point number
|
|
210
|
+
*/
|
|
211
|
+
function divuu(uint256 x, uint256 y) private pure returns (uint128) {
|
|
212
|
+
unchecked {
|
|
213
|
+
require(y != 0);
|
|
214
|
+
|
|
215
|
+
uint256 result;
|
|
216
|
+
|
|
217
|
+
if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
|
|
218
|
+
result = (x << 64) / y;
|
|
219
|
+
else {
|
|
220
|
+
uint256 msb = 192;
|
|
221
|
+
uint256 xc = x >> 192;
|
|
222
|
+
if (xc >= 0x100000000) {
|
|
223
|
+
xc >>= 32;
|
|
224
|
+
msb += 32;
|
|
225
|
+
}
|
|
226
|
+
if (xc >= 0x10000) {
|
|
227
|
+
xc >>= 16;
|
|
228
|
+
msb += 16;
|
|
229
|
+
}
|
|
230
|
+
if (xc >= 0x100) {
|
|
231
|
+
xc >>= 8;
|
|
232
|
+
msb += 8;
|
|
233
|
+
}
|
|
234
|
+
if (xc >= 0x10) {
|
|
235
|
+
xc >>= 4;
|
|
236
|
+
msb += 4;
|
|
237
|
+
}
|
|
238
|
+
if (xc >= 0x4) {
|
|
239
|
+
xc >>= 2;
|
|
240
|
+
msb += 2;
|
|
241
|
+
}
|
|
242
|
+
if (xc >= 0x2) msb += 1; // No need to shift xc anymore
|
|
243
|
+
|
|
244
|
+
result = (x << (255 - msb)) / (((y - 1) >> (msb - 191)) + 1);
|
|
245
|
+
require(result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
|
|
246
|
+
|
|
247
|
+
uint256 hi = result * (y >> 128);
|
|
248
|
+
uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
|
|
249
|
+
|
|
250
|
+
uint256 xh = x >> 192;
|
|
251
|
+
uint256 xl = x << 64;
|
|
252
|
+
|
|
253
|
+
if (xl < lo) xh -= 1;
|
|
254
|
+
xl -= lo; // We rely on overflow behavior here
|
|
255
|
+
lo = hi << 128;
|
|
256
|
+
if (xl < lo) xh -= 1;
|
|
257
|
+
xl -= lo; // We rely on overflow behavior here
|
|
258
|
+
|
|
259
|
+
assert(xh == hi >> 128);
|
|
260
|
+
|
|
261
|
+
result += xl / y;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
require(result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
|
|
265
|
+
return uint128(result);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity >=0.8.0;
|
|
3
|
+
|
|
4
|
+
import "./Math64X64.sol";
|
|
5
|
+
import "hardhat/console.sol";
|
|
6
|
+
|
|
7
|
+
/***
|
|
8
|
+
* @dev helper contract for calculating fixed per block compounding interest rate rewards.
|
|
9
|
+
*/
|
|
10
|
+
abstract contract StakingRewardsFixedAPY {
|
|
11
|
+
using Math64x64 for int128;
|
|
12
|
+
|
|
13
|
+
// precision constant for math
|
|
14
|
+
uint128 public constant PRECISION = 1e18;
|
|
15
|
+
uint128 public constant SHARE_PRECISION = 1e18;
|
|
16
|
+
uint128 public constant SHARE_DECIMALS = 1e4;
|
|
17
|
+
|
|
18
|
+
// the users stake information
|
|
19
|
+
struct StakerInfo {
|
|
20
|
+
uint128 lastSharePrice; // the share price that can be used to calculate earned rewards
|
|
21
|
+
uint128 rewardsPaid; // rewards that accounted already so should be substracted
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
struct Stats {
|
|
25
|
+
// last block this staking contract was updated and rewards were calculated
|
|
26
|
+
uint128 lastUpdateBlock;
|
|
27
|
+
// total supply of active stakes
|
|
28
|
+
uint128 totalStaked;
|
|
29
|
+
uint128 totalRewardsPaid;
|
|
30
|
+
uint256 savings; //total earning compounding interest;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
Stats public stats;
|
|
34
|
+
|
|
35
|
+
// the user info sheet
|
|
36
|
+
mapping(address => StakerInfo) public stakersInfo;
|
|
37
|
+
|
|
38
|
+
// interest rate per one block in 1e18 precision.
|
|
39
|
+
//for example APY=5% then per block = nroot(1+0.05,numberOfBlocksPerYear)
|
|
40
|
+
//nroot(1.05,6000000) = 1.000000008131694
|
|
41
|
+
//in 1e18 = 1000000008131694000
|
|
42
|
+
int128 public interestRatePerBlockX64;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @notice internal helper to convert unsigned interest rate per block in 1e18 precision to x64 format
|
|
46
|
+
*/
|
|
47
|
+
function _setAPY(uint128 _interestRatePerBlock) internal updateReward {
|
|
48
|
+
interestRatePerBlockX64 = Math64x64.divu(_interestRatePerBlock, 1e18); //convert to signed int x64
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @notice modifier to compound the APY on every state update
|
|
53
|
+
*/
|
|
54
|
+
modifier updateReward() {
|
|
55
|
+
_updateReward();
|
|
56
|
+
_;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @dev the amount of shares of the savings _account holds
|
|
61
|
+
* @param _account the address
|
|
62
|
+
*/
|
|
63
|
+
function sharesOf(address _account)
|
|
64
|
+
public
|
|
65
|
+
view
|
|
66
|
+
virtual
|
|
67
|
+
returns (uint256 shares);
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @dev the total outstanding shares
|
|
71
|
+
*/
|
|
72
|
+
function sharesSupply() public view virtual returns (uint256);
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @notice calculates the compounded savings based on passed blocks
|
|
76
|
+
* @return compoundedSavings the new savings
|
|
77
|
+
*/
|
|
78
|
+
function _compound() internal view returns (uint256 compoundedSavings) {
|
|
79
|
+
if (stats.savings == 0 || block.number == stats.lastUpdateBlock) {
|
|
80
|
+
return stats.savings;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
//earned in timespan = (interestRatePerBlock^blocksPassed * savings - savings)/PRECISION
|
|
84
|
+
//earned perToken = earnedInTimeSpan*PRECISION/totalStaked
|
|
85
|
+
//PRECISION cancels out
|
|
86
|
+
int128 compound = interestRatePerBlockX64.pow(
|
|
87
|
+
block.number - stats.lastUpdateBlock
|
|
88
|
+
);
|
|
89
|
+
compoundedSavings = compound.mulu(stats.savings);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @notice calculates the current share price (savings/totalShares)
|
|
94
|
+
* @return price the current share price in SHARE_PRECISION
|
|
95
|
+
*/
|
|
96
|
+
function sharePrice() public view returns (uint256 price) {
|
|
97
|
+
uint256 compoundedSavings = _compound();
|
|
98
|
+
|
|
99
|
+
// console.log(
|
|
100
|
+
// "compoundedSavings %s, shares: %s, sharePrice: %s",
|
|
101
|
+
// compoundedSavings,
|
|
102
|
+
// stats.totalShares,
|
|
103
|
+
// (compoundedSavings * SHARE_PRECISION) / (stats.totalShares * PRECISION)
|
|
104
|
+
// );
|
|
105
|
+
|
|
106
|
+
return
|
|
107
|
+
sharesSupply() == 0
|
|
108
|
+
? 0
|
|
109
|
+
: (compoundedSavings * SHARE_PRECISION) / (sharesSupply() * PRECISION);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @notice calculate how much user can withdraw
|
|
114
|
+
* @return balance account compounded savings balance
|
|
115
|
+
*/
|
|
116
|
+
function getSavings(address _account)
|
|
117
|
+
external
|
|
118
|
+
view
|
|
119
|
+
returns (uint256 balance)
|
|
120
|
+
{
|
|
121
|
+
balance = (sharePrice() * sharesOf(_account)) / SHARE_PRECISION;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function ceil(uint256 amount, uint256 precision)
|
|
125
|
+
internal
|
|
126
|
+
pure
|
|
127
|
+
returns (uint256)
|
|
128
|
+
{
|
|
129
|
+
return ((amount + precision - 1) / precision);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @dev helper to get _amount worth of shares
|
|
134
|
+
*/
|
|
135
|
+
function amountToShares(uint256 _amount)
|
|
136
|
+
public
|
|
137
|
+
view
|
|
138
|
+
returns (uint256 shares)
|
|
139
|
+
{
|
|
140
|
+
return
|
|
141
|
+
ceil(
|
|
142
|
+
(_amount * SHARE_PRECISION * SHARE_DECIMALS) / sharePrice(),
|
|
143
|
+
SHARE_DECIMALS
|
|
144
|
+
); //ceil ensures shares value >= amount
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @dev helper to get _account lastSharePrice, which is used to calculate accumulated rewards since lastSharePrice was updated
|
|
149
|
+
*/
|
|
150
|
+
function lastSharePrice(address _account)
|
|
151
|
+
public
|
|
152
|
+
view
|
|
153
|
+
returns (uint256 price)
|
|
154
|
+
{
|
|
155
|
+
return uint256(stakersInfo[_account].lastSharePrice);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* @dev get the principle of _account (ie estimated original deposit)
|
|
160
|
+
*/
|
|
161
|
+
function principle(address _account)
|
|
162
|
+
external
|
|
163
|
+
view
|
|
164
|
+
returns (uint256 deposited)
|
|
165
|
+
{
|
|
166
|
+
return (lastSharePrice(_account) * sharesOf(_account)) / SHARE_PRECISION;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* @notice The function allows anyone to calculate the exact amount of reward
|
|
171
|
+
* earned.
|
|
172
|
+
* @param _account A staker address
|
|
173
|
+
* @return earnedRewards total rewards earned
|
|
174
|
+
*/
|
|
175
|
+
function earned(address _account)
|
|
176
|
+
public
|
|
177
|
+
view
|
|
178
|
+
returns (uint256 earnedRewards)
|
|
179
|
+
{
|
|
180
|
+
uint256 shares = sharesOf(_account);
|
|
181
|
+
uint256 curPrice = sharePrice();
|
|
182
|
+
uint256 lastPrice = lastSharePrice(_account);
|
|
183
|
+
lastPrice = lastPrice > curPrice ? curPrice : lastPrice; //it could be that share price is lower immediatly after staking
|
|
184
|
+
|
|
185
|
+
earnedRewards =
|
|
186
|
+
((curPrice * shares) - (lastPrice * shares)) /
|
|
187
|
+
SHARE_PRECISION;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* @notice calculate the interest earned and not yet paid for stats.totalStaked
|
|
192
|
+
* @return debt the rewards(interest) not yet paid
|
|
193
|
+
*/
|
|
194
|
+
function getRewardsDebt() external view returns (uint256 debt) {
|
|
195
|
+
debt = _compound() - stats.totalStaked * PRECISION; //totalStaked is in G$ precision (ie 2 decimals)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* @notice compounds the global savings
|
|
200
|
+
*/
|
|
201
|
+
function _updateReward() internal virtual {
|
|
202
|
+
stats.savings = _compound();
|
|
203
|
+
stats.lastUpdateBlock = uint128(block.number);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* @notice perform state update when withdrawing
|
|
208
|
+
* @param _from account address withdrawing
|
|
209
|
+
* @param _shares amount to withdraw, if amount is max uint then it will withdraw available balance
|
|
210
|
+
* @return depositComponent how much was withdrawn from user original stake. >0 only when _amount > interest (rewards) earned
|
|
211
|
+
* @return rewardComponent how much was withdrawn from user earned rewards
|
|
212
|
+
*/
|
|
213
|
+
function _withdraw(address _from, uint256 _shares)
|
|
214
|
+
internal
|
|
215
|
+
virtual
|
|
216
|
+
updateReward
|
|
217
|
+
returns (uint256 depositComponent, uint256 rewardComponent)
|
|
218
|
+
{
|
|
219
|
+
uint256 sharesBalance = sharesOf(_from);
|
|
220
|
+
|
|
221
|
+
require(_shares > 0 && _shares <= sharesBalance, "no balance");
|
|
222
|
+
|
|
223
|
+
uint256 amount = (sharePrice() * _shares) / SHARE_PRECISION;
|
|
224
|
+
|
|
225
|
+
uint256 pendingRewards = earned(_from);
|
|
226
|
+
|
|
227
|
+
rewardComponent = pendingRewards >= amount ? amount : pendingRewards;
|
|
228
|
+
|
|
229
|
+
depositComponent = amount > rewardComponent ? amount - rewardComponent : 0;
|
|
230
|
+
|
|
231
|
+
//because of rounding down of rewardComponent after some operations this can cause the deposit component to be larger
|
|
232
|
+
//than it actually was
|
|
233
|
+
if (stats.totalStaked < depositComponent) {
|
|
234
|
+
uint256 diff = depositComponent - stats.totalStaked;
|
|
235
|
+
rewardComponent += diff;
|
|
236
|
+
depositComponent = stats.totalStaked;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
require(amount > 0, "min shares withdraw value: 1 gd");
|
|
240
|
+
|
|
241
|
+
// console.log("withdraw: reducing principle by %s", _amount);
|
|
242
|
+
|
|
243
|
+
stats.savings -= amount * PRECISION;
|
|
244
|
+
stats.totalStaked -= uint128(depositComponent);
|
|
245
|
+
stats.totalRewardsPaid += uint128(rewardComponent);
|
|
246
|
+
stakersInfo[_from].rewardsPaid += uint128(rewardComponent);
|
|
247
|
+
|
|
248
|
+
uint256 newShareSupply = sharesSupply() - _shares;
|
|
249
|
+
uint256 newSharePrice = newShareSupply == 0
|
|
250
|
+
? 0
|
|
251
|
+
: (stats.savings * SHARE_PRECISION) / (newShareSupply * PRECISION);
|
|
252
|
+
|
|
253
|
+
if (
|
|
254
|
+
depositComponent > 0 ||
|
|
255
|
+
rewardComponent == pendingRewards ||
|
|
256
|
+
newShareSupply == 0
|
|
257
|
+
) //we have withdrawn all rewards so we reset lastSharePrice
|
|
258
|
+
{
|
|
259
|
+
// console.log("withdraw: reset shareprice to: %s", newSharePrice);
|
|
260
|
+
stakersInfo[_from].lastSharePrice = uint128(newSharePrice);
|
|
261
|
+
} else {
|
|
262
|
+
//we set the lastSharePrice to not include remaining rewards value
|
|
263
|
+
stakersInfo[_from].lastSharePrice = uint128(
|
|
264
|
+
newSharePrice -
|
|
265
|
+
((pendingRewards - rewardComponent) * SHARE_PRECISION) /
|
|
266
|
+
(sharesBalance - _shares)
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* @notice perform state update when staking
|
|
273
|
+
* @param _from account address staking
|
|
274
|
+
* @param _amount amount to stake
|
|
275
|
+
*/
|
|
276
|
+
function _stake(address _from, uint256 _amount)
|
|
277
|
+
internal
|
|
278
|
+
virtual
|
|
279
|
+
updateReward
|
|
280
|
+
returns (uint256 shares)
|
|
281
|
+
{
|
|
282
|
+
require(_amount > 0, "Cannot stake 0");
|
|
283
|
+
shares = sharesSupply() > 0
|
|
284
|
+
? ((_amount * SHARE_PRECISION) / sharePrice()) //amount/sharePrice = new shares = amount/(savings/totalShares)
|
|
285
|
+
: (_amount * SHARE_DECIMALS); //principal/number of shares is shares price, so initially each share price will represent G%cent/SHARE_DECIMALS
|
|
286
|
+
require(shares > 0, "min stake 1 share price");
|
|
287
|
+
|
|
288
|
+
stakersInfo[_from].lastSharePrice = uint128(
|
|
289
|
+
sharesOf(_from) == 0
|
|
290
|
+
? (_amount * SHARE_PRECISION) / shares
|
|
291
|
+
: ((sharesOf(_from) * stakersInfo[_from].lastSharePrice) +
|
|
292
|
+
(shares * sharePrice())) / (sharesOf(_from) + shares)
|
|
293
|
+
);
|
|
294
|
+
stats.totalStaked += uint128(_amount);
|
|
295
|
+
stats.savings += _amount * PRECISION;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* @notice keep track of debt to user in case reward minting failed
|
|
300
|
+
* @dev notice that this should not be called when _rewardsPaid are 0
|
|
301
|
+
* @return shares added to cover rewards
|
|
302
|
+
*/
|
|
303
|
+
function _undoReward(address _to, uint256 _rewardsPaid)
|
|
304
|
+
internal
|
|
305
|
+
virtual
|
|
306
|
+
returns (uint256 shares)
|
|
307
|
+
{
|
|
308
|
+
//skip on invalid input
|
|
309
|
+
if (_rewardsPaid == 0) {
|
|
310
|
+
return 0;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
//calculate this before udpating global savings
|
|
314
|
+
shares = sharesSupply() > 0
|
|
315
|
+
? ((_rewardsPaid * SHARE_PRECISION) / sharePrice())
|
|
316
|
+
: (_rewardsPaid * SHARE_DECIMALS); //staker previously withdrew all, so shares issued like on first stake
|
|
317
|
+
|
|
318
|
+
stats.totalRewardsPaid -= uint128(_rewardsPaid);
|
|
319
|
+
stats.savings += _rewardsPaid * PRECISION; //rewards are part of the compounding interest
|
|
320
|
+
|
|
321
|
+
stakersInfo[_to].rewardsPaid -= uint128(_rewardsPaid);
|
|
322
|
+
|
|
323
|
+
//remove rewards from the lastSharePrice
|
|
324
|
+
//we set the lastSharePrice to not include unwithdrawn rewards
|
|
325
|
+
//if lastSharePrice is 0 then nothing to do. it means all funds are rewards ie profit
|
|
326
|
+
if (stakersInfo[_to].lastSharePrice > 0) {
|
|
327
|
+
uint256 rewardsSharesPart = (_rewardsPaid * SHARE_PRECISION) /
|
|
328
|
+
(sharesOf(_to) + shares);
|
|
329
|
+
|
|
330
|
+
stakersInfo[_to].lastSharePrice = rewardsSharesPart >=
|
|
331
|
+
stakersInfo[_to].lastSharePrice
|
|
332
|
+
? 0
|
|
333
|
+
: uint128(stakersInfo[_to].lastSharePrice - rewardsSharesPart);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
@@ -32,14 +32,14 @@ contract BulkProof {
|
|
|
32
32
|
bytes32[] proof;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
function bulkProof(Proof[] calldata proofs) external {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
35
|
+
// function bulkProof(Proof[] calldata proofs) external {
|
|
36
|
+
// for (uint256 i = 0; i < proofs.length; i++) {
|
|
37
|
+
// Proof memory proof = proofs[i];
|
|
38
|
+
// GoodReserveCDai(0xa150a825d425B36329D8294eeF8bD0fE68f8F6E0).claimGDX(
|
|
39
|
+
// proof.account,
|
|
40
|
+
// proof.balance,
|
|
41
|
+
// proof.proof
|
|
42
|
+
// );
|
|
43
|
+
// }
|
|
44
|
+
// }
|
|
45
45
|
}
|