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
+13 -2
View File
@@ -158,12 +158,23 @@ export class LighterExchangeAdapter implements ExchangeAdapter {
}
private logError(context: string, error: unknown): void {
if (process.env.LIGHTER_DEBUG === "1" || process.env.LIGHTER_DEBUG === "true") {
console.error(`[LighterExchangeAdapter] ${context} failed: ${extractMessage(error)}`);
if (process.env.LIGHTER_DEBUG !== "1" && process.env.LIGHTER_DEBUG !== "true") {
return;
}
if (isSuccessfulResponse(error)) {
console.info(`[LighterExchangeAdapter] ${context}: ${JSON.stringify(error)}`);
return;
}
console.error(`[LighterExchangeAdapter] ${context} failed: ${extractMessage(error)}`);
}
}
function isSuccessfulResponse(value: unknown): value is { code?: number } {
if (typeof value !== "object" || value == null) return false;
const code = (value as { code?: unknown }).code;
return typeof code === "number" && code === 200;
}
function resolveApiKeys(credentials: LighterCredentials): Record<number, string> {
if (credentials.apiKeys && Object.keys(credentials.apiKeys).length) {
return credentials.apiKeys;