Skip to content

Commit

Permalink
Merge branch 'main' into 136-factory-asset-symbol-aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
hcrypto7 authored Jun 17, 2024
2 parents b373b33 + 338c4ab commit 1ed0641
Show file tree
Hide file tree
Showing 10 changed files with 607 additions and 15 deletions.
8 changes: 8 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/pr_strategy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- [ ] integration interfaces
- [ ] constants
- [ ] routes
- [ ] farms
- [ ] skeleton
- [ ] universal test
- [ ] implementation
- [ ] deploy script
64 changes: 53 additions & 11 deletions chains/BaseLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ pragma solidity ^0.8.23;
import "../src/core/proxy/Proxy.sol";
import "../src/adapters/libs/AmmAdapterIdLib.sol";
import "../src/adapters/ChainlinkAdapter.sol";
import "../src/integrations/convex/IConvexRewardPool.sol";
import "../src/integrations/gamma/IHypervisor.sol";
import "../src/strategies/libs/StrategyIdLib.sol";
import "../src/strategies/libs/ALMPositionNameLib.sol";
import "../src/strategies/libs/StrategyDeveloperLib.sol";
import "../src/strategies/CompoundFarmStrategy.sol";
import "../src/strategies/GammaUniswapV3MerklFarmStrategy.sol";
import "../src/interfaces/IFactory.sol";
import "../src/interfaces/IPlatform.sol";
import "../src/interfaces/ISwapper.sol";
import "../src/integrations/convex/IConvexRewardPool.sol";
import "../src/interfaces/IPlatformDeployer.sol";
import "../script/libs/LogDeployLib.sol";
import "../script/libs/DeployAdapterLib.sol";
import "../src/interfaces/IPlatformDeployer.sol";
import "../src/strategies/CompoundFarmStrategy.sol";
import "../src/strategies/libs/StrategyDeveloperLib.sol";

