Optimism PBC Blog
Published in

Optimism PBC Blog

The Road to Sub-dollar Transactions Part 1: Slashing Fees by 30%

Sup nerds!

Last month was Optimism’s 1-year mainnetiversary. We’re incredibly proud of this milestone — but the path is far from over. As rollups mature, the path to sub-dollar fees begins.

About a month ago, we took the next step down this path, cutting transaction fees by about 30%. An average Uniswap trade dropped from $3.35 to $2.55, and at times has neared $1. Wonder how exactly we were able to accomplish this? Read on to find out!

A Primer on Optimism Transaction Fees

In order to understand how we cut costs we first need to understand what makes up a transaction fee on Optimism. Fees are made up of 1) Rollup Costs: The cost of “rolling up” transactions into batches and submitting them to Ethereum (L1), and 2) L2 Execution Costs: The cost to run the transaction on Optimism (L2). For a deeper-dive, read “How Optimism Works” in the Optimism docs.

1) Rollup Cost

Rather than paying L1 Ethereum gas prices for your entire transaction execution, on Optimism you only pay those prices for the portion of your transaction data that is submitted to L1 in a transaction batch. This cost includes the actual Calldata (input data) for your transaction, as well as a Fixed Overhead cost, which is the additional processing required to add an additional transaction to the largerbatch.

Optimism also adds a dynamic overhead (Fee Scalar) premium. This gives us a buffer in case L1 prices rapidly increase, and excess funds are directed towards public goods. (Read about Optimism PBC’s commitment to Public Goods Funding and a retrospective on our first funding round).

Calldata cost and L1 Gas Price are derived from L1 Ethereum, but Fixed Overhead and Fee Scalar are the “fancy numbers” that can be tuned by Optimism.

The “Layer 1 Gas Fee” represents these rollup costs:

Layer 1 Gas Fee =Fee Scalar * L1 Gas Price * (Calldata + Fixed Overhead)

Rollup costs currently make up about 99.6% of a transaction fee on Optimism, so we have the greatest potential to lower fees by optimizing this portion.

2) L2 Execution Cost

Transactions on Optimism use the same amount of gas as an equivalent transaction would use on Ethereum; however, the standard cost for gas on Optimism is only 0.001 gwei, many times cheaper than Layer 1. This gas price can increase slightly during high usage periods, but only makes up 0.4% of the total transaction fee on average.

The “Layer 2 Gas Fee” represents the execution cost:

Layer 2 Gas Fee = L2 Gas Price * L2 Gas Used

Transaction Savings

Adding the rollup costs and L2 execution costs gives us the total transaction fee. For simpler transactions such as ETH transfers, Optimism fees are about 5x cheaper than Ethereum, but for more complex actions such as a perpetual swap or an options trade, Optimism can be 200x+ cheaper than using L1 Ethereum directly!

Finding Our New Fee Parameters

Before we lowered fees, Fixed Overhead parameter was set to 2750 gas per transaction, and the Fee Scalar was set to 1.5x. A few things changed since these were originally set:

  1. Lower Cost Structure: As a result of Optimism’s Nov 11 EVM Equivalence upgrade, less gas is needed to submit Optimism transaction batches to L1. The actual overhead cost decreased almost 25%, from 2750 to 2100 gas per transaction.
  2. Learning from Experience: While it was still super early in Optimism’s life, we learned from our first few months of mainnet that we had capacity to reduce the premium buffer from a ~35% margin to a 10% margin (Margin = [Fees Collected — L1 Submit Costs] / Fees Collected).
Overhead Gas Decrease on EVM Equivalence Upgrade

Projections and Optimizations

The next step was to translate these lower costs into cheaper fees for Optimism users. To properly tune the Fixed Overhead and Fee Scalar parameters, we had to understand what influences our fee margin:

  1. Calldata: Calldata gas varies by transaction type (i.e. ETH Transfer: 0 calldata gas, Chainlink Oracle Update: 890 gas, Uniswap V3 trade: 3200 gas). An average transaction used 1100 calldata gas, but this will trend higher or lower as different apps gain popularity Optimism.
  2. Overhead: The cost of adding a transaction to a batch decreases as the total batch size increases. This is one of the ways where Layer 2 scaling differentiates from Layer 1 scaling: The more transactions there are, the cheaper transactions become. Overhead has already dropped from 2750 to 2100 gas, and will continue to decrease as Optimism usage increases.
  3. L1 Gas Prices: Transactions are submitted to L1 a few minutes after they happen on Optimism, and L1 Gas Prices change quite a bit in that time. If L1 gas prices rise, then the submitter pays more than it expected to, and if L1 gas prices fall, then it pays less than it expected to. During volatile gas price periods, this gap can get as wide as a 10% difference.
Transaction Batch Submitter — Overhead Gas Costs by Batch Size

We knew what these factors looked like today, but expected that usage could change once we lowered fees (i.e. more transactions, more calldata used). So we made some hypotheses to come up with a range of scenarios, and then simulated 5000 random days within those bounds (think Monte Carlo method). From there, we had a simple optimization problem: get as close as possible to our target 10% margin by changing the Fixed Overhead and Fee Scalar.

The result: Fixed Overhead of 2100 and Fee Scalar of 1.24

To implement the change, we just had to send two transactions: One to modify the Fixed Overhead, and one to modify the Fee Scalar. Then voila: 30% lower transaction fees!

Want to stay up to date with the data? See our Transaction Cost Contributors Dashboard here.

Hold on wait a minute, you all thought we were finished?

As we said at the outset — this was just a step in a continuous path of reducing our network fees. As the product keeps maturing, more and more OPtimizations will arise. Stay tuned for an upcoming article on the next step: transaction compression! And if you can’t wait, take a sneak peek — as always, we’re building it out in the open.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store