This package works with ethnum and prb-math to implement efficient fixed-point math that works with numbers which are considered to have 18 trailing decimals. The criterion crate is used for benchmarking, and it has shown a performance boost of 2x to 3x in most cases (though this has yet to be tested to see if it translates into lower gas costs).
This crate was made to only work with Secret Cosmwasm v1.
better-secret-math = { git = "https://github.com/securesecrets/better-secret-math" }
In the one above, we perform 4 multiplication operations using:
- unchecked U256
- converting from Uint256 -> doing checked U256 -> converting back to Uint256
- converting from Uint256 -> unchecked U256 -> converting back to Uint256
- checked Uint256 (this is the same as unchecked Uint256 since the Mul impl for this type uses checked_mul in it)