@gooddollar/goodprotocol 2.0.32-beta.0 → 2.0.33-beta.0

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 (314) hide show
  1. package/artifacts/abis/BuyFromReserveHelper.min.json +1 -0
  2. package/artifacts/abis/CeloDistributionHelper.min.json +1 -0
  3. package/artifacts/abis/CeloDistributionHelperTest.min.json +1 -0
  4. package/artifacts/abis/CeloDistributionHelperTestHelper.min.json +1 -0
  5. package/artifacts/abis/IBancorExchangeProvider.min.json +1 -0
  6. package/artifacts/abis/IBroker.min.json +1 -0
  7. package/artifacts/abis/IGoodDollarExchangeProvider.min.json +1 -0
  8. package/artifacts/abis/IGoodDollarExpansionController.min.json +1 -0
  9. package/artifacts/abis/IMentoReserve.min.json +1 -0
  10. package/artifacts/abis/ITradingLimits.min.json +1 -0
  11. package/artifacts/abis/MentoExchange.min.json +1 -0
  12. package/artifacts/abis/ProtocolUpgradeV4Mento.min.json +1 -0
  13. package/artifacts/abis/SuperfluidFaucet.min.json +1 -1
  14. package/artifacts/contracts/DAOStackInterfaces.sol/Avatar.dbg.json +1 -1
  15. package/artifacts/contracts/DAOStackInterfaces.sol/Controller.dbg.json +1 -1
  16. package/artifacts/contracts/DAOStackInterfaces.sol/GlobalConstraintInterface.dbg.json +1 -1
  17. package/artifacts/contracts/DAOStackInterfaces.sol/IntVoteInterface.dbg.json +1 -1
  18. package/artifacts/contracts/DAOStackInterfaces.sol/ReputationInterface.dbg.json +1 -1
  19. package/artifacts/contracts/DAOStackInterfaces.sol/SchemeRegistrar.dbg.json +1 -1
  20. package/artifacts/contracts/Interfaces.sol/AggregatorV3Interface.dbg.json +1 -1
  21. package/artifacts/contracts/Interfaces.sol/ERC20.dbg.json +1 -1
  22. package/artifacts/contracts/Interfaces.sol/IAaveIncentivesController.dbg.json +1 -1
  23. package/artifacts/contracts/Interfaces.sol/IAdminWallet.dbg.json +1 -1
  24. package/artifacts/contracts/Interfaces.sol/IDonationStaking.dbg.json +1 -1
  25. package/artifacts/contracts/Interfaces.sol/IERC2917.dbg.json +1 -1
  26. package/artifacts/contracts/Interfaces.sol/IFirstClaimPool.dbg.json +1 -1
  27. package/artifacts/contracts/Interfaces.sol/IGoodDollar.dbg.json +1 -1
  28. package/artifacts/contracts/Interfaces.sol/IGoodStaking.dbg.json +1 -1
  29. package/artifacts/contracts/Interfaces.sol/IHasRouter.dbg.json +1 -1
  30. package/artifacts/contracts/Interfaces.sol/IIdentity.dbg.json +1 -1
  31. package/artifacts/contracts/Interfaces.sol/IIdentityV2.dbg.json +1 -1
  32. package/artifacts/contracts/Interfaces.sol/ILendingPool.dbg.json +1 -1
  33. package/artifacts/contracts/Interfaces.sol/IMultichainRouter.dbg.json +1 -1
  34. package/artifacts/contracts/Interfaces.sol/INameService.dbg.json +1 -1
  35. package/artifacts/contracts/Interfaces.sol/IQuoterV2.dbg.json +1 -1
  36. package/artifacts/contracts/Interfaces.sol/ISwapRouter.dbg.json +1 -1
  37. package/artifacts/contracts/Interfaces.sol/IUBIScheme.dbg.json +1 -1
  38. package/artifacts/contracts/Interfaces.sol/ProxyAdmin.dbg.json +1 -1
  39. package/artifacts/contracts/Interfaces.sol/Reserve.dbg.json +1 -1
  40. package/artifacts/contracts/Interfaces.sol/Staking.dbg.json +1 -1
  41. package/artifacts/contracts/Interfaces.sol/Uniswap.dbg.json +1 -1
  42. package/artifacts/contracts/Interfaces.sol/UniswapFactory.dbg.json +1 -1
  43. package/artifacts/contracts/Interfaces.sol/UniswapPair.dbg.json +1 -1
  44. package/artifacts/contracts/Interfaces.sol/cERC20.dbg.json +1 -1
  45. package/artifacts/contracts/MentoInterfaces.sol/IBancorExchangeProvider.dbg.json +4 -0
  46. package/artifacts/contracts/MentoInterfaces.sol/IBancorExchangeProvider.json +282 -0
  47. package/artifacts/contracts/MentoInterfaces.sol/IBroker.dbg.json +4 -0
  48. package/artifacts/contracts/MentoInterfaces.sol/IBroker.json +491 -0
  49. package/artifacts/contracts/MentoInterfaces.sol/IGoodDollarExchangeProvider.dbg.json +4 -0
  50. package/artifacts/contracts/MentoInterfaces.sol/IGoodDollarExchangeProvider.json +164 -0
  51. package/artifacts/contracts/MentoInterfaces.sol/IGoodDollarExpansionController.dbg.json +4 -0
  52. package/artifacts/contracts/MentoInterfaces.sol/IGoodDollarExpansionController.json +333 -0
  53. package/artifacts/contracts/MentoInterfaces.sol/IMentoReserve.dbg.json +4 -0
  54. package/artifacts/contracts/MentoInterfaces.sol/IMentoReserve.json +927 -0
  55. package/artifacts/contracts/MentoInterfaces.sol/ITradingLimits.dbg.json +4 -0
  56. package/artifacts/contracts/MentoInterfaces.sol/ITradingLimits.json +10 -0
  57. package/artifacts/contracts/fuseFaucet/Faucet.sol/Faucet.dbg.json +1 -1
  58. package/artifacts/contracts/fuseFaucet/FuseFaucet.sol/FuseFaucet.dbg.json +1 -1
  59. package/artifacts/contracts/fuseFaucet/FuseFaucetV2.sol/FuseFaucetV2.dbg.json +1 -1
  60. package/artifacts/contracts/fuseFaucet/SuperfluidFacuet.sol/SuperfluidFaucet.dbg.json +1 -1
  61. package/artifacts/contracts/fuseFaucet/SuperfluidFacuet.sol/SuperfluidFaucet.json +46 -28
  62. package/artifacts/contracts/governance/ClaimersDistribution.sol/ClaimersDistribution.dbg.json +1 -1
  63. package/artifacts/contracts/governance/CompoundVotingMachine.sol/CompoundVotingMachine.dbg.json +1 -1
  64. package/artifacts/contracts/governance/GReputation.sol/GReputation.dbg.json +1 -1
  65. package/artifacts/contracts/governance/GoodDollarStaking.sol/GoodDollarStaking.dbg.json +1 -1
  66. package/artifacts/contracts/governance/GoodDollarStaking.sol/IGovernanceStaking.dbg.json +1 -1
  67. package/artifacts/contracts/governance/GoodDollarStaking.sol/IStakingUpgrade.dbg.json +1 -1
  68. package/artifacts/contracts/governance/GoodDollarStaking.sol/RewardsMinter.dbg.json +1 -1
  69. package/artifacts/contracts/governance/GovernanceStaking.sol/GovernanceStaking.dbg.json +1 -1
  70. package/artifacts/contracts/governance/MultiBaseGovernanceShareField.sol/MultiBaseGovernanceShareField.dbg.json +1 -1
  71. package/artifacts/contracts/governance/Reputation.sol/Reputation.dbg.json +1 -1
  72. package/artifacts/contracts/governance/StakersDistribution.sol/StakersDistribution.dbg.json +1 -1
  73. package/artifacts/contracts/governance/StakersDistribution.sol/StakersDistribution.json +2 -2
  74. package/artifacts/contracts/identity/IdentityV2.sol/IdentityV2.dbg.json +1 -1
  75. package/artifacts/contracts/invite/InvitesFuseV2.sol/InvitesFuseV2.dbg.json +1 -1
  76. package/artifacts/contracts/invite/InvitesV1.sol/InvitesV1.dbg.json +1 -1
  77. package/artifacts/contracts/invite/InvitesV2.sol/InvitesV2.dbg.json +1 -1
  78. package/artifacts/contracts/invite/OneTimeReward.sol/OneTimeReward.dbg.json +1 -1
  79. package/artifacts/contracts/mocks/AaveMock.sol/AaveMock.dbg.json +1 -1
  80. package/artifacts/contracts/mocks/AaveUSDMockOracle.sol/AaveUSDMockOracle.dbg.json +1 -1
  81. package/artifacts/contracts/mocks/BatUSDMockOracle.sol/BatUSDMockOracle.dbg.json +1 -1
  82. package/artifacts/contracts/mocks/CeloDistributionHelperTest.sol/CeloDistributionHelperTest.dbg.json +4 -0
  83. package/artifacts/contracts/mocks/CeloDistributionHelperTest.sol/CeloDistributionHelperTest.json +864 -0
  84. package/artifacts/contracts/mocks/CeloDistributionHelperTest.sol/CeloDistributionHelperTestHelper.dbg.json +4 -0
  85. package/artifacts/contracts/mocks/CeloDistributionHelperTest.sol/CeloDistributionHelperTestHelper.json +890 -0
  86. package/artifacts/contracts/mocks/CompUsdMockOracle.sol/CompUSDMockOracle.dbg.json +1 -1
  87. package/artifacts/contracts/mocks/DAIMock.sol/DAIMock.dbg.json +1 -1
  88. package/artifacts/contracts/mocks/DaiEthPriceMockOracle.sol/DaiEthPriceMockOracle.dbg.json +1 -1
  89. package/artifacts/contracts/mocks/DecimalsMock.sol/DecimalsMock.dbg.json +1 -1
  90. package/artifacts/contracts/mocks/DistributionBridgeMock.sol/DistributionBridgeMock.dbg.json +1 -1
  91. package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTest.dbg.json +1 -1
  92. package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTest.json +2 -2
  93. package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTestHelper.dbg.json +1 -1
  94. package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTestHelper.json +2 -2
  95. package/artifacts/contracts/mocks/EthUSDMockOracle.sol/EthUSDMockOracle.dbg.json +1 -1
  96. package/artifacts/contracts/mocks/FeesFormularMock.sol/FeesFormulaMock.dbg.json +1 -1
  97. package/artifacts/contracts/mocks/GasPriceMockOracle.sol/GasPriceMockOracle.dbg.json +1 -1
  98. package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.dbg.json +1 -1
  99. package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.json +2 -2
  100. package/artifacts/contracts/mocks/GoodDollarStakingMock.sol/GoodDollarStakingMock.dbg.json +1 -1
  101. package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.dbg.json +1 -1
  102. package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.json +2 -2
  103. package/artifacts/contracts/mocks/IdentityMock.sol/IdentityMock.dbg.json +1 -1
  104. package/artifacts/contracts/mocks/IncentiveControllerMock.sol/IncentiveControllerMock.dbg.json +1 -1
  105. package/artifacts/contracts/mocks/LendingPoolMock.sol/LendingPoolMock.dbg.json +1 -1
  106. package/artifacts/contracts/mocks/MultichainRouterMock.sol/IWrapper.dbg.json +1 -1
  107. package/artifacts/contracts/mocks/MultichainRouterMock.sol/MultichainRouterMock.dbg.json +1 -1
  108. package/artifacts/contracts/mocks/OverMintTester.sol/IGoodDollarStakingTest.dbg.json +1 -1
  109. package/artifacts/contracts/mocks/OverMintTester.sol/OverMintTester.dbg.json +1 -1
  110. package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.dbg.json +1 -1
  111. package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.json +2 -2
  112. package/artifacts/contracts/mocks/PayableMock.sol/PayableMock.dbg.json +1 -1
  113. package/artifacts/contracts/mocks/SixteenDecimalsTokenMock.sol/SixteenDecimalsTokenMock.dbg.json +1 -1
  114. package/artifacts/contracts/mocks/StakingMockFixedAPY.sol/StakingMockFixedAPY.dbg.json +1 -1
  115. package/artifacts/contracts/mocks/SwapHelperTest.sol/SwapHelperTest.dbg.json +1 -1
  116. package/artifacts/contracts/mocks/TwentyDecimalsTokenMock.sol/TwentyDecimalsTokenMock.dbg.json +1 -1
  117. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock.dbg.json +1 -1
  118. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock2.dbg.json +1 -1
  119. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock3.dbg.json +1 -1
  120. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock4.dbg.json +1 -1
  121. package/artifacts/contracts/mocks/UsdcMock.sol/USDCMock.dbg.json +1 -1
  122. package/artifacts/contracts/mocks/cBATMock.sol/cBATMock.dbg.json +1 -1
  123. package/artifacts/contracts/mocks/cDAILowWorthMock.sol/cDAILowWorthMock.dbg.json +1 -1
  124. package/artifacts/contracts/mocks/cDAIMock.sol/cDAIMock.dbg.json +1 -1
  125. package/artifacts/contracts/mocks/cDAINonMintableMock.sol/cDAINonMintableMock.dbg.json +1 -1
  126. package/artifacts/contracts/mocks/cDecimalsMock.sol/cDecimalsMock.dbg.json +1 -1
  127. package/artifacts/contracts/mocks/cSDTMock.sol/cSDTMock.dbg.json +1 -1
  128. package/artifacts/contracts/mocks/cUSDCMock.sol/cUSDCMock.dbg.json +1 -1
  129. package/artifacts/contracts/reserve/CeloDistributionHelper.sol/CeloDistributionHelper.dbg.json +4 -0
  130. package/artifacts/contracts/reserve/CeloDistributionHelper.sol/CeloDistributionHelper.json +864 -0
  131. package/artifacts/contracts/reserve/DistributionHelper.sol/DistributionHelper.dbg.json +1 -1
  132. package/artifacts/contracts/reserve/DistributionHelper.sol/DistributionHelper.json +2 -2
  133. package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.dbg.json +1 -1
  134. package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.json +2 -2
  135. package/artifacts/contracts/reserve/GoodMarketMaker.sol/GoodMarketMaker.dbg.json +1 -1
  136. package/artifacts/contracts/reserve/GoodMarketMaker.sol/GoodMarketMaker.json +2 -2
  137. package/artifacts/contracts/reserve/GoodReserveCDai.sol/ContributionCalc.dbg.json +1 -1
  138. package/artifacts/contracts/reserve/GoodReserveCDai.sol/GoodReserveCDai.dbg.json +1 -1
  139. package/artifacts/contracts/reserve/GoodReserveCDai.sol/GoodReserveCDai.json +2 -2
  140. package/artifacts/contracts/staking/BaseShareField.sol/BaseShareField.dbg.json +1 -1
  141. package/artifacts/contracts/staking/BaseShareFieldV2.sol/BaseShareFieldV2.dbg.json +1 -1
  142. package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.dbg.json +1 -1
  143. package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.json +2 -2
  144. package/artifacts/contracts/staking/FuseStakingV3.sol/FuseStakingV3.dbg.json +1 -1
  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/aave/AaveStakingFactory.sol/AaveStakingFactory.dbg.json +1 -1
  153. package/artifacts/contracts/staking/aave/AaveStakingFactory.sol/AaveStakingFactory.json +2 -2
  154. package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.dbg.json +1 -1
  155. package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.json +2 -2
  156. package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.dbg.json +1 -1
  157. package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.json +2 -2
  158. package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.dbg.json +1 -1
  159. package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.json +2 -2
  160. package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.dbg.json +1 -1
  161. package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.json +2 -2
  162. package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.dbg.json +1 -1
  163. package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.json +2 -2
  164. package/artifacts/contracts/staking/utils/Math64X64.sol/Math64x64.dbg.json +1 -1
  165. package/artifacts/contracts/staking/utils/StakingRewardsFixedAPY.sol/StakingRewardsFixedAPY.dbg.json +1 -1
  166. package/artifacts/contracts/token/ERC20PresetMinterPauserUpgradeable.sol/ERC20PresetMinterPauserUpgradeable.dbg.json +1 -1
  167. package/artifacts/contracts/token/ERC677.sol/ERC677.dbg.json +1 -1
  168. package/artifacts/contracts/token/ERC677.sol/ERC677Receiver.dbg.json +1 -1
  169. package/artifacts/contracts/token/GoodDollar.sol/GoodDollar.dbg.json +1 -1
  170. package/artifacts/contracts/token/IFeesFormula.sol/IFeesFormula.dbg.json +1 -1
  171. package/artifacts/contracts/token/MultichainFeeFormula.sol/MultichainFeeFormula.dbg.json +1 -1
  172. package/artifacts/contracts/token/superfluid/ERC20Permit.sol/ERC20Permit.dbg.json +1 -1
  173. package/artifacts/contracts/token/superfluid/ERC20Permit.sol/SelfApprove.dbg.json +1 -1
  174. package/artifacts/contracts/token/superfluid/ISuperGoodDollar.sol/IGoodDollarCustom.dbg.json +1 -1
  175. package/artifacts/contracts/token/superfluid/ISuperGoodDollar.sol/ISuperGoodDollar.dbg.json +1 -1
  176. package/artifacts/contracts/token/superfluid/ISuperToken.sol/ISuperToken.dbg.json +1 -1
  177. package/artifacts/contracts/token/superfluid/SuperGoodDollar.sol/SuperGoodDollar.dbg.json +1 -1
  178. package/artifacts/contracts/token/superfluid/SuperToken.sol/SuperToken.dbg.json +1 -1
  179. package/artifacts/contracts/token/superfluid/SuperfluidToken.sol/SuperfluidToken.dbg.json +1 -1
  180. package/artifacts/contracts/token/superfluid/UUPSProxiable.sol/UUPSProxiable.dbg.json +1 -1
  181. package/artifacts/contracts/token/superfluid/UUPSProxy.sol/Proxy.dbg.json +1 -1
  182. package/artifacts/contracts/token/superfluid/UUPSProxy.sol/UUPSProxy.dbg.json +1 -1
  183. package/artifacts/contracts/token/superfluid/UUPSProxy.sol/UUPSUtils.dbg.json +1 -1
  184. package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.dbg.json +1 -1
  185. package/artifacts/contracts/ubi/UBISchemeV2.sol/UBISchemeV2.dbg.json +1 -1
  186. package/artifacts/contracts/utils/AdminWallet.sol/AdminWallet.dbg.json +1 -1
  187. package/artifacts/contracts/utils/AdminWalletFuse.sol/AdminWalletFuse.dbg.json +1 -1
  188. package/artifacts/contracts/utils/BancorFormula.sol/BancorFormula.dbg.json +1 -1
  189. package/artifacts/contracts/utils/BulkProof.sol/BulkProof.dbg.json +1 -1
  190. package/artifacts/contracts/utils/BulkProof.sol/BulkProof.json +2 -2
  191. package/artifacts/contracts/utils/BulkWhitelist.sol/BulkWhitelist.dbg.json +1 -1
  192. package/artifacts/contracts/utils/BuyAndBridgeHelper.sol/BuyAndBridgeHelper.dbg.json +1 -1
  193. package/artifacts/contracts/utils/BuyAndBridgeHelper.sol/BuyAndBridgeHelper.json +2 -2
  194. package/artifacts/contracts/utils/BuyFromReserveHelper.sol/BuyFromReserveHelper.dbg.json +4 -0
  195. package/artifacts/contracts/utils/BuyFromReserveHelper.sol/BuyFromReserveHelper.json +476 -0
  196. package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDClone.dbg.json +1 -1
  197. package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDCloneFactory.dbg.json +1 -1
  198. package/artifacts/contracts/utils/BuyGDClone.sol/DonateGDClone.dbg.json +1 -1
  199. package/artifacts/contracts/utils/DAOContract.sol/DAOContract.dbg.json +1 -1
  200. package/artifacts/contracts/utils/DAOUpgradeableContract.sol/DAOUpgradeableContract.dbg.json +1 -1
  201. package/artifacts/contracts/utils/DSMath.sol/DSMath.dbg.json +1 -1
  202. package/artifacts/contracts/utils/DataTypes.sol/DataTypes.dbg.json +1 -1
  203. package/artifacts/contracts/utils/FuseOldBridgeKill.sol/EternalStorage.dbg.json +1 -1
  204. package/artifacts/contracts/utils/FuseOldBridgeKill.sol/FuseOldBridgeKill.dbg.json +1 -1
  205. package/artifacts/contracts/utils/FuseOldBridgeKill.sol/IUpgradeabilityOwnerStorage.dbg.json +1 -1
  206. package/artifacts/contracts/utils/FuseOldBridgeKill.sol/Initializable.dbg.json +1 -1
  207. package/artifacts/contracts/utils/FuseOldBridgeKill.sol/Ownable.dbg.json +1 -1
  208. package/artifacts/contracts/utils/FuseOldBridgeKill.sol/Upgradeable.dbg.json +1 -1
  209. package/artifacts/contracts/utils/GDFaucet.sol/GDFaucet.dbg.json +1 -1
  210. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/GoodDollarMintBurnWrapper.dbg.json +1 -1
  211. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/IRouter.dbg.json +1 -1
  212. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/PausableControl.dbg.json +1 -1
  213. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/TokenOperation.dbg.json +1 -1
  214. package/artifacts/contracts/utils/IdentityFix.sol/IdentityFix.dbg.json +1 -1
  215. package/artifacts/contracts/utils/LastauthReduction.sol/LastauthReduction.dbg.json +1 -1
  216. package/artifacts/contracts/utils/LastauthReduction.sol/LastauthReduction.json +2 -2
  217. package/artifacts/contracts/utils/MultiCall.sol/Multicall.dbg.json +1 -1
  218. package/artifacts/contracts/utils/MultichainBridgeHelper.sol/MultichainBridgeHelper.dbg.json +1 -1
  219. package/artifacts/contracts/utils/NameService.sol/NameService.dbg.json +1 -1
  220. package/artifacts/contracts/utils/OneTimePayments.sol/OneTimePayments.dbg.json +1 -1
  221. package/artifacts/contracts/utils/OneTimePaymentsV2.sol/OneTimePaymentsV2.dbg.json +1 -1
  222. package/artifacts/contracts/utils/ProtoclUpgradeV4Mento.sol/MentoExchange.dbg.json +4 -0
  223. package/artifacts/contracts/utils/ProtoclUpgradeV4Mento.sol/MentoExchange.json +24 -0
  224. package/artifacts/contracts/utils/ProtoclUpgradeV4Mento.sol/ProtocolUpgradeV4Mento.dbg.json +4 -0
  225. package/artifacts/contracts/utils/ProtoclUpgradeV4Mento.sol/ProtocolUpgradeV4Mento.json +92 -0
  226. package/artifacts/contracts/utils/ProtocolUpgrade.sol/OldMarketMaker.dbg.json +1 -1
  227. package/artifacts/contracts/utils/ProtocolUpgrade.sol/ProtocolUpgrade.dbg.json +1 -1
  228. package/artifacts/contracts/utils/ProtocolUpgradeFuse.sol/ProtocolUpgradeFuse.dbg.json +1 -1
  229. package/artifacts/contracts/utils/ProtocolUpgradeFuseRecover.sol/ProtocolUpgradeFuseRecover.dbg.json +1 -1
  230. package/artifacts/contracts/utils/ProtocolUpgradeRecover.sol/ProtocolUpgradeRecover.dbg.json +1 -1
  231. package/artifacts/contracts/utils/ProxyFactory1967.sol/ERC1967Proxy.dbg.json +1 -1
  232. package/artifacts/contracts/utils/ProxyFactory1967.sol/ProxyFactory1967.dbg.json +1 -1
  233. package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.dbg.json +1 -1
  234. package/artifacts/contracts/utils/ReserveRestore.sol/ReserveRestore.dbg.json +1 -1
  235. package/artifacts/contracts/utils/ReserveRestore.sol/ReserveRestore.json +2 -2
  236. package/contracts/MentoInterfaces.sol +746 -0
  237. package/contracts/fuseFaucet/SuperfluidFacuet.sol +29 -8
  238. package/contracts/mocks/CeloDistributionHelperTest.sol +25 -0
  239. package/contracts/reserve/CeloDistributionHelper.sol +286 -0
  240. package/contracts/reserve/GoodMarketMaker.sol +11 -1
  241. package/contracts/staking/GoodFundManager.sol +5 -2
  242. package/contracts/utils/BuyFromReserveHelper.sol +129 -0
  243. package/contracts/utils/ProtoclUpgradeV4Mento.sol +99 -0
  244. package/contracts/utils/ReserveRestore.sol +171 -147
  245. package/hardhat.config.ts +4 -4
  246. package/package.json +5 -2
  247. package/releases/deployment.json +8 -5
  248. package/scripts/multichain-deploy/helpers.ts +45 -24
  249. package/scripts/proposals/reserveRestore.ts +130 -85
  250. package/scripts/proposals/v4Upgrade.ts +845 -0
  251. package/test/reserve/CeloDistributionHelper.test.ts +377 -0
  252. package/test/reserve/GoodMarketMaker.test.ts +98 -35
  253. package/test/zzz - e2e/CeloDistributionHelper.e2e.test.ts +0 -0
  254. package/types/contracts/MentoInterfaces.sol/IBancorExchangeProvider.ts +422 -0
  255. package/types/contracts/MentoInterfaces.sol/IBroker.ts +727 -0
  256. package/types/contracts/MentoInterfaces.sol/IGoodDollarExchangeProvider.ts +341 -0
  257. package/types/contracts/MentoInterfaces.sol/IGoodDollarExpansionController.ts +617 -0
  258. package/types/contracts/MentoInterfaces.sol/IMentoReserve.ts +1700 -0
  259. package/types/contracts/MentoInterfaces.sol/index.ts +8 -0
  260. package/types/contracts/fuseFaucet/SuperfluidFacuet.sol/SuperfluidFaucet.ts +79 -41
  261. package/types/contracts/index.ts +2 -0
  262. package/types/contracts/mocks/CeloDistributionHelperTest.sol/CeloDistributionHelperTest.ts +1226 -0
  263. package/types/contracts/mocks/CeloDistributionHelperTest.sol/CeloDistributionHelperTestHelper.ts +1279 -0
  264. package/types/contracts/mocks/CeloDistributionHelperTest.sol/index.ts +5 -0
  265. package/types/contracts/mocks/index.ts +2 -0
  266. package/types/contracts/reserve/CeloDistributionHelper.ts +1226 -0
  267. package/types/contracts/reserve/index.ts +1 -0
  268. package/types/contracts/utils/BuyFromReserveHelper.ts +699 -0
  269. package/types/contracts/utils/ProtoclUpgradeV4Mento.sol/MentoExchange.ts +81 -0
  270. package/types/contracts/utils/ProtoclUpgradeV4Mento.sol/ProtocolUpgradeV4Mento.ts +161 -0
  271. package/types/contracts/utils/ProtoclUpgradeV4Mento.sol/index.ts +5 -0
  272. package/types/contracts/utils/index.ts +3 -0
  273. package/types/factories/contracts/MentoInterfaces.sol/IBancorExchangeProvider__factory.ts +301 -0
  274. package/types/factories/contracts/MentoInterfaces.sol/IBroker__factory.ts +506 -0
  275. package/types/factories/contracts/MentoInterfaces.sol/IGoodDollarExchangeProvider__factory.ts +183 -0
  276. package/types/factories/contracts/MentoInterfaces.sol/IGoodDollarExpansionController__factory.ts +352 -0
  277. package/types/factories/contracts/MentoInterfaces.sol/IMentoReserve__factory.ts +942 -0
  278. package/types/factories/contracts/MentoInterfaces.sol/index.ts +8 -0
  279. package/types/factories/contracts/fuseFaucet/SuperfluidFacuet.sol/SuperfluidFaucet__factory.ts +45 -27
  280. package/types/factories/contracts/governance/StakersDistribution__factory.ts +1 -1
  281. package/types/factories/contracts/index.ts +1 -0
  282. package/types/factories/contracts/mocks/CeloDistributionHelperTest.sol/CeloDistributionHelperTestHelper__factory.ts +949 -0
  283. package/types/factories/contracts/mocks/CeloDistributionHelperTest.sol/CeloDistributionHelperTest__factory.ts +919 -0
  284. package/types/factories/contracts/mocks/CeloDistributionHelperTest.sol/index.ts +5 -0
  285. package/types/factories/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTestHelper__factory.ts +1 -1
  286. package/types/factories/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTest__factory.ts +1 -1
  287. package/types/factories/contracts/mocks/GoodCompoundStakingTest__factory.ts +1 -1
  288. package/types/factories/contracts/mocks/GoodFundManagerTest__factory.ts +1 -1
  289. package/types/factories/contracts/mocks/OverMintTesterRegularStake__factory.ts +1 -1
  290. package/types/factories/contracts/mocks/index.ts +1 -0
  291. package/types/factories/contracts/reserve/CeloDistributionHelper__factory.ts +919 -0
  292. package/types/factories/contracts/reserve/DistributionHelper__factory.ts +1 -1
  293. package/types/factories/contracts/reserve/ExchangeHelper__factory.ts +1 -1
  294. package/types/factories/contracts/reserve/GoodMarketMaker__factory.ts +1 -1
  295. package/types/factories/contracts/reserve/GoodReserveCDai.sol/GoodReserveCDai__factory.ts +1 -1
  296. package/types/factories/contracts/reserve/index.ts +1 -0
  297. package/types/factories/contracts/staking/DonationsStaking__factory.ts +1 -1
  298. package/types/factories/contracts/staking/GoodFundManager__factory.ts +1 -1
  299. package/types/factories/contracts/staking/aave/AaveStakingFactory__factory.ts +1 -1
  300. package/types/factories/contracts/staking/aave/GoodAaveStakingV2__factory.ts +1 -1
  301. package/types/factories/contracts/staking/aave/GoodAaveStaking__factory.ts +1 -1
  302. package/types/factories/contracts/staking/compound/CompoundStakingFactory__factory.ts +1 -1
  303. package/types/factories/contracts/staking/compound/GoodCompoundStakingV2__factory.ts +1 -1
  304. package/types/factories/contracts/staking/compound/GoodCompoundStaking__factory.ts +1 -1
  305. package/types/factories/contracts/utils/BuyAndBridgeHelper__factory.ts +1 -1
  306. package/types/factories/contracts/utils/BuyFromReserveHelper__factory.ts +566 -0
  307. package/types/factories/contracts/utils/LastauthReduction__factory.ts +1 -1
  308. package/types/factories/contracts/utils/ProtoclUpgradeV4Mento.sol/MentoExchange__factory.ts +39 -0
  309. package/types/factories/contracts/utils/ProtoclUpgradeV4Mento.sol/ProtocolUpgradeV4Mento__factory.ts +152 -0
  310. package/types/factories/contracts/utils/ProtoclUpgradeV4Mento.sol/index.ts +5 -0
  311. package/types/factories/contracts/utils/ReserveRestore__factory.ts +1 -1
  312. package/types/factories/contracts/utils/index.ts +2 -0
  313. package/types/hardhat.d.ts +99 -0
  314. package/types/index.ts +22 -0
