Skip to content

Commit

Permalink
fix: minor 5.2 message fixes (#2148)
Browse files Browse the repository at this point in the history
* fix: minor 5.2 fixes

* CL++

* test++

* lint++

* Update x/leverage/types/tx.go

Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* Update x/leverage/types/tx.go

Co-authored-by: Robert Zaremba <robert@zaremba.ch>

---------

Co-authored-by: Robert Zaremba <robert@zaremba.ch>
  • Loading branch information
toteki and robert-zaremba authored Jul 20, 2023
1 parent b52a3b7 commit a8400a7
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 3 additions & 4 deletions x/incentive/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
)
}
Expand Down
2 changes: 1 addition & 1 deletion x/incentive/keeper/scenario_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 12 additions & 4 deletions x/leverage/types/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
1 change: 1 addition & 0 deletions x/leverage/types/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a8400a7

Please sign in to comment.