Learning Center

A practical guide to DeFi arbitrage, flash loans, and using FlashLoanLab safely and effectively.

What is Arbitrage?

Arbitrage is the simultaneous purchase and sale of an identical asset in two different markets to profit from a temporary price difference. In traditional finance this happens across stock exchanges. In DeFi it happens across decentralised exchanges (DEXes) — Uniswap, Curve, Balancer — where prices are set algorithmically by supply and demand and can briefly diverge.

Imagine WETH is priced at $3,000 on Uniswap V3 and $3,012 on Uniswap V2. An arbitrageur can buy on V3 and sell on V2, pocketing $12 per ETH before transaction costs. At scale (borrowing 100 ETH via a flash loan) that is $1,200 gross before gas — minus perhaps $10 in gas and $240 in platform fees, leaving ~$950 net profit for a single transaction.

Why do price gaps exist?

Each DEX runs an Automated Market Maker (AMM) that reprices tokens based on the ratio of reserves in its pool. When a large buy or sell hits one pool, its price moves but other pools don't know yet. The gap persists until an arbitrageur closes it — or until more trades naturally rebalance both pools.

On-chain atomicity

On-chain arbitrage executes both legs (buy and sell) inside a single Ethereum transaction. If the sell leg can't cover the buy at a profit, the entire transaction reverts — it either fully succeeds or fully fails. There is no half-executed state where you end up holding a token you can't sell.

Key insight

The atomic nature of blockchain transactions is what makes flash loan arbitrage safe from a capital-loss perspective. You cannot lose the borrowed principal — if the trade is not profitable, the loan is never drawn.

How Flash Loans Work

A flash loan is a DeFi primitive introduced by Aave that lets you borrow any amount of capital with zero collateral, provided you return it within the same transaction block. It sounds impossible, but it exploits a key Ethereum property: a transaction is atomic.

The mechanics, step by step

1. InitiateYour smart contract calls Aave's flashLoanSimple(asset, amount, params).
2. Aave lendsAave transfers the requested tokens to your contract.
3. Your logicAave calls your executeOperation() callback. You run the arbitrage: buy on DEX A, sell on DEX B.
4. RepaymentBefore executeOperation() returns, you approve Aave to pull back principal + 0.05% fee.
5. Aave pullsAave transfers principal + fee back from your contract.
6. Transaction endsIf repayment succeeded: done. If not: entire transaction reverts as if it never happened.

The FlashLoanReceiver contract

FlashLoanLab deploys a FlashLoanReceiver.sol contract for each user on each supported chain. When you execute an opportunity from the dashboard, FlashLoanLab constructs the transaction parameters and you sign them with your wallet. The contract calls Aave, executes the arbitrage hops, and distributes the profit split on-chain before the transaction closes.

The platform fee (15–25% depending on your plan) is transferred directly to the platform treasury inside the same transaction. The contract enforces a hard cap of 30% — the platform can never take more than this, even if a compromised server tried to set a higher rate.

Important

The contract has not yet undergone a formal third-party security audit. Start with Simulator mode and use amounts you are comfortable losing until an audit is complete.

Reading the Scanner

The scanner continuously monitors Uniswap V2 and V3 pools across Base, Arbitrum, and Ethereum, comparing prices pair by pair. Opportunities appear in the dashboard as soon as a spread above a minimum threshold is detected.

Key columns

ChainWhich blockchain the opportunity is on (Base, Arbitrum, Ethereum).
PairToken pair, e.g. WETH/USDC. The first token is the borrow token.
SpreadRaw price difference as a percentage. Higher is not always better — also check simulation result.
Est. ProfitEstimated net profit after gas and platform fee, in ETH.
Score0–100 confidence score. Combines profitability, simulation, safety, liquidity, and timing.
Simulationpassed / failed / pending. Only passed simulations are safe to execute live.
Token SafetyGoPlus API result: safe / warning / flagged. Never execute on flagged tokens.
ExpiresOpportunities are valid for 30 seconds. After that, prices may have moved.

Why some high-spread opportunities score low

A large spread on paper can still be unprofitable. Common reasons: the simulation fails because gas costs exceed profit; the token has a transfer tax that eats into the margin; or liquidity is too thin — the swap moves the price so much that by the time the sell leg executes, the spread has collapsed.

