@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,638 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
/**
|
|
3
|
+
Wrap the G$ token to provide mint permissions to multichain.org router/bridge
|
|
4
|
+
based on https://github.com/anyswap/multichain-smart-contracts/blob/1459fe6281867319af8ffb1849e5c16d242d6530/contracts/wrapper/MintBurnWrapper.sol
|
|
5
|
+
|
|
6
|
+
Added onTokenTransfer
|
|
7
|
+
Notice: contract needs to be registered as a scheme on Controller to be able to call mintTokens
|
|
8
|
+
Fixed:
|
|
9
|
+
https://github.com/anyswap/multichain-smart-contracts/issues/4
|
|
10
|
+
https://github.com/anyswap/multichain-smart-contracts/issues/3
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
pragma solidity ^0.8;
|
|
14
|
+
|
|
15
|
+
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
|
|
16
|
+
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
|
|
17
|
+
import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol";
|
|
18
|
+
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
|
19
|
+
import "@openzeppelin/contracts/utils/math/Math.sol";
|
|
20
|
+
import "hardhat/console.sol";
|
|
21
|
+
|
|
22
|
+
import "./DAOUpgradeableContract.sol";
|
|
23
|
+
|
|
24
|
+
library TokenOperation {
|
|
25
|
+
using AddressUpgradeable for address;
|
|
26
|
+
|
|
27
|
+
function safeBurnSelf(address token, uint256 value) internal {
|
|
28
|
+
// burn(uint256)
|
|
29
|
+
_callOptionalReturn(token, abi.encodeWithSelector(0x42966c68, value));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function safeBurnFrom(
|
|
33
|
+
address token,
|
|
34
|
+
address from,
|
|
35
|
+
uint256 value
|
|
36
|
+
) internal {
|
|
37
|
+
// burnFrom(address,uint256)
|
|
38
|
+
_callOptionalReturn(token, abi.encodeWithSelector(0x79cc6790, from, value));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function _callOptionalReturn(address token, bytes memory data) private {
|
|
42
|
+
bytes memory returndata = token.functionCall(
|
|
43
|
+
data,
|
|
44
|
+
"TokenOperation: low-level call failed"
|
|
45
|
+
);
|
|
46
|
+
if (returndata.length > 0) {
|
|
47
|
+
// Return data is optional
|
|
48
|
+
require(
|
|
49
|
+
abi.decode(returndata, (bool)),
|
|
50
|
+
"TokenOperation: did not succeed"
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface IRouter {
|
|
57
|
+
function mint(address to, uint256 amount) external returns (bool);
|
|
58
|
+
|
|
59
|
+
function burn(address from, uint256 amount) external returns (bool);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
//License-Identifier: GPL-3.0-or-later
|
|
63
|
+
|
|
64
|
+
abstract contract PausableControl {
|
|
65
|
+
mapping(bytes32 => bool) private _pausedRoles;
|
|
66
|
+
|
|
67
|
+
bytes32 public constant PAUSE_ALL_ROLE = 0x00;
|
|
68
|
+
|
|
69
|
+
event Paused(bytes32 role);
|
|
70
|
+
event Unpaused(bytes32 role);
|
|
71
|
+
|
|
72
|
+
modifier whenNotPaused(bytes32 role) {
|
|
73
|
+
require(
|
|
74
|
+
!paused(role) && !paused(PAUSE_ALL_ROLE),
|
|
75
|
+
"PausableControl: paused"
|
|
76
|
+
);
|
|
77
|
+
_;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
modifier whenPaused(bytes32 role) {
|
|
81
|
+
require(
|
|
82
|
+
paused(role) || paused(PAUSE_ALL_ROLE),
|
|
83
|
+
"PausableControl: not paused"
|
|
84
|
+
);
|
|
85
|
+
_;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function paused(bytes32 role) public view virtual returns (bool) {
|
|
89
|
+
return _pausedRoles[role];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function _pause(bytes32 role) internal virtual whenNotPaused(role) {
|
|
93
|
+
_pausedRoles[role] = true;
|
|
94
|
+
emit Paused(role);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function _unpause(bytes32 role) internal virtual whenPaused(role) {
|
|
98
|
+
_pausedRoles[role] = false;
|
|
99
|
+
emit Unpaused(role);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/// @dev MintBurnWrapper has the following aims:
|
|
104
|
+
/// 1. wrap token which does not support interface `IRouter`
|
|
105
|
+
/// 2. wrap token which wants to support multiple minters
|
|
106
|
+
/// 3. add security enhancement (mint cap, pausable, etc.)
|
|
107
|
+
contract GoodDollarMintBurnWrapper is
|
|
108
|
+
IRouter,
|
|
109
|
+
AccessControlEnumerableUpgradeable,
|
|
110
|
+
PausableControl,
|
|
111
|
+
DAOUpgradeableContract
|
|
112
|
+
{
|
|
113
|
+
using SafeERC20Upgradeable for IERC20Upgradeable;
|
|
114
|
+
|
|
115
|
+
// access control roles
|
|
116
|
+
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
|
|
117
|
+
bytes32 public constant BRIDGE_ROLE = keccak256("BRIDGE_ROLE");
|
|
118
|
+
bytes32 public constant ROUTER_ROLE = keccak256("ROUTER_ROLE");
|
|
119
|
+
bytes32 public constant REWARDS_ROLE = keccak256("REWARDS_ROLE");
|
|
120
|
+
bytes32 public constant GUARDIAN_ROLE = keccak256("GUARDIAN_ROLE");
|
|
121
|
+
|
|
122
|
+
// pausable control roles
|
|
123
|
+
bytes32 public constant PAUSE_MINT_ROLE = keccak256("PAUSE_MINT_ROLE");
|
|
124
|
+
bytes32 public constant PAUSE_BURN_ROLE = keccak256("PAUSE_BURN_ROLE");
|
|
125
|
+
bytes32 public constant PAUSE_ROUTER_ROLE = keccak256("PAUSE_ROUTER_ROLE");
|
|
126
|
+
bytes32 public constant PAUSE_REWARDS_ROLE = keccak256("PAUSE_REWARDS_ROLE");
|
|
127
|
+
|
|
128
|
+
struct InLimits {
|
|
129
|
+
uint256 maxIn; // single limit of each mint
|
|
130
|
+
uint256 capIn; // total limit of all mint
|
|
131
|
+
uint256 totalIn; // total minted minus burned
|
|
132
|
+
uint128 dailyCapIn; //cap per day
|
|
133
|
+
uint128 mintedToday; //total minted today
|
|
134
|
+
uint128 lastUpdate; //last update of dailyCap
|
|
135
|
+
uint128 totalRewards; // total rewards sent (sent + minted)
|
|
136
|
+
uint32 bpsPerDayIn; //basis points relative to token supply daily limit
|
|
137
|
+
uint128 lastDayReset; //last day we reset the daily limits
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
struct OutLimits {
|
|
141
|
+
uint256 maxOut; // single limit of each burn
|
|
142
|
+
uint256 capOut; // total limit of all burn
|
|
143
|
+
uint256 totalOut; // total burned minus minted
|
|
144
|
+
uint128 dailyCapOut; //burn cap per day
|
|
145
|
+
uint128 burnedToday; //total burned today
|
|
146
|
+
uint32 bpsPerDayOut; //basis points relative to token supply daily limit
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
mapping(address => InLimits) public minterSupply;
|
|
150
|
+
uint256 public totalMintCap_unused; // total mint cap, not used, kept because of upgradable storage
|
|
151
|
+
uint256 public totalMinted; // total minted amount
|
|
152
|
+
|
|
153
|
+
address public token; // the target token this contract is wrapping
|
|
154
|
+
uint256 private unused_tokenType; //kept because of upgradable storage layout, contract already deployed to Celo contains it
|
|
155
|
+
|
|
156
|
+
uint128 public currentDay; //used to reset daily minter limit
|
|
157
|
+
uint128 public updateFrequency; //how often to update the relative to supply daily limit
|
|
158
|
+
uint128 public totalMintDebt; // total outstanding rewards mint debt
|
|
159
|
+
uint128 public totalRewards; // total rewards sent (sent + minted)
|
|
160
|
+
mapping(address => OutLimits) public minterOutLimits;
|
|
161
|
+
|
|
162
|
+
event Minted(address minter, address to, uint256 amount);
|
|
163
|
+
event Burned(address minter, address to, uint256 amount);
|
|
164
|
+
event SendOrMint(
|
|
165
|
+
address rewarder,
|
|
166
|
+
address to,
|
|
167
|
+
uint256 amount,
|
|
168
|
+
uint256 sent,
|
|
169
|
+
uint256 minted,
|
|
170
|
+
uint256 outstandingMintDebt
|
|
171
|
+
);
|
|
172
|
+
event MinterSet(
|
|
173
|
+
address minter,
|
|
174
|
+
uint256 totalMintCapIn,
|
|
175
|
+
uint256 perTxCapIn,
|
|
176
|
+
uint32 bpsIn,
|
|
177
|
+
uint256 totalMintCapOut,
|
|
178
|
+
uint256 perTxCapOut,
|
|
179
|
+
uint32 bpsOut,
|
|
180
|
+
bool rewardsRole,
|
|
181
|
+
bool isUpdate
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
event UpdateFrequencySet(uint128 newFrequency);
|
|
185
|
+
|
|
186
|
+
modifier onlyRoles(bytes32[2] memory roles) {
|
|
187
|
+
require(
|
|
188
|
+
hasRole(roles[0], _msgSender()) || hasRole(roles[1], _msgSender()),
|
|
189
|
+
"role missing"
|
|
190
|
+
);
|
|
191
|
+
_;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function initialize(address _admin, INameService _nameService)
|
|
195
|
+
external
|
|
196
|
+
initializer
|
|
197
|
+
{
|
|
198
|
+
__AccessControlEnumerable_init();
|
|
199
|
+
setDAO(_nameService);
|
|
200
|
+
require(_admin != address(0), "zero admin address");
|
|
201
|
+
token = address(nativeToken());
|
|
202
|
+
updateFrequency = 90 days;
|
|
203
|
+
_setupRole(DEFAULT_ADMIN_ROLE, avatar);
|
|
204
|
+
_setupRole(DEFAULT_ADMIN_ROLE, _admin);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function upgrade1() external {
|
|
208
|
+
if (updateFrequency == 0) {
|
|
209
|
+
updateFrequency = 90 days;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function upgrade2() external {
|
|
214
|
+
IGoodDollar(token).renounceMinter(); //moving to mint via Controller
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function decimals() external view returns (uint8) {
|
|
218
|
+
return ERC20(token).decimals();
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function name() external view returns (string memory) {
|
|
222
|
+
return ERC20(token).name();
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function symbol() external view returns (string memory) {
|
|
226
|
+
return ERC20(token).symbol();
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function balanceOf(address account) external view returns (uint256 balance) {
|
|
230
|
+
return ERC20(token).balanceOf(account);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function owner() external view returns (address) {
|
|
234
|
+
return getRoleMember(DEFAULT_ADMIN_ROLE, 0);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
@notice set how frequent to udpate rewarder daily limit based on bps out of total supply
|
|
239
|
+
@param inSeconds frequency in seconds
|
|
240
|
+
*/
|
|
241
|
+
function setUpdateFrequency(uint128 inSeconds)
|
|
242
|
+
external
|
|
243
|
+
onlyRoles([GUARDIAN_ROLE, DEFAULT_ADMIN_ROLE])
|
|
244
|
+
{
|
|
245
|
+
updateFrequency = inSeconds;
|
|
246
|
+
emit UpdateFrequencySet(inSeconds);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* @notice pause one of the functions of the wrapper (see pause roles), only dev/guardian roles can call this
|
|
251
|
+
* @param role which function to pause
|
|
252
|
+
*/
|
|
253
|
+
function pause(bytes32 role)
|
|
254
|
+
external
|
|
255
|
+
onlyRoles([GUARDIAN_ROLE, DEFAULT_ADMIN_ROLE])
|
|
256
|
+
{
|
|
257
|
+
_pause(role);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* @notice unpause one of the functions of the wrapper (see pause roles), only dev/guardian roles can call this
|
|
262
|
+
* @param role which function to unpause
|
|
263
|
+
*/
|
|
264
|
+
function unpause(bytes32 role)
|
|
265
|
+
external
|
|
266
|
+
onlyRoles([GUARDIAN_ROLE, DEFAULT_ADMIN_ROLE])
|
|
267
|
+
{
|
|
268
|
+
_unpause(role);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* @notice implement the IRouter mint required for work with multichain router. This method is used by the multichain bridge to mint new tokens on sidechain
|
|
273
|
+
* on bridge transfer from another chain. Can only be called by the ROUTER role
|
|
274
|
+
* @param to recipient
|
|
275
|
+
* @param amount amount to mint
|
|
276
|
+
*/
|
|
277
|
+
function mint(address to, uint256 amount)
|
|
278
|
+
external
|
|
279
|
+
onlyRole(MINTER_ROLE)
|
|
280
|
+
returns (bool)
|
|
281
|
+
{
|
|
282
|
+
_updateDailyLimitCap(msg.sender);
|
|
283
|
+
_mint(to, amount);
|
|
284
|
+
emit Minted(msg.sender, to, amount);
|
|
285
|
+
return true;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* @notice implement the IRouter burn required for work with multichain router. This method is used by the multichain bridge to burn tokens on sidechain
|
|
290
|
+
* on bridge transfer to other chain. Can only be called by the ROUTER role
|
|
291
|
+
* @param from sender - requires sender to first approve tokens to the wrapper or use transferAndCall
|
|
292
|
+
* @param amount amount to mint
|
|
293
|
+
*/
|
|
294
|
+
function burn(address from, uint256 amount)
|
|
295
|
+
external
|
|
296
|
+
onlyRole(MINTER_ROLE)
|
|
297
|
+
whenNotPaused(PAUSE_ROUTER_ROLE)
|
|
298
|
+
returns (bool)
|
|
299
|
+
{
|
|
300
|
+
_updateDailyLimitCap(msg.sender);
|
|
301
|
+
_burn(from, amount);
|
|
302
|
+
emit Burned(msg.sender, from, amount);
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* @notice helper function to transfer from sidechain to another chain without the need to first approve tokens for burn.
|
|
308
|
+
* sender call transferAndCall(wrapperAddress,abi.encode(recipient,target chain id))
|
|
309
|
+
* @param sender sender
|
|
310
|
+
* @param amount sent by sender
|
|
311
|
+
* @param data expected to be recipient + target chain abi encoded
|
|
312
|
+
*/
|
|
313
|
+
function onTokenTransfer(
|
|
314
|
+
address sender,
|
|
315
|
+
uint256 amount,
|
|
316
|
+
bytes memory data
|
|
317
|
+
) external returns (bool) {
|
|
318
|
+
require(msg.sender == token); //verify this was called from a token transfer
|
|
319
|
+
(address bindaddr, uint256 chainId) = abi.decode(data, (address, uint256));
|
|
320
|
+
require(chainId != 0, "zero chainId");
|
|
321
|
+
bindaddr = bindaddr != address(0) ? bindaddr : sender;
|
|
322
|
+
|
|
323
|
+
IMultichainRouter(nameService.getAddress("MULTICHAIN_ROUTER")).anySwapOut(
|
|
324
|
+
address(this),
|
|
325
|
+
bindaddr,
|
|
326
|
+
amount,
|
|
327
|
+
chainId
|
|
328
|
+
);
|
|
329
|
+
return true;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* @notice allow REWARDS_ROLE to send existing funds in balance or mint new G$ on sidechain to recipient.
|
|
334
|
+
* @param to recipient
|
|
335
|
+
* @param amount amount to send or mint. if not enough balance the rest will be minted up to the rewarder dailyLimit
|
|
336
|
+
*/
|
|
337
|
+
function sendOrMint(address to, uint256 amount)
|
|
338
|
+
external
|
|
339
|
+
onlyRole(REWARDS_ROLE)
|
|
340
|
+
whenNotPaused(PAUSE_REWARDS_ROLE)
|
|
341
|
+
returns (uint256 totalSent)
|
|
342
|
+
{
|
|
343
|
+
_updateDailyLimitCap(msg.sender);
|
|
344
|
+
|
|
345
|
+
uint256 maxMintToday = minterSupply[msg.sender].dailyCapIn == 0
|
|
346
|
+
? amount
|
|
347
|
+
: minterSupply[msg.sender].dailyCapIn -
|
|
348
|
+
minterSupply[msg.sender].mintedToday;
|
|
349
|
+
|
|
350
|
+
//calcualte how much to send and mint
|
|
351
|
+
uint256 toSend = Math.min(
|
|
352
|
+
IERC20Upgradeable(token).balanceOf(address(this)),
|
|
353
|
+
amount
|
|
354
|
+
);
|
|
355
|
+
uint256 toMint = Math.min(amount - toSend, maxMintToday);
|
|
356
|
+
// console.log("sendOrMint %s %s %s", toMint, toSend, maxMintToday);
|
|
357
|
+
totalSent = toSend + toMint;
|
|
358
|
+
minterSupply[msg.sender].totalRewards += uint128(totalSent);
|
|
359
|
+
totalRewards += uint128(totalSent);
|
|
360
|
+
totalMintDebt += uint128(toMint);
|
|
361
|
+
if (toMint > 0) _mint(to, toMint);
|
|
362
|
+
|
|
363
|
+
if (toSend > 0) {
|
|
364
|
+
IERC20Upgradeable(token).safeTransfer(to, toSend);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
if (toMint == 0) {
|
|
368
|
+
//if we are not minting then we might have positive balance, check if we can cover out debt and burn some
|
|
369
|
+
//from balance in exchange for what we minted in the past ie mintDebt
|
|
370
|
+
_balanceDebt();
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
emit SendOrMint(_msgSender(), to, amount, toSend, toMint, totalMintDebt);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* @notice add minter or rewards role
|
|
378
|
+
* @param minter address of minter
|
|
379
|
+
* @param globalLimitIn minter global limit
|
|
380
|
+
* @param perTxLimitIn minter per tx limit
|
|
381
|
+
* @param bpsPerDayIn limit for rewards role in bps relative to G$ total supply
|
|
382
|
+
* @param globalLimitOut minter global limit
|
|
383
|
+
* @param perTxLimitOut minter per tx limit
|
|
384
|
+
* @param bpsPerDayOut limit for rewards role in bps relative to G$ total supply
|
|
385
|
+
* @param withRewardsRole should also grant REWARDS_ROLE to minter
|
|
386
|
+
*/
|
|
387
|
+
function addMinter(
|
|
388
|
+
address minter,
|
|
389
|
+
uint256 globalLimitIn,
|
|
390
|
+
uint256 perTxLimitIn,
|
|
391
|
+
uint32 bpsPerDayIn,
|
|
392
|
+
uint256 globalLimitOut,
|
|
393
|
+
uint256 perTxLimitOut,
|
|
394
|
+
uint32 bpsPerDayOut,
|
|
395
|
+
bool withRewardsRole
|
|
396
|
+
) external onlyRole(DEFAULT_ADMIN_ROLE) {
|
|
397
|
+
if (withRewardsRole) {
|
|
398
|
+
grantRole(REWARDS_ROLE, minter);
|
|
399
|
+
revokeRole(MINTER_ROLE, minter);
|
|
400
|
+
} else {
|
|
401
|
+
grantRole(MINTER_ROLE, minter);
|
|
402
|
+
revokeRole(REWARDS_ROLE, minter);
|
|
403
|
+
}
|
|
404
|
+
_setMinterCaps(
|
|
405
|
+
minter,
|
|
406
|
+
globalLimitIn,
|
|
407
|
+
perTxLimitIn,
|
|
408
|
+
bpsPerDayIn,
|
|
409
|
+
globalLimitOut,
|
|
410
|
+
perTxLimitOut,
|
|
411
|
+
bpsPerDayOut
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* @notice update minter or rewards role limits
|
|
417
|
+
* @param minter address of minter
|
|
418
|
+
* @param globalLimitIn minter global limit
|
|
419
|
+
* @param perTxLimitIn minter per tx limit
|
|
420
|
+
* @param bpsPerDayIn limit for rewards role in bps relative to G$ total supply
|
|
421
|
+
* @param globalLimitOut minter global limit
|
|
422
|
+
* @param perTxLimitOut minter per tx limit
|
|
423
|
+
* @param bpsPerDayOut limit for rewards role in bps relative to G$ total supply
|
|
424
|
+
*/
|
|
425
|
+
function setMinterCaps(
|
|
426
|
+
address minter,
|
|
427
|
+
uint256 globalLimitIn,
|
|
428
|
+
uint256 perTxLimitIn,
|
|
429
|
+
uint32 bpsPerDayIn,
|
|
430
|
+
uint256 globalLimitOut,
|
|
431
|
+
uint256 perTxLimitOut,
|
|
432
|
+
uint32 bpsPerDayOut
|
|
433
|
+
) external onlyRoles([GUARDIAN_ROLE, DEFAULT_ADMIN_ROLE]) {
|
|
434
|
+
_setMinterCaps(
|
|
435
|
+
minter,
|
|
436
|
+
globalLimitIn,
|
|
437
|
+
perTxLimitIn,
|
|
438
|
+
bpsPerDayIn,
|
|
439
|
+
globalLimitOut,
|
|
440
|
+
perTxLimitOut,
|
|
441
|
+
bpsPerDayOut
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* @notice update minter or rewards role limits
|
|
447
|
+
* @param minter address of minter
|
|
448
|
+
* @param globalLimitIn minter global limit
|
|
449
|
+
* @param perTxLimitIn minter per tx limit
|
|
450
|
+
* @param bpsPerDayIn limit for rewards role in bps relative to G$ total supply
|
|
451
|
+
* @param globalLimitOut minter global limit
|
|
452
|
+
* @param perTxLimitOut minter per tx limit
|
|
453
|
+
* @param bpsPerDayOut limit for rewards role in bps relative to G$ total supply
|
|
454
|
+
*/
|
|
455
|
+
function _setMinterCaps(
|
|
456
|
+
address minter,
|
|
457
|
+
uint256 globalLimitIn,
|
|
458
|
+
uint256 perTxLimitIn,
|
|
459
|
+
uint32 bpsPerDayIn,
|
|
460
|
+
uint256 globalLimitOut,
|
|
461
|
+
uint256 perTxLimitOut,
|
|
462
|
+
uint32 bpsPerDayOut
|
|
463
|
+
) internal {
|
|
464
|
+
InLimits storage m = minterSupply[minter];
|
|
465
|
+
OutLimits storage o = minterOutLimits[minter];
|
|
466
|
+
bool isUpdate = m.lastUpdate > 0;
|
|
467
|
+
bool withRewardsRole = hasRole(REWARDS_ROLE, minter);
|
|
468
|
+
m.capIn = globalLimitIn;
|
|
469
|
+
m.maxIn = perTxLimitIn;
|
|
470
|
+
m.bpsPerDayIn = bpsPerDayIn;
|
|
471
|
+
m.lastUpdate = uint128(block.timestamp);
|
|
472
|
+
m.dailyCapIn =
|
|
473
|
+
uint128(IERC20Upgradeable(token).totalSupply() * bpsPerDayIn) /
|
|
474
|
+
10000;
|
|
475
|
+
o.dailyCapOut =
|
|
476
|
+
uint128(IERC20Upgradeable(token).totalSupply() * bpsPerDayOut) /
|
|
477
|
+
10000;
|
|
478
|
+
o.capOut = globalLimitOut;
|
|
479
|
+
o.maxOut = perTxLimitOut;
|
|
480
|
+
o.bpsPerDayOut = bpsPerDayOut;
|
|
481
|
+
|
|
482
|
+
emit MinterSet(
|
|
483
|
+
minter,
|
|
484
|
+
globalLimitIn,
|
|
485
|
+
perTxLimitIn,
|
|
486
|
+
bpsPerDayIn,
|
|
487
|
+
globalLimitOut,
|
|
488
|
+
perTxLimitOut,
|
|
489
|
+
bpsPerDayOut,
|
|
490
|
+
withRewardsRole,
|
|
491
|
+
isUpdate
|
|
492
|
+
);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* @notice helper to update the current day, used to reset rewards role daily limit
|
|
497
|
+
*/
|
|
498
|
+
function _updateCurrentDay() internal {
|
|
499
|
+
currentDay = uint128(block.timestamp / 1 days);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* @notice helper for mint/sendOrMint action
|
|
504
|
+
*/
|
|
505
|
+
function _mint(address to, uint256 amount)
|
|
506
|
+
internal
|
|
507
|
+
whenNotPaused(PAUSE_MINT_ROLE)
|
|
508
|
+
{
|
|
509
|
+
require(to != address(this), "mint to self");
|
|
510
|
+
|
|
511
|
+
require(
|
|
512
|
+
minterSupply[msg.sender].maxIn == 0 ||
|
|
513
|
+
amount <= minterSupply[msg.sender].maxIn,
|
|
514
|
+
"minter max exceeded"
|
|
515
|
+
);
|
|
516
|
+
require(
|
|
517
|
+
minterSupply[msg.sender].dailyCapIn == 0 ||
|
|
518
|
+
minterSupply[msg.sender].dailyCapIn >=
|
|
519
|
+
(minterSupply[msg.sender].mintedToday + amount),
|
|
520
|
+
"minter daily cap exceeded"
|
|
521
|
+
);
|
|
522
|
+
|
|
523
|
+
minterSupply[msg.sender].mintedToday += uint128(amount);
|
|
524
|
+
minterSupply[msg.sender].totalIn += amount;
|
|
525
|
+
require(
|
|
526
|
+
minterSupply[msg.sender].capIn == 0 ||
|
|
527
|
+
minterSupply[msg.sender].totalIn <= minterSupply[msg.sender].capIn,
|
|
528
|
+
"minter cap exceeded"
|
|
529
|
+
);
|
|
530
|
+
|
|
531
|
+
totalMinted += amount;
|
|
532
|
+
|
|
533
|
+
if (minterOutLimits[msg.sender].totalOut >= amount) {
|
|
534
|
+
minterOutLimits[msg.sender].totalOut -= amount;
|
|
535
|
+
} else {
|
|
536
|
+
minterOutLimits[msg.sender].totalOut = 0;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
bool ok = dao.mintTokens(amount, to, avatar);
|
|
540
|
+
require(ok, "mint failed");
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* @notice helper for burn action
|
|
545
|
+
*/
|
|
546
|
+
function _burn(address from, uint256 amount)
|
|
547
|
+
internal
|
|
548
|
+
whenNotPaused(PAUSE_BURN_ROLE)
|
|
549
|
+
{
|
|
550
|
+
require(
|
|
551
|
+
minterOutLimits[msg.sender].maxOut == 0 ||
|
|
552
|
+
amount <= minterOutLimits[msg.sender].maxOut,
|
|
553
|
+
"minter burn max exceeded"
|
|
554
|
+
);
|
|
555
|
+
require(
|
|
556
|
+
minterOutLimits[msg.sender].dailyCapOut == 0 ||
|
|
557
|
+
minterOutLimits[msg.sender].dailyCapOut >=
|
|
558
|
+
(minterOutLimits[msg.sender].burnedToday + amount),
|
|
559
|
+
"minter burn daily cap exceeded"
|
|
560
|
+
);
|
|
561
|
+
|
|
562
|
+
minterOutLimits[msg.sender].burnedToday += uint128(amount);
|
|
563
|
+
minterOutLimits[msg.sender].totalOut += amount;
|
|
564
|
+
require(
|
|
565
|
+
minterOutLimits[msg.sender].capOut == 0 ||
|
|
566
|
+
minterOutLimits[msg.sender].totalOut <=
|
|
567
|
+
minterOutLimits[msg.sender].capOut,
|
|
568
|
+
"minter cap exceeded"
|
|
569
|
+
);
|
|
570
|
+
|
|
571
|
+
//update stats correctly, but dont fail if it tries to transfer tokens minted elsewhere as long as we burn some
|
|
572
|
+
if (totalMinted >= amount) {
|
|
573
|
+
totalMinted -= amount;
|
|
574
|
+
} else {
|
|
575
|
+
totalMinted = 0;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
if (minterSupply[msg.sender].totalIn >= amount) {
|
|
579
|
+
minterSupply[msg.sender].totalIn -= amount;
|
|
580
|
+
} else {
|
|
581
|
+
minterSupply[msg.sender].totalIn = 0;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
//handle onTokenTransfer (ERC677), assume tokens has been transfered
|
|
585
|
+
if (from == address(this)) {
|
|
586
|
+
TokenOperation.safeBurnSelf(token, amount);
|
|
587
|
+
} else {
|
|
588
|
+
TokenOperation.safeBurnFrom(token, from, amount);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* @notice helper for sendOrMint action to burn from balance to cover minting debt
|
|
594
|
+
*/
|
|
595
|
+
function _balanceDebt() internal {
|
|
596
|
+
uint256 toBurn = Math.min(
|
|
597
|
+
totalMintDebt,
|
|
598
|
+
IERC20Upgradeable(token).balanceOf(address(this))
|
|
599
|
+
);
|
|
600
|
+
|
|
601
|
+
if (toBurn > 0) {
|
|
602
|
+
totalMintDebt -= uint128(toBurn);
|
|
603
|
+
totalMinted -= toBurn;
|
|
604
|
+
ERC20(token).burn(toBurn); //from DAOUpgradableContract -> Interfaces
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* @notice helper for sendOrMint action to update the rewarder daily limit if updateFrequency passed
|
|
610
|
+
*/
|
|
611
|
+
function _updateDailyLimitCap(address minter) internal {
|
|
612
|
+
uint256 secondsPassed = block.timestamp - minterSupply[minter].lastUpdate;
|
|
613
|
+
uint256 totalSupply = IERC20Upgradeable(token).totalSupply();
|
|
614
|
+
if (secondsPassed >= updateFrequency) {
|
|
615
|
+
minterSupply[minter].dailyCapIn = uint128(
|
|
616
|
+
(totalSupply * minterSupply[minter].bpsPerDayIn) / 10000
|
|
617
|
+
);
|
|
618
|
+
minterOutLimits[minter].dailyCapOut = uint128(
|
|
619
|
+
(totalSupply * minterOutLimits[minter].bpsPerDayOut) / 10000
|
|
620
|
+
);
|
|
621
|
+
minterSupply[minter].lastUpdate = uint128(block.timestamp);
|
|
622
|
+
// console.log(
|
|
623
|
+
// "secondsPassed %s %s %s",
|
|
624
|
+
// secondsPassed,
|
|
625
|
+
// minter.dailyCap,
|
|
626
|
+
// minter.lastUpdate
|
|
627
|
+
// );
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
//check if daily limit needs reset
|
|
631
|
+
_updateCurrentDay();
|
|
632
|
+
if (currentDay != minterSupply[minter].lastDayReset) {
|
|
633
|
+
minterSupply[minter].mintedToday = 0;
|
|
634
|
+
minterOutLimits[minter].burnedToday = 0;
|
|
635
|
+
minterSupply[minter].lastDayReset = currentDay;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
/**
|
|
3
|
+
ethereum only helper to use transferAndCall for single tx (without user approve) to bridge over multichain
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
pragma solidity ^0.8;
|
|
7
|
+
|
|
8
|
+
import "../Interfaces.sol";
|
|
9
|
+
|
|
10
|
+
contract MultichainBridgeHelper {
|
|
11
|
+
IMultichainRouter public constant multiChainBridge =
|
|
12
|
+
IMultichainRouter(0x765277EebeCA2e31912C9946eAe1021199B39C61);
|
|
13
|
+
address public constant anyGoodDollar =
|
|
14
|
+
address(0xD17652350Cfd2A37bA2f947C910987a3B1A1c60d);
|
|
15
|
+
address public constant goodDollar =
|
|
16
|
+
address(0x67C5870b4A41D4Ebef24d2456547A03F1f3e094B);
|
|
17
|
+
|
|
18
|
+
function onTokenTransfer(
|
|
19
|
+
address sender,
|
|
20
|
+
uint256 amount,
|
|
21
|
+
bytes calldata data
|
|
22
|
+
) external returns (bool) {
|
|
23
|
+
require(msg.sender == goodDollar); //verify this was called from a token transfer
|
|
24
|
+
(address bindaddr, uint256 chainId) = abi.decode(data, (address, uint256));
|
|
25
|
+
require(chainId != 0, "zero chainId");
|
|
26
|
+
bindaddr = bindaddr != address(0) ? bindaddr : sender;
|
|
27
|
+
|
|
28
|
+
ERC20(goodDollar).approve(address(multiChainBridge), amount);
|
|
29
|
+
|
|
30
|
+
multiChainBridge.anySwapOutUnderlying(
|
|
31
|
+
anyGoodDollar,
|
|
32
|
+
bindaddr,
|
|
33
|
+
amount,
|
|
34
|
+
chainId
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
}
|
package/hardhat.config.ts
CHANGED
|
@@ -79,7 +79,7 @@ const hhconfig: HardhatUserConfig = {
|
|
|
79
79
|
accounts: {
|
|
80
80
|
accountsBalance: "10000000000000000000000000"
|
|
81
81
|
},
|
|
82
|
-
initialDate: "2021-12-01"
|
|
82
|
+
initialDate: "2021-12-01" //required for DAO tests like guardian
|
|
83
83
|
},
|
|
84
84
|
test: {
|
|
85
85
|
allowUnlimitedContractSize: true,
|
|
@@ -292,7 +292,9 @@ task(
|
|
|
292
292
|
task("cleanflat", "Cleans multiple SPDX and Pragma from flattened file")
|
|
293
293
|
.addPositionalParam("file", "flattened sol file")
|
|
294
294
|
.setAction(async ({ file }, { run }) => {
|
|
295
|
-
let flattened =
|
|
295
|
+
let flattened = await run("flatten:get-flattened-sources", {
|
|
296
|
+
files: [file]
|
|
297
|
+
});
|
|
296
298
|
|
|
297
299
|
// Remove every line started with "// SPDX-License-Identifier:"
|
|
298
300
|
flattened = flattened.replace(
|
|
@@ -319,5 +321,5 @@ task("cleanflat", "Cleans multiple SPDX and Pragma from flattened file")
|
|
|
319
321
|
);
|
|
320
322
|
|
|
321
323
|
flattened = flattened.trim();
|
|
322
|
-
writeFileSync(
|
|
324
|
+
writeFileSync("flat.sol", flattened);
|
|
323
325
|
});
|