Skip to content

v3.3.0

Choose a tag to compare

@nebojsakonsta nebojsakonsta released this 09 Jun 12:21
· 20 commits to master since this release

Pure optimization release. Same API, same precision, same return values to the last wei — just fewer opcodes in stdNormCDF. Every option pricer and greek built on the standard normal CDF gets the savings automatically.

What changed

  • Inlined erfPositiveHalf into stdNormCDF and removed the redundant (·1/√2) · √2 round-trip. The helper had no other callers, so it's gone.
  • Each branch now writes straight to the result in assembly — no shared t plumbing, no 0.5 ± half post-processing.
  • Helper erfPositiveHalf and its MathWrapper external removed.
  • INV_SQRT_2 constant removed (no longer used).

Gas savings

Function v3.2.0 v3.3.0 Saved %
stdNormCDF 734 660 −74 −10.1%
callOptionPrice 2,876 2,729 −147 −5.1%
putOptionPrice 2,887 2,739 −148 −5.1%
delta 1,797 1,724 −73 −4.1%
theta 3,441 3,293 −148 −4.3%
binaryCallPrice 2,092 2,018 −74 −3.5%
binaryPutPrice 2,097 2,023 −74 −3.5%
binaryTheta 3,501 3,353 −148 −4.2%
impliedVolatility (call) 13,100 12,370 −730 −5.6%
impliedVolatility (put) 13,184 12,446 −738 −5.6%

gamma, vega, binaryDelta, binaryGamma, binaryVega unchanged — they use the standard normal PDF, not the CDF.

Validation

  • All 572 tests pass at the same precision thresholds as v3.2.0.
  • Strict-equality perf assertions caught every gas drift automatically — no silent regressions or "improvements" possible.

Install

npm install defimath-lib@3.3.0

Links