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

More flexible flashloan health check #213

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

Conversation

cavemanloverboy
Copy link
Contributor

@cavemanloverboy cavemanloverboy commented Jun 4, 2024

Summary

With these changes, a flashloan can be initialized regardless of account health. However, a flashloan can only be finalized if one of following conditions are true:

  1. The account is in good health
  2. The account is in bad health and the health at the end of the flashloan has improved from the beginning of the flashloan.

Note that we don't simply check if health improved. as users should be allowed to worsen their health in case 1 so long as their account started and ended in good health. To facilitate the check in 2), 16 bytes have been taken from the marginfi account padding to store the account health at the start of the flashloan.

Testing

This PR adds two tests for flashloans for accounts that begin in bad health:

  1. SUCCESS test case where a user with a marginfi account in bad health does not worsen its health during a flashloan
  2. FAILURE test case where a user with a marginfi account in bad health worsens its health during a flashloan

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