blockulator

Option pricing and Gaussian bonding curves need Φ(x), the normal distribution's cumulative function, and on chain it is always an approximation. Each library here runs its own code at the same 385 points from −6 to 6, chosen so every format holds them exactly, and the result is compared with the exact value.

FP19 keeps 71 digits at every point. FP127 keeps 38 across the middle; in the far tail Φ(x) is near 10−9, and FP127's fixed 2−128 grid leaves it 30 digits there. Lyra v1's options market uses Hart's rational approximation and keeps 16 digits, more than any price needs. solstat, Primitive's Gaussian library, states a maximum error of 1.2 × 10−7 and meets it: about 7 digits, at a third of FP127's gas.

Primitive's earlier RMM-01 keeps about 2. Its getCDF uses the constant √2 in two places: once to scale x, which is right, and once as the Abramowitz and Stegun coefficient a3, where 1.421413741 belongs. Its error reaches 3.6 × 10−3, above the 3.15 × 10−3 its own comment states. That is a wrong constant, not a limit of the number format: with the right one the same code is good to about 10−7. Primitive's later Portfolio uses solstat.

Lyra's CDF is a public library function, so its gas includes the call into the library, as it does where Lyra is deployed.

Φ(x), the normal CDF

implementationlargest errorfewest digitsmedian digitsmedian gas
FP19
FP19, 256-bit float
2.26e-72717129,937
FP127
FP127, 127.128 fixed point
1.47e-39303813,307
solstat
WAD (10^18)
4.11e-8774,879
Lyra v1
10^27
3.99e-179167,426
Primitive RMM-01
ABDK 64.64
0.0036227,018

erfc(x)

implementationlargest errorfewest digitsmedian digitsmedian gas
FP19
FP19, 256-bit float
4.53e-72717129,357
FP127
FP127, 127.128 fixed point
1.45e-39223916,269
solstat
WAD (10^18)
7.97e-8174,260

Each library's own code at the 385 points x = k/32 from −6 to 6, exact in every representation here, against mpmath 150 digits: ncdf(x) and erfc(x) at the exact x. Digits are correct significant digits; gas is the median of a call over the points. Data: cdf.json; reproduce with make cdf.