@@ -17,8 +17,6 @@ contract SuperfluidFaucet is
17
17
  using SafeMathUpgradeable for uint256;
18
18
 
19
19
  bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");
20
- uint public constant GAS_TOPPING_AMOUNT = 350000;
21
- uint public constant FIRST_GAS_TOPPING_AMOUNT = 15e5;
22
20
 
23
21
  uint256 public _deprecated;
24
22
  uint256 public maxValuePerPeriod;
@@ -31,6 +29,9 @@ contract SuperfluidFaucet is
31
29
 
32
30
  mapping(address => RecipientInfo) public recipientInfo;
33
31
 
32
+ uint public gasToppingAmount;
33
+ uint public firstGasToppingAmount;
34
+
34
35
  event WalletTopped(address recipient, uint256 amount);
35
36
  event SettingsUpdated(uint256 maxValuePerPeriod, uint256 toppingPeriod);
36
37
 
@@ -51,7 +52,9 @@ contract SuperfluidFaucet is
51
52
  _setupRole(ADMIN_ROLE, msg.sender);
52
53
  _grantRole(ADMIN_ROLE, _admin);
53
54
  maxValuePerPeriod = _maxValuePerPeriod;
54
- toppingPeriod = _toppingPeriod;
55
+ toppingPeriod = _toppingPeriod * 1 days;
56
+ gasToppingAmount = 500000;
57
+ firstGasToppingAmount = 20e5;
55
58
  }
