diff --git a/src/interfaces/IStrategy.sol b/src/interfaces/IStrategy.sol index 8b7d0a2b..f1de554b 100644 --- a/src/interfaces/IStrategy.sol +++ b/src/interfaces/IStrategy.sol @@ -138,6 +138,9 @@ interface IStrategy is IERC165 { /// @notice Is HardWork on vault deposits can be enabled function isHardWorkOnDepositAllowed() external view returns (bool); + /// @notice Is HardWork can be executed + function isReadyForHardWork() external view returns (bool); + /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* WRITE FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ diff --git a/src/strategies/CompoundFarmStrategy.sol b/src/strategies/CompoundFarmStrategy.sol index 8dc62e0f..08e56841 100644 --- a/src/strategies/CompoundFarmStrategy.sol +++ b/src/strategies/CompoundFarmStrategy.sol @@ -155,6 +155,11 @@ contract CompoundFarmStrategy is FarmingStrategyBase { return true; } + /// @inheritdoc IStrategy + function isReadyForHardWork() external pure returns (bool isReady) { + isReady = true; + } + /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* FARMING STRATEGY BASE */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ diff --git a/src/strategies/DefiEdgeQuickSwapMerklFarmStrategy.sol b/src/strategies/DefiEdgeQuickSwapMerklFarmStrategy.sol index e22b2b70..19975372 100644 --- a/src/strategies/DefiEdgeQuickSwapMerklFarmStrategy.sol +++ b/src/strategies/DefiEdgeQuickSwapMerklFarmStrategy.sol @@ -175,6 +175,12 @@ contract DefiEdgeQuickSwapMerklFarmStrategy is LPStrategyBase, FarmingStrategyBa /// @inheritdoc IStrategy function isHardWorkOnDepositAllowed() external pure returns (bool allowed) {} + /// @inheritdoc IStrategy + function isReadyForHardWork() external view returns (bool) { + FarmingStrategyBaseStorage storage _$_ = _getFarmingStrategyBaseStorage(); + return StrategyLib.assetsAreOnBalance(_$_._rewardAssets); + } + /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* STRATEGY BASE */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ diff --git a/src/strategies/GammaQuickSwapMerklFarmStrategy.sol b/src/strategies/GammaQuickSwapMerklFarmStrategy.sol index 465453ce..95863094 100644 --- a/src/strategies/GammaQuickSwapMerklFarmStrategy.sol +++ b/src/strategies/GammaQuickSwapMerklFarmStrategy.sol @@ -184,6 +184,12 @@ contract GammaQuickSwapMerklFarmStrategy is LPStrategyBase, FarmingStrategyBase /// @inheritdoc IStrategy function isHardWorkOnDepositAllowed() external pure returns (bool allowed) {} + /// @inheritdoc IStrategy + function isReadyForHardWork() external view returns (bool) { + FarmingStrategyBaseStorage storage _$_ = _getFarmingStrategyBaseStorage(); + return StrategyLib.assetsAreOnBalance(_$_._rewardAssets); + } + /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* STRATEGY BASE */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ diff --git a/src/strategies/IchiQuickSwapMerklFarmStrategy.sol b/src/strategies/IchiQuickSwapMerklFarmStrategy.sol index 0627b6c0..8e618bf3 100644 --- a/src/strategies/IchiQuickSwapMerklFarmStrategy.sol +++ b/src/strategies/IchiQuickSwapMerklFarmStrategy.sol @@ -168,6 +168,12 @@ contract IchiQuickSwapMerklFarmStrategy is LPStrategyBase, FarmingStrategyBase { /// @inheritdoc IStrategy function isHardWorkOnDepositAllowed() external pure returns (bool allowed) {} + /// @inheritdoc IStrategy + function isReadyForHardWork() external view returns (bool) { + FarmingStrategyBaseStorage storage _$_ = _getFarmingStrategyBaseStorage(); + return StrategyLib.assetsAreOnBalance(_$_._rewardAssets); + } + /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* STRATEGY BASE */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ diff --git a/src/strategies/IchiRetroMerklFarmStrategy.sol b/src/strategies/IchiRetroMerklFarmStrategy.sol index fed9aafd..7db2188c 100644 --- a/src/strategies/IchiRetroMerklFarmStrategy.sol +++ b/src/strategies/IchiRetroMerklFarmStrategy.sol @@ -168,6 +168,12 @@ contract IchiRetroMerklFarmStrategy is LPStrategyBase, FarmingStrategyBase { /// @inheritdoc IStrategy function isHardWorkOnDepositAllowed() external pure returns (bool allowed) {} + /// @inheritdoc IStrategy + function isReadyForHardWork() external view returns (bool) { + FarmingStrategyBaseStorage storage _$_ = _getFarmingStrategyBaseStorage(); + return StrategyLib.assetsAreOnBalance(_$_._rewardAssets); + } + /// @dev this special method used to fix forge coverage issue function t() external pure returns (bool) { return true; diff --git a/src/strategies/QuickswapV3StaticFarmStrategy.sol b/src/strategies/QuickswapV3StaticFarmStrategy.sol index 7952bafd..d15e07f0 100644 --- a/src/strategies/QuickswapV3StaticFarmStrategy.sol +++ b/src/strategies/QuickswapV3StaticFarmStrategy.sol @@ -220,6 +220,11 @@ contract QuickSwapV3StaticFarmStrategy is LPStrategyBase, FarmingStrategyBase { return false; } + /// @inheritdoc IStrategy + function isReadyForHardWork() external pure returns (bool isReady) { + isReady = true; + } + /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* STRATEGY BASE */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ diff --git a/src/strategies/libs/StrategyLib.sol b/src/strategies/libs/StrategyLib.sol index 86d97d01..847e7b4f 100644 --- a/src/strategies/libs/StrategyLib.sol +++ b/src/strategies/libs/StrategyLib.sol @@ -213,6 +213,16 @@ library StrategyLib { } } + function assetsAreOnBalance(address[] memory assets) external view returns (bool isReady) { + uint rwLen = assets.length; + for (uint i; i < rwLen; ++i) { + if (IERC20(assets[i]).balanceOf(address(this)) > 0) { + isReady = true; + break; + } + } + } + // function getFarmsForStrategyId(address platform, string memory _id) external view returns (IFactory.Farm[] memory farms) { // uint total; // IFactory.Farm[] memory allFarms = IFactory(IPlatform(platform).factory()).farms(); diff --git a/src/test/MockStrategy.sol b/src/test/MockStrategy.sol index 4a0eb0ff..bca8ade1 100644 --- a/src/test/MockStrategy.sol +++ b/src/test/MockStrategy.sol @@ -55,6 +55,11 @@ contract MockStrategy is LPStrategyBase { return true; } + /// @inheritdoc IStrategy + function isReadyForHardWork() external pure returns (bool isReady) { + isReady = true; + } + function initVariants(address) public pure diff --git a/test/base/UniversalTest.sol b/test/base/UniversalTest.sol index f4b97681..0919ce58 100644 --- a/test/base/UniversalTest.sol +++ b/test/base/UniversalTest.sol @@ -387,6 +387,7 @@ abstract contract UniversalTest is Test, ChainSetup, Utils { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* HARDWORK 0 */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ + assertEq(strategy.isReadyForHardWork(), true); vm.txGasPrice(15e10); // 150gwei { vars.apr = 0;