| .. | ||
| backfillTradeIds.ts | ||
| cleanupStaleOrders.ts | ||
| README.md | ||
| reconcileTradeLifecycle.ts | ||
| revertExpiredOrders.ts | ||
| verifyWebsocketContract.ts | ||
Utility Scripts
This directory contains utility scripts for maintenance and troubleshooting.
Available Scripts
cleanupStaleOrders.ts
Purpose: Manually clean up very old stale orders (>24 hours) by marking them as 'unknown'.
When to use:
- After a prolonged bot outage
- When you have many old pending_new orders
- As part of database maintenance
How to run:
npm run cleanup-stale-orders
What it does:
- Queries database for orders in
pending_newstatus older than 24 hours - Marks each order as
unknownstatus - Logs summary of how many orders were updated
Example output:
[Cleanup] Starting stale order cleanup...
[Cleanup] Found 15 orders older than 24 hours in pending_new status
[Cleanup] Marking order abc123 as 'unknown' (age: 48h, symbol: BTC/USDT)
[Cleanup] Marking order def456 as 'unknown' (age: 36h, symbol: ETH/USDT)
...
[Cleanup] ✅ Cleanup complete! Updated 15 stale orders to 'unknown' status
Note: This is a one-time operation. For ongoing sync, use the automatic OrderStatusSyncService (runs every 5 minutes).
Adding New Scripts
To add a new utility script:
- Create a new
.tsfile in this directory - Add the script entry to
package.json:"scripts": { "your-script": "tsx src/scripts/yourScript.ts" } - Document it in this README