lighter-ts-sdk 1.0.11 β†’ 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/README.md +44 -48
  2. package/dist/browser/lighter-ts-sdk.browser.js +493 -89
  3. package/dist/browser/lighter-ts-sdk.browser.js.map +3 -3
  4. package/dist/cjs/api/account-api.d.ts +86 -15
  5. package/dist/cjs/api/account-api.d.ts.map +1 -1
  6. package/dist/cjs/api/account-api.js +107 -2
  7. package/dist/cjs/api/account-api.js.map +1 -1
  8. package/dist/cjs/api/bridge-api.d.ts +16 -0
  9. package/dist/cjs/api/bridge-api.d.ts.map +1 -1
  10. package/dist/cjs/api/bridge-api.js +21 -0
  11. package/dist/cjs/api/bridge-api.js.map +1 -1
  12. package/dist/cjs/api/info-api.d.ts +6 -0
  13. package/dist/cjs/api/info-api.d.ts.map +1 -1
  14. package/dist/cjs/api/info-api.js +11 -2
  15. package/dist/cjs/api/info-api.js.map +1 -1
  16. package/dist/cjs/api/notification-api.js +2 -2
  17. package/dist/cjs/api/notification-api.js.map +1 -1
  18. package/dist/cjs/api/order-api.d.ts +9 -4
  19. package/dist/cjs/api/order-api.d.ts.map +1 -1
  20. package/dist/cjs/api/order-api.js.map +1 -1
  21. package/dist/cjs/api/referral-api.d.ts +38 -0
  22. package/dist/cjs/api/referral-api.d.ts.map +1 -1
  23. package/dist/cjs/api/referral-api.js +69 -2
  24. package/dist/cjs/api/referral-api.js.map +1 -1
  25. package/dist/cjs/api/tokenlist-api.d.ts +18 -0
  26. package/dist/cjs/api/tokenlist-api.d.ts.map +1 -0
  27. package/dist/cjs/api/tokenlist-api.js +14 -0
  28. package/dist/cjs/api/tokenlist-api.js.map +1 -0
  29. package/dist/cjs/api/transaction-api.d.ts +9 -0
  30. package/dist/cjs/api/transaction-api.d.ts.map +1 -1
  31. package/dist/cjs/api/transaction-api.js +16 -0
  32. package/dist/cjs/api/transaction-api.js.map +1 -1
  33. package/dist/cjs/index.d.ts +37 -6
  34. package/dist/cjs/index.d.ts.map +1 -1
  35. package/dist/cjs/index.js +42 -7
  36. package/dist/cjs/index.js.map +1 -1
  37. package/dist/cjs/signer/wasm-signer-client.d.ts +22 -1
  38. package/dist/cjs/signer/wasm-signer-client.d.ts.map +1 -1
  39. package/dist/cjs/signer/wasm-signer-client.js +155 -47
  40. package/dist/cjs/signer/wasm-signer-client.js.map +1 -1
  41. package/dist/cjs/signer/wasm-signer.d.ts +39 -0
  42. package/dist/cjs/signer/wasm-signer.d.ts.map +1 -1
  43. package/dist/cjs/signer/wasm-signer.js +89 -37
  44. package/dist/cjs/signer/wasm-signer.js.map +1 -1
  45. package/dist/cjs/types/api.d.ts +2 -0
  46. package/dist/cjs/types/api.d.ts.map +1 -1
  47. package/dist/esm/api/account-api.d.ts +86 -15
  48. package/dist/esm/api/account-api.d.ts.map +1 -1
  49. package/dist/esm/api/account-api.js +107 -2
  50. package/dist/esm/api/account-api.js.map +1 -1
  51. package/dist/esm/api/bridge-api.d.ts +16 -0
  52. package/dist/esm/api/bridge-api.d.ts.map +1 -1
  53. package/dist/esm/api/bridge-api.js +21 -0
  54. package/dist/esm/api/bridge-api.js.map +1 -1
  55. package/dist/esm/api/info-api.d.ts +6 -0
  56. package/dist/esm/api/info-api.d.ts.map +1 -1
  57. package/dist/esm/api/info-api.js +11 -2
  58. package/dist/esm/api/info-api.js.map +1 -1
  59. package/dist/esm/api/notification-api.js +2 -2
  60. package/dist/esm/api/notification-api.js.map +1 -1
  61. package/dist/esm/api/order-api.d.ts +9 -4
  62. package/dist/esm/api/order-api.d.ts.map +1 -1
  63. package/dist/esm/api/order-api.js.map +1 -1
  64. package/dist/esm/api/referral-api.d.ts +38 -0
  65. package/dist/esm/api/referral-api.d.ts.map +1 -1
  66. package/dist/esm/api/referral-api.js +69 -2
  67. package/dist/esm/api/referral-api.js.map +1 -1
  68. package/dist/esm/api/tokenlist-api.d.ts +18 -0
  69. package/dist/esm/api/tokenlist-api.d.ts.map +1 -0
  70. package/dist/esm/api/tokenlist-api.js +10 -0
  71. package/dist/esm/api/tokenlist-api.js.map +1 -0
  72. package/dist/esm/api/transaction-api.d.ts +9 -0
  73. package/dist/esm/api/transaction-api.d.ts.map +1 -1
  74. package/dist/esm/api/transaction-api.js +16 -0
  75. package/dist/esm/api/transaction-api.js.map +1 -1
  76. package/dist/esm/index.d.ts +37 -6
  77. package/dist/esm/index.d.ts.map +1 -1
  78. package/dist/esm/index.js +39 -5
  79. package/dist/esm/index.js.map +1 -1
  80. package/dist/esm/signer/wasm-signer-client.d.ts +22 -1
  81. package/dist/esm/signer/wasm-signer-client.d.ts.map +1 -1
  82. package/dist/esm/signer/wasm-signer-client.js +156 -48
  83. package/dist/esm/signer/wasm-signer-client.js.map +1 -1
  84. package/dist/esm/signer/wasm-signer.d.ts +39 -0
  85. package/dist/esm/signer/wasm-signer.d.ts.map +1 -1
  86. package/dist/esm/signer/wasm-signer.js +89 -37
  87. package/dist/esm/signer/wasm-signer.js.map +1 -1
  88. package/dist/esm/types/api.d.ts +2 -0
  89. package/dist/esm/types/api.d.ts.map +1 -1
  90. package/dist/umd/lighter-signer.wasm +0 -0
  91. package/dist/umd/lighter-ts-sdk.js +493 -89
  92. package/dist/umd/lighter-ts-sdk.js.map +3 -3
  93. package/dist/umd/lighter-ts-sdk.min.js +8 -8
  94. package/dist/umd/lighter-ts-sdk.min.js.map +4 -4
  95. package/dist/umd/package.json +1 -1
  96. package/docs/GettingStarted.md +398 -388
  97. package/docs/MigrationGuide.md +5 -4
  98. package/docs/SignerClient.md +93 -0
  99. package/examples/README.md +178 -247
  100. package/examples/bridge_create_intent_address.ts +67 -0
  101. package/examples/cancel_all_orders_single_market.ts +37 -0
  102. package/examples/change_account_tier.ts +1 -1
  103. package/examples/close_all_positions.ts +7 -9
  104. package/examples/close_position.ts +9 -10
  105. package/examples/create_auth_token.ts +2 -0
  106. package/examples/create_grouped_ioc_with_integrator.ts +64 -0
  107. package/examples/create_grouped_orders.ts +219 -205
  108. package/examples/create_limit_order.ts +3 -3
  109. package/examples/create_market_order.ts +3 -4
  110. package/examples/create_market_order_quote_amount.ts +62 -0
  111. package/examples/create_order_skip_nonce.ts +63 -0
  112. package/examples/create_twap_order.ts +3 -3
  113. package/examples/deposit_to_subaccount.ts +7 -4
  114. package/examples/disable_eth_as_margin.ts +35 -0
  115. package/examples/disable_uta.ts +32 -0
  116. package/examples/enable_eth_as_margin.ts +35 -0
  117. package/examples/enable_uta.ts +32 -0
  118. package/examples/get_set_maker_only_api_keys.ts +43 -0
  119. package/examples/info_api_new_endpoints.ts +44 -0
  120. package/examples/integrator_approve.ts +54 -0
  121. package/examples/integrator_approve_same_master.ts +42 -0
  122. package/examples/integrator_create_modify_order.ts +119 -0
  123. package/examples/integrator_revoke.ts +43 -0
  124. package/examples/live_smoke.ts +72 -73
  125. package/examples/margin_eth_add_collateral_http.ts +1 -1
  126. package/examples/margin_eth_remove_collateral_http.ts +1 -1
  127. package/examples/market_data.ts +2 -3
  128. package/examples/modify_order.ts +13 -13
  129. package/examples/multi_client_advanced.ts +2 -2
  130. package/examples/onboarding.ts +9 -4
  131. package/examples/public_pool_deposit.ts +1 -1
  132. package/examples/public_pool_info.ts +8 -2
  133. package/examples/public_pool_operations.ts +4 -4
  134. package/examples/public_pool_withdraw.ts +1 -1
  135. package/examples/quickstart.ts +95 -0
  136. package/examples/referral_create.ts +60 -0
  137. package/examples/revoke_api_key.ts +2 -2
  138. package/examples/rfq_create_and_list.ts +63 -0
  139. package/examples/self_trade_create_modify_order.ts +93 -0
  140. package/examples/self_trade_grouped_orders.ts +49 -0
  141. package/examples/spot/README.md +4 -9
  142. package/examples/spot/cancel_spot_order.ts +3 -3
  143. package/examples/spot/create_market_spot_orders.ts +3 -3
  144. package/examples/spot/create_spot_limit_order.ts +6 -6
  145. package/examples/spot/create_spot_limit_order_with_sltp.ts +6 -7
  146. package/examples/spot/create_spot_twap_order.ts +1 -1
  147. package/examples/spot/modify_spot_order.ts +3 -3
  148. package/examples/spot_get_account_assets_http.ts +5 -5
  149. package/examples/stake_and_unstake.ts +48 -0
  150. package/examples/system_setup.ts +28 -6
  151. package/examples/tokenlist.ts +19 -0
  152. package/examples/transfer_same_master_account.ts +62 -0
  153. package/examples/transfer_spot_perp.ts +21 -65
  154. package/examples/update_margin_leverage.ts +3 -3
  155. package/examples/websocket_subscribe.ts +55 -0
  156. package/examples/withdraw_fast.ts +4 -4
  157. package/package.json +4 -3
  158. package/wasm/lighter-signer.wasm +0 -0
