From 4d1622f6346e93136c553de637fd2d180e2e5378 Mon Sep 17 00:00:00 2001 From: Alien Deployer Date: Fri, 29 Mar 2024 18:32:28 +0300 Subject: [PATCH] add GQMF farms, change forking block --- chains/PolygonLib.sol | 22 +++++++++++++++++++++- script/libs/DeployLib.sol | 9 +++++++-- test/adapters/KyberAdapter.Polygon.t.sol | 9 ++------- test/base/chains/PolygonSetup.sol | 9 ++++++--- test/strategies/GQMF.Polygon.t.sol | 3 ++- 5 files changed, 38 insertions(+), 14 deletions(-) diff --git a/chains/PolygonLib.sol b/chains/PolygonLib.sol index 25b8af83..c6afebcb 100644 --- a/chains/PolygonLib.sol +++ b/chains/PolygonLib.sol @@ -68,13 +68,15 @@ library PolygonLib { address public constant POOL_QUICKSWAPV3_WETH_USDT = 0x9CEff2F5138fC59eB925d270b8A7A9C02a1810f2; address public constant POOL_QUICKSWAPV3_dQUICK_QUICK = 0x194257104FabFd9f48bD01bd71A719637B4bbfA9; address public constant POOL_QUICKSWAPV3_USDCe_USDC = 0xEecB5Db986c20a8C88D8332E7e252A9671565751; + address public constant POOL_QUICKSWAPV3_USDC_WETH = 0xa6AeDF7c4Ed6e821E67a6BfD56FD1702aD9a9719; + address public constant POOL_QUICKSWAPV3_WMATIC_USDC = 0x6669B4706cC152F359e947BCa68E263A87c52634; + address public constant POOL_QUICKSWAPV3_USDC_DAI = 0xBC8f3da0bd42E1F2509cd8671Ce7c7E5f7fd39c8; address public constant POOL_KYBER_USDCe_USDT = 0x879664ce5A919727b3Ed4035Cf12F7F740E8dF00; address public constant POOL_KYBER_USDCe_DAI = 0x02A3E4184b145eE64A6Df3c561A3C0c6e2f23DFa; address public constant POOL_KYBER_KNC_USDCe = 0x4B440a7DE0Ab7041934d0c171849A76CC33234Fa; address public constant POOL_UNISWAPV3_ICHI_WMATIC_100 = 0x3D86A4B8C1b55509792d57e0C038128cC9C14fE7; address public constant POOL_RETRO_WMATIC_WETH_500 = 0x1a34EaBbe928Bf431B679959379b2225d60D9cdA; address public constant POOL_RETRO_oRETRO_RETRO_10000 = 0x387FBcE5E2933Bd3a7243D0be2aAC8fD9Ab3D55d; - // address public constant POOL_RETRO_WETH_RETRO_10000 = 0x35394eED0Be676ec6470fE6531daD809265310ff; address public constant POOL_RETRO_USDCe_RETRO_10000 = 0xc7d8B9c270D0E31A6a0Cf4496fe019766Be42E15; address public constant POOL_RETRO_WMATIC_USDCe_500 = 0xEC15624FBB314eb05BaaD4cA49b7904C0Cb6b645; address public constant POOL_RETRO_WBTC_WETH_500 = 0xb694E3bdd4BCdF843510983D257679D1E627C474; @@ -104,6 +106,8 @@ library PolygonLib { address public constant GAMMA_QUICKSWAP_USDCe_WETH_NARROW = 0x3Cc20A6795c4b57d9817399F68E83e71C8626580; address public constant GAMMA_QUICKSWAP_WMATIC_USDCe_NARROW = 0x04d521E2c414E6d898c6F2599FdD863Edf49e247; address public constant GAMMA_QUICKSWAP_WMATIC_USDCe_WIDE = 0x4A83253e88e77E8d518638974530d0cBbbF3b675; + address public constant GAMMA_QUICKSWAP_USDC_WETH_NARROW = 0x3974FbDC22741A1632E024192111107b202F214f; + address public constant GAMMA_QUICKSWAP_WMATIC_USDC_NARROW = 0x1cf4293125913cB3Dea4aD7f2bb4795B9e896CE9; address public constant GAMMA_RETRO_UNIPROXY = 0xDC8eE75f52FABF057ae43Bb4B85C55315b57186c; address public constant GAMMA_RETRO_WMATIC_USDCe_NARROW = 0xBE4E30b74b558E41f5837dC86562DF44aF57A013; address public constant GAMMA_RETRO_WMATIC_WETH_NARROW = 0xe7806B5ba13d4B2Ab3EaB3061cB31d4a4F3390Aa; @@ -232,6 +236,10 @@ library PolygonLib { factory.addFarms(farms4()); factory.addFarms(farms5()); factory.addFarms(farms6()); + if (block.number > 54573098) { + // Mar-12-2024 02:41:42 PM +UTC + factory.addFarms(farms7()); + } DeployLib.logAddedFarms(address(factory), showLog); //endregion -- Add farms ----- @@ -685,6 +693,18 @@ library PolygonLib { _farms[i++] = _makeGammaRetroMerklFarm(GAMMA_RETRO_WBTC_WETH_WIDE, ALMPositionNameLib.WIDE); } + // quickswap USDC native gamma + function farms7() public view returns (IFactory.Farm[] memory _farms) { + _farms = new IFactory.Farm[](2); + uint i; + + // [32] + _farms[i++] = _makeGammaQuickSwapMerklFarm(GAMMA_QUICKSWAP_USDC_WETH_NARROW, ALMPositionNameLib.NARROW); + + // [33] + _farms[i++] = _makeGammaQuickSwapMerklFarm(GAMMA_QUICKSWAP_WMATIC_USDC_NARROW, ALMPositionNameLib.NARROW); + } + function _makeGammaQuickSwapMerklFarm( address hypervisor, uint preset diff --git a/script/libs/DeployLib.sol b/script/libs/DeployLib.sol index 1628ad97..a40325e2 100644 --- a/script/libs/DeployLib.sol +++ b/script/libs/DeployLib.sol @@ -182,8 +182,13 @@ library DeployLib { assets_ = swapper.assets(); assetsStr = new string[](assets_.length); for (uint i; i < assets_.length; ++i) { - (uint price,) = priceReader.getPrice(assets_[i]); - assetsStr[i] = string.concat(IERC20Metadata(assets_[i]).symbol(), " ", CommonLib.formatUsdAmount(price)); + // using try..catch because on old forking blocks assets and pools can be not available + try priceReader.getPrice(assets_[i]) returns (uint price, bool) { + assetsStr[i] = + string.concat(IERC20Metadata(assets_[i]).symbol(), " ", CommonLib.formatUsdAmount(price)); + assetsStr[i] = + string.concat(IERC20Metadata(assets_[i]).symbol(), " ", CommonLib.formatUsdAmount(price)); + } catch {} } console.log("Added pools to swapper with assets:", CommonLib.implode(assetsStr, ", ")); } diff --git a/test/adapters/KyberAdapter.Polygon.t.sol b/test/adapters/KyberAdapter.Polygon.t.sol index 1f8d79bf..8505d810 100644 --- a/test/adapters/KyberAdapter.Polygon.t.sol +++ b/test/adapters/KyberAdapter.Polygon.t.sol @@ -10,7 +10,6 @@ contract KyberAdapterTest is PolygonSetup { ICAmmAdapter adapter; constructor() { - vm.rollFork(48098000); // Sep-01-2023 03:23:25 PM +UTC _init(); _hash = keccak256(bytes(AmmAdapterIdLib.KYBER)); adapter = ICAmmAdapter(platform.ammAdapter(_hash).proxy); @@ -27,8 +26,8 @@ contract KyberAdapterTest is PolygonSetup { amounts[0] = 1e6; amounts[1] = 2e6; int24[] memory ticks = new int24[](2); - ticks[0] = -120; - ticks[1] = 120; + ticks[0] = -120 * 1000; + ticks[1] = 120 * 1000; (uint liquidity, uint[] memory amountsConsumed) = adapter.getLiquidityForAmounts(pool, amounts, ticks); assertGt(liquidity, 0, "liquidity"); @@ -39,10 +38,6 @@ contract KyberAdapterTest is PolygonSetup { assertGt(liquidityAmounts[0], 0); assertGt(liquidityAmounts[1], 0); - // (uint amount0, uint amount1) = UniswapV3Adapter(address(adapter)).getAmountsForLiquidity(pool, ticks[0], ticks[1], uint128(liquidity)); - // assertEq(liquidityAmounts[0], amount0); - // assertEq(liquidityAmounts[1], amount1); - uint[] memory proportions = adapter.getProportions(pool); assertGt(proportions[0], 0, "props0"); assertGt(proportions[1], 0, "props1"); diff --git a/test/base/chains/PolygonSetup.sol b/test/base/chains/PolygonSetup.sol index 1a3d7d23..8bde50c9 100644 --- a/test/base/chains/PolygonSetup.sol +++ b/test/base/chains/PolygonSetup.sol @@ -7,25 +7,28 @@ import "../../../src/core/Platform.sol"; import "../../../src/core/Factory.sol"; abstract contract PolygonSetup is ChainSetup { + bool public showDeployLog; + constructor() { vm.selectFork(vm.createFork(vm.envString("POLYGON_RPC_URL"))); // vm.rollFork(48098000); // Sep-01-2023 03:23:25 PM +UTC // vm.rollFork(51800000); // Jan-01-2024 02:33:32 AM +UTC - vm.rollFork(54000000); // Feb-27-2024 12:56:05 AM +UTC + // vm.rollFork(54000000); // Feb-27-2024 12:56:05 AM +UTC + vm.rollFork(55000000); // Mar-23-2024 07:56:52 PM +UTC } function testPolygonSetupStub() external {} function _init() internal override { //region ----- DeployPlatform ----- - platform = Platform(PolygonLib.runDeploy(false)); + platform = Platform(PolygonLib.runDeploy(showDeployLog)); factory = Factory(address(platform.factory())); //endregion -- DeployPlatform ---- } function _deal(address token, address to, uint amount) internal override { if (token == PolygonLib.TOKEN_USDC) { - vm.prank(0x72A53cDBBcc1b9efa39c834A540550e23463AAcB); // Cryoto.com + vm.prank(0xe7804c37c13166fF0b37F5aE0BB07A3aEbb6e245); // 0xe7804c37c13166fF0b37F5aE0BB07A3aEbb6e245 IERC20(token).transfer(to, amount); } else { deal(token, to, amount); diff --git a/test/strategies/GQMF.Polygon.t.sol b/test/strategies/GQMF.Polygon.t.sol index 26bf6a4c..ec7ab4ff 100644 --- a/test/strategies/GQMF.Polygon.t.sol +++ b/test/strategies/GQMF.Polygon.t.sol @@ -21,7 +21,8 @@ contract GammaQuickSwapMerklFarmStrategyTest is PolygonSetup, UniversalTest { _addStrategy(13); _addStrategy(14); _addStrategy(15); - // _addStrategy(16); + _addStrategy(32); + _addStrategy(33); } function _addStrategy(uint farmId) internal {