@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.
Files changed (352) hide show
  1. package/artifacts/abis/BulkProof.min.json +1 -1
  2. package/artifacts/abis/DistributionBridgeMock.min.json +1 -0
  3. package/artifacts/abis/DistributionHelper.min.json +1 -0
  4. package/artifacts/abis/DistributionHelperTest.min.json +1 -0
  5. package/artifacts/abis/DistributionHelperTestHelper.min.json +1 -0
  6. package/artifacts/abis/ERC20.min.json +1 -1
  7. package/artifacts/abis/GoodDollarMintBurnWrapper.min.json +1 -0
  8. package/artifacts/abis/GoodDollarStaking.min.json +1 -0
  9. package/artifacts/abis/GoodDollarStakingMock.min.json +1 -0
  10. package/artifacts/abis/GoodReserveCDai.min.json +1 -1
  11. package/artifacts/abis/IERC2917.min.json +1 -1
  12. package/artifacts/abis/IGoodDollarStakingTest.min.json +1 -0
  13. package/artifacts/abis/IMultichainRouter.min.json +1 -0
  14. package/artifacts/abis/IRouter.min.json +1 -0
  15. package/artifacts/abis/IWrapper.min.json +1 -0
  16. package/artifacts/abis/Math64x64.min.json +1 -0
  17. package/artifacts/abis/MultichainBridgeHelper.min.json +1 -0
  18. package/artifacts/abis/MultichainRouterMock.min.json +1 -0
  19. package/artifacts/abis/OverMintTester.min.json +1 -1
  20. package/artifacts/abis/PausableControl.min.json +1 -0
  21. package/artifacts/abis/RewardsMinter.min.json +1 -0
  22. package/artifacts/abis/StakingMockFixedAPY.min.json +1 -0
  23. package/artifacts/abis/StakingRewardsFixedAPY.min.json +1 -0
  24. package/artifacts/abis/TokenOperation.min.json +1 -0
  25. package/artifacts/abis/cERC20.min.json +1 -1
  26. package/artifacts/contracts/DAOStackInterfaces.sol/Avatar.dbg.json +1 -1
  27. package/artifacts/contracts/DAOStackInterfaces.sol/Controller.dbg.json +1 -1
  28. package/artifacts/contracts/DAOStackInterfaces.sol/GlobalConstraintInterface.dbg.json +1 -1
  29. package/artifacts/contracts/DAOStackInterfaces.sol/IntVoteInterface.dbg.json +1 -1
  30. package/artifacts/contracts/DAOStackInterfaces.sol/ReputationInterface.dbg.json +1 -1
  31. package/artifacts/contracts/DAOStackInterfaces.sol/SchemeRegistrar.dbg.json +1 -1
  32. package/artifacts/contracts/Interfaces.sol/AggregatorV3Interface.dbg.json +1 -1
  33. package/artifacts/contracts/Interfaces.sol/ERC20.dbg.json +1 -1
  34. package/artifacts/contracts/Interfaces.sol/ERC20.json +13 -0
  35. package/artifacts/contracts/Interfaces.sol/IAaveIncentivesController.dbg.json +1 -1
  36. package/artifacts/contracts/Interfaces.sol/IAdminWallet.dbg.json +1 -1
  37. package/artifacts/contracts/Interfaces.sol/IDonationStaking.dbg.json +1 -1
  38. package/artifacts/contracts/Interfaces.sol/IERC2917.dbg.json +1 -1
  39. package/artifacts/contracts/Interfaces.sol/IERC2917.json +13 -0
  40. package/artifacts/contracts/Interfaces.sol/IFirstClaimPool.dbg.json +1 -1
  41. package/artifacts/contracts/Interfaces.sol/IGoodDollar.dbg.json +1 -1
  42. package/artifacts/contracts/Interfaces.sol/IGoodStaking.dbg.json +1 -1
  43. package/artifacts/contracts/Interfaces.sol/IHasRouter.dbg.json +1 -1
  44. package/artifacts/contracts/Interfaces.sol/IIdentity.dbg.json +1 -1
  45. package/artifacts/contracts/Interfaces.sol/ILendingPool.dbg.json +1 -1
  46. package/artifacts/contracts/Interfaces.sol/IMultichainRouter.dbg.json +4 -0
  47. package/artifacts/contracts/Interfaces.sol/IMultichainRouter.json +67 -0
  48. package/artifacts/contracts/Interfaces.sol/INameService.dbg.json +1 -1
  49. package/artifacts/contracts/Interfaces.sol/IUBIScheme.dbg.json +1 -1
  50. package/artifacts/contracts/Interfaces.sol/ProxyAdmin.dbg.json +1 -1
  51. package/artifacts/contracts/Interfaces.sol/Reserve.dbg.json +1 -1
  52. package/artifacts/contracts/Interfaces.sol/Staking.dbg.json +1 -1
  53. package/artifacts/contracts/Interfaces.sol/Uniswap.dbg.json +1 -1
  54. package/artifacts/contracts/Interfaces.sol/UniswapFactory.dbg.json +1 -1
  55. package/artifacts/contracts/Interfaces.sol/UniswapPair.dbg.json +1 -1
  56. package/artifacts/contracts/Interfaces.sol/cERC20.dbg.json +1 -1
  57. package/artifacts/contracts/Interfaces.sol/cERC20.json +13 -0
  58. package/artifacts/contracts/fuseFaucet/FuseFaucet.sol/FuseFaucet.dbg.json +1 -1
  59. package/artifacts/contracts/fuseFaucet/FuseFaucet.sol/FuseFaucet.json +2 -2
  60. package/artifacts/contracts/governance/ClaimersDistribution.sol/ClaimersDistribution.dbg.json +1 -1
  61. package/artifacts/contracts/governance/ClaimersDistribution.sol/ClaimersDistribution.json +2 -2
  62. package/artifacts/contracts/governance/CompoundVotingMachine.sol/CompoundVotingMachine.dbg.json +1 -1
  63. package/artifacts/contracts/governance/CompoundVotingMachine.sol/CompoundVotingMachine.json +2 -2
  64. package/artifacts/contracts/governance/GReputation.sol/GReputation.dbg.json +1 -1
  65. package/artifacts/contracts/governance/GReputation.sol/GReputation.json +2 -2
  66. package/artifacts/contracts/governance/GoodDollarStaking.sol/GoodDollarStaking.dbg.json +4 -0
  67. package/artifacts/contracts/governance/GoodDollarStaking.sol/GoodDollarStaking.json +1322 -0
  68. package/artifacts/contracts/governance/GoodDollarStaking.sol/RewardsMinter.dbg.json +4 -0
  69. package/artifacts/contracts/governance/GoodDollarStaking.sol/RewardsMinter.json +35 -0
  70. package/artifacts/contracts/governance/GovernanceStaking.sol/GovernanceStaking.dbg.json +1 -1
  71. package/artifacts/contracts/governance/GovernanceStaking.sol/GovernanceStaking.json +2 -2
  72. package/artifacts/contracts/governance/MultiBaseGovernanceShareField.sol/MultiBaseGovernanceShareField.dbg.json +1 -1
  73. package/artifacts/contracts/governance/Reputation.sol/Reputation.dbg.json +1 -1
  74. package/artifacts/contracts/governance/Reputation.sol/Reputation.json +2 -2
  75. package/artifacts/contracts/governance/StakersDistribution.sol/StakersDistribution.dbg.json +1 -1
  76. package/artifacts/contracts/governance/StakersDistribution.sol/StakersDistribution.json +2 -2
  77. package/artifacts/contracts/invite/InvitesV1.sol/InvitesV1.dbg.json +1 -1
  78. package/artifacts/contracts/invite/InvitesV1.sol/InvitesV1.json +2 -2
  79. package/artifacts/contracts/mocks/AaveMock.sol/AaveMock.dbg.json +1 -1
  80. package/artifacts/contracts/mocks/DAIMock.sol/DAIMock.dbg.json +1 -1
  81. package/artifacts/contracts/mocks/DecimalsMock.sol/DecimalsMock.dbg.json +1 -1
  82. package/artifacts/contracts/mocks/DistributionBridgeMock.sol/DistributionBridgeMock.dbg.json +4 -0
  83. package/artifacts/contracts/mocks/DistributionBridgeMock.sol/DistributionBridgeMock.json +152 -0
  84. package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTest.dbg.json +4 -0
  85. package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTest.json +662 -0
  86. package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTestHelper.dbg.json +4 -0
  87. package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTestHelper.json +680 -0
  88. package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.dbg.json +1 -1
  89. package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.json +2 -2
  90. package/artifacts/contracts/mocks/GoodDollarStakingMock.sol/GoodDollarStakingMock.dbg.json +4 -0
  91. package/artifacts/contracts/mocks/GoodDollarStakingMock.sol/GoodDollarStakingMock.json +1322 -0
  92. package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.dbg.json +1 -1
  93. package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.json +2 -2
  94. package/artifacts/contracts/mocks/IncentiveControllerMock.sol/IncentiveControllerMock.dbg.json +1 -1
  95. package/artifacts/contracts/mocks/LendingPoolMock.sol/LendingPoolMock.dbg.json +1 -1
  96. package/artifacts/contracts/mocks/MultichainRouterMock.sol/IWrapper.dbg.json +4 -0
  97. package/artifacts/contracts/mocks/MultichainRouterMock.sol/IWrapper.json +59 -0
  98. package/artifacts/contracts/mocks/MultichainRouterMock.sol/MultichainRouterMock.dbg.json +4 -0
  99. package/artifacts/contracts/mocks/MultichainRouterMock.sol/MultichainRouterMock.json +81 -0
  100. package/artifacts/contracts/mocks/OverMintTester.sol/IGoodDollarStakingTest.dbg.json +4 -0
  101. package/artifacts/contracts/mocks/OverMintTester.sol/IGoodDollarStakingTest.json +49 -0
  102. package/artifacts/contracts/mocks/OverMintTester.sol/OverMintTester.dbg.json +1 -1
  103. package/artifacts/contracts/mocks/OverMintTester.sol/OverMintTester.json +4 -4
  104. package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.dbg.json +1 -1
  105. package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.json +2 -2
  106. package/artifacts/contracts/mocks/SixteenDecimalsTokenMock.sol/SixteenDecimalsTokenMock.dbg.json +1 -1
  107. package/artifacts/contracts/mocks/StakingMockFixedAPY.sol/StakingMockFixedAPY.dbg.json +4 -0
  108. package/artifacts/contracts/mocks/StakingMockFixedAPY.sol/StakingMockFixedAPY.json +682 -0
  109. package/artifacts/contracts/mocks/SwapHelperTest.sol/SwapHelperTest.dbg.json +1 -1
  110. package/artifacts/contracts/mocks/SwapHelperTest.sol/SwapHelperTest.json +2 -2
  111. package/artifacts/contracts/mocks/TwentyDecimalsTokenMock.sol/TwentyDecimalsTokenMock.dbg.json +1 -1
  112. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock.dbg.json +1 -1
  113. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock.json +2 -2
  114. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock2.dbg.json +1 -1
  115. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock2.json +2 -2
  116. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock3.dbg.json +1 -1
  117. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock3.json +2 -2
  118. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock4.dbg.json +1 -1
  119. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock4.json +2 -2
  120. package/artifacts/contracts/mocks/UsdcMock.sol/USDCMock.dbg.json +1 -1
  121. package/artifacts/contracts/mocks/cBATMock.sol/cBATMock.dbg.json +1 -1
  122. package/artifacts/contracts/mocks/cDAILowWorthMock.sol/cDAILowWorthMock.dbg.json +1 -1
  123. package/artifacts/contracts/mocks/cDAIMock.sol/cDAIMock.dbg.json +1 -1
  124. package/artifacts/contracts/mocks/cDAINonMintableMock.sol/cDAINonMintableMock.dbg.json +1 -1
  125. package/artifacts/contracts/mocks/cDecimalsMock.sol/cDecimalsMock.dbg.json +1 -1
  126. package/artifacts/contracts/mocks/cSDTMock.sol/cSDTMock.dbg.json +1 -1
  127. package/artifacts/contracts/mocks/cUSDCMock.sol/cUSDCMock.dbg.json +1 -1
  128. package/artifacts/contracts/reserve/DistributionHelper.sol/DistributionHelper.dbg.json +4 -0
  129. package/artifacts/contracts/reserve/DistributionHelper.sol/DistributionHelper.json +662 -0
  130. package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.dbg.json +1 -1
  131. package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.json +2 -2
  132. package/artifacts/contracts/reserve/GoodMarketMaker.sol/GoodMarketMaker.dbg.json +1 -1
  133. package/artifacts/contracts/reserve/GoodMarketMaker.sol/GoodMarketMaker.json +2 -2
  134. package/artifacts/contracts/reserve/GoodReserveCDai.sol/ContributionCalc.dbg.json +1 -1
  135. package/artifacts/contracts/reserve/GoodReserveCDai.sol/GoodReserveCDai.dbg.json +1 -1
  136. package/artifacts/contracts/reserve/GoodReserveCDai.sol/GoodReserveCDai.json +75 -35
  137. package/artifacts/contracts/staking/BaseShareField.sol/BaseShareField.dbg.json +1 -1
  138. package/artifacts/contracts/staking/BaseShareField.sol/BaseShareField.json +2 -2
  139. package/artifacts/contracts/staking/BaseShareFieldV2.sol/BaseShareFieldV2.dbg.json +1 -1
  140. package/artifacts/contracts/staking/BaseShareFieldV2.sol/BaseShareFieldV2.json +2 -2
  141. package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.dbg.json +1 -1
  142. package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.json +2 -2
  143. package/artifacts/contracts/staking/FuseStakingV3.sol/FuseStakingV3.dbg.json +1 -1
  144. package/artifacts/contracts/staking/FuseStakingV3.sol/FuseStakingV3.json +2 -2
  145. package/artifacts/contracts/staking/FuseStakingV3.sol/IConsensus.dbg.json +1 -1
  146. package/artifacts/contracts/staking/FuseStakingV3.sol/PegSwap.dbg.json +1 -1
  147. package/artifacts/contracts/staking/GoodFundManager.sol/GoodFundManager.dbg.json +1 -1
  148. package/artifacts/contracts/staking/GoodFundManager.sol/GoodFundManager.json +2 -2
  149. package/artifacts/contracts/staking/SimpleStaking.sol/SimpleStaking.dbg.json +1 -1
  150. package/artifacts/contracts/staking/SimpleStakingV2.sol/SimpleStakingV2.dbg.json +1 -1
  151. package/artifacts/contracts/staking/UniswapV2SwapHelper.sol/UniswapV2SwapHelper.dbg.json +1 -1
  152. package/artifacts/contracts/staking/UniswapV2SwapHelper.sol/UniswapV2SwapHelper.json +2 -2
  153. package/artifacts/contracts/staking/aave/AaveStakingFactory.sol/AaveStakingFactory.dbg.json +1 -1
  154. package/artifacts/contracts/staking/aave/AaveStakingFactory.sol/AaveStakingFactory.json +2 -2
  155. package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.dbg.json +1 -1
  156. package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.json +2 -2
  157. package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.dbg.json +1 -1
  158. package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.json +2 -2
  159. package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.dbg.json +1 -1
  160. package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.json +2 -2
  161. package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.dbg.json +1 -1
  162. package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.json +2 -2
  163. package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.dbg.json +1 -1
  164. package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.json +2 -2
  165. package/artifacts/contracts/staking/utils/Math64X64.sol/Math64x64.dbg.json +4 -0
  166. package/artifacts/contracts/staking/utils/Math64X64.sol/Math64x64.json +10 -0
  167. package/artifacts/contracts/staking/utils/StakingRewardsFixedAPY.sol/StakingRewardsFixedAPY.dbg.json +4 -0
  168. package/artifacts/contracts/staking/utils/StakingRewardsFixedAPY.sol/StakingRewardsFixedAPY.json +268 -0
  169. package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.dbg.json +1 -1
  170. package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.json +2 -2
  171. package/artifacts/contracts/utils/AdminWallet.sol/AdminWallet.dbg.json +1 -1
  172. package/artifacts/contracts/utils/AdminWallet.sol/AdminWallet.json +2 -2
  173. package/artifacts/contracts/utils/BancorFormula.sol/BancorFormula.dbg.json +1 -1
  174. package/artifacts/contracts/utils/BulkProof.sol/BulkProof.dbg.json +1 -1
  175. package/artifacts/contracts/utils/BulkProof.sol/BulkProof.json +3 -34
  176. package/artifacts/contracts/utils/DAOContract.sol/DAOContract.dbg.json +1 -1
  177. package/artifacts/contracts/utils/DAOContract.sol/DAOContract.json +2 -2
  178. package/artifacts/contracts/utils/DAOUpgradeableContract.sol/DAOUpgradeableContract.dbg.json +1 -1
  179. package/artifacts/contracts/utils/DAOUpgradeableContract.sol/DAOUpgradeableContract.json +2 -2
  180. package/artifacts/contracts/utils/DSMath.sol/DSMath.dbg.json +1 -1
  181. package/artifacts/contracts/utils/DataTypes.sol/DataTypes.dbg.json +1 -1
  182. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/GoodDollarMintBurnWrapper.dbg.json +4 -0
  183. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/GoodDollarMintBurnWrapper.json +1263 -0
  184. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/IRouter.dbg.json +4 -0
  185. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/IRouter.json +59 -0
  186. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/PausableControl.dbg.json +4 -0
  187. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/PausableControl.json +69 -0
  188. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/TokenOperation.dbg.json +4 -0
  189. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/TokenOperation.json +10 -0
  190. package/artifacts/contracts/utils/MultichainBridgeHelper.sol/MultichainBridgeHelper.dbg.json +4 -0
  191. package/artifacts/contracts/utils/MultichainBridgeHelper.sol/MultichainBridgeHelper.json +79 -0
  192. package/artifacts/contracts/utils/NameService.sol/NameService.dbg.json +1 -1
  193. package/artifacts/contracts/utils/ProtocolUpgrade.sol/OldMarketMaker.dbg.json +1 -1
  194. package/artifacts/contracts/utils/ProtocolUpgrade.sol/ProtocolUpgrade.dbg.json +1 -1
  195. package/artifacts/contracts/utils/ProtocolUpgrade.sol/ProtocolUpgrade.json +2 -2
  196. package/artifacts/contracts/utils/ProtocolUpgradeFuse.sol/ProtocolUpgradeFuse.dbg.json +1 -1
  197. package/artifacts/contracts/utils/ProtocolUpgradeFuse.sol/ProtocolUpgradeFuse.json +2 -2
  198. package/artifacts/contracts/utils/ProtocolUpgradeFuseRecover.sol/ProtocolUpgradeFuseRecover.dbg.json +1 -1
  199. package/artifacts/contracts/utils/ProtocolUpgradeFuseRecover.sol/ProtocolUpgradeFuseRecover.json +2 -2
  200. package/artifacts/contracts/utils/ProtocolUpgradeRecover.sol/ProtocolUpgradeRecover.dbg.json +1 -1
  201. package/artifacts/contracts/utils/ProtocolUpgradeRecover.sol/ProtocolUpgradeRecover.json +2 -2
  202. package/artifacts/contracts/utils/ProxyFactory1967.sol/ERC1967Proxy.dbg.json +1 -1
  203. package/artifacts/contracts/utils/ProxyFactory1967.sol/ProxyFactory1967.dbg.json +1 -1
  204. package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.dbg.json +1 -1
  205. package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.json +2 -2
  206. package/contracts/Interfaces.sol +20 -0
  207. package/contracts/governance/GoodDollarStaking.sol +510 -0
  208. package/contracts/governance/MultiBaseGovernanceShareField.sol +1 -0
  209. package/contracts/mocks/DistributionBridgeMock.sol +50 -0
  210. package/contracts/mocks/DistributionHelperTest.sol +22 -0
  211. package/contracts/mocks/GoodDollarStakingMock.sol +24 -0
  212. package/contracts/mocks/MultichainRouterMock.sol +38 -0
  213. package/contracts/mocks/OverMintTester.sol +39 -25
  214. package/contracts/mocks/StakingMockFixedAPY.sol +78 -0
  215. package/contracts/reserve/DistributionHelper.sol +142 -0
  216. package/contracts/reserve/GoodReserveCDai.sol +95 -41
  217. package/contracts/staking/utils/Math64X64.sol +268 -0
  218. package/contracts/staking/utils/StakingRewardsFixedAPY.sol +336 -0
  219. package/contracts/utils/BulkProof.sol +10 -10
  220. package/contracts/utils/GoodDollarMintBurnWrapper.sol +638 -0
  221. package/contracts/utils/MultichainBridgeHelper.sol +39 -0
  222. package/hardhat.config.ts +5 -3
  223. package/package.json +7 -4
  224. package/patches/@openzeppelin+hardhat-upgrades+1.7.0.patch.depracate +67 -0
  225. package/releases/deployment.json +10 -3
  226. package/releases/olddao.json +1 -1
  227. package/scripts/analytics/activeUsersCount.ts +65 -0
  228. package/scripts/analytics/activeWalletsStats.ts +150 -0
  229. package/scripts/analytics/claimIncidentStats.ts +117 -0
  230. package/scripts/analytics/faucetStats.ts +103 -0
  231. package/scripts/analytics/goodHolders.ts +50 -0
  232. package/scripts/{misc → analytics}/goodgiveback.ts +0 -0
  233. package/scripts/governance/airdropCalculation.ts +1 -0
  234. package/scripts/multichain-deploy/basicdao-deploy.ts +20 -5
  235. package/scripts/multichain-deploy/gdSavings-deploy.ts +232 -0
  236. package/scripts/multichain-deploy/helpers.ts +73 -8
  237. package/scripts/multichain-deploy/multichainWrapper-deploy.ts +56 -0
  238. package/scripts/multichain-deploy/nonubiDistribution-deploy.ts +170 -0
  239. package/scripts/voltageswaps.ts +47 -0
  240. package/test/governance/ClaimersDistribution.test.ts +1 -1
  241. package/test/governance/GoodDollarStaking.gd.test.ts +559 -0
  242. package/test/governance/GoodDollarStaking.good.test.ts +998 -0
  243. package/test/governance/GovernanceStaking.test.ts +43 -0
  244. package/test/helpers.ts +9 -12
  245. package/test/reserve/DistributionHelper.test.ts +394 -0
  246. package/test/reserve/GoodReserveCDai.distribution.test.ts +296 -0
  247. package/test/reserve/GoodReserveCDai.gdx.test.ts +21 -16
  248. package/test/reserve/GoodReserveCDai.pause.test.ts +116 -0
  249. package/test/staking/StakingRewardsFixedAPY.test.ts +900 -0
  250. package/test/utils/AdminWallet.test.ts +35 -6
  251. package/test/utils/GoodDollarMintBurnWrapper.test.ts +796 -0
  252. package/tsconfig.json +4 -9
  253. package/types/AccessControl.ts +361 -0
  254. package/types/CERC20.ts +25 -0
  255. package/types/DistributionBridgeMock.ts +251 -0
  256. package/types/DistributionHelper.ts +908 -0
  257. package/types/DistributionHelperTest.ts +909 -0
  258. package/types/DistributionHelperTestHelper.ts +945 -0
  259. package/types/ERC165.ts +104 -0
  260. package/types/ERC20.ts +101 -49
  261. package/types/GoodDollarMintBurnWrapper.ts +1806 -0
  262. package/types/GoodDollarStaking.ts +1855 -0
  263. package/types/GoodDollarStakingMock.ts +1855 -0
  264. package/types/GoodReserveCDai.ts +90 -55
  265. package/types/IAccessControl.ts +306 -0
  266. package/types/IERC165.ts +104 -0
  267. package/types/IERC20.ts +300 -0
  268. package/types/IERC20Metadata.ts +339 -0
  269. package/types/IERC2917.ts +25 -0
  270. package/types/IGoodDollarStakingTest.ts +160 -0
  271. package/types/IMultichainRouter.ts +166 -0
  272. package/types/IRouter.ts +143 -0
  273. package/types/IWrapper.ts +143 -0
  274. package/types/MultichainBridgeHelper.ts +170 -0
  275. package/types/MultichainRouterMock.ts +141 -0
  276. package/types/Pausable.ts +103 -0
  277. package/types/PausableControl.ts +125 -0
  278. package/types/{BulkProof.ts → RewardsMinter.ts} +24 -28
  279. package/types/StakingMockFixedAPY.ts +995 -0
  280. package/types/StakingRewardsFixedAPY.ts +428 -0
  281. package/types/factories/AaveStakingFactory__factory.ts +1 -1
  282. package/types/factories/AccessControl__factory.ts +227 -0
  283. package/types/factories/AdminWallet__factory.ts +1 -1
  284. package/types/factories/BaseShareFieldV2__factory.ts +1 -1
  285. package/types/factories/BaseShareField__factory.ts +1 -1
  286. package/types/factories/CERC20__factory.ts +13 -0
  287. package/types/factories/ClaimersDistribution__factory.ts +1 -1
  288. package/types/factories/CompoundStakingFactory__factory.ts +1 -1
  289. package/types/factories/CompoundVotingMachine__factory.ts +1 -1
  290. package/types/factories/DAOContract__factory.ts +1 -1
  291. package/types/factories/DAOUpgradeableContract__factory.ts +1 -1
  292. package/types/factories/DistributionBridgeMock__factory.ts +207 -0
  293. package/types/factories/DistributionHelperTestHelper__factory.ts +737 -0
  294. package/types/factories/DistributionHelperTest__factory.ts +717 -0
  295. package/types/factories/DistributionHelper__factory.ts +713 -0
  296. package/types/factories/DonationsStaking__factory.ts +1 -1
  297. package/types/factories/ERC165__factory.ts +39 -0
  298. package/types/factories/ERC20__factory.ts +13 -0
  299. package/types/factories/ExchangeHelper__factory.ts +1 -1
  300. package/types/factories/FuseFaucet__factory.ts +1 -1
  301. package/types/factories/FuseStakingV3__factory.ts +1 -1
  302. package/types/factories/GReputation__factory.ts +1 -1
  303. package/types/factories/GoodAaveStakingV2__factory.ts +1 -1
  304. package/types/factories/GoodAaveStaking__factory.ts +1 -1
  305. package/types/factories/GoodCompoundStakingTest__factory.ts +1 -1
  306. package/types/factories/GoodCompoundStakingV2__factory.ts +1 -1
  307. package/types/factories/GoodCompoundStaking__factory.ts +1 -1
  308. package/types/factories/GoodDollarMintBurnWrapper__factory.ts +1318 -0
  309. package/types/factories/GoodDollarStakingMock__factory.ts +1404 -0
  310. package/types/factories/GoodDollarStaking__factory.ts +1400 -0
  311. package/types/factories/GoodFundManagerTest__factory.ts +1 -1
  312. package/types/factories/GoodFundManager__factory.ts +1 -1
  313. package/types/factories/GoodMarketMaker__factory.ts +1 -1
  314. package/types/factories/GoodReserveCDai__factory.ts +74 -34
  315. package/types/factories/GovernanceStaking__factory.ts +1 -1
  316. package/types/factories/IAccessControl__factory.ts +198 -0
  317. package/types/factories/IERC165__factory.ts +42 -0
  318. package/types/factories/IERC20Metadata__factory.ts +248 -0
  319. package/types/factories/IERC20__factory.ts +203 -0
  320. package/types/factories/IERC2917__factory.ts +13 -0
  321. package/types/factories/IGoodDollarStakingTest__factory.ts +68 -0
  322. package/types/factories/IMultichainRouter__factory.ts +82 -0
  323. package/types/factories/IRouter__factory.ts +71 -0
  324. package/types/factories/IWrapper__factory.ts +71 -0
  325. package/types/factories/InvitesV1__factory.ts +1 -1
  326. package/types/factories/MultichainBridgeHelper__factory.ts +134 -0
  327. package/types/factories/MultichainRouterMock__factory.ts +141 -0
  328. package/types/factories/OverMintTesterRegularStake__factory.ts +1 -1
  329. package/types/factories/OverMintTester__factory.ts +3 -3
  330. package/types/factories/PausableControl__factory.ts +84 -0
  331. package/types/factories/Pausable__factory.ts +62 -0
  332. package/types/factories/ProtocolUpgradeFuseRecover__factory.ts +1 -1
  333. package/types/factories/ProtocolUpgradeFuse__factory.ts +1 -1
  334. package/types/factories/ProtocolUpgradeRecover__factory.ts +1 -1
  335. package/types/factories/ProtocolUpgrade__factory.ts +1 -1
  336. package/types/factories/ReputationTestHelper__factory.ts +1 -1
  337. package/types/factories/Reputation__factory.ts +1 -1
  338. package/types/factories/RewardsMinter__factory.ts +47 -0
  339. package/types/factories/StakersDistribution__factory.ts +1 -1
  340. package/types/factories/StakingMockFixedAPY__factory.ts +745 -0
  341. package/types/factories/StakingRewardsFixedAPY__factory.ts +287 -0
  342. package/types/factories/SwapHelperTest__factory.ts +1 -1
  343. package/types/factories/UBIScheme__factory.ts +1 -1
  344. package/types/factories/UniswapV2SwapHelper__factory.ts +1 -1
  345. package/types/factories/UpgradableMock2__factory.ts +1 -1
  346. package/types/factories/UpgradableMock3__factory.ts +1 -1
  347. package/types/factories/UpgradableMock4__factory.ts +1 -1
  348. package/types/factories/UpgradableMock__factory.ts +1 -1
  349. package/types/hardhat.d.ts +225 -9
  350. package/types/index.ts +50 -4
  351. package/yarn.lock +180 -104
  352. package/types/factories/BulkProof__factory.ts +0 -89
