@gooddollar/goodprotocol 2.0.10 → 2.0.12
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/BuyGDClone.min.json +1 -1
- package/artifacts/abis/BuyGDCloneFactory.min.json +1 -1
- package/artifacts/abis/FuseStakingV3.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/FuseStakingV3.json +66 -2
- 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/FeesFormula.sol/IFeesFormula.dbg.json +1 -1
- package/artifacts/contracts/token/GoodDollar.sol/GoodDollar.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/SuperGoodDollar.sol/SuperGoodDollar.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/SuperToken.sol/SuperToken.dbg.json +1 -1
- 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 +27 -2
- package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDCloneFactory.dbg.json +1 -1
- package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDCloneFactory.json +52 -2
- 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/staking/FuseStakingV3.sol +79 -67
- package/contracts/utils/BuyGDClone.sol +59 -58
- package/package.json +3 -1
- package/releases/deployment.json +3 -1
- package/types/BuyGDClone.ts +42 -12
- package/types/BuyGDCloneFactory.ts +68 -0
- package/types/FuseStakingV3.ts +111 -0
- package/types/IStaticOracle.ts +507 -0
- package/types/IUniswapV3Factory.ts +333 -0
- package/types/factories/BuyGDCloneFactory__factory.ts +51 -1
- package/types/factories/BuyGDClone__factory.ts +26 -1
- package/types/factories/FuseStakingV3__factory.ts +65 -1
- package/types/factories/IStaticOracle__factory.ts +316 -0
- package/types/factories/IUniswapV3Factory__factory.ts +222 -0
- package/types/hardhat.d.ts +18 -9
- package/types/index.ts +4 -2
- package/yarn.lock +116 -2
- package/artifacts/abis/IStaticOracle.min.json +0 -1
- package/artifacts/contracts/utils/BuyGDClone.sol/IStaticOracle.dbg.json +0 -4
- package/artifacts/contracts/utils/BuyGDClone.sol/IStaticOracle.json +0 -79
|
@@ -24,17 +24,16 @@ interface IConsensus {
|
|
|
24
24
|
*/
|
|
25
25
|
function withdraw(address _validator, uint256 _amount) external;
|
|
26
26
|
|
|
27
|
-
function delegatedAmount(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
function delegatedAmount(
|
|
28
|
+
address _address,
|
|
29
|
+
address _validator
|
|
30
|
+
) external view returns (uint256);
|
|
31
31
|
|
|
32
32
|
function stakeAmount(address _address) external view returns (uint256);
|
|
33
33
|
|
|
34
|
-
function delegators(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
returns (address[] memory);
|
|
34
|
+
function delegators(
|
|
35
|
+
address _validator
|
|
36
|
+
) external view returns (address[] memory);
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
interface PegSwap {
|
|
@@ -44,11 +43,7 @@ interface PegSwap {
|
|
|
44
43
|
* @param source the token that is being given
|
|
45
44
|
* @param target the token that is being taken
|
|
46
45
|
*/
|
|
47
|
-
function swap(
|
|
48
|
-
uint256 sourceAmount,
|
|
49
|
-
address source,
|
|
50
|
-
address target
|
|
51
|
-
) external;
|
|
46
|
+
function swap(uint256 sourceAmount, address source, address target) external;
|
|
52
47
|
}
|
|
53
48
|
|
|
54
49
|
contract FuseStakingV3 is Initializable, OwnableUpgradeable {
|
|
@@ -84,6 +79,10 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
|
|
|
84
79
|
|
|
85
80
|
PegSwap pegSwap;
|
|
86
81
|
|
|
82
|
+
address payable public gasFaucet;
|
|
83
|
+
address payable public communityPool;
|
|
84
|
+
uint256 public lastFaucetBalance;
|
|
85
|
+
|
|
87
86
|
event UBICollected(
|
|
88
87
|
uint256 indexed currentDay,
|
|
89
88
|
uint256 ubi, //G$ sent to ubischeme
|
|
@@ -131,6 +130,11 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
|
|
|
131
130
|
_;
|
|
132
131
|
}
|
|
133
132
|
|
|
133
|
+
function upgrade() external onlyGuardian {
|
|
134
|
+
gasFaucet = payable(0x01ab5966C1d742Ae0CFF7f14cC0F4D85156e83d9);
|
|
135
|
+
communityPool = payable(0xCe69892CbDA078BbFAA3E5aE7A4b4d2Bf3E5c412);
|
|
136
|
+
}
|
|
137
|
+
|
|
134
138
|
function approve() external {
|
|
135
139
|
cERC20(fUSD).approve(address(pegSwap), type(uint256).max);
|
|
136
140
|
cERC20(USDC).approve(address(uniswap), type(uint256).max);
|
|
@@ -140,16 +144,21 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
|
|
|
140
144
|
ubischeme = UBIScheme(_ubischeme);
|
|
141
145
|
}
|
|
142
146
|
|
|
147
|
+
function updateSettings(
|
|
148
|
+
uint256 _stakeBackRatio,
|
|
149
|
+
uint256 _communityPoolRatio
|
|
150
|
+
) external onlyGuardian {
|
|
151
|
+
communityPoolRatio = _communityPoolRatio;
|
|
152
|
+
stakeBackRatio = _stakeBackRatio;
|
|
153
|
+
}
|
|
154
|
+
|
|
143
155
|
function stake() public payable returns (bool) {
|
|
144
156
|
return stake(address(0));
|
|
145
157
|
}
|
|
146
158
|
|
|
147
|
-
function stake(
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
onlyGuardian
|
|
151
|
-
returns (bool)
|
|
152
|
-
{
|
|
159
|
+
function stake(
|
|
160
|
+
address _validator
|
|
161
|
+
) public payable onlyGuardian returns (bool) {
|
|
153
162
|
require(msg.value > 0, "stake must be > 0");
|
|
154
163
|
require(validators.length > 0, "no approved validators");
|
|
155
164
|
bool found;
|
|
@@ -168,7 +177,7 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
|
|
|
168
177
|
"validator not in approved list"
|
|
169
178
|
);
|
|
170
179
|
|
|
171
|
-
bool staked =
|
|
180
|
+
bool staked = _stakeNextValidator(msg.value, _validator);
|
|
172
181
|
stakers[msg.sender] += msg.value;
|
|
173
182
|
return staked;
|
|
174
183
|
}
|
|
@@ -181,9 +190,9 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
|
|
|
181
190
|
for (uint256 i = 0; i < validators.length; i++) {
|
|
182
191
|
uint256 cur = consensus.delegatedAmount(address(this), validators[i]);
|
|
183
192
|
if (cur == 0) continue;
|
|
184
|
-
|
|
193
|
+
_undelegateWithCatch(validators[i], cur);
|
|
185
194
|
}
|
|
186
|
-
uint256 effectiveBalance =
|
|
195
|
+
uint256 effectiveBalance = _balance(); //use only undelegated funds
|
|
187
196
|
pendingFuseEarnings = 0;
|
|
188
197
|
if (effectiveBalance > 0) {
|
|
189
198
|
(bool ok, ) = msg.sender.call{ value: effectiveBalance }("");
|
|
@@ -192,7 +201,7 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
|
|
|
192
201
|
}
|
|
193
202
|
|
|
194
203
|
function withdraw(uint256 _value) public returns (uint256) {
|
|
195
|
-
uint256 effectiveBalance =
|
|
204
|
+
uint256 effectiveBalance = _balance(); //use only undelegated funds
|
|
196
205
|
uint256 toWithdraw = _value == 0 ? stakers[msg.sender] : _value;
|
|
197
206
|
uint256 toCollect = toWithdraw;
|
|
198
207
|
require(
|
|
@@ -204,16 +213,16 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
|
|
|
204
213
|
uint256 cur = consensus.delegatedAmount(address(this), validators[i]);
|
|
205
214
|
if (cur == 0) continue;
|
|
206
215
|
if (cur <= perValidator) {
|
|
207
|
-
|
|
216
|
+
_undelegateWithCatch(validators[i], cur);
|
|
208
217
|
toCollect = toCollect.sub(cur);
|
|
209
218
|
} else {
|
|
210
|
-
|
|
219
|
+
_undelegateWithCatch(validators[i], perValidator);
|
|
211
220
|
toCollect = toCollect.sub(perValidator);
|
|
212
221
|
}
|
|
213
222
|
if (toCollect == 0) break;
|
|
214
223
|
}
|
|
215
224
|
|
|
216
|
-
effectiveBalance =
|
|
225
|
+
effectiveBalance = _balance().sub(effectiveBalance); //use only undelegated funds
|
|
217
226
|
|
|
218
227
|
// in case some funds where not withdrawn
|
|
219
228
|
if (toWithdraw > effectiveBalance) {
|
|
@@ -227,10 +236,10 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
|
|
|
227
236
|
return toWithdraw;
|
|
228
237
|
}
|
|
229
238
|
|
|
230
|
-
function
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
{
|
|
239
|
+
function _stakeNextValidator(
|
|
240
|
+
uint256 _value,
|
|
241
|
+
address _validator
|
|
242
|
+
) internal returns (bool) {
|
|
234
243
|
if (validators.length == 0) return false;
|
|
235
244
|
if (_validator != address(0)) {
|
|
236
245
|
consensus.delegate{ value: _value }(_validator);
|
|
@@ -269,11 +278,11 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
|
|
|
269
278
|
function removeValidator(address _validator) public onlyOwner {
|
|
270
279
|
uint256 delegated = consensus.delegatedAmount(address(this), _validator);
|
|
271
280
|
if (delegated > 0) {
|
|
272
|
-
uint256 prevBalance =
|
|
273
|
-
|
|
281
|
+
uint256 prevBalance = _balance();
|
|
282
|
+
_undelegateWithCatch(_validator, delegated);
|
|
274
283
|
|
|
275
284
|
// wasnt withdrawn because validator needs to be taken of active validators
|
|
276
|
-
if (
|
|
285
|
+
if (_balance() == prevBalance) {
|
|
277
286
|
// pendingValidators.push(_validator);
|
|
278
287
|
return;
|
|
279
288
|
}
|
|
@@ -289,20 +298,32 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
|
|
|
289
298
|
}
|
|
290
299
|
}
|
|
291
300
|
|
|
301
|
+
function _fillGasFaucet(uint256 earned) internal returns (uint256 toTop) {
|
|
302
|
+
if (gasFaucet != address(0) && lastFaucetBalance > gasFaucet.balance) {
|
|
303
|
+
toTop = lastFaucetBalance - gasFaucet.balance;
|
|
304
|
+
if (toTop > earned) toTop = earned;
|
|
305
|
+
gasFaucet.call{ value: toTop }("");
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
lastFaucetBalance = gasFaucet.balance;
|
|
309
|
+
}
|
|
310
|
+
|
|
292
311
|
function collectUBIInterest() public notPaused {
|
|
293
312
|
uint256 curDay = ubischeme.currentDay();
|
|
294
313
|
require(curDay != lastDayCollected, "can collect only once in a ubi cycle");
|
|
295
314
|
|
|
296
|
-
uint256 earnings =
|
|
315
|
+
uint256 earnings = _balance() - pendingFuseEarnings;
|
|
297
316
|
require(pendingFuseEarnings + earnings > 0, "no earnings to collect");
|
|
298
317
|
|
|
299
318
|
lastDayCollected = curDay;
|
|
300
319
|
uint256 fuseUBI = earnings.mul(RATIO_BASE - stakeBackRatio).div(RATIO_BASE);
|
|
301
320
|
uint256 stakeBack = earnings - fuseUBI;
|
|
321
|
+
uint256 gasTopped = _fillGasFaucet(stakeBack);
|
|
322
|
+
stakeBack -= gasTopped;
|
|
302
323
|
|
|
303
324
|
uint256[] memory fuseswapResult = _buyGD(fuseUBI + pendingFuseEarnings); //buy GD with X% of earnings
|
|
304
325
|
pendingFuseEarnings = fuseUBI + pendingFuseEarnings - fuseswapResult[0];
|
|
305
|
-
|
|
326
|
+
_stakeNextValidator(stakeBack, address(0)); //stake back the rest of the earnings
|
|
306
327
|
|
|
307
328
|
uint256 gdBought = fuseswapResult[fuseswapResult.length - 1];
|
|
308
329
|
uint256 keeperFee = gdBought.mul(keeperFeeRatio).div(RATIO_BASE);
|
|
@@ -315,7 +336,7 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
|
|
|
315
336
|
uint256 ubiAfterFeeAndPool = gdBought.sub(communityPoolContribution);
|
|
316
337
|
|
|
317
338
|
GD.transfer(address(ubischeme), ubiAfterFeeAndPool); //transfer to ubischeme
|
|
318
|
-
|
|
339
|
+
GD.transfer(address(communityPool), communityPoolContribution);
|
|
319
340
|
|
|
320
341
|
emit UBICollected(
|
|
321
342
|
curDay,
|
|
@@ -378,10 +399,9 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
|
|
|
378
399
|
* @return usdcAmount and usedFuse how much usdc we got and how much fuse was used
|
|
379
400
|
*/
|
|
380
401
|
|
|
381
|
-
function _buyUSDC(
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
{
|
|
402
|
+
function _buyUSDC(
|
|
403
|
+
uint256 _fuseIn
|
|
404
|
+
) internal returns (uint256 usdcAmount, uint256 usedFuse) {
|
|
385
405
|
//buy from uniwasp
|
|
386
406
|
require(_fuseIn > 0, "buy value should be > 0");
|
|
387
407
|
UniswapPair uniswapFUSEfUSDPair = UniswapPair(
|
|
@@ -410,11 +430,9 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
|
|
|
410
430
|
usdcAmount = result[1] / 1e12; //convert fusd from 1e18 to usdc 1e6
|
|
411
431
|
}
|
|
412
432
|
|
|
413
|
-
function calcMaxFuseWithPriceImpact(
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
returns (uint256 fuseAmount, uint256 tokenOut)
|
|
417
|
-
{
|
|
433
|
+
function calcMaxFuseWithPriceImpact(
|
|
434
|
+
uint256 _value
|
|
435
|
+
) public view returns (uint256 fuseAmount, uint256 tokenOut) {
|
|
418
436
|
(uint256 r_fuse, uint256 r_gd, ) = UniswapPair(
|
|
419
437
|
uniswapFactory.getPair(uniswap.WETH(), address(GD))
|
|
420
438
|
).getReserves();
|
|
@@ -422,11 +440,9 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
|
|
|
422
440
|
return calcMaxTokenWithPriceImpact(r_fuse, r_gd, _value);
|
|
423
441
|
}
|
|
424
442
|
|
|
425
|
-
function calcMaxFuseUSDCWithPriceImpact(
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
returns (uint256 maxFuse, uint256 gdOut)
|
|
429
|
-
{
|
|
443
|
+
function calcMaxFuseUSDCWithPriceImpact(
|
|
444
|
+
uint256 _value
|
|
445
|
+
) public view returns (uint256 maxFuse, uint256 gdOut) {
|
|
430
446
|
UniswapPair uniswapFUSEfUSDPair = UniswapPair(
|
|
431
447
|
uniswapFactory.getPair(uniswap.WETH(), fUSD)
|
|
432
448
|
); //fusd is pegged 1:1 to usdc
|
|
@@ -463,7 +479,7 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
|
|
|
463
479
|
/**
|
|
464
480
|
* uniswap amountOut helper
|
|
465
481
|
*/
|
|
466
|
-
function
|
|
482
|
+
function _getAmountOut(
|
|
467
483
|
uint256 _amountIn,
|
|
468
484
|
uint256 _reserveIn,
|
|
469
485
|
uint256 _reserveOut
|
|
@@ -484,7 +500,7 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
|
|
|
484
500
|
) public view returns (uint256 maxToken, uint256 tokenOut) {
|
|
485
501
|
maxToken = (r_token * maxSlippageRatio) / RATIO_BASE;
|
|
486
502
|
maxToken = maxToken < _value ? maxToken : _value;
|
|
487
|
-
tokenOut =
|
|
503
|
+
tokenOut = _getAmountOut(maxToken, r_token, r_gd);
|
|
488
504
|
// uint256 start = 0;
|
|
489
505
|
// uint256 end = _value.div(1e18); //save iterations by moving precision to whole Fuse quantity
|
|
490
506
|
// // uint256 curPriceWei = uint256(1e18).mul(r_gd) / r_token; //uniswap quote formula UniswapV2Library.sol
|
|
@@ -524,22 +540,18 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
|
|
|
524
540
|
// }
|
|
525
541
|
}
|
|
526
542
|
|
|
527
|
-
function
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
{
|
|
543
|
+
function _undelegateWithCatch(
|
|
544
|
+
address _validator,
|
|
545
|
+
uint256 _amount
|
|
546
|
+
) internal returns (bool) {
|
|
531
547
|
try consensus.withdraw(_validator, _amount) {
|
|
532
548
|
return true;
|
|
533
|
-
} catch Error(
|
|
534
|
-
string memory /*reason*/
|
|
535
|
-
) {
|
|
549
|
+
} catch Error(string memory /*reason*/) {
|
|
536
550
|
// This is executed in case
|
|
537
551
|
// revert was called inside getData
|
|
538
552
|
// and a reason string was provided.
|
|
539
553
|
return false;
|
|
540
|
-
} catch (
|
|
541
|
-
bytes memory /*lowLevelData*/
|
|
542
|
-
) {
|
|
554
|
+
} catch (bytes memory /*lowLevelData*/) {
|
|
543
555
|
// This is executed in case revert() was used
|
|
544
556
|
// or there was a failing assertion, division
|
|
545
557
|
// by zero, etc. inside getData.
|
|
@@ -547,7 +559,7 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
|
|
|
547
559
|
}
|
|
548
560
|
}
|
|
549
561
|
|
|
550
|
-
function
|
|
562
|
+
function _balance() internal view returns (uint256) {
|
|
551
563
|
return payable(address(this)).balance;
|
|
552
564
|
}
|
|
553
565
|
|
|
@@ -559,10 +571,10 @@ contract FuseStakingV3 is Initializable, OwnableUpgradeable {
|
|
|
559
571
|
guardian = _guardian;
|
|
560
572
|
}
|
|
561
573
|
|
|
562
|
-
function collectCommunityPool(
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
{
|
|
574
|
+
function collectCommunityPool(
|
|
575
|
+
address _to,
|
|
576
|
+
uint256 amount
|
|
577
|
+
) external onlyGuardian {
|
|
566
578
|
communityPoolBalance -= amount;
|
|
567
579
|
GD.transfer(_to, amount);
|
|
568
580
|
}
|
|
@@ -3,39 +3,9 @@
|
|
|
3
3
|
pragma solidity >=0.8;
|
|
4
4
|
import "@openzeppelin/contracts-upgradeable/proxy/ClonesUpgradeable.sol";
|
|
5
5
|
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
|
6
|
+
import "@mean-finance/uniswap-v3-oracle/solidity/interfaces/IStaticOracle.sol";
|
|
6
7
|
import "../Interfaces.sol";
|
|
7
8
|
|
|
8
|
-
//@mean-finance/uniswap-v3-oracle
|
|
9
|
-
interface IStaticOracle {
|
|
10
|
-
/// @notice Will increase observations for all existing pools for the given pair, so they start accruing information for twap calculations
|
|
11
|
-
/// @dev Will revert if there are no pools available for the pair and period combination
|
|
12
|
-
/// @param tokenA One of the pair's tokens
|
|
13
|
-
/// @param tokenB The other of the pair's tokens
|
|
14
|
-
/// @param cardinality The cardinality that will be guaranteed when quoting
|
|
15
|
-
/// @return preparedPools The pools that were prepared
|
|
16
|
-
function prepareAllAvailablePoolsWithCardinality(
|
|
17
|
-
address tokenA,
|
|
18
|
-
address tokenB,
|
|
19
|
-
uint16 cardinality
|
|
20
|
-
) external returns (address[] memory preparedPools);
|
|
21
|
-
|
|
22
|
-
/// @notice Returns a quote, based on the given tokens and amount, by querying all of the pair's pools
|
|
23
|
-
/// @dev If some pools are not configured correctly for the given period, then they will be ignored
|
|
24
|
-
/// @dev Will revert if there are no pools available/configured for the pair and period combination
|
|
25
|
-
/// @param baseAmount Amount of token to be converted
|
|
26
|
-
/// @param baseToken Address of an ERC20 token contract used as the baseAmount denomination
|
|
27
|
-
/// @param quoteToken Address of an ERC20 token contract used as the quoteAmount denomination
|
|
28
|
-
/// @param period Number of seconds from which to calculate the TWAP
|
|
29
|
-
/// @return quoteAmount Amount of quoteToken received for baseAmount of baseToken
|
|
30
|
-
/// @return queriedPools The pools that were queried to calculate the quote
|
|
31
|
-
function quoteAllAvailablePoolsWithTimePeriod(
|
|
32
|
-
uint128 baseAmount,
|
|
33
|
-
address baseToken,
|
|
34
|
-
address quoteToken,
|
|
35
|
-
uint32 period
|
|
36
|
-
) external view returns (uint256 quoteAmount, address[] memory queriedPools);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
9
|
// @uniswap/v3-core
|
|
40
10
|
interface ISwapRouter {
|
|
41
11
|
struct ExactInputSingleParams {
|
|
@@ -155,12 +125,15 @@ contract BuyGDClone is Initializable {
|
|
|
155
125
|
* @dev If the contract has a balance of cUSD, it will swap cUSD for GD tokens.
|
|
156
126
|
* @param _minAmount The minimum amount of GD tokens to receive from the swap.
|
|
157
127
|
*/
|
|
158
|
-
function swap(
|
|
128
|
+
function swap(
|
|
129
|
+
uint256 _minAmount,
|
|
130
|
+
address payable refundGas
|
|
131
|
+
) external payable {
|
|
159
132
|
uint256 balance = address(this).balance;
|
|
160
|
-
if (balance > 0) return swapCelo(_minAmount);
|
|
133
|
+
if (balance > 0) return swapCelo(_minAmount, refundGas);
|
|
161
134
|
|
|
162
135
|
balance = ERC20(cusd).balanceOf(address(this));
|
|
163
|
-
if (balance > 0) return swapCusd(_minAmount);
|
|
136
|
+
if (balance > 0) return swapCusd(_minAmount, refundGas);
|
|
164
137
|
|
|
165
138
|
revert NO_BALANCE();
|
|
166
139
|
}
|
|
@@ -169,23 +142,35 @@ contract BuyGDClone is Initializable {
|
|
|
169
142
|
* @notice Swaps Celo for GD tokens.
|
|
170
143
|
* @param _minAmount The minimum amount of GD tokens to receive from the swap.
|
|
171
144
|
*/
|
|
172
|
-
function swapCelo(
|
|
173
|
-
uint256
|
|
174
|
-
|
|
145
|
+
function swapCelo(
|
|
146
|
+
uint256 _minAmount,
|
|
147
|
+
address payable refundGas
|
|
148
|
+
) public payable {
|
|
149
|
+
uint256 gasCosts;
|
|
150
|
+
if (refundGas != owner) {
|
|
151
|
+
(gasCosts, ) = oracle.quoteAllAvailablePoolsWithTimePeriod(
|
|
152
|
+
1e17, //0.1$
|
|
153
|
+
cusd,
|
|
154
|
+
celo,
|
|
155
|
+
60
|
|
156
|
+
);
|
|
157
|
+
}
|
|
175
158
|
|
|
176
|
-
uint256
|
|
159
|
+
uint256 amountIn = address(this).balance - gasCosts;
|
|
160
|
+
|
|
161
|
+
(uint256 minByTwap, ) = minAmountByTWAP(amountIn, celo, twapPeriod);
|
|
177
162
|
_minAmount = _minAmount > minByTwap ? _minAmount : minByTwap;
|
|
178
163
|
|
|
179
|
-
ERC20(celo).approve(address(router),
|
|
164
|
+
ERC20(celo).approve(address(router), amountIn);
|
|
180
165
|
ISwapRouter.ExactInputParams memory params = ISwapRouter.ExactInputParams({
|
|
181
166
|
path: abi.encodePacked(celo, uint24(3000), cusd, uint24(10000), gd),
|
|
182
167
|
recipient: owner,
|
|
183
|
-
amountIn:
|
|
168
|
+
amountIn: amountIn,
|
|
184
169
|
amountOutMinimum: _minAmount
|
|
185
170
|
});
|
|
186
171
|
router.exactInput(params);
|
|
187
|
-
if (
|
|
188
|
-
(bool sent, ) =
|
|
172
|
+
if (refundGas != owner) {
|
|
173
|
+
(bool sent, ) = refundGas.call{ value: gasCosts }("");
|
|
189
174
|
if (!sent) revert REFUND_FAILED(gasCosts);
|
|
190
175
|
}
|
|
191
176
|
}
|
|
@@ -194,23 +179,23 @@ contract BuyGDClone is Initializable {
|
|
|
194
179
|
* @notice Swaps cUSD for GD tokens.
|
|
195
180
|
* @param _minAmount The minimum amount of GD tokens to receive from the swap.
|
|
196
181
|
*/
|
|
197
|
-
function swapCusd(uint256 _minAmount) public {
|
|
198
|
-
uint256 gasCosts =
|
|
199
|
-
|
|
182
|
+
function swapCusd(uint256 _minAmount, address refundGas) public {
|
|
183
|
+
uint256 gasCosts = refundGas != owner ? 1e17 : 0; //fixed 0.1$
|
|
184
|
+
uint256 amountIn = ERC20(cusd).balanceOf(address(this)) - gasCosts;
|
|
200
185
|
|
|
201
|
-
uint256 minByTwap = minAmountByTWAP(
|
|
186
|
+
(uint256 minByTwap, ) = minAmountByTWAP(amountIn, cusd, twapPeriod);
|
|
202
187
|
_minAmount = _minAmount > minByTwap ? _minAmount : minByTwap;
|
|
203
188
|
|
|
204
|
-
ERC20(cusd).approve(address(router),
|
|
189
|
+
ERC20(cusd).approve(address(router), amountIn);
|
|
205
190
|
ISwapRouter.ExactInputParams memory params = ISwapRouter.ExactInputParams({
|
|
206
191
|
path: abi.encodePacked(cusd, uint24(10000), gd),
|
|
207
192
|
recipient: owner,
|
|
208
|
-
amountIn:
|
|
193
|
+
amountIn: amountIn,
|
|
209
194
|
amountOutMinimum: _minAmount
|
|
210
195
|
});
|
|
211
196
|
router.exactInput(params);
|
|
212
|
-
if (
|
|
213
|
-
ERC20(cusd).transfer(
|
|
197
|
+
if (refundGas != owner) {
|
|
198
|
+
ERC20(cusd).transfer(refundGas, gasCosts);
|
|
214
199
|
}
|
|
215
200
|
}
|
|
216
201
|
|
|
@@ -223,16 +208,16 @@ contract BuyGDClone is Initializable {
|
|
|
223
208
|
*/
|
|
224
209
|
function minAmountByTWAP(
|
|
225
210
|
uint256 baseAmount,
|
|
226
|
-
address baseToken
|
|
227
|
-
|
|
211
|
+
address baseToken,
|
|
212
|
+
uint32 period
|
|
213
|
+
) public view returns (uint256 minTwap, uint256 quote) {
|
|
228
214
|
uint128 toConvert = uint128(baseAmount);
|
|
229
|
-
uint256 quote;
|
|
230
215
|
if (baseToken == celo) {
|
|
231
216
|
(quote, ) = oracle.quoteAllAvailablePoolsWithTimePeriod(
|
|
232
217
|
toConvert,
|
|
233
218
|
baseToken,
|
|
234
219
|
cusd,
|
|
235
|
-
|
|
220
|
+
period
|
|
236
221
|
);
|
|
237
222
|
toConvert = uint128(quote);
|
|
238
223
|
}
|
|
@@ -240,10 +225,10 @@ contract BuyGDClone is Initializable {
|
|
|
240
225
|
toConvert,
|
|
241
226
|
cusd,
|
|
242
227
|
gd,
|
|
243
|
-
|
|
228
|
+
period
|
|
244
229
|
);
|
|
245
|
-
//minAmount should not be
|
|
246
|
-
return (quote *
|
|
230
|
+
//minAmount should not be 2% under twap (ie we dont expect price movement > 2% in timePeriod)
|
|
231
|
+
return ((quote * 98) / 100, quote);
|
|
247
232
|
}
|
|
248
233
|
|
|
249
234
|
/**
|
|
@@ -265,7 +250,7 @@ contract BuyGDClone is Initializable {
|
|
|
265
250
|
* @notice Factory contract for creating clones of BuyGDClone contract
|
|
266
251
|
*/
|
|
267
252
|
contract BuyGDCloneFactory {
|
|
268
|
-
address immutable impl;
|
|
253
|
+
address public immutable impl;
|
|
269
254
|
|
|
270
255
|
/**
|
|
271
256
|
* @notice Initializes the BuyGDCloneFactory contract with the provided parameters.
|
|
@@ -281,6 +266,7 @@ contract BuyGDCloneFactory {
|
|
|
281
266
|
IStaticOracle _oracle
|
|
282
267
|
) {
|
|
283
268
|
impl = address(new BuyGDClone(_router, _cusd, _gd, _oracle));
|
|
269
|
+
_oracle.prepareAllAvailablePoolsWithTimePeriod(_gd, _cusd, 600);
|
|
284
270
|
}
|
|
285
271
|
|
|
286
272
|
/**
|
|
@@ -295,6 +281,17 @@ contract BuyGDCloneFactory {
|
|
|
295
281
|
return clone;
|
|
296
282
|
}
|
|
297
283
|
|
|
284
|
+
function createAndSwap(
|
|
285
|
+
address owner,
|
|
286
|
+
uint256 minAmount
|
|
287
|
+
) external returns (address) {
|
|
288
|
+
bytes32 salt = keccak256(abi.encode(owner));
|
|
289
|
+
address clone = ClonesUpgradeable.cloneDeterministic(impl, salt);
|
|
290
|
+
BuyGDClone(payable(clone)).initialize(owner);
|
|
291
|
+
BuyGDClone(payable(clone)).swap(minAmount, payable(msg.sender));
|
|
292
|
+
return clone;
|
|
293
|
+
}
|
|
294
|
+
|
|
298
295
|
/**
|
|
299
296
|
* @notice Predicts the address of a new clone of the BuyGDClone contract with the provided owner address.
|
|
300
297
|
* @param owner The address of the owner of the new BuyGDClone contract.
|
|
@@ -306,4 +303,8 @@ contract BuyGDCloneFactory {
|
|
|
306
303
|
return
|
|
307
304
|
ClonesUpgradeable.predictDeterministicAddress(impl, salt, address(this));
|
|
308
305
|
}
|
|
306
|
+
|
|
307
|
+
function getBaseFee() external view returns (uint256) {
|
|
308
|
+
return block.basefee;
|
|
309
|
+
}
|
|
309
310
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gooddollar/goodprotocol",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.12",
|
|
4
4
|
"description": "GoodDollar Protocol",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": "18.x"
|
|
@@ -82,10 +82,12 @@
|
|
|
82
82
|
"@babel/polyfill": "*",
|
|
83
83
|
"@babel/preset-env": "*",
|
|
84
84
|
"@babel/register": "*",
|
|
85
|
+
"@celo-tools/celo-ethers-wrapper": "^0.4.0",
|
|
85
86
|
"@gnosis.pm/safe-core-sdk": "^3.2.0",
|
|
86
87
|
"@gnosis.pm/safe-core-sdk-types": "^1.7.0",
|
|
87
88
|
"@gnosis.pm/safe-ethers-lib": "^1.7.0",
|
|
88
89
|
"@gnosis.pm/safe-service-client": "^1.4.0",
|
|
90
|
+
"@mean-finance/uniswap-v3-oracle": "^1.0.3",
|
|
89
91
|
"@nomicfoundation/hardhat-network-helpers": "^1.0.8",
|
|
90
92
|
"@nomiclabs/hardhat-ethers": "^2.2.1",
|
|
91
93
|
"@nomiclabs/hardhat-etherscan": "^3.1.0",
|