Skip to content

Commit

Permalink
Refactor weight breaking fee and fix exit flow (#1116)
Browse files Browse the repository at this point in the history
* refactor

* remove

* remove breaking fee for lower threshold

* update

* reward

* exit fees

---------

Co-authored-by: Abhinav Kumar <[email protected]>
  • Loading branch information
amityadav0 and avkr003 authored Jan 23, 2025
1 parent 8ef8bbb commit ac39646
Show file tree
Hide file tree
Showing 58 changed files with 670 additions and 591 deletions.
612 changes: 345 additions & 267 deletions api/elys/amm/tx.pulsar.go

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions proto/elys/amm/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ message MsgExitPool {
message MsgExitPoolResponse {
repeated cosmos.base.v1beta1.Coin token_out = 1
[ (gogoproto.nullable) = false ];
string weight_balance_ratio = 2 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
}

message MsgSwapExactAmountIn {
Expand Down
1 change: 0 additions & 1 deletion x/accountedpool/types/query.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion x/accountedpool/types/tx.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 24 additions & 1 deletion x/amm/keeper/apply_exit_pool_state_change.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/elys-network/elys/x/amm/types"
)

func (k Keeper) ApplyExitPoolStateChange(ctx sdk.Context, pool types.Pool, exiter sdk.AccAddress, numShares sdkmath.Int, exitCoins sdk.Coins, isLiquidation bool) error {
func (k Keeper) ApplyExitPoolStateChange(ctx sdk.Context, pool types.Pool, exiter sdk.AccAddress, numShares sdkmath.Int, exitCoins sdk.Coins, isLiquidation bool, weightBalanceBonus sdkmath.LegacyDec) error {
// Withdraw exit amount of token from commitment module to exiter's wallet.
poolShareDenom := types.GetPoolShareDenom(pool.GetPoolId())

Expand All @@ -26,6 +26,29 @@ func (k Keeper) ApplyExitPoolStateChange(ctx sdk.Context, pool types.Pool, exite

k.SetPool(ctx, pool)

rebalanceTreasuryAddr := sdk.MustAccAddressFromBech32(pool.GetRebalanceTreasury())

if weightBalanceBonus.IsPositive() {
// calculate treasury amounts to send as bonus
weightBalanceBonusCoins := PortionCoins(exitCoins, weightBalanceBonus)
for _, coin := range weightBalanceBonusCoins {
treasuryTokenAmount := k.bankKeeper.GetBalance(ctx, rebalanceTreasuryAddr, coin.Denom).Amount
if treasuryTokenAmount.LT(coin.Amount) {
// override coin amount by treasuryTokenAmount
weightBalanceBonusCoins = weightBalanceBonusCoins.
Sub(coin). // remove the original coin
Add(sdk.NewCoin(coin.Denom, treasuryTokenAmount)) // add the treasuryTokenAmount
}
}

// send bonus tokens to recipient if positive
if weightBalanceBonusCoins.IsAllPositive() {
if err := k.bankKeeper.SendCoins(ctx, rebalanceTreasuryAddr, exiter, weightBalanceBonusCoins); err != nil {
return err
}
}
}

types.EmitRemoveLiquidityEvent(ctx, exiter, pool.GetPoolId(), exitCoins)
if k.hooks != nil {
err = k.hooks.AfterExitPool(ctx, exiter, pool, numShares, exitCoins)
Expand Down
6 changes: 3 additions & 3 deletions x/amm/keeper/apply_exit_pool_state_change_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (suite *AmmKeeperTestSuite) TestApplyExitPoolStateChange() {
suite.Require().True(lpTokenBalance.Amount.Equal(sdkmath.ZeroInt()))

ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Hour))
err = app.AmmKeeper.ApplyExitPoolStateChange(ctx, pool, addrs[0], pool.TotalShares.Amount, coins, false)
err = app.AmmKeeper.ApplyExitPoolStateChange(ctx, pool, addrs[0], pool.TotalShares.Amount, coins, false, sdkmath.LegacyZeroDec())
suite.Require().NoError(err)
},
func() {},
Expand All @@ -99,7 +99,7 @@ func (suite *AmmKeeperTestSuite) TestApplyExitPoolStateChange() {

coins := sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdkmath.NewInt(100000)), sdk.NewCoin("uusdt", sdkmath.NewInt(100000)))

err := suite.app.AmmKeeper.ApplyExitPoolStateChange(suite.ctx, pool, addr, pool.TotalShares.Amount, coins, false)
err := suite.app.AmmKeeper.ApplyExitPoolStateChange(suite.ctx, pool, addr, pool.TotalShares.Amount, coins, false, sdkmath.LegacyZeroDec())
suite.Require().Error(err)
},
func() {},
Expand Down Expand Up @@ -170,7 +170,7 @@ func (suite *AmmKeeperTestSuite) TestApplyExitPoolStateChange() {
coins = sdk.NewCoins(sdk.NewCoin("invalid_denom", sdkmath.NewInt(100000000)))

ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Hour))
err = app.AmmKeeper.ApplyExitPoolStateChange(ctx, pool, addr, pool.TotalShares.Amount, coins, false)
err = app.AmmKeeper.ApplyExitPoolStateChange(ctx, pool, addr, pool.TotalShares.Amount, coins, false, sdkmath.LegacyZeroDec())
suite.Require().Error(err)
},
func() {},
Expand Down
22 changes: 11 additions & 11 deletions x/amm/keeper/keeper_exit_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,38 @@ func (k Keeper) ExitPool(
tokenOutMins sdk.Coins,
tokenOutDenom string,
isLiquidation bool,
) (exitCoins sdk.Coins, err error) {
) (exitCoins sdk.Coins, weightBalanceBonus math.LegacyDec, err error) {
pool, poolExists := k.GetPool(ctx, poolId)
if !poolExists {
return sdk.Coins{}, types.ErrInvalidPoolId
return sdk.Coins{}, math.LegacyZeroDec(), types.ErrInvalidPoolId
}

totalSharesAmount := pool.GetTotalShares()
if shareInAmount.GTE(totalSharesAmount.Amount) {
return sdk.Coins{}, errorsmod.Wrapf(types.ErrInvalidMathApprox, "Trying to exit >= the number of shares contained in the pool.")
return sdk.Coins{}, math.LegacyZeroDec(), errorsmod.Wrapf(types.ErrInvalidMathApprox, "Trying to exit >= the number of shares contained in the pool.")
} else if shareInAmount.LTE(math.ZeroInt()) {
return sdk.Coins{}, errorsmod.Wrapf(types.ErrInvalidMathApprox, "Trying to exit a negative amount of shares")
return sdk.Coins{}, math.LegacyZeroDec(), errorsmod.Wrapf(types.ErrInvalidMathApprox, "Trying to exit a negative amount of shares")
}
params := k.GetParams(ctx)
exitCoins, err = pool.ExitPool(ctx, k.oracleKeeper, k.accountedPoolKeeper, shareInAmount, tokenOutDenom, params)
exitCoins, weightBalanceBonus, err = pool.ExitPool(ctx, k.oracleKeeper, k.accountedPoolKeeper, shareInAmount, tokenOutDenom, params)
if err != nil {
return sdk.Coins{}, err
return sdk.Coins{}, math.LegacyZeroDec(), err
}
if !tokenOutMins.DenomsSubsetOf(exitCoins) || tokenOutMins.IsAnyGT(exitCoins) {
return sdk.Coins{}, errorsmod.Wrapf(types.ErrLimitMinAmount,
return sdk.Coins{}, math.LegacyZeroDec(), errorsmod.Wrapf(types.ErrLimitMinAmount,
"Exit pool returned %s , minimum tokens out specified as %s",
exitCoins, tokenOutMins)
}

err = k.ApplyExitPoolStateChange(ctx, pool, sender, shareInAmount, exitCoins, isLiquidation)
err = k.ApplyExitPoolStateChange(ctx, pool, sender, shareInAmount, exitCoins, isLiquidation, weightBalanceBonus)
if err != nil {
return sdk.Coins{}, err
return sdk.Coins{}, math.LegacyZeroDec(), err
}

err = k.RecordTotalLiquidityDecrease(ctx, exitCoins)
if err != nil {
return sdk.Coins{}, err
return sdk.Coins{}, math.LegacyZeroDec(), err
}

return exitCoins, nil
return exitCoins, weightBalanceBonus, nil
}
2 changes: 1 addition & 1 deletion x/amm/keeper/keeper_exit_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (suite *AmmKeeperTestSuite) TestExitPool() {
for _, tc := range testCases {
suite.Run(tc.name, func() {
exiter, poolId, inShares, minTokensOut, tokenOutDenom, isLiq := tc.setup()
_, err := suite.app.AmmKeeper.ExitPool(suite.ctx, exiter, poolId, inShares, minTokensOut, tokenOutDenom, isLiq)
_, _, err := suite.app.AmmKeeper.ExitPool(suite.ctx, exiter, poolId, inShares, minTokensOut, tokenOutDenom, isLiq)
if tc.expectedErrMsg != "" {
suite.Require().Error(err)
suite.Require().Contains(err.Error(), tc.expectedErrMsg)
Expand Down
8 changes: 4 additions & 4 deletions x/amm/keeper/keeper_swap_exact_amount_in_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,14 @@ func (suite *AmmKeeperTestSuite) TestSwapExactAmountIn() {
swapFeeOut: sdkmath.LegacyZeroDec(),
tokenIn: sdk.NewInt64Coin("uusda", 10000),
tokenOutMin: sdkmath.ZeroInt(),
tokenOut: sdk.NewInt64Coin(ptypes.BaseCurrency, 9944),
tokenOut: sdk.NewInt64Coin(ptypes.BaseCurrency, 9950),
weightBalanceBonus: sdkmath.LegacyZeroDec(),
isOraclePool: true,
useNewRecipient: false,
expSenderBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 990000), sdk.NewInt64Coin(ptypes.BaseCurrency, 1009944)},
expSenderBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 990000), sdk.NewInt64Coin(ptypes.BaseCurrency, 1009950)},
expRecipientBalance: sdk.Coins{},
expPoolBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1009997), sdk.NewInt64Coin(ptypes.BaseCurrency, 990056)},
expTreasuryBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1000003), sdk.NewInt64Coin(ptypes.BaseCurrency, 1000000)},
expPoolBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1010000), sdk.NewInt64Coin(ptypes.BaseCurrency, 990050)},
expTreasuryBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1000000), sdk.NewInt64Coin(ptypes.BaseCurrency, 1000000)},
expPass: true,
errMsg: "",
},
Expand Down
8 changes: 4 additions & 4 deletions x/amm/keeper/keeper_swap_exact_amount_out_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,16 @@ func (suite *AmmKeeperTestSuite) TestSwapExactAmountOut() {
poolInitBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1000000), sdk.NewInt64Coin(ptypes.BaseCurrency, 1000000)},
treasuryInitBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1000000), sdk.NewInt64Coin(ptypes.BaseCurrency, 1000000)},
swapFeeOut: sdkmath.LegacyZeroDec(),
tokenIn: sdk.NewInt64Coin("uusda", 222546),
tokenIn: sdk.NewInt64Coin("uusda", 222224),
tokenInMax: sdkmath.NewInt(10000000),
tokenOut: sdk.NewInt64Coin(ptypes.BaseCurrency, 200000),
weightBalanceBonus: sdkmath.LegacyZeroDec(),
isOraclePool: true,
useNewRecipient: false,
expSenderBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 777454), sdk.NewInt64Coin(ptypes.BaseCurrency, 1200000)},
expSenderBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 777776), sdk.NewInt64Coin(ptypes.BaseCurrency, 1200000)},
expRecipientBalance: sdk.Coins{},
expPoolBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1222402), sdk.NewInt64Coin(ptypes.BaseCurrency, 800000)},
expTreasuryBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1000144), sdk.NewInt64Coin(ptypes.BaseCurrency, 1000000)},
expPoolBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1222224), sdk.NewInt64Coin(ptypes.BaseCurrency, 800000)},
expTreasuryBalance: sdk.Coins{sdk.NewInt64Coin("uusda", 1000000), sdk.NewInt64Coin(ptypes.BaseCurrency, 1000000)},
expPass: true,
},
{
Expand Down
5 changes: 3 additions & 2 deletions x/amm/keeper/msg_server_exit_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func (k msgServer) ExitPool(goCtx context.Context, msg *types.MsgExitPool) (*typ
if err != nil {
return nil, err
}
exitCoins, err := k.Keeper.ExitPool(ctx, sender, msg.PoolId, msg.ShareAmountIn, msg.MinAmountsOut, msg.TokenOutDenom, false)
exitCoins, weightBalanceBonus, err := k.Keeper.ExitPool(ctx, sender, msg.PoolId, msg.ShareAmountIn, msg.MinAmountsOut, msg.TokenOutDenom, false)
if err != nil {
return nil, err
}
Expand All @@ -28,6 +28,7 @@ func (k msgServer) ExitPool(goCtx context.Context, msg *types.MsgExitPool) (*typ
})

return &types.MsgExitPoolResponse{
TokenOut: exitCoins,
TokenOut: exitCoins,
WeightBalanceRatio: weightBalanceBonus,
}, nil
}
8 changes: 4 additions & 4 deletions x/amm/keeper/msg_server_exit_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ func (suite *AmmKeeperTestSuite) TestMsgServerExitPool() {
},
shareInAmount: types.OneShare.Quo(sdkmath.NewInt(10)),
tokenOutDenom: "uusdt",
minAmountsOut: sdk.Coins{sdk.NewInt64Coin("uusdt", 99935)},
minAmountsOut: sdk.Coins{sdk.NewInt64Coin("uusdt", 100000)},
// expSenderBalance: sdk.Coins{sdk.NewInt64Coin("uusdt", 95114)}, // slippage enabled
expSenderBalance: sdk.Coins{sdk.NewInt64Coin("uusdt", 99935)}, // slippage disabled
expSenderBalance: sdk.Coins{sdk.NewInt64Coin("uusdt", 100000)}, // slippage disabled
expPass: true,
},
{
Expand All @@ -79,9 +79,9 @@ func (suite *AmmKeeperTestSuite) TestMsgServerExitPool() {
},
shareInAmount: types.OneShare.Quo(sdkmath.NewInt(10)),
tokenOutDenom: ptypes.BaseCurrency,
minAmountsOut: sdk.Coins{sdk.NewInt64Coin(ptypes.BaseCurrency, 99221)},
minAmountsOut: sdk.Coins{sdk.NewInt64Coin(ptypes.BaseCurrency, 100000)},
// expSenderBalance: sdk.Coins{sdk.NewInt64Coin(ptypes.BaseCurrency, 99197)}, // slippage enabled
expSenderBalance: sdk.Coins{sdk.NewInt64Coin(ptypes.BaseCurrency, 99221)}, // slippage disabled
expSenderBalance: sdk.Coins{sdk.NewInt64Coin(ptypes.BaseCurrency, 100000)}, // slippage disabled
expPass: true,
},
} {
Expand Down
4 changes: 2 additions & 2 deletions x/amm/keeper/msg_server_join_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (suite *AmmKeeperTestSuite) TestMsgServerJoinPool() {
FeeDenom: ptypes.BaseCurrency,
},
// shareOutAmount: math.NewInt(694444166666666666), // weight breaking fee - slippage enable
shareOutAmount: math.NewInt(999057190958417937), // weight breaking fee - slippage disable
shareOutAmount: math.NewInt(1000000000000000000), // weight breaking fee - slippage disable
expSenderBalance: sdk.Coins{},
expTokenIn: sdk.Coins{sdk.NewInt64Coin("uusdt", 1000000)},
expPass: true,
Expand All @@ -75,7 +75,7 @@ func (suite *AmmKeeperTestSuite) TestMsgServerJoinPool() {
FeeDenom: ptypes.BaseCurrency,
},
// shareOutAmount: math.NewInt(805987500000000000), // weight recovery direction - slippage enable
shareOutAmount: math.NewInt(996102885682970026), // weight recovery direction - slippage disable
shareOutAmount: math.NewInt(1000000000000000000), // weight recovery direction - slippage disable
expSenderBalance: sdk.Coins{},
expTokenIn: sdk.Coins{sdk.NewInt64Coin("uusdt", 1000000)},
expPass: true,
Expand Down
6 changes: 3 additions & 3 deletions x/amm/keeper/msg_server_swap_exact_amount_in_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,15 @@ func (suite *AmmKeeperTestSuite) TestMsgServerSlippageDifferenceWhenSplit() {
swapFee := sdkmath.LegacyZeroDec()
tokenIn := sdk.NewInt64Coin(ptypes.BaseCurrency, 100000)
tokenOutMin := sdkmath.ZeroInt()
tokenOut := sdk.NewInt64Coin("uusdt", 98918)
tokenOut := sdk.NewInt64Coin("uusdt", 99000)
swapRoute := []types.SwapAmountInRoute{
{
PoolId: 1,
TokenOutDenom: "uusdt",
},
}
expSenderBalance := sdk.Coins{sdk.NewInt64Coin(ptypes.BaseCurrency, 900000), sdk.NewInt64Coin("uusdt", 98918)}
expSenderBalanceSplitSwap := sdk.Coins{sdk.NewInt64Coin(ptypes.BaseCurrency, 900000), sdk.NewInt64Coin("uusdt", 90420)}
expSenderBalance := sdk.Coins{sdk.NewInt64Coin(ptypes.BaseCurrency, 900000), sdk.NewInt64Coin("uusdt", 99000)}
expSenderBalanceSplitSwap := sdk.Coins{sdk.NewInt64Coin(ptypes.BaseCurrency, 900000), sdk.NewInt64Coin("uusdt", 90510)}

// bootstrap accounts
sender := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address())
Expand Down
30 changes: 9 additions & 21 deletions x/amm/types/calc_exit_pool.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package types

import (
"errors"

errorsmod "cosmossdk.io/errors"
sdkmath "cosmossdk.io/math"
"errors"
sdk "github.com/cosmos/cosmos-sdk/types"
)

Expand All @@ -14,8 +15,7 @@ func CalcExitValueWithoutSlippage(ctx sdk.Context, oracleKeeper OracleKeeper, ac
}

totalShares := pool.GetTotalShares()
var refundedShares sdkmath.LegacyDec
refundedShares = sdkmath.LegacyNewDecFromInt(exitingShares)
refundedShares := sdkmath.LegacyNewDecFromInt(exitingShares)

// Ensure totalShares is not zero to avoid division by zero
if totalShares.IsZero() {
Expand Down Expand Up @@ -104,7 +104,6 @@ func CalcExitPool(
if pool.PoolParams.UseOracle && tokenOutDenom != "" {

accountedAssets := pool.GetAccountedBalance(ctx, accountedPoolKeeper, pool.PoolAssets)
initialWeightDistance := pool.WeightDistanceFromTarget(ctx, oracleKeeper, accountedAssets)
tokenPrice := oracleKeeper.GetAssetPriceFromDenom(ctx, tokenOutDenom)
exitValueWithoutSlippage, err := CalcExitValueWithoutSlippage(ctx, oracleKeeper, accountedPoolKeeper, pool, exitingShares, tokenOutDenom)
if err != nil {
Expand All @@ -131,26 +130,15 @@ func CalcExitPool(
}
}

weightDistance := pool.WeightDistanceFromTarget(ctx, oracleKeeper, newAssetPools)
distanceDiff := weightDistance.Sub(initialWeightDistance)

// target weight
targetWeightOut := GetDenomNormalizedWeight(pool.PoolAssets, tokenOutDenom)
targetWeightIn := sdkmath.LegacyOneDec().Sub(targetWeightOut)

// weight breaking fee as in Plasma pool
finalWeightOut := GetDenomOracleAssetWeight(ctx, pool.PoolId, oracleKeeper, newAssetPools, tokenOutDenom)
finalWeightIn := sdkmath.LegacyOneDec().Sub(finalWeightOut)
initialAssetPools, err := pool.NewPoolAssetsAfterSwap(ctx,
sdk.NewCoins(),
sdk.NewCoins(), accountedAssets,
)
initialWeightOut := GetDenomOracleAssetWeight(ctx, pool.PoolId, oracleKeeper, initialAssetPools, tokenOutDenom)
weightBalanceBonus, weightBreakingFee, _ := pool.CalculateWeightFees(ctx, oracleKeeper, accountedAssets, newAssetPools, tokenOutDenom, params, sdkmath.LegacyOneDec())
// apply percentage to fees, consider improvement or reduction of other token
// Other denom weight ratio to reduce the weight breaking fees
initialWeightOut := GetDenomOracleAssetWeight(ctx, pool.PoolId, oracleKeeper, accountedAssets, tokenOutDenom)
initialWeightIn := sdkmath.LegacyOneDec().Sub(initialWeightOut)
weightBreakingFee := GetWeightBreakingFee(finalWeightIn, finalWeightOut, targetWeightIn, targetWeightOut, initialWeightIn, initialWeightOut, distanceDiff, params)
weightBreakingFee = weightBreakingFee.Mul(initialWeightIn)

tokenOutAmount := oracleOutAmount.Mul(sdkmath.LegacyOneDec().Sub(weightBreakingFee)).RoundInt()
return sdk.Coins{sdk.NewCoin(tokenOutDenom, tokenOutAmount)}, weightBreakingFee.Neg(), nil
return sdk.Coins{sdk.NewCoin(tokenOutDenom, tokenOutAmount)}, weightBalanceBonus, nil
}

for _, asset := range poolLiquidity {
Expand Down
17 changes: 14 additions & 3 deletions x/amm/types/calc_exit_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ func TestCalcExitPool(t *testing.T) {
"tokenA",
types.Params{
WeightBreakingFeeMultiplier: sdkmath.LegacyMustNewDecFromStr("0.0005"),
WeightBreakingFeePortion: sdkmath.LegacyMustNewDecFromStr("0.5"),
ThresholdWeightDifference: sdkmath.LegacyMustNewDecFromStr("0.2"),
},
sdk.Coins{sdk.NewCoin("tokenA", sdkmath.NewInt(100))},
sdkmath.LegacyZeroDec(),
Expand All @@ -155,7 +157,10 @@ func TestCalcExitPool(t *testing.T) {
},
sdkmath.NewInt(20),
"tokenA",
types.Params{},
types.Params{
WeightBreakingFeePortion: sdkmath.LegacyMustNewDecFromStr("0.5"),
ThresholdWeightDifference: sdkmath.LegacyMustNewDecFromStr("0.2"),
},
sdk.Coins{},
sdkmath.LegacyZeroDec(),
"shares is larger than the max amount",
Expand All @@ -171,7 +176,10 @@ func TestCalcExitPool(t *testing.T) {
},
sdkmath.NewInt(10),
"tokenA",
types.Params{},
types.Params{
WeightBreakingFeePortion: sdkmath.LegacyMustNewDecFromStr("0.5"),
ThresholdWeightDifference: sdkmath.LegacyMustNewDecFromStr("0.2"),
},
sdk.Coins{},
sdkmath.LegacyZeroDec(),
"amount too low",
Expand All @@ -188,7 +196,10 @@ func TestCalcExitPool(t *testing.T) {
},
sdkmath.NewInt(10),
"",
types.Params{},
types.Params{
WeightBreakingFeePortion: sdkmath.LegacyMustNewDecFromStr("0.5"),
ThresholdWeightDifference: sdkmath.LegacyMustNewDecFromStr("0.2"),
},
sdk.Coins{sdk.NewCoin("tokenA", sdkmath.NewInt(100))},
sdkmath.LegacyZeroDec(),
"",
Expand Down
Loading

0 comments on commit ac39646

Please sign in to comment.