Description:
The hook logs the swapAmount in ReFiBought and ReFiSold events.
swapAmount is derived from params.amountSpecified.
In Uniswap V4:
For Exact Input swaps, amountSpecified is negative (Input Amount).
For Exact Output swaps, amountSpecified is positive (Output Amount).
Consequently:
If a user buys ReFi (Exact Input), the event logs the Input Amount (ETH).
If a user buys ReFi (Exact Output), the event logs the Output Amount (ReFi).
This inconsistency means the "Amount" field in the event has different units (Input Currency vs Output Currency) depending on the swap type.
Furthermore, for ReFiSold (Exact Output), the event logs the ETH amount (Output) but implies it is the ReFi amount sold. The fee calculation also uses this ETH amount as the base, which is incorrect as fees are charged on the input asset.
Impact:
Off-chain indexers and analytics will record incorrect volumes and fees. Users relying on these events for accounting will have corrupted data.
Proof of Concept:
test/M1_EventData.t.sol demonstrates that an Exact Output swap logs the Output Amount, whereas Exact Input logs Input Amount.
Recommended Mitigation:
To accurately log the ReFi amount in all cases, the hook would need to know the unspecified amount (which is not available in beforeSwap).
Alternatively, explicitly log the currency address along with the amount, or only log amountSpecified and zeroForOne so indexers can decode it.
Best approach: Use afterSwap to capture the actual deltas, or accept that beforeSwap can only log amountSpecified and clarify the units in the event (e.g. event SwapAttempt(int256 amountSpecified, ...)).
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.