diff --git a/.gitmodules b/.gitmodules index cdd057f6..cf82e815 100644 --- a/.gitmodules +++ b/.gitmodules @@ -12,3 +12,4 @@ [submodule "lib/tokenized-strategy-periphery"] path = lib/tokenized-strategy-periphery url = https://github.com/yearn/tokenized-strategy-periphery + branch = master \ No newline at end of file diff --git a/src/Strategy.sol b/src/Strategy.sol index 72499cd9..a3bb41c4 100644 --- a/src/Strategy.sol +++ b/src/Strategy.sol @@ -118,37 +118,37 @@ contract Strategy is BaseStrategy { //////////////////////////////////////////////////////////////*/ /** - * @dev Optional function for strategist to override that can - * be called in between reports. - * - * If '_tend' is used tendTrigger() will also need to be overridden. - * - * This call can only be called by a permissioned role so may be - * through protected relays. - * - * This can be used to harvest and compound rewards, deposit idle funds, - * perform needed position maintenance or anything else that doesn't need - * a full report for. + * @notice Gets the max amount of `asset` that can be withdrawn. + * @dev Defaults to an unlimited amount for any address. But can + * be overridden by strategists. * - * EX: A strategy that can not deposit funds without getting - * sandwiched can use the tend when a certain threshold - * of idle to totalAssets has been reached. + * This function will be called before any withdraw or redeem to enforce + * any limits desired by the strategist. This can be used for illiquid + * or sandwichable strategies. * - * This will have no effect on PPS of the strategy till report() is called. + * EX: + * return asset.balanceOf(yieldSource); * - * @param _totalIdle The current amount of idle funds that are available to deploy. + * This does not need to take into account the `_owner`'s share balance + * or conversion rates from shares to assets. * - function _tend(uint256 _totalIdle) internal override {} - */ + * @param . The address that is withdrawing from the strategy. + * @return . The available amount that can be withdrawn in terms of `asset` + */ + function availableWithdrawLimit( + address /*_owner*/ + ) public view override returns (uint256) { + // NOTE: Withdraw limitations such as liquidity constraints should be accounted for HERE + // rather than _freeFunds in order to not count them as losses on withdraws. - /** - * @dev Optional trigger to override if tend() will be used by the strategy. - * This must be implemented if the strategy hopes to invoke _tend(). - * - * @return . Should return true if tend() should be called by keeper or false if not. - * - function _tendTrigger() internal view override returns (bool) {} - */ + // TODO: If desired implement withdraw limit logic and any needed state variables. + + // EX: + // if(yieldSource.notShutdown()) { + // return asset.balanceOf(address(this)) + asset.balanceOf(yieldSource); + // } + return asset.balanceOf(address(this)); + } /** * @notice Gets the max amount of `asset` that an address can deposit. @@ -183,31 +183,36 @@ contract Strategy is BaseStrategy { */ /** - * @notice Gets the max amount of `asset` that can be withdrawn. - * @dev Defaults to an unlimited amount for any address. But can - * be overridden by strategists. + * @dev Optional function for strategist to override that can + * be called in between reports. * - * This function will be called before any withdraw or redeem to enforce - * any limits desired by the strategist. This can be used for illiquid - * or sandwichable strategies. + * If '_tend' is used tendTrigger() will also need to be overridden. * - * EX: - * return asset.balanceOf(address(this));; + * This call can only be called by a permissioned role so may be + * through protected relays. * - * This does not need to take into account the `_owner`'s share balance - * or conversion rates from shares to assets. + * This can be used to harvest and compound rewards, deposit idle funds, + * perform needed position maintenance or anything else that doesn't need + * a full report for. * - * @param . The address that is withdrawing from the strategy. - * @return . The available amount that can be withdrawn in terms of `asset` + * EX: A strategy that can not deposit funds without getting + * sandwiched can use the tend when a certain threshold + * of idle to totalAssets has been reached. * - function availableWithdrawLimit( - address _owner - ) public view override returns (uint256) { - TODO: If desired Implement withdraw limit logic and any needed state variables. - - EX: - return asset.balanceOf(address(this)); - } + * This will have no effect on PPS of the strategy till report() is called. + * + * @param _totalIdle The current amount of idle funds that are available to deploy. + * + function _tend(uint256 _totalIdle) internal override {} + */ + + /** + * @dev Optional trigger to override if tend() will be used by the strategy. + * This must be implemented if the strategy hopes to invoke _tend(). + * + * @return . Should return true if tend() should be called by keeper or false if not. + * + function _tendTrigger() internal view override returns (bool) {} */ /**