@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.
- package/artifacts/abis/BuyGDCloneFactory.min.json +1 -1
- package/artifacts/abis/DonateGDClone.min.json +1 -0
- package/artifacts/abis/ISuperToken.min.json +1 -1
- package/artifacts/abis/SuperGoodDollar.min.json +1 -1
- package/artifacts/abis/SuperToken.min.json +1 -1
- package/artifacts/contracts/DAOStackInterfaces.sol/Avatar.dbg.json +1 -1
- package/artifacts/contracts/DAOStackInterfaces.sol/Controller.dbg.json +1 -1
- package/artifacts/contracts/DAOStackInterfaces.sol/GlobalConstraintInterface.dbg.json +1 -1
- package/artifacts/contracts/DAOStackInterfaces.sol/IntVoteInterface.dbg.json +1 -1
- package/artifacts/contracts/DAOStackInterfaces.sol/ReputationInterface.dbg.json +1 -1
- package/artifacts/contracts/DAOStackInterfaces.sol/SchemeRegistrar.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/AggregatorV3Interface.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/ERC20.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IAaveIncentivesController.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IAdminWallet.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IDonationStaking.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IERC2917.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IFirstClaimPool.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IGoodDollar.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IGoodStaking.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IHasRouter.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IIdentity.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IIdentityV2.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/ILendingPool.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IMultichainRouter.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/INameService.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IUBIScheme.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/ProxyAdmin.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/Reserve.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/Staking.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/Uniswap.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/UniswapFactory.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/UniswapPair.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/cERC20.dbg.json +1 -1
- package/artifacts/contracts/fuseFaucet/Faucet.sol/Faucet.dbg.json +1 -1
- package/artifacts/contracts/fuseFaucet/FuseFaucet.sol/FuseFaucet.dbg.json +1 -1
- package/artifacts/contracts/fuseFaucet/FuseFaucetV2.sol/FuseFaucetV2.dbg.json +1 -1
- package/artifacts/contracts/governance/ClaimersDistribution.sol/ClaimersDistribution.dbg.json +1 -1
- package/artifacts/contracts/governance/CompoundVotingMachine.sol/CompoundVotingMachine.dbg.json +1 -1
- package/artifacts/contracts/governance/GReputation.sol/GReputation.dbg.json +1 -1
- package/artifacts/contracts/governance/GoodDollarStaking.sol/GoodDollarStaking.dbg.json +1 -1
- package/artifacts/contracts/governance/GoodDollarStaking.sol/IGovernanceStaking.dbg.json +1 -1
- package/artifacts/contracts/governance/GoodDollarStaking.sol/IStakingUpgrade.dbg.json +1 -1
- package/artifacts/contracts/governance/GoodDollarStaking.sol/RewardsMinter.dbg.json +1 -1
- package/artifacts/contracts/governance/GovernanceStaking.sol/GovernanceStaking.dbg.json +1 -1
- package/artifacts/contracts/governance/MultiBaseGovernanceShareField.sol/MultiBaseGovernanceShareField.dbg.json +1 -1
- package/artifacts/contracts/governance/Reputation.sol/Reputation.dbg.json +1 -1
- package/artifacts/contracts/governance/StakersDistribution.sol/StakersDistribution.dbg.json +1 -1
- package/artifacts/contracts/identity/IdentityV2.sol/IdentityV2.dbg.json +1 -1
- package/artifacts/contracts/invite/InvitesFuseV2.sol/InvitesFuseV2.dbg.json +1 -1
- package/artifacts/contracts/invite/InvitesV1.sol/InvitesV1.dbg.json +1 -1
- package/artifacts/contracts/invite/InvitesV2.sol/InvitesV2.dbg.json +1 -1
- package/artifacts/contracts/mocks/AaveMock.sol/AaveMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/AaveUSDMockOracle.sol/AaveUSDMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/BatUSDMockOracle.sol/BatUSDMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/CompUsdMockOracle.sol/CompUSDMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/DAIMock.sol/DAIMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/DaiEthPriceMockOracle.sol/DaiEthPriceMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/DecimalsMock.sol/DecimalsMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/DistributionBridgeMock.sol/DistributionBridgeMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTestHelper.dbg.json +1 -1
- package/artifacts/contracts/mocks/EthUSDMockOracle.sol/EthUSDMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/FeesFormularMock.sol/FeesFormulaMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/GasPriceMockOracle.sol/GasPriceMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/GoodDollarStakingMock.sol/GoodDollarStakingMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/IdentityMock.sol/IdentityMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/IncentiveControllerMock.sol/IncentiveControllerMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/LendingPoolMock.sol/LendingPoolMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/MultichainRouterMock.sol/IWrapper.dbg.json +1 -1
- package/artifacts/contracts/mocks/MultichainRouterMock.sol/MultichainRouterMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/OverMintTester.sol/IGoodDollarStakingTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/OverMintTester.sol/OverMintTester.dbg.json +1 -1
- package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.dbg.json +1 -1
- package/artifacts/contracts/mocks/PayableMock.sol/PayableMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/SixteenDecimalsTokenMock.sol/SixteenDecimalsTokenMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/StakingMockFixedAPY.sol/StakingMockFixedAPY.dbg.json +1 -1
- package/artifacts/contracts/mocks/SwapHelperTest.sol/SwapHelperTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/TwentyDecimalsTokenMock.sol/TwentyDecimalsTokenMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock2.dbg.json +1 -1
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock3.dbg.json +1 -1
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock4.dbg.json +1 -1
- package/artifacts/contracts/mocks/UsdcMock.sol/USDCMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cBATMock.sol/cBATMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cDAILowWorthMock.sol/cDAILowWorthMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cDAIMock.sol/cDAIMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cDAINonMintableMock.sol/cDAINonMintableMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cDecimalsMock.sol/cDecimalsMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cSDTMock.sol/cSDTMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cUSDCMock.sol/cUSDCMock.dbg.json +1 -1
- package/artifacts/contracts/reserve/DistributionHelper.sol/DistributionHelper.dbg.json +1 -1
- package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.dbg.json +1 -1
- package/artifacts/contracts/reserve/GoodMarketMaker.sol/GoodMarketMaker.dbg.json +1 -1
- package/artifacts/contracts/reserve/GoodReserveCDai.sol/ContributionCalc.dbg.json +1 -1
- package/artifacts/contracts/reserve/GoodReserveCDai.sol/GoodReserveCDai.dbg.json +1 -1
- package/artifacts/contracts/staking/BaseShareField.sol/BaseShareField.dbg.json +1 -1
- package/artifacts/contracts/staking/BaseShareFieldV2.sol/BaseShareFieldV2.dbg.json +1 -1
- package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/FuseStakingV3.sol/FuseStakingV3.dbg.json +1 -1
- package/artifacts/contracts/staking/FuseStakingV3.sol/IConsensus.dbg.json +1 -1
- package/artifacts/contracts/staking/FuseStakingV3.sol/PegSwap.dbg.json +1 -1
- package/artifacts/contracts/staking/GoodFundManager.sol/GoodFundManager.dbg.json +1 -1
- package/artifacts/contracts/staking/SimpleStaking.sol/SimpleStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/SimpleStakingV2.sol/SimpleStakingV2.dbg.json +1 -1
- package/artifacts/contracts/staking/UniswapV2SwapHelper.sol/UniswapV2SwapHelper.dbg.json +1 -1
- package/artifacts/contracts/staking/aave/AaveStakingFactory.sol/AaveStakingFactory.dbg.json +1 -1
- package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.dbg.json +1 -1
- package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.dbg.json +1 -1
- package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.dbg.json +1 -1
- package/artifacts/contracts/staking/utils/Math64X64.sol/Math64x64.dbg.json +1 -1
- package/artifacts/contracts/staking/utils/StakingRewardsFixedAPY.sol/StakingRewardsFixedAPY.dbg.json +1 -1
- package/artifacts/contracts/token/ERC20PresetMinterPauserUpgradeable.sol/ERC20PresetMinterPauserUpgradeable.dbg.json +1 -1
- package/artifacts/contracts/token/ERC677.sol/ERC677.dbg.json +1 -1
- package/artifacts/contracts/token/ERC677.sol/ERC677Receiver.dbg.json +1 -1
- package/artifacts/contracts/token/GoodDollar.sol/GoodDollar.dbg.json +1 -1
- package/artifacts/contracts/token/IFeesFormula.sol/IFeesFormula.dbg.json +1 -1
- package/artifacts/contracts/token/MultichainFeeFormula.sol/MultichainFeeFormula.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/ERC20Permit.sol/ERC20Permit.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/ERC20Permit.sol/SelfApprove.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/ISuperGoodDollar.sol/IGoodDollarCustom.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/ISuperGoodDollar.sol/ISuperGoodDollar.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/ISuperToken.sol/ISuperToken.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/ISuperToken.sol/ISuperToken.json +26 -26
- package/artifacts/contracts/token/superfluid/SuperGoodDollar.sol/SuperGoodDollar.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/SuperGoodDollar.sol/SuperGoodDollar.json +41 -28
- package/artifacts/contracts/token/superfluid/SuperToken.sol/SuperToken.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/SuperToken.sol/SuperToken.json +28 -28
- package/artifacts/contracts/token/superfluid/SuperfluidToken.sol/SuperfluidToken.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/UUPSProxiable.sol/UUPSProxiable.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/UUPSProxy.sol/Proxy.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/UUPSProxy.sol/UUPSProxy.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/UUPSProxy.sol/UUPSUtils.dbg.json +1 -1
- package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.dbg.json +1 -1
- package/artifacts/contracts/ubi/UBISchemeV2.sol/UBISchemeV2.dbg.json +1 -1
- package/artifacts/contracts/utils/AdminWallet.sol/AdminWallet.dbg.json +1 -1
- package/artifacts/contracts/utils/AdminWalletFuse.sol/AdminWalletFuse.dbg.json +1 -1
- package/artifacts/contracts/utils/BancorFormula.sol/BancorFormula.dbg.json +1 -1
- package/artifacts/contracts/utils/BulkProof.sol/BulkProof.dbg.json +1 -1
- package/artifacts/contracts/utils/BuyAndBridgeHelper.sol/BuyAndBridgeHelper.dbg.json +1 -1
- package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDClone.dbg.json +1 -1
- package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDClone.json +2 -2
- package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDCloneFactory.dbg.json +1 -1
- package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDCloneFactory.json +112 -2
- package/artifacts/contracts/utils/BuyGDClone.sol/DonateGDClone.dbg.json +4 -0
- package/artifacts/contracts/utils/BuyGDClone.sol/DonateGDClone.json +358 -0
- package/artifacts/contracts/utils/BuyGDClone.sol/ISwapRouter.dbg.json +1 -1
- package/artifacts/contracts/utils/DAOContract.sol/DAOContract.dbg.json +1 -1
- package/artifacts/contracts/utils/DAOUpgradeableContract.sol/DAOUpgradeableContract.dbg.json +1 -1
- package/artifacts/contracts/utils/DSMath.sol/DSMath.dbg.json +1 -1
- package/artifacts/contracts/utils/DataTypes.sol/DataTypes.dbg.json +1 -1
- package/artifacts/contracts/utils/GDFaucet.sol/GDFaucet.dbg.json +1 -1
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/GoodDollarMintBurnWrapper.dbg.json +1 -1
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/IRouter.dbg.json +1 -1
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/PausableControl.dbg.json +1 -1
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/TokenOperation.dbg.json +1 -1
- package/artifacts/contracts/utils/IdentityFix.sol/IdentityFix.dbg.json +1 -1
- package/artifacts/contracts/utils/MultiCall.sol/Multicall.dbg.json +1 -1
- package/artifacts/contracts/utils/MultichainBridgeHelper.sol/MultichainBridgeHelper.dbg.json +1 -1
- package/artifacts/contracts/utils/NameService.sol/NameService.dbg.json +1 -1
- package/artifacts/contracts/utils/OneTimePayments.sol/OneTimePayments.dbg.json +1 -1
- package/artifacts/contracts/utils/OneTimePaymentsV2.sol/OneTimePaymentsV2.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgrade.sol/OldMarketMaker.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgrade.sol/ProtocolUpgrade.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgradeFuse.sol/ProtocolUpgradeFuse.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgradeFuseRecover.sol/ProtocolUpgradeFuseRecover.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgradeRecover.sol/ProtocolUpgradeRecover.dbg.json +1 -1
- package/artifacts/contracts/utils/ProxyFactory1967.sol/ERC1967Proxy.dbg.json +1 -1
- package/artifacts/contracts/utils/ProxyFactory1967.sol/ProxyFactory1967.dbg.json +1 -1
- package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.dbg.json +1 -1
- package/contracts/token/superfluid/ISuperToken.sol +2 -2
- package/contracts/token/superfluid/SuperGoodDollar.sol +405 -407
- package/contracts/token/superfluid/SuperToken.sol +2 -2
- package/contracts/utils/BuyGDClone.sol +138 -9
- package/dist/artifacts/contracts/token/superfluid/SuperGoodDollar.sol/SuperGoodDollar.json +41 -28
- package/package.json +1 -1
- package/releases/deployment.json +8 -3
- package/types/contracts/token/superfluid/ISuperToken.ts +43 -41
- package/types/contracts/token/superfluid/SuperGoodDollar.ts +66 -42
- package/types/contracts/token/superfluid/SuperToken.ts +44 -42
- package/types/contracts/utils/BuyGDClone.sol/BuyGDCloneFactory.ts +162 -0
- package/types/contracts/utils/BuyGDClone.sol/DonateGDClone.ts +529 -0
- package/types/contracts/utils/BuyGDClone.sol/index.ts +1 -0
- package/types/factories/contracts/token/superfluid/ISuperToken__factory.ts +26 -26
- package/types/factories/contracts/token/superfluid/SuperGoodDollar__factory.ts +40 -27
- package/types/factories/contracts/token/superfluid/SuperToken__factory.ts +27 -27
- package/types/factories/contracts/utils/BuyGDClone.sol/BuyGDCloneFactory__factory.ts +111 -1
- package/types/factories/contracts/utils/BuyGDClone.sol/BuyGDClone__factory.ts +1 -1
- package/types/factories/contracts/utils/BuyGDClone.sol/DonateGDClone__factory.ts +429 -0
- package/types/factories/contracts/utils/BuyGDClone.sol/index.ts +1 -0
- package/types/hardhat.d.ts +9 -0
- 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
|
|
68
|
+
IConstantOutflowNFT public CONSTANT_OUTFLOW_NFT;
|
|
69
69
|
|
|
70
70
|
/// @notice Constant Inflow NFT proxy address
|
|
71
|
-
IConstantInflowNFT public
|
|
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)
|
|
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
|
-
|
|
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
|
}
|