Skip to content

Commit

Permalink
fix: users can be prevented from liquid-staking funds by removin… (#728)
Browse files Browse the repository at this point in the history
* fix: Attackers can prevent users from liquid-staking funds by removing the Deposit entry

* add CHANGELOG.md
  • Loading branch information
puneet2019 authored Jan 19, 2024
1 parent 7d81888 commit 7b1acdc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ Ref: https://keepachangelog.com/en/1.0.0/
- [721](https://github.com/persistenceOne/pstake-native/pull/721) Add Query host chain user unbondings.

### Bug Fixes

- [728](https://github.com/persistenceOne/pstake-native/pull/728) Fix prevent users from liquid-staking funds by removing the Deposit entry.
- [727](https://github.com/persistenceOne/pstake-native/pull/727) Send LSM redeem messages in chunks.
- [726](https://github.com/persistenceOne/pstake-native/pull/726) Fix minimal unbondings.
- [725](https://github.com/persistenceOne/pstake-native/pull/725) Fix Incorrect bookkeeping of validator’s delegated
amount upon redelegation
- [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
- [725](https://github.com/persistenceOne/pstake-native/pull/725) Fix Incorrect bookkeeping of validator’s delegated
amount upon redelegation

## [v2.8.2] - 2024-01-09

Expand Down
8 changes: 6 additions & 2 deletions x/liquidstakeibc/keeper/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,19 @@ func (k *Keeper) AdjustDepositsForRedemption(

for _, deposit := range redeemableDeposits {
// there is enough tokens in this deposit to fulfill the redeem request
if deposit.Amount.Amount.GT(redeemAmount.Amount) || redeemAmount.IsZero() {
if redeemAmount.IsZero() {
return nil
}
if deposit.Amount.Amount.GT(redeemAmount.Amount) {
deposit.Amount = deposit.Amount.Sub(redeemAmount)
k.SetDeposit(ctx, deposit)
return nil
}

// the deposit is not enough to fulfill the redeem request, use it and remove it
redeemAmount = redeemAmount.Sub(deposit.Amount)
k.DeleteDeposit(ctx, deposit)
deposit.Amount = deposit.Amount.Sub(deposit.Amount) // zero coin, let the epoch delete these entries.
k.SetDeposit(ctx, deposit)
}

return nil
Expand Down

0 comments on commit 7b1acdc

Please sign in to comment.