@@ -4,17 +4,32 @@ pragma solidity ^0.8.23;
44import "../src/core/proxy/Proxy.sol " ;
55import "../src/adapters/libs/AmmAdapterIdLib.sol " ;
66import "../src/adapters/ChainlinkAdapter.sol " ;
7- import "../src/strategies/libs/StrategyIdLib.sol " ;
8- import "../src/strategies/libs/ALMPositionNameLib.sol " ;
97import "../src/interfaces/IFactory.sol " ;
108import "../src/interfaces/IPlatform.sol " ;
119import "../src/interfaces/ISwapper.sol " ;
10+ import "../src/interfaces/IPlatformDeployer.sol " ;
1211import "../src/integrations/convex/IConvexRewardPool.sol " ;
13- import "../script/libs/DeployLib .sol " ;
12+ import "../script/libs/LogDeployLib .sol " ;
1413import "../script/libs/DeployAdapterLib.sol " ;
15- import "../script/libs/DeployStrategyLib.sol " ;
16-
17- /// @dev Addresses, routes, farms, strategy logics, reward tokens, deploy function and other data for Polygon network
14+ import "../src/strategies/libs/StrategyIdLib.sol " ;
15+ import "../src/strategies/libs/ALMPositionNameLib.sol " ;
16+ import "../src/strategies/libs/StrategyDeveloperLib.sol " ;
17+ import "../src/strategies/GammaQuickSwapMerklFarmStrategy.sol " ;
18+ import "../src/strategies/QuickSwapStaticMerklFarmStrategy.sol " ;
19+ import "../src/strategies/CompoundFarmStrategy.sol " ;
20+ import "../src/strategies/DefiEdgeQuickSwapMerklFarmStrategy.sol " ;
21+ import "../src/strategies/IchiQuickSwapMerklFarmStrategy.sol " ;
22+ import "../src/strategies/IchiRetroMerklFarmStrategy.sol " ;
23+ import "../src/strategies/GammaRetroMerklFarmStrategy.sol " ;
24+ import "../src/strategies/CurveConvexFarmStrategy.sol " ;
25+ import "../src/strategies/YearnStrategy.sol " ;
26+
27+ /// @dev Polygon network [chainId: 137] data library
28+ /// ┏┓ ┓
29+ /// ┃┃┏┓┃┓┏┏┓┏┓┏┓
30+ /// ┣┛┗┛┗┗┫┗┫┗┛┛┗
31+ /// ┛ ┛
32+ /// @author Alien Deployer (https://github.com/a17)
1833library PolygonLib {
1934 // initial addresses
2035 address public constant MULTISIG = 0x36780E69D38c8b175761c6C5F8eD42E61ee490E9 ; // team
@@ -171,30 +186,34 @@ library PolygonLib {
171186 // Merkl
172187 address public constant MERKL_DISTRIBUTOR = 0x3Ef3D8bA38EBe18DB133cEc108f4D14CE00Dd9Ae ;
173188
174- function runDeploy (bool showLog ) internal returns (address platform ) {
175- //region ----- Deploy Platform -----
176- uint [] memory buildingPrice = new uint [](3 );
177- buildingPrice[0 ] = 50_000e18 ;
178- buildingPrice[1 ] = 50_000e18 ;
179- buildingPrice[2 ] = 100_000e18 ;
180- platform = DeployLib.deployPlatform (
181- "24.06.0-alpha " ,
182- MULTISIG,
183- TOKEN_PM,
184- TOKEN_SDIV,
185- buildingPrice,
186- "Polygon " ,
187- CommonLib.bytesToBytes32 (abi.encodePacked (bytes3 (0x7746d7 ), bytes3 (0x040206 ))),
188- TOKEN_USDCe,
189- GELATO_AUTOMATE,
190- 1e18 ,
191- 2e18
192- );
189+ function platformDeployParams () internal pure returns (IPlatformDeployer.DeployPlatformParams memory p ) {
190+ p.multisig = MULTISIG;
191+ p.version = "24.06.0-alpha " ;
192+ p.buildingPermitToken = TOKEN_PM;
193+ p.buildingPayPerVaultToken = TOKEN_SDIV;
194+ p.networkName = "Polygon " ;
195+ p.networkExtra = CommonLib.bytesToBytes32 (abi.encodePacked (bytes3 (0x7746d7 ), bytes3 (0x040206 )));
196+ p.targetExchangeAsset = TOKEN_USDCe;
197+ p.gelatoAutomate = GELATO_AUTOMATE;
198+ p.gelatoMinBalance = 1e18 ;
199+ p.gelatoDepositAmount = 2e18 ;
200+ }
201+
202+ function deployAndSetupInfrastructure (address platform , bool showLog ) internal {
203+ IFactory factory = IFactory (IPlatform (platform).factory ());
204+
205+ //region ----- Deployed Platform -----
193206 if (showLog) {
194207 console.log ("Deployed Stability platform " , IPlatform (platform).platformVersion ());
195208 console.log ("Platform address: " , platform);
196209 }
197- //endregion -- Deploy Platform ----
210+ //endregion -- Deployed Platform ----
211+
212+ //region ----- Deploy and setup vault types -----
213+ _addVaultType (factory, VaultTypeLib.COMPOUNDING, address (new CVault ()), 50_000e18 );
214+ _addVaultType (factory, VaultTypeLib.REWARDING, address (new RVault ()), 50_000e18 );
215+ _addVaultType (factory, VaultTypeLib.REWARDING_MANAGED, address (new RMVault ()), 100_000e18 );
216+ //endregion -- Deploy and setup vault types -----
198217
199218 //region ----- Deploy and setup oracle adapters -----
200219 IPriceReader priceReader = PriceReader (IPlatform (platform).priceReader ());
@@ -214,7 +233,7 @@ library PolygonLib {
214233 priceFeeds[2 ] = ORACLE_CHAINLINK_DAI_USD;
215234 chainlinkAdapter.addPriceFeeds (assets, priceFeeds);
216235 priceReader.addAdapter (address (chainlinkAdapter));
217- DeployLib .logDeployAndSetupOracleAdapter ("ChainLink " , address (chainlinkAdapter), showLog);
236+ LogDeployLib .logDeployAndSetupOracleAdapter ("ChainLink " , address (chainlinkAdapter), showLog);
218237 }
219238 //endregion -- Deploy and setup oracle adapters -----
220239
@@ -223,7 +242,7 @@ library PolygonLib {
223242 DeployAdapterLib.deployAmmAdapter (platform, AmmAdapterIdLib.ALGEBRA);
224243 DeployAdapterLib.deployAmmAdapter (platform, AmmAdapterIdLib.KYBER);
225244 DeployAdapterLib.deployAmmAdapter (platform, AmmAdapterIdLib.CURVE);
226- DeployLib .logDeployAmmAdapters (platform, showLog);
245+ LogDeployLib .logDeployAmmAdapters (platform, showLog);
227246 //endregion -- Deploy AMM adapters ----
228247
229248 //region ----- Setup Swapper -----
@@ -256,12 +275,11 @@ library PolygonLib {
256275 thresholdAmount[8 ] = 1e15 ;
257276 thresholdAmount[9 ] = 1e15 ;
258277 swapper.setThresholds (tokenIn, thresholdAmount);
259- DeployLib .logSetupSwapper (platform, showLog);
278+ LogDeployLib .logSetupSwapper (platform, showLog);
260279 }
261280 //endregion -- Setup Swapper -----
262281
263282 //region ----- Add farms -----
264- IFactory factory = IFactory (IPlatform (platform).factory ());
265283 factory.addFarms (farms ());
266284 // Jan-09-2024
267285 if (block .number > 52122638 ) {
@@ -271,7 +289,7 @@ library PolygonLib {
271289 if (block .number > 54573098 ) {
272290 factory.addFarms (farms3 ());
273291 }
274- DeployLib .logAddedFarms (address (factory), showLog);
292+ LogDeployLib .logAddedFarms (address (factory), showLog);
275293 //endregion -- Add farms -----
276294
277295 //region ----- Add strategy available init params -----
@@ -296,20 +314,20 @@ library PolygonLib {
296314 defaultBoostRewardToken[0 ] = TOKEN_PROFIT;
297315 defaultBoostRewardToken[1 ] = TOKEN_USDCe;
298316 IPlatform (platform).addBoostTokens (allowedBoostRewardToken, defaultBoostRewardToken);
299- DeployLib .logSetupRewardTokens (platform, showLog);
317+ LogDeployLib .logSetupRewardTokens (platform, showLog);
300318 //endregion -- Reward tokens -----
301319
302320 //region ----- Deploy strategy logics -----
303- DeployStrategyLib. deployStrategy (platform , StrategyIdLib.GAMMA_QUICKSWAP_MERKL_FARM, true );
304- DeployStrategyLib. deployStrategy (platform , StrategyIdLib.QUICKSWAP_STATIC_MERKL_FARM, true );
305- DeployStrategyLib. deployStrategy (platform , StrategyIdLib.COMPOUND_FARM, true );
306- DeployStrategyLib. deployStrategy (platform , StrategyIdLib.DEFIEDGE_QUICKSWAP_MERKL_FARM, true );
307- DeployStrategyLib. deployStrategy (platform , StrategyIdLib.ICHI_QUICKSWAP_MERKL_FARM, true );
308- DeployStrategyLib. deployStrategy (platform , StrategyIdLib.ICHI_RETRO_MERKL_FARM, true );
309- DeployStrategyLib. deployStrategy (platform , StrategyIdLib.GAMMA_RETRO_MERKL_FARM, true );
310- DeployStrategyLib. deployStrategy (platform , StrategyIdLib.CURVE_CONVEX_FARM, true );
311- DeployStrategyLib. deployStrategy (platform , StrategyIdLib.YEARN, false );
312- DeployLib .logDeployStrategies (platform, showLog);
321+ _addStrategyLogic (factory , StrategyIdLib.GAMMA_QUICKSWAP_MERKL_FARM, address ( new GammaQuickSwapMerklFarmStrategy ()) , true );
322+ _addStrategyLogic (factory , StrategyIdLib.QUICKSWAP_STATIC_MERKL_FARM, address ( new QuickSwapStaticMerklFarmStrategy ()) , true );
323+ _addStrategyLogic (factory , StrategyIdLib.COMPOUND_FARM, address ( new CompoundFarmStrategy ()) , true );
324+ _addStrategyLogic (factory , StrategyIdLib.DEFIEDGE_QUICKSWAP_MERKL_FARM, address ( new DefiEdgeQuickSwapMerklFarmStrategy ()) , true );
325+ _addStrategyLogic (factory , StrategyIdLib.ICHI_QUICKSWAP_MERKL_FARM, address ( new IchiQuickSwapMerklFarmStrategy ()) , true );
326+ _addStrategyLogic (factory , StrategyIdLib.ICHI_RETRO_MERKL_FARM, address ( new IchiRetroMerklFarmStrategy ()) , true );
327+ _addStrategyLogic (factory , StrategyIdLib.GAMMA_RETRO_MERKL_FARM, address ( new GammaRetroMerklFarmStrategy ()) , true );
328+ _addStrategyLogic (factory , StrategyIdLib.CURVE_CONVEX_FARM, address ( new CurveConvexFarmStrategy ()) , true );
329+ _addStrategyLogic (factory , StrategyIdLib.YEARN, address ( new YearnStrategy ()) , false );
330+ LogDeployLib .logDeployStrategies (platform, showLog);
313331 //endregion -- Deploy strategy logics -----
314332
315333 //region ----- Add DeX aggregators -----
@@ -619,5 +637,31 @@ library PolygonLib {
619637 return ISwapper.AddPoolData ({pool: pool, ammAdapterId: ammAdapterId, tokenIn: tokenIn, tokenOut: tokenOut});
620638 }
621639
640+ function _addVaultType (IFactory factory , string memory id , address implementation , uint buildingPrice ) internal {
641+ factory.setVaultConfig (
642+ IFactory.VaultConfig ({
643+ vaultType: id,
644+ implementation: implementation,
645+ deployAllowed: true ,
646+ upgradeAllowed: true ,
647+ buildingPrice: buildingPrice
648+ })
649+ );
650+ }
651+
652+ function _addStrategyLogic (IFactory factory , string memory id , address implementation , bool farming ) internal {
653+ factory.setStrategyLogicConfig (
654+ IFactory.StrategyLogicConfig ({
655+ id: id,
656+ implementation: address (implementation),
657+ deployAllowed: true ,
658+ upgradeAllowed: true ,
659+ farming: farming,
660+ tokenId: type (uint ).max
661+ }),
662+ StrategyDeveloperLib.getDeveloper (id)
663+ );
664+ }
665+
622666 function testPolygonLib () external {}
623667}
0 commit comments