Skip to content

Commit

Permalink
Merge pull request #107 from stabilitydao/gqmf-farms
Browse files Browse the repository at this point in the history
add GQMF farms, change forking block
  • Loading branch information
a17 authored Mar 29, 2024
2 parents bea3a47 + 4d1622f commit 3155e46
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 14 deletions.
22 changes: 21 additions & 1 deletion chains/PolygonLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 -----

Expand Down Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions script/libs/DeployLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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, ", "));
}
Expand Down
9 changes: 2 additions & 7 deletions test/adapters/KyberAdapter.Polygon.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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");
Expand All @@ -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");
Expand Down
9 changes: 6 additions & 3 deletions test/base/chains/PolygonSetup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion test/strategies/GQMF.Polygon.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 3155e46

Please sign in to comment.