@@ -68,23 +68,20 @@ func (k Keeper) JoinPoolNoSwap(
6868 params := k .GetParams (ctx )
6969 takerFees := k .parameterKeeper .GetParams (ctx ).TakerFees
7070 snapshot := k .GetAccountedPoolSnapshotOrSet (ctx , pool )
71- tokensJoined , sharesOut , slippage , weightBalanceBonus , _ , takerFeesFinal , err := pool .JoinPool (ctx , & snapshot , k .oracleKeeper , k .accountedPoolKeeper , tokensIn , params , takerFees )
71+ tokensJoined , sharesOut , _ , weightBalanceBonus , swapFee , takerFeesFinal , err := pool .JoinPool (ctx , & snapshot , k .oracleKeeper , k .accountedPoolKeeper , tokensIn , params , takerFees )
7272 if err != nil {
7373 return nil , sdkmath .ZeroInt (), err
7474 }
7575
76- if pool .PoolParams .UseOracle && len (tokensIn ) == 1 {
77- slippageAmount := slippage .Mul (tokensIn [0 ].Amount .ToLegacyDec ()).RoundInt ()
78- k .TrackWeightBreakingSlippage (ctx , pool .PoolId , sdk .NewCoin (tokensIn [0 ].Denom , slippageAmount ))
79- }
80-
8176 // sanity check, don't return error as not worth halting the LP. We know its not too much.
8277 if sharesOut .LT (shareOutAmount ) {
8378 ctx .Logger ().Error (fmt .Sprintf ("Expected to JoinPoolNoSwap >= %s shares, actually did %s shares" ,
8479 shareOutAmount , sharesOut ))
8580 }
81+ // slippage will be 0 as tokensIn.Len() != 1
82+ slippageCoins := sdk.Coins {}
8683
87- err = k .ApplyJoinPoolStateChange (ctx , pool , sender , sharesOut , tokensJoined , weightBalanceBonus , takerFeesFinal )
84+ err = k .ApplyJoinPoolStateChange (ctx , pool , sender , sharesOut , tokensJoined , weightBalanceBonus , takerFeesFinal , swapFee , slippageCoins )
8885 if err != nil {
8986 return nil , sdkmath.Int {}, err
9087 }
@@ -101,18 +98,27 @@ func (k Keeper) JoinPoolNoSwap(
10198 takerFees := k .parameterKeeper .GetParams (ctx ).TakerFees
10299 // on oracle pool, full tokenInMaxs are used regardless shareOutAmount
103100 snapshot := k .GetAccountedPoolSnapshotOrSet (ctx , pool )
104- tokensJoined , sharesOut , _ , weightBalanceBonus , _ , takerFeesFinal , err := pool .JoinPool (ctx , & snapshot , k .oracleKeeper , k .accountedPoolKeeper , tokenInMaxs , params , takerFees )
101+ tokensJoined , sharesOut , slippage , weightBalanceBonus , swapFee , takerFeesFinal , err := pool .JoinPool (ctx , & snapshot , k .oracleKeeper , k .accountedPoolKeeper , tokenInMaxs , params , takerFees )
105102 if err != nil {
106103 return nil , sdkmath .ZeroInt (), err
107104 }
108105
106+ slippageCoins := sdk.Coins {}
107+ if pool .PoolParams .UseOracle && len (tokenInMaxs ) == 1 {
108+ slippageAmount := slippage .Mul (tokenInMaxs [0 ].Amount .ToLegacyDec ()).RoundInt ()
109+ if slippageAmount .IsPositive () {
110+ slippageCoins = sdk .NewCoins (sdk .NewCoin (tokenInMaxs [0 ].Denom , slippageAmount ))
111+ k .TrackWeightBreakingSlippage (ctx , pool .PoolId , sdk .NewCoin (tokenInMaxs [0 ].Denom , slippageAmount ))
112+ }
113+ }
114+
109115 // sanity check, don't return error as not worth halting the LP. We know its not too much.
110116 if sharesOut .LT (shareOutAmount ) {
111117 ctx .Logger ().Error (fmt .Sprintf ("Expected to JoinPoolNoSwap >= %s shares, actually did %s shares" ,
112118 shareOutAmount , sharesOut ))
113119 }
114120
115- err = k .ApplyJoinPoolStateChange (ctx , pool , sender , sharesOut , tokensJoined , weightBalanceBonus , takerFeesFinal )
121+ err = k .ApplyJoinPoolStateChange (ctx , pool , sender , sharesOut , tokensJoined , weightBalanceBonus , takerFeesFinal , swapFee , slippageCoins )
116122 if err != nil {
117123 return nil , sdkmath.Int {}, err
118124 }
0 commit comments