Skip to content

Implement a Flash Loan module with strict post-execution balance invariant assertions #480

Description

@Damola-Sodiq

Description

Develop a feature to allow intra-transaction, zero-collateral borrowing of the vault's fractional liquidity, secured entirely by deterministic mathematical proofs.

Architecture & Context

To facilitate efficient market arbitrage across fractional token pools, traders need access to flash liquidity. The contract will release the requested funds, execute the borrower's custom callback contract, and strictly verify that balance_after >= balance_before + fee before resolving.

Technical Requirements

  • Utilize env.invoke_contract to execute the untrusted external callback securely.
  • Cache the pre-execution vault balances in protected memory variables.
  • Force an uncatchable panic if the post-execution balance delta is negative.

Acceptance Criteria

  • Flash loans execute successfully for compliant arbitrage contracts.
  • Non-compliant or malicious callbacks result in complete state reversion.
  • Flash loan fees are securely credited to the fractional asset holders.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions