@gooddollar/goodprotocol 1.0.29-beta.0 → 1.0.29-beta.2
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/AdminWallet.min.json +1 -1
- 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/Faucet.min.json +1 -0
- 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/IGoodDollar.min.json +1 -1
- package/artifacts/abis/IGoodDollarStakingTest.min.json +1 -0
- package/artifacts/abis/IGovernanceStaking.min.json +1 -0
- package/artifacts/abis/IIdentity.min.json +1 -1
- package/artifacts/abis/IIdentityV2.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/IdentityV2.min.json +1 -0
- package/artifacts/abis/InvitesV2.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/UBIScheme.min.json +1 -1
- 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/IGoodDollar.json +39 -0
- 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/IIdentity.json +51 -0
- package/artifacts/contracts/Interfaces.sol/IIdentityV2.dbg.json +4 -0
- package/artifacts/contracts/Interfaces.sol/IIdentityV2.json +281 -0
- 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/Faucet.sol/Faucet.dbg.json +4 -0
- package/artifacts/contracts/fuseFaucet/Faucet.sol/Faucet.json +684 -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 +1335 -0
- package/artifacts/contracts/governance/GoodDollarStaking.sol/IGovernanceStaking.dbg.json +4 -0
- package/artifacts/contracts/governance/GoodDollarStaking.sol/IGovernanceStaking.json +24 -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/identity/IdentityV2.sol/IdentityV2.dbg.json +4 -0
- package/artifacts/contracts/identity/IdentityV2.sol/IdentityV2.json +1000 -0
- package/artifacts/contracts/invite/InvitesV1.sol/InvitesV1.dbg.json +1 -1
- package/artifacts/contracts/invite/InvitesV1.sol/InvitesV1.json +2 -2
- package/artifacts/contracts/invite/InvitesV2.sol/InvitesV2.dbg.json +4 -0
- package/artifacts/contracts/invite/InvitesV2.sol/InvitesV2.json +586 -0
- 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 +1335 -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 +15 -22
- package/artifacts/contracts/utils/AdminWallet.sol/AdminWallet.dbg.json +1 -1
- package/artifacts/contracts/utils/AdminWallet.sol/AdminWallet.json +76 -56
- 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 +46 -0
- package/contracts/fuseFaucet/Faucet.sol +245 -0
- package/contracts/governance/GoodDollarStaking.sol +524 -0
- package/contracts/governance/MultiBaseGovernanceShareField.sol +1 -0
- package/contracts/identity/IdentityV2.sol +434 -0
- package/contracts/invite/InvitesV2.sol +316 -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/ubi/UBIScheme.sol +45 -40
- package/contracts/utils/AdminWallet.sol +42 -11
- 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 +21 -5
- package/package.json +9 -5
- package/patches/@openzeppelin+hardhat-upgrades+1.7.0.patch.depracate +67 -0
- package/releases/deploy-settings.json +36 -1
- package/releases/deployment.json +103 -55
- 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/0_proxyFactory-deploy.ts +45 -0
- package/scripts/multichain-deploy/{basicdao-deploy.ts → 1_basicdao-deploy.ts} +75 -56
- package/scripts/multichain-deploy/2_helpers-deploy.ts +143 -0
- package/scripts/multichain-deploy/3_gdSavings-deploy.ts +246 -0
- package/scripts/multichain-deploy/4_ubi-deploy.ts +121 -0
- package/scripts/multichain-deploy/5_gov-deploy.ts +123 -0
- package/scripts/multichain-deploy/helpers.ts +72 -8
- package/scripts/multichain-deploy/multichainWrapper-deploy.ts +56 -0
- package/scripts/multichain-deploy/verifyEtherscan.ts +84 -0
- package/scripts/test/localOldDaoDeploy.ts +10 -3
- package/scripts/upgrades/identity-upgrade.ts +153 -0
- package/scripts/upgrades/nonubiDistribution-deploy.ts +167 -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 +21 -20
- 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/ubi/UBIScheme.test.ts +30 -30
- package/test/ubi/UBISchemeCycle.test.ts +9 -7
- package/test/utils/AdminWallet.test.ts +40 -13
- package/test/utils/GoodDollarMintBurnWrapper.test.ts +796 -0
- package/tsconfig.json +4 -9
- package/types/AccessControl.ts +361 -0
- package/types/AdminWallet.ts +124 -113
- 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/Faucet.ts +1014 -0
- package/types/GoodDollarMintBurnWrapper.ts +1806 -0
- package/types/GoodDollarStaking.ts +1889 -0
- package/types/GoodDollarStakingMock.ts +1889 -0
- package/types/GoodReserveCDai.ts +90 -55
- package/types/IAccessControl.ts +306 -0
- package/types/IERC1271.ts +109 -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/IGoodDollar.ts +54 -0
- package/types/IGoodDollarStakingTest.ts +160 -0
- package/types/{BulkProof.ts → IGovernanceStaking.ts} +15 -28
- package/types/IIdentity.ts +75 -0
- package/types/IIdentityV2.ts +526 -0
- package/types/IMultichainRouter.ts +166 -0
- package/types/IRouter.ts +143 -0
- package/types/IWrapper.ts +143 -0
- package/types/IdentityV2.ts +1612 -0
- package/types/InvitesV2.ts +933 -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/RewardsMinter.ts +107 -0
- package/types/StakingMockFixedAPY.ts +995 -0
- package/types/StakingRewardsFixedAPY.ts +428 -0
- package/types/UBIScheme.ts +19 -40
- package/types/factories/AaveStakingFactory__factory.ts +1 -1
- package/types/factories/AccessControl__factory.ts +227 -0
- package/types/factories/AdminWallet__factory.ts +75 -55
- 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/Faucet__factory.ts +729 -0
- 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 +1417 -0
- package/types/factories/GoodDollarStaking__factory.ts +1413 -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/IERC1271__factory.ts +47 -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/IGoodDollar__factory.ts +39 -0
- package/types/factories/IGovernanceStaking__factory.ts +39 -0
- package/types/factories/IIdentityV2__factory.ts +293 -0
- package/types/factories/IIdentity__factory.ts +51 -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/IdentityV2__factory.ts +1048 -0
- package/types/factories/InvitesV1__factory.ts +1 -1
- package/types/factories/InvitesV2__factory.ts +634 -0
- 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 +14 -21
- 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 +279 -9
- package/types/index.ts +62 -4
- package/yarn.lock +184 -108
- package/types/factories/BulkProof__factory.ts +0 -89
|
@@ -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
|
+
}
|
|
@@ -71,7 +71,8 @@ contract UBIScheme is DAOUpgradeableContract {
|
|
|
71
71
|
//dont use first claim, and give ubi as usual
|
|
72
72
|
bool public useFirstClaimPool;
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
//minimum amount of users to divide the pool for, renamed from defaultDailyUbi
|
|
75
|
+
uint256 public minActiveUsers;
|
|
75
76
|
|
|
76
77
|
// A pool of GD to give to activated users,
|
|
77
78
|
// since they will enter the UBI pool
|
|
@@ -99,14 +100,14 @@ contract UBIScheme is DAOUpgradeableContract {
|
|
|
99
100
|
// Total claims per user stat
|
|
100
101
|
mapping(address => uint256) public totalClaimsPerUser;
|
|
101
102
|
|
|
103
|
+
bool public paused;
|
|
104
|
+
|
|
102
105
|
// Emits when a withdraw has been succeded
|
|
103
106
|
event WithdrawFromDao(uint256 prevBalance, uint256 newBalance);
|
|
104
107
|
|
|
105
108
|
// Emits when a user is activated
|
|
106
109
|
event ActivatedUser(address indexed account);
|
|
107
110
|
|
|
108
|
-
bool public paused;
|
|
109
|
-
|
|
110
111
|
// Emits when a fish has been succeded
|
|
111
112
|
event InactiveUserFished(
|
|
112
113
|
address indexed caller,
|
|
@@ -157,8 +158,8 @@ contract UBIScheme is DAOUpgradeableContract {
|
|
|
157
158
|
iterationGasLimit = 150000;
|
|
158
159
|
periodStart = (block.timestamp / (1 days)) * 1 days + 12 hours; //set start time to GMT noon
|
|
159
160
|
startOfCycle = periodStart;
|
|
160
|
-
useFirstClaimPool =
|
|
161
|
-
|
|
161
|
+
useFirstClaimPool = address(_firstClaimPool) != address(0);
|
|
162
|
+
minActiveUsers = 1000;
|
|
162
163
|
}
|
|
163
164
|
|
|
164
165
|
function setUseFirstClaimPool(bool _use) public {
|
|
@@ -285,17 +286,20 @@ contract UBIScheme is DAOUpgradeableContract {
|
|
|
285
286
|
Funds storage funds = dailyUBIHistory[currentDay];
|
|
286
287
|
funds.hasWithdrawn = shouldWithdrawFromDAO;
|
|
287
288
|
funds.openAmount = currentBalance;
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
}
|
|
289
|
+
dailyUbi = dailyCyclePool / max(activeUsersCount, minActiveUsers);
|
|
290
|
+
//update minActiveUsers as claimers grow
|
|
291
|
+
minActiveUsers = max(activeUsersCount / 2, minActiveUsers);
|
|
292
|
+
|
|
293
293
|
emit UBICalculated(currentDay, dailyUbi, block.number);
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
return dailyUbi;
|
|
297
297
|
}
|
|
298
298
|
|
|
299
|
+
function max(uint256 a, uint256 b) private pure returns (uint256) {
|
|
300
|
+
return a >= b ? a : b;
|
|
301
|
+
}
|
|
302
|
+
|
|
299
303
|
/**
|
|
300
304
|
*@dev Sets the currentDay variable to amount of days
|
|
301
305
|
* since start of contract.
|
|
@@ -356,12 +360,14 @@ contract UBIScheme is DAOUpgradeableContract {
|
|
|
356
360
|
* and emits an event in case of claimed.
|
|
357
361
|
* In case that `isFirstTime` is true, it awards the user.
|
|
358
362
|
* @param _account the account which recieves the funds
|
|
363
|
+
* @param _target the recipient of funds
|
|
359
364
|
* @param _amount the amount to transfer
|
|
360
365
|
* @param _isClaimed true for claimed
|
|
361
366
|
* @param _isFirstTime true for new user or fished user
|
|
362
367
|
*/
|
|
363
368
|
function _transferTokens(
|
|
364
369
|
address _account,
|
|
370
|
+
address _target,
|
|
365
371
|
uint256 _amount,
|
|
366
372
|
bool _isClaimed,
|
|
367
373
|
bool _isFirstTime
|
|
@@ -377,7 +383,7 @@ contract UBIScheme is DAOUpgradeableContract {
|
|
|
377
383
|
|
|
378
384
|
// awards a new user or a fished user
|
|
379
385
|
if (_isFirstTime) {
|
|
380
|
-
uint256 awardAmount = firstClaimPool.awardUser(
|
|
386
|
+
uint256 awardAmount = firstClaimPool.awardUser(_target);
|
|
381
387
|
claimDay[currentDay].claimAmount += awardAmount;
|
|
382
388
|
emit UBIClaimed(_account, awardAmount);
|
|
383
389
|
} else {
|
|
@@ -386,7 +392,7 @@ contract UBIScheme is DAOUpgradeableContract {
|
|
|
386
392
|
emit UBIClaimed(_account, _amount);
|
|
387
393
|
}
|
|
388
394
|
IGoodDollar token = nativeToken();
|
|
389
|
-
require(token.transfer(
|
|
395
|
+
require(token.transfer(_target, _amount), "claim transfer failed");
|
|
390
396
|
}
|
|
391
397
|
}
|
|
392
398
|
|
|
@@ -403,11 +409,9 @@ contract UBIScheme is DAOUpgradeableContract {
|
|
|
403
409
|
{
|
|
404
410
|
_dailyCyclePool = currentBalance / cycleLength;
|
|
405
411
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
_dailyUbi = defaultDailyUbi;
|
|
410
|
-
}
|
|
412
|
+
|
|
413
|
+
_dailyUbi = _dailyCyclePool / max(activeUsersCount, minActiveUsers);
|
|
414
|
+
|
|
411
415
|
return _dailyUbi;
|
|
412
416
|
}
|
|
413
417
|
|
|
@@ -447,9 +451,10 @@ contract UBIScheme is DAOUpgradeableContract {
|
|
|
447
451
|
* calculats the amount the account can claims, and transfers the amount to the account.
|
|
448
452
|
* Emits the address of account and amount claimed.
|
|
449
453
|
* @param _account The claimer account
|
|
454
|
+
* @param _target recipient of funds
|
|
450
455
|
* @return A bool indicating if UBI was claimed
|
|
451
456
|
*/
|
|
452
|
-
function _claim(address _account) internal returns (bool) {
|
|
457
|
+
function _claim(address _account, address _target) internal returns (bool) {
|
|
453
458
|
// calculats the formula up today ie on day 0 there are no active users, on day 1 any user
|
|
454
459
|
// (new or active) will trigger the calculation with the active users count of the day before
|
|
455
460
|
// and so on. the new or inactive users that will become active today, will not take into account
|
|
@@ -462,16 +467,16 @@ contract UBIScheme is DAOUpgradeableContract {
|
|
|
462
467
|
!fishedUsersAddresses[_account] &&
|
|
463
468
|
!hasClaimed(_account)
|
|
464
469
|
) {
|
|
465
|
-
_transferTokens(_account, newDistribution, true, false);
|
|
470
|
+
_transferTokens(_account, _target, newDistribution, true, false);
|
|
466
471
|
return true;
|
|
467
472
|
} else if (!isNotNewUser(_account) || fishedUsersAddresses[_account]) {
|
|
468
473
|
// a unregistered or fished user
|
|
469
474
|
activeUsersCount += 1;
|
|
470
475
|
fishedUsersAddresses[_account] = false;
|
|
471
476
|
if (useFirstClaimPool) {
|
|
472
|
-
_transferTokens(_account, 0, false, true);
|
|
477
|
+
_transferTokens(_account, _target, 0, false, true);
|
|
473
478
|
} else {
|
|
474
|
-
_transferTokens(_account, newDistribution, true, false);
|
|
479
|
+
_transferTokens(_account, _target, newDistribution, true, false);
|
|
475
480
|
}
|
|
476
481
|
emit ActivatedUser(_account);
|
|
477
482
|
return true;
|
|
@@ -486,14 +491,13 @@ contract UBIScheme is DAOUpgradeableContract {
|
|
|
486
491
|
* @return A bool indicating if UBI was claimed
|
|
487
492
|
*/
|
|
488
493
|
function claim() public requireStarted returns (bool) {
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
);
|
|
493
|
-
bool didClaim = _claim(msg.sender);
|
|
494
|
+
address whitelistedRoot = IIdentityV2(nameService.getAddress("IDENTITY"))
|
|
495
|
+
.getWhitelistedRoot(msg.sender);
|
|
496
|
+
require(whitelistedRoot != address(0), "UBIScheme: not whitelisted");
|
|
497
|
+
bool didClaim = _claim(whitelistedRoot, msg.sender);
|
|
494
498
|
address claimerDistribution = nameService.getAddress("GDAO_CLAIMERS");
|
|
495
499
|
if (didClaim && claimerDistribution != address(0)) {
|
|
496
|
-
ClaimersDistribution(claimerDistribution).updateClaim(
|
|
500
|
+
ClaimersDistribution(claimerDistribution).updateClaim(whitelistedRoot);
|
|
497
501
|
}
|
|
498
502
|
return didClaim;
|
|
499
503
|
}
|
|
@@ -524,7 +528,7 @@ contract UBIScheme is DAOUpgradeableContract {
|
|
|
524
528
|
if (activeUsersCount > 0) {
|
|
525
529
|
activeUsersCount -= 1;
|
|
526
530
|
}
|
|
527
|
-
_transferTokens(msg.sender, newDistribution, false, false);
|
|
531
|
+
_transferTokens(msg.sender, msg.sender, newDistribution, false, false);
|
|
528
532
|
emit InactiveUserFished(msg.sender, _account, newDistribution);
|
|
529
533
|
return true;
|
|
530
534
|
}
|
|
@@ -572,18 +576,19 @@ contract UBIScheme is DAOUpgradeableContract {
|
|
|
572
576
|
paused = _pause;
|
|
573
577
|
}
|
|
574
578
|
|
|
575
|
-
function upgrade() public {
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
579
|
+
// function upgrade() public {
|
|
580
|
+
// _onlyAvatar();
|
|
581
|
+
// paused = true;
|
|
582
|
+
// activeUsersCount = 50000; //estimated
|
|
583
|
+
// dailyUbi = 0; //required so distributionformula will trigger
|
|
584
|
+
// cycleLength = 30;
|
|
585
|
+
// currentCycleLength = 0; //this will trigger a new cycle calculation in distribution formula
|
|
586
|
+
// startOfCycle = block.timestamp - 91 days; //this will trigger a new calculation in distributionFormula
|
|
587
|
+
// periodStart = 1646136000;
|
|
588
|
+
// maxDailyUBI = 50000;
|
|
589
|
+
// distributionFormula();
|
|
590
|
+
// emit CycleLengthSet(cycleLength);
|
|
591
|
+
// }
|
|
587
592
|
|
|
588
593
|
function setActiveUserCount(uint256 _activeUserCount) public {
|
|
589
594
|
_onlyAvatar();
|
|
@@ -4,10 +4,10 @@ pragma solidity >=0.8.0;
|
|
|
4
4
|
|
|
5
5
|
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
|
6
6
|
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
|
|
7
|
-
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
|
|
8
7
|
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
|
|
9
8
|
|
|
10
9
|
import "../Interfaces.sol";
|
|
10
|
+
import "../utils/NameService.sol";
|
|
11
11
|
|
|
12
12
|
/* @title Admin wallet contract allowing whitelisting and topping up of
|
|
13
13
|
* addresses
|
|
@@ -15,7 +15,6 @@ import "../Interfaces.sol";
|
|
|
15
15
|
contract AdminWallet is
|
|
16
16
|
Initializable,
|
|
17
17
|
UUPSUpgradeable,
|
|
18
|
-
OwnableUpgradeable,
|
|
19
18
|
AccessControlUpgradeable
|
|
20
19
|
{
|
|
21
20
|
bytes32 public constant WALLET_ADMIN_ROLE = keccak256("WALLET_ADMIN_ROLE");
|
|
@@ -28,10 +27,13 @@ contract AdminWallet is
|
|
|
28
27
|
uint256 public toppingTimes;
|
|
29
28
|
uint256 public gasPrice;
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
NameService public nameService;
|
|
32
31
|
|
|
33
32
|
mapping(uint256 => mapping(address => uint256)) toppings;
|
|
34
33
|
|
|
34
|
+
uint64 public maxDailyNewWallets;
|
|
35
|
+
uint64 public day;
|
|
36
|
+
|
|
35
37
|
event AdminsAdded(address payable[] indexed admins);
|
|
36
38
|
event AdminsRemoved(address[] indexed admins);
|
|
37
39
|
event WalletTopped(address indexed user, uint256 amount);
|
|
@@ -47,17 +49,29 @@ contract AdminWallet is
|
|
|
47
49
|
*/
|
|
48
50
|
function initialize(
|
|
49
51
|
address payable[] memory _admins,
|
|
52
|
+
NameService _ns,
|
|
50
53
|
address _owner,
|
|
51
|
-
|
|
54
|
+
uint256 _gasPrice
|
|
52
55
|
) public initializer {
|
|
53
56
|
__AccessControl_init_unchained();
|
|
54
|
-
__Ownable_init_unchained();
|
|
55
57
|
_setupRole(DEFAULT_ADMIN_ROLE, _owner);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
|
|
59
|
+
|
|
60
|
+
_setDefaults(600000, 9e6, 3, _gasPrice);
|
|
61
|
+
nameService = _ns;
|
|
58
62
|
if (_admins.length > 0) {
|
|
59
63
|
addAdmins(_admins);
|
|
60
64
|
}
|
|
65
|
+
if (msg.sender != _owner) revokeRole(DEFAULT_ADMIN_ROLE, msg.sender);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
modifier onlyOwner() {
|
|
69
|
+
require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "not owner");
|
|
70
|
+
_;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function getIdentity() public view returns (IIdentityV2) {
|
|
74
|
+
return IIdentityV2(nameService.getAddress("IDENTITY"));
|
|
61
75
|
}
|
|
62
76
|
|
|
63
77
|
function setDefaults(
|
|
@@ -171,28 +185,45 @@ contract AdminWallet is
|
|
|
171
185
|
onlyAdmin
|
|
172
186
|
reimburseGas
|
|
173
187
|
{
|
|
174
|
-
|
|
188
|
+
getIdentity().addWhitelistedWithDID(_user, _did);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/* @dev Function to add given address to whitelist of identity contract
|
|
192
|
+
* can only be done by admins of wallet and if wallet is an IdentityAdmin
|
|
193
|
+
*/
|
|
194
|
+
function whitelist(
|
|
195
|
+
address _user,
|
|
196
|
+
string memory _did,
|
|
197
|
+
uint256 orgChain,
|
|
198
|
+
uint256 dateAuthenticated
|
|
199
|
+
) public onlyAdmin reimburseGas {
|
|
200
|
+
getIdentity().addWhitelistedWithDIDAndChain(
|
|
201
|
+
_user,
|
|
202
|
+
_did,
|
|
203
|
+
orgChain,
|
|
204
|
+
dateAuthenticated
|
|
205
|
+
);
|
|
175
206
|
}
|
|
176
207
|
|
|
177
208
|
/* @dev Function to remove given address from whitelist of identity contract
|
|
178
209
|
* can only be done by admins of wallet and if wallet is an IdentityAdmin
|
|
179
210
|
*/
|
|
180
211
|
function removeWhitelist(address _user) public onlyAdmin reimburseGas {
|
|
181
|
-
|
|
212
|
+
getIdentity().removeWhitelisted(_user);
|
|
182
213
|
}
|
|
183
214
|
|
|
184
215
|
/* @dev Function to add given address to blacklist of identity contract
|
|
185
216
|
* can only be done by admins of wallet and if wallet is an IdentityAdmin
|
|
186
217
|
*/
|
|
187
218
|
function blacklist(address _user) public onlyAdmin reimburseGas {
|
|
188
|
-
|
|
219
|
+
getIdentity().addBlacklisted(_user);
|
|
189
220
|
}
|
|
190
221
|
|
|
191
222
|
/* @dev Function to remove given address from blacklist of identity contract
|
|
192
223
|
* can only be done by admins of wallet and if wallet is an IdentityAdmin
|
|
193
224
|
*/
|
|
194
225
|
function removeBlacklist(address _user) public onlyAdmin reimburseGas {
|
|
195
|
-
|
|
226
|
+
getIdentity().removeBlacklisted(_user);
|
|
196
227
|
}
|
|
197
228
|
|
|
198
229
|
/* @dev Function to top given address with amount of G$ given in constructor
|
|
@@ -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
|
}
|