Crypto Training

Transaction Forensics with TX Graph: Reading Flash Loans, Routes, and MEV in the Receipt

A block explorer lists what a transaction did. Working out why takes the receipt, the logs and the call trace. This post reads two mainnet exploit transactions that way: the Makina drain of January 2026 and the Yearn iEarn TUSD drain of December 2025.

Crypto Training•2026-02-12•21 min read

Transaction forensics diagram

A mainnet transaction worth studying is rarely a single action. The sender borrows, routes through several pools, changes the piece of state it came for, repays and settles, and all of it happens inside one atomic call tree.

flowchart TD A["EOA / searcher"] --> R["Router / executor"] R -->|flashLoan| L["Lending pool"] R -->|swap| P1["AMM / stable pool"] R -->|swap| P2["AMM / stable pool"] R -->|repay| L R -->|profit| A note1["Find the hubs (routers, pools)<br/>and the edges that cross<br/>a trust boundary (token, oracle, hook)"] R -.-> note1

An exploit has the same shape, with the victim protocol as one of the hops. Reading such a transaction well means separating the plumbing (approvals, wraps, routing) from the two or three calls where untrusted input reached someone's accounting, because those calls are what a protocol engineer can design against.

The graphs in this post come from TX Graph, a call-graph viewer, although the method needs only a receipt and, when you can get one, a trace. Both worked examples are real, and every number below can be re-derived from a node with the scripts near the end.

Receipt vs trace: know what you can and cannot see#

A transaction receipt holds the status, the gas used and the logs. An execution trace holds every internal call with its input, output, value and revert status. The receipt is the cheaper artifact, since any node that still stores the block serves it through eth_getTransactionReceipt, while a trace needs a node that exposes debug_traceTransaction or trace_transaction, or a local replay with cast run.

Two limits of the receipt are easy to forget. Logs come only from frames that did not revert, so a failed sub-call inside a successful transaction leaves nothing behind, and state can change with no event at all, as with a raw storage write or a plain ETH transfer. In the second example below, one of eight approve calls reverted and the last step moved about 1,299 ETH with a bare value transfer. Neither fact is in the receipt.

Availability is the practical problem. When we re-ran the scripts in this post in November 2026, one large public endpoint returned null for both receipts, presumably because it no longer keeps that history, while another still served the receipts and both trace methods. A null receipt for a hash you know exists means the node has dropped the block, so keep an archive-capable endpoint for this kind of work.

When all you have is the receipt, read it as a set of signals. The ones that reliably indicate a multi-step program are:

  • a log count in the dozens or hundreds
  • many distinct contract addresses among the log emitters
  • several Approval logs from the same owner at the start (an executor granting itself routes)
  • bursts of pool events (TokenExchange, Swap, Sync, mint and burn pairs)
  • gas used in the millions, close to the per-transaction cap

Two mainnet examples#

Both examples are exploit transactions.

  • 0x78921ce8d0361193b0d34bc76800ef4754ba9151a1837492f17c559f23771c43 drained Yearn's legacy iEarn TUSD vault on 16 December 2025. Rekt's write-up lists this hash and puts the attacker's profit at about $293k. The same contract family lost about $11.5M in April 2023 (our replay).
  • 0x569733b8016ef9418f0b6bde8c14224d9e759e79301499908ecbcd956a0651f5 drained the Makina DUSD/USDC Curve pool on 20 January 2026. The root cause and a runnable PoC are in our Makina write-up.

The receipts alone give this much (values from eth_getTransactionByHash, eth_getTransactionReceipt and the block header):

TxBlock (UTC)Gas usedETH valueLogsLog emittersRecognisable emitters
0x7892...1c4324,027,660 (2025-12-16 20:49:47)13,728,7870.01 ETH19642TUSD, USDC, yTUSD and three other iEarn yTokens, the yUSD vault, Curve y pool and 3pool, Morpho Blue, Aave v1 and v2, Compound
0x5697...51f524,273,362 (2026-01-20 03:40:35)4,709,5939,999 wei10013USDC, 3Crv, MIM, the MIM/3Crv pool, DUSD and the DUSD/USDC pool, 3pool, Makina's Caliber and Machine, Aave v3, Morpho Blue, WETH, a Uniswap v3 pool

The first transaction used 13.7M gas out of a 16.4M limit. Since the Fusaka upgrade of 3 December 2025, EIP-7825 caps a single transaction at 16,777,216 gas, so this program was built close to the ceiling (the block limit at the time was 60M). The second transaction carries 16,835 bytes of calldata in which the approve selector 0x095ea7b3 appears ten times, which is the look of a generic executor that is handed a list of calls to make.

