Skip to content

Commit

Permalink
fix: move up withdraw limit
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlagonia committed Mar 22, 2024
1 parent 48c6e7d commit 8c2440b
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 46 deletions.
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
[submodule "lib/tokenized-strategy-periphery"]
path = lib/tokenized-strategy-periphery
url = https://github.com/yearn/tokenized-strategy-periphery
branch = master
97 changes: 51 additions & 46 deletions src/Strategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {}
*/

/**
Expand Down

0 comments on commit 8c2440b

Please sign in to comment.