/// @dev Base network [chainId: 8453] data library
/// ┳┓
Expand All @@ -35,6 +37,7 @@ library BaseLib {
address public constant TOKEN_USDbC = 0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA;
address public constant TOKEN_sFRAX = 0xe4796cCB6bB5DE2290C417Ac337F2b66CA2E770E;
address public constant TOKEN_COMP = 0x9e1028F5F1D5eDE59748FFceE5532509976840E0;
address public constant TOKEN_UNI = 0xc3De830EA07524a0761646a6a4e4be0e114a3C83;

// AMMs
address public constant POOL_UNISWAPV3_WETH_USDT_500 = 0xd92E0767473D1E3FF11Ac036f2b1DB90aD0aE55F;
Expand All @@ -44,13 +47,22 @@ library BaseLib {
address public constant POOL_UNISWAPV3_USDC_USDT_100 = 0xD56da2B74bA826f19015E6B7Dd9Dae1903E85DA1;
address public constant POOL_UNISWAPV3_USDC_wstETH_500 = 0x45837e65E4c44cA260aB40E6dc30fF1B466a00cA;
address public constant POOL_UNISWAPV3_WETH_COMP_10000 = 0x3367fEDd8Ad5a8Cf01cFE89Df3c697D3A59A1cAD;
address public constant POOL_UNISWAPV3_USDC_UNI_10000 = 0x35d84AE687f0D3bF8548d5470fd04D2abe74f074;
address public constant POOL_BASESWAP_WETH_USDC_450 = 0x883e4AE0A817f2901500971B353b5dD89Aa52184;
address public constant POOL_BASESWAP_USDC_USDbC_80 = 0x88492051E18a65FE00241A93699A6082aE95c828;
address public constant POOL_BASESWAP_sfrxETH_WETH_80 = 0x19F5828aA11e12Eed05Bfb435857115bd098823a;
address public constant POOL_BASESWAP_WETH_USDbC_450 = 0xEf3C164b0feE8Eb073513E88EcEa280A58cC9945;
address public constant POOL_BASESWAP_USDC_sFRAX_80 = 0x74E65d5E7f820771aa86fc99e5d67578Dc77517a;
address public constant POOL_BASESWAP_sfrxETH_sFRAX_450 = 0xee8092F8Da8342a07076b820d8bB553E962c182b;

// ALMs
address public constant GAMMA_UNISWAPV3_UNIPROXY = 0xbd8fD52BE2EC689dac9155FAd51774F63a965D99;
address public constant GAMMA_UNISWAPV3_WETH_USDC_500_NARROW = 0x8089f11dadBabf175Aea2415194A6a3a0575539d;
address public constant GAMMA_UNISWAPV3_WETH_wstETH_100_PEGGED = 0xbC73A3247Eb976a0A29b22f19E4EBAfa45EfdC65;
address public constant GAMMA_UNISWAPV3_cbETH_WETH_500_PEGGED = 0xa52ECC4ed16f97c71071A3Bd14309E846647d7F0;
address public constant GAMMA_UNISWAPV3_WETH_USDT_500_NARROW = 0xCbF2d065b73a2B883C15631C927D93Ee94028a68;
address public constant GAMMA_UNISWAPV3_USDC_USDT_100_STABLE = 0x96034EfF74c0D1ba2eCDBf4C09A6FE8FFd6b71c8;

// Oracles
address public constant ORACLE_CHAINLINK_USDC_USD = 0x7e860098F58bBFC8648a4311b374B1D669a2bc6B;
address public constant ORACLE_CHAINLINK_cbETH_USD = 0xd7818272B9e248357d13057AAb0B417aF31E817d;
Expand Down Expand Up @@ -138,12 +150,12 @@ library BaseLib {
uint[] memory thresholdAmount = new uint[](8);
thresholdAmount[0] = 1e3;
thresholdAmount[1] = 1e3;
thresholdAmount[2] = 1e15;
thresholdAmount[3] = 1e15;
thresholdAmount[4] = 1e15;
thresholdAmount[2] = 1e12;
thresholdAmount[3] = 1e12;
thresholdAmount[4] = 1e12;
thresholdAmount[5] = 1e3;
thresholdAmount[6] = 1e15;
thresholdAmount[7] = 1e15;
thresholdAmount[7] = 1e12;
swapper.setThresholds(tokenIn, thresholdAmount);
LogDeployLib.logSetupSwapper(platform, showLog);
}
Expand All @@ -156,6 +168,7 @@ library BaseLib {

//region ----- Deploy strategy logics -----
_addStrategyLogic(factory, StrategyIdLib.COMPOUND_FARM, address(new CompoundFarmStrategy()), true);
_addStrategyLogic(factory, StrategyIdLib.GAMMA_UNISWAPV3_MERKL_FARM, address(new GammaUniswapV3MerklFarmStrategy()), true);
LogDeployLib.logDeployStrategies(platform, showLog);
//endregion -- Deploy strategy logics -----

Expand All @@ -178,7 +191,7 @@ library BaseLib {
//endregion -- BC pools ----

//region ----- Pools ----
pools = new ISwapper.AddPoolData[](9);
pools = new ISwapper.AddPoolData[](10);
uint i;
// UniswapV3
pools[i++] = _makePoolData(POOL_UNISWAPV3_USDC_USDT_100, AmmAdapterIdLib.UNISWAPV3, TOKEN_USDC, TOKEN_USDT);
Expand All @@ -192,17 +205,46 @@ library BaseLib {
pools[i++] = _makePoolData(POOL_BASESWAP_USDC_USDbC_80, AmmAdapterIdLib.UNISWAPV3, TOKEN_USDbC, TOKEN_USDC);
pools[i++] = _makePoolData(POOL_BASESWAP_USDC_sFRAX_80, AmmAdapterIdLib.UNISWAPV3, TOKEN_sFRAX, TOKEN_USDC);
pools[i++] = _makePoolData(POOL_BASESWAP_sfrxETH_WETH_80, AmmAdapterIdLib.UNISWAPV3, TOKEN_sfrxETH, TOKEN_WETH);

// update 15.06.2024
pools[i++] = _makePoolData(POOL_UNISWAPV3_USDC_UNI_10000, AmmAdapterIdLib.UNISWAPV3, TOKEN_UNI, TOKEN_USDC);

//endregion -- Pools ----
}

function farms() public pure returns (IFactory.Farm[] memory _farms) {
_farms = new IFactory.Farm[](3);
function farms() public view returns (IFactory.Farm[] memory _farms) {
_farms = new IFactory.Farm[](6);
uint i;

// [0]-[2]
_farms[i++] = _makeCompoundFarm(COMPOUND_COMET_USDC);
_farms[i++] = _makeCompoundFarm(COMPOUND_COMET_USDbC);
_farms[i++] = _makeCompoundFarm(COMPOUND_COMET_ETH);

// [3]-[5]
_farms[i++] = _makeGammaUniswapV3MerklFarm(GAMMA_UNISWAPV3_cbETH_WETH_500_PEGGED, ALMPositionNameLib.PEGGED, TOKEN_UNI);
_farms[i++] = _makeGammaUniswapV3MerklFarm(GAMMA_UNISWAPV3_WETH_wstETH_100_PEGGED, ALMPositionNameLib.PEGGED, TOKEN_wstETH);
_farms[i++] = _makeGammaUniswapV3MerklFarm(GAMMA_UNISWAPV3_USDC_USDT_100_STABLE, ALMPositionNameLib.STABLE, TOKEN_UNI);
}

function _makeGammaUniswapV3MerklFarm(
address hypervisor,
uint preset,
address rewardAsset
) internal view returns (IFactory.Farm memory) {
IFactory.Farm memory farm;
farm.status = 0;
farm.pool = IHypervisor(hypervisor).pool();
farm.strategyLogicId = StrategyIdLib.GAMMA_UNISWAPV3_MERKL_FARM;
farm.rewardAssets = new address[](1);
farm.rewardAssets[0] = rewardAsset;
farm.addresses = new address[](2);
farm.addresses[0] = GAMMA_UNISWAPV3_UNIPROXY;
farm.addresses[1] = hypervisor;
farm.nums = new uint[](1);
farm.nums[0] = preset;
farm.ticks = new int24[](0);
return farm;
}

function _makePoolData(
Expand Down
97 changes: 97 additions & 0 deletions script/DeployStrategyGUMF.Base.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

import "forge-std/Script.sol";
import "../src/strategies/GammaUniswapV3MerklFarmStrategy.sol";
import {StrategyDeveloperLib} from "../src/strategies/libs/StrategyDeveloperLib.sol";

contract DeployStrategyGUMFPolygon is Script {
address public constant PLATFORM = 0x7eAeE5CfF17F7765d89F4A46b484256929C62312;
address public constant GAMMA_UNISWAPV3_UNIPROXY = 0xbd8fD52BE2EC689dac9155FAd51774F63a965D99;
address public constant GAMMA_UNISWAPV3_WETH_wstETH_100_PEGGED = 0xbC73A3247Eb976a0A29b22f19E4EBAfa45EfdC65;
address public constant GAMMA_UNISWAPV3_cbETH_WETH_500_PEGGED = 0xa52ECC4ed16f97c71071A3Bd14309E846647d7F0;
address public constant GAMMA_UNISWAPV3_USDC_USDT_100_STABLE = 0x96034EfF74c0D1ba2eCDBf4C09A6FE8FFd6b71c8;
address public constant TOKEN_wstETH = 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452;
address public constant TOKEN_UNI = 0xc3De830EA07524a0761646a6a4e4be0e114a3C83;
address public constant TOKEN_USDC = 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913;
address public constant POOL_UNISWAPV3_USDC_UNI_10000 = 0x35d84AE687f0D3bF8548d5470fd04D2abe74f074;

function run() external {
IFactory factory = IFactory(IPlatform(PLATFORM).factory());
ISwapper swapper = ISwapper(IPlatform(PLATFORM).swapper());
IFactory.Farm[] memory farms = __farms();
ISwapper.AddPoolData[] memory pools = _routes();

uint deployerPrivateKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(deployerPrivateKey);

address implementation = address(new GammaUniswapV3MerklFarmStrategy());

swapper.addPools(pools, false);

factory.addFarms(farms);

factory.setStrategyLogicConfig(
IFactory.StrategyLogicConfig({
id: StrategyIdLib.GAMMA_UNISWAPV3_MERKL_FARM,
implementation: implementation,
deployAllowed: true,
upgradeAllowed: true,
farming: true,
tokenId: type(uint).max
}),
StrategyDeveloperLib.getDeveloper(StrategyIdLib.GAMMA_UNISWAPV3_MERKL_FARM)
);

vm.stopBroadcast();
}

function testDeployBase() external {}

function _routes() internal pure returns (ISwapper.AddPoolData[] memory pools) {
pools = new ISwapper.AddPoolData[](1);
uint i;
pools[i++] = _makePoolData(POOL_UNISWAPV3_USDC_UNI_10000, AmmAdapterIdLib.UNISWAPV3, TOKEN_UNI, TOKEN_USDC);
}

function __farms() internal view returns (IFactory.Farm[] memory _farms) {
_farms = new IFactory.Farm[](3);
uint i;
_farms[i++] =
_makeGammaUniswapV3MerklFarm(GAMMA_UNISWAPV3_cbETH_WETH_500_PEGGED, ALMPositionNameLib.PEGGED, TOKEN_UNI);
_farms[i++] = _makeGammaUniswapV3MerklFarm(
GAMMA_UNISWAPV3_WETH_wstETH_100_PEGGED, ALMPositionNameLib.PEGGED, TOKEN_wstETH
);
_farms[i++] =
_makeGammaUniswapV3MerklFarm(GAMMA_UNISWAPV3_USDC_USDT_100_STABLE, ALMPositionNameLib.STABLE, TOKEN_UNI);
}

function _makeGammaUniswapV3MerklFarm(
address hypervisor,
uint preset,
address rewardAsset
) internal view returns (IFactory.Farm memory) {
IFactory.Farm memory farm;
farm.status = 0;
farm.pool = IHypervisor(hypervisor).pool();
farm.strategyLogicId = StrategyIdLib.GAMMA_UNISWAPV3_MERKL_FARM;
farm.rewardAssets = new address[](1);
farm.rewardAssets[0] = rewardAsset;
farm.addresses = new address[](2);
farm.addresses[0] = GAMMA_UNISWAPV3_UNIPROXY;
farm.addresses[1] = hypervisor;
farm.nums = new uint[](1);
farm.nums[0] = preset;
farm.ticks = new int24[](0);
return farm;
}

function _makePoolData(
address pool,
string memory ammAdapterId,
address tokenIn,
address tokenOut
) internal pure returns (ISwapper.AddPoolData memory) {
return ISwapper.AddPoolData({pool: pool, ammAdapterId: ammAdapterId, tokenIn: tokenIn, tokenOut: tokenOut});
}
}
Loading

0 comments on commit 1ed0641

Please sign in to comment.