PRBMath: A Smart Contract Library for Fixed Point Math
summary
Library implements 18‑decimal fixed point math (log/exp/power/sqrt, mulDiv with improved rounding), uses Solidity 0.8 features and custom errors, and targets DeFi use cases. Tests show 1,400 tests and 96% coverage, npm sees >1,000 weekly downloads. Gas: sqrt ranges ~114–846, power can reach ~24,000. Precision: complex power/exp loses precision to about ~12 decimals in worst cases. Plans include migrating to Foundry and adding a user‑defined value type for stronger type safety.
AI-written summary · about
chapters (3)
related talks
22mPRBMath: A Modern Smart Contract Library for Fixed-Point Math
25mCommSec D2 - Smart Contract (In)Security
06mTezDev Paris 2022 - Frank Hillard
21mSolType: Refinement Types for Arithmetic Overflow in Solidity
48mWhy Writing Blockchain Applications is Hard, and How FP Can Help
51mA Deal with the Devil: Breaking Smart Contracts
30mMempool Primitives: A New Class of Money Legos
34mCost Analysis of Smart Contracts via Parametric Resource Analysis
