Submitted by DadeKuma, also found by 0x1982us
Pool creation is permissionless, and users can create a pool by specifying asset denoms. The issue is that they can put a different order of the same token denoms, which should result in the same pool, but in fact, it does not. 
This ultimately cause the slippage mechanism to use the inverse ratio instead of the correct one, as in other parts of the codebase these values are always ordered, which will cause a loss of funds for the users that provide liquidity as they use the inverted slippage.
Users can create a pool by calling pool_manager::create_pool and specifying the asset_denoms.
They can call this function with the same denoms, but in a different order. In theory, this should result in the same pool, but this isnt the case.
Suppose Bob adds liquidity on a [uwhale, uluna] pool instead of a [uluna, uwhale] pool. The slippage tolerance check is triggered:
/contracts/pool-manager/src/liquidity/commands.rs#L271
This results in the following issue: supposing a k-product pool with n = 2 tokens, we calculate the slippage check:
/contracts/pool-manager/src/helpers.rs#L452
deposits are always sorted but the pool order is determined on creation. As the pool has [uwhale, uluna] instead of [uluna, uwhale] denominations, the slippage checks are inverted.
Run the following test in contracts/pool-manager/src/tests/integration_tests.rs:
Output:
If we switch the asset_infos order while creating the pool:
Output:
In pool_manager::create_pool, consider sorting the asset denoms, similarly to other parts of the code, by introducing a new struct to encapsulate both asset_denoms and asset_decimals (as they are tied together) and reorder it before creating the pool.
jvr0x (MANTRA) confirmed
