lighter-ts-sdk 1.0.10 β 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.
- package/README.md +44 -48
- package/dist/browser/lighter-ts-sdk.browser.js +1396 -528
- package/dist/browser/lighter-ts-sdk.browser.js.map +4 -4
- package/dist/cjs/api/account-api.d.ts +87 -15
- package/dist/cjs/api/account-api.d.ts.map +1 -1
- package/dist/cjs/api/account-api.js +107 -2
- package/dist/cjs/api/account-api.js.map +1 -1
- package/dist/cjs/api/bridge-api.d.ts +16 -0
- package/dist/cjs/api/bridge-api.d.ts.map +1 -1
- package/dist/cjs/api/bridge-api.js +21 -0
- package/dist/cjs/api/bridge-api.js.map +1 -1
- package/dist/cjs/api/info-api.d.ts +6 -0
- package/dist/cjs/api/info-api.d.ts.map +1 -1
- package/dist/cjs/api/info-api.js +11 -2
- package/dist/cjs/api/info-api.js.map +1 -1
- package/dist/cjs/api/notification-api.js +2 -2
- package/dist/cjs/api/notification-api.js.map +1 -1
- package/dist/cjs/api/order-api.d.ts +14 -7
- package/dist/cjs/api/order-api.d.ts.map +1 -1
- package/dist/cjs/api/order-api.js +1 -1
- package/dist/cjs/api/order-api.js.map +1 -1
- package/dist/cjs/api/referral-api.d.ts +38 -0
- package/dist/cjs/api/referral-api.d.ts.map +1 -1
- package/dist/cjs/api/referral-api.js +69 -2
- package/dist/cjs/api/referral-api.js.map +1 -1
- package/dist/cjs/api/tokenlist-api.d.ts +18 -0
- package/dist/cjs/api/tokenlist-api.d.ts.map +1 -0
- package/dist/cjs/api/tokenlist-api.js +14 -0
- package/dist/cjs/api/tokenlist-api.js.map +1 -0
- package/dist/cjs/api/transaction-api.d.ts +9 -0
- package/dist/cjs/api/transaction-api.d.ts.map +1 -1
- package/dist/cjs/api/transaction-api.js +16 -0
- package/dist/cjs/api/transaction-api.js.map +1 -1
- package/dist/cjs/api/ws-client.d.ts +28 -0
- package/dist/cjs/api/ws-client.d.ts.map +1 -1
- package/dist/cjs/api/ws-client.js +22 -0
- package/dist/cjs/api/ws-client.js.map +1 -1
- package/dist/cjs/index.d.ts +38 -6
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +42 -7
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/signer/wasm-signer-client.d.ts +99 -4
- package/dist/cjs/signer/wasm-signer-client.d.ts.map +1 -1
- package/dist/cjs/signer/wasm-signer-client.js +361 -88
- package/dist/cjs/signer/wasm-signer-client.js.map +1 -1
- package/dist/cjs/signer/wasm-signer.d.ts +97 -0
- package/dist/cjs/signer/wasm-signer.d.ts.map +1 -1
- package/dist/cjs/signer/wasm-signer.js +198 -40
- package/dist/cjs/signer/wasm-signer.js.map +1 -1
- package/dist/cjs/types/api.d.ts +2 -0
- package/dist/cjs/types/api.d.ts.map +1 -1
- package/dist/cjs/types/trading.d.ts +12 -0
- package/dist/cjs/types/trading.d.ts.map +1 -1
- package/dist/esm/api/account-api.d.ts +87 -15
- package/dist/esm/api/account-api.d.ts.map +1 -1
- package/dist/esm/api/account-api.js +107 -2
- package/dist/esm/api/account-api.js.map +1 -1
- package/dist/esm/api/bridge-api.d.ts +16 -0
- package/dist/esm/api/bridge-api.d.ts.map +1 -1
- package/dist/esm/api/bridge-api.js +21 -0
- package/dist/esm/api/bridge-api.js.map +1 -1
- package/dist/esm/api/info-api.d.ts +6 -0
- package/dist/esm/api/info-api.d.ts.map +1 -1
- package/dist/esm/api/info-api.js +11 -2
- package/dist/esm/api/info-api.js.map +1 -1
- package/dist/esm/api/notification-api.js +2 -2
- package/dist/esm/api/notification-api.js.map +1 -1
- package/dist/esm/api/order-api.d.ts +14 -7
- package/dist/esm/api/order-api.d.ts.map +1 -1
- package/dist/esm/api/order-api.js +1 -1
- package/dist/esm/api/order-api.js.map +1 -1
- package/dist/esm/api/referral-api.d.ts +38 -0
- package/dist/esm/api/referral-api.d.ts.map +1 -1
- package/dist/esm/api/referral-api.js +69 -2
- package/dist/esm/api/referral-api.js.map +1 -1
- package/dist/esm/api/tokenlist-api.d.ts +18 -0
- package/dist/esm/api/tokenlist-api.d.ts.map +1 -0
- package/dist/esm/api/tokenlist-api.js +10 -0
- package/dist/esm/api/tokenlist-api.js.map +1 -0
- package/dist/esm/api/transaction-api.d.ts +9 -0
- package/dist/esm/api/transaction-api.d.ts.map +1 -1
- package/dist/esm/api/transaction-api.js +16 -0
- package/dist/esm/api/transaction-api.js.map +1 -1
- package/dist/esm/api/ws-client.d.ts +28 -0
- package/dist/esm/api/ws-client.d.ts.map +1 -1
- package/dist/esm/api/ws-client.js +22 -0
- package/dist/esm/api/ws-client.js.map +1 -1
- package/dist/esm/index.d.ts +38 -6
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +39 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/signer/wasm-signer-client.d.ts +99 -4
- package/dist/esm/signer/wasm-signer-client.d.ts.map +1 -1
- package/dist/esm/signer/wasm-signer-client.js +362 -89
- package/dist/esm/signer/wasm-signer-client.js.map +1 -1
- package/dist/esm/signer/wasm-signer.d.ts +97 -0
- package/dist/esm/signer/wasm-signer.d.ts.map +1 -1
- package/dist/esm/signer/wasm-signer.js +198 -40
- package/dist/esm/signer/wasm-signer.js.map +1 -1
- package/dist/esm/types/api.d.ts +2 -0
- package/dist/esm/types/api.d.ts.map +1 -1
- package/dist/esm/types/trading.d.ts +12 -0
- package/dist/esm/types/trading.d.ts.map +1 -1
- package/dist/umd/lighter-signer.wasm +0 -0
- package/dist/umd/lighter-ts-sdk.js +1397 -529
- package/dist/umd/lighter-ts-sdk.js.map +4 -4
- package/dist/umd/lighter-ts-sdk.min.js +11 -8
- package/dist/umd/lighter-ts-sdk.min.js.map +4 -4
- package/dist/umd/package.json +1 -1
- package/dist/umd/wasm_exec.js +575 -575
- package/docs/GettingStarted.md +398 -388
- package/docs/MigrationGuide.md +5 -4
- package/docs/OrderApi.md +5 -2
- package/docs/SignerClient.md +108 -2
- package/docs/WsClient.md +29 -0
- package/examples/README.md +178 -247
- package/examples/bridge_create_intent_address.ts +67 -0
- package/examples/cancel_all_orders_single_market.ts +37 -0
- package/examples/change_account_tier.ts +1 -1
- package/examples/close_all_positions.ts +7 -9
- package/examples/close_position.ts +9 -10
- package/examples/create_auth_token.ts +2 -0
- package/examples/create_grouped_ioc_with_attached_sl_tp.ts +20 -3
- package/examples/create_grouped_ioc_with_integrator.ts +64 -0
- package/examples/create_grouped_orders.ts +219 -205
- package/examples/create_limit_order.ts +3 -3
- package/examples/create_market_order.ts +3 -4
- package/examples/create_market_order_quote_amount.ts +62 -0
- package/examples/create_order_skip_nonce.ts +63 -0
- package/examples/create_twap_order.ts +3 -3
- package/examples/deposit_to_subaccount.ts +7 -4
- package/examples/disable_eth_as_margin.ts +35 -0
- package/examples/disable_uta.ts +32 -0
- package/examples/enable_eth_as_margin.ts +35 -0
- package/examples/enable_uta.ts +32 -0
- package/examples/get_set_maker_only_api_keys.ts +43 -0
- package/examples/info_api_new_endpoints.ts +44 -0
- package/examples/integrator_approve.ts +54 -0
- package/examples/integrator_approve_same_master.ts +42 -0
- package/examples/integrator_create_modify_order.ts +119 -0
- package/examples/integrator_revoke.ts +43 -0
- package/examples/live_smoke.ts +72 -73
- package/examples/margin_eth_add_collateral_http.ts +1 -1
- package/examples/margin_eth_remove_collateral_http.ts +1 -1
- package/examples/market_data.ts +2 -3
- package/examples/modify_order.ts +13 -13
- package/examples/multi_client_advanced.ts +2 -2
- package/examples/onboarding.ts +9 -4
- package/examples/public_pool_deposit.ts +1 -1
- package/examples/public_pool_info.ts +8 -2
- package/examples/public_pool_operations.ts +4 -4
- package/examples/public_pool_withdraw.ts +1 -1
- package/examples/quickstart.ts +95 -0
- package/examples/referral_create.ts +60 -0
- package/examples/revoke_api_key.ts +2 -2
- package/examples/rfq_create_and_list.ts +63 -0
- package/examples/self_trade_create_modify_order.ts +93 -0
- package/examples/self_trade_grouped_orders.ts +49 -0
- package/examples/spot/README.md +4 -9
- package/examples/spot/cancel_spot_order.ts +3 -3
- package/examples/spot/create_market_spot_orders.ts +3 -3
- package/examples/spot/create_spot_limit_order.ts +6 -6
- package/examples/spot/create_spot_limit_order_with_sltp.ts +6 -7
- package/examples/spot/create_spot_twap_order.ts +1 -1
- package/examples/spot/modify_spot_order.ts +3 -3
- package/examples/spot_get_account_assets_http.ts +5 -5
- package/examples/stake_and_unstake.ts +48 -0
- package/examples/system_setup.ts +28 -6
- package/examples/tokenlist.ts +19 -0
- package/examples/transfer_same_master_account.ts +62 -0
- package/examples/transfer_spot_perp.ts +21 -65
- package/examples/update_margin_leverage.ts +3 -3
- package/examples/websocket_subscribe.ts +55 -0
- package/examples/withdraw_fast.ts +4 -4
- package/package.json +4 -3
- package/wasm/lighter-signer.wasm +0 -0
- package/wasm/wasm_exec.js +575 -575
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
|
|
49
|
+
- **Trade perpetual futures and spot markets** on Lighter Protocol
|
|
28
50
|
- **Create orders** (Market, Limit, TWAP) with automatic SL/TP
|
|
29
|
-
- **
|
|
30
|
-
- **
|
|
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
|
-
##
|
|
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
|
|
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
|
-
#
|
|
591
|
-
|
|
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/
|
|
601
|
-
2. **Next**: `examples/create_limit_order.ts` -
|
|
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` -
|
|
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
|
-
|
|
635
|
+
## β
Live-Tested Against Mainnet
|
|
608
636
|
|
|
609
|
-
|
|
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
|
-
###
|
|
706
|
+
### Unsupported Functions
|
|
711
707
|
|
|
712
|
-
These
|
|
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
|
|