Submitted by jonah1005
When a user provides imbalanced liquidity, the fee is calculated according to the ideal balance. In saddle finance, the optimal balance should be the same ratio as in the Pool.
Take, for example, if theres 10000 USD and 10000 DAI in the saddles USD/DAI pool, the user should get the optimal lp if he provides lp with ratio = 1.
However, if the customSwap pool is created with a target price = 2. The user would get 2 times more lp if he deposits DAI.
SwapUtils.sol#L1227-L1245
The current implementation does not calculates ideal balance correctly.
If the target price is set to be 10, the ideal balance deviates by 10.
The fee deviates a lot. I consider this is a high-risk issues.
We can observe the issue if we initiates two pools DAI/LINK pool and set the target price to be 4.
For the first pool, we deposit more DAI.
For the second pool, one we deposit more DAI.
We can get roughly 4x more lp in the first case
None
The current implementation uses self.balances
https://github.com/code-423n4/2021-11-bootfinance/blob/main/customswap/contracts/SwapUtils.sol#L1231-L1236
Replaces self.balances with _xp(self, newBalances) would be a simple fix.
I consider the team can take balances weighted pool as a reference. WeightedMath.sol#L149-L179
chickenpie347 (Boot Finance) confirmed
