Skip to main content

Overview

This guide will help you quickly build, test, and understand the Flash-Loan Router. You’ll compile the contracts, run the test suite, and learn the basic commands you’ll use during development.
Make sure you’ve completed the installation steps before proceeding.

Building the Project

1

Navigate to the project directory

cd flash-loan-router
2

Compile the contracts

Build all smart contracts using Forge:
forge build
This command:
  • Compiles all Solidity files in the src/ directory
  • Generates artifacts in the out/ directory
  • Uses the configuration from foundry.toml
Expected output:
[⠊] Compiling...
[⠒] Compiling 25 files with 0.8.28
[⠒] Solc 0.8.28 finished in 3.45s
Compiler run successful!

Running Tests

1

Run the full test suite

Execute all tests with Forge:
forge test
This runs all tests in the test/ directory and generates gas snapshots.
2

Run tests without internet connection

If you want to skip end-to-end tests that require RPC access:
forge test --no-match-path 'test/e2e/**/*'
E2E tests interact with live networks to test flash-loan integrations with Aave and ERC-3156 compatible lenders.
3

Run tests with verbosity

For detailed output including console logs:
forge test -vvv
Verbosity levels:
  • -v: Show test results
  • -vv: Show console logs
  • -vvv: Show execution traces
  • -vvvv: Show execution traces with stack
4

Run specific tests

Test a specific contract or function:
# Test a specific contract
forge test --match-contract FlashLoanRouterTest

# Test a specific function
forge test --match-test test_flashLoanAndSettle

Understanding Test Isolation

The project uses Foundry’s isolate feature:
# In foundry.toml
isolate = true
This ensures transient storage is cleared between each call in a test function, providing better control over state management.

Gas Benchmarking

The repository includes gas benchmarking for different flash-loan providers:
forge test
Gas snapshots are automatically generated in the snapshots/ directory, allowing you to:
  • Compare gas costs between different flash-loan providers
  • Track gas changes between code modifications
  • Optimize contract performance

Code Formatting

1

Check code formatting

Verify that your code follows the project’s style:
forge fmt --check
2

Format code automatically

Auto-format all Solidity files:
forge fmt
Some files (like FlashLoanRouter.sol) are excluded from formatting due to Foundry’s lack of support for the transient keyword.

Key Contracts

Now that you can build and test, here are the main contracts you’ll work with:
ContractLocationPurpose
FlashLoanRoutersrc/FlashLoanRouter.solMain entry point for executing settlements with flash loans
AaveBorrowersrc/AaveBorrower.solAdapter for Aave flash-loan protocol
ERC3156Borrowersrc/ERC3156Borrower.solAdapter for ERC-3156 compatible lenders (e.g., Maker)

Common Development Commands

# Build contracts
forge build

# Run all tests
forge test

# Run tests without E2E
forge test --no-match-path 'test/e2e/**/*'

# Watch mode (re-run tests on file changes)
forge test --watch

# Format code
forge fmt

# Clean build artifacts
forge clean

Quick Verification

Run this command to verify your setup is working correctly:
forge build && forge test --no-match-path 'test/e2e/**/*'
If both commands succeed, you’re ready to start developing!

Next Steps

Last modified on March 4, 2026