File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
protocol/daemons/liquidation/client Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -590,7 +590,11 @@ func TestSendLiquidatableSubaccountIds(t *testing.T) {
590590 tc .subaccountOpenPositionInfo ,
591591 1000 ,
592592 )
593- require .Equal (t , tc .expectedError , err )
593+ if tc .expectedError != nil {
594+ require .ErrorContains (t , err , tc .expectedError .Error ())
595+ } else {
596+ require .NoError (t , err )
597+ }
594598 })
595599 }
596600}
Original file line number Diff line number Diff line change @@ -30,7 +30,9 @@ type SubTaskRunner interface {
3030 ) error
3131}
3232
33- type SubTaskRunnerImpl struct {}
33+ type SubTaskRunnerImpl struct {
34+ lastLoopBlockHeight uint32
35+ }
3436
3537// Ensure SubTaskRunnerImpl implements the SubTaskRunner interface.
3638var _ SubTaskRunner = (* SubTaskRunnerImpl )(nil )
@@ -54,6 +56,19 @@ func (s *SubTaskRunnerImpl) RunLiquidationDaemonTaskLoop(
5456 return err
5557 }
5658
59+ // Skip the loop if no new block has been committed.
60+ // Note that lastLoopBlockHeight is initialized to 0, so the first loop will always run.
61+ if lastCommittedBlockHeight == s .lastLoopBlockHeight {
62+ daemonClient .logger .Info (
63+ "Skipping liquidation daemon task loop as no new block has been committed" ,
64+ "blockHeight" , lastCommittedBlockHeight ,
65+ )
66+ return nil
67+ }
68+
69+ // Update the last loop block height.
70+ s .lastLoopBlockHeight = lastCommittedBlockHeight
71+
5772 // 1. Fetch all information needed to calculate total net collateral and margin requirements.
5873 subaccounts ,
5974 perpInfos ,
You can’t perform that action at this time.
0 commit comments