perp-cli 0.7.36 → 0.7.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -570,6 +570,8 @@ export class FundingArbStrategy {
|
|
|
570
570
|
ctx.log(` [ARB] WARNING: Fill reconciliation failed: ${reconMsg}`);
|
|
571
571
|
}
|
|
572
572
|
// Verify both positions actually exist (catches instant liquidation)
|
|
573
|
+
// Wait for cache to expire before checking (exchanges cache positions for ~5s)
|
|
574
|
+
await new Promise(resolve => setTimeout(resolve, 6000));
|
|
573
575
|
try {
|
|
574
576
|
const [longPositions, shortPositions] = await Promise.all([
|
|
575
577
|
longAdapter.getPositions(),
|
|
@@ -577,10 +579,14 @@ export class FundingArbStrategy {
|
|
|
577
579
|
]);
|
|
578
580
|
const longExists = longPositions.some(p => p.symbol.toUpperCase() === best.symbol.toUpperCase() && parseFloat(p.size) > 0);
|
|
579
581
|
const shortExists = shortPositions.some(p => p.symbol.toUpperCase() === best.symbol.toUpperCase() && parseFloat(p.size) > 0);
|
|
580
|
-
if (!longExists
|
|
582
|
+
if (!longExists && !shortExists) {
|
|
583
|
+
// Both missing likely means cache issue — log warning but don't rollback
|
|
584
|
+
ctx.log(` [ARB] Position verification: both sides not visible for ${best.symbol} (may be cache delay)`);
|
|
585
|
+
}
|
|
586
|
+
else if (!longExists || !shortExists) {
|
|
587
|
+
// One side missing = instant liquidation — rollback the other
|
|
581
588
|
ctx.log(` [ARB] Position verification failed for ${best.symbol}: long=${longExists}, short=${shortExists}`);
|
|
582
589
|
logExecution({ type: "arb_entry", exchange: `${best.longExchange}↔${best.shortExchange}`, symbol: best.symbol, side: "verify", size: matched.size, status: "failed", error: `Position missing after fill: long=${longExists} short=${shortExists}`, dryRun: false });
|
|
583
|
-
// Rollback whichever side exists
|
|
584
590
|
if (longExists && !shortExists) {
|
|
585
591
|
try {
|
|
586
592
|
await longAdapter.marketOrder(best.symbol, "sell", matched.size);
|