@gooddollar/goodprotocol 1.0.30-beta.2 → 1.0.31-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 (183) hide show
  1. package/artifacts/abis/DistributionHelper.min.json +1 -1
  2. package/artifacts/abis/DistributionHelperTest.min.json +1 -1
  3. package/artifacts/abis/DistributionHelperTestHelper.min.json +1 -1
  4. package/artifacts/abis/FuseStakingV3.min.json +1 -1
  5. package/artifacts/abis/GoodReserveCDai.min.json +1 -1
  6. package/artifacts/contracts/DAOStackInterfaces.sol/Avatar.dbg.json +1 -1
  7. package/artifacts/contracts/DAOStackInterfaces.sol/Controller.dbg.json +1 -1
  8. package/artifacts/contracts/DAOStackInterfaces.sol/GlobalConstraintInterface.dbg.json +1 -1
  9. package/artifacts/contracts/DAOStackInterfaces.sol/IntVoteInterface.dbg.json +1 -1
  10. package/artifacts/contracts/DAOStackInterfaces.sol/ReputationInterface.dbg.json +1 -1
  11. package/artifacts/contracts/DAOStackInterfaces.sol/SchemeRegistrar.dbg.json +1 -1
  12. package/artifacts/contracts/Interfaces.sol/AggregatorV3Interface.dbg.json +1 -1
  13. package/artifacts/contracts/Interfaces.sol/ERC20.dbg.json +1 -1
  14. package/artifacts/contracts/Interfaces.sol/IAaveIncentivesController.dbg.json +1 -1
  15. package/artifacts/contracts/Interfaces.sol/IAdminWallet.dbg.json +1 -1
  16. package/artifacts/contracts/Interfaces.sol/IDonationStaking.dbg.json +1 -1
  17. package/artifacts/contracts/Interfaces.sol/IERC2917.dbg.json +1 -1
  18. package/artifacts/contracts/Interfaces.sol/IFirstClaimPool.dbg.json +1 -1
  19. package/artifacts/contracts/Interfaces.sol/IGoodDollar.dbg.json +1 -1
  20. package/artifacts/contracts/Interfaces.sol/IGoodStaking.dbg.json +1 -1
  21. package/artifacts/contracts/Interfaces.sol/IHasRouter.dbg.json +1 -1
  22. package/artifacts/contracts/Interfaces.sol/IIdentity.dbg.json +1 -1
  23. package/artifacts/contracts/Interfaces.sol/ILendingPool.dbg.json +1 -1
  24. package/artifacts/contracts/Interfaces.sol/IMultichainRouter.dbg.json +1 -1
  25. package/artifacts/contracts/Interfaces.sol/INameService.dbg.json +1 -1
  26. package/artifacts/contracts/Interfaces.sol/IUBIScheme.dbg.json +1 -1
  27. package/artifacts/contracts/Interfaces.sol/ProxyAdmin.dbg.json +1 -1
  28. package/artifacts/contracts/Interfaces.sol/Reserve.dbg.json +1 -1
  29. package/artifacts/contracts/Interfaces.sol/Staking.dbg.json +1 -1
  30. package/artifacts/contracts/Interfaces.sol/Uniswap.dbg.json +1 -1
  31. package/artifacts/contracts/Interfaces.sol/UniswapFactory.dbg.json +1 -1
  32. package/artifacts/contracts/Interfaces.sol/UniswapPair.dbg.json +1 -1
  33. package/artifacts/contracts/Interfaces.sol/cERC20.dbg.json +1 -1
  34. package/artifacts/contracts/fuseFaucet/FuseFaucet.sol/FuseFaucet.dbg.json +1 -1
  35. package/artifacts/contracts/governance/ClaimersDistribution.sol/ClaimersDistribution.dbg.json +1 -1
  36. package/artifacts/contracts/governance/CompoundVotingMachine.sol/CompoundVotingMachine.dbg.json +1 -1
  37. package/artifacts/contracts/governance/GReputation.sol/GReputation.dbg.json +1 -1
  38. package/artifacts/contracts/governance/GoodDollarStaking.sol/GoodDollarStaking.dbg.json +1 -1
  39. package/artifacts/contracts/governance/GoodDollarStaking.sol/RewardsMinter.dbg.json +1 -1
  40. package/artifacts/contracts/governance/GovernanceStaking.sol/GovernanceStaking.dbg.json +1 -1
  41. package/artifacts/contracts/governance/MultiBaseGovernanceShareField.sol/MultiBaseGovernanceShareField.dbg.json +1 -1
  42. package/artifacts/contracts/governance/Reputation.sol/Reputation.dbg.json +1 -1
  43. package/artifacts/contracts/governance/StakersDistribution.sol/StakersDistribution.dbg.json +1 -1
  44. package/artifacts/contracts/governance/StakersDistribution.sol/StakersDistribution.json +2 -2
  45. package/artifacts/contracts/invite/InvitesV1.sol/InvitesV1.dbg.json +1 -1
  46. package/artifacts/contracts/mocks/AaveMock.sol/AaveMock.dbg.json +1 -1
  47. package/artifacts/contracts/mocks/DAIMock.sol/DAIMock.dbg.json +1 -1
  48. package/artifacts/contracts/mocks/DecimalsMock.sol/DecimalsMock.dbg.json +1 -1
  49. package/artifacts/contracts/mocks/DistributionBridgeMock.sol/DistributionBridgeMock.dbg.json +1 -1
  50. package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTest.dbg.json +1 -1
  51. package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTest.json +9 -2
  52. package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTestHelper.dbg.json +1 -1
  53. package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTestHelper.json +9 -2
  54. package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.dbg.json +1 -1
  55. package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.json +2 -2
  56. package/artifacts/contracts/mocks/GoodDollarStakingMock.sol/GoodDollarStakingMock.dbg.json +1 -1
  57. package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.dbg.json +1 -1
  58. package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.json +2 -2
  59. package/artifacts/contracts/mocks/IncentiveControllerMock.sol/IncentiveControllerMock.dbg.json +1 -1
  60. package/artifacts/contracts/mocks/LendingPoolMock.sol/LendingPoolMock.dbg.json +1 -1
  61. package/artifacts/contracts/mocks/MultichainRouterMock.sol/IWrapper.dbg.json +1 -1
  62. package/artifacts/contracts/mocks/MultichainRouterMock.sol/MultichainRouterMock.dbg.json +1 -1
  63. package/artifacts/contracts/mocks/OverMintTester.sol/IGoodDollarStakingTest.dbg.json +1 -1
  64. package/artifacts/contracts/mocks/OverMintTester.sol/OverMintTester.dbg.json +1 -1
  65. package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.dbg.json +1 -1
  66. package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.json +2 -2
  67. package/artifacts/contracts/mocks/SixteenDecimalsTokenMock.sol/SixteenDecimalsTokenMock.dbg.json +1 -1
  68. package/artifacts/contracts/mocks/StakingMockFixedAPY.sol/StakingMockFixedAPY.dbg.json +1 -1
  69. package/artifacts/contracts/mocks/SwapHelperTest.sol/SwapHelperTest.dbg.json +1 -1
  70. package/artifacts/contracts/mocks/TwentyDecimalsTokenMock.sol/TwentyDecimalsTokenMock.dbg.json +1 -1
  71. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock.dbg.json +1 -1
  72. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock2.dbg.json +1 -1
  73. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock3.dbg.json +1 -1
  74. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock4.dbg.json +1 -1
  75. package/artifacts/contracts/mocks/UsdcMock.sol/USDCMock.dbg.json +1 -1
  76. package/artifacts/contracts/mocks/cBATMock.sol/cBATMock.dbg.json +1 -1
  77. package/artifacts/contracts/mocks/cDAILowWorthMock.sol/cDAILowWorthMock.dbg.json +1 -1
  78. package/artifacts/contracts/mocks/cDAIMock.sol/cDAIMock.dbg.json +1 -1
  79. package/artifacts/contracts/mocks/cDAINonMintableMock.sol/cDAINonMintableMock.dbg.json +1 -1
  80. package/artifacts/contracts/mocks/cDecimalsMock.sol/cDecimalsMock.dbg.json +1 -1
  81. package/artifacts/contracts/mocks/cSDTMock.sol/cSDTMock.dbg.json +1 -1
  82. package/artifacts/contracts/mocks/cUSDCMock.sol/cUSDCMock.dbg.json +1 -1
  83. package/artifacts/contracts/reserve/DistributionHelper.sol/DistributionHelper.dbg.json +1 -1
  84. package/artifacts/contracts/reserve/DistributionHelper.sol/DistributionHelper.json +9 -2
  85. package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.dbg.json +1 -1
  86. package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.json +2 -2
  87. package/artifacts/contracts/reserve/GoodMarketMaker.sol/GoodMarketMaker.dbg.json +1 -1
  88. package/artifacts/contracts/reserve/GoodReserveCDai.sol/ContributionCalc.dbg.json +1 -1
  89. package/artifacts/contracts/reserve/GoodReserveCDai.sol/GoodReserveCDai.dbg.json +1 -1
  90. package/artifacts/contracts/reserve/GoodReserveCDai.sol/GoodReserveCDai.json +8 -2
  91. package/artifacts/contracts/staking/BaseShareField.sol/BaseShareField.dbg.json +1 -1
  92. package/artifacts/contracts/staking/BaseShareFieldV2.sol/BaseShareFieldV2.dbg.json +1 -1
  93. package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.dbg.json +1 -1
  94. package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.json +2 -2
  95. package/artifacts/contracts/staking/FuseStakingV3.sol/FuseStakingV3.dbg.json +1 -1
  96. package/artifacts/contracts/staking/FuseStakingV3.sol/FuseStakingV3.json +31 -83
  97. package/artifacts/contracts/staking/FuseStakingV3.sol/IConsensus.dbg.json +1 -1
  98. package/artifacts/contracts/staking/FuseStakingV3.sol/PegSwap.dbg.json +1 -1
  99. package/artifacts/contracts/staking/GoodFundManager.sol/GoodFundManager.dbg.json +1 -1
  100. package/artifacts/contracts/staking/GoodFundManager.sol/GoodFundManager.json +2 -2
  101. package/artifacts/contracts/staking/SimpleStaking.sol/SimpleStaking.dbg.json +1 -1
  102. package/artifacts/contracts/staking/SimpleStakingV2.sol/SimpleStakingV2.dbg.json +1 -1
  103. package/artifacts/contracts/staking/UniswapV2SwapHelper.sol/UniswapV2SwapHelper.dbg.json +1 -1
  104. package/artifacts/contracts/staking/aave/AaveStakingFactory.sol/AaveStakingFactory.dbg.json +1 -1
  105. package/artifacts/contracts/staking/aave/AaveStakingFactory.sol/AaveStakingFactory.json +2 -2
  106. package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.dbg.json +1 -1
  107. package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.json +2 -2
  108. package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.dbg.json +1 -1
  109. package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.json +2 -2
  110. package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.dbg.json +1 -1
  111. package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.json +2 -2
  112. package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.dbg.json +1 -1
  113. package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.json +2 -2
  114. package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.dbg.json +1 -1
  115. package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.json +2 -2
  116. package/artifacts/contracts/staking/utils/Math64X64.sol/Math64x64.dbg.json +1 -1
  117. package/artifacts/contracts/staking/utils/StakingRewardsFixedAPY.sol/StakingRewardsFixedAPY.dbg.json +1 -1
  118. package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.dbg.json +1 -1
  119. package/artifacts/contracts/utils/AdminWallet.sol/AdminWallet.dbg.json +1 -1
  120. package/artifacts/contracts/utils/BancorFormula.sol/BancorFormula.dbg.json +1 -1
  121. package/artifacts/contracts/utils/BulkProof.sol/BulkProof.dbg.json +1 -1
  122. package/artifacts/contracts/utils/BulkProof.sol/BulkProof.json +2 -2
  123. package/artifacts/contracts/utils/DAOContract.sol/DAOContract.dbg.json +1 -1
  124. package/artifacts/contracts/utils/DAOUpgradeableContract.sol/DAOUpgradeableContract.dbg.json +1 -1
  125. package/artifacts/contracts/utils/DSMath.sol/DSMath.dbg.json +1 -1
  126. package/artifacts/contracts/utils/DataTypes.sol/DataTypes.dbg.json +1 -1
  127. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/GoodDollarMintBurnWrapper.dbg.json +1 -1
  128. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/IRouter.dbg.json +1 -1
  129. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/PausableControl.dbg.json +1 -1
  130. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/TokenOperation.dbg.json +1 -1
  131. package/artifacts/contracts/utils/MultichainBridgeHelper.sol/MultichainBridgeHelper.dbg.json +1 -1
  132. package/artifacts/contracts/utils/NameService.sol/NameService.dbg.json +1 -1
  133. package/artifacts/contracts/utils/ProtocolUpgrade.sol/OldMarketMaker.dbg.json +1 -1
  134. package/artifacts/contracts/utils/ProtocolUpgrade.sol/ProtocolUpgrade.dbg.json +1 -1
  135. package/artifacts/contracts/utils/ProtocolUpgradeFuse.sol/ProtocolUpgradeFuse.dbg.json +1 -1
  136. package/artifacts/contracts/utils/ProtocolUpgradeFuseRecover.sol/ProtocolUpgradeFuseRecover.dbg.json +1 -1
  137. package/artifacts/contracts/utils/ProtocolUpgradeRecover.sol/ProtocolUpgradeRecover.dbg.json +1 -1
  138. package/artifacts/contracts/utils/ProxyFactory1967.sol/ERC1967Proxy.dbg.json +1 -1
  139. package/artifacts/contracts/utils/ProxyFactory1967.sol/ProxyFactory1967.dbg.json +1 -1
  140. package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.dbg.json +1 -1
  141. package/contracts/reserve/DistributionHelper.sol +4 -0
  142. package/contracts/reserve/GoodReserveCDai.sol +14 -4
  143. package/contracts/staking/FuseStakingV3.sol +42 -112
  144. package/contracts/staking/GoodFundManager.sol +2 -2
  145. package/hardhat.config.ts +31 -3
  146. package/package.json +10 -5
  147. package/releases/deployment.json +47 -5
  148. package/scripts/analytics/activeWalletsStats.ts +4 -0
  149. package/scripts/analytics/gdinflow.ts +3 -0
  150. package/scripts/analytics/p2pTxs.ts +582 -0
  151. package/scripts/analytics/tokenInOutStats.ts +3 -1
  152. package/scripts/deployGnosisSafe.ts +21 -21
  153. package/scripts/gdx/gdxAirdropCalculation.ts +1 -1
  154. package/scripts/multichain-deploy/helpers.ts +141 -5
  155. package/scripts/multichain-deploy/v3-fix.ts +120 -0
  156. package/scripts/multichain-deploy/v3-upgrade.ts +219 -0
  157. package/scripts/staking/stakersGdRewardsCalculation.ts +57 -46
  158. package/test/staking/FuseStaking.test.ts +2 -4
  159. package/test/staking/StakingRewards.test.ts +13 -16
  160. package/types/DistributionHelper.ts +27 -0
  161. package/types/DistributionHelperTest.ts +27 -0
  162. package/types/DistributionHelperTestHelper.ts +27 -0
  163. package/types/FuseStakingV3.ts +66 -208
  164. package/types/GoodReserveCDai.ts +12 -6
  165. package/types/factories/AaveStakingFactory__factory.ts +1 -1
  166. package/types/factories/CompoundStakingFactory__factory.ts +1 -1
  167. package/types/factories/DistributionHelperTestHelper__factory.ts +8 -1
  168. package/types/factories/DistributionHelperTest__factory.ts +8 -1
  169. package/types/factories/DistributionHelper__factory.ts +8 -1
  170. package/types/factories/DonationsStaking__factory.ts +1 -1
  171. package/types/factories/ExchangeHelper__factory.ts +1 -1
  172. package/types/factories/FuseStakingV3__factory.ts +30 -82
  173. package/types/factories/GoodAaveStakingV2__factory.ts +1 -1
  174. package/types/factories/GoodAaveStaking__factory.ts +1 -1
  175. package/types/factories/GoodCompoundStakingTest__factory.ts +1 -1
  176. package/types/factories/GoodCompoundStakingV2__factory.ts +1 -1
  177. package/types/factories/GoodCompoundStaking__factory.ts +1 -1
  178. package/types/factories/GoodFundManagerTest__factory.ts +1 -1
  179. package/types/factories/GoodFundManager__factory.ts +1 -1
  180. package/types/factories/GoodReserveCDai__factory.ts +7 -1
  181. package/types/factories/OverMintTesterRegularStake__factory.ts +1 -1
  182. package/types/factories/StakersDistribution__factory.ts +1 -1
  183. package/yarn.lock +1114 -550
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/d531f8943a500ebcacf5db6ea5235572.json"
3
+ "buildInfo": "../../../build-info/82edabb017e079b951c9a9557f562e2a.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/d531f8943a500ebcacf5db6ea5235572.json"
3
+ "buildInfo": "../../../build-info/82edabb017e079b951c9a9557f562e2a.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/d531f8943a500ebcacf5db6ea5235572.json"
3
+ "buildInfo": "../../../build-info/82edabb017e079b951c9a9557f562e2a.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/d531f8943a500ebcacf5db6ea5235572.json"
3
+ "buildInfo": "../../../build-info/82edabb017e079b951c9a9557f562e2a.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/d531f8943a500ebcacf5db6ea5235572.json"
3
+ "buildInfo": "../../../build-info/82edabb017e079b951c9a9557f562e2a.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/d531f8943a500ebcacf5db6ea5235572.json"
3
+ "buildInfo": "../../../build-info/82edabb017e079b951c9a9557f562e2a.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/d531f8943a500ebcacf5db6ea5235572.json"
3
+ "buildInfo": "../../../build-info/82edabb017e079b951c9a9557f562e2a.json"
4
4
  }
