This plan outlines the steps to address issue #126: Contract: Formal Verification of Flash Loan Logic.
- Harden Flash Loan Logic: Fix potential overflow/underflow issues in fee calculations and repayment checks.
- Formal Verification: Add Kani proofs to verify the correctness of the logic, specifically:
- Overflow/underflow safety.
- Atomic repayment enforcement.
- Absence of reentrancy vulnerabilities (architectural check).
- Replace standard arithmetic with checked arithmetic for fee calculations and repayment checks.
- Ensure the contract handles potential errors gracefully (e.g., panicking on overflow).
- Implement Kani proofs to verify the logic.
- Focus on the
feecalculation and therepaymentlogic.
- Use
kanito prove that the fee calculation never overflows for valid inputs. - Use
kanito prove that the repayment condition correctly enforces that the balance must increase by at least the fee. - Run existing tests to ensure no regressions.
- Harden
lib.rs. - Create
verification.rswith Kani proofs. - Update
Cargo.tomlif needed for Kani dependencies.