Identify an Aave v3 repayment made with aTokens

A successful repayment can reduce debt without an incoming underlying ERC-20 transfer from the user. The reference pool exposes a repayment route that uses the caller’s aTokens of the same reserve.

Decode the pool method and rate mode

Identify repayWithATokens in the transaction and read the underlying asset, requested amount and debt mode. The reference entrypoint acts for msg.sender. Inspect the debt token and aToken records for that account rather than searching for a separate payer.

same reserve: 80 aToken units and 50 units of variable debt
repayWithATokens for 30 underlying units → reduce both positions

In the fixture, with sufficient balances, thirty nominal units of debt and thirty nominal units of supplied position are offset. Account for interest indexes and rounding at execution when comparing scaled balances; raw scaled units need not each decrease by thirty.

Classify the accounting route correctly

Record a debt repayment funded by the supplied position. Reporting both a cash withdrawal and a second cash deposit fabricates underlying transfers. Trace the actual deployed pool if a router or wrapper called it, because the immediate caller controls the on-behalf position in this entrypoint. github.com Pool.sol