56
59
 
57
60
  function updateSettings(
@@ -59,7 +62,7 @@ contract SuperfluidFaucet is
59
62
  uint256 _toppingPeriod
60
63
  ) external onlyRole(ADMIN_ROLE) {
61
64
  maxValuePerPeriod = _maxValuePerPeriod;
62
- toppingPeriod = _toppingPeriod;
65
+ toppingPeriod = _toppingPeriod * 1 days;
63
66
  emit SettingsUpdated(_maxValuePerPeriod, _toppingPeriod);
64
67
  }
65
68
 
@@ -78,6 +81,11 @@ contract SuperfluidFaucet is
78
81
 
79
82
  uint256 currentPeriod = block.timestamp / toppingPeriod;
80
83
 
84
+ // fix bug where period was divid by 30 and not by 30days, (for non effected users lsatWithdrawlPeriod will be < 57947235 for sure)
85
+ if (info.lastWithdrawalPeriod > 0 && info.lastWithdrawalPeriod > 57947235) {
86
+ if (currentPeriod > (info.lastWithdrawalPeriod * 30) / toppingPeriod)
87
+ return true;
88
+ }
81
89
  if (currentPeriod > info.lastWithdrawalPeriod) {
82
90
  return true; // New period, reset counters
83
91
  }
@@ -97,15 +105,22 @@ contract SuperfluidFaucet is
97
105
  return canTop(recipient, blockFee);
