PrimeDAO / prime-launch-dapp

https://launch.prime.xyz
6 stars 13 forks source link

initializing LBP should not cause balancer to issue weight error #639

Open dkent600 opened 2 years ago

dkent600 commented 2 years ago

When I create an LBP with default weights, sign it, then try to fund/initialized it, on the initialize step it fails with the UI error "Normalized weight invariant", a Balancer error which means "the normalized weights don't sum to ONE". They should sum to 100.

dkent600 commented 2 years ago

I introduced this bug when coding to avoid another issue where bignumbers were underflowing when typing small fractions into the funding amount in the LBP dashboard.

The bug is actually in the native javascript library, in toFixed, which adds garbage at the 17 and 18 decimals.

The fix is to eliminate use of toFixed and use a different algorithm.