Skip to main content

Prerequisites

Before you begin, ensure you have the following installed:

Foundry

The Flash-Loan Router is built with Foundry, a blazing fast Ethereum development toolkit. Install Foundry using:
curl -L https://foundry.paradigm.xyz | bash
foundryup
Verify your installation:
forge --version
Foundry requires a working Rust installation. If you encounter issues, visit Foundry’s installation guide.

Git

Ensure Git is installed for cloning the repository:
git --version

Installation Steps

1

Clone the repository

Clone the Flash-Loan Router repository from GitHub:
git clone https://github.com/cowprotocol/flash-loan-router.git
cd flash-loan-router
2

Install dependencies

Install Foundry dependencies (Forge automatically manages Solidity dependencies):
forge install
This will install all required libraries specified in the project configuration.
3

Set up environment variables

Copy the example environment file and configure it:
cp .env.example .env
Edit the .env file with your configuration:
# CLI
CHAIN_ID=1
ETH_RPC_URL=https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY
PRIVATE_KEY=your_private_key_here

# Forge deployment scripts:
# For smart contract verification
ETHERSCAN_API_KEY=your_etherscan_api_key
# FlashLoanRouter contract address used in a single deployment of AAVE Borrower.
# FLASHLOAN_ROUTER_ADDRESS=
Never commit your .env file to version control. It contains sensitive information like private keys.
4

Build the project

Compile all smart contracts:
forge build
This compiles all Solidity contracts using the settings defined in foundry.toml:
  • Solidity version: 0.8.28
  • EVM version: Cancun
  • Optimizer runs: 1,000,000
5

Verify installation

Run the test suite to ensure everything is set up correctly:
forge test
To exclude tests requiring an internet connection:
forge test --no-match-path 'test/e2e/**/*'
If all tests pass, your installation is complete!

Compiler Configuration

The project uses the following Foundry configuration (foundry.toml):
[profile.default]
src = "src"
out = "out"
libs = ["lib"]

# Compiler settings
solc = "0.8.28"
evm_version = "cancun"
optimizer = true
optimizer_runs = 1000000
The high optimizer run count (1,000,000) is configured for gas-efficient production deployment, prioritizing execution cost over deployment cost.

Next Steps

Now that you have the Flash-Loan Router installed, you can:
Last modified on March 4, 2026