Skip to content

Commit e6952d3

Browse files
mergify[bot]jyzhetqin7
authored
Transfer Insurance Fund Payment Before Subaccount Update + e2e test (backport #3140) (#3231)
Co-authored-by: jyzhe <[email protected]> Co-authored-by: Tian Qin <[email protected]>
1 parent aaddc51 commit e6952d3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

protocol/x/clob/keeper/process_single_match.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,12 @@ func (k Keeper) persistMatchedOrders(
419419
takerBuilderAddress = takerBuilderCodeParams.GetBuilderAddress()
420420
}
421421

422+
// Do this before subaccount updates so that bank sends are always valid between different
423+
// module accounts.
424+
if err := k.subaccountsKeeper.TransferInsuranceFundPayments(ctx, insuranceFundDelta, perpetualId); err != nil {
425+
return takerUpdateResult, makerUpdateResult, affiliateRevSharesQuoteQuantums, err
426+
}
427+
422428
// Create the subaccount update.
423429
updates := []satypes.Update{
424430
// Taker update
@@ -493,9 +499,6 @@ func (k Keeper) persistMatchedOrders(
493499
// perpetual object. This will reduce the number of times we need to get the perpetual from the
494500
// keeper.
495501

496-
if err := k.subaccountsKeeper.TransferInsuranceFundPayments(ctx, insuranceFundDelta, perpetualId); err != nil {
497-
return takerUpdateResult, makerUpdateResult, affiliateRevSharesQuoteQuantums, err
498-
}
499502
perpetual, err := k.perpetualsKeeper.GetPerpetual(ctx, perpetualId)
500503
if err != nil {
501504
return takerUpdateResult, makerUpdateResult, affiliateRevSharesQuoteQuantums, err

0 commit comments

Comments
 (0)