Skip to content

Commit

Permalink
fix: Attackers can prevent users from liquid-staking funds by removin…
Browse files Browse the repository at this point in the history
…g the Deposit entry
  • Loading branch information
puneet2019 committed Jan 19, 2024
1 parent 7d81888 commit e9d20e2
Showing 1 changed file with 6 additions and 2 deletions.
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 e9d20e2

Please sign in to comment.