Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/opz/solidity-fixedpoint
Implements fixed point numbers in Solidity using the Q number format.
https://github.com/opz/solidity-fixedpoint
ethereum fixed-point math solidity
Last synced: 3 months ago
JSON representation
Implements fixed point numbers in Solidity using the Q number format.
- Host: GitHub
- URL: https://github.com/opz/solidity-fixedpoint
- Owner: opz
- License: gpl-3.0
- Created: 2020-06-04T04:51:57.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-08-20T00:27:38.000Z (over 4 years ago)
- Last Synced: 2024-04-24T04:12:03.208Z (10 months ago)
- Topics: ethereum, fixed-point, math, solidity
- Language: JavaScript
- Homepage:
- Size: 207 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Solidity Fixed Point Library
[![Actions Status](https://github.com/opz/solidity-fixedpoint/workflows/CI/badge.svg)](https://github.com/opz/solidity-fixedpoint/actions)
[![npm](https://img.shields.io/npm/v/solidity-fixedpoint)](https://unpkg.com/solidity-fixedpoint@latest/)Implements fixed point numbers in Solidity using the [Q number format](https://en.wikipedia.org/wiki/Q_(number_format)).
Built off the Uniswap [FixedPoint](https://github.com/Uniswap/uniswap-lib/blob/master/contracts/libraries/FixedPoint.sol) and [Babylonian](https://github.com/Uniswap/uniswap-lib/blob/master/contracts/libraries/Babylonian.sol) libraries developed by [moodysalem](https://github.com/moodysalem).
This library uses the UQ192x64 format to maximize the range of fixed point numbers while keeping the resolution close to the 18 decimal places that is standard for most Solidity contracts.
Uniswap originally used the UQ112x112 format to optimize the variable packing in their contracts.
## Install Dependencies
`npm install`
## Compile Contracts
`npx buidler compile`
## Run Tests
`npx buidler test`
## Contributors
* [@opz](https://github.com/opz) 💻