Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

24.05.0-alpha; ERC4626StrategyBase, YearnStrategy, StrategyBase 1.1.0 #116

Merged
merged 20 commits into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion chains/PolygonLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ library PolygonLib {
address public constant POOL_UNISWAPV3_USDCe_WETH_500 = 0x45dDa9cb7c25131DF268515131f647d726f50608;
address public constant POOL_UNISWAPV3_PROFIT_WETH_100 = 0xE5e70cb76446BEE0053b1EdF22CaDa861c80D51F;
address public constant POOL_UNISWAPV3_WETH_COMP_3000 = 0x2260E0081A2A042DC55A07D379eb3c18bE28A1F2;
address public constant POOL_UNISWAPV3_WMATIC_COMP_3000 = 0x495b3576e2f67fa870e14d0996433FbdB4015794;
address public constant POOL_QUICKSWAPV3_USDCe_USDT = 0x7B925e617aefd7FB3a93Abe3a701135D7a1Ba710;
address public constant POOL_QUICKSWAPV3_USDCe_DAI = 0xe7E0eB9F6bCcCfe847fDf62a3628319a092F11a2;
address public constant POOL_QUICKSWAPV3_USDCe_WETH = 0x55CAaBB0d2b704FD0eF8192A7E35D8837e678207;
Expand Down Expand Up @@ -153,6 +154,13 @@ library PolygonLib {
address public constant CONVEX_REWARD_POOL_crvUSD_DAI = 0xaCb744c7e7C95586DB83Eda3209e6483Fb1FCbA4;
address public constant CONVEX_REWARD_POOL_crvUSD_USDC = 0x11F2217fa1D5c44Eae310b9b985E2964FC47D8f9;

// Yearn V3
address public constant YEARN_DAI = 0x90b2f54C6aDDAD41b8f6c4fCCd555197BC0F773B;
address public constant YEARN_USDT = 0xBb287E6017d3DEb0e2E65061e8684eab21060123;
address public constant YEARN_USDCe = 0xA013Fbd4b711f9ded6fB09C1c0d358E2FbC2EAA0;
address public constant YEARN_WMATIC = 0x28F53bA70E5c8ce8D03b1FaD41E9dF11Bb646c36;
address public constant YEARN_WETH = 0x305F25377d0a39091e99B975558b1bdfC3975654;

function runDeploy(bool showLog) internal returns (address platform) {
//region ----- DeployPlatform -----
uint[] memory buildingPrice = new uint[](3);
Expand Down Expand Up @@ -281,6 +289,7 @@ library PolygonLib {
DeployStrategyLib.deployStrategy(platform, StrategyIdLib.ICHI_RETRO_MERKL_FARM, true);
DeployStrategyLib.deployStrategy(platform, StrategyIdLib.GAMMA_RETRO_MERKL_FARM, true);
DeployStrategyLib.deployStrategy(platform, StrategyIdLib.CURVE_CONVEX_FARM, true);
DeployStrategyLib.deployStrategy(platform, StrategyIdLib.YEARN, false);
DeployLib.logDeployStrategies(platform, showLog);
//endregion -- Deploy strategy logics -----

Expand Down Expand Up @@ -736,7 +745,10 @@ library PolygonLib {
_farms[i++] = _makeCurveConvexFarm(POOL_CURVE_crvUSD_USDC, CONVEX_REWARD_POOL_crvUSD_USDC);
}

function _makeCurveConvexFarm(address curvePool, address convexRewardPool) internal view returns (IFactory.Farm memory) {
function _makeCurveConvexFarm(
address curvePool,
address convexRewardPool
) internal view returns (IFactory.Farm memory) {
IFactory.Farm memory farm;
uint rewardTokensLength = IConvexRewardPool(convexRewardPool).rewardLength();
farm.status = 0;
Expand Down
5 changes: 5 additions & 0 deletions script/libs/DeployStrategyLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import "../../src/strategies/IchiQuickSwapMerklFarmStrategy.sol";
import "../../src/strategies/IchiRetroMerklFarmStrategy.sol";
import "../../src/strategies/GammaRetroMerklFarmStrategy.sol";
import "../../src/strategies/CurveConvexFarmStrategy.sol";
import "../../src/strategies/YearnStrategy.sol";
import "../../src/strategies/libs/StrategyDeveloperLib.sol";

library DeployStrategyLib {
Expand Down Expand Up @@ -59,6 +60,10 @@ library DeployStrategyLib {
implementation = address(new CurveConvexFarmStrategy());
}

if (CommonLib.eq(id, StrategyIdLib.YEARN)) {
implementation = address(new YearnStrategy());
}

// nosemgrep
require(implementation != address(0), "DeployStrategyLib: unknown strategy");

Expand Down
6 changes: 4 additions & 2 deletions src/core/Factory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import "../interfaces/IStrategyLogic.sol";

/// @notice Platform factory assembling vaults. Stores vault settings, strategy logic, farms.
/// Provides the opportunity to upgrade vaults and strategies.
/// Changelog:
/// 1.1.0: getDeploymentKey fix for not farming strategies
/// @author Alien Deployer (https://github.com/a17)
/// @author Jude (https://github.com/iammrjude)
/// @author JodsMigel (https://github.com/JodsMigel)
Expand All @@ -31,7 +33,7 @@ contract Factory is Controllable, ReentrancyGuardUpgradeable, IFactory {
//region ----- Constants -----

/// @inheritdoc IControllable
string public constant VERSION = "1.0.3";
string public constant VERSION = "1.1.0";

uint internal constant _WEEK = 60 * 60 * 24 * 7;

Expand Down Expand Up @@ -536,7 +538,7 @@ contract Factory is Controllable, ReentrancyGuardUpgradeable, IFactory {
initStrategyAddresses,
initStrategyNums,
initStrategyTicks,
[1, 0, 0, 1, 0]
[1, 0, 1, 1, 0]
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/libs/FactoryLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ library FactoryLib {
vars.strategyInitAddresses,
vars.strategyInitNums,
vars.strategyInitTicks,
[1, 0, 0, 1, 0]
[1, 0, 1, 1, 0]
);

if (factory.deploymentKey(_deploymentKey) == address(0)) {
Expand Down Expand Up @@ -293,7 +293,7 @@ library FactoryLib {
vars.strategyInitAddresses,
vars.strategyInitNums,
vars.strategyInitTicks,
[1, 0, 0, 1, 0]
[1, 0, 1, 1, 0]
);

if (factory.deploymentKey(_deploymentKey) == address(0)) {
Expand Down
5 changes: 4 additions & 1 deletion src/interfaces/IStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ interface IStrategy is IERC165 {
view
returns (string[] memory variants, address[] memory addresses, uint[] memory nums, int24[] memory ticks);

/// @notice How strategy earns money
/// @notice How does the strategy make money?
/// @return Description in free form
function description() external view returns (string memory);

Expand All @@ -147,6 +147,9 @@ interface IStrategy is IERC165 {
/// @notice Is HardWork can be executed
function isReadyForHardWork() external view returns (bool);

/// @notice Strategy not need to compound revenue on HardWorks
function autoCompoundingByUnderlyingProtocol() external view returns (bool);

/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* WRITE FUNCTIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
Expand Down
76 changes: 76 additions & 0 deletions src/strategies/YearnStrategy.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

import "./libs/StrategyIdLib.sol";
import "./base/ERC4626StrategyBase.sol";

/// @title Hodl Yearn V3 multi ERC4626 vault, emit revenue, collect fees and show underlying protocols
/// @author Alien Deployer (https://github.com/a17)
contract YearnStrategy is ERC4626StrategyBase {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CONSTANTS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

/// @inheritdoc IControllable
string public constant VERSION = "1.0.0";

/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* INITIALIZATION */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

/// @inheritdoc IStrategy
function initialize(address[] memory addresses, uint[] memory nums, int24[] memory ticks) public initializer {
if (addresses.length != 3 || nums.length != 0 || ticks.length != 0) {
revert IControllable.IncorrectInitParams();

Check warning on line 24 in src/strategies/YearnStrategy.sol

View check run for this annotation

Codecov / codecov/patch

src/strategies/YearnStrategy.sol#L24

Added line #L24 was not covered by tests
}

__ERC4626StrategyBase_init(StrategyIdLib.YEARN, addresses[0], addresses[1], addresses[2]);
}

/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* VIEW FUNCTIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

/// @inheritdoc IStrategy
function description() external pure returns (string memory) {
// todo protocols
return "todo";
}

/// @inheritdoc IStrategy
function extra() external pure returns (bytes32) {
//slither-disable-next-line too-many-digits
return CommonLib.bytesToBytes32(abi.encodePacked(bytes3(0xdc568a), bytes3(0x000000)));
}

/// @inheritdoc IStrategy
function getSpecificName() external pure override returns (string memory, bool) {
// todo concat protocols
return ("", false);
}

/// @inheritdoc IStrategy
function initVariants(address platform_)
public
view
returns (string[] memory variants, address[] memory addresses, uint[] memory nums, int24[] memory ticks)
{
// todo construct storage for allowed yaern v3 vaults
}

/// @inheritdoc IStrategy
function isHardWorkOnDepositAllowed() external pure returns (bool) {
return true;
}

/// @inheritdoc IStrategy
function isReadyForHardWork() external pure returns (bool isReady) {
// todo ready if share price of yaern vault increased
isReady = true;
}

/// @inheritdoc IStrategy
function strategyLogicId() public pure override returns (string memory) {
return StrategyIdLib.YEARN;
}
}
Loading
Loading