@gooddollar/goodprotocol 2.0.16 → 2.0.18

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 (196) hide show
  1. package/artifacts/abis/BuyGDCloneFactory.min.json +1 -1
  2. package/artifacts/abis/DonateGDClone.min.json +1 -0
  3. package/artifacts/abis/ISuperToken.min.json +1 -1
  4. package/artifacts/abis/SuperGoodDollar.min.json +1 -1
  5. package/artifacts/abis/SuperToken.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/IIdentityV2.dbg.json +1 -1
  24. package/artifacts/contracts/Interfaces.sol/ILendingPool.dbg.json +1 -1
  25. package/artifacts/contracts/Interfaces.sol/IMultichainRouter.dbg.json +1 -1
  26. package/artifacts/contracts/Interfaces.sol/INameService.dbg.json +1 -1
  27. package/artifacts/contracts/Interfaces.sol/IUBIScheme.dbg.json +1 -1
  28. package/artifacts/contracts/Interfaces.sol/ProxyAdmin.dbg.json +1 -1
  29. package/artifacts/contracts/Interfaces.sol/Reserve.dbg.json +1 -1
  30. package/artifacts/contracts/Interfaces.sol/Staking.dbg.json +1 -1
  31. package/artifacts/contracts/Interfaces.sol/Uniswap.dbg.json +1 -1
  32. package/artifacts/contracts/Interfaces.sol/UniswapFactory.dbg.json +1 -1
  33. package/artifacts/contracts/Interfaces.sol/UniswapPair.dbg.json +1 -1
  34. package/artifacts/contracts/Interfaces.sol/cERC20.dbg.json +1 -1
  35. package/artifacts/contracts/fuseFaucet/Faucet.sol/Faucet.dbg.json +1 -1
  36. package/artifacts/contracts/fuseFaucet/FuseFaucet.sol/FuseFaucet.dbg.json +1 -1
  37. package/artifacts/contracts/fuseFaucet/FuseFaucetV2.sol/FuseFaucetV2.dbg.json +1 -1
  38. package/artifacts/contracts/governance/ClaimersDistribution.sol/ClaimersDistribution.dbg.json +1 -1
  39. package/artifacts/contracts/governance/CompoundVotingMachine.sol/CompoundVotingMachine.dbg.json +1 -1
  40. package/artifacts/contracts/governance/GReputation.sol/GReputation.dbg.json +1 -1
  41. package/artifacts/contracts/governance/GoodDollarStaking.sol/GoodDollarStaking.dbg.json +1 -1
  42. package/artifacts/contracts/governance/GoodDollarStaking.sol/IGovernanceStaking.dbg.json +1 -1
  43. package/artifacts/contracts/governance/GoodDollarStaking.sol/IStakingUpgrade.dbg.json +1 -1
  44. package/artifacts/contracts/governance/GoodDollarStaking.sol/RewardsMinter.dbg.json +1 -1
  45. package/artifacts/contracts/governance/GovernanceStaking.sol/GovernanceStaking.dbg.json +1 -1
  46. package/artifacts/contracts/governance/MultiBaseGovernanceShareField.sol/MultiBaseGovernanceShareField.dbg.json +1 -1
  47. package/artifacts/contracts/governance/Reputation.sol/Reputation.dbg.json +1 -1
  48. package/artifacts/contracts/governance/StakersDistribution.sol/StakersDistribution.dbg.json +1 -1
  49. package/artifacts/contracts/identity/IdentityV2.sol/IdentityV2.dbg.json +1 -1
  50. package/artifacts/contracts/invite/InvitesFuseV2.sol/InvitesFuseV2.dbg.json +1 -1
  51. package/artifacts/contracts/invite/InvitesV1.sol/InvitesV1.dbg.json +1 -1
  52. package/artifacts/contracts/invite/InvitesV2.sol/InvitesV2.dbg.json +1 -1
  53. package/artifacts/contracts/mocks/AaveMock.sol/AaveMock.dbg.json +1 -1
  54. package/artifacts/contracts/mocks/AaveUSDMockOracle.sol/AaveUSDMockOracle.dbg.json +1 -1
  55. package/artifacts/contracts/mocks/BatUSDMockOracle.sol/BatUSDMockOracle.dbg.json +1 -1
  56. package/artifacts/contracts/mocks/CompUsdMockOracle.sol/CompUSDMockOracle.dbg.json +1 -1
  57. package/artifacts/contracts/mocks/DAIMock.sol/DAIMock.dbg.json +1 -1
  58. package/artifacts/contracts/mocks/DaiEthPriceMockOracle.sol/DaiEthPriceMockOracle.dbg.json +1 -1
  59. package/artifacts/contracts/mocks/DecimalsMock.sol/DecimalsMock.dbg.json +1 -1
  60. package/artifacts/contracts/mocks/DistributionBridgeMock.sol/DistributionBridgeMock.dbg.json +1 -1
  61. package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTest.dbg.json +1 -1
  62. package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTestHelper.dbg.json +1 -1
  63. package/artifacts/contracts/mocks/EthUSDMockOracle.sol/EthUSDMockOracle.dbg.json +1 -1
  64. package/artifacts/contracts/mocks/FeesFormularMock.sol/FeesFormulaMock.dbg.json +1 -1
  65. package/artifacts/contracts/mocks/GasPriceMockOracle.sol/GasPriceMockOracle.dbg.json +1 -1
  66. package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.dbg.json +1 -1
  67. package/artifacts/contracts/mocks/GoodDollarStakingMock.sol/GoodDollarStakingMock.dbg.json +1 -1
  68. package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.dbg.json +1 -1
  69. package/artifacts/contracts/mocks/IdentityMock.sol/IdentityMock.dbg.json +1 -1
  70. package/artifacts/contracts/mocks/IncentiveControllerMock.sol/IncentiveControllerMock.dbg.json +1 -1
  71. package/artifacts/contracts/mocks/LendingPoolMock.sol/LendingPoolMock.dbg.json +1 -1
  72. package/artifacts/contracts/mocks/MultichainRouterMock.sol/IWrapper.dbg.json +1 -1
  73. package/artifacts/contracts/mocks/MultichainRouterMock.sol/MultichainRouterMock.dbg.json +1 -1
  74. package/artifacts/contracts/mocks/OverMintTester.sol/IGoodDollarStakingTest.dbg.json +1 -1
  75. package/artifacts/contracts/mocks/OverMintTester.sol/OverMintTester.dbg.json +1 -1
  76. package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.dbg.json +1 -1
  77. package/artifacts/contracts/mocks/PayableMock.sol/PayableMock.dbg.json +1 -1
  78. package/artifacts/contracts/mocks/SixteenDecimalsTokenMock.sol/SixteenDecimalsTokenMock.dbg.json +1 -1
  79. package/artifacts/contracts/mocks/StakingMockFixedAPY.sol/StakingMockFixedAPY.dbg.json +1 -1
  80. package/artifacts/contracts/mocks/SwapHelperTest.sol/SwapHelperTest.dbg.json +1 -1
  81. package/artifacts/contracts/mocks/TwentyDecimalsTokenMock.sol/TwentyDecimalsTokenMock.dbg.json +1 -1
  82. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock.dbg.json +1 -1
  83. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock2.dbg.json +1 -1
  84. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock3.dbg.json +1 -1
  85. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock4.dbg.json +1 -1
  86. package/artifacts/contracts/mocks/UsdcMock.sol/USDCMock.dbg.json +1 -1
  87. package/artifacts/contracts/mocks/cBATMock.sol/cBATMock.dbg.json +1 -1
  88. package/artifacts/contracts/mocks/cDAILowWorthMock.sol/cDAILowWorthMock.dbg.json +1 -1
  89. package/artifacts/contracts/mocks/cDAIMock.sol/cDAIMock.dbg.json +1 -1
  90. package/artifacts/contracts/mocks/cDAINonMintableMock.sol/cDAINonMintableMock.dbg.json +1 -1
  91. package/artifacts/contracts/mocks/cDecimalsMock.sol/cDecimalsMock.dbg.json +1 -1
  92. package/artifacts/contracts/mocks/cSDTMock.sol/cSDTMock.dbg.json +1 -1
  93. package/artifacts/contracts/mocks/cUSDCMock.sol/cUSDCMock.dbg.json +1 -1
  94. package/artifacts/contracts/reserve/DistributionHelper.sol/DistributionHelper.dbg.json +1 -1
  95. package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.dbg.json +1 -1
  96. package/artifacts/contracts/reserve/GoodMarketMaker.sol/GoodMarketMaker.dbg.json +1 -1
  97. package/artifacts/contracts/reserve/GoodReserveCDai.sol/ContributionCalc.dbg.json +1 -1
  98. package/artifacts/contracts/reserve/GoodReserveCDai.sol/GoodReserveCDai.dbg.json +1 -1
  99. package/artifacts/contracts/staking/BaseShareField.sol/BaseShareField.dbg.json +1 -1
  100. package/artifacts/contracts/staking/BaseShareFieldV2.sol/BaseShareFieldV2.dbg.json +1 -1
  101. package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.dbg.json +1 -1
  102. package/artifacts/contracts/staking/FuseStakingV3.sol/FuseStakingV3.dbg.json +1 -1
  103. package/artifacts/contracts/staking/FuseStakingV3.sol/IConsensus.dbg.json +1 -1
  104. package/artifacts/contracts/staking/FuseStakingV3.sol/PegSwap.dbg.json +1 -1
  105. package/artifacts/contracts/staking/GoodFundManager.sol/GoodFundManager.dbg.json +1 -1
  106. package/artifacts/contracts/staking/SimpleStaking.sol/SimpleStaking.dbg.json +1 -1
  107. package/artifacts/contracts/staking/SimpleStakingV2.sol/SimpleStakingV2.dbg.json +1 -1
  108. package/artifacts/contracts/staking/UniswapV2SwapHelper.sol/UniswapV2SwapHelper.dbg.json +1 -1
  109. package/artifacts/contracts/staking/aave/AaveStakingFactory.sol/AaveStakingFactory.dbg.json +1 -1
  110. package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.dbg.json +1 -1
  111. package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.dbg.json +1 -1
  112. package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.dbg.json +1 -1
  113. package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.dbg.json +1 -1
  114. package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.dbg.json +1 -1
  115. package/artifacts/contracts/staking/utils/Math64X64.sol/Math64x64.dbg.json +1 -1
  116. package/artifacts/contracts/staking/utils/StakingRewardsFixedAPY.sol/StakingRewardsFixedAPY.dbg.json +1 -1
  117. package/artifacts/contracts/token/ERC20PresetMinterPauserUpgradeable.sol/ERC20PresetMinterPauserUpgradeable.dbg.json +1 -1
  118. package/artifacts/contracts/token/ERC677.sol/ERC677.dbg.json +1 -1
  119. package/artifacts/contracts/token/ERC677.sol/ERC677Receiver.dbg.json +1 -1
  120. package/artifacts/contracts/token/GoodDollar.sol/GoodDollar.dbg.json +1 -1
  121. package/artifacts/contracts/token/IFeesFormula.sol/IFeesFormula.dbg.json +1 -1
  122. package/artifacts/contracts/token/MultichainFeeFormula.sol/MultichainFeeFormula.dbg.json +1 -1
  123. package/artifacts/contracts/token/superfluid/ERC20Permit.sol/ERC20Permit.dbg.json +1 -1
  124. package/artifacts/contracts/token/superfluid/ERC20Permit.sol/SelfApprove.dbg.json +1 -1
  125. package/artifacts/contracts/token/superfluid/ISuperGoodDollar.sol/IGoodDollarCustom.dbg.json +1 -1
  126. package/artifacts/contracts/token/superfluid/ISuperGoodDollar.sol/ISuperGoodDollar.dbg.json +1 -1
  127. package/artifacts/contracts/token/superfluid/ISuperToken.sol/ISuperToken.dbg.json +1 -1
  128. package/artifacts/contracts/token/superfluid/ISuperToken.sol/ISuperToken.json +26 -26
  129. package/artifacts/contracts/token/superfluid/SuperGoodDollar.sol/SuperGoodDollar.dbg.json +1 -1
  130. package/artifacts/contracts/token/superfluid/SuperGoodDollar.sol/SuperGoodDollar.json +41 -28
  131. package/artifacts/contracts/token/superfluid/SuperToken.sol/SuperToken.dbg.json +1 -1
  132. package/artifacts/contracts/token/superfluid/SuperToken.sol/SuperToken.json +28 -28
  133. package/artifacts/contracts/token/superfluid/SuperfluidToken.sol/SuperfluidToken.dbg.json +1 -1
  134. package/artifacts/contracts/token/superfluid/UUPSProxiable.sol/UUPSProxiable.dbg.json +1 -1
  135. package/artifacts/contracts/token/superfluid/UUPSProxy.sol/Proxy.dbg.json +1 -1
  136. package/artifacts/contracts/token/superfluid/UUPSProxy.sol/UUPSProxy.dbg.json +1 -1
  137. package/artifacts/contracts/token/superfluid/UUPSProxy.sol/UUPSUtils.dbg.json +1 -1
  138. package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.dbg.json +1 -1
  139. package/artifacts/contracts/ubi/UBISchemeV2.sol/UBISchemeV2.dbg.json +1 -1
  140. package/artifacts/contracts/utils/AdminWallet.sol/AdminWallet.dbg.json +1 -1
  141. package/artifacts/contracts/utils/AdminWalletFuse.sol/AdminWalletFuse.dbg.json +1 -1
  142. package/artifacts/contracts/utils/BancorFormula.sol/BancorFormula.dbg.json +1 -1
  143. package/artifacts/contracts/utils/BulkProof.sol/BulkProof.dbg.json +1 -1
  144. package/artifacts/contracts/utils/BuyAndBridgeHelper.sol/BuyAndBridgeHelper.dbg.json +1 -1
  145. package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDClone.dbg.json +1 -1
  146. package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDClone.json +2 -2
  147. package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDCloneFactory.dbg.json +1 -1
  148. package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDCloneFactory.json +112 -2
  149. package/artifacts/contracts/utils/BuyGDClone.sol/DonateGDClone.dbg.json +4 -0
  150. package/artifacts/contracts/utils/BuyGDClone.sol/DonateGDClone.json +358 -0
  151. package/artifacts/contracts/utils/BuyGDClone.sol/ISwapRouter.dbg.json +1 -1
  152. package/artifacts/contracts/utils/DAOContract.sol/DAOContract.dbg.json +1 -1
  153. package/artifacts/contracts/utils/DAOUpgradeableContract.sol/DAOUpgradeableContract.dbg.json +1 -1
  154. package/artifacts/contracts/utils/DSMath.sol/DSMath.dbg.json +1 -1
  155. package/artifacts/contracts/utils/DataTypes.sol/DataTypes.dbg.json +1 -1
  156. package/artifacts/contracts/utils/GDFaucet.sol/GDFaucet.dbg.json +1 -1
  157. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/GoodDollarMintBurnWrapper.dbg.json +1 -1
  158. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/IRouter.dbg.json +1 -1
  159. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/PausableControl.dbg.json +1 -1
  160. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/TokenOperation.dbg.json +1 -1
  161. package/artifacts/contracts/utils/IdentityFix.sol/IdentityFix.dbg.json +1 -1
  162. package/artifacts/contracts/utils/MultiCall.sol/Multicall.dbg.json +1 -1
  163. package/artifacts/contracts/utils/MultichainBridgeHelper.sol/MultichainBridgeHelper.dbg.json +1 -1
  164. package/artifacts/contracts/utils/NameService.sol/NameService.dbg.json +1 -1
  165. package/artifacts/contracts/utils/OneTimePayments.sol/OneTimePayments.dbg.json +1 -1
  166. package/artifacts/contracts/utils/OneTimePaymentsV2.sol/OneTimePaymentsV2.dbg.json +1 -1
  167. package/artifacts/contracts/utils/ProtocolUpgrade.sol/OldMarketMaker.dbg.json +1 -1
  168. package/artifacts/contracts/utils/ProtocolUpgrade.sol/ProtocolUpgrade.dbg.json +1 -1
  169. package/artifacts/contracts/utils/ProtocolUpgradeFuse.sol/ProtocolUpgradeFuse.dbg.json +1 -1
  170. package/artifacts/contracts/utils/ProtocolUpgradeFuseRecover.sol/ProtocolUpgradeFuseRecover.dbg.json +1 -1
  171. package/artifacts/contracts/utils/ProtocolUpgradeRecover.sol/ProtocolUpgradeRecover.dbg.json +1 -1
  172. package/artifacts/contracts/utils/ProxyFactory1967.sol/ERC1967Proxy.dbg.json +1 -1
  173. package/artifacts/contracts/utils/ProxyFactory1967.sol/ProxyFactory1967.dbg.json +1 -1
  174. package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.dbg.json +1 -1
  175. package/contracts/token/superfluid/ISuperToken.sol +2 -2
  176. package/contracts/token/superfluid/SuperGoodDollar.sol +405 -407
  177. package/contracts/token/superfluid/SuperToken.sol +2 -2
  178. package/contracts/utils/BuyGDClone.sol +138 -9
  179. package/dist/artifacts/contracts/token/superfluid/SuperGoodDollar.sol/SuperGoodDollar.json +41 -28
  180. package/package.json +1 -1
  181. package/releases/deployment.json +8 -3
  182. package/types/contracts/token/superfluid/ISuperToken.ts +43 -41
  183. package/types/contracts/token/superfluid/SuperGoodDollar.ts +66 -42
  184. package/types/contracts/token/superfluid/SuperToken.ts +44 -42
  185. package/types/contracts/utils/BuyGDClone.sol/BuyGDCloneFactory.ts +162 -0
  186. package/types/contracts/utils/BuyGDClone.sol/DonateGDClone.ts +529 -0
  187. package/types/contracts/utils/BuyGDClone.sol/index.ts +1 -0
  188. package/types/factories/contracts/token/superfluid/ISuperToken__factory.ts +26 -26
  189. package/types/factories/contracts/token/superfluid/SuperGoodDollar__factory.ts +40 -27
  190. package/types/factories/contracts/token/superfluid/SuperToken__factory.ts +27 -27
  191. package/types/factories/contracts/utils/BuyGDClone.sol/BuyGDCloneFactory__factory.ts +111 -1
  192. package/types/factories/contracts/utils/BuyGDClone.sol/BuyGDClone__factory.ts +1 -1
  193. package/types/factories/contracts/utils/BuyGDClone.sol/DonateGDClone__factory.ts +429 -0
  194. package/types/factories/contracts/utils/BuyGDClone.sol/index.ts +1 -0
  195. package/types/hardhat.d.ts +9 -0
  196. package/types/index.ts +2 -0
