The Reality of Flash Loan Arbitrage Bots
TECH INSIGHT / EXPLAINED
Flash loans allow an uncollateralized borrowing path that must satisfy the lender’s same-transaction repayment rules. Atomic rollback protects a particular on-chain state transition; it does not make an arbitrage attempt free of economic loss.
Local execution of the actual project
These captures show the existing project UI or functions executed locally with non-private sample inputs. Each caption states the scope of the execution.
What rolls back—and what does not
For a standard repay-in-transaction flow, the receiver borrows X, swaps X→Y→X and repays principal plus premium. If required repayment fails and the transaction reverts, the inner state changes revert. An included failed transaction still consumes gas. A successful transaction can also lose economically if the token gain is smaller than gas and other costs. Loan models that open debt require separate treatment and collateral/delegation rules.
Keep every cost in one unit
Suppose a hypothetical route borrows 10,000 X and returns 10,012 X before loan premium. If the actual configured premium for this example is 5 X, token surplus is 7 X. Estimated gas valued at 9 X makes expected net −2 X. A contract checking only “enough to repay” would allow a transaction that is economically negative. Premium and gas figures here are assumptions, not a current protocol tariff. Add a conservative minimum-surplus check and an off-chain gas budget using the same valuation unit.
output_in_X - principal_in_X - premium_in_X
- gas_cost_in_X - other_cost_in_X >= required_margin_in_XSimulation is a snapshot
eth_call executes against a selected state without an on-chain transaction fee, but the RPC service may charge for usage. Success at block B does not guarantee inclusion after other trades change reserves. Simulate the complete route with sender, calldata, value and token approvals, then apply deadline and minimum-output constraints in execution. Record simulated block and actual receipt to distinguish a model error from state movement.
Protocol mechanics matter
An Aave flash loan and a V2 flash swap use different callbacks and repayment mechanics. Borrowing from a pool and reentering that same pool during its locked callback may fail; do not assume the lending pool is also an unrestricted first swap venue. Verify callback caller, assets, amounts and authorized initiator. Treat untrusted callbacks and arbitrary approvals as security boundaries.
Measure failed attempts as well
Maintain a ledger of simulation rejections, submissions, reversions, gas paid and realized net asset changes. MEV and competing submissions can change execution order; private routing can change exposure but is not a profit guarantee. Scanner breadth or a claimed DEX count provides no evidence of profitability.
Documentation and next steps
Content and examples reviewed: 2026-09-29
댓글
댓글 쓰기