raydium-io / raydium-sdk-V2

Open-source Typescript SDK for Raydium
GNU General Public License v3.0
79 stars 47 forks source link

fix(cpmm-add-liquidity): the deposits will fail in any sol pool if invariant changes #48

Open SushantChandla opened 2 weeks ago

SushantChandla commented 2 weeks ago

I noticed that in the implementation when converting sol to wsol, we only convert anotherAmount variable, but it is possible that in invariant changes. In that case, if anotherAmount is slightly smaller than the amount needed for the deposit, the instruction on the smart contract side will cause failure with the error Insufficient balance.

It is more ideal that in the computePairAmount the slippage is also passed(right now its passed as 0) and then the amount calculate will be more correct.