diff --git a/CHANGELOG.md b/CHANGELOG.md index fc9937a5ad..0a6791eb14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,11 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +### Bug Fixes + +- [2148](https://github.com/umee-network/umee/pull/2148) Fix MsgBeginUnbonding counting existing unbondings against max unbond twice. +- [2148](https://github.com/umee-network/umee/pull/2148) Fix MsgLeverageLiquidate CLI not actually allowing wildcard denoms. + ### Features - [2129](https://github.com/umee-network/umee/pull/2129) Emergency Group x/ugov proto. diff --git a/x/incentive/keeper/msg_server.go b/x/incentive/keeper/msg_server.go index b38d228394..436116bcab 100644 --- a/x/incentive/keeper/msg_server.go +++ b/x/incentive/keeper/msg_server.go @@ -91,7 +91,7 @@ func (s msgServer) BeginUnbonding( } // get current account state for the requested uToken denom only - bonded, currentUnbonding, unbondings := k.BondSummary(ctx, addr, denom) + bonded, _, unbondings := k.BondSummary(ctx, addr, denom) maxUnbondings := int(k.GetParams(ctx).MaxUnbondings) if maxUnbondings > 0 && len(unbondings) >= maxUnbondings { @@ -100,11 +100,10 @@ func (s msgServer) BeginUnbonding( } // reject unbondings greater than maximum available amount - if currentUnbonding.Add(msg.UToken).Amount.GT(bonded.Amount) { + if msg.UToken.Amount.GT(bonded.Amount) { return nil, incentive.ErrInsufficientBonded.Wrapf( - "bonded: %s, unbonding: %s, requested: %s", + "bonded: %s, requested: %s", bonded, - currentUnbonding, msg.UToken, ) } diff --git a/x/incentive/keeper/scenario_test.go b/x/incentive/keeper/scenario_test.go index 14c0cac47c..0c1cfe832a 100644 --- a/x/incentive/keeper/scenario_test.go +++ b/x/incentive/keeper/scenario_test.go @@ -325,7 +325,7 @@ func TestZeroBondedAtProgramEnd(t *testing.T) { require.Equal(k.t, aliceReward, rewards, "alice claimed rewards at time 175") // fully unbond user at 75%, making her ineligible future rewards unless she bonds again - k.mustUnbond(alice, coin.New(uUmee, 100_000000)) + k.mustBeginUnbond(alice, coin.New(uUmee, 50_000000)) // complete the program k.advanceTimeTo(programStart + 110) // a bit past 100% duration diff --git a/x/leverage/types/tx.go b/x/leverage/types/tx.go index eb8a227d59..dea05ee51f 100644 --- a/x/leverage/types/tx.go +++ b/x/leverage/types/tx.go @@ -269,13 +269,21 @@ func (msg MsgLeveragedLiquidate) Route() string { return sdk.MsgTypeURL(&msg) } func (msg MsgLeveragedLiquidate) Type() string { return sdk.MsgTypeURL(&msg) } func (msg *MsgLeveragedLiquidate) ValidateBasic() error { - if err := validateSenderAndDenom(msg.Borrower, msg.RewardDenom); err != nil { - return err + if msg.RepayDenom != "" { + if err := sdk.ValidateDenom(msg.RepayDenom); err != nil { + return err + } + } + if msg.RewardDenom != "" { + if err := sdk.ValidateDenom(msg.RewardDenom); err != nil { + return err + } } - if err := sdk.ValidateDenom(msg.RepayDenom); err != nil { + _, err := sdk.AccAddressFromBech32(msg.Borrower) + if err != nil { return err } - _, err := sdk.AccAddressFromBech32(msg.Liquidator) + _, err = sdk.AccAddressFromBech32(msg.Liquidator) return err } diff --git a/x/leverage/types/tx_test.go b/x/leverage/types/tx_test.go index 2234cb98d7..dfd8a5b663 100644 --- a/x/leverage/types/tx_test.go +++ b/x/leverage/types/tx_test.go @@ -35,6 +35,7 @@ func TestTxs(t *testing.T) { types.NewMsgRepay(testAddr, token), types.NewMsgLiquidate(testAddr, testAddr, token, uDenom), types.NewMsgLeveragedLiquidate(testAddr, testAddr, token.Denom, uDenom), + types.NewMsgLeveragedLiquidate(testAddr, testAddr, "", ""), } for _, tx := range txs {