prb-math
prb-math copied to clipboard
Solidity library for advanced fixed-point math
It would be a nicer DX if the [TypeScript functions](https://github.com/paulrberg/prb-math/blob/e33a042e4d1673fe9b333830b75c4765ccf3f5f2/src/functions.ts) were shipped as an extension to the Ethers BigNumber type.
The idea is to merge the [mulDiv18][1] and the [mulDivSigned][2] functions into one, and thus to avoid duplicating the logic in the [mul][3] and the [div][4] functions of `SD59x18`. [1]:...
As @nonergodic has aptly mentioned [here](https://github.com/paulrberg/prb-math/issues/97#issuecomment-1173185195), the comment on line 604 of `PRBMath.sol` is incorrect: https://github.com/paulrberg/prb-math/blob/e33a042e4d1673fe9b333830b75c4765ccf3f5f2/contracts/PRBMath.sol#L604 Instead the comment should say something along the line of: > Set the initial...
In the `PRBMath.sol` contract, the [`msb`](https://github.com/paulrberg/prb-math/blob/989d8e233fdfbef1e766a2baa25355cbfefb3786/contracts/PRBMath.sol#L280) function defines the powers of two as `2**n` (in base 10), whereas `sqrt` defines them using hexadecimal notation `0x10...` (base 16). It would be...
As @nonergodic has explained in this [comment](https://github.com/paulrberg/prb-math/issues/97#issuecomment-1165851674), it might be more gas efficient to replace all the `>= CONSTANT` statements with `> CONSTANT-1`. My only reservation is that this might...
for every `uint > 0` check, replace with `uint != 0` to save about 44 gas per call see: https://github.com/KadenZipfel/gas-optimizations/blob/main/gas-saving-patterns/optimal-comparison-operator.md
I remove the unnecessary operation in avg function.
Either overload `toSD59x18` to accept `uint256` inputs or write a new convertor functions that accepts `uint256`.
Uniswap is the most popular DEX in DeFi. We should provide an example for how to use PRBMath when building something on top of Uniswap V2 and/ or Uniswap V3.
It still has many weekly downloads.