@@ -51,6 +51,10 @@ contract DistributionHelper is
51
51
  __AccessControlEnumerable_init();
52
52
  setDAO(_ns);
53
53
  _setupRole(DEFAULT_ADMIN_ROLE, avatar); //this needs to happen after setDAO for avatar to be non empty
54
+ updateAddresses();
55
+ }
56
+
57
+ function updateAddresses() public {
54
58
  fuseBridge = nameService.getAddress("BRIDGE_CONTRACT");
55
59
  multiChainBridge = IMultichainRouter(
56
60
  nameService.getAddress("MULTICHAIN_ROUTER")
@@ -115,7 +115,11 @@ contract GoodReserveCDai is
115
115
  address indexed receiverAddress
116
116
  );
117
117
 
118
- event NonUBIMinted(address distributionHelper, uint256 amountMinted);
118
+ event NonUBIMinted(
119
+ address distributionHelper,
120
+ uint256 amountMinted,
121
+ bool distributionSucceeded
122
+ );
119
123
 
120
124
  event DistributionHelperSet(address distributionHelper, uint32 bps);
121
125
 
@@ -288,7 +292,10 @@ contract GoodReserveCDai is
288
292
  tokenReturn >= _minReturn,
289
293
  "Token return must be above the minReturn"
290
294
  );
