Mathematics is the language in which God has written the universe

Galileo Galilei

Problem

  • No support for fixed-point arithmetic in Solidity
  • Implementing advanced math functions is hard
  • No popular fixed-point math library upgraded to v0.8

Solution

PRBMath

  • Logarithms, exponentials, square roots and more
  • Gas efficient, but still user-friendly
  • Operating with decimal numbers with 18 decimals

Comparison

PRBMath is the fastest, the most-well documented and the only offering Solidity v0.8.4 custom errors.

Comparison of fixed-point math libraries

Dev UX

I added NatSpec comments to each and every single piece of code in the library.

PRBMath source code with NatSpec comments

Testing and Security

  • 1102 test cases w/ Hardhat and Waffle
  • 98% coverage
  • Audit coming later this year

Use Cases

  • AMM Curves
  • Calculating interest rates
  • Pricing derivatives like options
  • TWAP oracles
  • Custom trading algos for Uniswap v3

Case in Point: Hifi AMM

YieldSpace formula used by the Hifi AMM

Case in Point: Hifi AMM

Hifi AMM Solidity implementation

License: Unlicense

Thanks for Coming!

  • Twitter: @PaulRBerg
  • GitHub: @paulrberg