-
Notifications
You must be signed in to change notification settings - Fork 33
Issue 152: defi: Build the formal Flash Loan callback interface #99
Copy link
Copy link
Open
Labels
Description
Description
We previously scaffolded the fee for flash loans, but to actually execute them, we need a standard cross-contract callback interface.
When a borrower requests a flash loan, our contract must send them the tokens, and then immediately call a specific execute_operation function on their smart contract.
If their contract fails to return the principal plus the fee by the end of that specific call, our contract must panic and revert the entire ledger state.
This is complex, synchronous DeFi architecture that requires deep knowledge of Soroban's cross-contract invocation.
Requirements
- Define a
FlashLoanReceivertrait that external borrower contracts must implement. - Update the
flash_loanfunction to transfer the requested tokens to the borrower's address. - Use
env.invoke_contract()to trigger the borrower's callback function. - Assert that the pool's token balance after the callback is
>=the balance before the loan + the flash loan fee.
Reactions are currently unavailable