Six EVM decompilers compared on the Uniswap V2 pair
Hundreds of DEX forks across EVM chains deploy copies of UniswapV2Pair, and many of those copies are unverified. The USDC/WETH pair on Ethereum is verified, so anything a decompiler prints for it can be checked against the source. We ran six EVM decompilers on the pair's runtime bytecode and checked every function. All five other decompilers produced more than ten behavioral errors each, without marking any line as uncertain. In EVMole's output we found none.
On an unverified fork, the decompiled code is all you have to go on. Below are three of these errors, in pool math, supply accounting, and token permissions. Each shows what the contract does, what was printed, and what you would conclude from it.
Three decompilers break the square root of the first deposit
The first liquidity provider to deposit into a pair receives the square root of the product of the two token amounts, minus 1,000 LP tokens that stay permanently locked. Math.sqrt computes that root iteratively: x starts at half the input plus one and decreases on each pass until it stops falling.
function sqrt(uint y) internal pure returns (uint z) {
if (y > 3) {
z = y;
uint x = y / 2 + 1;
while (x < z) {
z = x;
x = (y / x + x) / 2;
}
} else if (y != 0) {
z = 1;
}
}varg0 = v0 = (varg0 >> 1) + 1;
while (varg0 < varg0) {
assert(varg0);
assert(2);
varg0 = varg0 / varg0 + varg0 >> 1;
}
return varg0;var_36 = var_34;
var_37 = unchecked(var_34 / 2 + 1);
while (var_37 < var_36) {
require(var_37 != 0);
var_36 = var_37;
var_37 = unchecked(div(var_34, var_37) + var_37) / 2;
}
var_38 = var_36; Decompiler A tests varg0 < varg0, comparing the same variable against itself, so the loop never runs and the function returns 500,001 instead of 1,000. B updates z after x inside the loop, stopping after one pass and returning 250,001. C drops the loop altogether: its mint cuts off before the first-deposit branch, and its protocol-fee calculation computes each root without a loop. Going by any of the three, you would compute the wrong LP share for the first depositor.
Three decompilers never take burned tokens out of the supply
burn redeems LP tokens for the underlying pool assets. The pair reads its own LP balance once into liquidity, and _burn deducts that amount from both the pair's balance and totalSupply. Decompilers A, B, and D read the balance from storage again after zeroing it out.
function _burn(address from, uint value) internal {
balanceOf[from] = balanceOf[from].sub(value);
totalSupply = totalSupply.sub(value);
emit Transfer(from, address(0), value);
}balanceOf[address(this)] =
balanceOf[address(this)] - balanceOf[address(this)];
require(totalSupply - balanceOf[address(this)] <= totalSupply,
"ds-math-sub-underflow");
totalSupply = totalSupply - balanceOf[address(this)];
emit Transfer(address(this), address(0),
balanceOf[address(this)]);var_10 = storage_balanceOf[address(this)];
// …
storage_balanceOf[address(this)] = SafeMath.sub(
storage_balanceOf[address(this)], var_10, "ds-math-sub-underflow");
storage_totalSupply = SafeMath.sub(
storage_totalSupply, var_10, "ds-math-sub-underflow");
emit Transfer(indexed: [address(this), 0], data: [var_10]); In B's output, totalSupply never decreases and the Transfer event logs 0 tokens burned. Leaving burned tokens in totalSupply would break every subsequent mint and burn share calculation. A emits the same re-read, and D subtracts the zeroed balance from totalSupply the same way.
Two decompilers make the same mistake in USDC's permit nonce: reading a storage slot again after overwriting it.
Two decompilers lose the allowance in transferFrom
transferFrom lets a spender move LP tokens that an owner has approved, deducting the transfer amount from the allowance first. Because LP tokens are a claim on pool liquidity, this check is what stops anyone else from draining a holder's position.
function transferFrom(address from, address to, uint value) external returns (bool) {
if (allowance[from][msg.sender] != uint(-1)) {
allowance[from][msg.sender] = allowance[from][msg.sender].sub(value);
}
_transfer(from, to, value);
return true;
}require(balanceOf[arg0] - arg2 <= balanceOf[arg0],
"ds-math-sub-underflow");
balanceOf[arg0] -= arg2;
require(balanceOf[arg1] + arg2 >= balanceOf[arg1],
"ds-math-add-overflow");
balanceOf[arg1] += arg2;
emit Transfer(arg0, arg1, arg2);
return true;if (storage_allowance[arg_0][msg.sender] != type(uint256).max) {
storage_allowance[arg_0][msg.sender] = SafeMath.sub(
storage_allowance[arg_0][msg.sender], arg_2,
"ds-math-sub-underflow");
}
storage_balanceOf[arg_0] = SafeMath.sub(storage_balanceOf[arg_0], arg_2,
"ds-math-sub-underflow");
storage_balanceOf[arg_1] = SafeMath.add(storage_balanceOf[arg_1], arg_2,
"ds-math-add-overflow");
emit Transfer(indexed: [arg_0, arg_1], data: [arg_2]);
return 1; Decompiler C outputs a transferFrom with no allowance check at all: anyone appears able to transfer anyone else's LP tokens. Across the entire listing C produces, allowance only shows up in approve and permit. E's transferFrom stops right after checking the allowance, so it neither deducts the approval nor moves the tokens.
How the outputs were checked
Every decompiler was given the same runtime bytecode: the USDC/WETH pair, read from Ethereum on 13 October 2026. It is 11,293 bytes with 27 public functions, compiled with Solidity 0.5.16. The pair is not a proxy: the code compared is the code at its address, 0xB4e16d0168e52d35CaCD2c6185b44281Ec28C9Dc.
AI agents first reviewed each output against the verified source, function by function, looking for behavioral differences: wrong values, missing or invented checks, dropped writes, calls, or events, or truncated functions. Names, formatting, and readability did not count, and a mistake repeated across several functions counted once in each. We then checked every error shown on this page by hand against the source and each decompiler's output.
EVMole checks every decompiled function against the original bytecode with differential fuzzing before showing it (how the decompiler works).
Check it yourself
- The verified source on Sourcify, at the lines quoted above: Math.sqrt, _burn, and transferFrom.
- EVMole's output for the same code in the workbench: mint, burn, and transferFrom.
- Full writeups on USDC and Safe 1.3.0. Single-function examples on Tether, the Uniswap V2 router, and Chainlink are on the home page.