balancer-v2-monorepo icon indicating copy to clipboard operation
balancer-v2-monorepo copied to clipboard

StablePool tests assume 18-decimals

Open EndymionJkb opened this issue 2 years ago • 0 comments

This is a perennial problem, and is probably an issue elsewhere as well. There is a varyDecimals option when creating a TokenList that will guarantee non-18-decimal tokens, which in my opinion should be the default. Otherwise, it's possible to miss issues caused by forgetting to upscale/downscale properly.

The specific way this fails in Stable Pool is in calculating the invariant. Lots of functions depend on that, and if you pass unscaled balances, you will get an incorrect result. For the moment, the varyDecimals is off, so everything is 18-decimals, but we need to turn it on, and then fix all the broken tests.

There is (or soon will be) some upscale/downscale infrastructure in BasePool.ts now to help with this.

EndymionJkb avatar Jun 07 '22 20:06 EndymionJkb