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

Enable async withdrawals on superOETHb #2275

Merged
merged 23 commits into from
Oct 28, 2024
Merged

Conversation

shahthepro
Copy link
Collaborator

@shahthepro shahthepro commented Oct 12, 2024

Changes Overview

  • Removes CLAIM_DELAY constant in favour of a withdrawalClaimDelay variable
  • withdrawalClaimDelay has an hardcoded limit of 10m to 7d (to avoid accidentally or intentionally setting a huge withdrawal claim period)
  • withdrawalClaimDelay can be set to zero to disable async withdrawals. This will prevent users from making any new withdrawal requests. However, they'd be able to claim any pending withdrawals instantly after disabling it

Code Change Checklist

To be completed before internal review begins:

  • The contract code is complete
  • Executable deployment file
  • Fork tests that test after the deployment file runs
  • Unit tests *if needed
  • The owner has done a full checklist review of the code + tests

Internal review:

  • Two approvals by internal reviewers

Copy link

github-actions bot commented Oct 12, 2024

Warnings
⚠️ 👀 This PR needs at least 2 reviewers

Generated by 🚫 dangerJS against b3e4d1d

Copy link

codecov bot commented Oct 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 53.47%. Comparing base (95ece09) to head (b3e4d1d).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2275      +/-   ##
==========================================
+ Coverage   53.26%   53.47%   +0.20%     
==========================================
  Files          79       79              
  Lines        4089     4090       +1     
  Branches     1074     1079       +5     
==========================================
+ Hits         2178     2187       +9     
+ Misses       1908     1900       -8     
  Partials        3        3              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@shahthepro shahthepro marked this pull request as ready for review October 14, 2024 08:19
sparrowDom
sparrowDom previously approved these changes Oct 14, 2024
Copy link
Member

@sparrowDom sparrowDom left a comment

Choose a reason for hiding this comment

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

Left a couple of comments inline. Looks great 👍

contracts/contracts/harvest/FixedRateDripper.sol Outdated Show resolved Hide resolved
contracts/contracts/vault/VaultStorage.sol Outdated Show resolved Hide resolved
contracts/contracts/vault/VaultStorage.sol Show resolved Hide resolved
contracts/test/vault/oethb-vault.base.fork-test.js Outdated Show resolved Hide resolved
naddison36
naddison36 previously approved these changes Oct 16, 2024
Copy link
Collaborator

@naddison36 naddison36 left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -287,12 +288,16 @@ contract OETHVaultCore is VaultCore {
internal
returns (uint256 amount)
{
// Note: When `withdrawalClaimDelay` is set to 0, users can
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we will want to eventualy change the request.timestamp to become an end stamp rather than a start time stamp.

The current code has three awkward things:

  • If we change the claim duration, it retroactively changes the end date of inflight requests.
  • If we disable async claims by setting it to zero, it actually allows instant claims of all inflight claims.
  • If someone wrapped the governance execute() of a zero set, then they could flash loan a mint and a redeem in the same block.

However, our current upgrade on OETH will be atomically setting a value for this in the upgrade, and we don't have to use the zero value for now.

Given that the current zero value is dangerous, how about we also have the require nonzero in the claim? In this way we never accidentally give someone the ability to flashloan an 1:1 mint/redeem. We could then remove it at some future date once we've changed the code to make it safe.

Copy link
Collaborator Author

@shahthepro shahthepro Oct 26, 2024

Choose a reason for hiding this comment

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

I looked at changing request.timestamp to the end time. Looks like there's no space in the WithdrawRequest to fit in the same slot now. If we reuse the existing var on that struct, someone can still wrap our governance execute() and do a flash loan attack. So, yeah, leaving that aside for sometime later makes sense. When we do that change, perhaps we could consider disabling the async withdrawals first (go through governance and execute it) and then doing the upgrade would help avoid the flash loan attacks.

For now, I have changed _claimWithdrawal to revert when it's disabled as well.

However, our current upgrade on OETH will be atomically setting a value for this in the upgrade, and we don't have to use the zero value for now.

This may not be true. We have a deployment file for Base. Not for mainnet. I have excluded that file intentionally since we have other changes to the Vault happening soon (rebasification). I can set a reminder to update the deployment file in those PRs to reset the withdrawalClaimDelay to 10 minutes (current value)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agree on disabling withdraws right before the upgrade.

@shahthepro shahthepro merged commit f484add into master Oct 28, 2024
15 of 18 checks passed
@shahthepro shahthepro deleted the shah/oethb-async-withdrawal branch October 28, 2024 07:16
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.

4 participants