@gooddollar/goodprotocol 2.0.32 → 2.0.34-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 (566) hide show
  1. package/artifacts/abis/BuyFromReserveHelper.min.json +1 -0
  2. package/artifacts/abis/Faucet.min.json +1 -1
  3. package/artifacts/abis/GoodDollar2.min.json +1 -0
  4. package/artifacts/abis/ISuperToken.min.json +1 -1
  5. package/artifacts/abis/IdentityV3.min.json +1 -0
  6. package/artifacts/abis/SuperGoodDollar.min.json +1 -1
  7. package/artifacts/abis/SuperToken.min.json +1 -1
  8. package/artifacts/abis/SuperfluidFaucet.min.json +1 -1
  9. package/artifacts/abis/UBISchemeV2.min.json +1 -1
  10. package/artifacts/contracts/DAOStackInterfaces.sol/Avatar.dbg.json +1 -1
  11. package/artifacts/contracts/DAOStackInterfaces.sol/Controller.dbg.json +1 -1
  12. package/artifacts/contracts/DAOStackInterfaces.sol/GlobalConstraintInterface.dbg.json +1 -1
  13. package/artifacts/contracts/DAOStackInterfaces.sol/IntVoteInterface.dbg.json +1 -1
  14. package/artifacts/contracts/DAOStackInterfaces.sol/ReputationInterface.dbg.json +1 -1
  15. package/artifacts/contracts/DAOStackInterfaces.sol/SchemeRegistrar.dbg.json +1 -1
  16. package/artifacts/contracts/IQuoter.sol/IQuoterV2.dbg.json +4 -0
  17. package/artifacts/contracts/IQuoter.sol/IQuoterV2.json +211 -0
  18. package/artifacts/contracts/Interfaces.sol/AggregatorV3Interface.dbg.json +1 -1
  19. package/artifacts/contracts/Interfaces.sol/ERC20.dbg.json +1 -1
  20. package/artifacts/contracts/Interfaces.sol/IAaveIncentivesController.dbg.json +1 -1
  21. package/artifacts/contracts/Interfaces.sol/IAdminWallet.dbg.json +1 -1
  22. package/artifacts/contracts/Interfaces.sol/IDonationStaking.dbg.json +1 -1
  23. package/artifacts/contracts/Interfaces.sol/IERC2917.dbg.json +1 -1
  24. package/artifacts/contracts/Interfaces.sol/IFirstClaimPool.dbg.json +1 -1
  25. package/artifacts/contracts/Interfaces.sol/IGoodDollar.dbg.json +1 -1
  26. package/artifacts/contracts/Interfaces.sol/IGoodStaking.dbg.json +1 -1
  27. package/artifacts/contracts/Interfaces.sol/IHasRouter.dbg.json +1 -1
  28. package/artifacts/contracts/Interfaces.sol/IIdentity.dbg.json +1 -1
  29. package/artifacts/contracts/Interfaces.sol/IIdentityV2.dbg.json +1 -1
  30. package/artifacts/contracts/Interfaces.sol/ILendingPool.dbg.json +1 -1
  31. package/artifacts/contracts/Interfaces.sol/IMultichainRouter.dbg.json +1 -1
  32. package/artifacts/contracts/Interfaces.sol/INameService.dbg.json +1 -1
  33. package/artifacts/contracts/Interfaces.sol/IQuoterV2.dbg.json +1 -1
  34. package/artifacts/contracts/Interfaces.sol/ISwapRouter.dbg.json +1 -1
  35. package/artifacts/contracts/Interfaces.sol/IUBIScheme.dbg.json +1 -1
  36. package/artifacts/contracts/Interfaces.sol/ProxyAdmin.dbg.json +1 -1
  37. package/artifacts/contracts/Interfaces.sol/Reserve.dbg.json +1 -1
  38. package/artifacts/contracts/Interfaces.sol/Staking.dbg.json +1 -1
  39. package/artifacts/contracts/Interfaces.sol/Uniswap.dbg.json +1 -1
  40. package/artifacts/contracts/Interfaces.sol/UniswapFactory.dbg.json +1 -1
  41. package/artifacts/contracts/Interfaces.sol/UniswapPair.dbg.json +1 -1
  42. package/artifacts/contracts/Interfaces.sol/cERC20.dbg.json +1 -1
  43. package/artifacts/contracts/MentoInterfaces.sol/IBancorExchangeProvider.dbg.json +1 -1
  44. package/artifacts/contracts/MentoInterfaces.sol/IBroker.dbg.json +1 -1
  45. package/artifacts/contracts/MentoInterfaces.sol/IGoodDollarExchangeProvider.dbg.json +1 -1
  46. package/artifacts/contracts/MentoInterfaces.sol/IGoodDollarExpansionController.dbg.json +1 -1
  47. package/artifacts/contracts/MentoInterfaces.sol/IMentoReserve.dbg.json +1 -1
  48. package/artifacts/contracts/MentoInterfaces.sol/ITradingLimits.dbg.json +1 -1
  49. package/artifacts/contracts/fuseFaucet/Faucet.sol/Faucet.dbg.json +1 -1
  50. package/artifacts/contracts/fuseFaucet/Faucet.sol/Faucet.json +57 -2
  51. package/artifacts/contracts/fuseFaucet/FuseFaucet.sol/FuseFaucet.dbg.json +1 -1
  52. package/artifacts/contracts/fuseFaucet/FuseFaucet.sol/FuseFaucet.json +2 -2
  53. package/artifacts/contracts/fuseFaucet/FuseFaucetV2.sol/FuseFaucetV2.dbg.json +1 -1
  54. package/artifacts/contracts/fuseFaucet/FuseFaucetV2.sol/FuseFaucetV2.json +2 -2
  55. package/artifacts/contracts/fuseFaucet/SuperfluidFacuet.sol/SuperfluidFaucet.dbg.json +1 -1
  56. package/artifacts/contracts/fuseFaucet/SuperfluidFacuet.sol/SuperfluidFaucet.json +46 -28
  57. package/artifacts/contracts/governance/ClaimersDistribution.sol/ClaimersDistribution.dbg.json +1 -1
  58. package/artifacts/contracts/governance/ClaimersDistribution.sol/ClaimersDistribution.json +2 -2
  59. package/artifacts/contracts/governance/CompoundVotingMachine.sol/CompoundVotingMachine.dbg.json +1 -1
  60. package/artifacts/contracts/governance/CompoundVotingMachine.sol/CompoundVotingMachine.json +2 -2
  61. package/artifacts/contracts/governance/GReputation.sol/GReputation.dbg.json +1 -1
  62. package/artifacts/contracts/governance/GReputation.sol/GReputation.json +2 -2
  63. package/artifacts/contracts/governance/GoodDollarStaking.sol/GoodDollarStaking.dbg.json +1 -1
  64. package/artifacts/contracts/governance/GoodDollarStaking.sol/GoodDollarStaking.json +2 -2
  65. package/artifacts/contracts/governance/GoodDollarStaking.sol/IGovernanceStaking.dbg.json +1 -1
  66. package/artifacts/contracts/governance/GoodDollarStaking.sol/IStakingUpgrade.dbg.json +1 -1
  67. package/artifacts/contracts/governance/GoodDollarStaking.sol/RewardsMinter.dbg.json +1 -1
  68. package/artifacts/contracts/governance/GovernanceStaking.sol/GovernanceStaking.dbg.json +1 -1
  69. package/artifacts/contracts/governance/GovernanceStaking.sol/GovernanceStaking.json +2 -2
  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/Reputation.sol/Reputation.json +2 -2
  73. package/artifacts/contracts/governance/StakersDistribution.sol/StakersDistribution.dbg.json +1 -1
  74. package/artifacts/contracts/governance/StakersDistribution.sol/StakersDistribution.json +2 -2
  75. package/artifacts/contracts/identity/IdentityV2.sol/IdentityV2.dbg.json +1 -1
  76. package/artifacts/contracts/identity/IdentityV2.sol/IdentityV2.json +2 -2
  77. package/artifacts/contracts/identity/IdentityV3.sol/IdentityV3.dbg.json +4 -0
  78. package/artifacts/contracts/identity/IdentityV3.sol/IdentityV3.json +1089 -0
  79. package/artifacts/contracts/invite/InvitesFuseV2.sol/InvitesFuseV2.dbg.json +1 -1
  80. package/artifacts/contracts/invite/InvitesFuseV2.sol/InvitesFuseV2.json +2 -2
  81. package/artifacts/contracts/invite/InvitesV1.sol/InvitesV1.dbg.json +1 -1
  82. package/artifacts/contracts/invite/InvitesV1.sol/InvitesV1.json +2 -2
  83. package/artifacts/contracts/invite/InvitesV2.sol/InvitesV2.dbg.json +1 -1
  84. package/artifacts/contracts/invite/InvitesV2.sol/InvitesV2.json +2 -2
  85. package/artifacts/contracts/invite/OneTimeReward.sol/OneTimeReward.dbg.json +1 -1
  86. package/artifacts/contracts/invite/OneTimeReward.sol/OneTimeReward.json +2 -2
  87. package/artifacts/contracts/mocks/AaveMock.sol/AaveMock.dbg.json +1 -1
  88. package/artifacts/contracts/mocks/AaveMock.sol/AaveMock.json +2 -2
  89. package/artifacts/contracts/mocks/AaveUSDMockOracle.sol/AaveUSDMockOracle.dbg.json +1 -1
  90. package/artifacts/contracts/mocks/AaveUSDMockOracle.sol/AaveUSDMockOracle.json +2 -2
  91. package/artifacts/contracts/mocks/BatUSDMockOracle.sol/BatUSDMockOracle.dbg.json +1 -1
  92. package/artifacts/contracts/mocks/BatUSDMockOracle.sol/BatUSDMockOracle.json +2 -2
  93. package/artifacts/contracts/mocks/CeloDistributionHelperTest.sol/CeloDistributionHelperTest.dbg.json +1 -1
  94. package/artifacts/contracts/mocks/CeloDistributionHelperTest.sol/CeloDistributionHelperTest.json +2 -2
  95. package/artifacts/contracts/mocks/CeloDistributionHelperTest.sol/CeloDistributionHelperTestHelper.dbg.json +1 -1
  96. package/artifacts/contracts/mocks/CeloDistributionHelperTest.sol/CeloDistributionHelperTestHelper.json +2 -2
  97. package/artifacts/contracts/mocks/CompUsdMockOracle.sol/CompUSDMockOracle.dbg.json +1 -1
  98. package/artifacts/contracts/mocks/CompUsdMockOracle.sol/CompUSDMockOracle.json +2 -2
  99. package/artifacts/contracts/mocks/DAIMock.sol/DAIMock.dbg.json +1 -1
  100. package/artifacts/contracts/mocks/DAIMock.sol/DAIMock.json +2 -2
  101. package/artifacts/contracts/mocks/DaiEthPriceMockOracle.sol/DaiEthPriceMockOracle.dbg.json +1 -1
  102. package/artifacts/contracts/mocks/DaiEthPriceMockOracle.sol/DaiEthPriceMockOracle.json +2 -2
  103. package/artifacts/contracts/mocks/DecimalsMock.sol/DecimalsMock.dbg.json +1 -1
  104. package/artifacts/contracts/mocks/DecimalsMock.sol/DecimalsMock.json +2 -2
  105. package/artifacts/contracts/mocks/DistributionBridgeMock.sol/DistributionBridgeMock.dbg.json +1 -1
  106. package/artifacts/contracts/mocks/DistributionBridgeMock.sol/DistributionBridgeMock.json +2 -2
  107. package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTest.dbg.json +1 -1
  108. package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTest.json +2 -2
  109. package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTestHelper.dbg.json +1 -1
  110. package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTestHelper.json +2 -2
  111. package/artifacts/contracts/mocks/EthUSDMockOracle.sol/EthUSDMockOracle.dbg.json +1 -1
  112. package/artifacts/contracts/mocks/EthUSDMockOracle.sol/EthUSDMockOracle.json +2 -2
  113. package/artifacts/contracts/mocks/FeesFormularMock.sol/FeesFormulaMock.dbg.json +1 -1
  114. package/artifacts/contracts/mocks/FeesFormularMock.sol/FeesFormulaMock.json +2 -2
  115. package/artifacts/contracts/mocks/GasPriceMockOracle.sol/GasPriceMockOracle.dbg.json +1 -1
  116. package/artifacts/contracts/mocks/GasPriceMockOracle.sol/GasPriceMockOracle.json +2 -2
  117. package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.dbg.json +1 -1
  118. package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.json +2 -2
  119. package/artifacts/contracts/mocks/GoodDollarStakingMock.sol/GoodDollarStakingMock.dbg.json +1 -1
  120. package/artifacts/contracts/mocks/GoodDollarStakingMock.sol/GoodDollarStakingMock.json +2 -2
  121. package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.dbg.json +1 -1
  122. package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.json +2 -2
  123. package/artifacts/contracts/mocks/IdentityMock.sol/IdentityMock.dbg.json +1 -1
  124. package/artifacts/contracts/mocks/IdentityMock.sol/IdentityMock.json +2 -2
  125. package/artifacts/contracts/mocks/IncentiveControllerMock.sol/IncentiveControllerMock.dbg.json +1 -1
  126. package/artifacts/contracts/mocks/IncentiveControllerMock.sol/IncentiveControllerMock.json +2 -2
  127. package/artifacts/contracts/mocks/LendingPoolMock.sol/LendingPoolMock.dbg.json +1 -1
  128. package/artifacts/contracts/mocks/LendingPoolMock.sol/LendingPoolMock.json +2 -2
  129. package/artifacts/contracts/mocks/MultichainRouterMock.sol/IWrapper.dbg.json +1 -1
  130. package/artifacts/contracts/mocks/MultichainRouterMock.sol/MultichainRouterMock.dbg.json +1 -1
  131. package/artifacts/contracts/mocks/MultichainRouterMock.sol/MultichainRouterMock.json +2 -2
  132. package/artifacts/contracts/mocks/OverMintTester.sol/IGoodDollarStakingTest.dbg.json +1 -1
  133. package/artifacts/contracts/mocks/OverMintTester.sol/OverMintTester.dbg.json +1 -1
  134. package/artifacts/contracts/mocks/OverMintTester.sol/OverMintTester.json +2 -2
  135. package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.dbg.json +1 -1
  136. package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.json +2 -2
  137. package/artifacts/contracts/mocks/PayableMock.sol/PayableMock.dbg.json +1 -1
  138. package/artifacts/contracts/mocks/PayableMock.sol/PayableMock.json +2 -2
  139. package/artifacts/contracts/mocks/SixteenDecimalsTokenMock.sol/SixteenDecimalsTokenMock.dbg.json +1 -1
  140. package/artifacts/contracts/mocks/SixteenDecimalsTokenMock.sol/SixteenDecimalsTokenMock.json +2 -2
  141. package/artifacts/contracts/mocks/StakingMockFixedAPY.sol/StakingMockFixedAPY.dbg.json +1 -1
  142. package/artifacts/contracts/mocks/StakingMockFixedAPY.sol/StakingMockFixedAPY.json +2 -2
  143. package/artifacts/contracts/mocks/SwapHelperTest.sol/SwapHelperTest.dbg.json +1 -1
  144. package/artifacts/contracts/mocks/SwapHelperTest.sol/SwapHelperTest.json +2 -2
  145. package/artifacts/contracts/mocks/TwentyDecimalsTokenMock.sol/TwentyDecimalsTokenMock.dbg.json +1 -1
  146. package/artifacts/contracts/mocks/TwentyDecimalsTokenMock.sol/TwentyDecimalsTokenMock.json +2 -2
  147. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock.dbg.json +1 -1
  148. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock.json +2 -2
  149. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock2.dbg.json +1 -1
  150. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock2.json +2 -2
  151. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock3.dbg.json +1 -1
  152. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock3.json +2 -2
  153. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock4.dbg.json +1 -1
  154. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock4.json +2 -2
  155. package/artifacts/contracts/mocks/UsdcMock.sol/USDCMock.dbg.json +1 -1
  156. package/artifacts/contracts/mocks/UsdcMock.sol/USDCMock.json +2 -2
  157. package/artifacts/contracts/mocks/cBATMock.sol/cBATMock.dbg.json +1 -1
  158. package/artifacts/contracts/mocks/cBATMock.sol/cBATMock.json +2 -2
  159. package/artifacts/contracts/mocks/cDAILowWorthMock.sol/cDAILowWorthMock.dbg.json +1 -1
  160. package/artifacts/contracts/mocks/cDAILowWorthMock.sol/cDAILowWorthMock.json +2 -2
  161. package/artifacts/contracts/mocks/cDAIMock.sol/cDAIMock.dbg.json +1 -1
  162. package/artifacts/contracts/mocks/cDAIMock.sol/cDAIMock.json +2 -2
  163. package/artifacts/contracts/mocks/cDAINonMintableMock.sol/cDAINonMintableMock.dbg.json +1 -1
  164. package/artifacts/contracts/mocks/cDAINonMintableMock.sol/cDAINonMintableMock.json +2 -2
  165. package/artifacts/contracts/mocks/cDecimalsMock.sol/cDecimalsMock.dbg.json +1 -1
  166. package/artifacts/contracts/mocks/cDecimalsMock.sol/cDecimalsMock.json +2 -2
  167. package/artifacts/contracts/mocks/cSDTMock.sol/cSDTMock.dbg.json +1 -1
  168. package/artifacts/contracts/mocks/cSDTMock.sol/cSDTMock.json +2 -2
  169. package/artifacts/contracts/mocks/cUSDCMock.sol/cUSDCMock.dbg.json +1 -1
  170. package/artifacts/contracts/mocks/cUSDCMock.sol/cUSDCMock.json +2 -2
  171. package/artifacts/contracts/reserve/CeloDistributionHelper.sol/CeloDistributionHelper.dbg.json +1 -1
  172. package/artifacts/contracts/reserve/CeloDistributionHelper.sol/CeloDistributionHelper.json +2 -2
  173. package/artifacts/contracts/reserve/DistributionHelper.sol/DistributionHelper.dbg.json +1 -1
  174. package/artifacts/contracts/reserve/DistributionHelper.sol/DistributionHelper.json +2 -2
  175. package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.dbg.json +1 -1
  176. package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.json +2 -2
  177. package/artifacts/contracts/reserve/GoodMarketMaker.sol/GoodMarketMaker.dbg.json +1 -1
  178. package/artifacts/contracts/reserve/GoodMarketMaker.sol/GoodMarketMaker.json +2 -2
  179. package/artifacts/contracts/reserve/GoodReserveCDai.sol/ContributionCalc.dbg.json +1 -1
  180. package/artifacts/contracts/reserve/GoodReserveCDai.sol/GoodReserveCDai.dbg.json +1 -1
  181. package/artifacts/contracts/reserve/GoodReserveCDai.sol/GoodReserveCDai.json +2 -2
  182. package/artifacts/contracts/staking/BaseShareField.sol/BaseShareField.dbg.json +1 -1
  183. package/artifacts/contracts/staking/BaseShareField.sol/BaseShareField.json +2 -2
  184. package/artifacts/contracts/staking/BaseShareFieldV2.sol/BaseShareFieldV2.dbg.json +1 -1
  185. package/artifacts/contracts/staking/BaseShareFieldV2.sol/BaseShareFieldV2.json +2 -2
  186. package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.dbg.json +1 -1
  187. package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.json +2 -2
  188. package/artifacts/contracts/staking/FuseStakingV3.sol/FuseStakingV3.dbg.json +1 -1
  189. package/artifacts/contracts/staking/FuseStakingV3.sol/FuseStakingV3.json +2 -2
  190. package/artifacts/contracts/staking/FuseStakingV3.sol/IConsensus.dbg.json +1 -1
  191. package/artifacts/contracts/staking/FuseStakingV3.sol/PegSwap.dbg.json +1 -1
  192. package/artifacts/contracts/staking/GoodFundManager.sol/GoodFundManager.dbg.json +1 -1
  193. package/artifacts/contracts/staking/GoodFundManager.sol/GoodFundManager.json +2 -2
  194. package/artifacts/contracts/staking/SimpleStaking.sol/SimpleStaking.dbg.json +1 -1
  195. package/artifacts/contracts/staking/SimpleStakingV2.sol/SimpleStakingV2.dbg.json +1 -1
  196. package/artifacts/contracts/staking/UniswapV2SwapHelper.sol/UniswapV2SwapHelper.dbg.json +1 -1
  197. package/artifacts/contracts/staking/UniswapV2SwapHelper.sol/UniswapV2SwapHelper.json +2 -2
  198. package/artifacts/contracts/staking/aave/AaveStakingFactory.sol/AaveStakingFactory.dbg.json +1 -1
  199. package/artifacts/contracts/staking/aave/AaveStakingFactory.sol/AaveStakingFactory.json +2 -2
  200. package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.dbg.json +1 -1
  201. package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.json +2 -2
  202. package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.dbg.json +1 -1
  203. package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.json +2 -2
  204. package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.dbg.json +1 -1
  205. package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.json +2 -2
  206. package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.dbg.json +1 -1
  207. package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.json +2 -2
  208. package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.dbg.json +1 -1
  209. package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.json +2 -2
  210. package/artifacts/contracts/staking/utils/Math64X64.sol/Math64x64.dbg.json +1 -1
  211. package/artifacts/contracts/staking/utils/Math64X64.sol/Math64x64.json +2 -2
  212. package/artifacts/contracts/staking/utils/StakingRewardsFixedAPY.sol/StakingRewardsFixedAPY.dbg.json +1 -1
  213. package/artifacts/contracts/token/ERC20PresetMinterPauserUpgradeable.sol/ERC20PresetMinterPauserUpgradeable.dbg.json +1 -1
  214. package/artifacts/contracts/token/ERC20PresetMinterPauserUpgradeable.sol/ERC20PresetMinterPauserUpgradeable.json +2 -2
  215. package/artifacts/contracts/token/ERC677.sol/ERC677.dbg.json +1 -1
  216. package/artifacts/contracts/token/ERC677.sol/ERC677Receiver.dbg.json +1 -1
  217. package/artifacts/contracts/token/GoodDollar.sol/GoodDollar.dbg.json +1 -1
  218. package/artifacts/contracts/token/GoodDollar.sol/GoodDollar.json +2 -2
  219. package/artifacts/contracts/token/GoodDollar2.sol/GoodDollar2.dbg.json +4 -0
  220. package/artifacts/contracts/token/GoodDollar2.sol/GoodDollar2.json +1206 -0
  221. package/artifacts/contracts/token/IFeesFormula.sol/IFeesFormula.dbg.json +1 -1
  222. package/artifacts/contracts/token/MultichainFeeFormula.sol/MultichainFeeFormula.dbg.json +1 -1
  223. package/artifacts/contracts/token/MultichainFeeFormula.sol/MultichainFeeFormula.json +2 -2
  224. package/artifacts/contracts/token/superfluid/ERC20Permit.sol/ERC20Permit.dbg.json +1 -1
  225. package/artifacts/contracts/token/superfluid/ERC20Permit.sol/SelfApprove.dbg.json +1 -1
  226. package/artifacts/contracts/token/superfluid/ISuperGoodDollar.sol/IGoodDollarCustom.dbg.json +1 -1
  227. package/artifacts/contracts/token/superfluid/ISuperGoodDollar.sol/ISuperGoodDollar.dbg.json +1 -1
  228. package/artifacts/contracts/token/superfluid/ISuperToken.sol/ISuperToken.dbg.json +1 -1
  229. package/artifacts/contracts/token/superfluid/ISuperToken.sol/ISuperToken.json +0 -52
  230. package/artifacts/contracts/token/superfluid/SuperGoodDollar.sol/SuperGoodDollar.dbg.json +1 -1
  231. package/artifacts/contracts/token/superfluid/SuperGoodDollar.sol/SuperGoodDollar.json +2 -74
  232. package/artifacts/contracts/token/superfluid/SuperToken.sol/SuperToken.dbg.json +1 -1
  233. package/artifacts/contracts/token/superfluid/SuperToken.sol/SuperToken.json +2 -54
  234. package/artifacts/contracts/token/superfluid/SuperfluidToken.sol/SuperfluidToken.dbg.json +1 -1
  235. package/artifacts/contracts/token/superfluid/UUPSProxiable.sol/UUPSProxiable.dbg.json +1 -1
  236. package/artifacts/contracts/token/superfluid/UUPSProxy.sol/Proxy.dbg.json +1 -1
  237. package/artifacts/contracts/token/superfluid/UUPSProxy.sol/UUPSProxy.dbg.json +1 -1
  238. package/artifacts/contracts/token/superfluid/UUPSProxy.sol/UUPSProxy.json +2 -2
  239. package/artifacts/contracts/token/superfluid/UUPSProxy.sol/UUPSUtils.dbg.json +1 -1
  240. package/artifacts/contracts/token/superfluid/UUPSProxy.sol/UUPSUtils.json +2 -2
  241. package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.dbg.json +1 -1
  242. package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.json +2 -2
  243. package/artifacts/contracts/ubi/UBISchemeV2.sol/UBISchemeV2.dbg.json +1 -1
  244. package/artifacts/contracts/ubi/UBISchemeV2.sol/UBISchemeV2.json +2 -7
  245. package/artifacts/contracts/utils/AdminWallet.sol/AdminWallet.dbg.json +1 -1
  246. package/artifacts/contracts/utils/AdminWallet.sol/AdminWallet.json +2 -2
  247. package/artifacts/contracts/utils/AdminWalletFuse.sol/AdminWalletFuse.dbg.json +1 -1
  248. package/artifacts/contracts/utils/AdminWalletFuse.sol/AdminWalletFuse.json +2 -2
  249. package/artifacts/contracts/utils/BancorFormula.sol/BancorFormula.dbg.json +1 -1
  250. package/artifacts/contracts/utils/BancorFormula.sol/BancorFormula.json +2 -2
  251. package/artifacts/contracts/utils/BulkProof.sol/BulkProof.dbg.json +1 -1
  252. package/artifacts/contracts/utils/BulkProof.sol/BulkProof.json +2 -2
  253. package/artifacts/contracts/utils/BulkWhitelist.sol/BulkWhitelist.dbg.json +1 -1
  254. package/artifacts/contracts/utils/BulkWhitelist.sol/BulkWhitelist.json +2 -2
  255. package/artifacts/contracts/utils/BuyAndBridgeHelper.sol/BuyAndBridgeHelper.dbg.json +1 -1
  256. package/artifacts/contracts/utils/BuyAndBridgeHelper.sol/BuyAndBridgeHelper.json +2 -2
  257. package/artifacts/contracts/utils/BuyFromReserveHelper.sol/BuyFromReserveHelper.dbg.json +4 -0
  258. package/artifacts/contracts/utils/BuyFromReserveHelper.sol/BuyFromReserveHelper.json +476 -0
  259. package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDClone.dbg.json +1 -1
  260. package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDClone.json +2 -2
  261. package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDCloneFactory.dbg.json +1 -1
  262. package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDCloneFactory.json +2 -2
  263. package/artifacts/contracts/utils/BuyGDClone.sol/DonateGDClone.dbg.json +1 -1
  264. package/artifacts/contracts/utils/BuyGDClone.sol/DonateGDClone.json +2 -2
  265. package/artifacts/contracts/utils/DAOContract.sol/DAOContract.dbg.json +1 -1
  266. package/artifacts/contracts/utils/DAOContract.sol/DAOContract.json +2 -2
  267. package/artifacts/contracts/utils/DAOUpgradeableContract.sol/DAOUpgradeableContract.dbg.json +1 -1
  268. package/artifacts/contracts/utils/DAOUpgradeableContract.sol/DAOUpgradeableContract.json +2 -2
  269. package/artifacts/contracts/utils/DSMath.sol/DSMath.dbg.json +1 -1
  270. package/artifacts/contracts/utils/DSMath.sol/DSMath.json +2 -2
  271. package/artifacts/contracts/utils/DataTypes.sol/DataTypes.dbg.json +1 -1
  272. package/artifacts/contracts/utils/DataTypes.sol/DataTypes.json +2 -2
  273. package/artifacts/contracts/utils/FuseOldBridgeKill.sol/EternalStorage.dbg.json +1 -1
  274. package/artifacts/contracts/utils/FuseOldBridgeKill.sol/EternalStorage.json +2 -2
  275. package/artifacts/contracts/utils/FuseOldBridgeKill.sol/FuseOldBridgeKill.dbg.json +1 -1
  276. package/artifacts/contracts/utils/FuseOldBridgeKill.sol/FuseOldBridgeKill.json +2 -2
  277. package/artifacts/contracts/utils/FuseOldBridgeKill.sol/IUpgradeabilityOwnerStorage.dbg.json +1 -1
  278. package/artifacts/contracts/utils/FuseOldBridgeKill.sol/Initializable.dbg.json +1 -1
  279. package/artifacts/contracts/utils/FuseOldBridgeKill.sol/Initializable.json +2 -2
  280. package/artifacts/contracts/utils/FuseOldBridgeKill.sol/Ownable.dbg.json +1 -1
  281. package/artifacts/contracts/utils/FuseOldBridgeKill.sol/Ownable.json +2 -2
  282. package/artifacts/contracts/utils/FuseOldBridgeKill.sol/Upgradeable.dbg.json +1 -1
  283. package/artifacts/contracts/utils/FuseOldBridgeKill.sol/Upgradeable.json +2 -2
  284. package/artifacts/contracts/utils/GDFaucet.sol/GDFaucet.dbg.json +1 -1
  285. package/artifacts/contracts/utils/GDFaucet.sol/GDFaucet.json +2 -2
  286. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/GoodDollarMintBurnWrapper.dbg.json +1 -1
  287. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/GoodDollarMintBurnWrapper.json +2 -2
  288. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/IRouter.dbg.json +1 -1
  289. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/PausableControl.dbg.json +1 -1
  290. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/TokenOperation.dbg.json +1 -1
  291. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/TokenOperation.json +2 -2
  292. package/artifacts/contracts/utils/IdentityFix.sol/IdentityFix.dbg.json +1 -1
  293. package/artifacts/contracts/utils/IdentityFix.sol/IdentityFix.json +2 -2
  294. package/artifacts/contracts/utils/LastauthReduction.sol/LastauthReduction.dbg.json +1 -1
  295. package/artifacts/contracts/utils/LastauthReduction.sol/LastauthReduction.json +2 -2
  296. package/artifacts/contracts/utils/MultiCall.sol/Multicall.dbg.json +1 -1
  297. package/artifacts/contracts/utils/MultiCall.sol/Multicall.json +2 -2
  298. package/artifacts/contracts/utils/MultichainBridgeHelper.sol/MultichainBridgeHelper.dbg.json +1 -1
  299. package/artifacts/contracts/utils/MultichainBridgeHelper.sol/MultichainBridgeHelper.json +2 -2
  300. package/artifacts/contracts/utils/NameService.sol/NameService.dbg.json +1 -1
  301. package/artifacts/contracts/utils/NameService.sol/NameService.json +2 -2
  302. package/artifacts/contracts/utils/OneTimePayments.sol/OneTimePayments.dbg.json +1 -1
  303. package/artifacts/contracts/utils/OneTimePayments.sol/OneTimePayments.json +2 -2
  304. package/artifacts/contracts/utils/OneTimePaymentsV2.sol/OneTimePaymentsV2.dbg.json +1 -1
  305. package/artifacts/contracts/utils/OneTimePaymentsV2.sol/OneTimePaymentsV2.json +2 -2
  306. package/artifacts/contracts/utils/ProtoclUpgradeV4Mento.sol/MentoExchange.dbg.json +1 -1
  307. package/artifacts/contracts/utils/ProtoclUpgradeV4Mento.sol/ProtocolUpgradeV4Mento.dbg.json +1 -1
  308. package/artifacts/contracts/utils/ProtoclUpgradeV4Mento.sol/ProtocolUpgradeV4Mento.json +2 -2
  309. package/artifacts/contracts/utils/ProtocolUpgrade.sol/OldMarketMaker.dbg.json +1 -1
  310. package/artifacts/contracts/utils/ProtocolUpgrade.sol/ProtocolUpgrade.dbg.json +1 -1
  311. package/artifacts/contracts/utils/ProtocolUpgrade.sol/ProtocolUpgrade.json +2 -2
  312. package/artifacts/contracts/utils/ProtocolUpgradeFuse.sol/ProtocolUpgradeFuse.dbg.json +1 -1
  313. package/artifacts/contracts/utils/ProtocolUpgradeFuse.sol/ProtocolUpgradeFuse.json +2 -2
  314. package/artifacts/contracts/utils/ProtocolUpgradeFuseRecover.sol/ProtocolUpgradeFuseRecover.dbg.json +1 -1
  315. package/artifacts/contracts/utils/ProtocolUpgradeFuseRecover.sol/ProtocolUpgradeFuseRecover.json +2 -2
  316. package/artifacts/contracts/utils/ProtocolUpgradeRecover.sol/ProtocolUpgradeRecover.dbg.json +1 -1
  317. package/artifacts/contracts/utils/ProtocolUpgradeRecover.sol/ProtocolUpgradeRecover.json +2 -2
  318. package/artifacts/contracts/utils/ProxyFactory1967.sol/ERC1967Proxy.dbg.json +1 -1
  319. package/artifacts/contracts/utils/ProxyFactory1967.sol/ERC1967Proxy.json +2 -2
  320. package/artifacts/contracts/utils/ProxyFactory1967.sol/ProxyFactory1967.dbg.json +1 -1
  321. package/artifacts/contracts/utils/ProxyFactory1967.sol/ProxyFactory1967.json +2 -2
  322. package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.dbg.json +1 -1
  323. package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.json +2 -2
  324. package/artifacts/contracts/utils/ReserveRestore.sol/ReserveRestore.dbg.json +1 -1
  325. package/artifacts/contracts/utils/ReserveRestore.sol/ReserveRestore.json +2 -2
  326. package/contracts/IQuoter.sol +108 -0
  327. package/contracts/fuseFaucet/Faucet.sol +49 -37
  328. package/contracts/fuseFaucet/SuperfluidFacuet.sol +29 -8
  329. package/contracts/identity/IdentityV3.sol +534 -0
  330. package/contracts/token/ERC20PresetMinterPauserUpgradeable.sol +8 -9
  331. package/contracts/token/GoodDollar.sol +1 -1
  332. package/contracts/token/GoodDollar2.sol +13 -0
  333. package/contracts/token/superfluid/ISuperToken.sol +0 -19
  334. package/contracts/token/superfluid/SuperGoodDollar.sol +2 -21
  335. package/contracts/token/superfluid/SuperToken.sol +2 -2
  336. package/contracts/token/superfluid/SuperfluidToken.sol +66 -67
  337. package/contracts/ubi/UBISchemeV2.sol +12 -18
  338. package/contracts/utils/BuyFromReserveHelper.sol +129 -0
  339. package/dist/artifacts/contracts/identity/IdentityV2.sol/IdentityV2.json +2 -2
  340. package/dist/artifacts/contracts/token/superfluid/SuperGoodDollar.sol/SuperGoodDollar.json +177 -256
  341. package/dist/artifacts/contracts/token/superfluid/UUPSProxy.sol/UUPSProxy.json +2 -2
  342. package/dist/artifacts/contracts/utils/ProxyFactory1967.sol/ERC1967Proxy.json +2 -2
  343. package/dist/test-sdk/deploySuperGoodDollar.d.ts +1 -1
  344. package/dist/test-sdk/deploySuperGoodDollar.js +4 -8
  345. package/dist/test-sdk/index.js +1 -5
  346. package/hardhat.config.ts +37 -30
  347. package/package.json +3 -2
  348. package/releases/deploy-settings.json +5 -1
  349. package/releases/deployment.json +27 -1
  350. package/releases/olddao.json +1 -1
  351. package/scripts/analytics/activeGDStakers.ts +188 -0
  352. package/scripts/fv.ts +19 -1
  353. package/scripts/multichain-deploy/0_proxyFactory-deploy.ts +28 -5
  354. package/scripts/multichain-deploy/1_basicdao-deploy.ts +111 -73
  355. package/scripts/multichain-deploy/2_helpers-deploy.ts +13 -8
  356. package/scripts/multichain-deploy/4_ubi-deploy.ts +17 -19
  357. package/scripts/multichain-deploy/5_gov-deploy.ts +58 -26
  358. package/scripts/multichain-deploy/flattened/Avatar.sol +913 -0
  359. package/scripts/multichain-deploy/flattened/Controller.sol +1891 -0
  360. package/scripts/multichain-deploy/flattened/FeeFormula.sol +1290 -0
  361. package/scripts/multichain-deploy/fulldeploy.sh +17 -17
  362. package/scripts/multichain-deploy/helpers.ts +203 -70
  363. package/scripts/multichain-deploy/verify.ts +41 -0
  364. package/test/governance/ClaimersDistribution.test.ts +1 -1
  365. package/test/helpers.ts +59 -46
  366. package/test/identity/IdentityV2.test.ts +4 -1
  367. package/test/identity/IdentityV3.test.ts +449 -0
  368. package/test/invite/InvitesV2.test.ts +1 -1
  369. package/test/token/GoodDollar.test.ts +1 -1
  370. package/test/token/SuperGoodDollar.nohost.test.ts +383 -0
  371. package/test/token/SuperGoodDollar.test.ts +2 -10
  372. package/test/ubi/UBIScheme.e2e.test.ts +5 -5
  373. package/test/ubi/UBISchemeCycle.test.ts +69 -22
  374. package/test/ubi/UBISchemeV2.test.ts +636 -0
  375. package/test/utils/AdminWallet.test.ts +1 -1
  376. package/test/utils/ProxyFactory.test.ts +4 -1
  377. package/types/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.ts +108 -0
  378. package/types/@openzeppelin/contracts/proxy/ERC1967/index.ts +1 -0
  379. package/types/contracts/IQuoter.sol/IQuoterV2.ts +297 -0
  380. package/types/contracts/IQuoter.sol/index.ts +4 -0
  381. package/types/contracts/Interfaces.sol/AToken.ts +81 -0
  382. package/types/contracts/Interfaces.sol/IAaveIncentivesControllerV3.ts +156 -0
  383. package/types/contracts/Interfaces.sol/ILendingPoolV3.ts +254 -0
  384. package/types/contracts/fuseFaucet/Faucet.ts +109 -11
  385. package/types/contracts/fuseFaucet/SuperfluidBaseFacuet.sol/EthDistributor.ts +648 -0
  386. package/types/contracts/fuseFaucet/SuperfluidBaseFacuet.sol/EthDistributorUpgradeable.ts +843 -0
  387. package/types/contracts/fuseFaucet/SuperfluidBaseFacuet.sol/index.ts +4 -0
  388. package/types/contracts/fuseFaucet/SuperfluidFacuet.sol/SuperfluidFaucet.ts +79 -41
  389. package/types/contracts/identity/IdentityV3.ts +1899 -0
  390. package/types/contracts/identity/index.ts +1 -0
  391. package/types/contracts/index.ts +2 -0
  392. package/types/contracts/mocks/CeloDistributionHelperTest.sol/DistributionHelperTestHelper.ts +1252 -0
  393. package/types/contracts/reserve/GoodReserveADai.ts +2212 -0
  394. package/types/contracts/staking/aave/GoodAave3StakingV2.sol/GoodAaveStakingV2.ts +1808 -0
  395. package/types/contracts/staking/aave/GoodAave3StakingV2.sol/index.ts +4 -0
  396. package/types/contracts/token/GoodDollar18.ts +1871 -0
  397. package/types/contracts/token/GoodDollar2.ts +1871 -0
  398. package/types/contracts/token/index.ts +1 -0
  399. package/types/contracts/token/superfluid/ISuperToken.ts +0 -84
  400. package/types/contracts/token/superfluid/SuperGoodDollar.ts +12 -126
  401. package/types/contracts/token/superfluid/SuperToken.ts +0 -84
  402. package/types/contracts/ubi/UBISchemeV2.ts +3 -14
  403. package/types/contracts/utils/BuyFromReserveHelper.ts +699 -0
  404. package/types/contracts/utils/BuyGDClone.sol/IQuoterV2.ts +184 -0
  405. package/types/contracts/utils/BuyGDClone.sol/ISwapRouter.ts +306 -0
  406. package/types/contracts/utils/FuseOldBridgeKill.sol/BasicAMBErc677ToErc677.ts +108 -0
  407. package/types/contracts/utils/ProtocolUpgradeV4Mento.sol/MentoExchange.ts +81 -0
  408. package/types/contracts/utils/ProtocolUpgradeV4Mento.sol/ProtocolUpgradeV4Mento.ts +161 -0
  409. package/types/contracts/utils/ProtocolUpgradeV4Mento.sol/index.ts +5 -0
  410. package/types/contracts/utils/ReserveRestore.sol/MentoExchange.ts +81 -0
  411. package/types/contracts/utils/ReserveRestore.sol/ReserveRestore.ts +112 -0
  412. package/types/contracts/utils/ReserveRestore.sol/index.ts +5 -0
  413. package/types/contracts/utils/index.ts +1 -0
  414. package/types/factories/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy__factory.ts +146 -0
  415. package/types/factories/@openzeppelin/contracts/proxy/ERC1967/index.ts +1 -0
  416. package/types/factories/@openzeppelin/contracts/token/ERC20/ERC20__factory.ts +1 -1
  417. package/types/factories/@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable__factory.ts +1 -1
  418. package/types/factories/@openzeppelin/contracts-upgradeable/token/ERC20/presets/ERC20PresetMinterPauserUpgradeable__factory.ts +1 -1
  419. package/types/factories/@superfluid-finance/ethereum-contracts/contracts/libs/EventsEmitter__factory.ts +1 -1
  420. package/types/factories/@superfluid-finance/ethereum-contracts/contracts/superfluid/ConstantInflowNFT__factory.ts +1 -1
  421. package/types/factories/@superfluid-finance/ethereum-contracts/contracts/superfluid/ConstantOutflowNFT__factory.ts +1 -1
  422. package/types/factories/contracts/IQuoter.sol/IQuoterV2__factory.ts +226 -0
  423. package/types/factories/contracts/IQuoter.sol/index.ts +4 -0
  424. package/types/factories/contracts/Interfaces.sol/AToken__factory.ts +36 -0
  425. package/types/factories/contracts/Interfaces.sol/IAaveIncentivesControllerV3__factory.ts +88 -0
  426. package/types/factories/contracts/Interfaces.sol/ILendingPoolV3__factory.ts +186 -0
  427. package/types/factories/contracts/fuseFaucet/Faucet__factory.ts +56 -1
  428. package/types/factories/contracts/fuseFaucet/FuseFaucetV2__factory.ts +1 -1
  429. package/types/factories/contracts/fuseFaucet/FuseFaucet__factory.ts +1 -1
  430. package/types/factories/contracts/fuseFaucet/SuperfluidBaseFacuet.sol/EthDistributorUpgradeable__factory.ts +572 -0
  431. package/types/factories/contracts/fuseFaucet/SuperfluidBaseFacuet.sol/EthDistributor__factory.ts +482 -0
  432. package/types/factories/contracts/fuseFaucet/SuperfluidBaseFacuet.sol/index.ts +4 -0
  433. package/types/factories/contracts/fuseFaucet/SuperfluidFacuet.sol/SuperfluidFaucet__factory.ts +45 -27
  434. package/types/factories/contracts/governance/ClaimersDistribution__factory.ts +1 -1
  435. package/types/factories/contracts/governance/CompoundVotingMachine__factory.ts +1 -1
  436. package/types/factories/contracts/governance/GReputation__factory.ts +1 -1
  437. package/types/factories/contracts/governance/GoodDollarStaking.sol/GoodDollarStaking__factory.ts +1 -1
  438. package/types/factories/contracts/governance/GovernanceStaking__factory.ts +1 -1
  439. package/types/factories/contracts/governance/Reputation__factory.ts +1 -1
  440. package/types/factories/contracts/governance/StakersDistribution__factory.ts +1 -1
  441. package/types/factories/contracts/identity/IdentityV2__factory.ts +1 -1
  442. package/types/factories/contracts/identity/IdentityV3__factory.ts +1140 -0
  443. package/types/factories/contracts/identity/index.ts +1 -0
  444. package/types/factories/contracts/index.ts +1 -0
  445. package/types/factories/contracts/invite/InvitesFuseV2__factory.ts +1 -1
  446. package/types/factories/contracts/invite/InvitesV1__factory.ts +1 -1
  447. package/types/factories/contracts/invite/InvitesV2__factory.ts +1 -1
  448. package/types/factories/contracts/invite/OneTimeReward__factory.ts +1 -1
  449. package/types/factories/contracts/mocks/AaveMock__factory.ts +1 -1
  450. package/types/factories/contracts/mocks/AaveUSDMockOracle__factory.ts +1 -1
  451. package/types/factories/contracts/mocks/BatUSDMockOracle__factory.ts +1 -1
  452. package/types/factories/contracts/mocks/CBATMock__factory.ts +1 -1
  453. package/types/factories/contracts/mocks/CDAILowWorthMock__factory.ts +1 -1
  454. package/types/factories/contracts/mocks/CDAIMock__factory.ts +1 -1
  455. package/types/factories/contracts/mocks/CDAINonMintableMock__factory.ts +1 -1
  456. package/types/factories/contracts/mocks/CDecimalsMock__factory.ts +1 -1
  457. package/types/factories/contracts/mocks/CSDTMock__factory.ts +1 -1
  458. package/types/factories/contracts/mocks/CUSDCMock__factory.ts +1 -1
  459. package/types/factories/contracts/mocks/CeloDistributionHelperTest.sol/CeloDistributionHelperTestHelper__factory.ts +1 -1
  460. package/types/factories/contracts/mocks/CeloDistributionHelperTest.sol/CeloDistributionHelperTest__factory.ts +1 -1
  461. package/types/factories/contracts/mocks/CeloDistributionHelperTest.sol/DistributionHelperTestHelper__factory.ts +929 -0
  462. package/types/factories/contracts/mocks/CompUsdMockOracle.sol/CompUSDMockOracle__factory.ts +1 -1
  463. package/types/factories/contracts/mocks/DAIMock__factory.ts +1 -1
  464. package/types/factories/contracts/mocks/DaiEthPriceMockOracle__factory.ts +1 -1
  465. package/types/factories/contracts/mocks/DecimalsMock__factory.ts +1 -1
  466. package/types/factories/contracts/mocks/DistributionBridgeMock__factory.ts +1 -1
  467. package/types/factories/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTestHelper__factory.ts +1 -1
  468. package/types/factories/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTest__factory.ts +1 -1
  469. package/types/factories/contracts/mocks/EthUSDMockOracle__factory.ts +1 -1
  470. package/types/factories/contracts/mocks/FeesFormularMock.sol/FeesFormulaMock__factory.ts +1 -1
  471. package/types/factories/contracts/mocks/GasPriceMockOracle__factory.ts +1 -1
  472. package/types/factories/contracts/mocks/GoodCompoundStakingTest__factory.ts +1 -1
  473. package/types/factories/contracts/mocks/GoodDollarStakingMock__factory.ts +1 -1
  474. package/types/factories/contracts/mocks/GoodFundManagerTest__factory.ts +1 -1
  475. package/types/factories/contracts/mocks/IdentityMock__factory.ts +1 -1
  476. package/types/factories/contracts/mocks/IncentiveControllerMock__factory.ts +1 -1
  477. package/types/factories/contracts/mocks/LendingPoolMock__factory.ts +1 -1
  478. package/types/factories/contracts/mocks/MultichainRouterMock.sol/MultichainRouterMock__factory.ts +1 -1
  479. package/types/factories/contracts/mocks/OverMintTester.sol/OverMintTester__factory.ts +1 -1
  480. package/types/factories/contracts/mocks/OverMintTesterRegularStake__factory.ts +1 -1
  481. package/types/factories/contracts/mocks/PayableMock__factory.ts +1 -1
  482. package/types/factories/contracts/mocks/SixteenDecimalsTokenMock__factory.ts +1 -1
  483. package/types/factories/contracts/mocks/StakingMockFixedAPY__factory.ts +1 -1
  484. package/types/factories/contracts/mocks/SwapHelperTest__factory.ts +1 -1
  485. package/types/factories/contracts/mocks/TwentyDecimalsTokenMock__factory.ts +1 -1
  486. package/types/factories/contracts/mocks/UpgradableMocks.sol/UpgradableMock2__factory.ts +1 -1
  487. package/types/factories/contracts/mocks/UpgradableMocks.sol/UpgradableMock3__factory.ts +1 -1
  488. package/types/factories/contracts/mocks/UpgradableMocks.sol/UpgradableMock4__factory.ts +1 -1
  489. package/types/factories/contracts/mocks/UpgradableMocks.sol/UpgradableMock__factory.ts +1 -1
  490. package/types/factories/contracts/mocks/UsdcMock.sol/USDCMock__factory.ts +1 -1
  491. package/types/factories/contracts/reserve/CeloDistributionHelper__factory.ts +1 -1
  492. package/types/factories/contracts/reserve/DistributionHelper__factory.ts +1 -1
  493. package/types/factories/contracts/reserve/ExchangeHelper__factory.ts +1 -1
  494. package/types/factories/contracts/reserve/GoodMarketMaker__factory.ts +1 -1
  495. package/types/factories/contracts/reserve/GoodReserveADai__factory.ts +1502 -0
  496. package/types/factories/contracts/reserve/GoodReserveCDai.sol/GoodReserveCDai__factory.ts +1 -1
  497. package/types/factories/contracts/staking/BaseShareFieldV2__factory.ts +1 -1
  498. package/types/factories/contracts/staking/BaseShareField__factory.ts +1 -1
  499. package/types/factories/contracts/staking/DonationsStaking__factory.ts +1 -1
  500. package/types/factories/contracts/staking/FuseStakingV3.sol/FuseStakingV3__factory.ts +1 -1
  501. package/types/factories/contracts/staking/GoodFundManager__factory.ts +1 -1
  502. package/types/factories/contracts/staking/UniswapV2SwapHelper__factory.ts +1 -1
  503. package/types/factories/contracts/staking/aave/AaveStakingFactory__factory.ts +1 -1
  504. package/types/factories/contracts/staking/aave/GoodAave3StakingV2.sol/GoodAaveStakingV2__factory.ts +1240 -0
  505. package/types/factories/contracts/staking/aave/GoodAave3StakingV2.sol/index.ts +4 -0
  506. package/types/factories/contracts/staking/aave/GoodAaveStakingV2__factory.ts +1 -1
  507. package/types/factories/contracts/staking/aave/GoodAaveStaking__factory.ts +1 -1
  508. package/types/factories/contracts/staking/compound/CompoundStakingFactory__factory.ts +1 -1
  509. package/types/factories/contracts/staking/compound/GoodCompoundStakingV2__factory.ts +1 -1
  510. package/types/factories/contracts/staking/compound/GoodCompoundStaking__factory.ts +1 -1
  511. package/types/factories/contracts/token/ERC20PresetMinterPauserUpgradeable__factory.ts +1 -1
  512. package/types/factories/contracts/token/GoodDollar18__factory.ts +1257 -0
  513. package/types/factories/contracts/token/GoodDollar2__factory.ts +1257 -0
  514. package/types/factories/contracts/token/GoodDollar__factory.ts +1 -1
  515. package/types/factories/contracts/token/MultichainFeeFormula__factory.ts +1 -1
  516. package/types/factories/contracts/token/index.ts +1 -0
  517. package/types/factories/contracts/token/superfluid/ISuperToken__factory.ts +0 -52
  518. package/types/factories/contracts/token/superfluid/SuperGoodDollar__factory.ts +1 -73
  519. package/types/factories/contracts/token/superfluid/SuperToken__factory.ts +1 -53
  520. package/types/factories/contracts/token/superfluid/UUPSProxy.sol/UUPSProxy__factory.ts +1 -1
  521. package/types/factories/contracts/ubi/UBISchemeV2__factory.ts +1 -6
  522. package/types/factories/contracts/ubi/UBIScheme__factory.ts +1 -1
  523. package/types/factories/contracts/utils/AdminWalletFuse__factory.ts +1 -1
  524. package/types/factories/contracts/utils/AdminWallet__factory.ts +1 -1
  525. package/types/factories/contracts/utils/BancorFormula__factory.ts +1 -1
  526. package/types/factories/contracts/utils/BulkWhitelist__factory.ts +1 -1
  527. package/types/factories/contracts/utils/BuyAndBridgeHelper__factory.ts +1 -1
  528. package/types/factories/contracts/utils/BuyFromReserveHelper__factory.ts +566 -0
  529. package/types/factories/contracts/utils/BuyGDClone.sol/BuyGDCloneFactory__factory.ts +1 -1
  530. package/types/factories/contracts/utils/BuyGDClone.sol/BuyGDClone__factory.ts +1 -1
  531. package/types/factories/contracts/utils/BuyGDClone.sol/DonateGDClone__factory.ts +1 -1
  532. package/types/factories/contracts/utils/BuyGDClone.sol/IQuoterV2__factory.ts +126 -0
  533. package/types/factories/contracts/utils/BuyGDClone.sol/ISwapRouter__factory.ts +220 -0
  534. package/types/factories/contracts/utils/DAOContract__factory.ts +1 -1
  535. package/types/factories/contracts/utils/DAOUpgradeableContract__factory.ts +1 -1
  536. package/types/factories/contracts/utils/FuseOldBridgeKill.sol/BasicAMBErc677ToErc677__factory.ts +86 -0
  537. package/types/factories/contracts/utils/FuseOldBridgeKill.sol/FuseOldBridgeKill__factory.ts +1 -1
  538. package/types/factories/contracts/utils/FuseOldBridgeKill.sol/Initializable__factory.ts +1 -1
  539. package/types/factories/contracts/utils/FuseOldBridgeKill.sol/Ownable__factory.ts +1 -1
  540. package/types/factories/contracts/utils/GDFaucet__factory.ts +1 -1
  541. package/types/factories/contracts/utils/GoodDollarMintBurnWrapper.sol/GoodDollarMintBurnWrapper__factory.ts +1 -1
  542. package/types/factories/contracts/utils/IdentityFix__factory.ts +1 -1
  543. package/types/factories/contracts/utils/LastauthReduction__factory.ts +1 -1
  544. package/types/factories/contracts/utils/MultiCall.sol/Multicall__factory.ts +1 -1
  545. package/types/factories/contracts/utils/MultichainBridgeHelper__factory.ts +1 -1
  546. package/types/factories/contracts/utils/NameService__factory.ts +1 -1
  547. package/types/factories/contracts/utils/OneTimePaymentsV2__factory.ts +1 -1
  548. package/types/factories/contracts/utils/OneTimePayments__factory.ts +1 -1
  549. package/types/factories/contracts/utils/ProtoclUpgradeV4Mento.sol/ProtocolUpgradeV4Mento__factory.ts +1 -1
  550. package/types/factories/contracts/utils/ProtocolUpgrade.sol/ProtocolUpgrade__factory.ts +1 -1
  551. package/types/factories/contracts/utils/ProtocolUpgradeFuseRecover__factory.ts +1 -1
  552. package/types/factories/contracts/utils/ProtocolUpgradeFuse__factory.ts +1 -1
  553. package/types/factories/contracts/utils/ProtocolUpgradeRecover__factory.ts +1 -1
  554. package/types/factories/contracts/utils/ProtocolUpgradeV4Mento.sol/MentoExchange__factory.ts +39 -0
  555. package/types/factories/contracts/utils/ProtocolUpgradeV4Mento.sol/ProtocolUpgradeV4Mento__factory.ts +152 -0
  556. package/types/factories/contracts/utils/ProtocolUpgradeV4Mento.sol/index.ts +5 -0
  557. package/types/factories/contracts/utils/ProxyFactory1967.sol/ERC1967Proxy__factory.ts +1 -1
  558. package/types/factories/contracts/utils/ProxyFactory1967.sol/ProxyFactory1967__factory.ts +1 -1
  559. package/types/factories/contracts/utils/ReputationTestHelper__factory.ts +1 -1
  560. package/types/factories/contracts/utils/ReserveRestore.sol/MentoExchange__factory.ts +39 -0
  561. package/types/factories/contracts/utils/ReserveRestore.sol/ReserveRestore__factory.ts +95 -0
  562. package/types/factories/contracts/utils/ReserveRestore.sol/index.ts +5 -0
  563. package/types/factories/contracts/utils/ReserveRestore__factory.ts +1 -1
  564. package/types/factories/contracts/utils/index.ts +1 -0
  565. package/types/hardhat.d.ts +45 -0
  566. package/types/index.ts +8 -2
