From 68e8a6e4b0dd2e61b3af2e9f91d10a1f3e763bca Mon Sep 17 00:00:00 2001 From: tinkle-community Date: Tue, 13 Jan 2026 13:42:14 +0800 Subject: [PATCH] fix: provide FromAccountIndex and ApiKeyIndex for Lighter nonce auto-fetch Root cause: SDK requires these fields to fetch nonce from API, otherwise nonce gets cached/stuck --- trader/lighter_trader_v2_orders.go | 6 +++++- trader/lighter_trader_v2_trading.go | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/trader/lighter_trader_v2_orders.go b/trader/lighter_trader_v2_orders.go index 629ffbd1..bfa56c31 100644 --- a/trader/lighter_trader_v2_orders.go +++ b/trader/lighter_trader_v2_orders.go @@ -284,9 +284,13 @@ func (t *LighterTraderV2) CancelOrder(symbol, orderID string) error { } // Sign transaction using SDK + // Must provide FromAccountIndex and ApiKeyIndex for nonce auto-fetch to work nonce := int64(-1) // -1 means auto-fetch + apiKeyIdx := t.apiKeyIndex tx, err := t.txClient.GetCancelOrderTransaction(txReq, &types.TransactOpts{ - Nonce: &nonce, + FromAccountIndex: &t.accountIndex, + ApiKeyIndex: &apiKeyIdx, + Nonce: &nonce, }) if err != nil { return fmt.Errorf("failed to sign cancel order: %w", err) diff --git a/trader/lighter_trader_v2_trading.go b/trader/lighter_trader_v2_trading.go index c4e9b2be..e0b000d1 100644 --- a/trader/lighter_trader_v2_trading.go +++ b/trader/lighter_trader_v2_trading.go @@ -273,9 +273,13 @@ func (t *LighterTraderV2) CreateOrder(symbol string, isAsk bool, quantity float6 } // Sign transaction using SDK (nonce will be auto-fetched) + // Must provide FromAccountIndex and ApiKeyIndex for nonce auto-fetch to work nonce := int64(-1) // -1 means auto-fetch + apiKeyIdx := t.apiKeyIndex tx, err := t.txClient.GetCreateOrderTransaction(txReq, &types.TransactOpts{ - Nonce: &nonce, + FromAccountIndex: &t.accountIndex, + ApiKeyIndex: &apiKeyIdx, + Nonce: &nonce, }) if err != nil { return nil, fmt.Errorf("failed to sign order: %w", err)