@@ -3,32 +3,46 @@
3
3
  pragma solidity >=0.8.0;
4
4
  import "../governance/GovernanceStaking.sol";
5
5
 
6
- contract OverMintTester {
7
- ERC20 public stakingToken;
8
- GovernanceStaking public stakingContract;
9
- ERC20 public rewardToken;
10
-
11
- constructor (ERC20 _stakingToken ,GovernanceStaking _stakingContract,ERC20 _rewardToken){
12
- stakingToken = _stakingToken;
13
- stakingContract = _stakingContract;
14
- rewardToken = _rewardToken;
15
-
16
- }
6
+ interface IGoodDollarStakingTest {
7
+ function stake(uint256 amount) external;
17
8
 
18
- function stake()external{
9
+ function stake(uint256 amount, uint32 ratio) external;
19
10
 
20
- uint256 tokenBalance = stakingToken.balanceOf(address(this));
21
- stakingToken.approve(address(stakingContract),tokenBalance);
22
- stakingContract.stake(tokenBalance);
23
-
24
- }
25
- function overMintTest()external{
26
- stakingContract.withdrawRewards();
27
- uint256 tokenBalance = rewardToken.balanceOf(address(this));
28
- require(tokenBalance != 0,"Reward token balance should not be equal 0");
29
- stakingContract.withdrawRewards();
30
- uint256 tokenBalanceAfterSecondClaim = rewardToken.balanceOf(address(this));
31
- require (tokenBalance == tokenBalanceAfterSecondClaim,"It should not overmint rewards");
32
- }
11
+ function withdrawRewards() external;
12
+ }
33
13
 
14
+ contract OverMintTester {
15
+ ERC20 public stakingToken;
16
+ IGoodDollarStakingTest public stakingContract;
17
+ ERC20 public rewardToken;
18
+
19
+ constructor(
20
+ ERC20 _stakingToken,
21
+ IGoodDollarStakingTest _stakingContract,
22
+ ERC20 _rewardToken
23
+ ) {
24
+ stakingToken = _stakingToken;
25
+ stakingContract = _stakingContract;
26
+ rewardToken = _rewardToken;
27
+ }
28
+
29
+ function stake() external {
30
+ uint256 tokenBalance = stakingToken.balanceOf(address(this));
31
+ stakingToken.approve(address(stakingContract), tokenBalance);
32
+ try stakingContract.stake(tokenBalance, 0) {} catch {
33
+ stakingContract.stake(tokenBalance);
34
+ }
35
+ }
36
+
37
+ function overMintTest() external {
38
+ stakingContract.withdrawRewards();
39
+ uint256 tokenBalance = rewardToken.balanceOf(address(this));
40
+ require(tokenBalance != 0, "Reward token balance should not be equal 0");
41
+ stakingContract.withdrawRewards();
42
+ uint256 tokenBalanceAfterSecondClaim = rewardToken.balanceOf(address(this));
43
+ require(
44
+ tokenBalance == tokenBalanceAfterSecondClaim,
45
+ "It should not overmint rewards"
46
+ );
47
+ }
34
48
  }
@@ -0,0 +1,78 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity >=0.8.0;
3
+
4
+ import { ERC20 as ERC20_OZ } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
5
+ import "../staking/utils/StakingRewardsFixedAPY.sol";
6
+ import "hardhat/console.sol";
7
+
8
+ contract StakingMockFixedAPY is ERC20_OZ, StakingRewardsFixedAPY {
9
+ using Math64x64 for int128;
10
+
11
+ constructor(uint128 _interestRatePerBlock)
12
+ ERC20_OZ("G$ Savings Mock", "mocksvG$")
13
+ {
14
+ _setAPY(_interestRatePerBlock);
15
+ }
16
+
17
+ function sharesSupply() public view virtual override returns (uint256) {
18
+ return totalSupply();
19
+ }
20
+
21
+ function sharesOf(address _account)
22
+ public
23
+ view
24
+ virtual
25
+ override
26
+ returns (uint256)
27
+ {
28
+ return balanceOf(_account);
29
+ }
30
+
31
+ function setAPY(uint128 _interestRatePerBlock) public {
32
+ _setAPY(_interestRatePerBlock);
33
+ }
34
+
35
+ function compound() public view returns (uint256 compoundedSavings) {
36
+ return _compound();
37
+ }
38
+
39
+ function compoundNextBlock() public view returns (uint256 compoundedSavings) {
40
+ if (stats.savings == 0 || block.number == stats.lastUpdateBlock) {
41
+ return stats.savings;
42
+ }
43
+
44
+ //earned in timespan = (interestRatePerBlock^blocksPassed * savings - savings)/PRECISION
45
+ //earned perToken = earnedInTimeSpan*PRECISION/totalStaked
46
+ //PRECISION cancels out
47
+ int128 compounded = interestRatePerBlockX64.pow(
48
+ block.number + 1 - stats.lastUpdateBlock
49
+ );
50
+ compoundedSavings = compounded.mulu(stats.savings);
51
+ }
52
+
53
+ function withdraw(address _from, uint256 _shares)
54
+ public
55
+ returns (uint256 depositComponent, uint256 rewardComponent)
56
+ {
57
+ (depositComponent, rewardComponent) = _withdraw(_from, _shares);
58
+ _burn(_from, _shares);
59
+ }
60
+
61
+ function withdrawAndUndo(address _from, uint256 _shares)
62
+ public
63
+ returns (uint256 depositComponent, uint256 rewardComponent)
64
+ {
65
+ (depositComponent, rewardComponent) = withdraw(_from, _shares);
66
+ undoReward(_from, rewardComponent);
67
+ }
68
+
69
+ function stake(address _from, uint256 _amount) public {
70
+ uint256 shares = _stake(_from, _amount);
71
+ _mint(_from, shares);
72
+ }
73
+
74
+ function undoReward(address _to, uint256 _amount) public {
75
+ uint256 shares = _undoReward(_to, _amount);
76
+ _mint(_to, shares);
77
+ }
78
+ }
@@ -0,0 +1,142 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity ^0.8;
4
+
5
+ import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol";
6
+ import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
7
+ import "@openzeppelin/contracts/utils/math/Math.sol";
8
+
9
+ import "../utils/DAOUpgradeableContract.sol";
10
+
11
+ import "hardhat/console.sol";
12
+
13
+ /***
14
+ * @dev DistributionHelper receives funds and distributes them to recipients
15
+ * recipients can be on other blockchains and get their funds via fuse/multichain bridge
16
+ * accounts with ADMIN_ROLE can update the recipients, defaults to Avatar
17
+ */
18
+ contract DistributionHelper is
19
+ DAOUpgradeableContract,
20
+ AccessControlEnumerableUpgradeable
21
+ {
22
+ enum TransferType {
23
+ FuseBridge,
24
+ MultichainBridge,
25
+ Contract
26
+ }
27
+
28
+ struct DistributionRecipient {
29
+ uint32 bps; //share out of each distribution
30
+ uint32 chainId; //for multichain bridge
31
+ address addr; //recipient address
32
+ TransferType transferType;
33
+ }
34
+
35
+ DistributionRecipient[] public distributionRecipients;
36
+
37
+ address public fuseBridge;
38
+ IMultichainRouter public multiChainBridge;
39
+ address public anyGoodDollar; //G$ multichain wrapper on ethereum
40
+
41
+ event Distribution(
42
+ uint256 distributed,
43
+ uint256 startingBalance,
44
+ uint256 incomingAmount,
45
+ DistributionRecipient[] distributionRecipients
46
+ );
47
+ event RecipientUpdated(DistributionRecipient recipient, uint256 index);
48
+ event RecipientAdded(DistributionRecipient recipient, uint256 index);
49
+
50
+ function initialize(INameService _ns) external initializer {
51
+ __AccessControlEnumerable_init();
52
+ setDAO(_ns);
53
+ _setupRole(DEFAULT_ADMIN_ROLE, avatar); //this needs to happen after setDAO for avatar to be non empty
54
+ fuseBridge = nameService.getAddress("BRIDGE_CONTRACT");
55
+ multiChainBridge = IMultichainRouter(
56
+ nameService.getAddress("MULTICHAIN_ROUTER")
57
+ );
58
+ anyGoodDollar = nameService.getAddress("MULTICHAIN_ANYGOODDOLLAR");
59
+ }
60
+
61
+ /**
62
+ * @notice this is usually called by reserve, but can be called by anyone anytime to trigger distribution
63
+ * @param _amount how much was sent, informational only
64
+ */
65
+ function onDistribution(uint256 _amount) external virtual {
66
+ //we consider the actual balance and not _amount
67
+ // console.log("onDistribution amount: %s", _amount);
68
+ uint256 toDistribute = nativeToken().balanceOf(address(this));
69
+ if (toDistribute == 0) return;
70
+
71
+ uint256 totalDistributed;
72
+ for (uint256 i = 0; i < distributionRecipients.length; i++) {
73
+ DistributionRecipient storage r = distributionRecipients[i];
74
+ if (r.bps > 0) {
75
+ uint256 toTransfer = (toDistribute * r.bps) / 10000;
76
+ totalDistributed += toTransfer;
77
+ if (toTransfer > 0) distribute(r, toTransfer);
78
+ }
79
+ }
80
+
81
+ emit Distribution(
82
+ totalDistributed,
83
+ toDistribute,
84
+ _amount,
85
+ distributionRecipients
86
+ );
87
+ }
88
+
89
+ /**
90
+ * @notice add or update a recipient details, if address exists it will update, otherwise add
91
+ * to "remove" set recipient bps to 0. only ADMIN_ROLE can call this.
92
+ */
93
+ function addOrUpdateRecipient(DistributionRecipient memory _recipient)
94
+ external
95
+ onlyRole(DEFAULT_ADMIN_ROLE)
96
+ {
97
+ // console.log("addOrUpdate addr: %s", _recipient.addr);
98
+ for (uint256 i = 0; i < distributionRecipients.length; i++) {
99
+ // console.log(
100
+ // "addOrUpdate addr: %s idx: %s, recipient: %s",
101
+ // _recipient.addr,
102
+ // i,
103
+ // distributionRecipients[i].addr
104
+ // );
105
+ if (distributionRecipients[i].addr == _recipient.addr) {
106
+ distributionRecipients[i] = _recipient;
107
+ emit RecipientUpdated(_recipient, i);
108
+ return;
109
+ }
110
+ }
111
+ //if reached here then add new one
112
+ emit RecipientAdded(_recipient, distributionRecipients.length);
113
+ distributionRecipients.push(_recipient);
114
+ }
115
+
116
+ /**
117
+ * @notice internal function that takes care of sending the G$s according to the transfer type
118
+ * @param _recipient data about the recipient
119
+ * @param _amount how much to send
120
+ */
121
+ function distribute(DistributionRecipient storage _recipient, uint256 _amount)
122
+ internal
123
+ {
124
+ if (_recipient.transferType == TransferType.FuseBridge) {
125
+ nativeToken().transferAndCall(
126
+ fuseBridge,
127
+ _amount,
128
+ abi.encodePacked(_recipient.addr)
129
+ );
130
+ } else if (_recipient.transferType == TransferType.MultichainBridge) {
131
+ nativeToken().approve(address(multiChainBridge), _amount);
132
+ multiChainBridge.anySwapOutUnderlying(
133
+ anyGoodDollar,
134
+ _recipient.addr,
135
+ _amount,
136
+ _recipient.chainId
137
+ );
138
+ } else if (_recipient.transferType == TransferType.Contract) {
139
+ nativeToken().transferAndCall(_recipient.addr, _amount, "");
140
+ }
141
+ }
142
+ }
@@ -11,6 +11,9 @@ import "../utils/NameService.sol";
11
11
  import "../DAOStackInterfaces.sol";
12
12
  import "../Interfaces.sol";
13
13
  import "./GoodMarketMaker.sol";
14
+ import "./DistributionHelper.sol";
15
+
16
+ import "hardhat/console.sol";
14
17
 
15
18
  interface ContributionCalc {
16
19
  function calculateContribution(
@@ -51,6 +54,9 @@ contract GoodReserveCDai is
51
54
  /// @dev mark if user claimed his GDX
52
55
  mapping(address => bool) public isClaimedGDX;
53
56
 
57
+ uint32 public nonUbiBps; //how much of expansion G$ to allocate for non Ubi causes
58
+ DistributionHelper public distributionHelper; //in charge of distributing non UBI to different recipients
59
+
54
60
  // Emits when new GD tokens minted
55
61
  event UBIMinted(
56
62
  //epoch of UBI
@@ -109,6 +115,10 @@ contract GoodReserveCDai is
109
115
  address indexed receiverAddress
110
116
  );
111
117
 
118
+ event NonUBIMinted(address distributionHelper, uint256 amountMinted);
119
+
120
+ event DistributionHelperSet(address distributionHelper, uint32 bps);
121
+
112
122
  function initialize(INameService _ns, bytes32 _gdxAirdrop)
113
123
  public
114
124
  virtual
@@ -134,10 +144,11 @@ contract GoodReserveCDai is
134
144
  gdxAirdrop = _gdxAirdrop;
135
145
  }
136
146
 
137
- function setGDXAirdrop(bytes32 _airdrop) external {
138
- _onlyAvatar();
139
- gdxAirdrop = _airdrop;
140
- }
147
+ //no longer required
148
+ // function setGDXAirdrop(bytes32 _airdrop) external {
149
+ // _onlyAvatar();
150
+ // gdxAirdrop = _airdrop;
151
+ // }
141
152
 
142
153
  /// @dev GDX decimals
143
154
  function decimals() public pure override returns (uint8) {
@@ -166,7 +177,7 @@ contract GoodReserveCDai is
166
177
  * `buy` occurs only if the GD return is above the given minimum. It is possible
167
178
  * to buy only with cDAI and when the contract is set to active. MUST call to
168
179
  * cDAI `approve` prior this action to allow this contract to accomplish the
169
- * conversion.
180
+ * conversion. Will not work when paused (enforced via _mintGoodDollars)
170
181
  * @param _tokenAmount The amount of cDAI tokens that should be converted to GD tokens
171
182
  * @param _minReturn The minimum allowed return in GD tokens
172
183
  * @param _targetAddress address of g$ and gdx recipient if different than msg.sender
@@ -205,7 +216,8 @@ contract GoodReserveCDai is
205
216
 
206
217
  /**
207
218
  * @dev Mint rewards for staking contracts in G$ and update RR
208
- * requires minting permissions which is enforced by _mintGoodDollars
219
+ * requires minting permissions which is enforced by _mintGoodDollars.
220
+ * Will not work when paused
209
221
  * @param _to Receipent address for rewards
210
222
  * @param _amount G$ amount to mint for rewards
211
223
  */
@@ -213,7 +225,7 @@ contract GoodReserveCDai is
213
225
  address _token,
214
226
  address _to,
215
227
  uint256 _amount
216
- ) public {
228
+ ) external {
217
229
  getMarketMaker().mintFromReserveRatio(ERC20(_token), _amount);
218
230
  _mintGoodDollars(_to, _amount, false);
219
231
  //mint GDX
@@ -224,6 +236,7 @@ contract GoodReserveCDai is
224
236
  * @dev sell helper function burns GD tokens and update the bonding curve params.
225
237
  * `sell` occurs only if the token return is above the given minimum. Notice that
226
238
  * there is a contribution amount from the given GD that remains in the reserve.
239
+ * Will not work when paused.
227
240
  * @param _gdAmount The amount of GD tokens that should be converted to cDAI tokens
228
241
  * @param _minReturn The minimum allowed `sellTo` tokens return
229
242
  * @param _target address of the receiver of cDAI when sell G$
@@ -236,6 +249,7 @@ contract GoodReserveCDai is
236
249
  address _target,
237
250
  address _seller
238
251
  ) external returns (uint256, uint256) {
252
+ require(paused() == false, "paused");
239
253
  GoodMarketMaker mm = getMarketMaker();
240
254
  if (msg.sender != nameService.getAddress("EXCHANGE_HELPER")) {
241
255
  IGoodDollar(nameService.getAddress("GOODDOLLAR")).burnFrom(
@@ -292,7 +306,7 @@ contract GoodReserveCDai is
292
306
  return getMarketMaker().currentPrice(ERC20(cDaiAddress));
293
307
  }
294
308
 
295
- function currentPriceDAI() public view returns (uint256) {
309
+ function currentPriceDAI() external view returns (uint256) {
296
310
  cERC20 cDai = cERC20(cDaiAddress);
297
311
 
298
312
  return (((currentPrice() * 1e10) * cDai.exchangeRateStored()) / 1e28); // based on https://compound.finance/docs#protocol-math
@@ -309,6 +323,8 @@ contract GoodReserveCDai is
309
323
  uint256 _gdToMint,
310
324
  bool _internalCall
311
325
  ) internal {
326
+ require(paused() == false, "paused");
327
+
312
328
  //enforce minting rules
313
329
  require(
314
330
  _internalCall ||
@@ -344,7 +360,7 @@ contract GoodReserveCDai is
344
360
  uint256 _daiToConvert,
345
361
  uint256 _startingCDAIBalance,
346
362
  ERC20 _interestToken
347
- ) public returns (uint256, uint256) {
363
+ ) external returns (uint256, uint256) {
348
364
  cERC20(cDaiAddress).mint(_daiToConvert);
349
365
  uint256 interestInCdai = _interestToken.balanceOf(address(this)) -
350
366
  _startingCDAIBalance;
@@ -353,10 +369,29 @@ contract GoodReserveCDai is
353
369
  interestInCdai
354
370
  );
355
371
  uint256 gdExpansionToMint = getMarketMaker().mintExpansion(_interestToken);
372
+
373
+ uint256 nonUBI;
374
+
375
+ lastMinted = block.number;
356
376
  uint256 gdUBI = gdInterestToMint + gdExpansionToMint;
377
+
378
+ // console.log(
379
+ // "nonubi %s, sender: %s, fundManager: %s",
380
+ // nonUbiBps,
381
+ // _msgSender(),
382
+ // nameService.getAddress("FUND_MANAGER")
383
+ // );
384
+
385
+ if (nonUbiBps > 0 && address(distributionHelper) != address(0)) {
386
+ nonUBI = (gdExpansionToMint * nonUbiBps) / 10000;
387
+ gdUBI -= nonUBI;
388
+ _mintGoodDollars(address(distributionHelper), nonUBI, false);
389
+ try distributionHelper.onDistribution(nonUBI) {} catch {} //should not prevent mintUBI from completing
390
+ emit NonUBIMinted(address(distributionHelper), nonUBI);
391
+ }
392
+
357
393
  //this enforces who can call the public mintUBI method. only an address with permissions at reserve of RESERVE_MINTER_ROLE
358
394
  _mintGoodDollars(nameService.getAddress("FUND_MANAGER"), gdUBI, false);
359
- lastMinted = block.number;
360
395
  emit UBIMinted(
361
396
  lastMinted,
362
397
  address(_interestToken),
@@ -365,9 +400,24 @@ contract GoodReserveCDai is
365
400
  gdExpansionToMint,
366
401
  gdUBI
367
402
  );
403
+
368
404
  return (gdUBI, interestInCdai);
369
405
  }
370
406
 
407
+ /**
408
+ * @notice allows Avatar to change or set the distribution helper
409
+ * @param _helper address of distributionhelper contract
410
+ * @param _bps how much of UBI to transfer in basis points
411
+ */
412
+ function setDistributionHelper(DistributionHelper _helper, uint32 _bps)
413
+ external
414
+ {
415
+ _onlyAvatar();
416
+ distributionHelper = _helper;
417
+ nonUbiBps = _bps;
418
+ emit DistributionHelperSet(address(_helper), _bps);
419
+ }
420
+
371
421
  /**
372
422
  * @dev Allows the DAO to change the daily expansion rate
373
423
  * it is calculated by _nom/_denom with e27 precision. Emits
@@ -376,7 +426,9 @@ contract GoodReserveCDai is
376
426
  * @param _nom The numerator to calculate the global `reserveRatioDailyExpansion` from
377
427
  * @param _denom The denominator to calculate the global `reserveRatioDailyExpansion` from
378
428
  */
379
- function setReserveRatioDailyExpansion(uint256 _nom, uint256 _denom) public {
429
+ function setReserveRatioDailyExpansion(uint256 _nom, uint256 _denom)
430
+ external
431
+ {
380
432
  _onlyAvatar();
381
433
  getMarketMaker().setReserveRatioDailyExpansion(_nom, _denom);
382
434
  }
@@ -385,7 +437,7 @@ contract GoodReserveCDai is
385
437
  * @dev Remove minting rights after it has transferred the cDAI funds to `_avatar`
386
438
  * Only the Avatar can execute this method
387
439
  */
388
- function end() public {
440
+ function end() external {
389
441
  _onlyAvatar();
390
442
  // remaining cDAI tokens in the current reserve contract
391
443
  if (ERC20(cDaiAddress).balanceOf(address(this)) > 0) {
@@ -409,7 +461,7 @@ contract GoodReserveCDai is
409
461
  * @dev method to recover any stuck erc20 tokens (ie compound COMP)
410
462
  * @param _token the ERC20 token to recover
411
463
  */
412
- function recover(ERC20 _token) public {
464
+ function recover(ERC20 _token) external {
413
465
  _onlyAvatar();
414
466
  require(
415
467
  _token.transfer(address(avatar), _token.balanceOf(address(this))),
@@ -417,34 +469,36 @@ contract GoodReserveCDai is
417
469
  );
418
470
  }
419
471
 
420
- /**
421
- * @notice prove user balance in a specific blockchain state hash
422
- * @dev "rootState" is a special state that can be supplied once, and actually mints reputation on the current blockchain
423
- * @param _user the user to prove his balance
424
- * @param _gdx the balance we are prooving
425
- * @param _proof array of byte32 with proof data (currently merkle tree path)
426
- * @return true if proof is valid
427
- */
428
- function claimGDX(
429
- address _user,
430
- uint256 _gdx,
431
- bytes32[] memory _proof
432
- ) public returns (bool) {
433
- require(isClaimedGDX[_user] == false, "already claimed gdx");
434
- bytes32 leafHash = keccak256(abi.encode(_user, _gdx));
435
- bool isProofValid = MerkleProofUpgradeable.verify(
436
- _proof,
437
- gdxAirdrop,
438
- leafHash
439
- );
440
-
441
- require(isProofValid, "invalid merkle proof");
442
-
443
- _mintGDX(_user, _gdx);
444
-
445
- isClaimedGDX[_user] = true;
446
- return true;
447
- }
472
+ //no longer required all gdx was distributed
473
+ // /**
474
+ // * @notice prove user balance in a specific blockchain state hash
475
+ // * @dev "rootState" is a special state that can be supplied once, and actually mints reputation on the current blockchain
476
+ // * @param _user the user to prove his balance
477
+ // * @param _gdx the balance we are prooving
478
+ // * @param _proof array of byte32 with proof data (currently merkle tree path)
479
+ // * @return true if proof is valid
480
+ // */
481
+
482
+ // function claimGDX(
483
+ // address _user,
484
+ // uint256 _gdx,
485
+ // bytes32[] memory _proof
486
+ // ) public returns (bool) {
487
+ // require(isClaimedGDX[_user] == false, "already claimed gdx");
488
+ // bytes32 leafHash = keccak256(abi.encode(_user, _gdx));
489
+ // bool isProofValid = MerkleProofUpgradeable.verify(
490
+ // _proof,
491
+ // gdxAirdrop,
492
+ // leafHash
493
+ // );
494
+
495
+ // require(isProofValid, "invalid merkle proof");
496
+
497
+ // _mintGDX(_user, _gdx);
498
+
499
+ // isClaimedGDX[_user] = true;
500
+ // return true;
501
+ // }
448
502
 
449
503
  // implement minting constraints through the GlobalConstraintInterface interface. prevent any minting not through reserve
450
504
  function pre(