lighter-sdk-client 0.2.22
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 +816 -0
- package/dist/api/exchange/change-account-tier.cjs +6 -0
- package/dist/api/exchange/change-account-tier.d.cts +14 -0
- package/dist/api/exchange/change-account-tier.d.ts +14 -0
- package/dist/api/exchange/change-account-tier.js +6 -0
- package/dist/api/exchange/fastwithdraw.cjs +6 -0
- package/dist/api/exchange/fastwithdraw.d.cts +14 -0
- package/dist/api/exchange/fastwithdraw.d.ts +14 -0
- package/dist/api/exchange/fastwithdraw.js +6 -0
- package/dist/api/exchange/index.cjs +37 -0
- package/dist/api/exchange/index.d.cts +8 -0
- package/dist/api/exchange/index.d.ts +8 -0
- package/dist/api/exchange/index.js +37 -0
- package/dist/api/exchange/notification-ack.cjs +6 -0
- package/dist/api/exchange/notification-ack.d.cts +13 -0
- package/dist/api/exchange/notification-ack.d.ts +13 -0
- package/dist/api/exchange/notification-ack.js +6 -0
- package/dist/api/exchange/send-tx-batch.cjs +6 -0
- package/dist/api/exchange/send-tx-batch.d.cts +22 -0
- package/dist/api/exchange/send-tx-batch.d.ts +22 -0
- package/dist/api/exchange/send-tx-batch.js +6 -0
- package/dist/api/exchange/send-tx.cjs +12 -0
- package/dist/api/exchange/send-tx.d.cts +33 -0
- package/dist/api/exchange/send-tx.d.ts +33 -0
- package/dist/api/exchange/send-tx.js +12 -0
- package/dist/api/exchange/tokens-create.cjs +6 -0
- package/dist/api/exchange/tokens-create.d.cts +24 -0
- package/dist/api/exchange/tokens-create.d.ts +24 -0
- package/dist/api/exchange/tokens-create.js +6 -0
- package/dist/api/exchange/tokens-revoke.cjs +6 -0
- package/dist/api/exchange/tokens-revoke.d.cts +15 -0
- package/dist/api/exchange/tokens-revoke.d.ts +15 -0
- package/dist/api/exchange/tokens-revoke.js +6 -0
- package/dist/api/info/account-by-l1-address.cjs +6 -0
- package/dist/api/info/account-by-l1-address.d.cts +28 -0
- package/dist/api/info/account-by-l1-address.d.ts +28 -0
- package/dist/api/info/account-by-l1-address.js +6 -0
- package/dist/api/info/account.cjs +6 -0
- package/dist/api/info/account.d.cts +67 -0
- package/dist/api/info/account.d.ts +67 -0
- package/dist/api/info/account.js +6 -0
- package/dist/api/info/announcement.cjs +6 -0
- package/dist/api/info/announcement.d.cts +15 -0
- package/dist/api/info/announcement.d.ts +15 -0
- package/dist/api/info/announcement.js +6 -0
- package/dist/api/info/api-keys.cjs +6 -0
- package/dist/api/info/api-keys.d.cts +19 -0
- package/dist/api/info/api-keys.d.ts +19 -0
- package/dist/api/info/api-keys.js +6 -0
- package/dist/api/info/asset-details.cjs +6 -0
- package/dist/api/info/asset-details.d.cts +26 -0
- package/dist/api/info/asset-details.d.ts +26 -0
- package/dist/api/info/asset-details.js +6 -0
- package/dist/api/info/candles.cjs +6 -0
- package/dist/api/info/candles.d.cts +23 -0
- package/dist/api/info/candles.d.ts +23 -0
- package/dist/api/info/candles.js +6 -0
- package/dist/api/info/exchange-stats.cjs +6 -0
- package/dist/api/info/exchange-stats.d.cts +11 -0
- package/dist/api/info/exchange-stats.d.ts +11 -0
- package/dist/api/info/exchange-stats.js +6 -0
- package/dist/api/info/fastbridge-info.cjs +6 -0
- package/dist/api/info/fastbridge-info.d.cts +10 -0
- package/dist/api/info/fastbridge-info.d.ts +10 -0
- package/dist/api/info/fastbridge-info.js +6 -0
- package/dist/api/info/funding-rates.cjs +6 -0
- package/dist/api/info/funding-rates.d.cts +16 -0
- package/dist/api/info/funding-rates.d.ts +16 -0
- package/dist/api/info/funding-rates.js +6 -0
- package/dist/api/info/fundings.cjs +6 -0
- package/dist/api/info/fundings.d.cts +21 -0
- package/dist/api/info/fundings.d.ts +21 -0
- package/dist/api/info/fundings.js +6 -0
- package/dist/api/info/index.cjs +85 -0
- package/dist/api/info/index.d.cts +22 -0
- package/dist/api/info/index.d.ts +22 -0
- package/dist/api/info/index.js +85 -0
- package/dist/api/info/next-nonce.cjs +6 -0
- package/dist/api/info/next-nonce.d.cts +14 -0
- package/dist/api/info/next-nonce.d.ts +14 -0
- package/dist/api/info/next-nonce.js +6 -0
- package/dist/api/info/order-book-details.cjs +8 -0
- package/dist/api/info/order-book-details.d.cts +95 -0
- package/dist/api/info/order-book-details.d.ts +95 -0
- package/dist/api/info/order-book-details.js +8 -0
- package/dist/api/info/order-books.cjs +6 -0
- package/dist/api/info/order-books.d.cts +16 -0
- package/dist/api/info/order-books.d.ts +16 -0
- package/dist/api/info/order-books.js +6 -0
- package/dist/api/info/recent-trades.cjs +6 -0
- package/dist/api/info/recent-trades.d.cts +11 -0
- package/dist/api/info/recent-trades.d.ts +11 -0
- package/dist/api/info/recent-trades.js +6 -0
- package/dist/api/info/root-info.cjs +6 -0
- package/dist/api/info/root-info.d.cts +8 -0
- package/dist/api/info/root-info.d.ts +8 -0
- package/dist/api/info/root-info.js +6 -0
- package/dist/api/info/root-status.cjs +6 -0
- package/dist/api/info/root-status.d.cts +10 -0
- package/dist/api/info/root-status.d.ts +10 -0
- package/dist/api/info/root-status.js +6 -0
- package/dist/api/info/tx-from-l1-hash.cjs +6 -0
- package/dist/api/info/tx-from-l1-hash.d.cts +9 -0
- package/dist/api/info/tx-from-l1-hash.d.ts +9 -0
- package/dist/api/info/tx-from-l1-hash.js +6 -0
- package/dist/api/info/tx.cjs +6 -0
- package/dist/api/info/tx.d.cts +33 -0
- package/dist/api/info/tx.d.ts +33 -0
- package/dist/api/info/tx.js +6 -0
- package/dist/api/info/txs.cjs +6 -0
- package/dist/api/info/txs.d.cts +11 -0
- package/dist/api/info/txs.d.ts +11 -0
- package/dist/api/info/txs.js +6 -0
- package/dist/api/info/withdrawal-delay.cjs +6 -0
- package/dist/api/info/withdrawal-delay.d.cts +8 -0
- package/dist/api/info/withdrawal-delay.d.ts +8 -0
- package/dist/api/info/withdrawal-delay.js +6 -0
- package/dist/api/info-private/account-active-orders.cjs +6 -0
- package/dist/api/info-private/account-active-orders.d.cts +11 -0
- package/dist/api/info-private/account-active-orders.d.ts +11 -0
- package/dist/api/info-private/account-active-orders.js +6 -0
- package/dist/api/info-private/account-inactive-orders.cjs +6 -0
- package/dist/api/info-private/account-inactive-orders.d.cts +52 -0
- package/dist/api/info-private/account-inactive-orders.d.ts +52 -0
- package/dist/api/info-private/account-inactive-orders.js +6 -0
- package/dist/api/info-private/account-limits.cjs +6 -0
- package/dist/api/info-private/account-limits.d.cts +16 -0
- package/dist/api/info-private/account-limits.d.ts +16 -0
- package/dist/api/info-private/account-limits.js +6 -0
- package/dist/api/info-private/account-metadata.cjs +6 -0
- package/dist/api/info-private/account-metadata.d.cts +22 -0
- package/dist/api/info-private/account-metadata.d.ts +22 -0
- package/dist/api/info-private/account-metadata.js +6 -0
- package/dist/api/info-private/deposit-history.cjs +6 -0
- package/dist/api/info-private/deposit-history.d.cts +27 -0
- package/dist/api/info-private/deposit-history.d.ts +27 -0
- package/dist/api/info-private/deposit-history.js +6 -0
- package/dist/api/info-private/export.cjs +6 -0
- package/dist/api/info-private/export.d.cts +16 -0
- package/dist/api/info-private/export.d.ts +16 -0
- package/dist/api/info-private/export.js +6 -0
- package/dist/api/info-private/fastwithdraw-info.cjs +6 -0
- package/dist/api/info-private/fastwithdraw-info.d.cts +16 -0
- package/dist/api/info-private/fastwithdraw-info.d.ts +16 -0
- package/dist/api/info-private/fastwithdraw-info.js +6 -0
- package/dist/api/info-private/index.cjs +75 -0
- package/dist/api/info-private/index.d.cts +19 -0
- package/dist/api/info-private/index.d.ts +19 -0
- package/dist/api/info-private/index.js +75 -0
- package/dist/api/info-private/l1-metadata.cjs +6 -0
- package/dist/api/info-private/l1-metadata.d.cts +16 -0
- package/dist/api/info-private/l1-metadata.d.ts +16 -0
- package/dist/api/info-private/l1-metadata.js +6 -0
- package/dist/api/info-private/liquidations.cjs +6 -0
- package/dist/api/info-private/liquidations.d.cts +66 -0
- package/dist/api/info-private/liquidations.d.ts +66 -0
- package/dist/api/info-private/liquidations.js +6 -0
- package/dist/api/info-private/pnl.cjs +6 -0
- package/dist/api/info-private/pnl.d.cts +24 -0
- package/dist/api/info-private/pnl.d.ts +24 -0
- package/dist/api/info-private/pnl.js +6 -0
- package/dist/api/info-private/position-funding.cjs +6 -0
- package/dist/api/info-private/position-funding.d.cts +28 -0
- package/dist/api/info-private/position-funding.d.ts +28 -0
- package/dist/api/info-private/position-funding.js +6 -0
- package/dist/api/info-private/public-pools-metadata.cjs +6 -0
- package/dist/api/info-private/public-pools-metadata.d.cts +24 -0
- package/dist/api/info-private/public-pools-metadata.d.ts +24 -0
- package/dist/api/info-private/public-pools-metadata.js +6 -0
- package/dist/api/info-private/referral-points.cjs +6 -0
- package/dist/api/info-private/referral-points.d.cts +24 -0
- package/dist/api/info-private/referral-points.d.ts +24 -0
- package/dist/api/info-private/referral-points.js +6 -0
- package/dist/api/info-private/tokens.cjs +6 -0
- package/dist/api/info-private/tokens.d.cts +24 -0
- package/dist/api/info-private/tokens.d.ts +24 -0
- package/dist/api/info-private/tokens.js +6 -0
- package/dist/api/info-private/trades.cjs +6 -0
- package/dist/api/info-private/trades.d.cts +49 -0
- package/dist/api/info-private/trades.d.ts +49 -0
- package/dist/api/info-private/trades.js +6 -0
- package/dist/api/info-private/transfer-fee-info.cjs +6 -0
- package/dist/api/info-private/transfer-fee-info.d.cts +15 -0
- package/dist/api/info-private/transfer-fee-info.d.ts +15 -0
- package/dist/api/info-private/transfer-fee-info.js +6 -0
- package/dist/api/info-private/transfer-history.cjs +6 -0
- package/dist/api/info-private/transfer-history.d.cts +27 -0
- package/dist/api/info-private/transfer-history.d.ts +27 -0
- package/dist/api/info-private/transfer-history.js +6 -0
- package/dist/api/info-private/withdraw-history.cjs +6 -0
- package/dist/api/info-private/withdraw-history.d.cts +27 -0
- package/dist/api/info-private/withdraw-history.d.ts +27 -0
- package/dist/api/info-private/withdraw-history.js +6 -0
- package/dist/chunk-24BJYHI5.cjs +166 -0
- package/dist/chunk-2R5COGAH.cjs +10 -0
- package/dist/chunk-3OSXAPI3.js +8 -0
- package/dist/chunk-3R4OL3TU.cjs +17 -0
- package/dist/chunk-3SKO62BC.js +0 -0
- package/dist/chunk-3Y76Q54G.js +18 -0
- package/dist/chunk-3ZIFHX7Q.cjs +1 -0
- package/dist/chunk-467IJZRE.js +14 -0
- package/dist/chunk-472ULOSN.js +10 -0
- package/dist/chunk-4LNJ2577.js +17 -0
- package/dist/chunk-4MZ3XQUJ.cjs +13 -0
- package/dist/chunk-4TIJW7PH.cjs +14 -0
- package/dist/chunk-4UDAN2FX.js +225 -0
- package/dist/chunk-4VAZ7ZA2.js +10 -0
- package/dist/chunk-5JDRAN7L.cjs +22 -0
- package/dist/chunk-5P5CPB5A.js +18 -0
- package/dist/chunk-5U6X6DI7.cjs +13 -0
- package/dist/chunk-5WEMEUUI.js +22 -0
- package/dist/chunk-6CD3YMMG.cjs +1 -0
- package/dist/chunk-6GCE6YQR.cjs +8 -0
- package/dist/chunk-6LUEPRL7.cjs +16 -0
- package/dist/chunk-6M6GRSDD.cjs +370 -0
- package/dist/chunk-6NEX2QS6.js +370 -0
- package/dist/chunk-76SPKVHT.js +48 -0
- package/dist/chunk-77QSYYAW.js +13 -0
- package/dist/chunk-7U2USLAM.cjs +8 -0
- package/dist/chunk-A2APDMN3.js +13 -0
- package/dist/chunk-AHCELOTZ.js +325 -0
- package/dist/chunk-AMNDQGYL.js +18 -0
- package/dist/chunk-BA2QFD27.cjs +19 -0
- package/dist/chunk-BES73YEF.js +8 -0
- package/dist/chunk-BKIL4UXV.cjs +22 -0
- package/dist/chunk-BKJGDTS3.js +8 -0
- package/dist/chunk-BVC2AA7Y.cjs +8 -0
- package/dist/chunk-BXMXWCMD.js +13 -0
- package/dist/chunk-C7OTZCGC.js +0 -0
- package/dist/chunk-DCKMNDS3.js +0 -0
- package/dist/chunk-DOZF64YC.cjs +17 -0
- package/dist/chunk-DW6W5SX2.cjs +18 -0
- package/dist/chunk-E3GJJZER.cjs +8 -0
- package/dist/chunk-EBSW5ZYW.js +19 -0
- package/dist/chunk-F24JA2OV.cjs +22 -0
- package/dist/chunk-FJJWUBKM.js +17 -0
- package/dist/chunk-FM4WWIRI.cjs +17 -0
- package/dist/chunk-FODEDUT4.js +8 -0
- package/dist/chunk-GEWTGUEG.cjs +1 -0
- package/dist/chunk-GI4WUHSL.cjs +1 -0
- package/dist/chunk-GYABNQWH.js +8 -0
- package/dist/chunk-GYQ6HJQY.cjs +21 -0
- package/dist/chunk-INCL3WRA.cjs +13 -0
- package/dist/chunk-IQQRFW4A.cjs +8 -0
- package/dist/chunk-IT6LK2G5.cjs +19 -0
- package/dist/chunk-IXF4QUC6.js +8 -0
- package/dist/chunk-J3UZK77O.cjs +18 -0
- package/dist/chunk-J7GXRK7R.cjs +19 -0
- package/dist/chunk-JLCOD3WH.cjs +325 -0
- package/dist/chunk-JNTYHWDJ.js +22 -0
- package/dist/chunk-JTE4UBAX.js +8 -0
- package/dist/chunk-JTP6DTDN.js +0 -0
- package/dist/chunk-K7ZQARON.js +8 -0
- package/dist/chunk-L5SDFTHR.cjs +242 -0
- package/dist/chunk-LBVNEQ5R.cjs +21 -0
- package/dist/chunk-LXNCAKJZ.js +0 -0
- package/dist/chunk-LYNZNSLV.js +18 -0
- package/dist/chunk-MAPH47LH.cjs +1 -0
- package/dist/chunk-MO4PMYTS.js +0 -0
- package/dist/chunk-MOOGM3DW.cjs +1 -0
- package/dist/chunk-MZCKU6FF.js +8 -0
- package/dist/chunk-NIT6TCVS.cjs +8 -0
- package/dist/chunk-NOFXPTLU.js +8 -0
- package/dist/chunk-NOREYPFC.js +612 -0
- package/dist/chunk-NRZGE42C.js +23 -0
- package/dist/chunk-NSFKW27X.js +0 -0
- package/dist/chunk-O3PA6HV2.js +18 -0
- package/dist/chunk-OBR3B6S7.cjs +367 -0
- package/dist/chunk-ON64OVOQ.cjs +20 -0
- package/dist/chunk-OPSCTD6W.js +17 -0
- package/dist/chunk-P32EPCEM.js +19 -0
- package/dist/chunk-PEALQBVN.js +19 -0
- package/dist/chunk-PP4Q2W66.cjs +10 -0
- package/dist/chunk-PPU2VWXX.js +12 -0
- package/dist/chunk-Q2MT7FZ7.js +242 -0
- package/dist/chunk-QCE5PEXE.cjs +8 -0
- package/dist/chunk-QILV2ZMV.js +166 -0
- package/dist/chunk-QMXZQNBK.cjs +8 -0
- package/dist/chunk-QNM3HYIV.cjs +8 -0
- package/dist/chunk-QXGO7TJ2.js +17 -0
- package/dist/chunk-R37XMGAI.cjs +612 -0
- package/dist/chunk-RGVFMOQI.js +20 -0
- package/dist/chunk-RYDJEI67.cjs +48 -0
- package/dist/chunk-S4OE3IME.js +13 -0
- package/dist/chunk-SA6CXVP6.js +22 -0
- package/dist/chunk-TELGVFFP.js +13 -0
- package/dist/chunk-TM3CNEVD.js +367 -0
- package/dist/chunk-TPGO4YD3.js +21 -0
- package/dist/chunk-TSHQJVUP.js +0 -0
- package/dist/chunk-TWGXKYO2.cjs +23 -0
- package/dist/chunk-U25GSCR7.cjs +17 -0
- package/dist/chunk-U2SM46CP.cjs +17 -0
- package/dist/chunk-UORSMHI2.js +21 -0
- package/dist/chunk-VDBWTSBC.cjs +1 -0
- package/dist/chunk-VNQKWIQG.cjs +13 -0
- package/dist/chunk-VW77SNCY.js +24 -0
- package/dist/chunk-VWX5CLM4.cjs +225 -0
- package/dist/chunk-W2BVNVOC.cjs +1 -0
- package/dist/chunk-W5VY4TWP.js +16 -0
- package/dist/chunk-WK6OQRMG.cjs +8 -0
- package/dist/chunk-WWLOQFSW.cjs +12 -0
- package/dist/chunk-X7E6XJVQ.cjs +18 -0
- package/dist/chunk-XOG6T533.cjs +18 -0
- package/dist/chunk-XQGOXCT4.js +22 -0
- package/dist/chunk-YVJVFJ24.cjs +19 -0
- package/dist/chunk-YWN57BJF.js +8 -0
- package/dist/chunk-Z5XTWR2A.cjs +8 -0
- package/dist/chunk-ZDNQFOED.js +17 -0
- package/dist/chunk-ZGWYI7Q2.cjs +24 -0
- package/dist/chunk-ZIMFMYT2.cjs +22 -0
- package/dist/chunk-ZJVQD6JD.cjs +18 -0
- package/dist/chunk-ZKFXRN6W.cjs +13 -0
- package/dist/chunk-ZWYNOAL3.js +19 -0
- package/dist/client/exchange-client.cjs +14 -0
- package/dist/client/exchange-client.d.cts +409 -0
- package/dist/client/exchange-client.d.ts +409 -0
- package/dist/client/exchange-client.js +14 -0
- package/dist/client/index.cjs +71 -0
- package/dist/client/index.d.cts +53 -0
- package/dist/client/index.d.ts +53 -0
- package/dist/client/index.js +71 -0
- package/dist/client/info-client.cjs +27 -0
- package/dist/client/info-client.d.cts +255 -0
- package/dist/client/info-client.d.ts +255 -0
- package/dist/client/info-client.js +27 -0
- package/dist/client/info-private-client.cjs +25 -0
- package/dist/client/info-private-client.d.cts +293 -0
- package/dist/client/info-private-client.d.ts +293 -0
- package/dist/client/info-private-client.js +25 -0
- package/dist/client/l1-bridge-client.cjs +6 -0
- package/dist/client/l1-bridge-client.d.cts +45 -0
- package/dist/client/l1-bridge-client.d.ts +45 -0
- package/dist/client/l1-bridge-client.js +6 -0
- package/dist/client/ws-client.cjs +6 -0
- package/dist/client/ws-client.d.cts +64 -0
- package/dist/client/ws-client.d.ts +64 -0
- package/dist/client/ws-client.js +6 -0
- package/dist/index.cjs +225 -0
- package/dist/index.d.cts +54 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.js +225 -0
- package/dist/signing/index.cjs +7 -0
- package/dist/signing/index.d.cts +1 -0
- package/dist/signing/index.d.ts +1 -0
- package/dist/signing/index.js +7 -0
- package/dist/signing/wasm-signer.cjs +6 -0
- package/dist/signing/wasm-signer.d.cts +101 -0
- package/dist/signing/wasm-signer.d.ts +101 -0
- package/dist/signing/wasm-signer.js +6 -0
- package/dist/types/bridge.cjs +1 -0
- package/dist/types/bridge.d.cts +24 -0
- package/dist/types/bridge.d.ts +24 -0
- package/dist/types/bridge.js +1 -0
- package/dist/types/constant.cjs +148 -0
- package/dist/types/constant.d.cts +142 -0
- package/dist/types/constant.d.ts +142 -0
- package/dist/types/constant.js +148 -0
- package/dist/types/index.cjs +151 -0
- package/dist/types/index.d.cts +3 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +151 -0
- package/dist/types/ws.cjs +1 -0
- package/dist/types/ws.d.cts +362 -0
- package/dist/types/ws.d.ts +362 -0
- package/dist/types/ws.js +1 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,816 @@
|
|
|
1
|
+
# Lighter SDK Client
|
|
2
|
+
|
|
3
|
+
Unofficial TypeScript/JavaScript SDK client for the Lighter protocol - a high-performance decentralized exchange built on zkSync.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/lighter-sdk-client)
|
|
6
|
+
[](https://opensource.org/licenses/ISC)
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- 🔄 **Full API Coverage** - Complete access to public, private, and exchange endpoints
|
|
11
|
+
- 🔐 **WASM Signing** - Built-in transaction signing with WebAssembly support
|
|
12
|
+
- 🌉 **L1 Bridge Integration** - Direct integration with L1 bridging functionality
|
|
13
|
+
- 📡 **WebSocket Support** - Real-time market data and account updates
|
|
14
|
+
- 🎯 **TypeScript First** - Full type safety and IntelliSense support
|
|
15
|
+
- 📋 **Protocol Constants** - Comprehensive enums and constants for type-safe interactions
|
|
16
|
+
- ⚡ **High Performance** - Optimized for speed with minimal dependencies
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pnpm add lighter-sdk-client
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
### Public API (InfoClient)
|
|
27
|
+
|
|
28
|
+
Access public market data without authentication:
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import { InfoClient } from 'lighter-sdk-client';
|
|
32
|
+
|
|
33
|
+
const client = new InfoClient({
|
|
34
|
+
baseURL: 'https://mainnet.zklighter.elliot.ai'
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Get account information
|
|
38
|
+
const account = await client.getAccountInfo({
|
|
39
|
+
by: 'index',
|
|
40
|
+
value: '0'
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Get order books
|
|
44
|
+
const orderBooks = await client.getOrderBooks();
|
|
45
|
+
|
|
46
|
+
// Get asset details
|
|
47
|
+
const allAssets = await client.getAssetDetails();
|
|
48
|
+
const specificAsset = await client.getAssetDetails({ asset_index: 0 });
|
|
49
|
+
|
|
50
|
+
// Get recent trades
|
|
51
|
+
const trades = await client.getRecentTrades({
|
|
52
|
+
market_id: 1,
|
|
53
|
+
limit: 50
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Get candlestick data
|
|
57
|
+
const candles = await client.getCandlesticks({
|
|
58
|
+
market_id: 1,
|
|
59
|
+
resolution: '1h',
|
|
60
|
+
start_timestamp: Math.floor(Date.now() / 1000) - 86400,
|
|
61
|
+
end_timestamp: Math.floor(Date.now() / 1000)
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Get withdrawal delay
|
|
65
|
+
const withdrawalDelay = await client.getWithdrawalDelay();
|
|
66
|
+
|
|
67
|
+
// Get root status
|
|
68
|
+
const rootStatus = await client.getRootStatus();
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Exchange Operations (ExchangeClient)
|
|
72
|
+
|
|
73
|
+
Send transactions and manage orders:
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
import { ExchangeClient } from 'lighter-sdk-client';
|
|
77
|
+
|
|
78
|
+
const client = new ExchangeClient({
|
|
79
|
+
baseURL: 'https://mainnet.zklighter.elliot.ai'
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// Send a transaction
|
|
83
|
+
const result = await client.sendTransaction({
|
|
84
|
+
account_index: 0,
|
|
85
|
+
api_key_index: 0,
|
|
86
|
+
transaction: '0x...'
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// Send a batch of transactions
|
|
90
|
+
const batchResult = await client.sendTransactionBatch({
|
|
91
|
+
account_index: 0,
|
|
92
|
+
api_key_index: 0,
|
|
93
|
+
transactions: ['0x...', '0x...']
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// Change account tier
|
|
97
|
+
const tierResult = await client.changeAccountTier({
|
|
98
|
+
account_index: 0,
|
|
99
|
+
new_tier: 'premium'
|
|
100
|
+
}, 'auth-token');
|
|
101
|
+
|
|
102
|
+
// Fast withdraw
|
|
103
|
+
const withdrawResult = await client.fastWithdraw({
|
|
104
|
+
tx_info: '0x...',
|
|
105
|
+
to_address: '0x...'
|
|
106
|
+
}, 'auth-token');
|
|
107
|
+
|
|
108
|
+
// Create API token
|
|
109
|
+
const newToken = await client.createToken({
|
|
110
|
+
name: 'My API Token',
|
|
111
|
+
account_index: 0,
|
|
112
|
+
expiry: Math.floor(Date.now() / 1000) + 86400 * 30, // 30 days
|
|
113
|
+
sub_account_access: true,
|
|
114
|
+
scopes: 'read.*'
|
|
115
|
+
}, 'auth-token');
|
|
116
|
+
|
|
117
|
+
// Revoke API token
|
|
118
|
+
const revokeResult = await client.revokeToken({
|
|
119
|
+
token_id: 123,
|
|
120
|
+
account_index: 0
|
|
121
|
+
}, 'auth-token');
|
|
122
|
+
|
|
123
|
+
// Generate L1 sign message for changing public key
|
|
124
|
+
const signMessage = await client.generateChangePubKeyL1SignMessage(
|
|
125
|
+
'0xabcdef...', // pubKeyHex
|
|
126
|
+
1, // nonce
|
|
127
|
+
0, // accountIndex
|
|
128
|
+
0 // newApiKeyIndex
|
|
129
|
+
);
|
|
130
|
+
console.log('Sign this message:', signMessage);
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Private API (InfoPrivateClient)
|
|
134
|
+
|
|
135
|
+
Access authenticated account data with automatic WASM signing:
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
import { InfoPrivateClient, WasmSigner } from 'lighter-sdk-client';
|
|
139
|
+
|
|
140
|
+
// Initialize WASM signer
|
|
141
|
+
const wasmSigner = new WasmSigner({
|
|
142
|
+
wasmPath: './public/wasm/lighter-signer.wasm',
|
|
143
|
+
wasmExecPath: './public/wasm/lighter-wasm-exec.js'
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// Create private client - authentication is handled automatically
|
|
147
|
+
const client = new InfoPrivateClient({
|
|
148
|
+
baseURL: 'https://mainnet.zklighter.elliot.ai',
|
|
149
|
+
wasmSigning: wasmSigner
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// Get active orders
|
|
153
|
+
const activeOrders = await client.getAccountActiveOrders({
|
|
154
|
+
account_index: 0,
|
|
155
|
+
market_id: 1
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// Get inactive orders with pagination
|
|
159
|
+
const inactiveOrders = await client.getAccountInactiveOrders({
|
|
160
|
+
account_index: 0,
|
|
161
|
+
limit: 50,
|
|
162
|
+
market_id: 1
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// Get account limits and tier info
|
|
166
|
+
const limits = await client.getAccountLimits({
|
|
167
|
+
account_index: 0
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// Get L1 metadata
|
|
171
|
+
const l1Metadata = await client.getL1Metadata({
|
|
172
|
+
l1_address: '0x...'
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
// Get API tokens for account
|
|
176
|
+
const tokens = await client.getTokens({
|
|
177
|
+
account_index: 0
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// Get deposit history
|
|
181
|
+
const deposits = await client.getDepositHistory({
|
|
182
|
+
account_index: 0,
|
|
183
|
+
l1_address: '0x...',
|
|
184
|
+
filter: 'pending'
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
// Get withdrawal history
|
|
188
|
+
const withdrawals = await client.getWithdrawHistory({
|
|
189
|
+
account_index: 0,
|
|
190
|
+
l1_address: '0x...',
|
|
191
|
+
filter: 'completed'
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
// Get fast withdraw information
|
|
195
|
+
const fastWithdrawInfo = await client.getFastWithdrawInfo({
|
|
196
|
+
account_index: 0
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// Get transfer fee information
|
|
200
|
+
const transferFeeInfo = await client.getTransferFeeInfo({
|
|
201
|
+
account_index: 0,
|
|
202
|
+
to_account_index: 1
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
// Get transfer history
|
|
206
|
+
const transfers = await client.getTransferHistory({
|
|
207
|
+
account_index: 0,
|
|
208
|
+
cursor: 'optional-cursor-for-pagination'
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
// Get liquidation history
|
|
212
|
+
const liquidations = await client.getLiquidations({
|
|
213
|
+
account_index: 0,
|
|
214
|
+
limit: 50,
|
|
215
|
+
market_id: 1
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
// Get profit and loss data
|
|
219
|
+
const pnl = await client.getPnL({
|
|
220
|
+
by: 'account_index',
|
|
221
|
+
value: '0',
|
|
222
|
+
resolution: '1d',
|
|
223
|
+
start_timestamp: Math.floor(Date.now() / 1000) - 86400 * 30,
|
|
224
|
+
end_timestamp: Math.floor(Date.now() / 1000),
|
|
225
|
+
count_back: 30
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
// Get position funding history
|
|
229
|
+
const funding = await client.getPositionFunding({
|
|
230
|
+
account_index: 0,
|
|
231
|
+
limit: 50,
|
|
232
|
+
market_id: 1,
|
|
233
|
+
side: 'long'
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
// Get public pools metadata
|
|
237
|
+
const pools = await client.getPublicPools({
|
|
238
|
+
filter: 'all',
|
|
239
|
+
limit: 10,
|
|
240
|
+
index: 0
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
// Get referral points
|
|
244
|
+
const referralPoints = await client.getReferralPoints({
|
|
245
|
+
account_index: 0
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
// Get trades for account or market
|
|
249
|
+
const trades = await client.getTrades({
|
|
250
|
+
sort_by: 'timestamp',
|
|
251
|
+
limit: 50,
|
|
252
|
+
account_index: 0,
|
|
253
|
+
market_id: 1,
|
|
254
|
+
sort_dir: 'desc'
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
// Export data
|
|
258
|
+
const exportData = await client.getExport({
|
|
259
|
+
type: 'trade',
|
|
260
|
+
account_index: 0,
|
|
261
|
+
market_id: 1
|
|
262
|
+
});
|
|
263
|
+
console.log('Download URL:', exportData.data_url);
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### L1 Bridge Operations
|
|
267
|
+
|
|
268
|
+
Deposit and withdraw assets:
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
import { L1BridgeClient } from 'lighter-sdk-client';
|
|
272
|
+
import { arbitrum } from 'viem/chains';
|
|
273
|
+
|
|
274
|
+
const bridgeClient = new L1BridgeClient({
|
|
275
|
+
chain: arbitrum,
|
|
276
|
+
l1RpcUrl: 'https://arb1.arbitrum.io/rpc',
|
|
277
|
+
privateKey: '0x...',
|
|
278
|
+
bridgeContractAddress: '0x...',
|
|
279
|
+
usdcAddress: '0x...'
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
// Deposit USDC from L1 to L2
|
|
283
|
+
const result = await bridgeClient.depositUSDC({
|
|
284
|
+
amount: '100.00',
|
|
285
|
+
lighterAccountIndex: 0
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
console.log('Transaction hash:', result.transactionHash);
|
|
289
|
+
console.log('Amount deposited:', result.amountDeposited);
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### WebSocket Client
|
|
293
|
+
|
|
294
|
+
Subscribe to real-time market data and account updates with automatic reconnection:
|
|
295
|
+
|
|
296
|
+
```typescript
|
|
297
|
+
import { WsClient } from 'lighter-sdk-client';
|
|
298
|
+
|
|
299
|
+
const wsClient = new WsClient({
|
|
300
|
+
url: 'wss://mainnet.zklighter.elliot.ai/stream',
|
|
301
|
+
reconnectInterval: 5000, // Initial reconnect delay (ms)
|
|
302
|
+
maxReconnectAttempts: Infinity, // Unlimited reconnection attempts
|
|
303
|
+
onOpen: () => console.log('WebSocket connected'),
|
|
304
|
+
onClose: () => console.log('WebSocket disconnected'),
|
|
305
|
+
onError: (error) => console.error('WebSocket error:', error),
|
|
306
|
+
onMessage: (data) => console.log('Raw message:', data)
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
// Connect to WebSocket server
|
|
310
|
+
await wsClient.connect();
|
|
311
|
+
|
|
312
|
+
// Subscribe to order book updates
|
|
313
|
+
wsClient.subscribeOrderBook(1, (update) => {
|
|
314
|
+
console.log('Order book:', update.order_book);
|
|
315
|
+
console.log('Bids:', update.order_book.bids);
|
|
316
|
+
console.log('Asks:', update.order_book.asks);
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
// Subscribe to market statistics
|
|
320
|
+
wsClient.subscribeMarketStats('all', (update) => {
|
|
321
|
+
console.log('Market stats:', update.market_stats);
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
// Subscribe to trade updates for a specific market
|
|
325
|
+
wsClient.subscribeTrades(1, (update) => {
|
|
326
|
+
update.trades.forEach(trade => {
|
|
327
|
+
console.log('Trade:', {
|
|
328
|
+
price: trade.price,
|
|
329
|
+
size: trade.size,
|
|
330
|
+
side: trade.is_maker_ask ? 'sell' : 'buy'
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
// Subscribe to block height updates
|
|
336
|
+
wsClient.subscribeHeight((update) => {
|
|
337
|
+
console.log('Current block height:', update.height);
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
// Subscribe to account updates (requires authentication)
|
|
341
|
+
const authToken = 'your-auth-token';
|
|
342
|
+
|
|
343
|
+
// Subscribe to all account data
|
|
344
|
+
wsClient.subscribeAccountAll(0, (update) => {
|
|
345
|
+
console.log('Positions:', update.positions);
|
|
346
|
+
console.log('Orders:', update.trades);
|
|
347
|
+
console.log('Pool shares:', update.shares);
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
// Subscribe to specific market for an account
|
|
351
|
+
wsClient.subscribeAccountMarket(1, 0, authToken, (update) => {
|
|
352
|
+
console.log('Account orders:', update.orders);
|
|
353
|
+
console.log('Account position:', update.position);
|
|
354
|
+
console.log('Account trades:', update.trades);
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
// Subscribe to user statistics
|
|
358
|
+
wsClient.subscribeUserStats(0, (update) => {
|
|
359
|
+
console.log('Portfolio value:', update.stats.portfolio_value);
|
|
360
|
+
console.log('Available balance:', update.stats.available_balance);
|
|
361
|
+
console.log('Leverage:', update.stats.leverage);
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
// Subscribe to notifications
|
|
365
|
+
wsClient.subscribeNotifications(0, authToken, (update) => {
|
|
366
|
+
update.notifs.forEach(notif => {
|
|
367
|
+
console.log('Notification:', notif.kind, notif.content);
|
|
368
|
+
});
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
// Unsubscribe from specific channels
|
|
372
|
+
wsClient.unsubscribeOrderBook(1);
|
|
373
|
+
wsClient.unsubscribeMarketStats('all');
|
|
374
|
+
|
|
375
|
+
// Check connection status
|
|
376
|
+
const isConnected = wsClient.isConnectedToWebSocket();
|
|
377
|
+
console.log('Connected:', isConnected);
|
|
378
|
+
|
|
379
|
+
// Get all active subscriptions
|
|
380
|
+
const subscriptions = wsClient.getSubscriptions();
|
|
381
|
+
console.log('Active subscriptions:', subscriptions);
|
|
382
|
+
|
|
383
|
+
// Disconnect when done (stops automatic reconnection)
|
|
384
|
+
wsClient.disconnect();
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
**Features:**
|
|
388
|
+
- ✅ **Automatic Reconnection** - Uses `reconnecting-websocket` library for reliable connections
|
|
389
|
+
- ✅ **Exponential Backoff** - Gradually increases reconnection delay (up to 30 seconds)
|
|
390
|
+
- ✅ **Auto-Resubscription** - Automatically resubscribes to all channels after reconnection
|
|
391
|
+
- ✅ **Type-Safe** - Full TypeScript support with typed update handlers
|
|
392
|
+
- ✅ **Connection Management** - Built-in connection state tracking and lifecycle hooks
|
|
393
|
+
|
|
394
|
+
## API Reference
|
|
395
|
+
|
|
396
|
+
### InfoClient
|
|
397
|
+
|
|
398
|
+
Public API client for market data and account information. No authentication required.
|
|
399
|
+
|
|
400
|
+
#### Methods
|
|
401
|
+
|
|
402
|
+
**Account Methods**
|
|
403
|
+
- `getAccountInfo(params)` - Get account information by index or L2 address
|
|
404
|
+
- `getAccountByL1Address(params)` - Get account information associated with an L1 address
|
|
405
|
+
|
|
406
|
+
**API Keys & Announcements**
|
|
407
|
+
- `getApiKeys(params)` - Get API keys for an account
|
|
408
|
+
- `getAnnouncements()` - Get system announcements
|
|
409
|
+
|
|
410
|
+
**Market Data**
|
|
411
|
+
- `getAssetDetails(params?)` - Get asset details for a specific asset or all assets (symbol, decimals, limits, pricing)
|
|
412
|
+
- `getCandlesticks(params)` - Get candlestick data with specified resolution and time range
|
|
413
|
+
- `getFundings(params)` - Get funding history for a market
|
|
414
|
+
- `getExchangeStats()` - Get exchange-wide statistics including volume and fees
|
|
415
|
+
- `getFundingRates()` - Get current funding rates for all markets
|
|
416
|
+
|
|
417
|
+
**Order Books**
|
|
418
|
+
- `getOrderBooks()` - Get list of all order books with configurations
|
|
419
|
+
- `getOrderBookDetails(params)` - Get detailed information about a specific order book
|
|
420
|
+
- `getOrderBookOrders(params)` - Get bids and asks in an order book
|
|
421
|
+
|
|
422
|
+
**Trades**
|
|
423
|
+
- `getRecentTrades(params)` - Get recent trades for a market
|
|
424
|
+
- `getTrades(params, authorization?)` - Get trades with optional filtering and authentication
|
|
425
|
+
|
|
426
|
+
**Transactions**
|
|
427
|
+
- `getTransaction(params)` - Get a specific transaction by hash
|
|
428
|
+
- `getTransactions(params?)` - Get transactions with optional filtering
|
|
429
|
+
- `getTransactionFromL1TxHash(params)` - Get L2 transaction from L1 transaction hash
|
|
430
|
+
|
|
431
|
+
**Utilities**
|
|
432
|
+
- `getNextNonce(params)` - Get the next nonce for an account
|
|
433
|
+
- `getFastBridgeInfo()` - Get fast bridge configuration and status
|
|
434
|
+
- `getWithdrawalDelay()` - Get withdrawal delay in seconds
|
|
435
|
+
- `getRootStatus()` - Get root status information including network status and timestamp
|
|
436
|
+
|
|
437
|
+
### ExchangeClient
|
|
438
|
+
|
|
439
|
+
Client for sending transactions and managing exchange operations.
|
|
440
|
+
|
|
441
|
+
#### Methods
|
|
442
|
+
|
|
443
|
+
**Transaction Submission**
|
|
444
|
+
- `sendTransaction(params)` - Send a signed transaction to the exchange
|
|
445
|
+
- `sendTx(params)` - Send transaction with form data format
|
|
446
|
+
- `sendTxWithIndices(params)` - Send transaction with account and API key indices
|
|
447
|
+
- `sendTxJson(params)` - Send transaction with JSON payload format
|
|
448
|
+
- `sendTransactionBatch(params)` - Send multiple transactions in a single batch for better efficiency
|
|
449
|
+
|
|
450
|
+
**Account Management**
|
|
451
|
+
- `changeAccountTier(params, authorization?)` - Change account tier (requires authorization)
|
|
452
|
+
- `fastWithdraw(params, authorization?)` - Fast withdraw funds (requires authorization)
|
|
453
|
+
|
|
454
|
+
**API Tokens**
|
|
455
|
+
- `createToken(params, authorization?)` - Create API token with specified permissions and expiry
|
|
456
|
+
- `revokeToken(params, authorization?)` - Revoke an existing API token
|
|
457
|
+
- `generateChangePubKeyL1SignMessage(pubKeyHex, nonce, accountIndex, newApiKeyIndex)` - Generate L1 sign message for changing public key
|
|
458
|
+
|
|
459
|
+
**Notifications**
|
|
460
|
+
- `acknowledgeNotification(params)` - Acknowledge receipt of a notification
|
|
461
|
+
|
|
462
|
+
### InfoPrivateClient
|
|
463
|
+
|
|
464
|
+
Client for authenticated/private endpoints. Authentication is handled automatically via WasmSigner.
|
|
465
|
+
|
|
466
|
+
#### Methods
|
|
467
|
+
|
|
468
|
+
**Account Orders**
|
|
469
|
+
- `getAccountActiveOrders(params)` - Get active orders for an account in a specific market
|
|
470
|
+
- `getAccountInactiveOrders(params)` - Get inactive orders with pagination support
|
|
471
|
+
|
|
472
|
+
**Account Information**
|
|
473
|
+
- `getAccountLimits(params)` - Get account limits including max LLP percentage, user tier, and pool creation permissions
|
|
474
|
+
- `getAccountMetadata(params)` - Get account metadata by index or L1 address
|
|
475
|
+
- `getL1Metadata(params)` - Get L1 metadata for an address including referral information
|
|
476
|
+
- `getTokens(params)` - Get API tokens for an account with details including name, expiry, scopes, and status
|
|
477
|
+
|
|
478
|
+
**Transaction History**
|
|
479
|
+
- `getDepositHistory(params)` - Get deposit history with status and timestamps
|
|
480
|
+
- `getWithdrawHistory(params)` - Get withdrawal history with status and timestamps
|
|
481
|
+
- `getFastWithdrawInfo(params)` - Get fast withdraw limits and account information
|
|
482
|
+
- `getTransferFeeInfo(params)` - Get transfer fee information between accounts
|
|
483
|
+
- `getTransferHistory(params)` - Get transfer history with pagination support
|
|
484
|
+
- `getLiquidations(params)` - Get liquidation history with pagination support
|
|
485
|
+
|
|
486
|
+
**Analytics**
|
|
487
|
+
- `getPnL(params)` - Get profit and loss data with customizable resolution and time range
|
|
488
|
+
- `getPositionFunding(params)` - Get position funding history with pagination support
|
|
489
|
+
|
|
490
|
+
**Liquidity Pools**
|
|
491
|
+
- `getPublicPools(params?)` - Get public pool information including TVL, APY, and share details
|
|
492
|
+
|
|
493
|
+
**Referral System**
|
|
494
|
+
- `getReferralPoints(params)` - Get referral points data including user points and referral list
|
|
495
|
+
|
|
496
|
+
**Trading**
|
|
497
|
+
- `getTrades(params)` - Get trades for an account or market with sorting and filtering options
|
|
498
|
+
|
|
499
|
+
**Data Export**
|
|
500
|
+
- `getExport(params)` - Export data (funding or trade data) for downloading
|
|
501
|
+
|
|
502
|
+
### L1BridgeClient
|
|
503
|
+
|
|
504
|
+
Client for L1 bridge operations to move assets between Layer 1 and Layer 2.
|
|
505
|
+
|
|
506
|
+
#### Methods
|
|
507
|
+
|
|
508
|
+
**Bridge Operations**
|
|
509
|
+
- `depositUSDC(params)` - Deposit USDC from L1 to L2 Lighter account
|
|
510
|
+
|
|
511
|
+
**Balance & Allowance**
|
|
512
|
+
- `checkUSDCBalance()` - Check USDC balance on L1
|
|
513
|
+
- `checkAllowance()` - Check current USDC allowance for bridge contract
|
|
514
|
+
- `approveUSDC(amount)` - Approve USDC spending for bridge contract
|
|
515
|
+
|
|
516
|
+
### WsClient
|
|
517
|
+
|
|
518
|
+
WebSocket client for real-time market data and account updates with automatic reconnection and resubscription.
|
|
519
|
+
|
|
520
|
+
#### Configuration Options
|
|
521
|
+
|
|
522
|
+
```typescript
|
|
523
|
+
interface WebSocketConfig {
|
|
524
|
+
url?: string; // WebSocket server URL (default: wss://mainnet.zklighter.elliot.ai/stream)
|
|
525
|
+
reconnectInterval?: number; // Initial reconnect delay in ms (default: 5000)
|
|
526
|
+
maxReconnectAttempts?: number; // Max reconnection attempts (default: Infinity)
|
|
527
|
+
onMessage?: (data: any) => void; // Raw message handler
|
|
528
|
+
onError?: (error: Error) => void; // Error handler
|
|
529
|
+
onClose?: () => void; // Close event handler
|
|
530
|
+
onOpen?: () => void; // Open event handler
|
|
531
|
+
}
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
#### Methods
|
|
535
|
+
|
|
536
|
+
**Connection Management**
|
|
537
|
+
- `connect()` - Establish WebSocket connection with automatic reconnection support
|
|
538
|
+
- `disconnect()` - Close WebSocket connection and stop automatic reconnection
|
|
539
|
+
- `isConnectedToWebSocket()` - Check if currently connected to WebSocket server
|
|
540
|
+
- `getSubscriptions()` - Get list of all active subscriptions
|
|
541
|
+
|
|
542
|
+
**Market Data Subscriptions**
|
|
543
|
+
- `subscribeOrderBook(marketIndex, handler)` - Subscribe to order book updates (bids/asks)
|
|
544
|
+
- `unsubscribeOrderBook(marketIndex)` - Unsubscribe from order book updates
|
|
545
|
+
- `subscribeTrades(marketIndex, handler)` - Subscribe to trade updates for a market
|
|
546
|
+
- `unsubscribeTrades(marketIndex)` - Unsubscribe from trade updates
|
|
547
|
+
- `subscribeMarketStats(market, handler)` - Subscribe to market statistics (market can be number or 'all')
|
|
548
|
+
- `unsubscribeMarketStats(market)` - Unsubscribe from market statistics
|
|
549
|
+
- `subscribeSpotMarketStats(market, handler)` - Subscribe to spot market statistics
|
|
550
|
+
- `unsubscribeSpotMarketStats(market)` - Unsubscribe from spot market statistics
|
|
551
|
+
|
|
552
|
+
**Account Subscriptions** (requires authentication)
|
|
553
|
+
- `subscribeAccountAll(accountId, handler)` - Subscribe to all account data (positions, trades, shares)
|
|
554
|
+
- `unsubscribeAccountAll(accountId)` - Unsubscribe from all account data
|
|
555
|
+
- `subscribeAccountMarket(marketId, accountId, auth, handler)` - Subscribe to account updates for specific market
|
|
556
|
+
- `unsubscribeAccountMarket(marketId, accountId)` - Unsubscribe from account market updates
|
|
557
|
+
- `subscribeAccountOrders(marketIndex, accountId, auth, handler)` - Subscribe to order updates for specific market
|
|
558
|
+
- `unsubscribeAccountOrders(marketIndex, accountId)` - Unsubscribe from order updates
|
|
559
|
+
- `subscribeAccountAllOrders(accountId, auth, handler)` - Subscribe to all order updates across markets
|
|
560
|
+
- `unsubscribeAccountAllOrders(accountId)` - Unsubscribe from all order updates
|
|
561
|
+
- `subscribeAccountAllPositions(accountId, auth, handler)` - Subscribe to all position updates
|
|
562
|
+
- `unsubscribeAccountAllPositions(accountId)` - Unsubscribe from position updates
|
|
563
|
+
- `subscribeAccountAllTrades(accountId, auth, handler)` - Subscribe to all trade updates
|
|
564
|
+
- `unsubscribeAccountAllTrades(accountId)` - Unsubscribe from trade updates
|
|
565
|
+
- `subscribeUserStats(accountId, handler)` - Subscribe to user statistics (portfolio, balance, leverage)
|
|
566
|
+
- `unsubscribeUserStats(accountId)` - Unsubscribe from user statistics
|
|
567
|
+
|
|
568
|
+
**Pool Subscriptions** (requires authentication)
|
|
569
|
+
- `subscribePoolData(accountId, auth, handler)` - Subscribe to pool data updates
|
|
570
|
+
- `unsubscribePoolData(accountId)` - Unsubscribe from pool data
|
|
571
|
+
- `subscribePoolInfo(accountId, auth, handler)` - Subscribe to pool information updates
|
|
572
|
+
- `unsubscribePoolInfo(accountId)` - Unsubscribe from pool information
|
|
573
|
+
|
|
574
|
+
**System Subscriptions**
|
|
575
|
+
- `subscribeNotifications(accountId, auth, handler)` - Subscribe to system notifications
|
|
576
|
+
- `unsubscribeNotifications(accountId)` - Unsubscribe from notifications
|
|
577
|
+
- `subscribeTransactions(handler)` - Subscribe to all transaction updates
|
|
578
|
+
- `unsubscribeTransactions()` - Unsubscribe from transaction updates
|
|
579
|
+
- `subscribeExecutedTransactions(handler)` - Subscribe to executed transaction updates
|
|
580
|
+
- `unsubscribeExecutedTransactions()` - Unsubscribe from executed transactions
|
|
581
|
+
- `subscribeAccountTransactions(accountId, auth, handler)` - Subscribe to account-specific transactions
|
|
582
|
+
- `unsubscribeAccountTransactions(accountId)` - Unsubscribe from account transactions
|
|
583
|
+
- `subscribeHeight(handler)` - Subscribe to block height updates
|
|
584
|
+
- `unsubscribeHeight()` - Unsubscribe from height updates
|
|
585
|
+
|
|
586
|
+
**Advanced**
|
|
587
|
+
- `subscribe<TPayload>(subscription)` - Generic subscribe method with custom subscription options
|
|
588
|
+
- `unsubscribe(channel)` - Generic unsubscribe method for any channel
|
|
589
|
+
- `send(message)` - Send raw message through WebSocket connection
|
|
590
|
+
|
|
591
|
+
## Constants and Enums
|
|
592
|
+
|
|
593
|
+
The SDK provides comprehensive constants and enums for type-safe interaction with the Lighter protocol:
|
|
594
|
+
|
|
595
|
+
### Transaction Types
|
|
596
|
+
|
|
597
|
+
```typescript
|
|
598
|
+
import { TxType } from 'lighter-sdk-client';
|
|
599
|
+
|
|
600
|
+
// L1 Transaction Types
|
|
601
|
+
TxType.L1Deposit
|
|
602
|
+
TxType.L1ChangePubKey
|
|
603
|
+
TxType.L1CreateMarket
|
|
604
|
+
TxType.L1UpdateMarket
|
|
605
|
+
TxType.L1CancelAllOrders
|
|
606
|
+
TxType.L1Withdraw
|
|
607
|
+
TxType.L1CreateOrder
|
|
608
|
+
TxType.L1BurnShares
|
|
609
|
+
|
|
610
|
+
// L2 Transaction Types
|
|
611
|
+
TxType.L2ChangePubKey
|
|
612
|
+
TxType.L2CreateSubAccount
|
|
613
|
+
TxType.L2CreatePublicPool
|
|
614
|
+
TxType.L2UpdatePublicPool
|
|
615
|
+
TxType.L2Transfer
|
|
616
|
+
TxType.L2Withdraw
|
|
617
|
+
TxType.L2CreateOrder
|
|
618
|
+
TxType.L2CancelOrder
|
|
619
|
+
TxType.L2CancelAllOrders
|
|
620
|
+
TxType.L2ModifyOrder
|
|
621
|
+
TxType.L2MintShares
|
|
622
|
+
TxType.L2BurnShares
|
|
623
|
+
TxType.L2UpdateLeverage
|
|
624
|
+
TxType.L2CreateGroupedOrders
|
|
625
|
+
TxType.L2UpdateMargin
|
|
626
|
+
|
|
627
|
+
// Internal Transaction Types
|
|
628
|
+
TxType.InternalClaimOrder
|
|
629
|
+
TxType.InternalCancelOrder
|
|
630
|
+
TxType.InternalDeleverage
|
|
631
|
+
TxType.InternalExitPosition
|
|
632
|
+
TxType.InternalCancelAllOrders
|
|
633
|
+
TxType.InternalLiquidatePosition
|
|
634
|
+
TxType.InternalCreateOrder
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
### Order Types
|
|
638
|
+
|
|
639
|
+
```typescript
|
|
640
|
+
import { OrderType } from 'lighter-sdk-client';
|
|
641
|
+
|
|
642
|
+
OrderType.Limit // Standard limit order
|
|
643
|
+
OrderType.Market // Market order
|
|
644
|
+
OrderType.StopLoss // Stop loss order
|
|
645
|
+
OrderType.StopLossLimit // Stop loss limit order
|
|
646
|
+
OrderType.TakeProfit // Take profit order
|
|
647
|
+
OrderType.TakeProfitLimit // Take profit limit order
|
|
648
|
+
OrderType.TWAP // Time-weighted average price order
|
|
649
|
+
OrderType.TWAPSub // TWAP sub-order (internal)
|
|
650
|
+
OrderType.Liquidation // Liquidation order (internal)
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
### Order Time-In-Force
|
|
654
|
+
|
|
655
|
+
```typescript
|
|
656
|
+
import { OrderTimeInForce } from 'lighter-sdk-client';
|
|
657
|
+
|
|
658
|
+
OrderTimeInForce.ImmediateOrCancel // Execute immediately or cancel
|
|
659
|
+
OrderTimeInForce.GoodTillTime // Active until specified time
|
|
660
|
+
OrderTimeInForce.PostOnly // Only add to order book (maker only)
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
### Grouping Types
|
|
664
|
+
|
|
665
|
+
```typescript
|
|
666
|
+
import { GroupingType } from 'lighter-sdk-client';
|
|
667
|
+
|
|
668
|
+
GroupingType.Default // No grouping
|
|
669
|
+
GroupingType.OneTriggersTheOther // OCO: One triggers the other
|
|
670
|
+
GroupingType.OneCancelsTheOther // OCO: One cancels the other
|
|
671
|
+
GroupingType.OneTriggersAOneCancelsTheOther // OTOCO: Combined behavior
|
|
672
|
+
```
|
|
673
|
+
|
|
674
|
+
### Margin Modes
|
|
675
|
+
|
|
676
|
+
```typescript
|
|
677
|
+
import {
|
|
678
|
+
PositionMarginMode,
|
|
679
|
+
AssetMarginMode,
|
|
680
|
+
MarginUpdateDirection
|
|
681
|
+
} from 'lighter-sdk-client';
|
|
682
|
+
|
|
683
|
+
// Position Margin Mode
|
|
684
|
+
PositionMarginMode.Cross // Cross margin
|
|
685
|
+
PositionMarginMode.Isolated // Isolated margin
|
|
686
|
+
|
|
687
|
+
// Asset Margin Mode
|
|
688
|
+
AssetMarginMode.Disabled
|
|
689
|
+
AssetMarginMode.Enabled
|
|
690
|
+
|
|
691
|
+
// Margin Update Direction
|
|
692
|
+
MarginUpdateDirection.RemoveFromIsolated
|
|
693
|
+
MarginUpdateDirection.AddToIsolated
|
|
694
|
+
```
|
|
695
|
+
|
|
696
|
+
### Asset Route Types
|
|
697
|
+
|
|
698
|
+
```typescript
|
|
699
|
+
import { AssetRouteType } from 'lighter-sdk-client';
|
|
700
|
+
|
|
701
|
+
AssetRouteType.Perps // Perpetual futures
|
|
702
|
+
AssetRouteType.Spot // Spot trading
|
|
703
|
+
```
|
|
704
|
+
|
|
705
|
+
### Numeric Constants
|
|
706
|
+
|
|
707
|
+
The SDK includes various numeric constants for limits and validations:
|
|
708
|
+
|
|
709
|
+
```typescript
|
|
710
|
+
import {
|
|
711
|
+
OneUSDC,
|
|
712
|
+
MinOrderPrice,
|
|
713
|
+
MaxOrderPrice,
|
|
714
|
+
MinOrderBaseAmount,
|
|
715
|
+
MaxOrderBaseAmount,
|
|
716
|
+
MinAccountIndex,
|
|
717
|
+
MaxAccountIndex,
|
|
718
|
+
NativeAssetIndex,
|
|
719
|
+
USDCAssetIndex,
|
|
720
|
+
// ... and many more
|
|
721
|
+
} from 'lighter-sdk-client';
|
|
722
|
+
|
|
723
|
+
// Example usage
|
|
724
|
+
const minAmount = MinOrderBaseAmount; // 1
|
|
725
|
+
const maxAmount = MaxOrderBaseAmount; // 281474976710655
|
|
726
|
+
const usdcDecimals = OneUSDC; // 1000000
|
|
727
|
+
```
|
|
728
|
+
|
|
729
|
+
Available numeric constants include:
|
|
730
|
+
- **Account Indices**: `MinAccountIndex`, `MaxAccountIndex`, `MaxMasterAccountIndex`, `MinSubAccountIndex`
|
|
731
|
+
- **Market Indices**: `MinMarketIndex`, `MaxPerpsMarketIndex`, `MinSpotMarketIndex`, `MaxSpotMarketIndex`
|
|
732
|
+
- **Asset Indices**: `NativeAssetIndex`, `USDCAssetIndex`, `MinAssetIndex`, `MaxAssetIndex`
|
|
733
|
+
- **Order Limits**: `MinOrderPrice`, `MaxOrderPrice`, `MinOrderBaseAmount`, `MaxOrderBaseAmount`
|
|
734
|
+
- **Order Timing**: `MinOrderExpiryPeriod`, `MaxOrderExpiryPeriod`, `MinOrderCancelAllPeriod`, `MaxOrderCancelAllPeriod`
|
|
735
|
+
- **Pool Limits**: `MaxInvestedPublicPoolCount`, `MinInitialTotalShares`, `MaxInitialTotalShares`
|
|
736
|
+
- **Exchange Limits**: `MaxExchangeUSDC`, `MinTransferAmount`, `MaxTransferAmount`, `MinWithdrawalAmount`, `MaxWithdrawalAmount`
|
|
737
|
+
|
|
738
|
+
## Configuration
|
|
739
|
+
|
|
740
|
+
### Base URLs
|
|
741
|
+
|
|
742
|
+
- **Mainnet**: `https://mainnet.zklighter.elliot.ai`
|
|
743
|
+
- **WebSocket**: `wss://mainnet.zklighter.elliot.ai/stream`
|
|
744
|
+
|
|
745
|
+
### WASM Signing Setup
|
|
746
|
+
|
|
747
|
+
For transaction signing, you need to include the WASM files (please copy them from the `lighter-sdk-client` package to your `./public` directory):
|
|
748
|
+
|
|
749
|
+
```typescript
|
|
750
|
+
import { WasmSigner } from 'lighter-sdk-client';
|
|
751
|
+
|
|
752
|
+
const wasmSigning = new WasmSigner({
|
|
753
|
+
wasmPath: './public/wasm/lighter-signer.wasm',
|
|
754
|
+
wasmExecPath: './public/wasm/lighter-wasm-exec.js'
|
|
755
|
+
});
|
|
756
|
+
```
|
|
757
|
+
|
|
758
|
+
The WASM files should be placed in your public directory and served statically.
|
|
759
|
+
|
|
760
|
+
## Dependencies
|
|
761
|
+
|
|
762
|
+
- `axios` - HTTP client for API requests
|
|
763
|
+
- `viem` - Ethereum library for L1 bridge operations
|
|
764
|
+
- `wagmi` - React hooks for Ethereum (peer dependency)
|
|
765
|
+
- `@tanstack/react-query` - Data fetching library (peer dependency)
|
|
766
|
+
|
|
767
|
+
## Development
|
|
768
|
+
|
|
769
|
+
### Build
|
|
770
|
+
|
|
771
|
+
```bash
|
|
772
|
+
pnpm build
|
|
773
|
+
```
|
|
774
|
+
|
|
775
|
+
### Project Structure
|
|
776
|
+
|
|
777
|
+
```
|
|
778
|
+
src/
|
|
779
|
+
├── api/ # API endpoint implementations
|
|
780
|
+
│ ├── exchange/ # Exchange/transaction endpoints
|
|
781
|
+
│ ├── info/ # Public info endpoints
|
|
782
|
+
│ └── info-private/ # Private/authenticated endpoints
|
|
783
|
+
├── client/ # Client classes
|
|
784
|
+
│ ├── exchange-client.ts
|
|
785
|
+
│ ├── info-client.ts
|
|
786
|
+
│ ├── info-private-client.ts
|
|
787
|
+
│ ├── l1-bridge-client.ts
|
|
788
|
+
│ └── ws-client.ts
|
|
789
|
+
├── signing/ # Transaction signing utilities
|
|
790
|
+
│ └── wasm-signer.ts
|
|
791
|
+
└── types/ # TypeScript type definitions
|
|
792
|
+
├── bridge.ts
|
|
793
|
+
├── constant.ts # Protocol constants and enums
|
|
794
|
+
├── ws.ts
|
|
795
|
+
└── index.ts
|
|
796
|
+
```
|
|
797
|
+
|
|
798
|
+
## License
|
|
799
|
+
|
|
800
|
+
ISC
|
|
801
|
+
|
|
802
|
+
## Disclaimer
|
|
803
|
+
|
|
804
|
+
This is an unofficial SDK client for the Lighter protocol. Use at your own risk. Always verify transactions before signing.
|
|
805
|
+
|
|
806
|
+
## Links
|
|
807
|
+
|
|
808
|
+
- [Lighter Protocol](https://lighter.xyz)
|
|
809
|
+
- [Documentation](https://docs.lighter.xyz)
|
|
810
|
+
|
|
811
|
+
## Support
|
|
812
|
+
|
|
813
|
+
For issues and questions:
|
|
814
|
+
- Create an issue on GitHub
|
|
815
|
+
- Join the Lighter community Discord
|
|
816
|
+
- Check the official documentation
|