@@ -65,10 +65,10 @@ contract SuperToken is UUPSProxiable, SuperfluidToken, ISuperToken {
65
65
  ERC777Helper.Operators internal _operators;
66
66
 
67
67
  /// @notice Constant Outflow NFT proxy address
68
- IConstantOutflowNFT public constantOutflowNFT;
68
+ IConstantOutflowNFT public CONSTANT_OUTFLOW_NFT;
69
69
 
70
70
  /// @notice Constant Inflow NFT proxy address
71
- IConstantInflowNFT public constantInflowNFT;
71
+ IConstantInflowNFT public CONSTANT_INFLOW_NFT;
72
72
 
73
73
  /// @notice Pool Admin NFT proxy address
74
74
  IPoolAdminNFT public poolAdminNFT;
@@ -125,10 +125,7 @@ contract BuyGDClone is Initializable {
125
125
  * @dev If the contract has a balance of cUSD, it will swap cUSD for GD tokens.
126
126
  * @param _minAmount The minimum amount of GD tokens to receive from the swap.
127
127
  */
128
- function swap(
129
- uint256 _minAmount,
130
- address payable refundGas
131
- ) external payable {
128
+ function swap(uint256 _minAmount, address payable refundGas) public payable {
132
129
  uint256 balance = address(this).balance;
133
130
  if (balance > 0) return swapCelo(_minAmount, refundGas);
134
131
 
@@ -235,7 +232,7 @@ contract BuyGDClone is Initializable {
235
232
  * @notice Recovers tokens accidentally sent to the contract.
236
233
  * @param token The address of the token to recover. Use address(0) to recover ETH.
237
234
  */
238
- function recover(address token) external {
235
+ function recover(address token) external virtual {
239
236
  if (token == address(0)) {
240
237
  (bool sent, ) = payable(owner).call{ value: address(this).balance }("");
241
238
  if (!sent) revert REFUND_FAILED(address(this).balance);
@@ -245,12 +242,89 @@ contract BuyGDClone is Initializable {
245
242
  }
246
243
  }
247
244
 
245
+ contract DonateGDClone is BuyGDClone {
246
+ error EXEC_FAILED(bytes error);
247
+
248
+ address public recoverTo;
249
+ bytes public callData;
250
+
251
+ constructor(
252
+ ISwapRouter _router,
253
+ address _cusd,
254
+ address _gd,
255
+ IStaticOracle _oracle
256
+ ) BuyGDClone(_router, _cusd, _gd, _oracle) {}
257
+
258
+ /**
259
+ * @notice Initializes the contract with the owner's address.
260
+ * @param _recoverTo The address of the owner of the contract that can recover stuck funds
261
+ * @param _donateTo The address of the funds target
262
+ */
263
+ function initialize(
264
+ address _recoverTo,
265
+ address _donateTo,
266
+ bytes memory _callData
267
+ ) external initializer {
268
+ owner = _donateTo;
269
+ recoverTo = _recoverTo;
270
+ callData = _callData;
271
+ }
272
+
273
+ function exec(
274
+ uint256 _minAmount,
275
+ address payable refundGas,
276
+ bool withSwap
277
+ ) public payable {
278
+ // in case we need to swap and call a contract, we redirect funds here
279
+ address tempOwner = owner;
280
+ if (withSwap && callData.length > 0) {
281
+ owner = address(this);
282
+ }
283
+ //no perform swap
284
+ if (withSwap) {
285
+ swap(_minAmount, refundGas);
286
+ owner = tempOwner;
287
+ }
288
+
289
+ //now exec
290
+ if (callData.length > 0) {
291
+ // approve spend of the different possible tokens, before calling the target contract
292
+ uint256 cusdBalance = ERC20(cusd).balanceOf(address(this));
293
+ uint256 gdBalance = ERC20(gd).balanceOf(address(this));
294
+ uint256 celoBalance = address(this).balance;
295
+
296
+ if (cusdBalance > 0) ERC20(cusd).approve(address(owner), cusdBalance);
297
+ if (gdBalance > 0) ERC20(gd).approve(address(owner), gdBalance);
298
+ if (celoBalance > 0) ERC20(celo).approve(address(owner), celoBalance);
299
+
300
+ (bool success, bytes memory data) = owner.call{ value: 0 }(callData);
301
+ if (!success) revert EXEC_FAILED(data);
302
+ }
303
+ }
304
+
305
+ /**
306
+ * @notice Recovers tokens accidentally sent to the contract.
307
+ * @param token The address of the token to recover. Use address(0) to recover ETH.
308
+ */
309
+ function recover(address token) external virtual override {
310
+ if (token == address(0)) {
311
+ (bool sent, ) = payable(recoverTo).call{ value: address(this).balance }(
312
+ ""
313
+ );
314
+ if (!sent) revert REFUND_FAILED(address(this).balance);
315
+ } else {
316
+ ERC20(token).transfer(recoverTo, ERC20(token).balanceOf(address(this)));
317
+ }
318
+ }
319
+ }
320
+
248
321
  /**
249
322
  * @title BuyGDCloneFactory
250
323
  * @notice Factory contract for creating clones of BuyGDClone contract
251
324
  */
252
325
  contract BuyGDCloneFactory {
253
326
  address public immutable impl;
327
+ address public immutable donateImpl;
254
328
 
255
329
  /**
256
330
  * @notice Initializes the BuyGDCloneFactory contract with the provided parameters.
@@ -266,6 +340,8 @@ contract BuyGDCloneFactory {
266
340
  IStaticOracle _oracle
267
341
  ) {
268
342
  impl = address(new BuyGDClone(_router, _cusd, _gd, _oracle));
343
+ donateImpl = address(new DonateGDClone(_router, _cusd, _gd, _oracle));
344
+
269
345
  _oracle.prepareAllAvailablePoolsWithTimePeriod(_gd, _cusd, 600);
270
346
  }
271
347
 
@@ -274,24 +350,57 @@ contract BuyGDCloneFactory {
274
350
  * @param owner The address of the owner of the new BuyGDClone contract.
275
351
  * @return The address of the new BuyGDClone contract.
276
352
  */
277
- function create(address owner) external returns (address) {
353
+ function create(address owner) public returns (address) {
278
354
  bytes32 salt = keccak256(abi.encode(owner));
279
355
  address clone = ClonesUpgradeable.cloneDeterministic(impl, salt);
280
356
  BuyGDClone(payable(clone)).initialize(owner);
281
357
  return clone;
282
358
  }
283
359
 
360
+ /**
361
+ * @notice Creates a new clone of the BuyGDClone contract with the provided owner address.
362
+ * @param owner The address of the owner of the new DoanteGDClone contract that can recover funds.
363
+ * @param donateOrExecTo The address of the target for funds
364
+ * @param callData a payload to execute on the target donateOrExecTo instead of simple transfers (using approve instead)
365
+ *
366
+ * @return The address of the new BuyGDClone contract.
367
+ */
368
+ function createDonation(
369
+ address owner,
370
+ address donateOrExecTo,
371
+ bytes memory callData
372
+ ) public returns (address) {
373
+ bytes32 salt = keccak256(abi.encode(owner, donateOrExecTo, callData));
374
+ address clone = ClonesUpgradeable.cloneDeterministic(donateImpl, salt);
375
+ DonateGDClone(payable(clone)).initialize(owner, donateOrExecTo, callData);
376
+ return clone;
377
+ }
378
+
284
379
  function createAndSwap(
285
380
  address owner,
286
381
  uint256 minAmount
287
382
  ) external returns (address) {
288
- bytes32 salt = keccak256(abi.encode(owner));
289
- address clone = ClonesUpgradeable.cloneDeterministic(impl, salt);
290
- BuyGDClone(payable(clone)).initialize(owner);
383
+ address clone = create(owner);
291
384
  BuyGDClone(payable(clone)).swap(minAmount, payable(msg.sender));
292
385
  return clone;
293
386
  }
294
387
 
388
+ function createDonationAndSwap(
389
+ address owner,
390
+ address donateOrExecTo,
391
+ bool withSwap,
392
+ uint256 minAmount,
393
+ bytes memory callData
394
+ ) external returns (address) {
395
+ address clone = createDonation(owner, donateOrExecTo, callData);
396
+ DonateGDClone(payable(clone)).exec(
397
+ minAmount,
398
+ payable(msg.sender),
399
+ withSwap
400
+ );
401
+ return clone;
402
+ }
403
+
295
404
  /**
296
405
  * @notice Predicts the address of a new clone of the BuyGDClone contract with the provided owner address.
297
406
  * @param owner The address of the owner of the new BuyGDClone contract.
@@ -304,6 +413,26 @@ contract BuyGDCloneFactory {
304
413
  ClonesUpgradeable.predictDeterministicAddress(impl, salt, address(this));
305
414
  }
306
415
 
416
+ /**
417
+ * @notice Predicts the address of a new clone of the BuyGDClone contract with the provided owner address.
418
+ * @param owner The address of the owner of the new BuyGDClone contract.
419
+ * @return The predicted address of the new BuyGDClone contract.
420
+ */
421
+ function predictDonation(
422
+ address owner,
423
+ address donateOrExecTo,
424
+ bytes memory callData
425
+ ) external view returns (address) {
426
+ bytes32 salt = keccak256(abi.encode(owner, donateOrExecTo, callData));
427
+
428
+ return
429
+ ClonesUpgradeable.predictDeterministicAddress(
430
+ donateImpl,
431
+ salt,
432
+ address(this)
433
+ );
434
+ }
435
+
307
436
  function getBaseFee() external view returns (uint256) {
308
437
  return block.basefee;
309
438
  }