Skip to content

Commit

Permalink
bugfix for hotfix: fix deltaQuantums calculation (#537)
Browse files Browse the repository at this point in the history
  • Loading branch information
BrendanChou authored Oct 8, 2023
1 parent 1da1b6b commit 04ceb92
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions protocol/x/clob/keeper/liquidations.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,13 @@ func (k Keeper) LiquidateSubaccountsAgainstOrderbook(
if numAttemptedDeleveraging < k.MaxDeleveragingAttemptsPerBlock {
// The liquidation order was unfilled. Try to deleverage the subaccount.
subaccountId := liquidationOrder.GetSubaccountId()
deltaQuantums := liquidationOrder.GetDeltaQuantums()
subaccount := k.subaccountsKeeper.GetSubaccount(ctx, subaccountId)

// Get a pseudorandom perpetualId from the list of open positions.
subaccount := k.subaccountsKeeper.GetSubaccount(ctx, subaccountId)
positions := subaccount.GetPerpetualPositions()
perpetualId := positions[pseudoRand.Intn(len(positions))].PerpetualId
position := positions[pseudoRand.Intn(len(positions))]
perpetualId := position.PerpetualId
deltaQuantums := new(big.Int).Neg(position.GetBigQuantums())

_, err := k.MaybeDeleverageSubaccount(ctx, subaccountId, perpetualId, deltaQuantums)
if err != nil {
Expand Down

0 comments on commit 04ceb92

Please sign in to comment.