Identify what you can before you have labels#

Some addresses are canonical, and recognising them is enough to form a first hypothesis.

AddressWhat it isWhy it matters in forensics
0xA0b8...eB48USDC6 decimals, present in most routes, frequent source of rounding edges
0x6B17...1d0FDAI18 decimals, common in Curve stable routes
0xC02a...6Cc2WETHETH legs, wraps and unwraps, final settlement
0xbEbc...F1C7Curve 3poolstable routing hub and a price source for other protocols
0x8787...A4E2Aave v3 Poolflash loans, liquidations, debt operations
0xBBBB...FFCbMorpho Bluefee-free flash loans, isolated lending markets

From this table alone you can say that both transactions touch a flash-loan venue and Curve stable pools, and that the second one also emits events from two contracts that belong to neither, which is where the victim is likely to be.

A simple workflow that scales#

Step 1: identify the entry contracts#

Start with the top-level to address and with any address that emits many logs. In the first example to is an unverified contract, 0x67e0...8e42. In the second, to equals from, which gets its own section below. You do not need a label for every address at this stage, because classes are enough: lending protocol, stable pool, router, wrapped ETH, unknown.

Step 2: classify the transaction archetype#

Most complex transactions fall into a few archetypes.

ArchetypeTypical signals
liquidationlending events, collateral transfers, a repay
flash loan arbitragea flash-loan event, swap events, a repayment transfer
sandwichvictim swap between an attacker swap and its reverse in the same block
oracle manipulationlarge pool move, a protocol call that reads a price, the reverse pool move
governance or adminrole-gated events, upgrades, parameter changes

Pick a bucket and then try to falsify it. For the second transaction the evidence is direct. Its calldata contains 0xe0232b42 once, the selector of Morpho Blue's flashLoan(address,uint256,bytes), and 0x42b0b77c once, the selector of Aave v3's flashLoanSimple. The receipt confirms both with a Morpho FlashLoan log at index 7 and an Aave FlashLoan log at index 92, and the 84 logs in between are the body of the loan callbacks. Inside that body, bursts of Curve events surround two protocol events named PositionUpdated and TotalAumUpdated, which matches the oracle manipulation row.

A warning about function selectors#

A selector is the first four bytes of a hash, and public databases map it back to whatever names people have registered. That makes a lookup a hint about the function and never evidence of what the function does.

The first example's top-level selector 0x2f570a23 resolves to test(bytes). That may well be the name the deployer chose, and it tells you nothing about a 13.7M-gas call into an unverified contract. The second example's top-level selector 0x34030d9e has no entry in 4byte.directory or in the Sourcify signature database. Collisions are routine too. The ERC-20 transfer(address,uint256) selector 0xa9059cbb is also registered as workMyDirefulOwner(uint256,uint256) and join_tg_invmru_haha_fd06787(address,bool), and 4byte.directory lists 51 signatures for 0x00000000. The Makina trace shows how that goes wrong in practice. It contains 208 calls to the identity precompile at address 0x04 whose data starts with four zero bytes, and our first-pass decoder, which took the first database hit for each selector, labelled them as Seaport's fulfillBasicOrder_efficient_6GL6yc.

Facts come from a verified ABI for the target contract, from a trace decoded against that ABI, and from patterns that agree across logs.

Step 3: map the trust boundary crossings#

Swaps and transfers are the plumbing. The security content of a transaction is in the calls where a protocol accepts something from a party it does not control and writes the result into its own accounting. Those boundaries are external token calls, oracle and pool reads, callbacks (hooks, ERC-777 and receiver hooks, flash-loan callbacks) and low-level calls whose return data is assumed to be well formed.

Write each one as an edge, for example protocol -> token.transferFrom, protocol -> oracle.latestAnswer or protocol -> hook.beforeSwap, and ask what the party on the right can lie about.

The Makina trace has a clean instance. Inside Caliber.accountForPosition, a script executor reads calc_withdraw_one_coin on the MIM/3Crv pool and get_virtual_price and balances on 3pool, and only afterwards multiplies by Chainlink-style feeds. The pools answer truthfully about their current state, and their current state is whatever the caller made it a few calls earlier with borrowed liquidity. A sound feed on the last multiplication does not help when the quantity being priced came from a spot read.

Step 4: look for liveness hazards#

Transactions that steal nothing still show where a protocol can be stopped. A hook or token that reverts can block every user of a pool, a path whose gas cost grows with state can be pushed out of reach, and an unbounded loop does that by itself as the protocol grows.

The gas cap gives this a hard edge. A path whose worst case needs more than 16,777,216 gas can no longer be executed in one transaction at all, so any user-critical function (withdraw, repay, liquidate) deserves a worst-case gas estimate with adversarial state. The first example ran at 13.7M, which shows how close a real program can get.

Decode events from topics#

Each log carries topics, and topic 0 is the hash of the event signature. A handful of them identify most of what a complex transaction does, with no ABI needed.

Topic 0 (prefix)EventWhat it tells you
0xddf252adERC-20 Transfer(address,address,uint256)token flow edges and their direction
0x8c5be1e5ERC-20 Approval(address,address,uint256)which spenders an executor set up, and so which venues it planned to use
0x8b3e96f2Curve TokenExchangea stable-pool swap leg
0xc42079f9Uniswap v3 Swapa concentrated-liquidity swap leg
0xd78ad95fUniswap v2 Swapa constant-product swap leg
0xc76f1b4fMorpho Blue FlashLoan(address,address,uint256)flash loan, with token and amount
0xefefaba5Aave v3 FlashLoanflash loan, with asset, amount and premium
0x7fcf532cWETH Withdrawal(address,uint256)unwrap to ETH, usually the settlement step

Counting Transfer logs per token shows which assets carry the route. In the Makina transaction USDC has 17, 3Crv has 14 and MIM has 8. In the Yearn transaction the yUSD vault token has 20, USDC 15, TUSD 14 and yTUSD 8. The tokens at the top are the working capital and the pool tokens being pushed around. In both examples the victim's own token sits lower in the list (DUSD with 4 transfers, yTUSD with 8).

The Makina transaction, step by step#

The receipt of 0x5697...51f5 is enough to reconstruct the whole attack. The log indices below are from eth_getTransactionReceipt, and the amounts are the raw values scaled by each token's decimals.

sequenceDiagram participant S as Sender EOA with delegated code participant M as Morpho Blue participant A as Aave v3 Pool participant D as DUSD/USDC pool participant C as 3pool and MIM/3Crv pool participant K as Makina Caliber and Machine participant U as Uniswap v3 USDC/WETH participant B as block.coinbase S->>M: flashLoan 160.59M USDC M->>S: onMorphoFlashLoan S->>A: flashLoanSimple 119.41M USDC A->>S: executeOperation loop two rounds S->>D: add 100M USDC, buy DUSD with 10M USDC S->>C: 170M USDC into 3pool, 150M 3Crv into MIM/3Crv S->>K: accountForPosition, updateTotalAum K->>C: calc_withdraw_one_coin, get_virtual_price S->>D: sell DUSD, remove liquidity S->>C: unwind both pools S->>K: accountForPosition, updateTotalAum end S->>A: repay 119.47M USDC S->>M: repay 160.59M USDC S->>U: 4.24M USDC for 1,299.18 WETH S->>B: 1,299.05 ETH
LogsEmitter and eventWhat it shows
0 to 6seven Approval logs from the senderspenders are the DUSD/USDC pool, 3pool, the MIM/3Crv pool, Aave and Morpho, so the plan is visible before anything moves
7 to 9Morpho FlashLoan, two USDC Transfer160,590,920 USDC from Morpho Blue and 119,409,080 USDC from Aave's aToken contract, exactly 280,000,000 in total
10 to 15DUSD/USDC pool AddLiquidity, TokenExchange100M USDC added as liquidity, then 10M USDC swapped for 9,215,229 DUSD
16 to 273pool AddLiquidity, MIM/3Crv AddLiquidity, RemoveLiquidityOne, TokenExchange170M USDC becomes 163.45M 3Crv, of which 150M goes into the MIM/3Crv pool. The last swap sells 120M 3Crv for 37,743 MIM, so the pool is almost out of MIM and far out of balance
28 and 29Caliber PositionUpdated, Machine TotalAumUpdatedthe position is re-valued at 19,363,192 and total AUM is written as 67,886,575 (6-decimal units)
30 to 35DUSD/USDC pool TokenExchange, RemoveLiquidityOnethe same 9,215,229 DUSD now sells for 12,785,692 USDC, and the LP position returns 100,666,132 USDC
36 to 47MIM/3Crv and 3pool eventsthe manipulation is unwound and 169,585,244 USDC comes back from 3pool
48 and 49PositionUpdated, TotalAumUpdatedthe position is back at 3,114,287 and AUM at 51,637,670
50 to 89the same sequence againround two: AUM goes to 68,217,264 and back to 51,688,025
90 to 93Aave ReserveDataUpdated, FlashLoan, two USDC TransferAave is repaid 119,468,784 USDC (a 0.05% premium of 59,705 USDC) and Morpho 160,590,920 USDC (no fee)
94 to 99Uniswap v3 Swap, WETH Withdrawalthe remaining 4,244,312 USDC is swapped for 1,299.18 WETH and unwrapped