291
- cERC20(cDaiAddress).transfer(_target, tokenReturn);
295
+ require(
296
+ cERC20(cDaiAddress).transfer(_target, tokenReturn),
297
+ "cdai transfer failed"
298
+ );
292
299
 
293
300
  emit TokenSold(
294
301
  _seller,
@@ -386,8 +393,11 @@ contract GoodReserveCDai is
386
393
  nonUBI = (gdExpansionToMint * nonUbiBps) / 10000;
387
394
  gdUBI -= nonUBI;
388
395
  _mintGoodDollars(address(distributionHelper), nonUBI, false);
389
- try distributionHelper.onDistribution(nonUBI) {} catch {} //should not prevent mintUBI from completing
390
- emit NonUBIMinted(address(distributionHelper), nonUBI);
396
+ bool success = true;
397
+ try distributionHelper.onDistribution(nonUBI) {} catch {
398
+ success = false;
399
+ } //should not prevent mintUBI from completing
400
+ emit NonUBIMinted(address(distributionHelper), nonUBI, success);
391
401
  }
392
402
 
393
403
  //this enforces who can call the public mintUBI method. only an address with permissions at reserve of RESERVE_MINTER_ROLE
@@ -98,12 +98,27 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
98
98
  /**
99
99
  * @dev initialize
100
100
  */
