Skip to content

Commit

Permalink
fix: tidy up collateral balances
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinTrinque committed Dec 20, 2023
1 parent 60466bc commit 3124fb4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/collateral/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -3696,6 +3696,7 @@ func (e *Engine) RemoveDistressed(ctx context.Context, parties []events.MarketPo
if err := e.UpdateBalance(ctx, bondAcc.ID, bondAcc.Balance.SetUint64(0)); err != nil {
return nil, err
}
// get an updated copy of the margin account after being topped up from bond account
marginAcc, _ = e.GetAccountByID(e.accountID(marketID, party.Party(), asset, types.AccountTypeMargin))
}
// take whatever is left on the general account, and move to margin balance
Expand All @@ -3717,6 +3718,7 @@ func (e *Engine) RemoveDistressed(ctx context.Context, parties []events.MarketPo
if err := e.UpdateBalance(ctx, genAcc.ID, genAcc.Balance.SetUint64(0)); err != nil {
return nil, err
}
// get an updated copy of the margin account after being topped up from general account
marginAcc, _ = e.GetAccountByID(e.accountID(marketID, party.Party(), asset, types.AccountTypeMargin))
}
// move monies from the margin account (balance is general, bond, and margin combined now)
Expand Down

0 comments on commit 3124fb4

Please sign in to comment.