0.1.1 • Published 10 months ago

pmath_64x64 v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

PoptionFixedPointLib - 64x64 Fixed Point Numerical Operations for Smart Contracts

  • PoptionFixedPointLib is an open-source library aimed at bringing very gas efficient and high-precision numerical operations to smart contracts. This library is a part of an options smart contract project, providing essential numerical functions in a 64x64 fixed-point representation for superior precision and performance.

Features

The library supports various mathematical operations and functions including:

  • Multiplication (mul)
  • Division (div)
  • Combined multiplication and division (muldiv)
  • Natural logarithm (ln)
  • Sqrt root(sqrt)
  • Exponential function (exp)
  • Normal cumulative distribution function (normcdf)
  • Cauchy cumulative distribution function (cauchycdf)

Sure, here's the information converted into a table:

FunctionPrecision / ErrorAverage Gas Cost (over 1000 runs unless specified)comments
lnFull 64x64 precision1259The gas cost is 5 time smaller than the ABDKMath64x64 one (7126)
sqrtFull 64x64 precision629The gas cost is a little smaller than the ABDKMath64x64 one (699)
exp5e-18 relative error1793The gas cost is 1.5 time smaller than the ABDKMath64x64 one (2746)
normcdf2e-7 absolute error444.7
cauchycdf2e-12 relative error587.4

https://github.com/PaulRBerg/prb-math

Usage

Import the FixedPointLib library into your smart contract and instantiate it as needed. Each function takes as input 64x64 fixed point numbers and returns a 64x64 fixed point number.

Try running some of the following tasks:

npx hardhat help
npx hardhat test

Contribution

As an open-source project, we welcome contributions from everyone. If you're interested in contributing, please feel free to open issues or make pull requests.

License

This project is licensed under MIT LICENSE. See the LICENSE file for details.

Contact

If you have any questions or run into any issues, please feel free to open an issue on this repository.

Happy coding!

0.1.1

10 months ago

0.1.0

10 months ago