From a8d31b39e38382e5bb79e3839098a745533efec3 Mon Sep 17 00:00:00 2001 From: kenta-elys Date: Fri, 1 Sep 2023 08:46:53 +0000 Subject: [PATCH] fix: add missing params --- x/amm/types/calc_exit_pool.go | 7 ++++--- x/amm/types/pool_join_pool_no_swap.go | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/x/amm/types/calc_exit_pool.go b/x/amm/types/calc_exit_pool.go index b2c1a7e6b..f3d947eb1 100644 --- a/x/amm/types/calc_exit_pool.go +++ b/x/amm/types/calc_exit_pool.go @@ -8,8 +8,8 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -func CalcExitValueWithoutSlippage(ctx sdk.Context, oracleKeeper OracleKeeper, pool Pool, exitingShares sdk.Int, tokenOutDenom string) (sdk.Dec, error) { - tvl, err := pool.TVL(ctx, oracleKeeper) +func CalcExitValueWithoutSlippage(ctx sdk.Context, oracleKeeper OracleKeeper, accPoolKeeper AccountedPoolKeeper, pool Pool, exitingShares sdk.Int, tokenOutDenom string) (sdk.Dec, error) { + tvl, err := pool.TVL(ctx, oracleKeeper, accPoolKeeper) if err != nil { return sdk.ZeroDec(), err } @@ -57,6 +57,7 @@ func CalcExitValueWithoutSlippage(ctx sdk.Context, oracleKeeper OracleKeeper, po &pool, sdk.Coins{sdk.NewCoin(exitedCoin.Denom, resizedAmount)}, tokenOutDenom, + accPoolKeeper, ) if err != nil { return sdk.ZeroDec(), err @@ -88,7 +89,7 @@ func CalcExitPool(ctx sdk.Context, oracleKeeper OracleKeeper, pool Pool, account if pool.PoolParams.UseOracle && tokenOutDenom != "" { initialWeightDistance := pool.WeightDistanceFromTarget(ctx, oracleKeeper, pool.PoolAssets) tokenPrice := oracleKeeper.GetAssetPriceFromDenom(ctx, tokenOutDenom) - exitValueWithoutSlippage, err := CalcExitValueWithoutSlippage(ctx, oracleKeeper, pool, exitingShares, tokenOutDenom) + exitValueWithoutSlippage, err := CalcExitValueWithoutSlippage(ctx, oracleKeeper, accountedPoolKeeper, pool, exitingShares, tokenOutDenom) if err != nil { return sdk.Coins{}, err } diff --git a/x/amm/types/pool_join_pool_no_swap.go b/x/amm/types/pool_join_pool_no_swap.go index bd5a42f28..4150f6191 100644 --- a/x/amm/types/pool_join_pool_no_swap.go +++ b/x/amm/types/pool_join_pool_no_swap.go @@ -17,7 +17,7 @@ type InternalSwapRequest struct { OutToken string } -func (p *Pool) CalcJoinValueWithoutSlippage(ctx sdk.Context, oracleKeeper OracleKeeper, tokensIn sdk.Coins) (math.LegacyDec, error) { +func (p *Pool) CalcJoinValueWithoutSlippage(ctx sdk.Context, oracleKeeper OracleKeeper, accountedPoolKeeper AccountedPoolKeeper, tokensIn sdk.Coins) (math.LegacyDec, error) { joinValue := sdk.ZeroDec() for _, asset := range tokensIn { tokenPrice := oracleKeeper.GetAssetPriceFromDenom(ctx, asset.Denom) @@ -99,6 +99,7 @@ func (p *Pool) CalcJoinValueWithoutSlippage(ctx sdk.Context, oracleKeeper Oracle p, sdk.Coins{sdk.NewCoin(req.InAmount.Denom, resizedAmount)}, req.OutToken, + accountedPoolKeeper, ) if err != nil { return sdk.ZeroDec(), err @@ -124,7 +125,7 @@ func (p *Pool) JoinPoolNoSwap(ctx sdk.Context, oracleKeeper OracleKeeper, accoun return numShares, nil } - joinValueWithoutSlippage, err := p.CalcJoinValueWithoutSlippage(ctx, oracleKeeper, tokensIn) + joinValueWithoutSlippage, err := p.CalcJoinValueWithoutSlippage(ctx, oracleKeeper, accountedPoolKeeper, tokensIn) if err != nil { return sdk.ZeroInt(), err }