Diagnose CurrencyNotSettled at the end of a Uniswap v4 unlock

A v4 swap can complete inside an unlock callback while the surrounding transaction later reverts. The manager checks that all outstanding currency deltas have been settled before finishing the unlock.

Reconstruct deltas by account and currency

Follow all manager actions within the callback. Negative caller delta means the caller owes that currency to the manager; positive delta represents a credit. Track both sides instead of checking only a router’s net token value.

after swap: caller delta A = -100; caller delta B = +97
before unlock returns: both currency deltas must be zero

In the example the callback must cover the 100-unit A debt and consume the 97-unit B credit through supported settlement or take paths. A successful ERC-20 transfer alone need not update the manager’s delta accounting; verify the sync and settle sequence for that currency.

Include nested work before diagnosing the remainder

Multiple swaps and hooks can net deltas during the same unlock. Inspect the final outstanding account-currency entries and check native-currency versus ERC-20 settlement handling. A reverted unlock commits none of the attempted swaps. github.com PoolManager.sol