BaseFeeAdjuster is a SwapVM (the Aqua swap engine) price-modifier instruction. It adjusts swap amounts based on the current network gas price: when block.basefee exceeds the maker's configured baseline, the maker improves the effective price to compensate the taker for elevated transaction costs.
Source: src/instructions/BaseFeeAdjuster.sol
Compatible with 1→0 swaps (token1 → token0) only.
Router scope: BaseFeeAdjuster is not part of the shipped Aqua router opcode set (Controls, XYCSwap, XYCConcentrate, Decay, Fee, PeggedSwap, Extruction). It is a SwapVM price-modifier instruction offered on the relevant router, alongside the other post-swap modifiers listed under Related (for example OraclePriceAdjuster), rather than on the Aqua router.
Args encoding
| Field | Offset | Size | Type | Description |
|---|---|---|---|---|
baseGasPrice |
0 | 8 bytes | uint64 |
Baseline gas price (wei); adjustment triggers when block.basefee > baseGasPrice |
ethToToken1Price |
8 | 12 bytes | uint96 |
ETH price in token1 units (1e18 scale, e.g. 3000e18 for 1 ETH = 3000 USDC) |
gasAmount |
20 | 3 bytes | uint24 |
Estimated gas units to compensate (e.g. 150000) |
maxPriceDecay |
23 | 8 bytes | uint64 |
Maximum allowed price adjustment coefficient in 1e18 scale |
Total: 31 bytes. Build with BaseFeeAdjusterArgsBuilder.build(uint64 baseGasPrice, uint96 ethToToken1Price, uint24 gasAmount, uint64 maxPriceDecay).
Instructions
_baseFeeAdjuster1D
function _baseFeeAdjuster1D(Context memory ctx, bytes calldata args) internal view
Must be placed after a swap instruction so that both amountIn and amountOut are already computed.
Behavior
When block.basefee > baseGasPrice:
- Calculates extra cost:
extraGasCost = (block.basefee − baseGasPrice) × gasAmount - Converts to token1:
extraCostInToken1 = extraGasCost × ethToToken1Price / 1e18 - Computes a price improvement ratio capped by
maxPriceDecay:
- exactIn: increases
amountOut(taker receives more token0) - exactOut: decreases
amountIn(taker pays less token1)
When block.basefee <= baseGasPrice: no adjustment is made.
Errors: BaseFeeAdjusterShouldBeAppliedAfterSwap() if amountIn == 0 || amountOut == 0.
Related
- LimitSwap: typical predecessor that sets the base amounts.
- OraclePriceAdjuster: oracle-based price adjustment, also applied post-swap.