Skip to content

Commit

Permalink
fix: Unstaking finding (#726)
Browse files Browse the repository at this point in the history
* fix unstaking finding

* changelog
  • Loading branch information
kruspy authored Jan 19, 2024
1 parent 85fad38 commit ce9c73f
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Bug Fixes

- [726](https://github.com/persistenceOne/pstake-native/pull/726) Fix minimal unbondings.
- [720](https://github.com/persistenceOne/pstake-native/pull/720) Fix unbondings loop.
- [719](https://github.com/persistenceOne/pstake-native/pull/719) Fix afterEpoch hooks to take LiquidStake feature
instead of LiquidStakeIBC
Expand Down
10 changes: 10 additions & 0 deletions x/liquidstakeibc/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,16 @@ func (k msgServer) LiquidUnstake(
return nil, types.ErrHostChainInactive
}

// check for minimum unbonding amount
if msg.Amount.Amount.LT(hc.MinimumDeposit) {
return nil, errorsmod.Wrapf(
types.ErrMinDeposit,
"expected amount more than %s, got %s",
hc.MinimumDeposit,
msg.Amount.Amount,
)
}

// check if the message amount has the correct denom
if msg.Amount.Denom != hc.MintDenom() {
return nil, errorsmod.Wrapf(types.ErrInvalidDenom,
Expand Down
50 changes: 49 additions & 1 deletion x/liquidstakeibc/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,55 @@ func (suite *IntegrationTestSuite) Test_msgServer_LiquidUnstake() {
goCtx: ctx,
msg: &types.MsgLiquidUnstake{
DelegatorAddress: suite.chainA.SenderAccount.GetAddress().String(),
Amount: sdk.NewInt64Coin(hc.MintDenom(), 100),
Amount: sdk.NewInt64Coin(hc.MintDenom(), 1000000),
},
},
want: nil,
wantErr: true,
},
{
name: "amount less than minimum amount",
args: args{
goCtx: ctx,
msg: &types.MsgLiquidUnstake{
DelegatorAddress: suite.chainA.SenderAccount.GetAddress().String(),
Amount: sdk.NewInt64Coin(hc.MintDenom(), 0),
},
},
want: nil,
wantErr: true,
},
{
name: "mint denom not parseable",
args: args{
goCtx: ctx,
msg: &types.MsgLiquidUnstake{
DelegatorAddress: suite.chainA.SenderAccount.GetAddress().String(),
Amount: sdk.NewInt64Coin(hc.HostDenom, 1000000),
},
},
want: nil,
wantErr: true,
},
{
name: "host chain not found",
args: args{
goCtx: ctx,
msg: &types.MsgLiquidUnstake{
DelegatorAddress: suite.chainA.SenderAccount.GetAddress().String(),
Amount: sdk.NewInt64Coin("stk/uosmo", 1000000),
},
},
want: nil,
wantErr: true,
},
{
name: "invalid delegator address",
args: args{
goCtx: ctx,
msg: &types.MsgLiquidUnstake{
DelegatorAddress: "invalidaddr",
Amount: sdk.NewInt64Coin(hc.MintDenom(), 1000000),
},
},
want: nil,
Expand Down

0 comments on commit ce9c73f

Please sign in to comment.