Best practice

Always check "Simulation: passed" before executing. Never execute on a "flagged" token safety rating — it indicates possible honeypot, transfer tax above 10%, or blacklist functions.

Understanding Scores

The score (0–100) is a single number that combines all signals into a confidence estimate. Auto Trading only fires on scores ≥ 90. Manual execution works at any score, but the score is there to guide your judgement.

Score components

Simulation result (40 pts)Highest weight. Did the Hardhat fork simulation pass? A failed simulation is a hard cap at 50.
Net profit after fees (25 pts)Scaled by profit size. Very thin profits score low here.
Token safety (15 pts)GoPlus rating. Safe = full 15 pts. Warning = partial. Flagged = 0.
Liquidity depth (10 pts)How much can be traded before the pool price moves significantly.
Chain congestion (5 pts)Current gas price relative to 24h average. High gas = lower score.
Spread confidence (5 pts)How fresh the price data is. Stale quotes reduce this component.

Score thresholds

90–100High confidence. Auto Trading fires here. Good for live execution.
70–89Moderate confidence. Manual execution is reasonable with careful review.
50–69Low confidence. Simulation may have passed but margins are thin.
< 50Do not execute. Likely a failed simulation or flagged token.

Risk Management

Flash loan arbitrage has a unique risk profile compared to spot trading. Understanding the risks helps you size your exposure and configure safety controls appropriately.

Risks you cannot be protected from

Gas cost riskEven a reverted transaction costs gas. In very high-congestion conditions, gas can exceed profit estimates.
MEV / front-runningMempool bots can see your transaction and copy it with higher gas, executing the same arbitrage before you.
Smart contract riskBugs in FlashLoanReceiver.sol or Aave V3 could lead to loss of funds.
Price oracle riskExtremely rare: oracle manipulation attacks can create false arbitrage signals.

Safety Controls

Safety Controls (Settings > Safety) let you set hard limits for the auto-trading bot:

Min ScoreOnly fire on opportunities above this score. Default: 90.
Min Profit (USD)Skip trades where estimated net profit is below this threshold.
Max Daily LossAutomatically pause the bot if total daily losses (gas costs on reverts) exceed this.
Max Trades / DayCap the number of executions per calendar day.
Max Failed TXsPause after this many consecutive failed transactions.

Start conservative

When running auto trading for the first time, start with Paper mode (simulated execution, no real transactions) for a few days. Observe the score distribution and profitability estimates. Only switch to Mainnet mode after you understand the patterns you see.

Emergency Stop

The Emergency Stop button in the dashboard immediately halts all auto-trading activity, cancels any queued jobs, and disarms the bot. Use it any time you see unexpected behaviour. It takes effect within seconds and can always be re-armed manually.

Auto Trading Guide

Prerequisites

PlanPro or higher. Free plan is scanner + simulator only.
Trading walletA dedicated hot wallet for automated execution. Not your main wallet.
ETH for gasKeep at least 0.05 ETH on Base and 0.01 ETH on Arbitrum per 24h of running.

Setting up a trading wallet

Create a fresh wallet in MetaMask (or generate one via cast wallet newif you use Foundry). Fund it with gas only — no large holdings. Never reuse a wallet that holds significant assets. Register it in Settings > Auto Trading > Trading Wallet. The private key is encrypted AES-256-GCM server-side and never exposed again.

Important

Your trading wallet private key is stored encrypted on the server. You will not be able to retrieve it after registration. Keep a secure offline backup in your own password manager.

Choosing Paper vs Mainnet mode

Paper mode runs the full evaluation pipeline — score, simulation check, safety controls — but records executions as simulated without submitting any real transactions. Use it to validate that your safety settings are calibrated correctly before going live.

Mainnet mode submits real transactions. Switch to it only after at least 24 hours of Paper mode with a pattern you are comfortable with.

Monitoring activity

The Auto Trading dashboard shows today's stats (trades attempted, succeeded, failed, net profit) and a live activity log. Check the log regularly — if you see many failed transactions or pauses triggered by safety limits, review your settings and current market conditions before re-arming.