mrgnlabs / marginfi-v2

Apache License 2.0
150 stars 65 forks source link

Flashloans #121

Closed jkbpvsc closed 8 months ago

jkbpvsc commented 1 year ago

Flashloans

How they work

Flashloans work by deferring health checks for an account to the end of the flashloan. This is achieved with two new instructions. flashloan_start and flashloan_end.

Security checklist

  1. end_flashloan ix index is after start_flashloan ix index
  2. Ixs has an end_flashloan ix present
  3. end_flashloan ix is for the marginfi program
  4. end_flashloan ix is for the same marginfi account
  5. Account is not disabled
  6. Account is not already in a flashloan

Considerations

jkbpvsc commented 12 months ago

One consideration I'm having is if we should have all the borrows and repays happen in the fl_start and fl_end ixs, to prevent any unexpected combinations of flashloan ixs and bank state updates. Thoughts @losman0s?