Preprint v1, 19 September 2026 measured in Foundry

Making simulation affordable on chain

All figures generated by the test suite that checks them

Abstract. Every on-chain option protocol prices with a closed form. A closed form is cheap, and that is the reason: simulation costs too much to run inside a call. The price of that choice is paid twice. Contracts with no closed form cannot be quoted at all, and the volatility a closed form needs has to arrive from somewhere else, so it is imported from off chain or agreed by a vote. Simulation removes both problems and has been unaffordable. This paper measures where a Monte Carlo quote actually spends its gas and removes of it with three changes: warm-starting the square root from the previous step, a sampler that takes one hash instead of two, and accumulating the log so the exponential runs once a path instead of once a step. The same quote falls from to gas, times cheaper, and the price it returns moves by parts in 1018. A free view call that stopped at 32 paths reaches 128, which halves the error of the estimate it returns.
Keywords. Monte Carlo, option pricing, gas, fixed point, view calls, Solidity

1Why nobody simulates

Siren, Lyra, Dopex, Premia, Pods, Rysk and Auctus all price with Black-Scholes, directly or with modifications [1]. The reason is arithmetic: a closed form is a handful of operations, and a simulation is thousands.

Two things follow. The first is that a payoff with no closed form has no price. Barriers, digitals and arithmetic Asians are ordinary instruments and none of them can be quoted this way. The second is subtler. A closed form takes volatility as an input, and volatility is not observable, so it has to be supplied. Premia builds a volatility surface off chain and imports it through an oracle; Dopex has market makers vote on the steepness of the implied volatility curve [1]. The price is computed on chain and the number that decides it is not.

A simulation needs neither. It walks the price forward and averages what the contract pays, so any payoff that can be written as a function of a path can be quoted, and the process it walks is the model rather than a parameter handed to one. What stops it is cost. This paper measures that cost and takes most of it away.

2What a path is made of

One step of a simulated path draws a normal, scales it by the current standard deviation, and moves the price. When the variance is not constant the step also updates it, which needs a square root. Measured on their own, over two hundred calls each:

Table 1. The pieces of a step, priced separately. The right column is what this paper replaces each with.

pieceas usually writtenrewrittensaving

Two of the three give most of themselves up. The exponential does not: it is already close to as cheap as a Taylor series with argument reduction gets, and rewriting it as binary powers returns almost nothing. It is still the largest single item in a quote, because a path calls it every step.

3The three changes

The root, warm started. A variance recursion needs the standard deviation, and taking the root from scratch is a division loop run to convergence. But the root barely moves between steps, so the previous one is already close and Newton needs only a few passes from it. Section 4 measures how few.

The sampler, one hash. A standard normal built from the sum of twelve uniforms is conventionally taken from two hashes and a loop over six shifts each. One hash carries twelve twenty-one bit uniforms, the loop unrolls, and the input can be built in scratch memory rather than allocated. The distribution is unchanged.

The exponential, once a path. A terminal payoff does not need the price at every step, only at the end, and the terminal price is the product of the steps. Their logarithms can be summed and exponentiated once. This does not make the exponential cheaper; it calls it seventy-eight times less. Barriers and Asians still need the price at every step and keep the long form.

4What warm starting costs

Newton converges from any positive guess, given enough passes. The question is how many, and the answer depends on how far the guess is from the answer. While the variance creeps, three passes are enough. A real path does not creep: a single large shock can take the variance up more than fourfold in one step, and from that far away three passes land well short.

Table 2. Passes against exactness, priced as a whole quote of 16 paths and 78 steps. Drift is measured against seven passes.

Newton passesgasdrift, parts in 1018

Five passes land on the same number as seven and cost less. Three is a saving that quietly costs precision; six is precision already paid for. Everything below uses five.

5The quote

Each change applied to the one before it, on a single quote of 16 paths and 78 steps with a variance that feeds on itself:

Figure 1. Gas for one quote as each change is added. The first two are cheaper arithmetic; the third is the same arithmetic run far less often, and it is the largest of the three.

Table 3. The same, as numbers.

appliedgassaving

The price the quote returns moves by wei in , which is parts in 1018. A Monte Carlo estimate at this path count carries a standard error near one percent, so the change is thirteen orders of magnitude below the noise it sits in.

6What it buys

A simulation's error falls with the square root of the number of paths, so paths are the only thing a quote is really buying. Public nodes commonly cap a view call near fifty million gas.

Table 4. One quote at 78 steps, before and after, against a fifty million budget.

pathsbeforeafterfits a free call

Before, a free quote stopped at 32 paths. After, it reaches 128: four times the paths inside the same budget, and half the error. That is the difference between a simulated quote that is only meaningful at the money and one that is meaningful away from it.

7Scope

Gas is measured in Foundry against the Ethereum virtual machine, with the optimizer on and compilation through the intermediate representation. Figures are for the reference implementations in this repository, which are written to be read rather than to be the fastest possible; a production engine will differ. The sampler change alters no distribution and the exponential change alters no arithmetic, so both are exact. Warm starting is not exact, and Section 4 is the measurement of how inexact. The comparison of pricing approaches in Section 1 follows published descriptions of those protocols [1].

8Reproduction

test/Audit.t.sol writes every number on this page during the run that checks it. src/Bench.sol holds each piece as its own callable function; src/Engines.sol holds four engines that differ by one change each, so a saving can be read as a whole quote rather than as a part.

forge test -vv

References

  1. [1]Published descriptions of on-chain option pricing in Siren, Lyra, Dopex, Premia, Pods, Rysk and Auctus, including Premia's off-chain volatility surface delivered by oracle and Dopex's market-maker vote on implied volatility.
  2. [2]F. Black, M. Scholes. The pricing of options and corporate liabilities. Journal of Political Economy 81, 637–654, 1973.
  3. [3]P. Boyle. Options: a Monte Carlo approach. Journal of Financial Economics 4, 323–338, 1977.