Skip to content

Commit 257ecbf

Browse files
authored
join pool query non oracle pool fix (#1246)
1 parent c47aabe commit 257ecbf

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

x/amm/types/pool_join_pool.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,14 @@ func (p *Pool) JoinPool(
115115
normalizedWeights := NormalizedWeights(p.PoolAssets)
116116
for _, weight := range normalizedWeights {
117117
if weight.Asset != tokenIn.Denom {
118-
_, slippage, err := p.CalcOutAmtGivenIn(ctx, oracleKeeper, snapshot, tokensIn, weight.Asset, sdkmath.LegacyZeroDec(), accountedPoolKeeper)
118+
_, slippage, err = p.CalcOutAmtGivenIn(ctx, oracleKeeper, snapshot, tokensIn, weight.Asset, sdkmath.LegacyZeroDec(), accountedPoolKeeper)
119119
if err == nil {
120120
totalSlippage = totalSlippage.Add(slippage.Mul(weight.Weight))
121121
}
122122
}
123123
}
124124

125-
numShares, tokensJoined, err := p.CalcSingleAssetJoinPoolShares(tokensIn, takerFees)
125+
numShares, tokensJoined, err = p.CalcSingleAssetJoinPoolShares(tokensIn, takerFees)
126126
if err != nil {
127127
return sdk.NewCoins(), sdkmath.Int{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), err
128128
}
@@ -133,8 +133,8 @@ func (p *Pool) JoinPool(
133133
totalWeight := p.TotalWeight
134134
normalizedWeight := poolAssetsByDenom[tokenIn.Denom].Weight.ToLegacyDec().Quo(totalWeight.ToLegacyDec())
135135
// We multiply the swap fee and taker fees by the normalized weight because it is calculated like this later in CalcSingleAssetJoinPoolShares function
136-
swapFee := feeRatio(normalizedWeight, p.PoolParams.SwapFee)
137-
takerFee := feeRatio(normalizedWeight, takerFees)
136+
swapFee = sdkmath.LegacyZeroDec().Sub(feeRatio(normalizedWeight, p.PoolParams.SwapFee))
137+
takerFee := sdkmath.LegacyZeroDec().Sub(feeRatio(normalizedWeight, takerFees))
138138

139139
// update pool with the calculated share and liquidity needed to join pool
140140
err = p.IncreaseLiquidity(numShares, tokensJoined)

0 commit comments

Comments
 (0)