Skip to content

Add Uniswap TWAP fee oracle for batch_policy.log_gas_price - #30

Open
stephenctw wants to merge 6 commits into
mainfrom
feature/l1-fee-oracle
Open

Add Uniswap TWAP fee oracle for batch_policy.log_gas_price#30
stephenctw wants to merge 6 commits into
mainfrom
feature/l1-fee-oracle

Conversation

@stephenctw

Copy link
Copy Markdown
Collaborator

Summary

  • Add an L1 fee oracle that converts paid gas (base_fee + priority) into fee-token smallest units via a pinned Uniswap V3 WETH/X 30‑minute TWAP, applies 10× slack, and updates batch_policy.log_gas_price.
  • Share Alloy’s EIP-1559 estimator between the batch poster and the oracle so submission and charging stay on one policy; Anvil/devnet uses an explicit fixed exponent (mainnet/Sepolia default to pinned USDC pool presets).
  • Supervise the oracle as a sixth runtime worker with a mandatory refresh before the inclusion lane starts; frame fees remain immutable until the next frame opens.

Test plan

  • cargo test -p sequencer --lib fee_oracle
  • cargo test -p sequencer --lib eip1559
  • cargo test -p sequencer --lib config::
  • cargo run -p rollups-e2e --bin rollups-e2e -- fixed_fee_oracle_sets_frame_fee_test --exact
  • Confirm Anvil boots with fixed log_gas_price = 0 when fee-oracle env is unset
  • Confirm mainnet/Sepolia resolve to the pinned USDC pool presets without overrides

Drop the redundant current_frame_fee argument so dequeue/execute always
use the lane's committed WriteHead fee.
Extract Alloy's MetaMask-style medium estimator behind a small helper so
batch submission and fee charging stay on one policy.
Convert base+priority gas into fee-token units via a pinned V3 TWAP,
apply 10× slack, and persist log_gas_price through a dedicated writer.
Resolve fixed vs Uniswap sources from config, require an initial refresh
before the inclusion lane starts, and join the oracle on shutdown.
Record fee-token TWAP charging, writer ownership, env knobs, and Uniswap
pool trust in the operator-facing and threat-model docs.
Add live-source worker/math/TWAP unit tests and assert a configured
fixed log_gas_price is sampled into the first frame fee on devnet.
@stephenctw
stephenctw requested a review from GCdePaula August 3, 2026 08:06
@stephenctw stephenctw self-assigned this Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant