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

fix: move up available withdraw limit #28

Merged
merged 4 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
path = lib/tokenized-strategy
url = https://github.com/yearn/tokenized-strategy
release = v3.0.2
[submodule "lib/tokenized-strategy-periphery"]
path = lib/tokenized-strategy-periphery
url = https://github.com/yearn/tokenized-strategy-periphery
release = v3.0.2
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[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 @@ -43,7 +43,7 @@
* @param _amount The amount of 'asset' that the strategy can attempt
* to deposit in the yield source.
*/
function _deployFunds(uint256 _amount) internal override {

Check warning on line 46 in src/Strategy.sol

View workflow job for this annotation

GitHub Actions / solidity

Code contains empty blocks
// TODO: implement deposit logic EX:
//
// lendingPool.deposit(address(asset), _amount ,0);
Expand All @@ -70,7 +70,7 @@
*
* @param _amount, The amount of 'asset' to be freed.
*/
function _freeFunds(uint256 _amount) internal override {

Check warning on line 73 in src/Strategy.sol

View workflow job for this annotation

GitHub Actions / solidity

Code contains empty blocks
// TODO: implement withdraw logic EX:
//
// lendingPool.withdraw(address(asset), _amount);
Expand Down Expand Up @@ -118,37 +118,37 @@
//////////////////////////////////////////////////////////////*/

/**
* @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 @@
*/

/**
* @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
Loading