Skip to main content

Overview

This guide covers the basic deployment process for the Flash-Loan Router contracts. The contracts are deployed using Foundry’s scripting system and support deterministic deployment via CREATE2, ensuring the same addresses across all networks.
For detailed deployment operations, monitoring, and advanced configuration, see the Operations section.

Deployed Addresses

All contracts are deployed deterministically with CREATE2 and share the same addresses across supported networks:
ContractAddress
FlashLoanRouter0x9da8B48441583a2b93e2eF8213aAD0EC0b392C69
AaveBorrower0x7d9C4DeE56933151Bc5C909cfe09DEf0d315CB4A
ERC3156Borrower0x47d71b4B3336AB2729436186C216955F3C27cD04
See networks.json for complete deployment details by chain ID.

Prerequisites

Before deploying, ensure you have:
1

Environment setup

Configure your .env file with the required variables:
# Required for deployment
CHAIN_ID=1
ETH_RPC_URL=https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY
PRIVATE_KEY=your_private_key_here

# Optional: for contract verification
ETHERSCAN_API_KEY=your_etherscan_api_key
Load the environment variables:
source .env
Ensure your deployer account has sufficient ETH for gas fees on the target network.
2

Verify compilation

Build the contracts to ensure they compile successfully:
forge build

Deployment Options

Deploy All Contracts

To deploy all contracts (FlashLoanRouter, AaveBorrower, and ERC3156Borrower) in a single transaction:
1

Dry-run the deployment

Simulate the deployment without broadcasting:
forge script script/DeployAllContracts.s.sol:DeployAllContracts \
  --rpc-url $ETH_RPC_URL \
  --private-key $PRIVATE_KEY
Review the output to verify:
  • Gas estimates
  • Contract addresses
  • Constructor arguments
2

Broadcast the deployment

Execute the deployment on the network:
forge script script/DeployAllContracts.s.sol:DeployAllContracts \
  --rpc-url $ETH_RPC_URL \
  --private-key $PRIVATE_KEY \
  --broadcast
3

Verify contracts (optional)

Add the --verify flag to automatically verify contracts on Etherscan:
forge script script/DeployAllContracts.s.sol:DeployAllContracts \
  --rpc-url $ETH_RPC_URL \
  --private-key $PRIVATE_KEY \
  --broadcast \
  --verify
Ensure ETHERSCAN_API_KEY is set in your .env file for verification to work.

Deploy a Single Contract

For deploying individual contracts, use the scripts in script/single-deployment/:
forge script script/single-deployment/DeployFlashLoanRouter.s.sol:DeployFlashLoanRouter \
  --rpc-url $ETH_RPC_URL \
  --private-key $PRIVATE_KEY \
  --broadcast

Contract Verification

If you need to verify already deployed contracts manually:
forge verify-contract \
  0x9da8B48441583a2b93e2eF8213aAD0EC0b392C69 \
  src/FlashLoanRouter.sol:FlashLoanRouter \
  --chain-id $CHAIN_ID \
  --etherscan-api-key $ETHERSCAN_API_KEY \
  --constructor-args $(cast abi-encode "constructor(address)" 0x9008D19f58AAbD9eD0D60971565AA8510560ab41)

Deployment Flow

The DeployAllContracts script follows this sequence:
  1. Deploy FlashLoanRouter - The main router contract that coordinates flash loans and settlements
  2. Deploy AaveBorrower - Adapter for Aave flash-loan protocol (requires FlashLoanRouter address)
  3. Deploy ERC3156Borrower - Adapter for ERC-3156 compatible lenders (requires FlashLoanRouter address)
Each borrower contract needs the FlashLoanRouter address as a constructor argument.

Updating Deployment Records

After deployment, update the networks.json file to track your deployment:
1

Generate networks file

The networks.json file is generated automatically from broadcast files:
bash script/generate-networks-file.sh > networks.json
2

Manual deployments

For deployments done outside of Forge scripts, manually update:
# Edit the manual networks file
vim broadcast/networks-manual.json
Then regenerate:
bash script/generate-networks-file.sh > networks.json

Network Support

The Flash-Loan Router supports deployment to all networks where CoW Protocol is deployed and flash-loan lenders (Aave, Maker, etc.) are available. CoW Protocol is deployed on the following networks:
NetworkChain IDType
Ethereum1Mainnet
Gnosis Chain100Mainnet
Arbitrum One42161Layer 2
Base8453Layer 2
Optimism10Layer 2
Polygon137Sidechain
BNB Smart Chain56Sidechain
Avalanche C-Chain43114Sidechain
Linea59144Layer 2
Sepolia11155111Testnet
For the complete list of deployment addresses per network, see the networks.json file.

Deployment Checklist

Before deploying to production:
  • Verify all environment variables are set correctly
  • Run a dry-run deployment on the target network
  • Ensure deployer account has sufficient ETH for gas
  • Review gas estimates and contract addresses
  • Test deployment on a testnet first
  • Verify contracts on block explorer
  • Update networks.json with new deployment addresses
  • Document any network-specific configuration

Next Steps

Last modified on March 4, 2026