@gooddollar/goodprotocol 2.0.19 → 2.0.21
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/IQuoterV2.min.json +1 -0
- 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/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 +2 -2
- package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDCloneFactory.dbg.json +1 -1
- package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDCloneFactory.json +259 -2
- package/artifacts/contracts/utils/BuyGDClone.sol/DonateGDClone.dbg.json +1 -1
- package/artifacts/contracts/utils/BuyGDClone.sol/DonateGDClone.json +2 -2
- package/artifacts/contracts/utils/BuyGDClone.sol/IQuoterV2.dbg.json +4 -0
- package/artifacts/contracts/utils/BuyGDClone.sol/IQuoterV2.json +111 -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/utils/BuyGDClone.sol +182 -2
- package/package.json +1 -1
- package/releases/deployment.json +1 -1
- package/scripts/blockchainTestSetup.sh +18 -0
- package/scripts/deployFullDAO.ts +21 -0
- package/scripts/test/simulateInterest.ts +1 -1
- package/types/contracts/utils/BuyGDClone.sol/BuyGDCloneFactory.ts +320 -3
- package/types/contracts/utils/BuyGDClone.sol/IQuoterV2.ts +184 -0
- package/types/contracts/utils/BuyGDClone.sol/index.ts +1 -0
- package/types/factories/contracts/utils/BuyGDClone.sol/BuyGDCloneFactory__factory.ts +258 -1
- package/types/factories/contracts/utils/BuyGDClone.sol/BuyGDClone__factory.ts +1 -1
- package/types/factories/contracts/utils/BuyGDClone.sol/DonateGDClone__factory.ts +1 -1
- package/types/factories/contracts/utils/BuyGDClone.sol/IQuoterV2__factory.ts +126 -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
|
@@ -77,6 +77,57 @@ interface ISwapRouter {
|
|
|
77
77
|
) external payable returns (uint256 amountIn);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
interface IQuoterV2 {
|
|
81
|
+
/// @notice Returns the amount out received for a given exact input swap without executing the swap
|
|
82
|
+
/// @param path The path of the swap, i.e. each token pair and the pool fee
|
|
83
|
+
/// @param amountIn The amount of the first token to swap
|
|
84
|
+
/// @return amountOut The amount of the last token that would be received
|
|
85
|
+
/// @return sqrtPriceX96AfterList List of the sqrt price after the swap for each pool in the path
|
|
86
|
+
/// @return initializedTicksCrossedList List of the initialized ticks that the swap crossed for each pool in the path
|
|
87
|
+
/// @return gasEstimate The estimate of the gas that the swap consumes
|
|
88
|
+
function quoteExactInput(
|
|
89
|
+
bytes memory path,
|
|
90
|
+
uint256 amountIn
|
|
91
|
+
)
|
|
92
|
+
external
|
|
93
|
+
returns (
|
|
94
|
+
uint256 amountOut,
|
|
95
|
+
uint160[] memory sqrtPriceX96AfterList,
|
|
96
|
+
uint32[] memory initializedTicksCrossedList,
|
|
97
|
+
uint256 gasEstimate
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
struct QuoteExactInputSingleParams {
|
|
101
|
+
address tokenIn;
|
|
102
|
+
address tokenOut;
|
|
103
|
+
uint256 amountIn;
|
|
104
|
+
uint24 fee;
|
|
105
|
+
uint160 sqrtPriceLimitX96;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/// @notice Returns the amount out received for a given exact input but for a swap of a single pool
|
|
109
|
+
/// @param params The params for the quote, encoded as `QuoteExactInputSingleParams`
|
|
110
|
+
/// tokenIn The token being swapped in
|
|
111
|
+
/// tokenOut The token being swapped out
|
|
112
|
+
/// fee The fee of the token pool to consider for the pair
|
|
113
|
+
/// amountIn The desired input amount
|
|
114
|
+
/// sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap
|
|
115
|
+
/// @return amountOut The amount of `tokenOut` that would be received
|
|
116
|
+
/// @return sqrtPriceX96After The sqrt price of the pool after the swap
|
|
117
|
+
/// @return initializedTicksCrossed The number of initialized ticks that the swap crossed
|
|
118
|
+
/// @return gasEstimate The estimate of the gas that the swap consumes
|
|
119
|
+
function quoteExactInputSingle(
|
|
120
|
+
QuoteExactInputSingleParams memory params
|
|
121
|
+
)
|
|
122
|
+
external
|
|
123
|
+
returns (
|
|
124
|
+
uint256 amountOut,
|
|
125
|
+
uint160 sqrtPriceX96After,
|
|
126
|
+
uint32 initializedTicksCrossed,
|
|
127
|
+
uint256 gasEstimate
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
80
131
|
/*
|
|
81
132
|
* @title BuyGDClone
|
|
82
133
|
* @notice This contract allows users to swap Celo or cUSD for GoodDollar (GD) tokens.
|
|
@@ -208,6 +259,9 @@ contract BuyGDClone is Initializable {
|
|
|
208
259
|
address baseToken,
|
|
209
260
|
uint32 period
|
|
210
261
|
) public view returns (uint256 minTwap, uint256 quote) {
|
|
262
|
+
uint24[] memory fees = new uint24[](1);
|
|
263
|
+
fees[0] = 10000;
|
|
264
|
+
|
|
211
265
|
uint128 toConvert = uint128(baseAmount);
|
|
212
266
|
if (baseToken == celo) {
|
|
213
267
|
(quote, ) = oracle.quoteAllAvailablePoolsWithTimePeriod(
|
|
@@ -218,10 +272,11 @@ contract BuyGDClone is Initializable {
|
|
|
218
272
|
);
|
|
219
273
|
toConvert = uint128(quote);
|
|
220
274
|
}
|
|
221
|
-
(quote, ) = oracle.
|
|
275
|
+
(quote, ) = oracle.quoteSpecificFeeTiersWithTimePeriod(
|
|
222
276
|
toConvert,
|
|
223
277
|
cusd,
|
|
224
278
|
gd,
|
|
279
|
+
fees,
|
|
225
280
|
period
|
|
226
281
|
);
|
|
227
282
|
//minAmount should not be 2% under twap (ie we dont expect price movement > 2% in timePeriod)
|
|
@@ -323,8 +378,27 @@ contract DonateGDClone is BuyGDClone {
|
|
|
323
378
|
* @notice Factory contract for creating clones of BuyGDClone contract
|
|
324
379
|
*/
|
|
325
380
|
contract BuyGDCloneFactory {
|
|
381
|
+
error NOT_GD_TOKEN();
|
|
382
|
+
error INVALID_TWAP();
|
|
383
|
+
error RECIPIENT_ZERO();
|
|
384
|
+
|
|
385
|
+
IQuoterV2 public constant quoter =
|
|
386
|
+
IQuoterV2(0x82825d0554fA07f7FC52Ab63c961F330fdEFa8E8); // celo quoter
|
|
387
|
+
|
|
326
388
|
address public immutable impl;
|
|
327
389
|
address public immutable donateImpl;
|
|
390
|
+
address public immutable gd;
|
|
391
|
+
address public immutable cusd;
|
|
392
|
+
IStaticOracle public immutable oracle;
|
|
393
|
+
ISwapRouter public immutable router;
|
|
394
|
+
|
|
395
|
+
event GDSwapToCusd(
|
|
396
|
+
address from,
|
|
397
|
+
address to,
|
|
398
|
+
uint256 amountIn,
|
|
399
|
+
uint256 amountOut,
|
|
400
|
+
bytes note
|
|
401
|
+
);
|
|
328
402
|
|
|
329
403
|
/**
|
|
330
404
|
* @notice Initializes the BuyGDCloneFactory contract with the provided parameters.
|
|
@@ -341,7 +415,10 @@ contract BuyGDCloneFactory {
|
|
|
341
415
|
) {
|
|
342
416
|
impl = address(new BuyGDClone(_router, _cusd, _gd, _oracle));
|
|
343
417
|
donateImpl = address(new DonateGDClone(_router, _cusd, _gd, _oracle));
|
|
344
|
-
|
|
418
|
+
gd = _gd;
|
|
419
|
+
cusd = _cusd;
|
|
420
|
+
oracle = _oracle;
|
|
421
|
+
router = _router;
|
|
345
422
|
_oracle.prepareAllAvailablePoolsWithTimePeriod(_gd, _cusd, 600);
|
|
346
423
|
}
|
|
347
424
|
|
|
@@ -436,4 +513,107 @@ contract BuyGDCloneFactory {
|
|
|
436
513
|
function getBaseFee() external view returns (uint256) {
|
|
437
514
|
return block.basefee;
|
|
438
515
|
}
|
|
516
|
+
|
|
517
|
+
function onTokenTransfer(
|
|
518
|
+
address from,
|
|
519
|
+
uint256 amount,
|
|
520
|
+
bytes calldata data
|
|
521
|
+
) external returns (bool) {
|
|
522
|
+
if (msg.sender != gd) revert NOT_GD_TOKEN();
|
|
523
|
+
(address to, uint256 minAmount, bytes memory note) = abi.decode(
|
|
524
|
+
data,
|
|
525
|
+
(address, uint256, bytes)
|
|
526
|
+
);
|
|
527
|
+
if (to == address(0)) revert RECIPIENT_ZERO();
|
|
528
|
+
|
|
529
|
+
uint256 amountIn = ERC20(gd).balanceOf(address(this));
|
|
530
|
+
|
|
531
|
+
uint256 amountReceived = swapToCusd(amountIn, minAmount, to);
|
|
532
|
+
emit GDSwapToCusd(from, to, amount, amountReceived, note);
|
|
533
|
+
return true;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* @notice Swaps cUSD for GD tokens.
|
|
538
|
+
* @param _minAmount The minimum amount of GD tokens to receive from the swap.
|
|
539
|
+
*/
|
|
540
|
+
function swapToCusd(
|
|
541
|
+
uint256 amountIn,
|
|
542
|
+
uint256 _minAmount,
|
|
543
|
+
address recipient
|
|
544
|
+
) public returns (uint256) {
|
|
545
|
+
if (msg.sender != gd) {
|
|
546
|
+
ERC20(gd).transferFrom(msg.sender, address(this), amountIn);
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
if (_minAmount == 0) (_minAmount, ) = minAmountByTWAP(amountIn, gd, 60);
|
|
550
|
+
|
|
551
|
+
ERC20(gd).approve(address(router), amountIn);
|
|
552
|
+
ISwapRouter.ExactInputParams memory params = ISwapRouter.ExactInputParams({
|
|
553
|
+
path: abi.encodePacked(gd, uint24(10000), cusd),
|
|
554
|
+
recipient: recipient,
|
|
555
|
+
amountIn: amountIn,
|
|
556
|
+
amountOutMinimum: _minAmount
|
|
557
|
+
});
|
|
558
|
+
return router.exactInput(params);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* @notice Calculates the minimum amount of tokens that can be received for a given amount of base tokens,
|
|
563
|
+
* based on the time-weighted average price (TWAP) of the token pair over a specified period of time.
|
|
564
|
+
* @param baseAmount The amount of base tokens to swap.
|
|
565
|
+
* @param baseToken The address of the base token.
|
|
566
|
+
* @return minTwap The minimum amount of G$ expected to receive by twap
|
|
567
|
+
*/
|
|
568
|
+
function minAmountByTWAP(
|
|
569
|
+
uint256 baseAmount,
|
|
570
|
+
address baseToken,
|
|
571
|
+
uint32 period
|
|
572
|
+
) public view returns (uint256 minTwap, uint256 quote) {
|
|
573
|
+
uint24[] memory fees = new uint24[](1);
|
|
574
|
+
fees[0] = 10000;
|
|
575
|
+
uint128 toConvert = uint128(baseAmount);
|
|
576
|
+
(quote, ) = oracle.quoteSpecificFeeTiersWithTimePeriod(
|
|
577
|
+
toConvert,
|
|
578
|
+
baseToken,
|
|
579
|
+
cusd,
|
|
580
|
+
fees,
|
|
581
|
+
period
|
|
582
|
+
);
|
|
583
|
+
|
|
584
|
+
(uint256 curPrice, ) = oracle.quoteSpecificFeeTiersWithTimePeriod(
|
|
585
|
+
toConvert,
|
|
586
|
+
baseToken,
|
|
587
|
+
cusd,
|
|
588
|
+
fees,
|
|
589
|
+
0
|
|
590
|
+
);
|
|
591
|
+
|
|
592
|
+
// (ie we dont expect price movement > 2% in timePeriod)
|
|
593
|
+
if ((quote * 98) / 100 > curPrice) {
|
|
594
|
+
revert INVALID_TWAP();
|
|
595
|
+
}
|
|
596
|
+
//minAmount should not be 2% under curPrice (including slippage and price impact)
|
|
597
|
+
//this is just a guesstimate, for accurate results use uniswap sdk to get price quote
|
|
598
|
+
//v3 price quote is not available on chain
|
|
599
|
+
return ((curPrice * 980) / 1000, quote);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
function quoteCusd(uint256 amountIn) external returns (uint256 amountOut) {
|
|
603
|
+
return quoteToken(amountIn, 10000, cusd);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
function quoteToken(
|
|
607
|
+
uint256 amountIn,
|
|
608
|
+
uint24 fee,
|
|
609
|
+
address targetToken
|
|
610
|
+
) public returns (uint256 amountOut) {
|
|
611
|
+
IQuoterV2.QuoteExactInputSingleParams memory params;
|
|
612
|
+
params.amountIn = amountIn;
|
|
613
|
+
params.tokenIn = gd;
|
|
614
|
+
params.tokenOut = targetToken;
|
|
615
|
+
params.fee = fee;
|
|
616
|
+
|
|
617
|
+
(amountOut, , , ) = quoter.quoteExactInputSingle(params);
|
|
618
|
+
}
|
|
439
619
|
}
|
package/package.json
CHANGED
package/releases/deployment.json
CHANGED
|
@@ -487,7 +487,7 @@
|
|
|
487
487
|
"MpbBridge": "0xa3247276DbCC76Dd7705273f766eB3E8a5ecF4a5",
|
|
488
488
|
"StaticOracle": "0x00851A91a3c4E9a4c1B48df827Bacc1f884bdE28",
|
|
489
489
|
"BuyGDFactory": "0x00e533B7d6255D05b7f15034B1c989c21F51b91C",
|
|
490
|
-
"BuyGDFactoryV2": "
|
|
490
|
+
"BuyGDFactoryV2": "0xBB2Ef9b160741AAC9e7e654E2fAAf8CE0EDe95fe"
|
|
491
491
|
},
|
|
492
492
|
"gnosis": {
|
|
493
493
|
"GuardiansSafe": "0x84c10b45fe51bfb4f86c19a47fdbc187d4572fb8"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
mkdir /tmp/goodprotocol
|
|
3
|
+
cp -R node_modules/@gooddollar/goodprotocol /tmp/goodprotocol
|
|
4
|
+
pushd /tmp/goodprotocol
|
|
5
|
+
export CI=false
|
|
6
|
+
export MNEMONIC='test test test test test test test test test test test junk'
|
|
7
|
+
export ADMIN_MNEMONIC='test test test test test test test test test test test junk'
|
|
8
|
+
yarn set version 3.6.0
|
|
9
|
+
echo "nodeLinker: node-modules" >> .yarnrc.yml
|
|
10
|
+
yarn --immutable
|
|
11
|
+
npx patch-package
|
|
12
|
+
yarn runNode &
|
|
13
|
+
sleep 30
|
|
14
|
+
yarn deployTest
|
|
15
|
+
yarn minimize
|
|
16
|
+
popd
|
|
17
|
+
cp -R /tmp/goodprotocol/artifacts node_modules/@gooddollar/goodprotocol/
|
|
18
|
+
cp -R /tmp/goodprotocol/releases node_modules/@gooddollar/goodprotocol/
|
package/scripts/deployFullDAO.ts
CHANGED
|
@@ -249,6 +249,26 @@ export const createDAO = async () => {
|
|
|
249
249
|
|
|
250
250
|
console.log("deploying v2...");
|
|
251
251
|
const v2 = await deployV2(network.name, false, olddao);
|
|
252
|
+
if (isMainnet) {
|
|
253
|
+
let distHelper = await upgrades.deployProxy(
|
|
254
|
+
await ethers.getContractFactory("DistributionHelper"),
|
|
255
|
+
[v2.NameService],
|
|
256
|
+
{
|
|
257
|
+
initializer: "initialize(address)",
|
|
258
|
+
kind: "uups"
|
|
259
|
+
}
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
const goodReserve = await ethers.getContractFactory("GoodReserveCDai");
|
|
263
|
+
console.log("setting distribution helper...");
|
|
264
|
+
|
|
265
|
+
await genericCall(
|
|
266
|
+
v2.GoodReserveCDai,
|
|
267
|
+
goodReserve.interface.encodeFunctionData("setDistributionHelper", [
|
|
268
|
+
distHelper.address
|
|
269
|
+
])
|
|
270
|
+
);
|
|
271
|
+
}
|
|
252
272
|
console.log("deploying adminWallet...");
|
|
253
273
|
const adminWallet = await deployAdminWallet(Identity.address, v2.NameService);
|
|
254
274
|
console.log("setting up identity:", {
|
|
@@ -345,6 +365,7 @@ const deployBridge = async (Avatar, gd, setSchemes, isMainnet) => {
|
|
|
345
365
|
|
|
346
366
|
const deployMainnet = async (Avatar, Identity) => {
|
|
347
367
|
console.log("deploying mainnet...");
|
|
368
|
+
|
|
348
369
|
const [root] = await ethers.getSigners();
|
|
349
370
|
|
|
350
371
|
const cdaiFactory = await ethers.getContractFactory("cDAIMock");
|