Skip to content

Commit

Permalink
fix: added more checks for party sufficient balance on submit and amend
Browse files Browse the repository at this point in the history
  • Loading branch information
ze97286 committed Apr 26, 2024
1 parent 63f0e4a commit f72d300
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions core/execution/spot/market.go
Original file line number Diff line number Diff line change
Expand Up @@ -2225,6 +2225,12 @@ func (m *Market) amendOrder(ctx context.Context, orderAmendment *types.OrderAmen
if ret.Order.Side == types.SideSell {
asset = m.baseAsset
}

// verify that the party has sufficient funds in their general account to cover for this amount
if err := m.collateral.PartyHasSufficientBalance(asset, ret.Order.Party, num.Sum(amt, fees)); err != nil {
return nil, nil, err
}

transfer, err := m.orderHoldingTracker.TransferToHoldingAccount(ctx, ret.Order.ID, ret.Order.Party, asset, amt, fees)
if err != nil {
m.log.Panic("failed to transfer funds to holding account for order", logging.Order(ret.Order), logging.Error(err))
Expand Down Expand Up @@ -3042,6 +3048,12 @@ func (m *Market) transferToHoldingAccount(ctx context.Context, order *types.Orde
if order.Side == types.SideSell {
asset = m.baseAsset
}

// verify that the party has sufficient funds in their general account to cover for this amount
if err := m.collateral.PartyHasSufficientBalance(asset, order.Party, num.Sum(amt, fees)); err != nil {
return err
}

transfer, err := m.orderHoldingTracker.TransferToHoldingAccount(ctx, order.ID, order.Party, asset, amt, fees)
if err != nil {
m.log.Panic("failed to transfer funds to holding account for order", logging.Order(order), logging.Error(err))
Expand Down

0 comments on commit f72d300

Please sign in to comment.