osmosis icon indicating copy to clipboard operation
osmosis copied to clipboard

[stableswap]: Implement `maxNumAssets` and `maxTokensPerAsset` to ensure multi-asset pools can't overflow

Open AlpinYukseloglu opened this issue 3 years ago • 0 comments

Background

Even with extremely generous precision bounds, since we're dealing with non-linear k values for our stableswap CFMM it will almost always be possible to trigger an overflow if we don't bound the number of assets and the number of tokens for each asset. We should implement maxNumAssets and maxTokensPerAsset and add related checks to all pool creation and swapping logic to ensure that CFMM inputs are bounded.

Suggested Design

  • Hard code maxNumAssets and maxTokensPerAsset to numbers that fit within our expected precision bounds. The specific numbers are TBD depending on the max number of assets we want to be able to accommodate in a single multi-asset pool

Acceptance Criteria

  • All existing tests pass
  • Error catching tests for out of bound inputs are added and pass

AlpinYukseloglu avatar Sep 22 '22 21:09 AlpinYukseloglu