Logs 28, 29, 48 and 49 are the finding. A value that prices DUSD moved from about 51.6M to 67.9M and back inside one transaction, on a call that an arbitrary sender made in the middle of a flash loan. Everything else is the cost of setting that up and the mechanics of cashing it out. The two rounds returned 283.04M and 281.27M USDC for 280M put in each time, which gives 4,304,016 USDC before Aave's premium and matches the profit in our PoC.

The trace adds three things the receipt cannot show. The eighth approve (3Crv to 3pool) reverted and the program carried on. The pool reads described under step 3 of the workflow happen inside accountForPosition, between the manipulation and the DUSD sale. The last call in the transaction sends 1,299.05 ETH to 0xa6c2...8387, which is the miner field of block 24,273,362, and leaves the sender about 0.13 ETH.

Using TX Graph productively#

TX Graph takes a network, a transaction hash and, optionally, your own RPC URL and Etherscan key. It requests debug_traceTransaction with the callTracer and draws the call tree as a graph, with contract names from explorer metadata. It can also load the trace of a local Foundry test, which is useful for comparing a PoC against the real transaction.

Its value is that it shows structure, and a large trace has too much of it to read linearly. The Makina trace has 1,107 call frames (155 CALL, 220 DELEGATECALL, 732 STATICCALL), 16 levels deep, across 74 distinct addresses. Opening every node is a way to lose an afternoon, so start with three questions.

  1. Where is the root? The top-level to, and whether it is a contract, a proxy or the sender itself.
  2. Where are the hubs? Nodes that originate many calls. In the Makina trace the sender makes 48 calls, the script executor that Caliber delegates to makes 44, 3pool 20, the MIM/3Crv pool implementation 18 and the DUSD/USDC pool 12. Count CALL frames only, since proxies inflate the numbers with one DELEGATECALL per call.
  3. Which edges cross a trust boundary? Calls from a protocol into a token, a pool, an oracle or a callback target, as in step 3 of the workflow.

A status note, as of 24 November 2026: the upstream Cyfrin/tx-graph repository is archived (last commit in March 2026), and the hosted instance returned an error for the Makina hash on its built-in RPC, so expect to supply your own trace-capable endpoint in the RPC field. cast run <hash> --rpc-url <url> is the dependable fallback. It replays the transaction locally and prints the decoded tree, 2,327 lines for the Makina transaction, in about five minutes over a free public endpoint.

Recognizing MEV structure from the outside#

Without builder and relay data you can still read several MEV signals from the transaction and its block.

SignalWhy it is MEV-shaped
index 0 to 2 in the block (the Makina transaction is index 0, the Yearn one index 2)top-of-block placement is what a bundle or a winning bid buys
a direct ETH transfer to block.coinbasepayment that only happens if the transaction lands, the bundle convention
a near-zero priority fee next to a large coinbase transferthe bid is a share of the profit
packed calldata to an unverified executorsearcher infrastructure, as opposed to a wallet calling a router

Both examples have them. The Yearn transaction opens with a 0.01 ETH transfer to the coinbase of a Titan-built block. The Makina transaction set a priority fee of 1 wei and handed 99.99% of its proceeds to the coinbase, which is what you would expect from a copied transaction outbidding the original. Our write-up identifies its sender as an MEV bot that front-ran the attacker.

For protocol design the conclusion is the one in Ethereum Is a Dark Forest: once a profitable call exists, assume somebody can choose its ordering and will pay nearly the whole profit to do so. Slippage bounds, TWAP windows, caps and circuit breakers are how that assumption becomes visible in code.

Scripts: pull the signals yourself#

These run on Node 18 or later with no dependencies. ETH_RPC_URL must point at a node that still serves the block you ask about.

JS
const RPC = process.env.ETH_RPC_URL;

export async function rpc(method, params) {
  const res = await fetch(RPC, {
    method: "POST",
    headers: { "content-type": "application/json" },
    body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
  });
  const { result, error } = await res.json();
  if (error) throw new Error(`${method}: ${error.message}`);
  return result;
}

export async function summarize(txHash) {
  const [tx, rc] = await Promise.all([
    rpc("eth_getTransactionByHash", [txHash]),
    rpc("eth_getTransactionReceipt", [txHash]),
  ]);
  if (!tx || !rc) throw new Error("node has no data for this hash (pruned history?)");
  const emitters = new Set(rc.logs.map((l) => l.address.toLowerCase()));
  return {
    block: Number(tx.blockNumber),
    type: Number(tx.type),
    from: tx.from,
    to: tx.to,
    selfCall: tx.from === tx.to,
    selector: tx.input.length >= 10 ? tx.input.slice(0, 10) : null,
    gasUsed: Number(rc.gasUsed),
    gasLimit: Number(tx.gas),
    status: Number(rc.status),
    logCount: rc.logs.length,
    logEmitters: emitters.size,
  };
}

