From 7635b7d467cd868d9a9d5af26bed5dd4627497fb Mon Sep 17 00:00:00 2001 From: discountry Date: Fri, 3 Oct 2025 03:29:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=20Lighter=20?= =?UTF-8?q?=E9=80=82=E9=85=8D=E5=99=A8=E7=9A=84=E8=AE=A2=E5=8D=95=E8=BF=87?= =?UTF-8?q?=E6=9C=9F=E9=80=BB=E8=BE=91=EF=BC=8C=E6=94=AF=E6=8C=81=E5=8D=B3?= =?UTF-8?q?=E6=97=B6=E6=88=96=E5=8F=96=E6=B6=88=E8=AE=A2=E5=8D=95=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/exchanges/lighter/gateway.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/exchanges/lighter/gateway.ts b/src/exchanges/lighter/gateway.ts index 552b949..2b50284 100644 --- a/src/exchanges/lighter/gateway.ts +++ b/src/exchanges/lighter/gateway.ts @@ -745,10 +745,17 @@ export class LighterGateway { if (params.stopPrice != null) { triggerPriceScaled = decimalToScaled(params.stopPrice, this.priceDecimals); } - // Align with chain expectations: use absolute future timestamp (ms) for OrderExpiry - // and a shorter-lived tx ExpiredAt. 28 days for order expiry, ~10 minutes for tx expiry. + // Align with chain expectations: + // - IOC and MARKET/STOP_MARKET orders must use Nil/Immediate expiry + // - All other orders use absolute future timestamp (ms) for ~28 days const TWENTY_EIGHT_DAYS_MS = 28 * 24 * 60 * 60 * 1000; - const orderExpiry = BigInt(Date.now() + TWENTY_EIGHT_DAYS_MS); + const isImmediate = + resultTimeInForce === LIGHTER_TIME_IN_FORCE.IMMEDIATE_OR_CANCEL || + resultType === LIGHTER_ORDER_TYPE.MARKET || + resultType === LIGHTER_ORDER_TYPE.STOP_LOSS; + const orderExpiry = isImmediate + ? BigInt(IMMEDIATE_OR_CANCEL_EXPIRY_PLACEHOLDER) + : BigInt(Date.now() + TWENTY_EIGHT_DAYS_MS); return { marketIndex: this.marketId,