Skip to content

Commit

Permalink
fix: add missing params
Browse files Browse the repository at this point in the history
  • Loading branch information
kenta-elys committed Sep 1, 2023
1 parent 13292db commit a8d31b3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions x/amm/types/calc_exit_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
5 changes: 3 additions & 2 deletions x/amm/types/pool_join_pool_no_swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
}
Expand Down

0 comments on commit a8d31b3

Please sign in to comment.