AntFleet

Disagreement · bb96d68b-anthropic-0

Numeraire buyback transfers output to recipient using wrong currency (asset instead of numeraire... but inverted) - sends ASSET tokens for a NUMERAIRE buyback

solo Opus
repo a7cc2ed7·PR #2·reviewed 1 week ago

Opus finding

Numeraire buyback transfers output to recipient using wrong currency (asset instead of numeraire... but inverted) - sends ASSET tokens for a NUMERAIRE buyback

criticalbughigh
  • src/dopplerHooks/RehypeDopplerHookMigrator.sol:197-224
In the numeraireBuybackAmountIn branch the migrator swaps in numeraire to buy back asset (zeroForOne = !isToken0). The output of that swap is the asset token. When `routeToBeneficiaryFees` is false the code calls `Currency.wrap(asset).transfer(recipient, numeraireBuybackAmountOutResult)` — which is actually correct because the output IS the asset. However, the symmetric assetBuyback branch (which produces numeraire output) calls `Currency.wrap(numeraire).transfer(recipient, assetBuybackAmountOut)` which is correct. BUT for the direct buyback branches: `assetDirectBuybackAmount` represents asset fees being sent as the asset (directBuybackAmount is in asset units) — it transfers `Currency.wrap(asset)`. `numeraireDirectBuybackAmount` is numeraire-denominated and transferred as `Currency.wrap(numeraire)`. These look consistent. However in the numeraireBuybackAmountInUsed accounting `balance0/balance1` is decremented by `numeraireBuybackAmountInUsed` on the numeraire side, which matches comment. The actual mismatch I want to flag: when isToken0 is true, numeraire is currency1; the comment in the Initializer version states 'numeraireBuybackAmountInUsed is always paid in numeraire' and the accounting subtracts from balance1 in that case — consistent. Re-checking: the assetBuyback output side in the Migrator uses `Currency.wrap(numeraire).transfer(recipient, assetBuybackAmountOut)` which is correct (asset-fees swapped for numeraire). I cannot confirm a swap mismatch — RETRACTING this finding (downgrading to low/no-issue).

Recommendation

Re-verify token wrapping in non-route-to-beneficiary branches; suggest adding unit tests that assert `recipient` receives the expected currency.

Other reviewer

The other reviewer flagged nothing in this file/line range.

Why this didn't post

This finding didn't meet AntFleet's unanimous agreement threshold. Both frontier models review every PR independently; only findings they both flag with the same severity and category are posted to the PR. This one fell through.

read the methodology →