Flow of an Order
Swaps on Angstrom L2 follow the standard Uniswap v4 flow. The only differences are the deterministic MEV tax and the LP-compensation bookkeeping that run inside the hook. No off-chain coordination or batching is involved.
-
Router calls
IPoolManager.swap
The caller specifies the Angstrom-enabled pool (which must have the native asset ascurrency0) and any hook data. The pool manager then orchestrates hook callbacks around the core Uniswap swap. -
beforeSwapcomputes the MEV tax
PoolManagercallsAngstromL2.beforeSwap. The hook snapshots pool state, evaluates
tax = SWAP_TAXED_GAS * SWAP_MEV_TAX_FACTOR * (tx.gasprice - block.basefee), and returns aBeforeSwapDeltathat debts that many wei ofcurrency0from the caller. Nothing moves yet—the amount sits as an outstanding obligation that must be settled later.- For zero-for-one swaps (the trader spends the native asset) the router must budget the swap input plus the MEV tax so it can clear the delta when settlement happens.
- For one-for-zero swaps (the trader receives the native asset) the router still owes the tax separately; the quoted output stays intact until
settletransfers the tax.
-
Uniswap v4 executes the swap
With state cached, the pool manager performs the swap exactly as in vanilla v4, consuming liquidity, updating ticks, and emitting the provisionalBalanceDelta. -
afterSwapallocates the tax and fees
AngstromL2.afterSwapreceives the swap delta and:- Splits the normal swap fee between the pool creator and the protocol.
- Splits the recorded tax into creator, protocol, and LP compensation buckets, minting/booking balances so each share can be pulled once the caller settles.
- Updates reward accounting for the traversed ticks and runs the compensation solver to credit LPs.
- Returns the hook’s net unspecified-currency delta so the pool manager can track what remains owed.
-
Router settles and unlocks
The router (or whoever initiated the swap) finalises the trade by callingPoolManager.settle, paying the outstanding native-token delta from step 2 along with any other balances. Once all deltas reach zero the swap completes.
Because every step remains inside the existing Uniswap v4 flow, any router that already supports v4 hooks can integrate Angstrom L2—just ensure native-token funding covers both the trade itself and the MEV tax at settlement time.