@@ -635,27 +635,29 @@ export class UserPnlSettlerBot implements Bot {
635635 perpPosition . quoteAssetAmount ,
636636 QUOTE_PRECISION
637637 ) ;
638- logger . info (
639- `[trySettleUsersWithNoPositions] User ${ user
640- . getUserAccountPublicKey ( )
641- . toBase58 ( ) } has empty perp position in market ${
642- perpPosition . marketIndex
643- } with unsettled pnl: ${ pnl } `
644- ) ;
645-
646- const userData = {
647- settleeUserAccountPublicKey : user . getUserAccountPublicKey ( ) ,
648- settleeUserAccount : user . getUserAccount ( ) ,
649- pnl,
650- } ;
638+ if ( pnl !== 0 ) {
639+ logger . info (
640+ `[trySettleUsersWithNoPositions] User ${ user
641+ . getUserAccountPublicKey ( )
642+ . toBase58 ( ) } has empty perp position in market ${
643+ perpPosition . marketIndex
644+ } with unsettled pnl: ${ pnl } `
645+ ) ;
651646
652- if ( usersToSettleMap . has ( perpPosition . marketIndex ) ) {
653- const existingData = usersToSettleMap . get (
654- perpPosition . marketIndex
655- ) ! ;
656- existingData . push ( userData ) ;
657- } else {
658- usersToSettleMap . set ( perpPosition . marketIndex , [ userData ] ) ;
647+ const userData = {
648+ settleeUserAccountPublicKey : user . getUserAccountPublicKey ( ) ,
649+ settleeUserAccount : user . getUserAccount ( ) ,
650+ pnl,
651+ } ;
652+
653+ if ( usersToSettleMap . has ( perpPosition . marketIndex ) ) {
654+ const existingData = usersToSettleMap . get (
655+ perpPosition . marketIndex
656+ ) ! ;
657+ existingData . push ( userData ) ;
658+ } else {
659+ usersToSettleMap . set ( perpPosition . marketIndex , [ userData ] ) ;
660+ }
659661 }
660662 }
661663 }
@@ -821,18 +823,24 @@ export class UserPnlSettlerBot implements Bot {
821823 doSimulation : true ,
822824 recentBlockhash : recentBlockhash . blockhash ,
823825 } ) ;
824- logger . info (
825- `[sendTxForChunk] Settle Pnl estimated ${ simResult . cuEstimate } CUs for ${ ixs . length } ixs, ${ users . length } users.`
826- ) ;
827826 if ( simResult . simError !== null ) {
828827 logger . error (
829- `Sim error: ${ JSON . stringify ( simResult . simError ) } \n${
828+ `Sim error for users: ${ users
829+ . map ( ( u ) => u . settleeUserAccountPublicKey . toBase58 ( ) )
830+ . join ( ', ' ) } : ${ JSON . stringify ( simResult . simError ) } \n${
830831 simResult . simTxLogs ? simResult . simTxLogs . join ( '\n' ) : ''
831832 } `
832833 ) ;
833834 handleSimResultError ( simResult , errorCodesToSuppress , `(settlePnL)` ) ;
834835 success = false ;
835836 } else {
837+ logger . info (
838+ `[sendTxForChunk] Settle Pnl estimated ${
839+ simResult . cuEstimate
840+ } CUs for ${ ixs . length } ixs, ${ users . length } users (${ users
841+ . map ( ( u ) => u . settleeUserAccountPublicKey . toBase58 ( ) )
842+ . join ( ', ' ) } )`
843+ ) ;
836844 const sendTxStart = Date . now ( ) ;
837845 const txSig = await this . driftClient . txSender . sendVersionedTransaction (
838846 simResult . tx ,
0 commit comments