@@ -8,7 +8,7 @@ import { BLOCK_RANGE, REAPER_MAX_ATTEMPTS, DYNAMO_BATCH_WRITE_MAX, OLDEST_BLOCK_
88import { ethers } from 'ethers'
99import { CosignedPriorityOrder , CosignedV2DutchOrder , CosignedV3DutchOrder , DutchOrder , FillInfo , CosignedHybridOrder , OrderType , OrderValidation , OrderValidator , REACTOR_ADDRESS_MAPPING , UniswapXEventWatcher , UniswapXOrder } from '@uniswap/uniswapx-sdk'
1010import { parseOrder } from '../../handlers/OrderParser'
11- import { AVERAGE_BLOCK_TIME , getSettledAmounts } from '../../handlers/check-order-status/util'
11+ import { AVERAGE_BLOCK_TIME , getSettledAmounts , IS_TERMINAL_STATE } from '../../handlers/check-order-status/util'
1212import { ChainId } from '../../util/chain'
1313import { getRpcUrl } from '../../Config'
1414import { LimitOrdersRepository } from '../../repositories/limit-orders-repository'
@@ -229,8 +229,7 @@ export class GSReaper {
229229 provider ,
230230 state . chainId ,
231231 this . log ,
232- state . failedFillScanRanges ,
233- this . unresolvedOrderStatus
232+ state . failedFillScanRanges
234233 )
235234
236235 return {
@@ -413,8 +412,7 @@ async function checkCancelledOrders(
413412 provider : ethers . providers . StaticJsonRpcProvider ,
414413 chainId : number ,
415414 log : Logger ,
416- failedFillScanRanges : BlockRange [ ] ,
417- unresolvedOrderStatus : ORDER_STATUS ,
415+ failedFillScanRanges : BlockRange [ ]
418416) : Promise < Record < string , OrderUpdate > > {
419417 const orderUpdates = { ...existingUpdates }
420418 const quoter = new OrderValidator ( provider , chainId )
@@ -463,14 +461,10 @@ async function checkCancelledOrders(
463461 if ( ! orderUpdates [ orderHash ] ) {
464462 try {
465463 const { order, signature, entity } = await getOrderByHash ( repo , orderHash )
466- // Another writer (e.g. the check-order-status state machine) may have
467- // resolved this order since the run's GET_OPEN_ORDERS snapshot -- most
468- // importantly to FILLED, which a used nonce is also consistent with.
469- // Only resolve orders whose DB status still matches the snapshot.
470- if ( entity . orderStatus !== unresolvedOrderStatus ) {
471- log . info (
472- `Order ${ orderHash } status is now ${ entity . orderStatus } (no longer ${ unresolvedOrderStatus } ); skipping resolution`
473- )
464+ // Another writer (e.g. check-order-status) may have resolved this order since
465+ // the run's GET_OPEN_ORDERS snapshot; never re-resolve a terminal order.
466+ if ( IS_TERMINAL_STATE ( entity . orderStatus ) ) {
467+ log . info ( `Order ${ orderHash } is already terminal (${ entity . orderStatus } ); skipping resolution` )
474468 continue
475469 }
476470 // We only check for nonce used and expired for permissioned tokens
0 commit comments