← Back to news
v3.4.0Jun 14, 2026

DeFiMath v3.4.0 — Foundry property-fuzz testing layer added

Two changes:

  1. Foundry property-based fuzz testing layer — 92 mathematical properties across all six modules, fuzzed with 32,000 random runs each. 2.94 million random executions per CI run verifying things like ln(exp(x)) ≈ x, put-call parity, Φ(x) + Φ(−x) = 1, and 89 others. Foundry shrinks counterexamples automatically on failure.
  2. EXP_LOWER_BOUND refactored from uint256 magnitude to signed int256 value (−41.446e18). Lets exp's negative branch compare x directly against the bound — 1–3 gas saved across every function that calls exp.

Foundry property-fuzz layer

Hardhat-only testing validates each function at concrete points against external JS references. Foundry adds a complementary layer that validates the algebraic structure across the random input space.

92 properties organized into five categories — round-trips, monotonicity, identities, output bounds, symmetries. Per-module breakdowns on each module's docs page. Full suite completes in ~6 seconds locally and ~30 seconds on a 2-core CI runner.

Both layers run via npm test — Hardhat first (correctness + gas regression), then Foundry (algebraic structure).

Gas changes

Every function calling exp internally inherits the savings:

Function v3.3.0 gas v3.4.0 gas Saved
exp333331−2
expm1439438−1
pow750748−2
gamma1,4991,496−3
theta3,2933,290−3
vega1,4391,436−3
binaryDelta1,8251,822−3
binaryGamma1,9671,964−3
binaryTheta3,3533,350−3
binaryVega1,9131,910−3

Small but uniform. No precision change, no API change.

No behavioural change

Same precision, same return values, same input domain. All 681 tests across Hardhat (589) and Foundry (92) pass — the new Foundry layer is fully additive, not a replacement.

Get it

npm install [email protected]