Welcome
DeFiMath is a high-performance, open-source Solidity library designed for Ethereum smart contracts. It provides optimized, gas-efficient implementations of core DeFi primitives and mathematical utilities—built with precision and performance in mind.
Why DefiMath?
DeFi primitives: core building blocks tailored for advanced financial protocols like options, futures, and other derivatives.
Gas optimized: carefully engineered for minimal gas usage without compromising precision.
High-precision math: accurate fixed-point and integer operations essential for financial calculations.
Get Started
Check out our GitHub Repository to explore the code and contribute.
Stay Updated
Join our mailing list to receive the latest Solidity optimization tips and tricks, directly to your inbox.
Sign Up for Updates
What's inside?
DeFiMath implements advanced math and derivatives functions in Solidity. The following tables provide overview of derivatives and math functions you can use:
call
European call option pricing
3203
5.6e-12
put
European put option pricing
3229
5.4e-12
delta
Call and put option price sensitivity to underlying change
2033
6.9e-15
gamma
Option price sensitivity to delta change
1707
9.1e-17
theta
Option price sensitivity to time change
3823
3.7e-14
vega
Call and put option price sensitivity to volatility change
1680
4.8e-14
exp
Exponential function
359
5.1e-12
ln
Natural logarithm
608
1.5e-12
log2
Logarithm with base 2
681
1.5e-12
log10
Logarithm with base 10
681
1.4e-12
sqrt
Square root function
383
2.8e-14
cdf
Standard normal cumulative distribution function
799
4.6e-13
erf
Error function
773
7.4e-13
Last updated