Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wadExp function comments mistake #343

Open
0x-stan opened this issue Nov 28, 2022 · 3 comments
Open

wadExp function comments mistake #343

0x-stan opened this issue Nov 28, 2022 · 3 comments

Comments

@0x-stan
Copy link

0x-stan commented Nov 28, 2022

https://github.com/transmissions11/solmate/blob/main/src/utils/SignedWadMath.sol#L93

// When the result is < 0.5 we return zero. This happens when
// x <= floor(log(0.5e18) * 1e18) ~ -42e18
if (x <= -42139678854452767551) return 0;

log(0.5e18) -> log(0.5e-18)

log(0.5e18) = 40.753384493332874
log(0.5e-18) = -42.13967885445277

image

@transmissions11
Copy link
Owner

ah hm nice find!

@recmo
Copy link

recmo commented Nov 28, 2022

Yeah, that should be x <= floor(log(0.5e-18) * 1e18) ~ -42e18

@0x-stan
Copy link
Author

0x-stan commented Nov 29, 2022

Another comments mistake found by @paco0x

// x is now in the range (-42, 136) * 1e18. Convert to (-42, 136) * 2**96
// for more intermediate precision and a binary basis. This base conversion
// is a multiplication by 1e18 / 2**96 = 5**18 / 2**78.
x = (x << 78) / 5**18;

should be 2**96 / 1e18 = 2**78 / 5**18

https://github.com/transmissions11/solmate/blob/main/src/utils/SignedWadMath.sol#L102

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants