Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: minor 5.2 message fixes #2148

Merged
merged 8 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

### Bug Fixes
toteki marked this conversation as resolved.
Show resolved Hide resolved
- [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) {
toteki marked this conversation as resolved.
Show resolved Hide resolved
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
18 changes: 14 additions & 4 deletions x/leverage/types/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,23 @@ 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 != "" {
err := sdk.ValidateDenom(msg.RepayDenom)
if err != nil {
toteki marked this conversation as resolved.
Show resolved Hide resolved
return err
}
}
if msg.RewardDenom != "" {
err := sdk.ValidateDenom(msg.RewardDenom)
if err != nil {
toteki marked this conversation as resolved.
Show resolved Hide resolved
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