fix: correct Lighter API response parsing for GetOpenOrders

- Changed response field from 'data' to 'orders' to match Lighter API
- Updated OrderResponse struct to match Lighter's actual field names
- Fixed field types: price/quantity as strings, is_ask for side
This commit is contained in:
tinkle-community
2026-01-13 13:28:18 +08:00
parent ef91bec2dd
commit 33cf09e7fe
3 changed files with 39 additions and 25 deletions

View File

@@ -148,7 +148,7 @@ func (t *LighterTraderV2) GetOrderStatus(symbol string, orderID string) (map[str
"orderId": order.OrderID,
"status": unifiedStatus,
"avgPrice": order.Price,
"executedQty": order.FilledQty,
"executedQty": order.FilledBaseAmount,
"commission": 0.0,
}, nil
}
@@ -239,11 +239,11 @@ func (t *LighterTraderV2) GetActiveOrders(symbol string) ([]OrderResponse, error
logger.Infof("📋 LIGHTER GetActiveOrders raw response: %s", string(body))
// Parse response
// Parse response - Lighter API uses "orders" field, not "data"
var apiResp struct {
Code int `json:"code"`
Message string `json:"message"`
Data []OrderResponse `json:"data"`
Orders []OrderResponse `json:"orders"`
}
if err := json.Unmarshal(body, &apiResp); err != nil {
@@ -254,8 +254,8 @@ func (t *LighterTraderV2) GetActiveOrders(symbol string) ([]OrderResponse, error
return nil, fmt.Errorf("failed to get active orders (code %d): %s", apiResp.Code, apiResp.Message)
}
logger.Infof("✓ LIGHTER - Retrieved %d active orders", len(apiResp.Data))
return apiResp.Data, nil
logger.Infof("✓ LIGHTER - Retrieved %d active orders", len(apiResp.Orders))
return apiResp.Orders, nil
}
// CancelOrder Cancel a single order