Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

force reloading equity share when party lp is cancelled or goes out of pending state #3361

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion execution/market.go
Original file line number Diff line number Diff line change
Expand Up @@ -3633,8 +3633,11 @@ func (m *Market) updateAndCreateOrders(
return parties[i].Party < parties[j].Party
})

var updateShares bool
for _, v := range parties {
if !v.Faulty {
// update shares to add this party to the shares
updateShares = true
m.liquidity.RemovePending(v.Party)
continue
}
Expand All @@ -3649,8 +3652,21 @@ func (m *Market) updateAndCreateOrders(
}

// now the party had not enough enough funds to pay the margin
_ = m.cancelDistressedLiquidityProvision(
err := m.cancelDistressedLiquidityProvision(
ctx, v.Party, faultyLPOrders[v.Party])
if err != nil {
m.log.Debug("issue cancelling liquidity provision",
logging.Error(err),
logging.MarketID(m.GetID()),
logging.PartyID(v.Party))
}
// update shares to remove this party from the shares
updateShares = true
}

if updateShares {
// force update of shares so they are updated for all
_ = m.equityShares.Shares(m.liquidity.GetInactiveParties())
}

return nil
Expand Down