package/README.md CHANGED
@@ -21,16 +21,44 @@ npm install lighter-ts-sdk
21
21
  yarn add lighter-ts-sdk
22
22
  ```
23
23
 
24
+ ### Module Formats
25
+
26
+ The package ships ESM, CommonJS, and a browser UMD bundle, resolved automatically via `package.json`'s `exports` field. Both of the following work out of the box:
27
+
28
+ ```typescript
29
+ // ESM (import)
30
+ import { SignerClient, ApiClient, OrderType } from 'lighter-ts-sdk';
31
+ ```
32
+
33
+ ```javascript
34
+ // CommonJS (require)
35
+ const { SignerClient, ApiClient, OrderType } = require('lighter-ts-sdk');
36
+ ```
37
+
38
+ ```html
39
+ <!-- Browser (UMD global) -->
40
+ <script src="https://unpkg.com/lighter-ts-sdk/dist/umd/lighter-ts-sdk.js"></script>
41
+ <script>
42
+ const { SignerClient } = window.LighterSDK;
43
+ </script>
44
+ ```
45
+
24
46
  ## πŸš€ What Does This SDK Do?
25
47
 
26
48
  The Lighter TypeScript SDK provides everything you need to:
27
- - **Trade perpetual futures and SPOT Markets** on Lighter Protocol
49
+ - **Trade perpetual futures and spot markets** on Lighter Protocol
28
50
  - **Create orders** (Market, Limit, TWAP) with automatic SL/TP
29
- - **Manage positions** (open, close, update leverage)
30
- - **Transfer funds** between accounts
51
+ - **Build grouped orders** (OTO, OCO, OTOCO) and self-trade-prevention orders
52
+ - **Manage positions** (open, close, update leverage and margin mode)
53
+ - **Manage sub-accounts** and transfer funds between accounts (including spot↔perp)
54
+ - **Approve and route fees to integrators** (frontends, bots, affiliate platforms)
55
+ - **Manage Unified Trading Account (UTA) and per-asset margin settings**
56
+ - **Use public pools, staking, and RFQ** where available on your account
31
57
  - **Monitor transactions** with built-in status tracking
32
58
  - **Handle errors** automatically with retry logic
33
59
 
60
+ See [`examples/`](./examples) for a runnable script covering every feature above.
61
+
34
62
  ## 🎯 Getting Started
35
63
 
36
64
  ### Step 1: Set Up Your Environment
@@ -362,7 +390,7 @@ await signerClient.updateMargin(
362
390
  - `direction` parameter is only used for isolated-margin positions
363
391
  - Always verify sufficient collateral before removing it
364
392
 
365
- ## οΏ½πŸ”§ Common Operations
393
+ ## πŸ”§ Common Operations
366
394
 
367
395
  ### Create a Market Order
368
396
 
@@ -584,11 +612,13 @@ try {
584
612
 
585
613
  ## πŸ“– Examples
586
614
 
587
- The `examples/` directory contains working examples for every feature:
615
+ The `examples/` directory contains 60+ working examples covering every feature, all run against a live mainnet account as part of this SDK's release validation. Start with the quickstart, then browse [`examples/README.md`](./examples/README.md) for the full index.
588
616
 
589
617
  ```bash
590
- # Run examples
591
- npx tsx examples/create_market_order.ts # Market order with SL/TP
618
+ npx tsx examples/quickstart.ts # Smallest possible flow: create, confirm, cancel an order
619
+
620
+ # Then explore by feature
621
+ npx tsx examples/create_market_order.ts # Market order with SL/TP
592
622
  npx tsx examples/create_limit_order.ts # Limit order with SL/TP
593
623
  npx tsx examples/cancel_order.ts # Cancel orders
594
624
  npx tsx examples/close_position.ts # Close positions
@@ -597,48 +627,14 @@ npx tsx examples/deposit_to_subaccount.ts # Fund transfers
597
627
 
598
628
  ## πŸŽ“ Learning Path
599
629
 
600
- 1. **Start Here**: `examples/create_market_order.ts` - Simplest order creation
601
- 2. **Next**: `examples/create_limit_order.ts` - Learn about limit orders
630
+ 1. **Start Here**: `examples/quickstart.ts` - Smallest possible end-to-end flow
631
+ 2. **Next**: `examples/create_limit_order.ts` / `examples/create_market_order.ts` - Orders with SL/TP
602
632
  3. **Then**: `examples/cancel_order.ts` - Learn about order management
603
- 4. **Advanced**: `examples/send_tx_batch.ts` - Batch transactions
604
-
605
- ## βœ… Live Executed Transactions (Testnet)
633
+ 4. **Advanced**: `examples/create_grouped_orders.ts`, `examples/send_tx_batch.ts` - Grouped and batch transactions
606
634
 
607
- The SDK has been thoroughly tested with real transactions on Lighter Protocol testnet. Here are verified transaction hashes from live example execution:
635
+ ## βœ… Live-Tested Against Mainnet
608
636
 
609
- ### Real Transaction Examples
610
-
611
- **1. Market Order with OTOCO (SL/TP)**
612
- ```
613
- Transaction Hash: c622140d6d15760bbf5462e3f472a97b0eac8fb138becc00cb7ce24b223c19e352fe7e15098337c5
614
- Example: examples/create_market_order.ts
615
- Details: 60 ETH order with $2800 SL / $3100 TP
616
- Status: βœ… Submitted to testnet
617
- ```
618
-
619
- **2. Limit Order with Grouping**
620
- ```
621
- Transaction Hash: 4349b469fa8d71161fc012a9d3224e1f4eda355527e91e83bb193ab9345bc19bfba22d7ab64721d1
622
- Example: examples/create_limit_order.ts
623
- Details: Limit entry with automatic SL/TP attachment
624
- Status: βœ… Submitted to testnet
625
- ```
626
-
627
- **3. Market Order with Max Slippage (1%)**
628
- ```
629
- Transaction Hash: f1d2ab2ca65f77310502298961c6e738e21a2b9f2e8e4614a75d2bbf5a4168d225bec7708675cdca
630
- Example: examples/create_market_order_max_slippage.ts
631
- Details: Market order with 1% slippage protection
632
- Status: βœ… Submitted to testnet
633
- ```
634
-
635
- **4. IOC Order with Attached SL/TP**
636
- ```
637
- Transaction Hash: 1d64b0bab34e2469a190558e53d13c8614ebd5075d4ed2eca079aab551a259b92343ad1c5d1fbed8
638
- Example: examples/create_grouped_ioc_with_attached_sl_tp.ts
639
- Details: Immediate-or-cancel with grouped exits
640
- Status: βœ… Submitted to testnet
641
- ```
637
+ Every example in [`examples/`](./examples), including `examples/spot/`, has been exercised against a live Lighter Protocol mainnet account as part of this SDK's release validation β€” order lifecycle (market/limit/TWAP, perp and spot), grouped orders (OTO/OCO/OTOCO), integrator approve/order/revoke, sub-accounts and transfers, margin/UTA toggles, and transaction status monitoring. Examples that depend on account-specific state (balances, whitelist access, a second funded account) are clearly marked as such in [`examples/README.md`](./examples/README.md) rather than reporting false success.
642
638
 
643
639
  ### Running Your Own Transactions
644
640
 
@@ -707,9 +703,9 @@ If you're upgrading from an older version that used `temp-lighter-go`:
707
703
 
708
704
  **None!** The API remains the same. The change is internal to signer implementation.
709
705
 
710
- ### Removed Functions
706
+ ### Unsupported Functions
711
707
 
712
- These functions are no longer supported and have been removed:
708
+ These methods still exist for backward compatibility but throw an informative error, since the underlying functionality is not exported by the `lighter-go` WASM signer:
713
709
  - `getPublicKey()` - Use `generateAPIKey()` instead (returns both keys)
714
710
  - `switchAPIKey()` - Use `createClient()` with different `apiKeyIndex` values instead
715
711