A flash loan must be repaid in the same transaction

Explainer7 min read

How does a flash loan work? Follow borrowing and repayment inside one transaction, then separate Aave V3 flash loans, Uniswap v2 flash swaps and ongoing debt.

Brokzi checks a fictional Aave V3 flash-loan round trip: borrow, use and return principal plus fee inside one transaction. An unclosed loop is rejected; the scene is a teaching metaphor, not a live transaction.
AI-assisted editorial illustration · Brokzi
On this page

Borrow, do the work, return the money. With a flash loan, those steps belong inside the same transaction. There is no afternoon repayment deadline and no borrowed balance to take home afterward.

For readers trying to understand DeFi, the useful question is not how fast someone clicks. It is which conditions must hold before the transaction can finish successfully. This explainer uses Aave V3's repayment-only path and a separate Uniswap v2 comparison; it does not describe every protocol version or provide transaction instructions.

How a flash loan closes its loop

Aave's V3 flash-loan guide describes a pool transferring assets to a receiving contract, which runs its operation before repayment is checked. On the single-asset flashLoanSimple path, the receiver needs both the required balance and permission for the Pool to collect principal plus premium.

Think of one operation with a closing check, rather than a loan followed by a second repayment transaction. A successful middle step cannot make up for a failed closing check. The V3 Origin v3.7.0 implementation collects principal plus premium from the receiver after its operation. Having enough tokens without the required allowance is not sufficient either. This code tag is an implementation reference, not proof of every market's deployed version.

The Pool reference distinguishes this single-reserve method from the multi-asset flashLoan method. Availability and the applicable market's rules still matter. "No collateral posted for the atomic loan" does not mean unlimited liquidity or a promise that any requested amount will be supplied.

Same transaction is stricter than same block

A block can contain several transactions. Ethereum's transaction documentation describes each as a signed instruction that executes and updates network state. A block is not one shared repayment window for every instruction it contains.

Sending a borrowing transaction now and a repayment transaction later in that block does not meet a same-transaction requirement. Nor can the operation wait for a bank transfer, a future price change or confirmation on another chain to bring the money back.

"Atomic" describes the success or rollback of the relevant execution. It does not mean time has stopped or that every separate action in a block gets undone together. The scope of the transaction is the boundary that matters.

Principal, premium and gas are separate amounts

Here is a fictional accounting example, using invented token Q and an assumed premium of 0.10%. This is not a live Aave fee, a quoted opportunity or a recommended trade.

Item in the teaching exampleAmountMeaning
Principal borrowed10,000 QAmount temporarily supplied
Assumed premium10 Q10,000 Q × 0.001
Required closing repayment10,010 QPrincipal plus the assumed premium
Balance available at closing in a failing case10,009 QShort by 1 Q; this does not meet the repayment amount

The example does not explain where the extra 10 Q comes from. It could not simply be declared into existence because the loan is atomic. A strategy must account for its resources and costs; passing a repayment check is not proof that its operator made a profit.

Aave's guide says its premium is configurable and identifies a current-value getter. A documented initialization value is not a verified fee for every deployed market today. The single-asset method also does not receive the approved-borrower fee waiver described for the other method. No deployed fee setting was queried for this article.

Ethereum gas pays for computation. It is separate from the loan premium and, on Ethereum mainnet, is paid in ETH rather than our fictional Q. Swap fees and execution prices can add other costs if swaps are part of an operation. A low premium alone cannot establish an attractive overall result.

What happens when repayment fails?

If the required Aave repayment cannot be collected on the repayment-only path, the operation reverts. EIP-140 defines rollback of reverted execution. For a top-level reverted transaction, the borrowing and the dependent contract changes inside that execution do not remain as completed actions. A receiver does not get to keep the principal by deliberately missing the check.

The chain still processed the included attempt. Gas accounting is not erased by reverting execution, as our failed Ethereum transaction explainer explains. A local preview that was never submitted is a different case from an included transaction that failed.

Rollback is therefore not a money-back guarantee for every expense, and it is not a security certificate for the contracts involved. It tells you what happens to the reverted execution's changes. It does not establish that a separate earlier approval was safe, or that other transactions were undone.

Aave's debt option is a different commitment

The name of a function can hide a distinction. Aave V3's multi-asset flashLoan interface can, under its permitted mode and borrowing conditions, leave an ongoing variable-rate debt position instead of immediately repaying a selected asset. flashLoanSimple does not offer that debt-opening option.

That branch is not an uncollateralized balance disappearing into next week. Aave's credit-delegation guide explains how another account can authorize borrowing against its borrowing power; sufficient collateral must be available for the borrowing operation. The borrower and the collateral provider need not be the same party.

This is why an account of a transaction should state whether a particular asset was repaid or became debt. Our liquidation explainer covers the collateral and debt boundary. It is a separate question from closing a repayment-only flash loan.

A Uniswap flash swap is not an Aave loan

Uniswap v2's flash-swap guide describes a pair sending output tokens before it enforces the required input and reserve condition. The callback can return the same token or provide the other token, with the applicable fee-adjusted accounting.

The shared idea is conditional execution inside one transaction. The settlement rules differ: do not paste an Aave premium calculation onto a Uniswap v2 pair. This comparison is specifically about v2, not a claim that every Uniswap version uses identical mechanics.

ArrangementWhat closes the operation?Can ordinary debt remain afterward?
Aave V3 repayment-only flash loanRequired principal and premium are collected within the transactionNo ongoing loan on this path
Uniswap v2 flash swapPair's input and fee-adjusted reserve condition is satisfiedNot an ordinary credit position from the swap itself
Aave V3 permitted debt-opening branchBorrowing conditions allow the selected amount to become debtYes; this is not the repayment-only case

A read-first checklist for a flash-loan claim

Before interpreting a diagram or an account of a transaction, record:

  1. The network, protocol version and actual method. A familiar logo does not identify the settlement rules.
  2. The asset borrowed, principal, applicable premium and the unit in which each cost is charged.
  3. The receiving contract's operation and the condition checked before completion, including any necessary collection permission.
  4. Whether the result is repayment, a permitted debt position or a reverted attempt.
  5. Which claims are observations and which remain assumptions, especially costs, profit and contract safety.

A favorable transaction simulation is a preview against a selected state, not a reservation of a future result. Likewise, token allowances explain a collection permission; they do not create the missing balance.

A flash loan is conditional liquidity inside one transaction. Its defining feature is the closing condition, not a guarantee of free capital, profit or harmless failure.

Sources

Primary documentation checked October 27, 2026, Asia/Tbilisi. Aave V3 and Uniswap v2 are version-scoped examples. The amounts and illustration are fictional. No live pool parameter, wallet, contract, borrowing strategy or transaction was tested; this is education, not a contract audit or financial recommendation.

See something wrong? Brokzi logs material changes. Prepare a correction note.

About the byline

Brokzi Editorial

The accountable byline for Brokzi’s explainers, definitions, news notes, and corrections.

Editorial responsibility →