@@ -0,0 +1,1891 @@
1
+ // File: openzeppelin-solidity/contracts/ownership/Ownable.sol
2
+
3
+ pragma solidity ^0.5.0;
4
+
5
+ /**
6
+ * @title Ownable
7
+ * @dev The Ownable contract has an owner address, and provides basic authorization control
8
+ * functions, this simplifies the implementation of "user permissions".
9
+ */
10
+ contract Ownable {
11
+ address private _owner;
12
+
13
+ event OwnershipTransferred(
14
+ address indexed previousOwner,
15
+ address indexed newOwner
16
+ );
17
+
18
+ /**
19
+ * @dev The Ownable constructor sets the original `owner` of the contract to the sender
20
+ * account.
21
+ */
22
+ constructor() internal {
23
+ _owner = msg.sender;
24
+ emit OwnershipTransferred(address(0), _owner);
25
+ }
26
+
27
+ /**
28
+ * @return the address of the owner.
29
+ */
30
+ function owner() public view returns (address) {
31
+ return _owner;
32
+ }
33
+
34
+ /**
35
+ * @dev Throws if called by any account other than the owner.
36
+ */
37
+ modifier onlyOwner() {
38
+ require(isOwner());
39
+ _;
40
+ }
41
+
42
+ /**
43
+ * @return true if `msg.sender` is the owner of the contract.
44
+ */
45
+ function isOwner() public view returns (bool) {
46
+ return msg.sender == _owner;
47
+ }
48
+
49
+ /**
50
+ * @dev Allows the current owner to relinquish control of the contract.
51
+ * @notice Renouncing to ownership will leave the contract without an owner.
52
+ * It will not be possible to call the functions with the `onlyOwner`
53
+ * modifier anymore.
54
+ */
55
+ function renounceOwnership() public onlyOwner {
56
+ emit OwnershipTransferred(_owner, address(0));
57
+ _owner = address(0);
58
+ }
59
+
60
+ /**
61
+ * @dev Allows the current owner to transfer control of the contract to a newOwner.
62
+ * @param newOwner The address to transfer ownership to.
63
+ */
64
+ function transferOwnership(address newOwner) public onlyOwner {
65
+ _transferOwnership(newOwner);
66
+ }
67
+
68
+ /**
69
+ * @dev Transfers control of the contract to a newOwner.
70
+ * @param newOwner The address to transfer ownership to.
71
+ */
72
+ function _transferOwnership(address newOwner) internal {
73
+ require(newOwner != address(0));
74
+ emit OwnershipTransferred(_owner, newOwner);
75
+ _owner = newOwner;
76
+ }
77
+ }
78
+
79
+ // File: @daostack/infra/contracts/Reputation.sol
80
+
81
+ pragma solidity ^0.5.4;
82
+
83
+ /**
84
+ * @title Reputation system
85
+ * @dev A DAO has Reputation System which allows peers to rate other peers in order to build trust .
86
+ * A reputation is use to assign influence measure to a DAO'S peers.
87
+ * Reputation is similar to regular tokens but with one crucial difference: It is non-transferable.
88
+ * The Reputation contract maintain a map of address to reputation value.
89
+ * It provides an onlyOwner functions to mint and burn reputation _to (or _from) a specific address.
90
+ */
91
+
92
+ contract Reputation is Ownable {
93
+ uint8 public decimals = 18; //Number of decimals of the smallest unit
94
+ // Event indicating minting of reputation to an address.
95
+ event Mint(address indexed _to, uint256 _amount);
96
+ // Event indicating burning of reputation for an address.
97
+ event Burn(address indexed _from, uint256 _amount);
98
+
99
+ /// @dev `Checkpoint` is the structure that attaches a block number to a
100
+ /// given value, the block number attached is the one that last changed the
101
+ /// value
102
+ struct Checkpoint {
103
+ // `fromBlock` is the block number that the value was generated from
104
+ uint128 fromBlock;
105
+ // `value` is the amount of reputation at a specific block number
106
+ uint128 value;
107
+ }
108
+
109
+ // `balances` is the map that tracks the balance of each address, in this
110
+ // contract when the balance changes the block number that the change
111
+ // occurred is also included in the map
112
+ mapping(address => Checkpoint[]) balances;
113
+
114
+ // Tracks the history of the `totalSupply` of the reputation
115
+ Checkpoint[] totalSupplyHistory;
116
+
117
+ /// @notice Constructor to create a Reputation
118
+ constructor() public {}
119
+
120
+ /// @dev This function makes it easy to get the total number of reputation
121
+ /// @return The total number of reputation
122
+ function totalSupply() public view returns (uint256) {
123
+ return totalSupplyAt(block.number);
124
+ }
125
+
126
+ ////////////////
127
+ // Query balance and totalSupply in History
128
+ ////////////////
129
+ /**
130
+ * @dev return the reputation amount of a given owner
131
+ * @param _owner an address of the owner which we want to get his reputation
132
+ */
133
+ function balanceOf(address _owner) public view returns (uint256 balance) {
134
+ return balanceOfAt(_owner, block.number);
135
+ }
136
+
137
+ /// @dev Queries the balance of `_owner` at a specific `_blockNumber`
138
+ /// @param _owner The address from which the balance will be retrieved
139
+ /// @param _blockNumber The block number when the balance is queried
140
+ /// @return The balance at `_blockNumber`
141
+ function balanceOfAt(
142
+ address _owner,
143
+ uint256 _blockNumber
144
+ ) public view returns (uint256) {
145
+ if (
146
+ (balances[_owner].length == 0) ||
147
+ (balances[_owner][0].fromBlock > _blockNumber)
148
+ ) {
149
+ return 0;
150
+ // This will return the expected balance during normal situations
151
+ } else {
152
+ return getValueAt(balances[_owner], _blockNumber);
153
+ }
154
+ }
155
+
156
+ /// @notice Total amount of reputation at a specific `_blockNumber`.
157
+ /// @param _blockNumber The block number when the totalSupply is queried
158
+ /// @return The total amount of reputation at `_blockNumber`
159
+ function totalSupplyAt(uint256 _blockNumber) public view returns (uint256) {
160
+ if (
161
+ (totalSupplyHistory.length == 0) ||
162
+ (totalSupplyHistory[0].fromBlock > _blockNumber)
163
+ ) {
164
+ return 0;
165
+ // This will return the expected totalSupply during normal situations
166
+ } else {
167
+ return getValueAt(totalSupplyHistory, _blockNumber);
168
+ }
169
+ }
170
+
171
+ /// @notice Generates `_amount` reputation that are assigned to `_owner`
172
+ /// @param _user The address that will be assigned the new reputation
173
+ /// @param _amount The quantity of reputation generated
174
+ /// @return True if the reputation are generated correctly
175
+ function mint(
176
+ address _user,
177
+ uint256 _amount
178
+ ) public onlyOwner returns (bool) {
179
+ uint256 curTotalSupply = totalSupply();
180
+ require(curTotalSupply + _amount >= curTotalSupply); // Check for overflow
181
+ uint256 previousBalanceTo = balanceOf(_user);
182
+ require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow
183
+ updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount);
184
+ updateValueAtNow(balances[_user], previousBalanceTo + _amount);
185
+ emit Mint(_user, _amount);
186
+ return true;
187
+ }
188
+
189
+ /// @notice Burns `_amount` reputation from `_owner`
190
+ /// @param _user The address that will lose the reputation
191
+ /// @param _amount The quantity of reputation to burn
192
+ /// @return True if the reputation are burned correctly
193
+ function burn(
194
+ address _user,
195
+ uint256 _amount
196
+ ) public onlyOwner returns (bool) {
197
+ uint256 curTotalSupply = totalSupply();
198
+ uint256 amountBurned = _amount;
199
+ uint256 previousBalanceFrom = balanceOf(_user);
200
+ if (previousBalanceFrom < amountBurned) {
201
+ amountBurned = previousBalanceFrom;
202
+ }
203
+ updateValueAtNow(totalSupplyHistory, curTotalSupply - amountBurned);
204
+ updateValueAtNow(balances[_user], previousBalanceFrom - amountBurned);
205
+ emit Burn(_user, amountBurned);
206
+ return true;
207
+ }
208
+
209
+ ////////////////
210
+ // Internal helper functions to query and set a value in a snapshot array
211
+ ////////////////
212
+
213
+ /// @dev `getValueAt` retrieves the number of reputation at a given block number
214
+ /// @param checkpoints The history of values being queried
215
+ /// @param _block The block number to retrieve the value at
216
+ /// @return The number of reputation being queried
217
+ function getValueAt(
218
+ Checkpoint[] storage checkpoints,
219
+ uint256 _block
220
+ ) internal view returns (uint256) {
221
+ if (checkpoints.length == 0) {
222
+ return 0;
223
+ }
224
+
225
+ // Shortcut for the actual value
226
+ if (_block >= checkpoints[checkpoints.length - 1].fromBlock) {
227
+ return checkpoints[checkpoints.length - 1].value;
228
+ }
229
+ if (_block < checkpoints[0].fromBlock) {
230
+ return 0;
231
+ }
232
+
233
+ // Binary search of the value in the array
234
+ uint256 min = 0;
235
+ uint256 max = checkpoints.length - 1;
236
+ while (max > min) {
237
+ uint256 mid = (max + min + 1) / 2;
238
+ if (checkpoints[mid].fromBlock <= _block) {
239
+ min = mid;
240
+ } else {
241
+ max = mid - 1;
242
+ }
243
+ }
244
+ return checkpoints[min].value;
245
+ }
246
+
247
+ /// @dev `updateValueAtNow` used to update the `balances` map and the
248
+ /// `totalSupplyHistory`
249
+ /// @param checkpoints The history of data being updated
250
+ /// @param _value The new number of reputation
251
+ function updateValueAtNow(
252
+ Checkpoint[] storage checkpoints,
253
+ uint256 _value
254
+ ) internal {
255
+ require(uint128(_value) == _value); //check value is in the 128 bits bounderies
256
+ if (
257
+ (checkpoints.length == 0) ||
258
+ (checkpoints[checkpoints.length - 1].fromBlock < block.number)
259
+ ) {
260
+ Checkpoint storage newCheckPoint = checkpoints[checkpoints.length++];
261
+ newCheckPoint.fromBlock = uint128(block.number);
262
+ newCheckPoint.value = uint128(_value);
263
+ } else {
264
+ Checkpoint storage oldCheckPoint = checkpoints[checkpoints.length - 1];
265
+ oldCheckPoint.value = uint128(_value);
266
+ }
267
+ }
268
+ }
269
+
270
+ // File: openzeppelin-solidity/contracts/token/ERC20/IERC20.sol
271
+
272
+ pragma solidity ^0.5.0;
273
+
274
+ /**
275
+ * @title ERC20 interface
276
+ * @dev see https://github.com/ethereum/EIPs/issues/20
277
+ */
278
+ interface IERC20 {
279
+ function transfer(address to, uint256 value) external returns (bool);
280
+
281
+ function approve(address spender, uint256 value) external returns (bool);
282
+
283
+ function transferFrom(
284
+ address from,
285
+ address to,
286
+ uint256 value
287
+ ) external returns (bool);
288
+
289
+ function totalSupply() external view returns (uint256);
290
+
291
+ function balanceOf(address who) external view returns (uint256);
292
+
293
+ function allowance(
294
+ address owner,
295
+ address spender
296
+ ) external view returns (uint256);
297
+
298
+ event Transfer(address indexed from, address indexed to, uint256 value);
299
+
300
+ event Approval(address indexed owner, address indexed spender, uint256 value);
301
+ }
302
+
303
+ // File: openzeppelin-solidity/contracts/math/SafeMath.sol
304
+
305
+ pragma solidity ^0.5.0;
306
+
307
+ /**
308
+ * @title SafeMath
309
+ * @dev Unsigned math operations with safety checks that revert on error
310
+ */
311
+ library SafeMath {
312
+ /**
313
+ * @dev Multiplies two unsigned integers, reverts on overflow.
314
+ */
315
+ function mul(uint256 a, uint256 b) internal pure returns (uint256) {
316
+ // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
317
+ // benefit is lost if 'b' is also tested.
318
+ // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
319
+ if (a == 0) {
320
+ return 0;
321
+ }
322
+
323
+ uint256 c = a * b;
324
+ require(c / a == b);
325
+
326
+ return c;
327
+ }
328
+
329
+ /**
330
+ * @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero.
331
+ */
332
+ function div(uint256 a, uint256 b) internal pure returns (uint256) {
333
+ // Solidity only automatically asserts when dividing by 0
334
+ require(b > 0);
335
+ uint256 c = a / b;
336
+ // assert(a == b * c + a % b); // There is no case in which this doesn't hold
337
+
338
+ return c;
339
+ }
340
+
341
+ /**
342
+ * @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend).
343
+ */
344
+ function sub(uint256 a, uint256 b) internal pure returns (uint256) {
345
+ require(b <= a);
346
+ uint256 c = a - b;
347
+
348
+ return c;
349
+ }
350
+
351
+ /**
352
+ * @dev Adds two unsigned integers, reverts on overflow.
353
+ */
354
+ function add(uint256 a, uint256 b) internal pure returns (uint256) {
355
+ uint256 c = a + b;
356
+ require(c >= a);
357
+
358
+ return c;
359
+ }
360
+
361
+ /**
362
+ * @dev Divides two unsigned integers and returns the remainder (unsigned integer modulo),
363
+ * reverts when dividing by zero.
364
+ */
365
+ function mod(uint256 a, uint256 b) internal pure returns (uint256) {
366
+ require(b != 0);
367
+ return a % b;
368
+ }
369
+ }
370
+
371
+ // File: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol
372
+
373
+ pragma solidity ^0.5.0;
374
+
375
+ /**
376
+ * @title Standard ERC20 token
377
+ *
378
+ * @dev Implementation of the basic standard token.
379
+ * https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
380
+ * Originally based on code by FirstBlood:
381
+ * https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
382
+ *
383
+ * This implementation emits additional Approval events, allowing applications to reconstruct the allowance status for
384
+ * all accounts just by listening to said events. Note that this isn't required by the specification, and other
385
+ * compliant implementations may not do it.
386
+ */
387
+ contract ERC20 is IERC20 {
388
+ using SafeMath for uint256;
389
+
390
+ mapping(address => uint256) private _balances;
391
+
392
+ mapping(address => mapping(address => uint256)) private _allowed;
393
+
394
+ uint256 private _totalSupply;
395
+
396
+ /**
397
+ * @dev Total number of tokens in existence
398
+ */
399
+ function totalSupply() public view returns (uint256) {
400
+ return _totalSupply;
401
+ }
402
+
403
+ /**
404
+ * @dev Gets the balance of the specified address.
405
+ * @param owner The address to query the balance of.
406
+ * @return An uint256 representing the amount owned by the passed address.
407
+ */
408
+ function balanceOf(address owner) public view returns (uint256) {
409
+ return _balances[owner];
410
+ }
411
+
412
+ /**
413
+ * @dev Function to check the amount of tokens that an owner allowed to a spender.
414
+ * @param owner address The address which owns the funds.
415
+ * @param spender address The address which will spend the funds.
416
+ * @return A uint256 specifying the amount of tokens still available for the spender.
417
+ */
418
+ function allowance(
419
+ address owner,
420
+ address spender
421
+ ) public view returns (uint256) {
422
+ return _allowed[owner][spender];
423
+ }
424
+
425
+ /**
426
+ * @dev Transfer token for a specified address
427
+ * @param to The address to transfer to.
428
+ * @param value The amount to be transferred.
429
+ */
430
+ function transfer(address to, uint256 value) public returns (bool) {
431
+ _transfer(msg.sender, to, value);
432
+ return true;
433
+ }
434
+
435
+ /**
436
+ * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
437
+ * Beware that changing an allowance with this method brings the risk that someone may use both the old
438
+ * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
439
+ * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
440
+ * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
441
+ * @param spender The address which will spend the funds.
442
+ * @param value The amount of tokens to be spent.
443
+ */
444
+ function approve(address spender, uint256 value) public returns (bool) {
445
+ require(spender != address(0));
446
+
447
+ _allowed[msg.sender][spender] = value;
448
+ emit Approval(msg.sender, spender, value);
449
+ return true;
450
+ }
451
+
452
+ /**
453
+ * @dev Transfer tokens from one address to another.
454
+ * Note that while this function emits an Approval event, this is not required as per the specification,
455
+ * and other compliant implementations may not emit the event.
456
+ * @param from address The address which you want to send tokens from
457
+ * @param to address The address which you want to transfer to
458
+ * @param value uint256 the amount of tokens to be transferred
459
+ */
460
+ function transferFrom(
461
+ address from,
462
+ address to,
463
+ uint256 value
464
+ ) public returns (bool) {
465
+ _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
466
+ _transfer(from, to, value);
467
+ emit Approval(from, msg.sender, _allowed[from][msg.sender]);
468
+ return true;
469
+ }
470
+
471
+ /**
472
+ * @dev Increase the amount of tokens that an owner allowed to a spender.
473
+ * approve should be called when allowed_[_spender] == 0. To increment
474
+ * allowed value is better to use this function to avoid 2 calls (and wait until
475
+ * the first transaction is mined)
476
+ * From MonolithDAO Token.sol
477
+ * Emits an Approval event.
478
+ * @param spender The address which will spend the funds.
479
+ * @param addedValue The amount of tokens to increase the allowance by.
480
+ */
481
+ function increaseAllowance(
482
+ address spender,
483
+ uint256 addedValue
484
+ ) public returns (bool) {
485
+ require(spender != address(0));
486
+
487
+ _allowed[msg.sender][spender] = _allowed[msg.sender][spender].add(
488
+ addedValue
489
+ );
490
+ emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
491
+ return true;
492
+ }
493
+
494
+ /**
495
+ * @dev Decrease the amount of tokens that an owner allowed to a spender.
496
+ * approve should be called when allowed_[_spender] == 0. To decrement
497
+ * allowed value is better to use this function to avoid 2 calls (and wait until
498
+ * the first transaction is mined)
499
+ * From MonolithDAO Token.sol
500
+ * Emits an Approval event.
501
+ * @param spender The address which will spend the funds.
502
+ * @param subtractedValue The amount of tokens to decrease the allowance by.
503
+ */
504
+ function decreaseAllowance(
505
+ address spender,
506
+ uint256 subtractedValue
507
+ ) public returns (bool) {
508
+ require(spender != address(0));
509
+
510
+ _allowed[msg.sender][spender] = _allowed[msg.sender][spender].sub(
511
+ subtractedValue
512
+ );
513
+ emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
514
+ return true;
515
+ }
516
+
517
+ /**
518
+ * @dev Transfer token for a specified addresses
519
+ * @param from The address to transfer from.
520
+ * @param to The address to transfer to.
521
+ * @param value The amount to be transferred.
522
+ */
523
+ function _transfer(address from, address to, uint256 value) internal {
524
+ require(to != address(0));
525
+
526
+ _balances[from] = _balances[from].sub(value);
527
+ _balances[to] = _balances[to].add(value);
528
+ emit Transfer(from, to, value);
529
+ }
530
+
531
+ /**
532
+ * @dev Internal function that mints an amount of the token and assigns it to
533
+ * an account. This encapsulates the modification of balances such that the
534
+ * proper events are emitted.
535
+ * @param account The account that will receive the created tokens.
536
+ * @param value The amount that will be created.
537
+ */
538
+ function _mint(address account, uint256 value) internal {
539
+ require(account != address(0));
540
+
541
+ _totalSupply = _totalSupply.add(value);
542
+ _balances[account] = _balances[account].add(value);
543
+ emit Transfer(address(0), account, value);
544
+ }
545
+
546
+ /**
547
+ * @dev Internal function that burns an amount of the token of a given
548
+ * account.
549
+ * @param account The account whose tokens will be burnt.
550
+ * @param value The amount that will be burnt.
551
+ */
552
+ function _burn(address account, uint256 value) internal {
553
+ require(account != address(0));
554
+
555
+ _totalSupply = _totalSupply.sub(value);
556
+ _balances[account] = _balances[account].sub(value);
557
+ emit Transfer(account, address(0), value);
558
+ }
559
+
560
+ /**
561
+ * @dev Internal function that burns an amount of the token of a given
562
+ * account, deducting from the sender's allowance for said account. Uses the
563
+ * internal burn function.
564
+ * Emits an Approval event (reflecting the reduced allowance).
565
+ * @param account The account whose tokens will be burnt.
566
+ * @param value The amount that will be burnt.
567
+ */
568
+ function _burnFrom(address account, uint256 value) internal {
569
+ _allowed[account][msg.sender] = _allowed[account][msg.sender].sub(value);
570
+ _burn(account, value);
571
+ emit Approval(account, msg.sender, _allowed[account][msg.sender]);
572
+ }
573
+ }
574
+
575
+ // File: openzeppelin-solidity/contracts/token/ERC20/ERC20Burnable.sol
576
+
577
+ pragma solidity ^0.5.0;
578
+
579
+ /**
580
+ * @title Burnable Token
581
+ * @dev Token that can be irreversibly burned (destroyed).
582
+ */
583
+ contract ERC20Burnable is ERC20 {
584
+ /**
585
+ * @dev Burns a specific amount of tokens.
586
+ * @param value The amount of token to be burned.
587
+ */
588
+ function burn(uint256 value) public {
589
+ _burn(msg.sender, value);
590
+ }
591
+
592
+ /**
593
+ * @dev Burns a specific amount of tokens from the target address and decrements allowance
594
+ * @param from address The address which you want to send tokens from
595
+ * @param value uint256 The amount of token to be burned
596
+ */
597
+ function burnFrom(address from, uint256 value) public {
598
+ _burnFrom(from, value);
599
+ }
600
+ }
601
+
602
+ // File: @daostack/arc/contracts/controller/DAOToken.sol
603
+
604
+ pragma solidity ^0.5.4;
605
+
606
+ /**
607
+ * @title DAOToken, base on zeppelin contract.
608
+ * @dev ERC20 compatible token. It is a mintable, burnable token.
609
+ */
610
+
611
+ contract DAOToken is ERC20, ERC20Burnable, Ownable {
612
+ string public name;
613
+ string public symbol;
614
+ // solhint-disable-next-line const-name-snakecase
615
+ uint8 public constant decimals = 18;
616
+ uint256 public cap;
617
+
618
+ /**
619
+ * @dev Constructor
620
+ * @param _name - token name
621
+ * @param _symbol - token symbol
622
+ * @param _cap - token cap - 0 value means no cap
623
+ */
624
+ constructor(string memory _name, string memory _symbol, uint256 _cap) public {
625
+ name = _name;
626
+ symbol = _symbol;
627
+ cap = _cap;
628
+ }
629
+
630
+ /**
631
+ * @dev Function to mint tokens
632
+ * @param _to The address that will receive the minted tokens.
633
+ * @param _amount The amount of tokens to mint.
634
+ */
635
+ function mint(address _to, uint256 _amount) public onlyOwner returns (bool) {
636
+ if (cap > 0) require(totalSupply().add(_amount) <= cap);
637
+ _mint(_to, _amount);
638
+ return true;
639
+ }
640
+ }
641
+
642
+ // File: openzeppelin-solidity/contracts/utils/Address.sol
643
+
644
+ pragma solidity ^0.5.0;
645
+
646
+ /**
647
+ * Utility library of inline functions on addresses
648
+ */
649
+ library Address {
650
+ /**
651
+ * Returns whether the target address is a contract
652
+ * @dev This function will return false if invoked during the constructor of a contract,
653
+ * as the code is not actually created until after the constructor finishes.
654
+ * @param account address of the account to check
655
+ * @return whether the target address is a contract
656
+ */
657
+ function isContract(address account) internal view returns (bool) {
658
+ uint256 size;
659
+ // XXX Currently there is no better way to check if there is a contract in an address
660
+ // than to check the size of the code at that address.
661
+ // See https://ethereum.stackexchange.com/a/14016/36603
662
+ // for more details about how this works.
663
+ // TODO Check this again before the Serenity release, because all addresses will be
664
+ // contracts then.
665
+ // solhint-disable-next-line no-inline-assembly
666
+ assembly {
667
+ size := extcodesize(account)
668
+ }
669
+ return size > 0;
670
+ }
671
+ }
672
+
673
+ // File: @daostack/arc/contracts/libs/SafeERC20.sol
674
+
675
+ /*
676
+
677
+ SafeERC20 by daostack.
678
+ The code is based on a fix by SECBIT Team.
679
+
680
+ USE WITH CAUTION & NO WARRANTY
681
+
682
+ REFERENCE & RELATED READING
683
+ - https://github.com/ethereum/solidity/issues/4116
684
+ - https://medium.com/@chris_77367/explaining-unexpected-reverts-starting-with-solidity-0-4-22-3ada6e82308c
685
+ - https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca
686
+ - https://gist.github.com/BrendanChou/88a2eeb80947ff00bcf58ffdafeaeb61
687
+
688
+ */
689
+ pragma solidity ^0.5.4;
690
+
691
+ library SafeERC20 {
692
+ using Address for address;
693
+
694
+ bytes4 private constant TRANSFER_SELECTOR =
695
+ bytes4(keccak256(bytes("transfer(address,uint256)")));
696
+ bytes4 private constant TRANSFERFROM_SELECTOR =
697
+ bytes4(keccak256(bytes("transferFrom(address,address,uint256)")));
698
+ bytes4 private constant APPROVE_SELECTOR =
699
+ bytes4(keccak256(bytes("approve(address,uint256)")));
700
+
701
+ function safeTransfer(
702
+ address _erc20Addr,
703
+ address _to,
704
+ uint256 _value
705
+ ) internal {
706
+ // Must be a contract addr first!
707
+ require(_erc20Addr.isContract());
708
+
709
+ (bool success, bytes memory returnValue) = // solhint-disable-next-line avoid-low-level-calls
710
+ _erc20Addr.call(abi.encodeWithSelector(TRANSFER_SELECTOR, _to, _value));
711
+ // call return false when something wrong
712
+ require(success);
713
+ //check return value
714
+ require(
715
+ returnValue.length == 0 ||
716
+ (returnValue.length == 32 && (returnValue[31] != 0))
717
+ );
718
+ }
719
+
720
+ function safeTransferFrom(
721
+ address _erc20Addr,
722
+ address _from,
723
+ address _to,
724
+ uint256 _value
725
+ ) internal {
726
+ // Must be a contract addr first!
727
+ require(_erc20Addr.isContract());
728
+
729
+ (bool success, bytes memory returnValue) = // solhint-disable-next-line avoid-low-level-calls
730
+ _erc20Addr.call(
731
+ abi.encodeWithSelector(TRANSFERFROM_SELECTOR, _from, _to, _value)
732
+ );
733
+ // call return false when something wrong
734
+ require(success);
735
+ //check return value
736
+ require(
737
+ returnValue.length == 0 ||
738
+ (returnValue.length == 32 && (returnValue[31] != 0))
739
+ );
740
+ }
741
+
742
+ function safeApprove(
743
+ address _erc20Addr,
744
+ address _spender,
745
+ uint256 _value
746
+ ) internal {
747
+ // Must be a contract addr first!
748
+ require(_erc20Addr.isContract());
749
+
750
+ // safeApprove should only be called when setting an initial allowance,
751
+ // or when resetting it to zero.
752
+ require(
753
+ (_value == 0) ||
754
+ (IERC20(_erc20Addr).allowance(address(this), _spender) == 0)
755
+ );
756
+
757
+ (bool success, bytes memory returnValue) = // solhint-disable-next-line avoid-low-level-calls
758
+ _erc20Addr.call(abi.encodeWithSelector(APPROVE_SELECTOR, _spender, _value));
759
+ // call return false when something wrong
760
+ require(success);
761
+ //check return value
762
+ require(
763
+ returnValue.length == 0 ||
764
+ (returnValue.length == 32 && (returnValue[31] != 0))
765
+ );
766
+ }
767
+ }
768
+
769
+ // File: @daostack/arc/contracts/controller/Avatar.sol
770
+
771
+ pragma solidity ^0.5.4;
772
+
773
+ /**
774
+ * @title An Avatar holds tokens, reputation and ether for a controller
775
+ */
776
+ contract Avatar is Ownable {
777
+ using SafeERC20 for address;
778
+
779
+ string public orgName;
780
+ DAOToken public nativeToken;
781
+ Reputation public nativeReputation;
782
+
783
+ event GenericCall(
784
+ address indexed _contract,
785
+ bytes _data,
786
+ uint _value,
787
+ bool _success
788
+ );
789
+ event SendEther(uint256 _amountInWei, address indexed _to);
790
+ event ExternalTokenTransfer(
791
+ address indexed _externalToken,
792
+ address indexed _to,
793
+ uint256 _value
794
+ );
795
+ event ExternalTokenTransferFrom(
796
+ address indexed _externalToken,
797
+ address _from,
798
+ address _to,
799
+ uint256 _value
800
+ );
801
+ event ExternalTokenApproval(
802
+ address indexed _externalToken,
803
+ address _spender,
804
+ uint256 _value
805
+ );
806
+ event ReceiveEther(address indexed _sender, uint256 _value);
807
+ event MetaData(string _metaData);
808
+
809
+ /**
810
+ * @dev the constructor takes organization name, native token and reputation system
811
+ and creates an avatar for a controller
812
+ */
813
+ constructor(
814
+ string memory _orgName,
815
+ DAOToken _nativeToken,
816
+ Reputation _nativeReputation
817
+ ) public {
818
+ orgName = _orgName;
819
+ nativeToken = _nativeToken;
820
+ nativeReputation = _nativeReputation;
821
+ }
822
+
823
+ /**
824
+ * @dev enables an avatar to receive ethers
825
+ */
826
+ function() external payable {
827
+ emit ReceiveEther(msg.sender, msg.value);
828
+ }
829
+
830
+ /**
831
+ * @dev perform a generic call to an arbitrary contract
832
+ * @param _contract the contract's address to call
833
+ * @param _data ABI-encoded contract call to call `_contract` address.
834
+ * @param _value value (ETH) to transfer with the transaction
835
+ * @return bool success or fail
836
+ * bytes - the return bytes of the called contract's function.
837
+ */
838
+ function genericCall(
839
+ address _contract,
840
+ bytes memory _data,
841
+ uint256 _value
842
+ ) public onlyOwner returns (bool success, bytes memory returnValue) {
843
+ // solhint-disable-next-line avoid-call-value
844
+ (success, returnValue) = _contract.call.value(_value)(_data);
845
+ emit GenericCall(_contract, _data, _value, success);
846
+ }
847
+
848
+ /**
849
+ * @dev send ethers from the avatar's wallet
850
+ * @param _amountInWei amount to send in Wei units
851
+ * @param _to send the ethers to this address
852
+ * @return bool which represents success
853
+ */
854
+ function sendEther(
855
+ uint256 _amountInWei,
856
+ address payable _to
857
+ ) public onlyOwner returns (bool) {
858
+ _to.transfer(_amountInWei);
859
+ emit SendEther(_amountInWei, _to);
860
+ return true;
861
+ }
862
+
863
+ /**
864
+ * @dev external token transfer
865
+ * @param _externalToken the token contract
866
+ * @param _to the destination address
867
+ * @param _value the amount of tokens to transfer
868
+ * @return bool which represents success
869
+ */
870
+ function externalTokenTransfer(
871
+ IERC20 _externalToken,
872
+ address _to,
873
+ uint256 _value
874
+ ) public onlyOwner returns (bool) {
875
+ address(_externalToken).safeTransfer(_to, _value);
876
+ emit ExternalTokenTransfer(address(_externalToken), _to, _value);
877
+ return true;
878
+ }
879
+
880
+ /**
881
+ * @dev external token transfer from a specific account
882
+ * @param _externalToken the token contract
883
+ * @param _from the account to spend token from
884
+ * @param _to the destination address
885
+ * @param _value the amount of tokens to transfer
886
+ * @return bool which represents success
887
+ */
888
+ function externalTokenTransferFrom(
889
+ IERC20 _externalToken,
890
+ address _from,
891
+ address _to,
892
+ uint256 _value
893
+ ) public onlyOwner returns (bool) {
894
+ address(_externalToken).safeTransferFrom(_from, _to, _value);
895
+ emit ExternalTokenTransferFrom(address(_externalToken), _from, _to, _value);
896
+ return true;
897
+ }
898
+
899
+ /**
900
+ * @dev externalTokenApproval approve the spender address to spend a specified amount of tokens
901
+ * on behalf of msg.sender.
902
+ * @param _externalToken the address of the Token Contract
903
+ * @param _spender address
904
+ * @param _value the amount of ether (in Wei) which the approval is referring to.
905
+ * @return bool which represents a success
906
+ */
907
+ function externalTokenApproval(
908
+ IERC20 _externalToken,
909
+ address _spender,
910
+ uint256 _value
911
+ ) public onlyOwner returns (bool) {
912
+ address(_externalToken).safeApprove(_spender, _value);
913
+ emit ExternalTokenApproval(address(_externalToken), _spender, _value);
914
+ return true;
915
+ }
916
+
917
+ /**
918
+ * @dev metaData emits an event with a string, should contain the hash of some meta data.
919
+ * @param _metaData a string representing a hash of the meta data
920
+ * @return bool which represents a success
921
+ */
922
+ function metaData(string memory _metaData) public onlyOwner returns (bool) {
923
+ emit MetaData(_metaData);
924
+ return true;
925
+ }
926
+ }
927
+
928
+ // File: @daostack/arc/contracts/globalConstraints/GlobalConstraintInterface.sol
929
+
930
+ pragma solidity ^0.5.4;
931
+
932
+ contract GlobalConstraintInterface {
933
+ enum CallPhase {
934
+ Pre,
935
+ Post,
936
+ PreAndPost
937
+ }
938
+
939
+ function pre(
940
+ address _scheme,
941
+ bytes32 _params,
942
+ bytes32 _method
943
+ ) public returns (bool);
944
+
945
+ function post(
946
+ address _scheme,
947
+ bytes32 _params,
948
+ bytes32 _method
949
+ ) public returns (bool);
950
+
951
+ /**
952
+ * @dev when return if this globalConstraints is pre, post or both.
953
+ * @return CallPhase enum indication Pre, Post or PreAndPost.
954
+ */
955
+ function when() public returns (CallPhase);
956
+ }
957
+
958
+ // File: @daostack/arc/contracts/controller/ControllerInterface.sol
959
+
960
+ pragma solidity ^0.5.4;
961
+
962
+ /**
963
+ * @title Controller contract
964
+ * @dev A controller controls the organizations tokens ,reputation and avatar.
965
+ * It is subject to a set of schemes and constraints that determine its behavior.
966
+ * Each scheme has it own parameters and operation permissions.
967
+ */
968
+ interface ControllerInterface {
969
+ /**
970
+ * @dev Mint `_amount` of reputation that are assigned to `_to` .
971
+ * @param _amount amount of reputation to mint
972
+ * @param _to beneficiary address
973
+ * @return bool which represents a success
974
+ */
975
+ function mintReputation(
976
+ uint256 _amount,
977
+ address _to,
978
+ address _avatar
979
+ ) external returns (bool);
980
+
981
+ /**
982
+ * @dev Burns `_amount` of reputation from `_from`
983
+ * @param _amount amount of reputation to burn
984
+ * @param _from The address that will lose the reputation
985
+ * @return bool which represents a success
986
+ */
987
+ function burnReputation(
988
+ uint256 _amount,
989
+ address _from,
990
+ address _avatar
991
+ ) external returns (bool);
992
+
993
+ /**
994
+ * @dev mint tokens .
995
+ * @param _amount amount of token to mint
996
+ * @param _beneficiary beneficiary address
997
+ * @param _avatar address
998
+ * @return bool which represents a success
999
+ */
1000
+ function mintTokens(
1001
+ uint256 _amount,
1002
+ address _beneficiary,
1003
+ address _avatar
1004
+ ) external returns (bool);
1005
+
1006
+ /**
1007
+ * @dev register or update a scheme
1008
+ * @param _scheme the address of the scheme
1009
+ * @param _paramsHash a hashed configuration of the usage of the scheme
1010
+ * @param _permissions the permissions the new scheme will have
1011
+ * @param _avatar address
1012
+ * @return bool which represents a success
1013
+ */
1014
+ function registerScheme(
1015
+ address _scheme,
1016
+ bytes32 _paramsHash,
1017
+ bytes4 _permissions,
1018
+ address _avatar
1019
+ ) external returns (bool);
1020
+
1021
+ /**
1022
+ * @dev unregister a scheme
1023
+ * @param _avatar address
1024
+ * @param _scheme the address of the scheme
1025
+ * @return bool which represents a success
1026
+ */
1027
+ function unregisterScheme(
1028
+ address _scheme,
1029
+ address _avatar
1030
+ ) external returns (bool);
1031
+
1032
+ /**
1033
+ * @dev unregister the caller's scheme
1034
+ * @param _avatar address
1035
+ * @return bool which represents a success
1036
+ */
1037
+ function unregisterSelf(address _avatar) external returns (bool);
1038
+
1039
+ /**
1040
+ * @dev add or update Global Constraint
1041
+ * @param _globalConstraint the address of the global constraint to be added.
1042
+ * @param _params the constraint parameters hash.
1043
+ * @param _avatar the avatar of the organization
1044
+ * @return bool which represents a success
1045
+ */
1046
+ function addGlobalConstraint(
1047
+ address _globalConstraint,
1048
+ bytes32 _params,
1049
+ address _avatar
1050
+ ) external returns (bool);
1051
+
1052
+ /**
1053
+ * @dev remove Global Constraint
1054
+ * @param _globalConstraint the address of the global constraint to be remove.
1055
+ * @param _avatar the organization avatar.
1056
+ * @return bool which represents a success
1057
+ */
1058
+ function removeGlobalConstraint(
1059
+ address _globalConstraint,
1060
+ address _avatar
1061
+ ) external returns (bool);
1062
+
1063
+ /**
1064
+ * @dev upgrade the Controller
1065
+ * The function will trigger an event 'UpgradeController'.
1066
+ * @param _newController the address of the new controller.
1067
+ * @param _avatar address
1068
+ * @return bool which represents a success
1069
+ */
1070
+ function upgradeController(
1071
+ address _newController,
1072
+ Avatar _avatar
1073
+ ) external returns (bool);
1074
+
1075
+ /**
1076
+ * @dev perform a generic call to an arbitrary contract
1077
+ * @param _contract the contract's address to call
1078
+ * @param _data ABI-encoded contract call to call `_contract` address.
1079
+ * @param _avatar the controller's avatar address
1080
+ * @param _value value (ETH) to transfer with the transaction
1081
+ * @return bool -success
1082
+ * bytes - the return value of the called _contract's function.
1083
+ */
1084
+ function genericCall(
1085
+ address _contract,
1086
+ bytes calldata _data,
1087
+ Avatar _avatar,
1088
+ uint256 _value
1089
+ ) external returns (bool, bytes memory);
1090
+
1091
+ /**
1092
+ * @dev send some ether
1093
+ * @param _amountInWei the amount of ether (in Wei) to send
1094
+ * @param _to address of the beneficiary
1095
+ * @param _avatar address
1096
+ * @return bool which represents a success
1097
+ */
1098
+ function sendEther(
1099
+ uint256 _amountInWei,
1100
+ address payable _to,
1101
+ Avatar _avatar
1102
+ ) external returns (bool);
1103
+
1104
+ /**
1105
+ * @dev send some amount of arbitrary ERC20 Tokens
1106
+ * @param _externalToken the address of the Token Contract
1107
+ * @param _to address of the beneficiary
1108
+ * @param _value the amount of ether (in Wei) to send
1109
+ * @param _avatar address
1110
+ * @return bool which represents a success
1111
+ */
1112
+ function externalTokenTransfer(
1113
+ IERC20 _externalToken,
1114
+ address _to,
1115
+ uint256 _value,
1116
+ Avatar _avatar
1117
+ ) external returns (bool);
1118
+
1119
+ /**
1120
+ * @dev transfer token "from" address "to" address
1121
+ * One must to approve the amount of tokens which can be spend from the
1122
+ * "from" account.This can be done using externalTokenApprove.
1123
+ * @param _externalToken the address of the Token Contract
1124
+ * @param _from address of the account to send from
1125
+ * @param _to address of the beneficiary
1126
+ * @param _value the amount of ether (in Wei) to send
1127
+ * @param _avatar address
1128
+ * @return bool which represents a success
1129
+ */
1130
+ function externalTokenTransferFrom(
1131
+ IERC20 _externalToken,
1132
+ address _from,
1133
+ address _to,
1134
+ uint256 _value,
1135
+ Avatar _avatar
1136
+ ) external returns (bool);
1137
+
1138
+ /**
1139
+ * @dev externalTokenApproval approve the spender address to spend a specified amount of tokens
1140
+ * on behalf of msg.sender.
1141
+ * @param _externalToken the address of the Token Contract
1142
+ * @param _spender address
1143
+ * @param _value the amount of ether (in Wei) which the approval is referring to.
1144
+ * @return bool which represents a success
1145
+ */
1146
+ function externalTokenApproval(
1147
+ IERC20 _externalToken,
1148
+ address _spender,
1149
+ uint256 _value,
1150
+ Avatar _avatar
1151
+ ) external returns (bool);
1152
+
1153
+ /**
1154
+ * @dev metaData emits an event with a string, should contain the hash of some meta data.
1155
+ * @param _metaData a string representing a hash of the meta data
1156
+ * @param _avatar Avatar
1157
+ * @return bool which represents a success
1158
+ */
1159
+ function metaData(
1160
+ string calldata _metaData,
1161
+ Avatar _avatar
1162
+ ) external returns (bool);
1163
+
1164
+ /**
1165
+ * @dev getNativeReputation
1166
+ * @param _avatar the organization avatar.
1167
+ * @return organization native reputation
1168
+ */
1169
+ function getNativeReputation(address _avatar) external view returns (address);
1170
+
1171
+ function isSchemeRegistered(
1172
+ address _scheme,
1173
+ address _avatar
1174
+ ) external view returns (bool);
1175
+
1176
+ function getSchemeParameters(
1177
+ address _scheme,
1178
+ address _avatar
1179
+ ) external view returns (bytes32);
1180
+
1181
+ function getGlobalConstraintParameters(
1182
+ address _globalConstraint,
1183
+ address _avatar
1184
+ ) external view returns (bytes32);
1185
+
1186
+ function getSchemePermissions(
1187
+ address _scheme,
1188
+ address _avatar
1189
+ ) external view returns (bytes4);
1190
+
1191
+ /**
1192
+ * @dev globalConstraintsCount return the global constraint pre and post count
1193
+ * @return uint256 globalConstraintsPre count.
1194
+ * @return uint256 globalConstraintsPost count.
1195
+ */
1196
+ function globalConstraintsCount(
1197
+ address _avatar
1198
+ ) external view returns (uint, uint);
1199
+
1200
+ function isGlobalConstraintRegistered(
1201
+ address _globalConstraint,
1202
+ address _avatar
1203
+ ) external view returns (bool);
1204
+ }
1205
+
1206
+ // File: @daostack/arc/contracts/controller/Controller.sol
1207
+
1208
+ pragma solidity ^0.5.4;
1209
+
1210
+ /**
1211
+ * @title Controller contract
1212
+ * @dev A controller controls the organizations tokens, reputation and avatar.
1213
+ * It is subject to a set of schemes and constraints that determine its behavior.
1214
+ * Each scheme has it own parameters and operation permissions.
1215
+ */
1216
+ contract Controller is ControllerInterface {
1217
+ struct Scheme {
1218
+ bytes32 paramsHash; // a hash "configuration" of the scheme
1219
+ bytes4 permissions; // A bitwise flags of permissions,
1220
+ // All 0: Not registered,
1221
+ // 1st bit: Flag if the scheme is registered,
1222
+ // 2nd bit: Scheme can register other schemes
1223
+ // 3rd bit: Scheme can add/remove global constraints
1224
+ // 4th bit: Scheme can upgrade the controller
1225
+ // 5th bit: Scheme can call genericCall on behalf of
1226
+ // the organization avatar
1227
+ }
1228
+
1229
+ struct GlobalConstraint {
1230
+ address gcAddress;
1231
+ bytes32 params;
1232
+ }
1233
+
1234
+ struct GlobalConstraintRegister {
1235
+ bool isRegistered; //is registered
1236
+ uint256 index; //index at globalConstraints
1237
+ }
1238
+
1239
+ mapping(address => Scheme) public schemes;
1240
+
1241
+ Avatar public avatar;
1242
+ DAOToken public nativeToken;
1243
+ Reputation public nativeReputation;
1244
+ // newController will point to the new controller after the present controller is upgraded
1245
+ address public newController;
1246
+ // globalConstraintsPre that determine pre conditions for all actions on the controller
1247
+
1248
+ GlobalConstraint[] public globalConstraintsPre;
1249
+ // globalConstraintsPost that determine post conditions for all actions on the controller
1250
+ GlobalConstraint[] public globalConstraintsPost;
1251
+ // globalConstraintsRegisterPre indicate if a globalConstraints is registered as a pre global constraint
1252
+ mapping(address => GlobalConstraintRegister)
1253
+ public globalConstraintsRegisterPre;
1254
+ // globalConstraintsRegisterPost indicate if a globalConstraints is registered as a post global constraint
1255
+ mapping(address => GlobalConstraintRegister)
1256
+ public globalConstraintsRegisterPost;
1257
+
1258
+ event MintReputation(
1259
+ address indexed _sender,
1260
+ address indexed _to,
1261
+ uint256 _amount
1262
+ );
1263
+ event BurnReputation(
1264
+ address indexed _sender,
1265
+ address indexed _from,
1266
+ uint256 _amount
1267
+ );
1268
+ event MintTokens(
1269
+ address indexed _sender,
1270
+ address indexed _beneficiary,
1271
+ uint256 _amount
1272
+ );
1273
+ event RegisterScheme(address indexed _sender, address indexed _scheme);
1274
+ event UnregisterScheme(address indexed _sender, address indexed _scheme);
1275
+ event UpgradeController(
1276
+ address indexed _oldController,
1277
+ address _newController
1278
+ );
1279
+
1280
+ event AddGlobalConstraint(
1281
+ address indexed _globalConstraint,
1282
+ bytes32 _params,
1283
+ GlobalConstraintInterface.CallPhase _when
1284
+ );
1285
+
1286
+ event RemoveGlobalConstraint(
1287
+ address indexed _globalConstraint,
1288
+ uint256 _index,
1289
+ bool _isPre
1290
+ );
1291
+
1292
+ constructor(Avatar _avatar) public {
1293
+ avatar = _avatar;
1294
+ nativeToken = avatar.nativeToken();
1295
+ nativeReputation = avatar.nativeReputation();
1296
+ schemes[msg.sender] = Scheme({
1297
+ paramsHash: bytes32(0),
1298
+ permissions: bytes4(0x0000001F)
1299
+ });
1300
+ }
1301
+
1302
+ // Do not allow mistaken calls:
1303
+ // solhint-disable-next-line payable-fallback
1304
+ function() external {
1305
+ revert();
1306
+ }
1307
+
1308
+ // Modifiers:
1309
+ modifier onlyRegisteredScheme() {
1310
+ require(
1311
+ schemes[msg.sender].permissions & bytes4(0x00000001) == bytes4(0x00000001)
1312
+ );
1313
+ _;
1314
+ }
1315
+
1316
+ modifier onlyRegisteringSchemes() {
1317
+ require(
1318
+ schemes[msg.sender].permissions & bytes4(0x00000002) == bytes4(0x00000002)
1319
+ );
1320
+ _;
1321
+ }
1322
+
1323
+ modifier onlyGlobalConstraintsScheme() {
1324
+ require(
1325
+ schemes[msg.sender].permissions & bytes4(0x00000004) == bytes4(0x00000004)
1326
+ );
1327
+ _;
1328
+ }
1329
+
1330
+ modifier onlyUpgradingScheme() {
1331
+ require(
1332
+ schemes[msg.sender].permissions & bytes4(0x00000008) == bytes4(0x00000008)
1333
+ );
1334
+ _;
1335
+ }
1336
+
1337
+ modifier onlyGenericCallScheme() {
1338
+ require(
1339
+ schemes[msg.sender].permissions & bytes4(0x00000010) == bytes4(0x00000010)
1340
+ );
1341
+ _;
1342
+ }
1343
+
1344
+ modifier onlyMetaDataScheme() {
1345
+ require(
1346
+ schemes[msg.sender].permissions & bytes4(0x00000010) == bytes4(0x00000010)
1347
+ );
1348
+ _;
1349
+ }
1350
+
1351
+ modifier onlySubjectToConstraint(bytes32 func) {
1352
+ uint256 idx;
1353
+ for (idx = 0; idx < globalConstraintsPre.length; idx++) {
1354
+ require(
1355
+ (GlobalConstraintInterface(globalConstraintsPre[idx].gcAddress)).pre(
1356
+ msg.sender,
1357
+ globalConstraintsPre[idx].params,
1358
+ func
1359
+ )
1360
+ );
1361
+ }
1362
+ _;
1363
+ for (idx = 0; idx < globalConstraintsPost.length; idx++) {
1364
+ require(
1365
+ (GlobalConstraintInterface(globalConstraintsPost[idx].gcAddress)).post(
1366
+ msg.sender,
1367
+ globalConstraintsPost[idx].params,
1368
+ func
1369
+ )
1370
+ );
1371
+ }
1372
+ }
1373
+
1374
+ modifier isAvatarValid(address _avatar) {
1375
+ require(_avatar == address(avatar));
1376
+ _;
1377
+ }
1378
+
1379
+ /**
1380
+ * @dev Mint `_amount` of reputation that are assigned to `_to` .
1381
+ * @param _amount amount of reputation to mint
1382
+ * @param _to beneficiary address
1383
+ * @return bool which represents a success
1384
+ */
1385
+ function mintReputation(
1386
+ uint256 _amount,
1387
+ address _to,
1388
+ address _avatar
1389
+ )
1390
+ external
1391
+ onlyRegisteredScheme
1392
+ onlySubjectToConstraint("mintReputation")
1393
+ isAvatarValid(_avatar)
1394
+ returns (bool)
1395
+ {
1396
+ emit MintReputation(msg.sender, _to, _amount);
1397
+ return nativeReputation.mint(_to, _amount);
1398
+ }
1399
+
1400
+ /**
1401
+ * @dev Burns `_amount` of reputation from `_from`
1402
+ * @param _amount amount of reputation to burn
1403
+ * @param _from The address that will lose the reputation
1404
+ * @return bool which represents a success
1405
+ */
1406
+ function burnReputation(
1407
+ uint256 _amount,
1408
+ address _from,
1409
+ address _avatar
1410
+ )
1411
+ external
1412
+ onlyRegisteredScheme
1413
+ onlySubjectToConstraint("burnReputation")
1414
+ isAvatarValid(_avatar)
1415
+ returns (bool)
1416
+ {
1417
+ emit BurnReputation(msg.sender, _from, _amount);
1418
+ return nativeReputation.burn(_from, _amount);
1419
+ }
1420
+
1421
+ /**
1422
+ * @dev mint tokens .
1423
+ * @param _amount amount of token to mint
1424
+ * @param _beneficiary beneficiary address
1425
+ * @return bool which represents a success
1426
+ */
1427
+ function mintTokens(
1428
+ uint256 _amount,
1429
+ address _beneficiary,
1430
+ address _avatar
1431
+ )
1432
+ external
1433
+ onlyRegisteredScheme
1434
+ onlySubjectToConstraint("mintTokens")
1435
+ isAvatarValid(_avatar)
1436
+ returns (bool)
1437
+ {
1438
+ emit MintTokens(msg.sender, _beneficiary, _amount);
1439
+ return nativeToken.mint(_beneficiary, _amount);
1440
+ }
1441
+
1442
+ /**
1443
+ * @dev register a scheme
1444
+ * @param _scheme the address of the scheme
1445
+ * @param _paramsHash a hashed configuration of the usage of the scheme
1446
+ * @param _permissions the permissions the new scheme will have
1447
+ * @return bool which represents a success
1448
+ */
1449
+ function registerScheme(
1450
+ address _scheme,
1451
+ bytes32 _paramsHash,
1452
+ bytes4 _permissions,
1453
+ address _avatar
1454
+ )
1455
+ external
1456
+ onlyRegisteringSchemes
1457
+ onlySubjectToConstraint("registerScheme")
1458
+ isAvatarValid(_avatar)
1459
+ returns (bool)
1460
+ {
1461
+ Scheme memory scheme = schemes[_scheme];
1462
+
1463
+ // Check scheme has at least the permissions it is changing, and at least the current permissions:
1464
+ // Implementation is a bit messy. One must recall logic-circuits ^^
1465
+
1466
+ // produces non-zero if sender does not have all of the perms that are changing between old and new
1467
+ require(
1468
+ bytes4(0x0000001f) &
1469
+ (_permissions ^ scheme.permissions) &
1470
+ (~schemes[msg.sender].permissions) ==
1471
+ bytes4(0)
1472
+ );
1473
+
1474
+ // produces non-zero if sender does not have all of the perms in the old scheme
1475
+ require(
1476
+ bytes4(0x0000001f) &
1477
+ (scheme.permissions & (~schemes[msg.sender].permissions)) ==
1478
+ bytes4(0)
1479
+ );
1480
+
1481
+ // Add or change the scheme:
1482
+ schemes[_scheme].paramsHash = _paramsHash;
1483
+ schemes[_scheme].permissions = _permissions | bytes4(0x00000001);
1484
+ emit RegisterScheme(msg.sender, _scheme);
1485
+ return true;
1486
+ }
1487
+
1488
+ /**
1489
+ * @dev unregister a scheme
1490
+ * @param _scheme the address of the scheme
1491
+ * @return bool which represents a success
1492
+ */
1493
+ function unregisterScheme(
1494
+ address _scheme,
1495
+ address _avatar
1496
+ )
1497
+ external
1498
+ onlyRegisteringSchemes
1499
+ onlySubjectToConstraint("unregisterScheme")
1500
+ isAvatarValid(_avatar)
1501
+ returns (bool)
1502
+ {
1503
+ //check if the scheme is registered
1504
+ if (_isSchemeRegistered(_scheme) == false) {
1505
+ return false;
1506
+ }
1507
+ // Check the unregistering scheme has enough permissions:
1508
+ require(
1509
+ bytes4(0x0000001f) &
1510
+ (schemes[_scheme].permissions & (~schemes[msg.sender].permissions)) ==
1511
+ bytes4(0)
1512
+ );
1513
+
1514
+ // Unregister:
1515
+ emit UnregisterScheme(msg.sender, _scheme);
1516
+ delete schemes[_scheme];
1517
+ return true;
1518
+ }
1519
+
1520
+ /**
1521
+ * @dev unregister the caller's scheme
1522
+ * @return bool which represents a success
1523
+ */
1524
+ function unregisterSelf(
1525
+ address _avatar
1526
+ ) external isAvatarValid(_avatar) returns (bool) {
1527
+ if (_isSchemeRegistered(msg.sender) == false) {
1528
+ return false;
1529
+ }
1530
+ delete schemes[msg.sender];
1531
+ emit UnregisterScheme(msg.sender, msg.sender);
1532
+ return true;
1533
+ }
1534
+
1535
+ /**
1536
+ * @dev add or update Global Constraint
1537
+ * @param _globalConstraint the address of the global constraint to be added.
1538
+ * @param _params the constraint parameters hash.
1539
+ * @return bool which represents a success
1540
+ */
1541
+ function addGlobalConstraint(
1542
+ address _globalConstraint,
1543
+ bytes32 _params,
1544
+ address _avatar
1545
+ ) external onlyGlobalConstraintsScheme isAvatarValid(_avatar) returns (bool) {
1546
+ GlobalConstraintInterface.CallPhase when = GlobalConstraintInterface(
1547
+ _globalConstraint
1548
+ ).when();
1549
+ if (
1550
+ (when == GlobalConstraintInterface.CallPhase.Pre) ||
1551
+ (when == GlobalConstraintInterface.CallPhase.PreAndPost)
1552
+ ) {
1553
+ if (!globalConstraintsRegisterPre[_globalConstraint].isRegistered) {
1554
+ globalConstraintsPre.push(GlobalConstraint(_globalConstraint, _params));
1555
+ globalConstraintsRegisterPre[
1556
+ _globalConstraint
1557
+ ] = GlobalConstraintRegister(true, globalConstraintsPre.length - 1);
1558
+ } else {
1559
+ globalConstraintsPre[
1560
+ globalConstraintsRegisterPre[_globalConstraint].index
1561
+ ].params = _params;
1562
+ }
1563
+ }
1564
+ if (
1565
+ (when == GlobalConstraintInterface.CallPhase.Post) ||
1566
+ (when == GlobalConstraintInterface.CallPhase.PreAndPost)
1567
+ ) {
1568
+ if (!globalConstraintsRegisterPost[_globalConstraint].isRegistered) {
1569
+ globalConstraintsPost.push(
1570
+ GlobalConstraint(_globalConstraint, _params)
1571
+ );
1572
+ globalConstraintsRegisterPost[
1573
+ _globalConstraint
1574
+ ] = GlobalConstraintRegister(true, globalConstraintsPost.length - 1);
1575
+ } else {
1576
+ globalConstraintsPost[
1577
+ globalConstraintsRegisterPost[_globalConstraint].index
1578
+ ].params = _params;
1579
+ }
1580
+ }
1581
+ emit AddGlobalConstraint(_globalConstraint, _params, when);
1582
+ return true;
1583
+ }
1584
+
1585
+ /**
1586
+ * @dev remove Global Constraint
1587
+ * @param _globalConstraint the address of the global constraint to be remove.
1588
+ * @return bool which represents a success
1589
+ */
1590
+ // solhint-disable-next-line code-complexity
1591
+ function removeGlobalConstraint(
1592
+ address _globalConstraint,
1593
+ address _avatar
1594
+ ) external onlyGlobalConstraintsScheme isAvatarValid(_avatar) returns (bool) {
1595
+ GlobalConstraintRegister memory globalConstraintRegister;
1596
+ GlobalConstraint memory globalConstraint;
1597
+ GlobalConstraintInterface.CallPhase when = GlobalConstraintInterface(
1598
+ _globalConstraint
1599
+ ).when();
1600
+ bool retVal = false;
1601
+
1602
+ if (
1603
+ (when == GlobalConstraintInterface.CallPhase.Pre) ||
1604
+ (when == GlobalConstraintInterface.CallPhase.PreAndPost)
1605
+ ) {
1606
+ globalConstraintRegister = globalConstraintsRegisterPre[
1607
+ _globalConstraint
1608
+ ];
1609
+ if (globalConstraintRegister.isRegistered) {
1610
+ if (globalConstraintRegister.index < globalConstraintsPre.length - 1) {
1611
+ globalConstraint = globalConstraintsPre[
1612
+ globalConstraintsPre.length - 1
1613
+ ];
1614
+ globalConstraintsPre[
1615
+ globalConstraintRegister.index
1616
+ ] = globalConstraint;
1617
+ globalConstraintsRegisterPre[globalConstraint.gcAddress]
1618
+ .index = globalConstraintRegister.index;
1619
+ }
1620
+ globalConstraintsPre.length--;
1621
+ delete globalConstraintsRegisterPre[_globalConstraint];
1622
+ retVal = true;
1623
+ }
1624
+ }
1625
+ if (
1626
+ (when == GlobalConstraintInterface.CallPhase.Post) ||
1627
+ (when == GlobalConstraintInterface.CallPhase.PreAndPost)
1628
+ ) {
1629
+ globalConstraintRegister = globalConstraintsRegisterPost[
1630
+ _globalConstraint
1631
+ ];
1632
+ if (globalConstraintRegister.isRegistered) {
1633
+ if (globalConstraintRegister.index < globalConstraintsPost.length - 1) {
1634
+ globalConstraint = globalConstraintsPost[
1635
+ globalConstraintsPost.length - 1
1636
+ ];
1637
+ globalConstraintsPost[
1638
+ globalConstraintRegister.index
1639
+ ] = globalConstraint;
1640
+ globalConstraintsRegisterPost[globalConstraint.gcAddress]
1641
+ .index = globalConstraintRegister.index;
1642
+ }
1643
+ globalConstraintsPost.length--;
1644
+ delete globalConstraintsRegisterPost[_globalConstraint];
1645
+ retVal = true;
1646
+ }
1647
+ }
1648
+ if (retVal) {
1649
+ emit RemoveGlobalConstraint(
1650
+ _globalConstraint,
1651
+ globalConstraintRegister.index,
1652
+ when == GlobalConstraintInterface.CallPhase.Pre
1653
+ );
1654
+ }
1655
+ return retVal;
1656
+ }
1657
+
1658
+ /**
1659
+ * @dev upgrade the Controller
1660
+ * The function will trigger an event 'UpgradeController'.
1661
+ * @param _newController the address of the new controller.
1662
+ * @return bool which represents a success
1663
+ */
1664
+ function upgradeController(
1665
+ address _newController,
1666
+ Avatar _avatar
1667
+ )
1668
+ external
1669
+ onlyUpgradingScheme
1670
+ isAvatarValid(address(_avatar))
1671
+ returns (bool)
1672
+ {
1673
+ require(newController == address(0)); // so the upgrade could be done once for a contract.
1674
+ require(_newController != address(0));
1675
+ newController = _newController;
1676
+ avatar.transferOwnership(_newController);
1677
+ require(avatar.owner() == _newController);
1678
+ if (nativeToken.owner() == address(this)) {
1679
+ nativeToken.transferOwnership(_newController);
1680
+ require(nativeToken.owner() == _newController);
1681
+ }
1682
+ if (nativeReputation.owner() == address(this)) {
1683
+ nativeReputation.transferOwnership(_newController);
1684
+ require(nativeReputation.owner() == _newController);
1685
+ }
1686
+ emit UpgradeController(address(this), newController);
1687
+ return true;
1688
+ }
1689
+
1690
+ /**
1691
+ * @dev perform a generic call to an arbitrary contract
1692
+ * @param _contract the contract's address to call
1693
+ * @param _data ABI-encoded contract call to call `_contract` address.
1694
+ * @param _avatar the controller's avatar address
1695
+ * @param _value value (ETH) to transfer with the transaction
1696
+ * @return bool -success
1697
+ * bytes - the return value of the called _contract's function.
1698
+ */
1699
+ function genericCall(
1700
+ address _contract,
1701
+ bytes calldata _data,
1702
+ Avatar _avatar,
1703
+ uint256 _value
1704
+ )
1705
+ external
1706
+ onlyGenericCallScheme
1707
+ onlySubjectToConstraint("genericCall")
1708
+ isAvatarValid(address(_avatar))
1709
+ returns (bool, bytes memory)
1710
+ {
1711
+ return avatar.genericCall(_contract, _data, _value);
1712
+ }
1713
+
1714
+ /**
1715
+ * @dev send some ether
1716
+ * @param _amountInWei the amount of ether (in Wei) to send
1717
+ * @param _to address of the beneficiary
1718
+ * @return bool which represents a success
1719
+ */
1720
+ function sendEther(
1721
+ uint256 _amountInWei,
1722
+ address payable _to,
1723
+ Avatar _avatar
1724
+ )
1725
+ external
1726
+ onlyRegisteredScheme
1727
+ onlySubjectToConstraint("sendEther")
1728
+ isAvatarValid(address(_avatar))
1729
+ returns (bool)
1730
+ {
1731
+ return avatar.sendEther(_amountInWei, _to);
1732
+ }
1733
+
1734
+ /**
1735
+ * @dev send some amount of arbitrary ERC20 Tokens
1736
+ * @param _externalToken the address of the Token Contract
1737
+ * @param _to address of the beneficiary
1738
+ * @param _value the amount of ether (in Wei) to send
1739
+ * @return bool which represents a success
1740
+ */
1741
+ function externalTokenTransfer(
1742
+ IERC20 _externalToken,
1743
+ address _to,
1744
+ uint256 _value,
1745
+ Avatar _avatar
1746
+ )
1747
+ external
1748
+ onlyRegisteredScheme
1749
+ onlySubjectToConstraint("externalTokenTransfer")
1750
+ isAvatarValid(address(_avatar))
1751
+ returns (bool)
1752
+ {
1753
+ return avatar.externalTokenTransfer(_externalToken, _to, _value);
1754
+ }
1755
+
1756
+ /**
1757
+ * @dev transfer token "from" address "to" address
1758
+ * One must to approve the amount of tokens which can be spend from the
1759
+ * "from" account.This can be done using externalTokenApprove.
1760
+ * @param _externalToken the address of the Token Contract
1761
+ * @param _from address of the account to send from
1762
+ * @param _to address of the beneficiary
1763
+ * @param _value the amount of ether (in Wei) to send
1764
+ * @return bool which represents a success
1765
+ */
1766
+ function externalTokenTransferFrom(
1767
+ IERC20 _externalToken,
1768
+ address _from,
1769
+ address _to,
1770
+ uint256 _value,
1771
+ Avatar _avatar
1772
+ )
1773
+ external
1774
+ onlyRegisteredScheme
1775
+ onlySubjectToConstraint("externalTokenTransferFrom")
1776
+ isAvatarValid(address(_avatar))
1777
+ returns (bool)
1778
+ {
1779
+ return avatar.externalTokenTransferFrom(_externalToken, _from, _to, _value);
1780
+ }
1781
+
1782
+ /**
1783
+ * @dev externalTokenApproval approve the spender address to spend a specified amount of tokens
1784
+ * on behalf of msg.sender.
1785
+ * @param _externalToken the address of the Token Contract
1786
+ * @param _spender address
1787
+ * @param _value the amount of ether (in Wei) which the approval is referring to.
1788
+ * @return bool which represents a success
1789
+ */
1790
+ function externalTokenApproval(
1791
+ IERC20 _externalToken,
1792
+ address _spender,
1793
+ uint256 _value,
1794
+ Avatar _avatar
1795
+ )
1796
+ external
1797
+ onlyRegisteredScheme
1798
+ onlySubjectToConstraint("externalTokenIncreaseApproval")
1799
+ isAvatarValid(address(_avatar))
1800
+ returns (bool)
1801
+ {
1802
+ return avatar.externalTokenApproval(_externalToken, _spender, _value);
1803
+ }
1804
+
1805
+ /**
1806
+ * @dev metaData emits an event with a string, should contain the hash of some meta data.
1807
+ * @param _metaData a string representing a hash of the meta data
1808
+ * @param _avatar Avatar
1809
+ * @return bool which represents a success
1810
+ */
1811
+ function metaData(
1812
+ string calldata _metaData,
1813
+ Avatar _avatar
1814
+ ) external onlyMetaDataScheme isAvatarValid(address(_avatar)) returns (bool) {
1815
+ return avatar.metaData(_metaData);
1816
+ }
1817
+
1818
+ /**
1819
+ * @dev getNativeReputation
1820
+ * @param _avatar the organization avatar.
1821
+ * @return organization native reputation
1822
+ */
1823
+ function getNativeReputation(
1824
+ address _avatar
1825
+ ) external view isAvatarValid(_avatar) returns (address) {
1826
+ return address(nativeReputation);
1827
+ }
1828
+
1829
+ function isSchemeRegistered(
1830
+ address _scheme,
1831
+ address _avatar
1832
+ ) external view isAvatarValid(_avatar) returns (bool) {
1833
+ return _isSchemeRegistered(_scheme);
1834
+ }
1835
+
1836
+ function getSchemeParameters(
1837
+ address _scheme,
1838
+ address _avatar
1839
+ ) external view isAvatarValid(_avatar) returns (bytes32) {
1840
+ return schemes[_scheme].paramsHash;
1841
+ }
1842
+
1843
+ function getSchemePermissions(
1844
+ address _scheme,
1845
+ address _avatar
1846
+ ) external view isAvatarValid(_avatar) returns (bytes4) {
1847
+ return schemes[_scheme].permissions;
1848
+ }
1849
+
1850
+ function getGlobalConstraintParameters(
1851
+ address _globalConstraint,
1852
+ address
1853
+ ) external view returns (bytes32) {
1854
+ GlobalConstraintRegister memory register = globalConstraintsRegisterPre[
1855
+ _globalConstraint
1856
+ ];
1857
+
1858
+ if (register.isRegistered) {
1859
+ return globalConstraintsPre[register.index].params;
1860
+ }
1861
+
1862
+ register = globalConstraintsRegisterPost[_globalConstraint];
1863
+
1864
+ if (register.isRegistered) {
1865
+ return globalConstraintsPost[register.index].params;
1866
+ }
1867
+ }
1868
+
1869
+ /**
1870
+ * @dev globalConstraintsCount return the global constraint pre and post count
1871
+ * @return uint256 globalConstraintsPre count.
1872
+ * @return uint256 globalConstraintsPost count.
1873
+ */
1874
+ function globalConstraintsCount(
1875
+ address _avatar
1876
+ ) external view isAvatarValid(_avatar) returns (uint, uint) {
1877
+ return (globalConstraintsPre.length, globalConstraintsPost.length);
1878
+ }
1879
+
1880
+ function isGlobalConstraintRegistered(
1881
+ address _globalConstraint,
1882
+ address _avatar
1883
+ ) external view isAvatarValid(_avatar) returns (bool) {
1884
+ return (globalConstraintsRegisterPre[_globalConstraint].isRegistered ||
1885
+ globalConstraintsRegisterPost[_globalConstraint].isRegistered);
1886
+ }
1887
+
1888
+ function _isSchemeRegistered(address _scheme) private view returns (bool) {
1889
+ return (schemes[_scheme].permissions & bytes4(0x00000001) != bytes4(0));
1890
+ }
1891
+ }