98
106
  }
99
107
 
108
+ function updateGasToppingAmounts(
109
+ uint _gasToppingAmount,
110
+ uint _firstGasToppingAmount
111
+ ) external onlyRole(ADMIN_ROLE) {
112
+ gasToppingAmount = _gasToppingAmount;
113
+ firstGasToppingAmount = _firstGasToppingAmount;
114
+ }
115
+
100
116
  function getToppingValue(
101
117
  bool firstTime,
102
118
  uint baseFee
103
- ) public pure returns (uint) {
119
+ ) public view returns (uint) {
104
120
  //top wallet with current base fee + 10% for priority fee and l1 fees
105
121
  return
106
- ((firstTime ? FIRST_GAS_TOPPING_AMOUNT : GAS_TOPPING_AMOUNT) *
107
- baseFee *
108
- 110) / 100;
122
+ ((firstTime ? firstGasToppingAmount : gasToppingAmount) * baseFee * 110) /
123
+ 100;
109
124
  }
110
125
 
111
126
  function topWallet(address payable recipient) external onlyRole(ADMIN_ROLE) {
@@ -115,6 +130,12 @@ contract SuperfluidFaucet is
115
130
  uint amount = getToppingValue(firstTime, block.basefee);
116
131
  uint256 currentPeriod = block.timestamp / toppingPeriod;
117
132
 
133
+ // fix bug where period was divid by 30 and not by 30days, (for non effected users lsatWithdrawlPeriod will be < 57947235 for sure)
134
+ if (info.lastWithdrawalPeriod > 0 && info.lastWithdrawalPeriod > 57947235) {
135
+ info.lastWithdrawalPeriod =
136
+ (info.lastWithdrawalPeriod * 30) /
137
+ toppingPeriod;
138
+ }
118
139
  if (currentPeriod > info.lastWithdrawalPeriod) {
119
140
  info.totalWithdrawnThisPeriod = 0;
120
141
  info.lastWithdrawalPeriod = currentPeriod;
@@ -0,0 +1,25 @@
1
+ pragma solidity >=0.8;
2
+
3
+ import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
4
+ import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
5
+ import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol";
6
+ import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
7
+ import "@openzeppelin/contracts/utils/math/Math.sol";
8
+
9
+ import "../reserve/CeloDistributionHelper.sol";
10
+
11
+ contract CeloDistributionHelperTest is CeloDistributionHelper {
12
+ function onDistribution(uint256 _amount) external override {
13
+ revert();
14
+ }
15
+ }
16
+
17
+ contract CeloDistributionHelperTestHelper is CeloDistributionHelper {
18
+ function setOracle(IStaticOracle oracle) external {
19
+ STATIC_ORACLE = oracle;
20
+ }
21
+
22
+ function setBridges(address _mpbBridge) external {
23
+ mpbBridge = IMessagePassingBridge(_mpbBridge);
24
+ }
25
+ }
@@ -0,0 +1,286 @@
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 "@mean-finance/uniswap-v3-oracle/solidity/interfaces/IStaticOracle.sol";
8
+ import "@gooddollar/bridge-contracts/contracts/messagePassingBridge/IMessagePassingBridge.sol";
9
+
10
+ import "../utils/DAOUpgradeableContract.sol";
11
+
12
+ // import "hardhat/console.sol";
13
+
14
+ /***
15
+ * @dev DistributionHelper receives funds and distributes them to recipients
16
+ * recipients can be on other blockchains and get their funds via fuse/multichain bridge
17
+ * accounts with ADMIN_ROLE can update the recipients, defaults to Avatar
18
+ */
19
+ contract CeloDistributionHelper is
20
+ DAOUpgradeableContract,
21
+ AccessControlEnumerableUpgradeable
22
+ {
23
+ error FEE_LIMIT(uint256 fee);
24
+ error INVALID_CHAINID();
25
+
26
+ bytes32 public constant GUARDIAN_ROLE = keccak256("GUARDIAN_ROLE");
27
+
28
+ address public constant CELO = 0x471EcE3750Da237f93B8E339c536989b8978a438;
29
+
30
+ address public constant CUSD = 0x765DE816845861e75A25fCA122bb6898B8B1282a;
31
+
32
+ ISwapRouter public constant ROUTER =
33
+ ISwapRouter(0x5615CDAb10dc425a742d643d949a7F474C01abc4);
34
+
35
+ enum TransferType {
36
+ LayerZeroBridge,
37
+ Transfer,
38
+ TransferAndCall
39
+ }
40
+
41
+ struct DistributionRecipient {
42
+ uint32 bps; //share out of each distribution
43
+ uint32 chainId; //for multichain bridge
44
+ address addr; //recipient address
45
+ TransferType transferType;
46
+ }
47
+
48
+ struct FeeSettings {
49
+ uint128 maxFee;
50
+ uint128 minBalanceForFees;
51
+ uint8 percentageToSellForFee;
52
+ uint8 maxSlippage;
53
+ }
54
+
55
+ DistributionRecipient[] public distributionRecipients;
56
+
57
+ IMessagePassingBridge public mpbBridge;
58
+ FeeSettings public feeSettings;
59
+ IStaticOracle public STATIC_ORACLE;
60
+
61
+ event Distribution(
62
+ uint256 distributed,
63
+ uint256 startingBalance,
64
+ uint256 incomingAmount,
65
+ DistributionRecipient[] distributionRecipients,
66
+ uint256 gdSoldForGas,
67
+ uint256 nativeBoughtForGas
68
+ );
69
+ event RecipientUpdated(DistributionRecipient recipient, uint256 index);
70
+ event RecipientAdded(DistributionRecipient recipient, uint256 index);
71
+ event BuyNativeFailed(string reason);
72
+
73
+ receive() external payable {}
74
+
75
+ function initialize(
76
+ INameService _ns,
77
+ IStaticOracle _oracle
78
+ ) external initializer {
79
+ __AccessControlEnumerable_init();
80
+ setDAO(_ns);
81
+ _setupRole(DEFAULT_ADMIN_ROLE, avatar); //this needs to happen after setDAO for avatar to be non empty
82
+ _setupRole(GUARDIAN_ROLE, avatar);
83
+ mpbBridge = IMessagePassingBridge(
84
+ nameService.getAddress("MPBBRIDGE_CONTRACT")
85
+ );
86
+ STATIC_ORACLE = _oracle;
87
+ uint24[] memory fees = new uint24[](1);
88
+ fees[0] = 10000;
89
+ STATIC_ORACLE.prepareSpecificFeeTiersWithTimePeriod(
90
+ CUSD,
91
+ address(nativeToken()),
92
+ fees,
93
+ 60
94
+ );
95
+ fees[0] = 100;
96
+ STATIC_ORACLE.prepareSpecificFeeTiersWithTimePeriod(CUSD, CELO, fees, 60);
97
+ }
98
+
99
+ function setFeeSettings(
100
+ FeeSettings memory _feeData
101
+ ) external onlyRole(GUARDIAN_ROLE) {
102
+ feeSettings = _feeData;
103
+ }
104
+
105
+ /**
106
+ * @notice this is usually called by reserve, but can be called by anyone anytime to trigger distribution
107
+ * @param _amount how much was sent, informational only
108
+ */
109
+ function onDistribution(uint256 _amount) external virtual {
110
+ //we consider the actual balance and not _amount
111
+ uint256 toDistribute = nativeToken().balanceOf(address(this));
112
+ if (toDistribute == 0) return;
113
+
114
+ uint256 boughtNative;
115
+ uint256 gdToSellForFee;
116
+ uint256 minReceived;
117
+ if (address(this).balance < feeSettings.minBalanceForFees) {
118
+ gdToSellForFee =
119
+ (toDistribute * feeSettings.percentageToSellForFee) /
120
+ 100;
121
+ (gdToSellForFee, minReceived) = calcGDToSell(gdToSellForFee);
122
+ toDistribute -= gdToSellForFee;
123
+ boughtNative = buyNativeWithGD(gdToSellForFee, minReceived);
124
+ }
125
+
126
+ uint256 totalDistributed;
127
+ for (uint256 i = 0; i < distributionRecipients.length; i++) {
128
+ DistributionRecipient storage r = distributionRecipients[i];
129
+ if (r.bps > 0) {
130
+ uint256 toTransfer = (toDistribute * r.bps) / 10000;
131
+ totalDistributed += toTransfer;
132
+ if (toTransfer > 0) distribute(r, toTransfer);
133
+ }
134
+ }
135
+
136
+ emit Distribution(
137
+ totalDistributed,
138
+ toDistribute,
139
+ _amount,
140
+ distributionRecipients,
141
+ gdToSellForFee,
142
+ boughtNative
143
+ );
144
+ }
145
+
146
+ /**
147
+ * @notice add or update a recipient details, if address exists it will update, otherwise add
148
+ * to "remove" set recipient bps to 0. only ADMIN_ROLE can call this.
149
+ */
150
+ function addOrUpdateRecipient(
151
+ DistributionRecipient memory _recipient
152
+ ) external onlyRole(DEFAULT_ADMIN_ROLE) {
153
+ if (
154
+ _recipient.transferType != TransferType.LayerZeroBridge &&
155
+ _recipient.chainId != block.chainid
156
+ ) {
157
+ revert INVALID_CHAINID();
158
+ }
159
+
160
+ for (uint256 i = 0; i < distributionRecipients.length; i++) {
161
+ if (distributionRecipients[i].addr == _recipient.addr) {
162
+ distributionRecipients[i] = _recipient;
163
+ emit RecipientUpdated(_recipient, i);
164
+ return;
165
+ }
166
+ }
167
+ //if reached here then add new one
168
+ emit RecipientAdded(_recipient, distributionRecipients.length);
169
+ distributionRecipients.push(_recipient);
170
+ }
171
+
172
+ /**
173
+ * @notice internal function that takes care of sending the G$s according to the transfer type
174
+ * @param _recipient data about the recipient
175
+ * @param _amount how much to send
176
+ */
177
+ function distribute(
178
+ DistributionRecipient storage _recipient,
179
+ uint256 _amount
180
+ ) internal {
181
+ if (_recipient.transferType == TransferType.LayerZeroBridge) {
182
+ nativeToken().approve(address(mpbBridge), _amount);
183
+ (uint256 lzFee, ) = ILayerZeroFeeEstimator(address(mpbBridge))
184
+ .estimateSendFee(
185
+ mpbBridge.toLzChainId(_recipient.chainId),
186
+ address(this),
187
+ _recipient.addr,
188
+ _amount,
189
+ false,
190
+ abi.encodePacked(uint16(1), uint256(400000)) // 400k gas to execute bridge at target chain
191
+ );
192
+ if (lzFee > feeSettings.maxFee || lzFee > address(this).balance)
193
+ revert FEE_LIMIT(lzFee);
194
+
195
+ mpbBridge.bridgeToWithLz{ value: lzFee }(
196
+ _recipient.addr,
197
+ _recipient.chainId,
198
+ _amount,
199
+ ""
200
+ );
201
+ } else if (_recipient.transferType == TransferType.TransferAndCall) {
202
+ nativeToken().transferAndCall(_recipient.addr, _amount, "");
203
+ } else if (_recipient.transferType == TransferType.Transfer) {
204
+ nativeToken().transfer(_recipient.addr, _amount);
205
+ }
206
+ }
207
+
208
+ function calcGDToSell(
209
+ uint256 maxAmountToSell
210
+ ) public view returns (uint256 gdToSell, uint256 minReceived) {
211
+ uint24[] memory fees = new uint24[](1);
212
+ fees[0] = 100;
213
+ uint256 nativeToBuy = feeSettings.minBalanceForFees *
214
+ 3 -
215
+ address(this).balance;
216
+ (uint256 nativeValueInUSD, ) = STATIC_ORACLE
217
+ .quoteSpecificFeeTiersWithTimePeriod(
218
+ uint128(nativeToBuy),
219
+ CELO,
220
+ CUSD,
221
+ fees,
222
+ 60 //last 1 minute
223
+ );
224
+
225
+ fees[0] = 10000;
226
+ (gdToSell, ) = STATIC_ORACLE.quoteSpecificFeeTiersWithTimePeriod(
227
+ uint128(nativeValueInUSD),
228
+ CUSD,
229
+ address(nativeToken()),
230
+ fees,
231
+ 60 //last 1 minute
232
+ );
233
+
234
+ minReceived = nativeToBuy;
235
+ if (gdToSell > maxAmountToSell) {
236
+ gdToSell = maxAmountToSell;
237
+
238
+ fees[0] = 10000;
239
+ // gdToSell = (nativeValueInUSD * 1e18) / gdPriceInUSD; // mul by 1e18 so result is in 18 decimals
240
+ (uint256 minReceivedCUSD, ) = STATIC_ORACLE
241
+ .quoteSpecificFeeTiersWithTimePeriod(
242
+ uint128(gdToSell),
243
+ address(nativeToken()),
244
+ CUSD,
245
+ fees,
246
+ 60 //last 1 minute
247
+ );
248
+
249
+ fees[0] = 100;
250
+ (minReceived, ) = STATIC_ORACLE.quoteSpecificFeeTiersWithTimePeriod(
251
+ uint128(minReceivedCUSD),
252
+ CUSD,
253
+ CELO,
254
+ fees,
255
+ 60 //last 1 minute
256
+ );
257
+ }
258
+ }
259
+
260
+ function buyNativeWithGD(
261
+ uint256 amountToSell,
262
+ uint256 minReceived
263
+ ) internal returns (uint256 nativeBought) {
264
+ ERC20(nativeToken()).approve(address(ROUTER), amountToSell);
265
+ uint256 amountOutMinimum = (minReceived * (100 - feeSettings.maxSlippage)) /
266
+ 100; // 5% slippage
267
+ ISwapRouter.ExactInputParams memory params = ISwapRouter.ExactInputParams({
268
+ path: abi.encodePacked(
269
+ nativeToken(),
270
+ uint24(10000),
271
+ CUSD,
272
+ uint24(100),
273
+ CELO
274
+ ),
275
+ recipient: address(this),
276
+ amountIn: amountToSell,
277
+ amountOutMinimum: amountOutMinimum
278
+ });
279
+ try ROUTER.exactInput(params) returns (uint256 amountOut) {
280
+ return amountOut;
281
+ } catch Error(string memory reason) {
282
+ emit BuyNativeFailed(reason);
283
+ return 0;
284
+ }
285
+ }
286
+ }
@@ -300,8 +300,18 @@ contract GoodMarketMaker is DAOUpgradeableContract, DSMath {
300
300
 
301
301
  // The return value after the deduction
302
302
  uint256 tokenReturn = sellReturn(_token, amountAfterContribution);
303
- rtoken.gdSupply -= _gdAmount;
303
+
304
+ rtoken.gdSupply -= amountAfterContribution;
304
305
  rtoken.reserveSupply -= tokenReturn;
306
+ //burn contributed tokens on curve
307
+ if (_contributionGdAmount > 0) {
308
+ uint256 nom = rtoken.gdSupply * rtoken.reserveRatio;
309
+ uint256 denom = rtoken.gdSupply - _contributionGdAmount;
310
+ uint256 newRatio = nom / denom;
311
+ rtoken.reserveRatio = uint32(newRatio);
312
+ rtoken.gdSupply -= _contributionGdAmount;
313
+ }
314
+
305
315
  emit BalancesUpdated(
306
316
  msg.sender,
307
317
  address(_token),
@@ -398,13 +398,16 @@ contract GoodFundManager is DAOUpgradeableContract, DSMath {
398
398
  staking.blockStart,
399
399
  staking.blockEnd
400
400
  );
401
- if (amount > 0 && staking.isBlackListed == false) {
401
+ if (
402
+ amount > 0 &&
403
+ staking.isBlackListed == false &&
404
+ GoodReserveCDai(nameService.getAddress("RESERVE")).paused() == false
405
+ ) {
402
406
  GoodReserveCDai(nameService.getAddress("RESERVE")).mintRewardFromRR(
403
407
  _token,
404
408
  _user,
405
409
  amount
406
410
  );
407
-
408
411
  emit StakingRewardMinted(msg.sender, _user, amount);
409
412
  }
410
413
  }
@@ -0,0 +1,129 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity >=0.8.0;
3
+
4
+ import "../MentoInterfaces.sol";
5
+ import "@openzeppelin/contracts/access/AccessControl.sol";
6
+ import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
7
+ import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
8
+ import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
9
+
10
+ contract BuyFromReserveHelper is AccessControl, ReentrancyGuard {
11
+ using SafeERC20 for IERC20;
12
+
13
+ bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");
14
+ bytes32 public constant EXECUTOR_ROLE = keccak256("EXECUTOR_ROLE");
15
+
16
+ address public safe;
17
+ address public exchangeProvider;
18
+ bytes32 public exchangeId;
19
+ IERC20 public tokenIn;
20
+ IERC20 public tokenOut;
21
+ IBroker public broker;
22
+
23
+ event SafeUpdated(address indexed newSafe);
24
+ event SettingsUpdated(
25
+ address indexed exchangeProvider,
26
+ bytes32 indexed exchangeId
27
+ );
28
+ event GDBought(address indexed buyer, uint256 amountIn, uint256 amountOut);
29
+
30
+ constructor(
31
+ address _safe,
32
+ address _tokenIn,
33
+ address _tokenOut,
34
+ address _broker,
35
+ address _exchangeProvider,
36
+ bytes32 _exchangeId
37
+ ) {
38
+ require(_safe != address(0), "Safe address cannot be zero");
39
+ require(_tokenIn != address(0), "TokenIn address cannot be zero");
40
+ require(_tokenOut != address(0), "TokenOut address cannot be zero");
41
+ require(_broker != address(0), "Broker address cannot be zero");
42
+ require(_exchangeProvider != address(0), "ExchangeProvider cannot be zero");
43
+ require(_exchangeId != bytes32(0), "ExchangeId cannot be zero");
44
+
45
+ safe = _safe;
46
+ tokenIn = IERC20(_tokenIn);
47
+ tokenOut = IERC20(_tokenOut);
48
+ broker = IBroker(_broker);
49
+ exchangeProvider = _exchangeProvider;
50
+ exchangeId = _exchangeId;
51
+
52
+ _setupRole(DEFAULT_ADMIN_ROLE, _safe);
53
+ _setupRole(EXECUTOR_ROLE, msg.sender);
54
+ }
55
+
56
+ function updateSafe(address _newSafe) external {
57
+ require(msg.sender == safe, "Only safe can update");
58
+ require(_newSafe != address(0), "New safe address cannot be zero");
59
+
60
+ // Update admin role
61
+ _revokeRole(DEFAULT_ADMIN_ROLE, safe);
62
+ _setupRole(DEFAULT_ADMIN_ROLE, _newSafe);
63
+
64
+ safe = _newSafe;
65
+ emit SafeUpdated(_newSafe);
66
+ }
67
+
68
+ function updateSettings(
69
+ address _exchangeProvider,
70
+ bytes32 _exchangeId,
71
+ address _tokenIn,
72
+ address _tokenOut,
73
+ address _broker
74
+ ) external onlyRole(DEFAULT_ADMIN_ROLE) {
75
+ require(_exchangeProvider != address(0), "ExchangeProvider cannot be zero");
76
+ require(_exchangeId != bytes32(0), "ExchangeId cannot be zero");
77
+ require(_tokenIn != address(0), "TokenIn address cannot be zero");
78
+ require(_tokenOut != address(0), "TokenOut address cannot be zero");
79
+ require(_broker != address(0), "Broker address cannot be zero");
80
+
81
+ exchangeProvider = _exchangeProvider;
82
+ exchangeId = _exchangeId;
83
+ tokenIn = IERC20(_tokenIn);
84
+ tokenOut = IERC20(_tokenOut);
85
+ broker = IBroker(_broker);
86
+
87
+ emit SettingsUpdated(_exchangeProvider, _exchangeId);
88
+ }
89
+
90
+ function buyGdFromBroker(
91
+ uint256 amountInNominal,
92
+ uint256 minReturnNominal
93
+ ) external onlyRole(EXECUTOR_ROLE) nonReentrant {
94
+ require(amountInNominal > 0, "Amount must be greater than zero");
95
+ require(minReturnNominal > 0, "Minimum return must be greater than zero");
96
+
97
+ uint256 amountIn = amountInNominal * 1e18;
98
+ uint256 minReturn = minReturnNominal * 1e18;
99
+
100
+ // assume minimum price for 0.00005 for G$ for safety check
101
+ require((amountIn * 1e18) / 5e13 >= minReturn, "minReturn seems too low");
102
+
103
+ // Transfer tokenIn from the safe to this contract
104
+ tokenIn.safeTransferFrom(safe, address(this), amountIn);
105
+
106
+ // Reset any existing approval
107
+ tokenIn.safeApprove(address(broker), 0);
108
+ // Approve the broker to spend tokenIn
109
+ tokenIn.safeApprove(address(broker), amountIn);
110
+
111
+ // Call the broker to buy tokenOut (G$)
112
+ uint256 amountOut = broker.swapIn(
113
+ exchangeProvider,
114
+ exchangeId,
115
+ address(tokenIn),
116
+ address(tokenOut),
117
+ amountIn,
118
+ minReturn
119
+ );
120
+
121
+ // Verify minimum return
122
+ require(amountOut >= minReturn, "Insufficient return amount");
123
+
124
+ // Transfer bought tokens to safe
125
+ tokenOut.safeTransfer(safe, amountOut);
126
+
127
+ emit GDBought(msg.sender, amountIn, amountOut);
128
+ }
129
+ }
@@ -0,0 +1,99 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity >=0.8.0;
3
+
4
+ import "../utils/NameService.sol";
5
+ import "../Interfaces.sol";
6
+ import "../MentoInterfaces.sol";
7
+
8
+ // import "hardhat/console.sol";
9
+
10
+ interface MentoExchange {
11
+ function reserve() external view returns (address);
12
+ }
13
+
14
+ contract ProtocolUpgradeV4Mento {
15
+ address avatar;
16
+
17
+ constructor(address _avatar) {
18
+ avatar = _avatar;
19
+ }
20
+
21
+ function upgrade(
22
+ Controller _controller,
23
+ IBancorExchangeProvider.PoolExchange memory _exchange,
24
+ address _mentoExchange,
25
+ address _mentoController,
26
+ address _distHelper,
27
+ uint256 totalGlobalSupply
28
+ ) external {
29
+ require(msg.sender == address(avatar), "only avatar can call this");
30
+
31
+ // uint32 expansionFrequency = 1 days;
32
+ // uint64 expansionRate = 288617289021952; //10% a year = ((1e18 - expansionRate)/1e18)^365=0.9
33
+ uint256 cUSDBalance = ERC20(_exchange.reserveAsset).balanceOf(
34
+ MentoExchange(_mentoExchange).reserve()
35
+ );
36
+ require(cUSDBalance >= 200000e18, "not enough reserve");
37
+
38
+ uint256 gdSupply = ERC20(_exchange.tokenAddress).totalSupply();
39
+ uint256 price = 0.0001 ether; // we initialize with price of 0.0001
40
+ // given price calculate the reserve ratio
41
+ uint32 reserveRatio = uint32(
42
+ (cUSDBalance * 1e18 * 1e8) / (price * totalGlobalSupply)
43
+ ); //cUSDBalance/(price * gdSupply/1e18) * 1e8
44
+ uint32 exitContribution = 0.1 * 1e8;
45
+
46
+ _exchange.reserveBalance = cUSDBalance;
47
+ _exchange.tokenSupply = totalGlobalSupply;
48
+ _exchange.reserveRatio = reserveRatio;
49
+ _exchange.exitContribution = exitContribution;
50
+
51
+ (bool ok, bytes memory result) = _controller.genericCall(
52
+ address(_mentoExchange),
53
+ abi.encodeCall(IBancorExchangeProvider.createExchange, _exchange),
54
+ address(avatar),
55
+ 0
56
+ );
57
+
58
+ // console.log("createExchange %s", ok);
59
+ require(ok, "createExchange failed");
60
+ bytes32 exchangeId = abi.decode(result, (bytes32));
61
+ // console.logBytes32(exchangeId);
62
+ (ok, ) = _controller.genericCall(
63
+ address(_mentoController),
64
+ abi.encodeCall(
65
+ IGoodDollarExpansionController.setExpansionConfig,
66
+ (exchangeId, 288617289021952, 1 days) //10% a year = ((1e18 - expansionRate)/1e18)^365=0.9 frequency 1 day
67
+ ),
68
+ address(avatar),
69
+ 0
70
+ );
71
+ require(ok, "setExpansionConfig failed");
72
+
73
+ (ok, ) = _controller.genericCall(
74
+ address(_mentoController),
75
+ abi.encodeCall(
76
+ IGoodDollarExpansionController.setDistributionHelper,
77
+ _distHelper
78
+ ),
79
+ address(avatar),
80
+ 0
81
+ );
82
+ require(ok, "setDistribuitionHelper failed");
83
+
84
+ // mint exit liquidity to bridge
85
+ uint256 toMint = totalGlobalSupply - gdSupply;
86
+ require(
87
+ _controller.mintTokens(
88
+ toMint,
89
+ 0xa3247276DbCC76Dd7705273f766eB3E8a5ecF4a5,
90
+ address(avatar)
91
+ ),
92
+ "bridge minting failed"
93
+ );
94
+
95
+ // prevent executing again
96
+ require(_controller.unregisterSelf(avatar), "unregistering failed");
97
+ avatar = address(0);
98
+ }
99
+ }