Count Transfer logs by token#

JS
const TRANSFER_TOPIC0 =
  "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef";

export async function transfersByToken(txHash) {
  const rc = await rpc("eth_getTransactionReceipt", [txHash]);
  if (!rc) throw new Error("node has no receipt for this hash (pruned history?)");
  const counts = new Map();
  for (const log of rc.logs) {
    if (log.topics[0] !== TRANSFER_TOPIC0) continue;
    const token = log.address.toLowerCase();
    counts.set(token, (counts.get(token) || 0) + 1);
  }
  return [...counts.entries()].sort((a, b) => b[1] - a[1]);
}

Look up selector candidates#

JS
export async function selectorToCandidates(sel) {
  const url = `https://www.4byte.directory/api/v1/signatures/?hex_signature=${sel}`;
  const res = await fetch(url);
  const j = await res.json();
  return (j.results || []).map((r) => r.text_signature);
}

Treat the output as candidates. A generic name such as test(bytes) or several unrelated names for one selector mean the database has nothing to tell you, and a verified ABI for the target contract always takes precedence. cast 4byte <selector> does the same lookup against the Sourcify signature database.

Measure the call tree#

JS
export async function callShape(txHash) {
  const root = await rpc("debug_traceTransaction", [txHash, { tracer: "callTracer" }]);
  const byType = {};
  const fanOut = new Map();
  let frames = 0;
  let maxDepth = 0;
  (function walk(call, depth) {
    frames += 1;
    maxDepth = Math.max(maxDepth, depth);
    byType[call.type] = (byType[call.type] || 0) + 1;
    for (const child of call.calls || []) {
      if (child.type === "CALL") {
        fanOut.set(call.to, (fanOut.get(call.to) || 0) + 1);
      }
      walk(child, depth + 1);
    }
  })(root, 0);
  const hubs = [...fanOut.entries()].sort((a, b) => b[1] - a[1]).slice(0, 5);
  return { frames, maxDepth, byType, hubs };
}

This is the hub question from the TX Graph section as a function. It needs an endpoint that exposes debug_traceTransaction, which most free tiers do not.

Turning forensic insight into protocol defense#

Reading transactions changes how you write contracts, and three design habits follow directly from the examples above.

1) Assume transactions are programs#

A protocol that reasons about one user calling one function once will be surprised by routers that batch calls, by flash-loan compositions and by searchers who call it several times in a block. The Makina sender called accountForPosition and updateTotalAum four times each in a single transaction, with pool moves in between. Properties therefore have to hold across sequences of calls, which is the subject of Invariant-First Auditing.

2) Make price reads explicit and bounded#

Every path that reads a price, a virtual price or a pool balance should say which source it uses, what it costs to move that source for one block, and what bounds the damage if someone pays that cost. In Makina's case the answers were a spot read, the price of a flash loan, and nothing. A cap on how far AUM may move per update, a delay between re-accounting and use, or restricting who may trigger re-accounting would each have changed the outcome. Oracles and TWAPs covers the options.

3) Engineer for liveness#

Reverts and gas growth are security failures in their own right. A hook that can make every swap revert freezes funds for as long as it chooses to, and bounty programs such as Immunefi's classification rate temporary freezing of funds as high and permanent freezing as critical. Gas Griefing and Untrusted Reverts goes through the patterns.

A note on "from == to"#

The Makina transaction has the same address as from and to, and still produces 1,107 call frames. The explanation is EIP-7702, live on mainnet since the Pectra upgrade of 7 May 2025. The sender's account code is 0xef0100 followed by the address 0x454d03b2...b724e8, which is a delegation indicator: any call to the account executes the code at that address in the account's own context. The transaction itself is an ordinary type 2 transaction, because the delegation was set earlier and stays until the owner replaces it.

So an EOA can now send a transaction to itself and run an arbitrary program, with tx.origin equal to msg.sender in every call that program makes directly. The EIP states the consequences plainly: it breaks sandwich protections that rely on tx.origin and reentrancy guards of the style require(tx.origin == msg.sender). Any code that treats that equality as proof of a plain wallet with no code behind it has been wrong since May 2025. cast code <address> shows the delegation in one call when you want to check a sender.

Sources and further reading#