Skip to main content
Learn how to debug reverted transactions using trace analysis tools. This guide covers common failure patterns and their fixes based on real production cases.

Prerequisites

Before you begin, you need:
  • The transaction hash of the failed transaction
  • Access to a trace analysis tool

Core Debugging Workflow

Follow these steps to diagnose most transaction failures.
1

Find the Revert Location

Open the transaction in Blocksec or Tenderly and identify:
  • The top-level revert reason (if available)
  • The first revert in the call tree (this is often the actual root cause)
  • The contract or call before the revert (this is the failing action)
Trace tools sometimes show multiple errors. When the UI summary conflicts with the raw trace, trust the raw trace.
2

Classify the Failure

Most reverts fall into these categories:
CategoryCommon Indicators
Out of gasTrace ends abruptly, OOG error
Insufficient allowancetransfer amount exceeds allowance
Insufficient balanceinsufficient balance, transfer amount exceeds balance
Missing msg.valueinsufficient balance for transfer on native token
Slippage exceededMin output checks fail
Oracle issuesStalePrice, bad feed errors
Deadline expiredEXPIRED, Transaction too old
Token restrictionsTransfer blocked, tax fees, blacklist
Once you identify the category, the fix becomes clear.
3

Compare Expected vs Actual Inputs

Aggregator and router failures often stem from input mismatches:
  • gasLimit on-chain vs gasLimit from /quote or /stepTransaction
  • Approval amount vs actual spend amount
  • msg.value sent vs msg.value required
  • minAmountOut vs actual output at execution
  • Token address or price feed ID errors
4

Reproduce and Test

Simulate the failed call with identical calldata and state. Then change one variable at a time:
  • Increase gasLimit
  • Add or adjust msg.value
  • Relax slippage parameters
If changing one variable makes the simulation succeed, you have found the root cause.

Common Failure Modes

Symptom

The trace ends abruptly or shows an out-of-gas (OOG) error.

How to Confirm

  1. Check the transaction’s gasLimit
  2. Look for OOG in the revert reason
  3. Re-simulate with a higher gasLimit (use the value from the quote API)

Root Cause

The transaction used a lower gasLimit than the quote recommended. Wallets or relayers sometimes override gas settings.

Fix

  • Use the exact gasLimit from the quote response
  • Add a 10–20% safety buffer if your product allows it
  • Verify that wallets and relayers do not clamp gas values

Example

The API returned sufficient gasLimit, but the on-chain transaction reverted. Re-simulating with the correct gasLimit succeeded.

Symptom

Revert message: transfer amount exceeds allowance

How to Confirm

  1. Find the transferFrom(...) call in the trace
  2. Identify which spender is pulling funds
  3. Check allowance(owner, spender) at the execution block

Root Cause

The user either did not approve, approved the wrong spender, or approved less than the required amount. A previous transaction may have consumed the allowance.

Fix

  • Prompt an approval for the correct token and spender
  • Consider infinite approval vs exact approval tradeoffs

Example

Transaction reverted due to insufficient allowance

Symptom

Errors such as:
  • insufficient balance for transfer
  • Native value forwarding fails

How to Confirm

  1. Check the transaction’s msg.value in Tenderly
  2. Find where the router forwards ETH in the trace
  3. Look for balance failures at that point

Root Cause

The route requires native tokens (for fees, bridged gas, or protocol payments), but the transaction sent value=0.

Fix

  • Include the msg.value returned by the API
  • Verify that relayers and wallets do not drop the value field

Example

The transaction failed because msg.value was missing despite the API returning a non-zero value.View in Tenderly

Symptom

Revert message: PythErrors.StalePrice()

How to Confirm

Look for getPriceNoOlderThan(..., age=N) reverting in the trace.

Root Cause

The oracle data is too old, or the pool uses an incorrect feed ID that is not being updated.

Fix

Contact LI.FI support to report the issue.

Example

PythErrors.StalePrice() occurred because a pool used an incorrect feed ID.View in Tenderly

Symptom

Revert message: insufficient balance or transfer amount exceeds balance

How to Confirm

  1. Find the token transfer in the trace
  2. Identify the “from” address
  3. Check balanceOf(from) at execution time

Root Cause

The user’s balance changed between quote and execution. Fee-on-transfer or rebasing tokens can cause unexpected balance changes.

Fix

  • Re-quote and verify balances immediately before sending
  • For fee-on-transfer tokens, contact LI.FI support to add the token to the deny list

Example

Transaction reverted due to insufficient balance

Symptom

Revert related to minimum output or slippage checks (exact message varies by DEX).

How to Confirm

Find the swap step and compare:
  • amountOutMin or minReturnAmount
  • Actual computed amountOut
If amountOut < minReturnAmount, the transaction reverts.

Root Cause

Price movement, MEV extraction, volatile pools, low liquidity, or stale quotes.

Fix

  • Increase slippage tolerance (15–25% for volatile or new tokens)
  • Execute within 60–90 seconds of quoting

Example

Symptom

The final swap step fails with SafeERC20: low-level call failed.

How to Confirm

