We’re Here and Ready to Care for You
Some locations have recently been consolidated to better serve our patients. We are fully open and continuing care at nearby Gentle Dentistry offices.
Your records are secure and available at your new location.
Find Your Nearest Location
Gentle Dentistry — Contributing to the Prevention and Cure of Dental Disease
Gentle Dentistry
Search Locations
Schedule
Services All Services Preventive Care Dental Implants Endodontics / Root Canals Dentures Pediatric Dentistry Urgent Dental Care
Locations Edina Eagan Hutchinson Plymouth New Hope Coon Rapids Bloomington / Point Family Dentistry
Patient Resources New Patients Insurance Membership Patient Forms Pay My Bill
About Insurance Membership / Dental Savings Plan Reviews Careers Contact

Uniswap Flash Swaps Explained: How to Borrow Tokens Without Collateral (And Profit From It)

· Taylor Johnson

A trader has identified an arbitrage opportunity: Token A is trading at 1.02 on Uniswap’s Ethereum mainnet pool but only 1.00 on a competing exchange. The profit exists, but executing it requires capital. Traditional lending requires collateral, credit checks, and time. Flash swaps offer a different path: borrow the tokens from a Uniswap liquidity pool, execute the arbitrage on another exchange, repay the original amount plus a 0.05% fee—all within a single transaction. If the arbitrage produces more than the fee, the profit is yours. If it fails, the transaction reverts and no debt remains.

Flash swaps are one of the most powerful and least understood features in decentralized finance. They expose a fundamental difference between traditional finance and blockchain: in a trustless system, collateral can be replaced by verification. Because Ethereum transactions are atomic—either fully executed or fully reverted—a smart contract can enforce that borrowed tokens are returned before a transaction settles. This capability enables strategies that would be impossible or prohibitively expensive in traditional markets, but it also requires precise execution and deep understanding of smart contract behavior. Understanding how flash swaps work, where they are useful, and how they can fail separates profitable execution from costly mistakes.

Flash swap execution flow showing token borrowing, on-chain execution verification, and atomic repayment within a single Ethereum transaction

The mechanics of flash swaps on Uniswap

A flash swap begins with a request to a Uniswap V2 or V3 pool to send tokens before payment is received. The pool transfers the requested amount to the caller’s contract. Control then passes to a callback function defined in the caller’s smart contract code. During this callback, the borrowed tokens can be used for any purpose: swapped on another protocol, deposited into a lending market, liquidated as collateral, or any other on-chain action. At the end of the callback, the original amount plus the fee must be paid back to the pool. If the repayment does not occur, the entire transaction reverts—the borrowed tokens are returned, the callback never happens, and the attacker loses only the gas cost.

The fee structure is straightforward. Uniswap V2 flash swaps charge 0.05% of the borrowed amount. V3 introduces fee-tier specificity: a flash swap from a 0.01% fee pool costs 0.01% to use, while borrowing from a 1% pool costs 1%. This structure incentivizes users to borrow from lower-fee pools when possible and rewards liquidity providers for allowing flash swaps on their capital. Because the fee is paid in the same token being borrowed, repayment amounts are deterministic. A user borrowing 100 DAI from a 0.05% pool must return 100.05 DAI plus any other fees incurred during the callback execution.

The critical technical requirement is that the borrowed tokens and fee must be returned to the pool before the transaction ends. This is verified through state changes on the blockchain itself. The Uniswap smart contract checks the pool’s token balance before and after the transaction. If the final balance is at least the original amount plus the fee, the transaction succeeds. If not, it reverts. No external oracle, intermediary, or time delay is required. The protocol relies entirely on the atomicity of blockchain transactions and the immutability of smart contract code.

This design differs fundamentally from collateralized lending. Traditional finance requires collateral because loans span time and trust is uncertain. A borrower could default or disappear. On Ethereum, a transaction either completes or fails before the next block. There is no intermediate state where tokens have been borrowed but not repaid. This is why flash swaps are possible without collateral and why they require precise execution: the execution window is exactly one transaction, and failure means total reversion, not partial loss.

Arbitrage as the canonical flash swap use case

Price differences between exchanges are the most straightforward application of flash swaps. If Token A trades at $100 on Uniswap and $101 on another decentralized exchange or centralized platform with an accessible API, a flash swap can capture the difference. The execution is: borrow from the cheaper pool using a flash swap, sell immediately on the expensive pool, pocket the 1% profit minus the 0.05% Uniswap fee and gas costs, and use the proceeds to repay the flash swap.

The practical complexity lies in identifying real arbitrage opportunities. Price feeds across multiple exchanges may show opportunities that disappear by the time a transaction is confirmed. Network congestion, transaction ordering (MEV), and slippage can all consume the apparent profit. A $100 difference that seemed certain might evaporate as the transaction waits in the mempool. Advanced traders use private relays like Flashbots Protect to hide pending transactions from public visibility, reducing the chance that a front-running bot captures the profit before the legitimate arbitrage executes.

MEV—maximum extractable value—deserves special attention. When an arbitrage opportunity becomes visible, validators and block builders can see it too. If a transaction is broadcast to the public mempool, a searcher with higher gas fees can front-run it, execute the same arbitrage first, and leave the original trader paying high fees for no profit. This pressure has pushed serious flash swap arbitrage toward private transaction pools or custom routing. The Uniswap protocol itself does not solve MEV, but it makes MEV possible and profitable in a way traditional finance cannot match.

Profitable arbitrage also depends on reliable access to pricing data. A protocol using an on-chain oracle to verify prices must trust that oracle. If the oracle is outdated or manipulable, an attacker could execute a flash swap knowing that the repayment check would pass even if the economic outcome is unfavorable. This is why many uniswap arbitrage strategies are custom-built rather than templatized—the profitability and safety depend on the specific pools, fee tiers, and counterparties involved.

Liquidation strategies enabled by zero-collateral borrowing

Lending protocols like Aave and Compound allow users to borrow against collateral. If the collateral value drops, the position becomes liquidatable. A liquidator can repay the debt and seize the collateral at a discount. Traditionally, a liquidator must have sufficient capital on hand or arrange a loan to execute the liquidation quickly. Flash swaps change this. A liquidator can borrow the repayment amount using a flash swap, liquidate the position, receive the discounted collateral, and use proceeds to repay the flash swap.

This mechanism is economically significant. Liquidations maintain protocol stability by preventing debt from exceeding collateral. Without accessible liquidation tools, bad debt accumulates. Flash swaps democratize liquidation by removing the capital requirement. Any participant with the ability to write a smart contract can become a liquidator, which increases competition and tightens liquidation discounts. The reduced discount means borrowers pay less to get liquidated, which makes borrowing slightly safer for the system as a whole.

A real liquidation sequence works as follows: a Compound user has 100 ETH collateralized against 50,000 USDC borrowed. The ETH price drops to 450 per token, so the collateral is now worth 45,000 USDC. The position is undercollateralized by 5,000 USDC. A liquidator uses a flash swap to borrow 50,000 USDC from Uniswap, repays Compound on behalf of the borrower (closing the loan), receives the 100 ETH as collateral, sells it for 45,000 USDC, and uses those proceeds plus 5,000 USDC from another source to repay the flash swap. The liquidator keeps the difference between the 45,000 USDC received and the 50,000 USDC owed (minus the flash swap fee and gas).

The key risk is price slippage during execution. If ETH price moves significantly between the liquidation and the sale, the collateral proceeds may not cover the repayment amount. This is why liquidation strategies often incorporate buffers or checks: only liquidate if the expected proceeds exceed the repayment plus a margin. A liquidator who assumes prices remain static can lose money if on-chain execution is slow or if other transactions execute in the same block, moving prices.

Flash swaps and oracle manipulation defenses

Because flash swaps allow borrowing large amounts without collateral, they create a potential vector for price oracle attacks. An attacker could execute a flash swap to borrow a massive amount of Token A, use it to distort the price on a decentralized exchange pool (which relies on reserves to calculate prices), trigger liquidations or other profitable actions based on the manipulated price, repay the flash swap, and walk away with profit from the liquidations. This attack is theoretically possible but practically difficult because it requires all steps to succeed within a single transaction.

Uniswap’s TWAP (time-weighted average price) oracle is one defense. Instead of relying on the current price in a pool, a TWAP averages prices over a longer time period, usually minutes. A single large transaction cannot significantly distort a TWAP, so oracles based on TWAP are more resistant to flash swap attacks. However, TWAP has limitations: it is slower to respond to legitimate price changes and can still be manipulated if an attacker executes multiple transactions across blocks.

The more fundamental defense is architecture. Protocols should not rely solely on instantaneous pool prices for critical decisions. Using multiple price sources, adding time delays between price observation and execution, and requiring over-collateralization are all strategies that reduce the impact of short-term price distortion. A flash swap attack is most profitable against protocols that have a single price source and execute immediately. As protocols become more defensive, flash swap attack vectors narrow, but they do not disappear entirely.

Sophisticated traders and protocol designers often assume that any profitable opportunity enabled by flash swaps will be tested by attackers. This assumption drives security practices: monitoring for unusual liquidation patterns, using decentralized governance to adjust risk parameters quickly, and designing contracts so that single-transaction attacks cannot extract significant value. The presence of flash swaps forces security consciousness that would otherwise be optional.

The on-chain execution requirement and its constraints

Flash swaps can only execute strategies that are fully on-chain. If a profitable opportunity requires interaction with a centralized exchange, a private API, or manual human judgment, a flash swap cannot capture it. The callback function runs in a smart contract, which means it can only call other smart contracts or perform low-level blockchain operations. It cannot make HTTP requests, query external databases, or wait for a human approval.

This constraint is actually a feature from a security perspective. Because all execution is on-chain and immutable, every step of a flash swap strategy is auditable. An observer can see exactly what tokens were borrowed, where they were used, and how they were repaid. There is no hidden complexity or off-chain behavior. For traders and developers, this means flash swap strategies are reproducible: the same code will produce the same result given the same on-chain conditions.

The execution window is also limited by block time and gas. A transaction must complete within a single block, which on Ethereum is roughly 12 seconds. Complex strategies that require many contract calls may consume significant gas, reducing profitability. A flash swap that borrows 1 million USDC and makes five swaps across different pools might spend 300,000 gas at 30 gwei per unit, equivalent to roughly 9 USDC in fees. The arbitrage must be large enough to exceed this cost, or it is not profitable.

These constraints mean flash swaps are best suited for high-frequency, high-volume strategies. A sophisticated market maker might profit from 0.01% arbitrage on millions of dollars of daily volume. A retail trader attempting to profit from 1% differences across pools will likely lose money to gas costs and slippage unless the volume is substantial. Understanding the cost structure—protocol fees, gas fees, slippage, and MEV risk—is more important than identifying the raw price difference.

Implementation patterns and common pitfalls

A flash swap contract typically follows this structure: a user calls a contract function with parameters specifying which tokens to borrow and how much. The contract calls the Uniswap pool’s flash method, passing its own address as the callback recipient. The pool sends the tokens and invokes a callback function. Inside the callback, the contract executes the strategy (swap, liquidate, or other action). Before the callback returns, the contract must approve the pool to withdraw the repayment amount from its balance. The pool then withdraws the repayment, and the transaction ends.

Common pitfalls emerge in the callback logic. A developer might forget to leave sufficient balance for repayment, executing a profitable strategy but then failing to repay and reverting the entire transaction. Another mistake is assuming that the token balance in the callback represents only the borrowed tokens. If the contract holds leftover balance from previous transactions, the repayment check might pass even though the callback did not properly account for what was borrowed. A third pitfall is underestimating gas costs: a callback that makes many contract calls might run out of gas before reaching the repayment step, causing a revert and wasted transaction fees.

Security audits for flash swap contracts focus on several areas. Is the callback function protected against reentrancy? A malicious token transfer could trigger a callback on the recipient contract, which might alter state in unexpected ways. Does the contract correctly calculate repayment amounts, accounting for all fees and amounts borrowed? Are there any edge cases where the expected strategy could fail (e.g., insufficient liquidity on the destination exchange)? Can the contract be called by an attacker to drain funds? Many flash swap exploits have resulted from missing permission checks or incorrect fee calculations rather than flaws in the Uniswap protocol itself.

Professional flash swap implementations often include multiple layers of protection. A contract might verify that the caller is authorized before executing the strategy. It might check that the expected profit exceeds a minimum threshold before proceeding, preventing execution during adverse conditions. It might use external price feeds as a sanity check on the amounts being swapped. These safeguards consume gas and reduce potential profit from each trade, but they prevent catastrophic losses from market moves or unexpected conditions.

Regulatory and game-theoretic implications of flash borrowing

Flash swaps occupy an uncertain regulatory space. They are not loans in the traditional sense because they are settled within microseconds and carry no credit risk. But they are not simple trades either, because they involve temporary transfer of tokens without immediate payment. Regulators focused on preventing fraud and market manipulation have shown interest in flash loan attacks, particularly those that manipulate prices or trigger liquidations unfairly. However, most regulatory attention has focused on ensuring proper disclosure and preventing outright theft rather than restricting the mechanism itself.

From a game-theoretic perspective, flash swaps have changed the structure of decentralized markets. They enable liquidations that were previously impossible, which improves capital efficiency but also creates new incentives for sandwich attacks and price manipulation. They allow arbitrage with zero capital, which promotes price discovery but also incentivizes the use of private transaction pools to hide profitable strategies. The presence of flash swaps makes market structure more complex and more favorable to sophisticated participants with access to custom tools and infrastructure.

The broader question is whether flash swaps increase or decrease market stability. They enable defensive liquidations that prevent bad debt accumulation, which is stabilizing. But they also enable sophisticated attacks and require careful protocol design to defend against. The answer likely depends on the specific protocol and market: a well-defended lending protocol using TWAP oracles may find that flash swaps improve stability, while a poorly designed protocol with instantaneous price feeds could be destabilized. This tension means that flash swaps will likely remain a focal point for both attackers and defenders in decentralized finance.

Why flash swaps matter beyond the immediate profit

Flash swaps are significant not primarily because they make traders rich, but because they reveal the capabilities and constraints of blockchain architecture. They demonstrate that atomicity and code execution can replace collateral and credit verification. This insight applies beyond trading: atomic swaps between blockchains, instant settlement of complex contracts, and other applications all rely on similar principles. Understanding flash swaps provides intuition for how decentralized systems can achieve coordination and trust without intermediaries.

For developers, flash swaps represent a frontier of smart contract design. Building strategies that work requires understanding not just Uniswap but also the broader ecosystem: lending protocols, price oracles, MEV mechanics, and gas economics. This systems-level thinking is becoming essential as decentralized finance matures. A developer who understands only Uniswap may miss opportunities or introduce vulnerabilities. One who understands the full context can build strategies that are both profitable and secure.

The practical lesson is that decentralized finance enables strategies that traditional finance cannot easily replicate, but those strategies require both technical sophistication and careful risk management. Flash swaps are not a shortcut to profit; they are a tool that amplifies the skill of the user wielding it. Proper execution requires understanding the protocol mechanics, the broader market context, and the failure modes. A trader who treats flash swaps as a magic profit button will eventually discover that the margin between genius and disaster is precisely the margin between profit and loss.

Frequently asked questions

What is the fee for a flash swap on Uniswap?

Flash swap fees depend on the pool’s fee tier. Borrowing from a 0.01% fee pool costs 0.01%, while borrowing from a 0.05% or 1% pool costs 0.05% or 1% respectively. The fee is paid in the token being borrowed and must be included in the repayment amount to avoid transaction reversion.

Can flash swaps be used on Uniswap’s Layer 2 networks like Arbitrum and Optimism?

Yes. Uniswap operates on Ethereum, Arbitrum, Optimism, Base, Polygon, and BNB Chain. Flash swaps work on all of these networks with the same mechanics. However, gas costs and liquidity depth vary by network, so profitability depends on the specific deployment and available pools.

What happens if a flash swap callback fails before repayment?

If any part of the transaction fails before the repayment is completed, the entire transaction reverts. The borrowed tokens are returned to the pool, the strategy does not execute, and the only cost to the user is the gas spent. This atomic property is what makes flash swaps possible without collateral.