101
- function initialize() public initializer {
101
+ function initialize(address _uniswap, address _gd) public initializer {
102
102
  __Ownable_init_unchained();
103
- consensus = IConsensus(
104
- address(0x3014ca10b91cb3D0AD85fEf7A3Cb95BCAc9c0f79)
105
- );
103
+ consensus = IConsensus(address(0x3014ca10b91cb3D0AD85fEf7A3Cb95BCAc9c0f79));
106
104
  validators.push(address(0xcb876A393F05a6677a8a029f1C6D7603B416C0A6));
105
+ stakeBackRatio = 33333; //%33
106
+ communityPoolRatio = 33333; //%33
107
+ maxSlippageRatio = 3000; //3%
108
+ keeperFeeRatio = 30; //0.03%
109
+ RATIO_BASE = 100000; //100%
110
+ uniswap = Uniswap(
111
+ _uniswap == address(0)
112
+ ? 0xE3F85aAd0c8DD7337427B9dF5d0fB741d65EEEB5
113
+ : _uniswap
114
+ );
115
+
116
+ GD = IGoodDollar(_gd);
117
+ uniswapFactory = UniswapFactory(uniswap.factory());
118
+ uniswapPair = UniswapPair(uniswapFactory.getPair(uniswap.WETH(), _gd));
119
+ pegSwap = PegSwap(0xdfE016328E7BcD6FA06614fE3AF3877E931F7e0a);
120
+ USDC = address(0x620fd5fa44BE6af63715Ef4E65DDFA0387aD13F5);
121
+ fUSD = address(0x249BE57637D8B013Ad64785404b24aeBaE9B098B);
107
122
  }
108
123
 
109
124
  modifier notPaused() {
@@ -116,79 +131,13 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
116
131
  _;
117
132
  }
118
133
 
119
- function upgrade0() external {
120
- if (RATIO_BASE == 0) {
121
- stakeBackRatio = 33333; //%33
122
- communityPoolRatio = 33333; //%33
123
- maxSlippageRatio = 3000; //3%
124
- keeperFeeRatio = 30; //0.03%
125
- RATIO_BASE = 100000; //100%
126
- }
127
- }
128
-
129
- function upgrade1(
130
- address _gd,
131
- address _ubischeme,
132
- address _uniswap
133
- ) external {
134
- if (address(uniswapPair) == address(0)) {
135
- uniswap = Uniswap(
136
- _uniswap == address(0)
137
- ? 0xFB76e9E7d88E308aB530330eD90e84a952570319
138
- : _uniswap
139
- );
140
- GD = IGoodDollar(_gd);
141
- ubischeme = UBIScheme(_ubischeme);
142
-
143
- uniswapFactory = UniswapFactory(uniswap.factory());
144
- uniswapPair = UniswapPair(
145
- uniswapFactory.getPair(uniswap.WETH(), _gd)
146
- );
147
- }
148
- }
149
-
150
- function upgrade2() external {
151
- if (USDC == address(0)) {
152
- USDC = address(0x620fd5fa44BE6af63715Ef4E65DDFA0387aD13F5);
153
- fUSD = address(0x249BE57637D8B013Ad64785404b24aeBaE9B098B);
154
- }
155
- }
156
-
157
- function upgrade3() external {
158
- if (guardian == address(0)) {
159
- paused = true;
160
- guardian = address(0x5128E3C1f8846724cc1007Af9b4189713922E4BB);
161
- }
162
- }
163
-
164
- function upgrade4() external {
165
- if (address(pegSwap) == address(0)) {
166
- pegSwap = PegSwap(0xdfE016328E7BcD6FA06614fE3AF3877E931F7e0a);
167
- paused = false;
168
- }
169
- }
170
-
171
- function upgrade5() external {
134
+ function approve() external {
172
135
  cERC20(fUSD).approve(address(pegSwap), type(uint256).max);
173
136
  cERC20(USDC).approve(address(uniswap), type(uint256).max);
174
137
  }
175
138
 
176
- function upgrade6() external {
177
- //switch to voltage
178
- uniswap = Uniswap(0xE3F85aAd0c8DD7337427B9dF5d0fB741d65EEEB5);
179
- uniswapFactory = UniswapFactory(uniswap.factory());
180
- uniswapPair = UniswapPair(
181
- uniswapFactory.getPair(uniswap.WETH(), address(GD))
182
- );
183
- }
184
-
185
- function setContracts(address _gd, address _ubischeme) public onlyOwner {
186
- if (_gd != address(0)) {
187
- GD = IGoodDollar(_gd);
188
- }
189
- if (_ubischeme != address(0)) {
190
- ubischeme = UBIScheme(_ubischeme);
191
- }
139
+ function setUBIScheme(address _ubischeme) public onlyOwner {
140
+ ubischeme = UBIScheme(_ubischeme);
192
141
  }
193
142
 
194
143
  function stake() public payable returns (bool) {
@@ -230,17 +179,15 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
230
179
 
231
180
  function withdrawAll() public onlyGuardian {
232
181
  for (uint256 i = 0; i < validators.length; i++) {
233
- uint256 cur = consensus.delegatedAmount(
234
- address(this),
235
- validators[i]
236
- );
182
+ uint256 cur = consensus.delegatedAmount(address(this), validators[i]);
237
183
  if (cur == 0) continue;
238
184
  undelegateWithCatch(validators[i], cur);
239
185
  }
240
186
  uint256 effectiveBalance = balance(); //use only undelegated funds
241
187
  pendingFuseEarnings = 0;
242
188
  if (effectiveBalance > 0) {
243
- msg.sender.call{ value: effectiveBalance }("");
189
+ (bool ok, ) = msg.sender.call{ value: effectiveBalance }("");
190
+ require(ok, "transfer failed");
244
191
  }
245
192
  }
246
193
 
@@ -254,10 +201,7 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
254
201
  );
255
202
  uint256 perValidator = _value.div(validators.length);
256
203
  for (uint256 i = 0; i < validators.length; i++) {
257
- uint256 cur = consensus.delegatedAmount(
258
- address(this),
259
- validators[i]
260
- );
204
+ uint256 cur = consensus.delegatedAmount(address(this), validators[i]);
261
205
  if (cur == 0) continue;
262
206
  if (cur <= perValidator) {
263
207
  undelegateWithCatch(validators[i], cur);
@@ -296,10 +240,7 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
296
240
  uint256 perValidator = (totalDelegated() + _value) / validators.length;
297
241
  uint256 left = _value;
298
242
  for (uint256 i = 0; i < validators.length && left > 0; i++) {
299
- uint256 cur = consensus.delegatedAmount(
300
- address(this),
301
- validators[i]
302
- );
243
+ uint256 cur = consensus.delegatedAmount(address(this), validators[i]);
303
244
 
304
245
  if (cur < perValidator) {
305
246
  uint256 toDelegate = perValidator.sub(cur);
@@ -319,20 +260,14 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
319
260
  function totalDelegated() public view returns (uint256) {
320
261
  uint256 total = 0;
321
262
  for (uint256 i = 0; i < validators.length; i++) {
322
- uint256 cur = consensus.delegatedAmount(
323
- address(this),
324
- validators[i]
325
- );
263
+ uint256 cur = consensus.delegatedAmount(address(this), validators[i]);
326
264
  total += cur;
327
265
  }
328
266
  return total;
329
267
  }
330
268
 
331
269
  function removeValidator(address _validator) public onlyOwner {
332
- uint256 delegated = consensus.delegatedAmount(
333
- address(this),
334
- _validator
335
- );
270
+ uint256 delegated = consensus.delegatedAmount(address(this), _validator);
336
271
  if (delegated > 0) {
337
272
  uint256 prevBalance = balance();
338
273
  undelegateWithCatch(_validator, delegated);
@@ -356,18 +291,13 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
356
291
 
357
292
  function collectUBIInterest() public notPaused {
358
293
  uint256 curDay = ubischeme.currentDay();
359
- require(
360
- curDay != lastDayCollected,
361
- "can collect only once in a ubi cycle"
362
- );
294
+ require(curDay != lastDayCollected, "can collect only once in a ubi cycle");
363
295
 
364
296
  uint256 earnings = balance() - pendingFuseEarnings;
365
297
  require(pendingFuseEarnings + earnings > 0, "no earnings to collect");
366
298
 
367
299
  lastDayCollected = curDay;
368
- uint256 fuseUBI = earnings.mul(RATIO_BASE - stakeBackRatio).div(
369
- RATIO_BASE
370
- );
300
+ uint256 fuseUBI = earnings.mul(RATIO_BASE - stakeBackRatio).div(RATIO_BASE);
371
301
  uint256 stakeBack = earnings - fuseUBI;
372
302
 
373
303
  uint256[] memory fuseswapResult = _buyGD(fuseUBI + pendingFuseEarnings); //buy GD with X% of earnings
@@ -378,9 +308,9 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
378
308
  uint256 keeperFee = gdBought.mul(keeperFeeRatio).div(RATIO_BASE);
379
309
  if (keeperFee > 0) GD.transfer(msg.sender, keeperFee);
380
310
  gdBought -= keeperFee;
381
- uint256 communityPoolContribution = gdBought
382
- .mul(communityPoolRatio)
383
- .div(RATIO_BASE); //subtract fee // * ommunityPoolRatio // = G$ after fee * communityPoolRatio%
311
+ uint256 communityPoolContribution = gdBought.mul(communityPoolRatio).div(
312
+ RATIO_BASE
313
+ ); //subtract fee // * ommunityPoolRatio // = G$ after fee * communityPoolRatio%
384
314
 
385
315
  uint256 ubiAfterFeeAndPool = gdBought.sub(communityPoolContribution);
386
316
 
@@ -407,13 +337,10 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
407
337
  function _buyGD(uint256 _value) internal returns (uint256[] memory) {
408
338
  //buy from uniwasp
409
339
  require(_value > 0, "buy value should be > 0");
410
- (uint256 maxFuse, uint256 fuseGDOut) = calcMaxFuseWithPriceImpact(
340
+ (uint256 maxFuse, uint256 fuseGDOut) = calcMaxFuseWithPriceImpact(_value);
341
+ (uint256 maxFuseUSDC, uint256 usdcGDOut) = calcMaxFuseUSDCWithPriceImpact(
411
342
  _value
412
343
  );
413
- (
414
- uint256 maxFuseUSDC,
415
- uint256 usdcGDOut
416
- ) = calcMaxFuseUSDCWithPriceImpact(_value);
417
344
  address[] memory path;
418
345
  if (maxFuse >= maxFuseUSDC) {
419
346
  path = new address[](2);
@@ -471,9 +398,12 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
471
398
  address[] memory path = new address[](2);
472
399
  path[1] = fUSD;
473
400
  path[0] = uniswap.WETH();
474
- uint256[] memory result = uniswap.swapExactETHForTokens{
475
- value: maxFuse
476
- }((tokenOut * 95) / 100, path, address(this), block.timestamp);
401
+ uint256[] memory result = uniswap.swapExactETHForTokens{ value: maxFuse }(
402
+ (tokenOut * 95) / 100,
403
+ path,
404
+ address(this),
405
+ block.timestamp
406
+ );
477
407
 
478
408
  pegSwap.swap(result[1], fUSD, USDC);
479
409
  usedFuse = result[0];
@@ -194,10 +194,10 @@ contract GoodFundManager is DAOUpgradeableContract, DSMath {
194
194
  }
195
195
  }
196
196
 
197
- if (exist && (_isBlackListed || _rewardsPerBlock == 0)) {
197
+ if (exist && _isBlackListed) {
198
198
  activeContracts[i] = activeContracts[activeContracts.length - 1];
199
199
  activeContracts.pop();
200
- } else if (!exist && !(_isBlackListed || _rewardsPerBlock == 0)) {
200
+ } else if (!exist && !_isBlackListed) {
201
201
  activeContracts.push(_stakingAddress);
202
202
  }
203
203
  emit StakingRewardSet(
package/hardhat.config.ts CHANGED
@@ -24,7 +24,9 @@ import { ethers } from "ethers";
24
24
  import { fstat, readFileSync, writeFileSync } from "fs";
25
25
  config();
26
26
 
27
- const mnemonic = process.env.MNEMONIC;
27
+ const mnemonic =
28
+ process.env.MNEMONIC ||
29
+ "test test test test test test test test test test test junk";
28
30
  const deployerPrivateKey =
29
31
  process.env.PRIVATE_KEY || ethers.utils.hexZeroPad("0x11", 32);
30
32
  const infura_api = process.env.INFURA_API;
@@ -74,12 +76,17 @@ const hhconfig: HardhatUserConfig = {
74
76
 
75
77
  networks: {
76
78
  hardhat: {
77
- chainId: 4447,
79
+ chainId: process.env.FORK_CHAIN_ID
80
+ ? Number(process.env.FORK_CHAIN_ID)
81
+ : 4447,
78
82
  allowUnlimitedContractSize: true,
79
83
  accounts: {
80
84
  accountsBalance: "10000000000000000000000000"
81
85
  },
82
- initialDate: "2021-12-01" //required for DAO tests like guardian
86
+ initialDate: "2021-12-01", //required for DAO tests like guardian
87
+ forking: process.env.FORK_CHAIN_ID && {
88
+ url: "https://eth-mainnet.alchemyapi.io/v2/" + process.env.ALCHEMY_KEY
89
+ }
83
90
  },
84
91
  test: {
85
92
  allowUnlimitedContractSize: true,
@@ -193,6 +200,27 @@ const hhconfig: HardhatUserConfig = {
193
200
  gas: 3000000,
194
201
  gasPrice: 500000000,
195
202
  chainId: 42220
203
+ },
204
+ "staging-celo": {
205
+ accounts: { mnemonic },
206
+ url: "https://forno.celo.org",
207
+ gas: 3000000,
208
+ gasPrice: 150000000,
209
+ chainId: 42220
210
+ },
211
+ "development-celo": {
212
+ accounts: { mnemonic },
213
+ url: "https://forno.celo.org",
214
+ gas: 3000000,
215
+ gasPrice: 150000000,
216
+ chainId: 42220
217
+ },
218
+ gnosis: {
219
+ accounts: [deployerPrivateKey],
220
+ url: "https://rpc.gnosischain.com",
221
+ gas: 3000000,
222
+ gasPrice: 500000000,
223
+ chainId: 100
196
224
  }
197
225
  },
198
226
  mocha: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gooddollar/goodprotocol",
3
- "version": "1.0.30-beta.2",
3
+ "version": "1.0.31-beta.0",
4
4
  "description": "GoodDollar Protocol",
5
5
  "scripts": {
6
6
  "build": "scripts/build.sh deploy",
@@ -61,7 +61,6 @@
61
61
  "@openzeppelin/contracts-upgradeable": "^4.3.2",
62
62
  "@typechain/hardhat": "^6.1.2",
63
63
  "async-promise-pool": "^1.0.4",
64
- "ethers-multicall": "^0.2.1",
65
64
  "openzeppelin-solidity": "^4.3.2",
66
65
  "patch-package": "latest",
67
66
  "press-any-key": "^0.1.1",
@@ -73,7 +72,12 @@
73
72
  "@babel/polyfill": "*",
74
73
  "@babel/preset-env": "*",
75
74
  "@babel/register": "*",
76
- "@nomiclabs/hardhat-ethers": "^2.1.1",
75
+ "@gnosis.pm/safe-core-sdk": "^3.2.0",
76
+ "@gnosis.pm/safe-core-sdk-types": "^1.7.0",
77
+ "@gnosis.pm/safe-ethers-lib": "^1.7.0",
78
+ "@gnosis.pm/safe-service-client": "^1.4.0",
79
+ "@nomicfoundation/hardhat-network-helpers": "^1.0.6",
80
+ "@nomiclabs/hardhat-ethers": "^2.2.1",
77
81
  "@nomiclabs/hardhat-etherscan": "^3.1.0",
78
82
  "@nomiclabs/hardhat-waffle": "^2.0.3",
79
83
  "@openzeppelin/hardhat-upgrades": "^1.20.0",
@@ -89,8 +93,9 @@
89
93
  "chai": "*",
90
94
  "coveralls": "*",
91
95
  "dotenv": "*",
92
- "ethereum-waffle": "*",
93
- "ethers": "^5.4.7",
96
+ "ethereum-waffle": "^3.4.4",
97
+ "ethers": "^5.7.2",
98
+ "ethers-multicall": "^0.2.3",
94
99
  "ethers-eip712": "*",
95
100
  "fs-extra": "9.0.0",
96
101
  "graphql": "^15.5.0",
@@ -521,8 +521,9 @@
521
521
  ]
522
522
  ],
523
523
  "MultichainRouter": "0x765277eebeca2e31912c9946eae1021199b39c61",
524
- "anyGoodDollar": "0xd17652350cfd2a37ba2f947c910987a3b1a1c60d",
525
- "GuardiansSafe": "0x84c10b45fe51bfb4f86c19a47fdbc187d4572fb8"
524
+ "AnyGoodDollar": "0xd17652350cfd2a37ba2f947c910987a3b1a1c60d",
525
+ "GuardiansSafe": "0xE0c5daa7CC6F88d29505f702a53bb5E67600e7Ec",
526
+ "DistributionHelper": "0xAcadA0C9795fdBb6921AE96c4D7Db2F8B8c52Fd0"
526
527
  },
527
528
  "production": {
528
529
  "NameService": "0xec6dcE387B1616a0c44fF2E4fA9E90E53Cf14eb0",
@@ -549,7 +550,7 @@
549
550
  "ProxyAdmin": "0x57179b2A8eB019157b0C3E761cdB26c82C982a3B",
550
551
  "FuseFaucet": "0x01ab5966C1d742Ae0CFF7f14cC0F4D85156e83d9",
551
552
  "FuseStaking": "0xA199F0C353E25AdF022378B0c208D600f39a6505",
552
- "GuardiansSafe": "0x84c10b45fe51bfb4f86c19a47fdbc187d4572fb8"
553
+ "GuardiansSafe": "0x5878123fe880881f1Ecc92D5fd31e5D3F5Fba2e9"
553
554
  },
554
555
  "production-celo": {
555
556
  "ProxyFactory": "0x99C22e78A579e2176311c736C4c9F0b0D5A47806",
@@ -560,13 +561,54 @@
560
561
  "NameService": "0x563a80a452264a9e1aa37c6FA0B46D04C3c71b24",
561
562
  "GReputation": "0xAC132ECe25217867E318eA8ff63420C90d5a74A6",
562
563
  "GuardiansSafeOld": "0xC9D09BA972B4EB6Bb7347F2229FB6d50434fFCa6",
563
- "GuardiansSafe": "0x84c10b45fe51bfb4f86c19a47fdbc187d4572fb8",
564
+ "GuardiansSafe": "0xa2521e8F5A990903fdD8Afa6570C52526e7E0D5E",
564
565
  "network": "production-celo",
565
566
  "networkId": 42220,
566
567
  "GoodDollarMintBurnWrapper": "0x5566b6E4962BA83e05a426Ad89031ec18e9CadD3",
567
568
  "MultichainRouter": "0xf27Ee99622C3C9b264583dACB2cCE056e194494f"
568
569
  },
569
- "localhost": {
570
+ "development-celo": {
571
+ "ProxyFactory": "0xA441cd89b0964B51d23201d65E037DA7aF8F74E9",
572
+ "GoodDollar": "0xAB89A70d1Af04ED8badf915Ba1f5b28E9F322624",
573
+ "Avatar": "0xE0e3BFb1A1850bdFe36ED1563CC2abB6A8B6De78",
574
+ "Controller": "0x6717A1948328C8eCCb5C933Fae90e0631C2486fE",
575
+ "Identity": "0xec97ee6d70C626044224998192B96fEF05949De1",
576
+ "NameService": "0x266E5a0931E52229CC241376bC701Ab6199Aec4D",
577
+ "GReputation": "0x6614823763EAd52aCc4952b9634624439B738683",
578
+ "AdminWallet": "0xb7b543bfd9e2E0AD1d0aA68f56c883Dd377E3D24",
579
+ "Faucet": "0x256AFcfEcB5C7f62CE46b54492Bb8ac38163672f",
580
+ "Invites": "0xdC8F0da3f29A3C419a8EEf36665ba2a3EF737B8f",
581
+ "GoodDollarMintBurnWrapper": "0x3fa553a5a044D5c4f5C70878148568410305f953",
582
+ "UBIScheme": "0x2d42e6220af2485d1e6E5B4d3661A74671AA9a79",
583
+ "ClaimersDistribution": "0x80018e6Dd79f6B892Fca6b592746136a3aa5ef6d",
584
+ "CompoundVotingMachine": "0x00e44d746F3931cAB775099F4C6451f893BB9378",
585
+ "network": "development-celo",
586
+ "networkId": 42220,
587
+ "GoodDollarStaking": "0x0b13807334C1618D71E5FCe792f40A22007c433A"
588
+ },
589
+ "staging-celo": {
590
+ "ProxyFactory": "0x7e8292481EA8EbEb49e486B7e99c00C50fBa2689",
591
+ "GoodDollar": "0x33265D74abd5ae87cA02A4Fb0C30B7405C8b0682",
592
+ "Avatar": "0x2FD18f9de3F581Ca492A485D2b32E361EeAE2e63",
593
+ "Controller": "0xa229BdD05436362484b10586dAa79a316e3080C5",
594
+ "Identity": "0xc82d50c667F389906aCA4B72D577fA56Bf7F8910",
595
+ "NameService": "0x8d0b621796445454180e7DD25f96B1782848338B",
596
+ "GReputation": "0x759a03326df90b740f6b8b6D31e12a3F95D64C28",
597
+ "FeeFormula": "0xcf08461E5bAd9C508D482329Eae0f1b4c4D4c489",
598
+ "DAOCreator": "0xA614d2641c21FEa4c73A2D6e71C6ad341349808B",
599
+ "AddFounders": "0x558fA360988601601ac410678963Bf785156076D",
600
+ "AdminWallet": "0x822590F8baf606b1e18dC1FA8Ca39D5C66C20981",
601
+ "Faucet": "0x9803B5811260Bfd1F5b0b0c9eC9aD4bF96D7ea94",
602
+ "Invites": "0x4E094c2e35e57c90667AbD6D8FE25CE63F4ae00B",
603
+ "GoodDollarMintBurnWrapper": "0x156Fd9563973EFB94a297B76CFac32CdC92a8d1A",
604
+ "UBIScheme": "0x04f2Cf8865e2ddfEf0047FdfA7A1b05ade614288",
605
+ "ClaimersDistribution": "0x83186CE77ef296BA6561096447938AE05D1F026e",
606
+ "CompoundVotingMachine": "0xEdde78b850a08B6b8AB3E84f61cD6dC70Cc7f156",
607
+ "network": "staging-celo",
608
+ "networkId": 42220,
609
+ "GoodDollarStaking": "0x1eF9D3Ed46D4B82E7e8089BDdd00a493e9930f46"
610
+ },
611
+ "gnosis": {
570
612
  "GuardiansSafe": "0x84c10b45fe51bfb4f86c19a47fdbc187d4572fb8"
571
613
  }
572
614
  }
@@ -4,6 +4,10 @@ import PromisePool from "async-promise-pool";
4
4
  import fs from "fs";
5
5
  import { ethers } from "hardhat";
6
6
 
7
+ /****
8
+ * Fetch token holders and their last activity date
9
+ * can be used to create stats about active users and how much G$ isnt active
10
+ */
7
11
  const main = async () => {
8
12
  let result = [];
9
13
  let balances = {};
@@ -5,6 +5,9 @@ import fs from "fs";
5
5
  import { ethers } from "hardhat";
6
6
  import { keccak256 } from "web3-utils";
7
7
 
8
+ /***
9
+ * fetch all income to certain accounts
10
+ */
8
11
  const main = async () => {
9
12
  const uniques = {};
10
13
  let addresses = [];