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

FlashLoan: Allow mango ix after flash loan end #681

Merged
merged 1 commit into from
Aug 18, 2023
Merged

Conversation

ckamm
Copy link
Collaborator

@ckamm ckamm commented Aug 16, 2023

This lifts an unnecessary restriction, making it possible to do things like flash loan and then liquidate with the resulting balances in a single transaction.

The "no mango ix after FlashLoanEnd" limitation was unnecessary: After the flash loan ends, the mango accounts are in a valid state again. And it's impossible to use a two FlashLoanEnd for a single FlashLoanBegin for the same reason that isolated FlashLoanEnds are rejected.

This lifts an unnecessary restriction, making it possible to do things
like flash loan and then liquidate with the resulting balances in a
single transaction.

The "no mango ix after FlashLoanEnd" limitation was unnecessary:
After the flash loan ends, the mango accounts are in a valid state
again. And it's impossible to use a two FlashLoanEnd for a single
FlashLoanBegin for the same reason that isolated FlashLoanEnds are
rejected.
@github-actions github-actions bot added the program On-chain program changes label Aug 16, 2023
@Lou-Kamades
Copy link
Contributor

What's the reason for not allowing any other mango instructions in the middle of a flash loan? Naively, I'd think a major use case would be atomic liquidations like:

  1. take out a flash loan
  2. liquidate someone
  3. swap away the
  4. repay the flash loan

@ckamm
Copy link
Collaborator Author

ckamm commented Aug 18, 2023

@Lou-Kamades Mango instructions during a flash loan make it very hard to reason about the safety. Currently we can be assured that no banks or vaults or accounts change state during the flash loan, simpllifying the flow a lot.

We could relax that, but it'd need significant effort to make sure it's safe.

@ckamm ckamm merged commit cbc96fe into dev Aug 18, 2023
12 of 14 checks passed
@ckamm ckamm deleted the ckamm/flash-loan-post-ix branch August 18, 2023 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
program On-chain program changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants