feat: enhance order handling in LighterGateway and introduce order identity normalization for improved precision and consistency

This commit is contained in:
discountry
2025-11-12 19:17:04 +08:00
parent 1baee3a207
commit e7f6341961
11 changed files with 318 additions and 40 deletions
+19
View File
@@ -0,0 +1,19 @@
function isPlainObject(value: unknown): value is Record<string, unknown> {
return typeof value === "object" && value != null && !Array.isArray(value);
}
/**
* Determines whether a per-market websocket payload should reset the cached
* orders before applying its contents.
*/
export function shouldResetMarketOrders(bucket: unknown, snapshot: boolean): boolean {
if (snapshot) return true;
if (bucket == null) return false;
if (Array.isArray(bucket)) {
return bucket.length === 0;
}
if (isPlainObject(bucket)) {
return Object.keys(bucket).length === 0;
}
return false;
}