In the trace, look for:
  1. A transferFrom call that reverts
  2. A nested external call that fails (often to a tax wallet or fee handler)
  3. The error bubbling up as SafeERC20: low-level call failed

Root Cause

Some tokens have custom transfer logic that fails under certain conditions. For example, tokens with sell taxes may call external contracts that reject ETH or revert unexpectedly.

Fix

  • Treat the token as incompatible for sell routes
  • Report to LI.FI support for addition to the token deny list
Use token risk scanners like honeypot.is or GoPlus to check for honeypot flags, sell restrictions, or abnormal taxes.

Example

The router failed to transfer tokens because the token’s tax wallet rejected ETH.View in Blocksec

Symptom

Revert inside pool math, such as Curve’s get_D failing to converge after 255 iterations.

How to Confirm

The trace shows a revert in pool math functions (get_D, invariant computation) with a raise statement.

Root Cause

The pool is broken, often due to a compromised token causing extreme imbalance or invalid state.

Fix

Contact LI.FI support to blacklist the pool.

Example

A Curve pool’s get_D function failed to converge. The Curve team confirmed the pool was broken.View in Tenderly

Symptom

Revert message: UniswapV2: LOCKED

How to Confirm

In the trace:
  1. The Uniswap V2 pair transfers a token
  2. The token’s transfer logic calls back into the same pair
  3. The pair’s reentrancy lock triggers

Root Cause

A token with callback or fee-swap logic re-enters the pair during transfer. This often happens with misconfigured fee-on-transfer tokens.

Fix

Contact LI.FI support to blacklist the pool.

Example

Swaps involving WeightedIndex reverted with UniswapV2: LOCKED. KyberSwap blacklisted the affected pool.View in Tenderly

Symptom

Revert due to insufficient balance mid-route, even though the user had enough tokens initially.

How to Confirm

The trace shows:
  1. An earlier hop receives less tokens than expected
  2. A later hop tries to transfer the originally calculated amount
  3. The balance check fails

Root Cause

Fee-on-transfer (FoT) or deflationary tokens take a fee during transfer. The route assumes exact amounts, but the actual received amount is less than calculated.

Fix

Contact LI.FI support to add the token to the deny list.

Example

fBOMB failed with Max20: insufficient balance because its deflationary mechanism broke the route’s exact calculations.

Symptom

Revert caused by a pool-level reentrancy lock, especially with fee-on-transfer tokens.

How to Confirm

The trace shows a revert at the pool with reentrancy guard behavior, similar to “LOCKED” but protocol-specific.

Root Cause

Newer DEXs add reentrancy protections that conflict with fee-on-transfer or callback tokens.

Fix

Contact LI.FI support to blacklist the pool.

Example

Kodiak v2 pools added reentrancy locks that caused fee-on-transfer tokens to revert.View in Tenderly

Symptom

Revert messages such as:
  • Transaction too old
  • EXPIRED
  • SwapRouter: EXPIRED

How to Confirm

  1. Find the encoded deadline in the calldata (usually a 32-byte word)
  2. Convert the hex value to Unix time
  3. Compare to the block timestamp when the transaction was mined
If block_timestamp > deadline, the router rejects the transaction.Example calculation:
  • Deadline: 0x6951e2e0 = 1,766,974,176
  • Block timestamp: 1,766,975,579
  • Delta: 1,403 seconds (~23 minutes late)
View VM trace

Root Cause

The transaction was submitted too late due to slow signing, mempool congestion, low gas price, or relayer delays.

Fix

  • Get a fresh quote and submit immediately
  • Increase gas price for stuck transactions
  • Do not reuse old calldata
Late execution often means the market has moved. Even without an explicit deadline revert, stale quotes frequently fail due to slippage. Always re-quote.

Quick Decision Checklist

Follow these steps when debugging a failed transaction:
1

Find the First Revert

Look at the call tree, not just the UI headline. The first revert is usually the root cause.
2

Identify the Category

CheckAction
Out of gas?Compare submitted vs recommended gasLimit
Allowance?Check allowance(owner, spender)
Balance?Check balanceOf at execution block
Missing value?Compare transaction value vs required value
Slippage?Compare minOut vs actual output
Oracle?Look for stale price or wrong feed ID
Token issue?Check for transfer reverts or false returns
3

Simulate the Transaction

Use Tenderly or Blocksec to reproduce the failure with identical parameters.
4

Test Single Changes

Modify one variable at a time (gas, value, approval, slippage) until the simulation succeeds.

Quick Reference

FailureKey IndicatorFix
Out of gasTrace ends abruptly, OOG errorUse gasLimit from quote
Allowancetransfer amount exceeds allowanceApprove correct spender
Balanceinsufficient balanceRe-quote and verify balance
Missing valueNative transfer failsInclude msg.value from API
SlippageMin output check failsIncrease slippage, execute faster
Stale oracleStalePrice errorsReport to LI.FI support
Token restrictionSafeERC20: low-level call failedReport token for deny list
Broken poolMath convergence failsReport pool for blacklist
ReentrancyLOCKED errorsReport pool for blacklist
Deadline expiredEXPIREDRe-quote and execute quickly