Skip to content

Issue 152: defi: Build the formal Flash Loan callback interface #99

@AlAfiz

Description

@AlAfiz

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 FlashLoanReceiver trait that external borrower contracts must implement.
  • Update the flash_loan function 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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions