lighter-sdk-client 0.2.11
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 +574 -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-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-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-5YGIBBTZ.js +357 -0
- package/dist/chunk-62KDFQ7D.js +367 -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-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-AKEQDKGA.js +167 -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-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-KV6G2ZCR.js +539 -0
- package/dist/chunk-L5SDFTHR.cjs +242 -0
- package/dist/chunk-LBVNEQ5R.cjs +21 -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-MOMFTZ7N.cjs +357 -0
- package/dist/chunk-MZCKU6FF.js +8 -0
- package/dist/chunk-NIMYOIVU.cjs +1 -0
- package/dist/chunk-NIT6TCVS.cjs +8 -0
- package/dist/chunk-NOFXPTLU.js +8 -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-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-QMXZQNBK.cjs +8 -0
- package/dist/chunk-QNM3HYIV.cjs +8 -0
- package/dist/chunk-QXGO7TJ2.js +17 -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-SK6Y2YH6.js +0 -0
- package/dist/chunk-TELGVFFP.js +13 -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-UICTRTWB.cjs +367 -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-VT3N7TOX.js +325 -0
- package/dist/chunk-VW77SNCY.js +24 -0
- package/dist/chunk-W2BVNVOC.cjs +1 -0
- package/dist/chunk-W2CTGWUW.cjs +539 -0
- package/dist/chunk-W5VY4TWP.js +16 -0
- package/dist/chunk-WDQ4YM6C.cjs +167 -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-XPZBVL56.cjs +325 -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 +352 -0
- package/dist/client/exchange-client.d.ts +352 -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 +63 -0
- package/dist/client/ws-client.d.ts +63 -0
- package/dist/client/ws-client.js +6 -0
- package/dist/index.cjs +79 -0
- package/dist/index.d.cts +53 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.js +79 -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/index.cjs +3 -0
- package/dist/types/index.d.cts +2 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +3 -0
- package/dist/types/ws.cjs +1 -0
- package/dist/types/ws.d.cts +351 -0
- package/dist/types/ws.d.ts +351 -0
- package/dist/types/ws.js +1 -0
- package/package.json +52 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/client/l1-bridge-client.ts
|
|
2
|
+
var _viem = require('viem');
|
|
3
|
+
var _accounts = require('viem/accounts');
|
|
4
|
+
var USDC_ABI = [
|
|
5
|
+
{
|
|
6
|
+
name: "transfer",
|
|
7
|
+
type: "function",
|
|
8
|
+
stateMutability: "nonpayable",
|
|
9
|
+
inputs: [
|
|
10
|
+
{ name: "to", type: "address" },
|
|
11
|
+
{ name: "amount", type: "uint256" }
|
|
12
|
+
],
|
|
13
|
+
outputs: [{ type: "bool" }]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: "approve",
|
|
17
|
+
type: "function",
|
|
18
|
+
stateMutability: "nonpayable",
|
|
19
|
+
inputs: [
|
|
20
|
+
{ name: "spender", type: "address" },
|
|
21
|
+
{ name: "amount", type: "uint256" }
|
|
22
|
+
],
|
|
23
|
+
outputs: [{ type: "bool" }]
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "balanceOf",
|
|
27
|
+
type: "function",
|
|
28
|
+
stateMutability: "view",
|
|
29
|
+
inputs: [{ name: "account", type: "address" }],
|
|
30
|
+
outputs: [{ type: "uint256" }]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "decimals",
|
|
34
|
+
type: "function",
|
|
35
|
+
stateMutability: "view",
|
|
36
|
+
inputs: [],
|
|
37
|
+
outputs: [{ type: "uint8" }]
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "allowance",
|
|
41
|
+
type: "function",
|
|
42
|
+
stateMutability: "view",
|
|
43
|
+
inputs: [
|
|
44
|
+
{ name: "owner", type: "address" },
|
|
45
|
+
{ name: "spender", type: "address" }
|
|
46
|
+
],
|
|
47
|
+
outputs: [{ type: "uint256" }]
|
|
48
|
+
}
|
|
49
|
+
];
|
|
50
|
+
var BRIDGE_ABI = [
|
|
51
|
+
{
|
|
52
|
+
name: "deposit",
|
|
53
|
+
type: "function",
|
|
54
|
+
stateMutability: "nonpayable",
|
|
55
|
+
inputs: [
|
|
56
|
+
{ name: "amount", type: "uint256" },
|
|
57
|
+
{ name: "l2AccountIndex", type: "uint256" }
|
|
58
|
+
],
|
|
59
|
+
outputs: []
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: "depositTo",
|
|
63
|
+
type: "function",
|
|
64
|
+
stateMutability: "nonpayable",
|
|
65
|
+
inputs: [
|
|
66
|
+
{ name: "amount", type: "uint256" },
|
|
67
|
+
{ name: "l2AccountIndex", type: "uint256" },
|
|
68
|
+
{ name: "to", type: "address" }
|
|
69
|
+
],
|
|
70
|
+
outputs: []
|
|
71
|
+
}
|
|
72
|
+
];
|
|
73
|
+
var L1BridgeClient = class {
|
|
74
|
+
constructor(config) {
|
|
75
|
+
this.config = config;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Deposit USDC from L1 to L2
|
|
79
|
+
* @param params - Deposit parameters
|
|
80
|
+
* @returns Promise<L1DepositResult>
|
|
81
|
+
*/
|
|
82
|
+
async depositToL2(params) {
|
|
83
|
+
const account = _accounts.privateKeyToAccount.call(void 0, params.ethPrivateKey);
|
|
84
|
+
const publicClient = _viem.createPublicClient.call(void 0, {
|
|
85
|
+
chain: { id: this.config.chainId },
|
|
86
|
+
transport: _viem.http.call(void 0, this.config.rpcUrl)
|
|
87
|
+
});
|
|
88
|
+
const walletClient = _viem.createWalletClient.call(void 0, {
|
|
89
|
+
account,
|
|
90
|
+
chain: { id: this.config.chainId },
|
|
91
|
+
transport: _viem.http.call(void 0, this.config.rpcUrl)
|
|
92
|
+
});
|
|
93
|
+
const usdcContract = _viem.getContract.call(void 0, {
|
|
94
|
+
address: this.config.usdcContract,
|
|
95
|
+
abi: USDC_ABI,
|
|
96
|
+
client: { public: publicClient, wallet: walletClient }
|
|
97
|
+
});
|
|
98
|
+
const bridgeContract = _viem.getContract.call(void 0, {
|
|
99
|
+
address: this.config.l1BridgeContract,
|
|
100
|
+
abi: BRIDGE_ABI,
|
|
101
|
+
client: { public: publicClient, wallet: walletClient }
|
|
102
|
+
});
|
|
103
|
+
const decimals = await usdcContract.read.decimals();
|
|
104
|
+
const amountInUnits = _viem.parseUnits.call(void 0, params.usdcAmount.toString(), decimals);
|
|
105
|
+
const balance = await usdcContract.read.balanceOf([account.address]);
|
|
106
|
+
if (balance < amountInUnits) {
|
|
107
|
+
throw new Error(`Insufficient USDC balance. Required: ${_viem.formatUnits.call(void 0, amountInUnits, decimals)}, Available: ${_viem.formatUnits.call(void 0, balance, decimals)}`);
|
|
108
|
+
}
|
|
109
|
+
const allowance = await usdcContract.read.allowance([account.address, this.config.l1BridgeContract]);
|
|
110
|
+
if (allowance < amountInUnits) {
|
|
111
|
+
const approveHash = await usdcContract.write.approve([this.config.l1BridgeContract, amountInUnits], {
|
|
112
|
+
gasPrice: params.gasPrice ? _viem.parseUnits.call(void 0, params.gasPrice, 9) : void 0,
|
|
113
|
+
gas: params.gasLimit ? BigInt(params.gasLimit) : void 0
|
|
114
|
+
});
|
|
115
|
+
await publicClient.waitForTransactionReceipt({ hash: approveHash });
|
|
116
|
+
}
|
|
117
|
+
const depositHash = await bridgeContract.write.deposit([amountInUnits, BigInt(params.l2AccountIndex)], {
|
|
118
|
+
gasPrice: params.gasPrice ? _viem.parseUnits.call(void 0, params.gasPrice, 9) : void 0,
|
|
119
|
+
gas: params.gasLimit ? BigInt(params.gasLimit) : void 0
|
|
120
|
+
});
|
|
121
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash: depositHash });
|
|
122
|
+
if (!receipt) {
|
|
123
|
+
throw new Error("Transaction receipt not found");
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
l1TxHash: depositHash,
|
|
127
|
+
l2AccountIndex: params.l2AccountIndex,
|
|
128
|
+
amount: _viem.formatUnits.call(void 0, amountInUnits, decimals),
|
|
129
|
+
status: receipt.status === "success" ? "completed" : "failed",
|
|
130
|
+
blockNumber: Number(receipt.blockNumber),
|
|
131
|
+
gasUsed: receipt.gasUsed.toString()
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Check USDC balance for an address
|
|
136
|
+
* @param address - Ethereum address
|
|
137
|
+
* @returns Promise<string> - Balance in USDC units
|
|
138
|
+
*/
|
|
139
|
+
async getUSDCBalance(address) {
|
|
140
|
+
const publicClient = _viem.createPublicClient.call(void 0, {
|
|
141
|
+
chain: { id: this.config.chainId },
|
|
142
|
+
transport: _viem.http.call(void 0, this.config.rpcUrl)
|
|
143
|
+
});
|
|
144
|
+
const usdcContract = _viem.getContract.call(void 0, {
|
|
145
|
+
address: this.config.usdcContract,
|
|
146
|
+
abi: USDC_ABI,
|
|
147
|
+
client: publicClient
|
|
148
|
+
});
|
|
149
|
+
const balance = await usdcContract.read.balanceOf([address]);
|
|
150
|
+
const decimals = await usdcContract.read.decimals();
|
|
151
|
+
return _viem.formatUnits.call(void 0, balance, decimals);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Check USDC allowance for bridge contract
|
|
155
|
+
* @param address - Ethereum address
|
|
156
|
+
* @returns Promise<string> - Allowance in USDC units
|
|
157
|
+
*/
|
|
158
|
+
async getUSDCAllowance(address) {
|
|
159
|
+
const publicClient = _viem.createPublicClient.call(void 0, {
|
|
160
|
+
chain: { id: this.config.chainId },
|
|
161
|
+
transport: _viem.http.call(void 0, this.config.rpcUrl)
|
|
162
|
+
});
|
|
163
|
+
const usdcContract = _viem.getContract.call(void 0, {
|
|
164
|
+
address: this.config.usdcContract,
|
|
165
|
+
abi: USDC_ABI,
|
|
166
|
+
client: publicClient
|
|
167
|
+
});
|
|
168
|
+
const allowance = await usdcContract.read.allowance([address, this.config.l1BridgeContract]);
|
|
169
|
+
const decimals = await usdcContract.read.decimals();
|
|
170
|
+
return _viem.formatUnits.call(void 0, allowance, decimals);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Get transaction status
|
|
174
|
+
* @param txHash - Transaction hash
|
|
175
|
+
* @returns Promise<L1DepositResult>
|
|
176
|
+
*/
|
|
177
|
+
async getTransactionStatus(txHash) {
|
|
178
|
+
const publicClient = _viem.createPublicClient.call(void 0, {
|
|
179
|
+
chain: { id: this.config.chainId },
|
|
180
|
+
transport: _viem.http.call(void 0, this.config.rpcUrl)
|
|
181
|
+
});
|
|
182
|
+
const tx = await publicClient.getTransaction({ hash: txHash });
|
|
183
|
+
const receipt = await publicClient.getTransactionReceipt({ hash: txHash }).catch(() => null);
|
|
184
|
+
if (!tx) {
|
|
185
|
+
throw new Error("Transaction not found");
|
|
186
|
+
}
|
|
187
|
+
if (!receipt) {
|
|
188
|
+
return {
|
|
189
|
+
l1TxHash: txHash,
|
|
190
|
+
l2AccountIndex: 0,
|
|
191
|
+
// Will be updated when transaction is parsed
|
|
192
|
+
amount: "0",
|
|
193
|
+
status: "pending"
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
const amount = "0";
|
|
197
|
+
const l2AccountIndex = 0;
|
|
198
|
+
return {
|
|
199
|
+
l1TxHash: txHash,
|
|
200
|
+
l2AccountIndex,
|
|
201
|
+
amount,
|
|
202
|
+
status: receipt.status === "success" ? "completed" : "failed",
|
|
203
|
+
blockNumber: Number(receipt.blockNumber),
|
|
204
|
+
gasUsed: receipt.gasUsed.toString()
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Get default bridge configuration for mainnet
|
|
209
|
+
* @returns L1BridgeConfig
|
|
210
|
+
*/
|
|
211
|
+
static getMainnetConfig() {
|
|
212
|
+
return {
|
|
213
|
+
l1BridgeContract: "0x0000000000000000000000000000000000000000",
|
|
214
|
+
// Replace with actual bridge contract
|
|
215
|
+
usdcContract: "0xA0b86a33E6441b8c4C8C0E4A8c4c4c4c4c4c4c4c4",
|
|
216
|
+
// Replace with actual USDC contract
|
|
217
|
+
rpcUrl: "https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY",
|
|
218
|
+
// Replace with actual RPC URL
|
|
219
|
+
chainId: 1
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Get default bridge configuration for testnet
|
|
224
|
+
* @returns L1BridgeConfig
|
|
225
|
+
*/
|
|
226
|
+
static getTestnetConfig() {
|
|
227
|
+
return {
|
|
228
|
+
l1BridgeContract: "0x0000000000000000000000000000000000000000",
|
|
229
|
+
// Replace with actual testnet bridge contract
|
|
230
|
+
usdcContract: "0x0000000000000000000000000000000000000000",
|
|
231
|
+
// Replace with actual testnet USDC contract
|
|
232
|
+
rpcUrl: "https://eth-sepolia.g.alchemy.com/v2/YOUR_API_KEY",
|
|
233
|
+
// Replace with actual testnet RPC URL
|
|
234
|
+
chainId: 11155111
|
|
235
|
+
// Sepolia testnet
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
exports.L1BridgeClient = L1BridgeClient;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/api/info-private/position-funding.ts
|
|
2
|
+
async function getPositionFunding(client, params, authorization) {
|
|
3
|
+
const config = {
|
|
4
|
+
params: {
|
|
5
|
+
account_index: params.account_index,
|
|
6
|
+
limit: params.limit,
|
|
7
|
+
...params.market_id !== void 0 ? { market_id: params.market_id } : {},
|
|
8
|
+
...params.cursor ? { cursor: params.cursor } : {},
|
|
9
|
+
...params.side ? { side: params.side } : {},
|
|
10
|
+
...params.auth ? { auth: params.auth } : {}
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
if (authorization) {
|
|
14
|
+
config.headers = { Authorization: authorization };
|
|
15
|
+
}
|
|
16
|
+
return client.get("/api/v1/positionFunding", config).then((response) => response.data);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
exports.getPositionFunding = getPositionFunding;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/api/info-private/transfer-fee-info.ts
|
|
2
|
+
async function getTransferFeeInfo(client, params, authorization) {
|
|
3
|
+
const config = {
|
|
4
|
+
params: {
|
|
5
|
+
account_index: params.account_index,
|
|
6
|
+
...params.to_account_index !== void 0 ? { to_account_index: params.to_account_index } : {},
|
|
7
|
+
...params.auth ? { auth: params.auth } : {}
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
if (authorization) {
|
|
11
|
+
config.headers = { Authorization: authorization };
|
|
12
|
+
}
|
|
13
|
+
return client.get("/api/v1/transferFeeInfo", config).then((response) => response.data);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
getTransferFeeInfo
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
File without changes
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/client/ws-client.ts
|
|
2
|
+
var WsClient = class {
|
|
3
|
+
constructor(config) {
|
|
4
|
+
this.ws = null;
|
|
5
|
+
this.reconnectAttempts = 0;
|
|
6
|
+
this.reconnectTimer = null;
|
|
7
|
+
this.subscriptions = /* @__PURE__ */ new Map();
|
|
8
|
+
this.isConnecting = false;
|
|
9
|
+
this.isConnected = false;
|
|
10
|
+
this.config = {
|
|
11
|
+
reconnectInterval: 5e3,
|
|
12
|
+
maxReconnectAttempts: 5,
|
|
13
|
+
...config
|
|
14
|
+
};
|
|
15
|
+
this.url = this.config.url || "wss://mainnet.zklighter.elliot.ai/stream";
|
|
16
|
+
}
|
|
17
|
+
connect() {
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
if (this.isConnecting || this.isConnected) {
|
|
20
|
+
resolve();
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
this.isConnecting = true;
|
|
24
|
+
try {
|
|
25
|
+
this.ws = new WebSocket(this.url);
|
|
26
|
+
this.ws.onopen = () => {
|
|
27
|
+
this.isConnecting = false;
|
|
28
|
+
this.isConnected = true;
|
|
29
|
+
this.reconnectAttempts = 0;
|
|
30
|
+
_optionalChain([this, 'access', _ => _.config, 'access', _2 => _2.onOpen, 'optionalCall', _3 => _3()]);
|
|
31
|
+
this.resubscribeAll();
|
|
32
|
+
resolve();
|
|
33
|
+
};
|
|
34
|
+
this.ws.onmessage = (event) => {
|
|
35
|
+
try {
|
|
36
|
+
const message = JSON.parse(event.data);
|
|
37
|
+
_optionalChain([this, 'access', _4 => _4.config, 'access', _5 => _5.onMessage, 'optionalCall', _6 => _6(message)]);
|
|
38
|
+
this.handleSubscriptionMessage(message);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
this.ws.onerror = (error) => {
|
|
43
|
+
this.isConnecting = false;
|
|
44
|
+
_optionalChain([this, 'access', _7 => _7.config, 'access', _8 => _8.onError, 'optionalCall', _9 => _9(new Error("WebSocket error"))]);
|
|
45
|
+
reject(new Error("WebSocket error"));
|
|
46
|
+
};
|
|
47
|
+
this.ws.onclose = () => {
|
|
48
|
+
this.isConnected = false;
|
|
49
|
+
_optionalChain([this, 'access', _10 => _10.config, 'access', _11 => _11.onClose, 'optionalCall', _12 => _12()]);
|
|
50
|
+
this.attemptReconnect();
|
|
51
|
+
};
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.error("WebSocket connection error:", error);
|
|
54
|
+
this.isConnecting = false;
|
|
55
|
+
reject(error);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
disconnect() {
|
|
60
|
+
if (this.reconnectTimer) {
|
|
61
|
+
clearTimeout(this.reconnectTimer);
|
|
62
|
+
this.reconnectTimer = null;
|
|
63
|
+
}
|
|
64
|
+
if (this.ws) {
|
|
65
|
+
this.ws.close();
|
|
66
|
+
this.ws = null;
|
|
67
|
+
}
|
|
68
|
+
this.isConnected = false;
|
|
69
|
+
this.isConnecting = false;
|
|
70
|
+
}
|
|
71
|
+
subscribe(subscription) {
|
|
72
|
+
if (!this.isConnected || !this.ws) {
|
|
73
|
+
throw new Error("WebSocket is not connected");
|
|
74
|
+
}
|
|
75
|
+
const message = {
|
|
76
|
+
type: "subscribe",
|
|
77
|
+
channel: subscription.channel
|
|
78
|
+
};
|
|
79
|
+
if (subscription.auth) {
|
|
80
|
+
message.auth = subscription.auth;
|
|
81
|
+
}
|
|
82
|
+
if (subscription.params) {
|
|
83
|
+
for (const [key, value] of Object.entries(subscription.params)) {
|
|
84
|
+
if (value !== void 0) {
|
|
85
|
+
message[key] = value;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const normalizedChannel = this.normalizeChannel(subscription.channel);
|
|
90
|
+
const storedSubscription = { ...subscription };
|
|
91
|
+
this.ws.send(JSON.stringify(message));
|
|
92
|
+
this.subscriptions.set(normalizedChannel, storedSubscription);
|
|
93
|
+
}
|
|
94
|
+
subscribeOrderBook(marketIndex, handler) {
|
|
95
|
+
this.subscribe({
|
|
96
|
+
channel: `order_book/${marketIndex}`,
|
|
97
|
+
handler,
|
|
98
|
+
parser: this.passthroughParser()
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
unsubscribeOrderBook(marketIndex) {
|
|
102
|
+
this.unsubscribe(`order_book/${marketIndex}`);
|
|
103
|
+
}
|
|
104
|
+
subscribeMarketStats(market, handler) {
|
|
105
|
+
const channel = `market_stats/${market}`;
|
|
106
|
+
this.subscribe({
|
|
107
|
+
channel,
|
|
108
|
+
handler,
|
|
109
|
+
parser: this.passthroughParser()
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
unsubscribeMarketStats(market) {
|
|
113
|
+
this.unsubscribe(`market_stats/${market}`);
|
|
114
|
+
}
|
|
115
|
+
subscribeSpotMarketStats(market, handler) {
|
|
116
|
+
const channel = `spot_market_stats/${market}`;
|
|
117
|
+
this.subscribe({
|
|
118
|
+
channel,
|
|
119
|
+
handler,
|
|
120
|
+
parser: this.passthroughParser()
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
unsubscribeSpotMarketStats(market) {
|
|
124
|
+
this.unsubscribe(`spot_market_stats/${market}`);
|
|
125
|
+
}
|
|
126
|
+
subscribeTrades(marketIndex, handler) {
|
|
127
|
+
this.subscribe({
|
|
128
|
+
channel: `trade/${marketIndex}`,
|
|
129
|
+
handler,
|
|
130
|
+
parser: this.passthroughParser()
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
unsubscribeTrades(marketIndex) {
|
|
134
|
+
this.unsubscribe(`trade/${marketIndex}`);
|
|
135
|
+
}
|
|
136
|
+
subscribeAccountAll(accountId, handler) {
|
|
137
|
+
this.subscribe({
|
|
138
|
+
channel: `account_all/${accountId}`,
|
|
139
|
+
handler,
|
|
140
|
+
parser: this.passthroughParser()
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
unsubscribeAccountAll(accountId) {
|
|
144
|
+
this.unsubscribe(`account_all/${accountId}`);
|
|
145
|
+
}
|
|
146
|
+
subscribeAccountMarket(marketId, accountId, auth, handler) {
|
|
147
|
+
this.subscribe({
|
|
148
|
+
channel: `account_market/${marketId}/${accountId}`,
|
|
149
|
+
auth,
|
|
150
|
+
handler,
|
|
151
|
+
parser: this.passthroughParser()
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
unsubscribeAccountMarket(marketId, accountId) {
|
|
155
|
+
this.unsubscribe(`account_market/${marketId}/${accountId}`);
|
|
156
|
+
}
|
|
157
|
+
subscribeUserStats(accountId, handler) {
|
|
158
|
+
this.subscribe({
|
|
159
|
+
channel: `user_stats/${accountId}`,
|
|
160
|
+
handler,
|
|
161
|
+
parser: this.passthroughParser()
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
unsubscribeUserStats(accountId) {
|
|
165
|
+
this.unsubscribe(`user_stats/${accountId}`);
|
|
166
|
+
}
|
|
167
|
+
subscribeTransactions(handler) {
|
|
168
|
+
this.subscribe({
|
|
169
|
+
channel: "transaction",
|
|
170
|
+
handler,
|
|
171
|
+
parser: this.passthroughParser()
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
unsubscribeTransactions() {
|
|
175
|
+
this.unsubscribe("transaction");
|
|
176
|
+
}
|
|
177
|
+
subscribeExecutedTransactions(handler) {
|
|
178
|
+
this.subscribe({
|
|
179
|
+
channel: "executed_transaction",
|
|
180
|
+
handler,
|
|
181
|
+
parser: this.passthroughParser()
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
unsubscribeExecutedTransactions() {
|
|
185
|
+
this.unsubscribe("executed_transaction");
|
|
186
|
+
}
|
|
187
|
+
subscribeAccountTransactions(accountId, auth, handler) {
|
|
188
|
+
this.subscribe({
|
|
189
|
+
channel: `account_tx/${accountId}`,
|
|
190
|
+
auth,
|
|
191
|
+
handler,
|
|
192
|
+
parser: this.passthroughParser()
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
unsubscribeAccountTransactions(accountId) {
|
|
196
|
+
this.unsubscribe(`account_tx/${accountId}`);
|
|
197
|
+
}
|
|
198
|
+
subscribeAccountAllOrders(accountId, auth, handler) {
|
|
199
|
+
this.subscribe({
|
|
200
|
+
channel: `account_all_orders/${accountId}`,
|
|
201
|
+
auth,
|
|
202
|
+
handler,
|
|
203
|
+
parser: this.passthroughParser()
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
unsubscribeAccountAllOrders(accountId) {
|
|
207
|
+
this.unsubscribe(`account_all_orders/${accountId}`);
|
|
208
|
+
}
|
|
209
|
+
subscribeHeight(handler) {
|
|
210
|
+
this.subscribe({
|
|
211
|
+
channel: "height",
|
|
212
|
+
handler,
|
|
213
|
+
parser: this.passthroughParser()
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
unsubscribeHeight() {
|
|
217
|
+
this.unsubscribe("height");
|
|
218
|
+
}
|
|
219
|
+
subscribePoolData(accountId, auth, handler) {
|
|
220
|
+
this.subscribe({
|
|
221
|
+
channel: `pool_data/${accountId}`,
|
|
222
|
+
auth,
|
|
223
|
+
handler,
|
|
224
|
+
parser: this.passthroughParser()
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
unsubscribePoolData(accountId) {
|
|
228
|
+
this.unsubscribe(`pool_data/${accountId}`);
|
|
229
|
+
}
|
|
230
|
+
subscribePoolInfo(accountId, auth, handler) {
|
|
231
|
+
this.subscribe({
|
|
232
|
+
channel: `pool_info/${accountId}`,
|
|
233
|
+
auth,
|
|
234
|
+
handler,
|
|
235
|
+
parser: this.passthroughParser()
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
unsubscribePoolInfo(accountId) {
|
|
239
|
+
this.unsubscribe(`pool_info/${accountId}`);
|
|
240
|
+
}
|
|
241
|
+
subscribeNotifications(accountId, auth, handler) {
|
|
242
|
+
this.subscribe({
|
|
243
|
+
channel: `notification/${accountId}`,
|
|
244
|
+
auth,
|
|
245
|
+
handler,
|
|
246
|
+
parser: this.passthroughParser()
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
unsubscribeNotifications(accountId) {
|
|
250
|
+
this.unsubscribe(`notification/${accountId}`);
|
|
251
|
+
}
|
|
252
|
+
subscribeAccountOrders(marketIndex, accountId, auth, handler) {
|
|
253
|
+
this.subscribe({
|
|
254
|
+
channel: `account_orders/${marketIndex}/${accountId}`,
|
|
255
|
+
auth,
|
|
256
|
+
handler,
|
|
257
|
+
parser: this.passthroughParser()
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
unsubscribeAccountOrders(marketIndex, accountId) {
|
|
261
|
+
this.unsubscribe(`account_orders/${marketIndex}/${accountId}`);
|
|
262
|
+
}
|
|
263
|
+
subscribeAccountAllTrades(accountId, auth, handler) {
|
|
264
|
+
this.subscribe({
|
|
265
|
+
channel: `account_all_trades/${accountId}`,
|
|
266
|
+
auth,
|
|
267
|
+
handler,
|
|
268
|
+
parser: this.passthroughParser()
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
unsubscribeAccountAllTrades(accountId) {
|
|
272
|
+
this.unsubscribe(`account_all_trades/${accountId}`);
|
|
273
|
+
}
|
|
274
|
+
subscribeAccountAllPositions(accountId, auth, handler) {
|
|
275
|
+
this.subscribe({
|
|
276
|
+
channel: `account_all_positions/${accountId}`,
|
|
277
|
+
auth,
|
|
278
|
+
handler,
|
|
279
|
+
parser: this.passthroughParser()
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
unsubscribeAccountAllPositions(accountId) {
|
|
283
|
+
this.unsubscribe(`account_all_positions/${accountId}`);
|
|
284
|
+
}
|
|
285
|
+
unsubscribe(channel) {
|
|
286
|
+
if (!this.isConnected || !this.ws) {
|
|
287
|
+
throw new Error("WebSocket is not connected");
|
|
288
|
+
}
|
|
289
|
+
const message = {
|
|
290
|
+
type: "unsubscribe",
|
|
291
|
+
channel
|
|
292
|
+
};
|
|
293
|
+
this.ws.send(JSON.stringify(message));
|
|
294
|
+
this.subscriptions.delete(this.normalizeChannel(channel));
|
|
295
|
+
}
|
|
296
|
+
send(message) {
|
|
297
|
+
if (!this.isConnected || !this.ws) {
|
|
298
|
+
throw new Error("WebSocket is not connected");
|
|
299
|
+
}
|
|
300
|
+
this.ws.send(JSON.stringify(message));
|
|
301
|
+
}
|
|
302
|
+
normalizeChannel(channel) {
|
|
303
|
+
return channel.replace(/:/g, "/");
|
|
304
|
+
}
|
|
305
|
+
passthroughParser() {
|
|
306
|
+
return (payload) => payload;
|
|
307
|
+
}
|
|
308
|
+
handleSubscriptionMessage(rawMessage) {
|
|
309
|
+
if (!rawMessage || typeof rawMessage !== "object") {
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
const channelName = typeof rawMessage.channel === "string" ? rawMessage.channel : void 0;
|
|
313
|
+
if (!channelName) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
const normalizedChannel = this.normalizeChannel(channelName);
|
|
317
|
+
const subscription = this.subscriptions.get(normalizedChannel);
|
|
318
|
+
if (!subscription || typeof subscription.handler !== "function") {
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
try {
|
|
322
|
+
const parser = typeof subscription.parser === "function" ? subscription.parser : (payload) => payload;
|
|
323
|
+
const parsed = parser(rawMessage);
|
|
324
|
+
subscription.handler(parsed);
|
|
325
|
+
} catch (error) {
|
|
326
|
+
const normalizedError = error instanceof Error ? error : new Error(String(error));
|
|
327
|
+
_optionalChain([this, 'access', _13 => _13.config, 'access', _14 => _14.onError, 'optionalCall', _15 => _15(normalizedError)]);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
attemptReconnect() {
|
|
331
|
+
if (this.reconnectAttempts >= (this.config.maxReconnectAttempts || 5)) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
this.reconnectAttempts++;
|
|
335
|
+
this.reconnectTimer = setTimeout(() => {
|
|
336
|
+
this.connect().catch(() => {
|
|
337
|
+
this.attemptReconnect();
|
|
338
|
+
});
|
|
339
|
+
}, this.config.reconnectInterval || 5e3);
|
|
340
|
+
}
|
|
341
|
+
resubscribeAll() {
|
|
342
|
+
const subscriptions = Array.from(this.subscriptions.values());
|
|
343
|
+
for (const subscription of subscriptions) {
|
|
344
|
+
this.subscribe(subscription);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
isConnectedToWebSocket() {
|
|
348
|
+
return this.isConnected;
|
|
349
|
+
}
|
|
350
|
+
getSubscriptions() {
|
|
351
|
+
return Array.from(this.subscriptions.values());
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
exports.WsClient = WsClient;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/api/info/candles.ts
|
|
2
|
+
async function getCandlesticks(client, params) {
|
|
3
|
+
return client.get("/api/v1/candles", { params }).then((response) => response.data);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
exports.getCandlesticks = getCandlesticks;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// src/api/info-private/pnl.ts
|
|
2
|
+
async function getPnL(client, params, authorization) {
|
|
3
|
+
const config = {
|
|
4
|
+
params: {
|
|
5
|
+
by: params.by,
|
|
6
|
+
value: params.value,
|
|
7
|
+
resolution: params.resolution,
|
|
8
|
+
start_timestamp: params.start_timestamp,
|
|
9
|
+
end_timestamp: params.end_timestamp,
|
|
10
|
+
count_back: params.count_back,
|
|
11
|
+
...params.auth ? { auth: params.auth } : {},
|
|
12
|
+
...params.ignore_transfers !== void 0 ? { ignore_transfers: params.ignore_transfers } : {}
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
if (authorization) {
|
|
16
|
+
config.headers = { Authorization: authorization };
|
|
17
|
+
}
|
|
18
|
+
return client.get("/api/v1/pnl", config).then((response) => response.data);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
getPnL
|
|
23
|
+
};
|
|
File without changes
|