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

feat: Global delayed insurance withdrawal #246

Open
wants to merge 3 commits into
base: contracts-v2
Choose a base branch
from

Conversation

OsmanBran
Copy link
Contributor

Motivation

Delayed insurance withdrawal should be enforced on all withdrawals to prevent sudden draining of the insurance pool.

When a user wants to withdraw from the pool they should first call intendToWithdraw. They will then have to wait for the cooldown period to elapse (5 days). Then, they will have a window of time to withdraw (2 days). Once this passes they will have to renotify their intent to withdraw before withdrawing.

          ┌───────────────────────────────────┬─────────────────────────┐
          │      `COOLDOWN_PERIOD` 5 days     │ `WITHDRAW_WINDOW` 2 days│
          └───────────────────────────────────┴─────────────────────────┘
           ↑                                               ↑ 
           User calls `intendToWithdraw`        User can call `withdraw`
           User can call `cancelWithdraw` to reset cooldown

Note that there is no on-chain bookkeeping for delayed withdrawals, pool collateral is only updated once the user has called withdraw.

Changes

  • Add intendToWithdraw, cancelWithdraw and update withdraw functions as above
  • Added tests

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.

1 participant