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

9 - emergencyWithdraw override function to withdraw funds after strategy shutdown #44

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mcclurejt
Copy link
Contributor

@mcclurejt mcclurejt commented Dec 19, 2024

This pr implements the _emergencyWithdraw strategy hook so that funds can be withdrawn when the strategy is shut down.

The hook transfers all hyperdrive long tokens to the trusted Emergency Admin address so that they can be closed and the proceeds transferred back to the strategy.

issue

@mcclurejt mcclurejt changed the title adds the emergencyWithdraw override function to withdraw funds after strategy shutdown emergencyWithdraw override function to withdraw funds after strategy shutdown Dec 19, 2024
@mcclurejt mcclurejt changed the title emergencyWithdraw override function to withdraw funds after strategy shutdown 9 - emergencyWithdraw override function to withdraw funds after strategy shutdown Dec 19, 2024
/// likelihood of reverts.
function _emergencyWithdraw(uint256) internal override {
IEverlongStrategy.EverlongPosition memory position;
while (!_portfolio.isEmpty()) {
Copy link

@MrToph MrToph Dec 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there might be a lot of open positions and closing them is not cheap. worst case, you can't fit them in a single block. consider just closing positions until at least amount parameter is reached (can still fully close the individual positions, something like while (!empty && closed < amount) { ... closed += bondAmount }. And then change the natspec that amount is actually a bond amount).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants