From 7850d3ba6de4edebffccd2ee5dc54fe73d8ba696 Mon Sep 17 00:00:00 2001 From: bvvvp009 Date: Tue, 23 Dec 2025 14:34:15 +0530 Subject: [PATCH] fix: Change MarketIndex from uint8_t to int16_t to support spot markets Fixes #106 Spot market orders (market_id >= 2048) were incorrectly routed to perps market 0 due to uint8_t overflow. The uint8_t type (max 255) was truncating spot market IDs (2048+) to 0. Updated CreateOrderTxReq struct MarketIndex field from uint8_t to int16_t in Python ctypes definition and all platform header files to match lighter-go sharedlib fix. --- lighter/signer_client.py | 2 +- lighter/signers/lighter-signer-darwin-arm64.h | 2 +- lighter/signers/lighter-signer-linux-amd64.h | 2 +- lighter/signers/lighter-signer-linux-arm64.h | 2 +- lighter/signers/lighter-signer-windows-amd64.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lighter/signer_client.py b/lighter/signer_client.py index c1bb252..2364c56 100644 --- a/lighter/signer_client.py +++ b/lighter/signer_client.py @@ -29,7 +29,7 @@ class ApiKeyResponse(ctypes.Structure): class CreateOrderTxReq(ctypes.Structure): _fields_ = [ - ("MarketIndex", ctypes.c_uint8), + ("MarketIndex", ctypes.c_int16), ("ClientOrderIndex", ctypes.c_longlong), ("BaseAmount", ctypes.c_longlong), ("Price", ctypes.c_uint32), diff --git a/lighter/signers/lighter-signer-darwin-arm64.h b/lighter/signers/lighter-signer-darwin-arm64.h index 307323c..e2f9e86 100644 --- a/lighter/signers/lighter-signer-darwin-arm64.h +++ b/lighter/signers/lighter-signer-darwin-arm64.h @@ -43,7 +43,7 @@ typedef struct { } ApiKeyResponse; typedef struct { - uint8_t MarketIndex; + int16_t MarketIndex; int64_t ClientOrderIndex; int64_t BaseAmount; uint32_t Price; diff --git a/lighter/signers/lighter-signer-linux-amd64.h b/lighter/signers/lighter-signer-linux-amd64.h index b097024..2b3ae4b 100644 --- a/lighter/signers/lighter-signer-linux-amd64.h +++ b/lighter/signers/lighter-signer-linux-amd64.h @@ -43,7 +43,7 @@ typedef struct { } ApiKeyResponse; typedef struct { - uint8_t MarketIndex; + int16_t MarketIndex; int64_t ClientOrderIndex; int64_t BaseAmount; uint32_t Price; diff --git a/lighter/signers/lighter-signer-linux-arm64.h b/lighter/signers/lighter-signer-linux-arm64.h index b097024..2b3ae4b 100644 --- a/lighter/signers/lighter-signer-linux-arm64.h +++ b/lighter/signers/lighter-signer-linux-arm64.h @@ -43,7 +43,7 @@ typedef struct { } ApiKeyResponse; typedef struct { - uint8_t MarketIndex; + int16_t MarketIndex; int64_t ClientOrderIndex; int64_t BaseAmount; uint32_t Price; diff --git a/lighter/signers/lighter-signer-windows-amd64.h b/lighter/signers/lighter-signer-windows-amd64.h index 164e01c..44a69af 100644 --- a/lighter/signers/lighter-signer-windows-amd64.h +++ b/lighter/signers/lighter-signer-windows-amd64.h @@ -43,7 +43,7 @@ typedef struct { } ApiKeyResponse; typedef struct { - uint8_t MarketIndex; + int16_t MarketIndex; int64_t ClientOrderIndex; int64_t BaseAmount; uint32_t Price;