prb-math
prb-math copied to clipboard
Console.log for the UD60x18, SD59x18 types
Describe the feature you would like
A way to console.log for the UD60x18, SD59x18 types.
Additional context
No response
Thanks @asparuhdamyanov for your feature request.
Extending things like Forge's console.log and console2.log is difficult in Solidity because Rust-like traits are not supported.
One idea is to create a bespoke prbConsole library. Users would have to import both that and the Forge library. Would this work for you?
Note that in the meantime, you can unwrap the PRBMath types like so:
import { ud, unwrap } from "@prb/math/src/UD60x18.sol";
import { console2 } from "forge-std/src/console2.sol";
function testFoo() external view {
UD60x18 x = ud(3.14e18);
console2.log(unwrap(x));
}
or using UD60x18.unwrap(x).