Skip to content

v3.4.0

Latest

Choose a tag to compare

@nebojsakonsta nebojsakonsta released this 14 Jun 13:03
· 2 commits to master since this release

Highlights

  • Foundry property-fuzz testing layer added — 92 mathematical properties × 32,000 random runs = 2.94M random executions per CI run. Complements the existing 589 Hardhat tests with algebraic-structure checks (round-trips, monotonicity, identities, output bounds, symmetries) across all six modules. Counterexamples are automatically shrunk on failure.
  • EXP_LOWER_BOUND refactored from uint256 magnitude to signed int256 value (−41.446e18). Lets exp's negative branch compare x directly against the bound — propagates 1–3 gas savings across every function that calls exp internally.

Gas changes

All from the same exp cleanup. No precision change, no API change.

Function v3.3.0 v3.4.0 Saved
exp 333 331 −2
expm1 439 438 −1
pow 750 748 −2
gamma 1,499 1,496 −3
theta 3,293 3,290 −3
vega 1,439 1,436 −3
impliedVolatility (call) 12,370 12,355 −15
impliedVolatility (put) 12,446 12,431 −15
binaryDelta 1,825 1,822 −3
binaryGamma 1,967 1,964 −3
binaryTheta 3,353 3,350 −3
binaryVega 1,913 1,910 −3
continuousToDiscrete 508 507 −1
internalRateOfReturn (4-cashflow) 17,043 16,995 −48
internalRateOfReturn (12-cashflow) 49,285 49,120 −165

Other cleanups

  • Added named constants LN_10, SQRT_2, ERF_BOUND to Math.sol (values were previously inline literals).
  • Function docs now use actual Solidity constant names in Bounds + Errors tables, with explicit inheritance from underlying primitives.

Compatibility

  • No API changes, no behavioural changes
  • Same input domain, same return values
  • Solidity ^0.8.31, EVM target osaka (unchanged)

Install

npm install defimath-lib@3.4.0

Links