Skip to content

Bug: STOP_LOSS orders (type=2) return "invalid PublicKey" error #102

@sifmimo

Description

@sifmimo

Summary

When creating STOP_LOSS orders (type=2) using the SDK 1.0.2, the server returns {"code":21136,"message":"invalid PublicKey, update the sdk to the latest version"} even though LIMIT orders (type=0) work correctly with the same credentials.

Environment

  • SDK Version: lighter-sdk 1.0.2
  • Python Version: 3.10
  • OS: Linux (both x86_64 and ARM64)
  • Signer binary: lighter-signer-linux-amd64.so (v1.0.2)

Steps to Reproduce

  1. Create a SignerClient with valid credentials
  2. Sign a LIMIT order (type=0) - works correctly
  3. Sign a STOP_LOSS order (type=2) with the same credentials - fails with "invalid PublicKey"

Code Example

# LIMIT order - works
result_limit = signer.SignCreateOrder(
    1,  # market_id
    nonce,
    20,  # base_amount
    88300000,  # price
    1,  # is_ask
    0,  # order_type = LIMIT
    1,  # time_in_force = GTC
    0,  # reduce_only
    0,  # trigger_price
    -1,  # order_expiry
    -1,  # nonce
    api_key_index,
    account_index,
)
# Result: {"code":21739,"message":"not enough margin"} - expected business error

# STOP_LOSS order - fails
result_stop = signer.SignCreateOrder(
    1,  # market_id
    nonce+1,
    20,  # base_amount
    88300000,  # price
    1,  # is_ask
    2,  # order_type = STOP_LOSS
    0,  # time_in_force = IOC (required for STOP_LOSS)
    0,  # reduce_only
    88300000,  # trigger_price
    order_expiry,  # order_expiry (timestamp)
    -1,  # nonce
    api_key_index,
    account_index,
)
# Result: {"code":21136,"message":"invalid PublicKey, update the sdk to the latest version"}

Generated tx_info comparison

LIMIT (works):

{
  "AccountIndex": 281474976628453,
  "ApiKeyIndex": 2,
  "MarketIndex": 1,
  "Type": 0,
  "TimeInForce": 1,
  "TriggerPrice": 0,
  "OrderExpiry": 1768608915864
}

STOP_LOSS (fails):

{
  "AccountIndex": 281474976628453,
  "ApiKeyIndex": 2,
  "MarketIndex": 1,
  "Type": 2,
  "TimeInForce": 0,
  "TriggerPrice": 88300000,
  "OrderExpiry": 1768608915863
}

Expected Behavior

STOP_LOSS orders should be signed and accepted by the server, similar to LIMIT orders.

Actual Behavior

STOP_LOSS orders are signed successfully by the SDK, but the server rejects them with "invalid PublicKey" error.

Additional Information

  • The signature is generated without errors from the signer binary
  • The tx_info JSON contains valid data
  • The same credentials work for LIMIT orders
  • Tested on both Linux x86_64 (AMD64) and Linux ARM64 with the same result

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions