@@ -164,24 +164,23 @@ async function main(): Promise<void> {
164164 )
165165 : Array . from ( userMap . entries ( ) ) ;
166166
167+ function noteMismatch ( functionName : string , userPubkey ) : void {
168+ mismatchesByFunction [ functionName ] =
169+ ( mismatchesByFunction [ functionName ] ?? 0 ) + 1 ;
170+ usersWithDiscrepancies . add ( userPubkey . toBase58 ( ) ) ;
171+ mismatches += 1 ;
172+ }
173+
167174 for ( const [ userKey , currUser ] of usersFilterd ) {
168175 usersChecked += 1 ;
169176 const userPubkey = new PublicKey ( userKey ) ;
170-
171- function noteMismatch ( functionName : string ) : void {
172- mismatchesByFunction [ functionName ] =
173- ( mismatchesByFunction [ functionName ] ?? 0 ) + 1 ;
174- usersWithDiscrepancies . add ( userPubkey . toBase58 ( ) ) ;
175- mismatches += 1 ;
176- }
177-
178177 // clean curr User position flags to be all 0
179178
180179 currUser . getActivePerpPositions ( ) . forEach ( ( position ) => {
181180 position . positionFlag = 0 ;
182181 } ) ;
183182
184- const oldUser = buildOldUserFromSnapshot ( driftClient , currUser , COMMITMENT ) ;
183+ const oldUser = buildOldUserFromSnapshot ( driftClient , currUser ) ;
185184
186185 try {
187186 // Cross-account level comparisons
@@ -202,7 +201,7 @@ async function main(): Promise<void> {
202201 vNew_fc ,
203202 vOld_fc
204203 ) ;
205- noteMismatch ( 'getFreeCollateral' ) ;
204+ noteMismatch ( 'getFreeCollateral' , userPubkey ) ;
206205 }
207206
208207 // only do free collateral for now
@@ -219,7 +218,7 @@ async function main(): Promise<void> {
219218 vNew_tc ,
220219 vOld_tc
221220 ) ;
222- noteMismatch ( 'getTotalCollateral' ) ;
221+ noteMismatch ( 'getTotalCollateral' , userPubkey ) ;
223222 }
224223
225224 // getMarginRequirement (strict=true, includeOpenOrders=true)
@@ -243,7 +242,7 @@ async function main(): Promise<void> {
243242 vNew_mr ,
244243 vOld_mr
245244 ) ;
246- noteMismatch ( 'getMarginRequirement' ) ;
245+ noteMismatch ( 'getMarginRequirement' , userPubkey ) ;
247246 }
248247 }
249248 // continue;
@@ -264,7 +263,7 @@ async function main(): Promise<void> {
264263 vNew_pbp ,
265264 vOld_pbp
266265 ) ;
267- noteMismatch ( 'getPerpBuyingPower' ) ;
266+ noteMismatch ( 'getPerpBuyingPower' , userPubkey ) ;
268267 }
269268
270269 // liquidationPrice (defaults)
@@ -278,7 +277,7 @@ async function main(): Promise<void> {
278277 vNew_lp ,
279278 vOld_lp
280279 ) ;
281- noteMismatch ( 'liquidationPrice' ) ;
280+ noteMismatch ( 'liquidationPrice' , userPubkey ) ;
282281 }
283282
284283 // liquidationPriceAfterClose with 10% of current quote as close amount (skip if zero/absent)
@@ -303,7 +302,7 @@ async function main(): Promise<void> {
303302 vNew_lpac ,
304303 vOld_lpac
305304 ) ;
306- noteMismatch ( 'liquidationPriceAfterClose' ) ;
305+ noteMismatch ( 'liquidationPriceAfterClose' , userPubkey ) ;
307306 }
308307 }
309308 }
0 commit comments