mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-13 07:46:54 +08:00
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
This commit is contained in:
@@ -284,9 +284,13 @@ func (t *LighterTraderV2) CancelOrder(symbol, orderID string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sign transaction using SDK
|
// Sign transaction using SDK
|
||||||
|
// Must provide FromAccountIndex and ApiKeyIndex for nonce auto-fetch to work
|
||||||
nonce := int64(-1) // -1 means auto-fetch
|
nonce := int64(-1) // -1 means auto-fetch
|
||||||
|
apiKeyIdx := t.apiKeyIndex
|
||||||
tx, err := t.txClient.GetCancelOrderTransaction(txReq, &types.TransactOpts{
|
tx, err := t.txClient.GetCancelOrderTransaction(txReq, &types.TransactOpts{
|
||||||
Nonce: &nonce,
|
FromAccountIndex: &t.accountIndex,
|
||||||
|
ApiKeyIndex: &apiKeyIdx,
|
||||||
|
Nonce: &nonce,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to sign cancel order: %w", err)
|
return fmt.Errorf("failed to sign cancel order: %w", err)
|
||||||
|
|||||||
@@ -273,9 +273,13 @@ func (t *LighterTraderV2) CreateOrder(symbol string, isAsk bool, quantity float6
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sign transaction using SDK (nonce will be auto-fetched)
|
// 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
|
nonce := int64(-1) // -1 means auto-fetch
|
||||||
|
apiKeyIdx := t.apiKeyIndex
|
||||||
tx, err := t.txClient.GetCreateOrderTransaction(txReq, &types.TransactOpts{
|
tx, err := t.txClient.GetCreateOrderTransaction(txReq, &types.TransactOpts{
|
||||||
Nonce: &nonce,
|
FromAccountIndex: &t.accountIndex,
|
||||||
|
ApiKeyIndex: &apiKeyIdx,
|
||||||
|
Nonce: &nonce,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to sign order: %w", err)
|
return nil, fmt.Errorf("failed to sign order: %w", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user