{"_id":"@andy-liquid-labs/lighter-ts-sdk","_rev":"7-94014739b69d81e1c9004406d7e6fd9c","name":"@andy-liquid-labs/lighter-ts-sdk","dist-tags":{"latest":"1.0.6"},"versions":{"1.0.0":{"name":"@andy-liquid-labs/lighter-ts-sdk","version":"1.0.0","keywords":["lighter","sdk","trading","crypto","signing"],"author":"","license":"MIT","_id":"@andy-liquid-labs/lighter-ts-sdk@1.0.0","maintainers":[{"name":"andy-liquid-labs","email":"andy@liquid-labs.xyz"}],"homepage":"https://github.com/elliottech/lighter-ts-sdk#readme","bugs":{"url":"https://github.com/elliottech/lighter-ts-sdk/issues"},"dist":{"shasum":"41b6a59d76ac5961c28fc16609c4cfe0469e0794","tarball":"https://registry.npmjs.org/@andy-liquid-labs/lighter-ts-sdk/-/lighter-ts-sdk-1.0.0.tgz","fileCount":85,"integrity":"sha512-mAObzDAlfjY8u8R6JtmprHyZ+dLZbU7dEZy83LbkEVniX28h9rHTpdv210f41eC9LbwoVoehuR1apkN3MyrrhQ==","signatures":[{"sig":"MEQCIGhVXVOEV25Cp8DaeVYc8zkIECeEqt3+K7omKA0IYaI3AiB22ZqCsdI+Xp+kci5qHfdREI0TcsV0ciUgnZ2Vsoc3Lw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":1707240},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"fa2ee7fb8d2957a18960875afd7f08aaa90d04ff","scripts":{"lint":"eslint src --ext .ts","test":"vitest run","build":"tsup","typecheck":"tsc --noEmit","test:watch":"vitest","prepublishOnly":"npm run build"},"_npmUser":{"name":"andy-liquid-labs","email":"andy@liquid-labs.xyz"},"repository":{"url":"git+https://github.com/elliottech/lighter-ts-sdk.git","type":"git"},"_npmVersion":"9.6.4","description":"TypeScript SDK for Lighter - signing & hashing of Lighter transactions","directories":{},"_nodeVersion":"20.0.0","dependencies":{"axios":"^1.13.3","js-sha256":"^0.11.1","reconnecting-websocket":"^4.4.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","eslint":"^8.55.0","vitest":"^1.0.0","typescript":"^5.3.0","@types/node":"^25.0.10","@typescript-eslint/parser":"^6.13.0","@typescript-eslint/eslint-plugin":"^6.13.0"},"_npmOperationalInternal":{"tmp":"tmp/lighter-ts-sdk_1.0.0_1770093609816_0.8930578761563641","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@andy-liquid-labs/lighter-ts-sdk","version":"1.0.1","keywords":["lighter","sdk","trading","crypto","signing"],"author":"","license":"MIT","_id":"@andy-liquid-labs/lighter-ts-sdk@1.0.1","maintainers":[{"name":"andy-liquid-labs","email":"andy@liquid-labs.xyz"}],"homepage":"https://github.com/elliottech/lighter-ts-sdk#readme","bugs":{"url":"https://github.com/elliottech/lighter-ts-sdk/issues"},"dist":{"shasum":"37d05f755f2a114dbe1cd5b6aa9442734c79f040","tarball":"https://registry.npmjs.org/@andy-liquid-labs/lighter-ts-sdk/-/lighter-ts-sdk-1.0.1.tgz","fileCount":85,"integrity":"sha512-w38YJysZQE8VgaINXhoqOdPGKdilMzPvj2zaPRPjUpN/3xY2XxBmib46OZHrR9wJRwitgG0sYivUJ3UY0VXqwQ==","signatures":[{"sig":"MEQCIH7c9AseQQZVDQeUDOYNScx3P90WDSjUsDpXzp1olFpnAiBNjLtoUIanvJxz1B6e1nrQpp+0LSCDUc+q8tfDMX8nTg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":1706595},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"1b4eba87bd3c95c11e7e8e6a3d09fae438a3c70b","scripts":{"lint":"eslint src --ext .ts","test":"vitest run","build":"tsup","typecheck":"tsc --noEmit","test:watch":"vitest","prepublishOnly":"npm run build"},"_npmUser":{"name":"andy-liquid-labs","email":"andy@liquid-labs.xyz"},"repository":{"url":"git+https://github.com/elliottech/lighter-ts-sdk.git","type":"git"},"_npmVersion":"9.6.4","description":"TypeScript SDK for Lighter - signing & hashing of Lighter transactions","directories":{},"_nodeVersion":"20.0.0","dependencies":{"axios":"^1.13.3","js-sha256":"^0.11.1","reconnecting-websocket":"^4.4.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","eslint":"^8.55.0","vitest":"^1.0.0","typescript":"^5.3.0","@types/node":"^25.0.10","@typescript-eslint/parser":"^6.13.0","@typescript-eslint/eslint-plugin":"^6.13.0"},"_npmOperationalInternal":{"tmp":"tmp/lighter-ts-sdk_1.0.1_1770107473508_0.23895362808510012","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@andy-liquid-labs/lighter-ts-sdk","version":"1.0.2","keywords":["lighter","sdk","trading","crypto","signing"],"author":"","license":"MIT","_id":"@andy-liquid-labs/lighter-ts-sdk@1.0.2","maintainers":[{"name":"andy-liquid-labs","email":"andy@liquid-labs.xyz"}],"homepage":"https://github.com/elliottech/lighter-ts-sdk#readme","bugs":{"url":"https://github.com/elliottech/lighter-ts-sdk/issues"},"dist":{"shasum":"81afb933b1604f5f7615d6a7e7ec8c51a7a860b5","tarball":"https://registry.npmjs.org/@andy-liquid-labs/lighter-ts-sdk/-/lighter-ts-sdk-1.0.2.tgz","fileCount":85,"integrity":"sha512-scDZUixnybT7LMB4geeLJP1G9ASgqxKY8wTpy1ZDtUrrFuCfl7GGr7dpJ+59IlUQAqyip+Xm5IUdJHUTV7U7oA==","signatures":[{"sig":"MEUCIHOzTMYkR00XisEZ4AcRwuGxPenvm2bGIUjfPjB22+02AiEA/zATYceZouckxFzYX0OLpB3WQ9h5YNEVpKxDO2e8NL4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":1709565},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"fa1f468791b9e6bb038904a24f35553c4c604d86","scripts":{"lint":"eslint src --ext .ts","test":"vitest run","build":"tsup","typecheck":"tsc --noEmit","test:watch":"vitest","prepublishOnly":"npm run build"},"_npmUser":{"name":"andy-liquid-labs","email":"andy@liquid-labs.xyz"},"repository":{"url":"git+https://github.com/elliottech/lighter-ts-sdk.git","type":"git"},"_npmVersion":"9.6.4","description":"TypeScript SDK for Lighter - signing & hashing of Lighter transactions","directories":{},"_nodeVersion":"20.0.0","dependencies":{"axios":"^1.13.3","js-sha256":"^0.11.1","reconnecting-websocket":"^4.4.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","eslint":"^8.55.0","vitest":"^1.0.0","typescript":"^5.3.0","@types/node":"^25.0.10","@typescript-eslint/parser":"^6.13.0","@typescript-eslint/eslint-plugin":"^6.13.0"},"_npmOperationalInternal":{"tmp":"tmp/lighter-ts-sdk_1.0.2_1770275597320_0.7951400251136196","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@andy-liquid-labs/lighter-ts-sdk","version":"1.0.3","keywords":["lighter","sdk","trading","crypto","signing"],"author":"","license":"MIT","_id":"@andy-liquid-labs/lighter-ts-sdk@1.0.3","maintainers":[{"name":"andy-liquid-labs","email":"andy@liquid-labs.xyz"}],"homepage":"https://github.com/elliottech/lighter-ts-sdk#readme","bugs":{"url":"https://github.com/elliottech/lighter-ts-sdk/issues"},"dist":{"shasum":"491cbcb170037e03927ebb8a0565cf17fca1b671","tarball":"https://registry.npmjs.org/@andy-liquid-labs/lighter-ts-sdk/-/lighter-ts-sdk-1.0.3.tgz","fileCount":85,"integrity":"sha512-7G9S0E2DiGxfTldN/ubbyB2ObdYQu4jMpBGRpTzzTiwZMCnyp614OPEcyA/3Tcvylp5KJHARw2ApC1GicTSyXg==","signatures":[{"sig":"MEUCIQDNcr1wLgWVuHc6B2pHrSsGkQyJE4Y3/DiWY449Q3wptwIgNavk4KWN11xhpc96OnNDxdH7TgDN6DnniKE6iWZO7OM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":1728375},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"1b8db66c08801ccd197b5080e8b0cf7f86c90cdf","scripts":{"lint":"eslint src --ext .ts","test":"vitest run","build":"tsup","typecheck":"tsc --noEmit","test:watch":"vitest","prepublishOnly":"npm run build"},"_npmUser":{"name":"andy-liquid-labs","email":"andy@liquid-labs.xyz"},"repository":{"url":"git+https://github.com/elliottech/lighter-ts-sdk.git","type":"git"},"_npmVersion":"9.6.4","description":"TypeScript SDK for Lighter - signing & hashing of Lighter transactions","directories":{},"_nodeVersion":"20.0.0","dependencies":{"axios":"^1.13.3","js-sha256":"^0.11.1","reconnecting-websocket":"^4.4.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","eslint":"^8.55.0","vitest":"^1.0.0","typescript":"^5.3.0","@types/node":"^25.0.10","@typescript-eslint/parser":"^6.13.0","@typescript-eslint/eslint-plugin":"^6.13.0"},"_npmOperationalInternal":{"tmp":"tmp/lighter-ts-sdk_1.0.3_1770284829220_0.4967636970972422","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@andy-liquid-labs/lighter-ts-sdk","version":"1.0.4","keywords":["lighter","sdk","trading","crypto","signing"],"author":"","license":"MIT","_id":"@andy-liquid-labs/lighter-ts-sdk@1.0.4","maintainers":[{"name":"andy-liquid-labs","email":"andy@liquid-labs.xyz"}],"homepage":"https://github.com/elliottech/lighter-ts-sdk#readme","bugs":{"url":"https://github.com/elliottech/lighter-ts-sdk/issues"},"dist":{"shasum":"795128c57de7d4437aa80cda39349f772b7636c7","tarball":"https://registry.npmjs.org/@andy-liquid-labs/lighter-ts-sdk/-/lighter-ts-sdk-1.0.4.tgz","fileCount":85,"integrity":"sha512-DrgG95ipj87nFQmZ7Oa873TLVJIx3hIveX5lcWvPfRpWtl4r+azQ8E4EmiTuglxjAX467osDLgTMm0zgGEqcgw==","signatures":[{"sig":"MEYCIQDdpaoKBU6whYot9xaa+29sST2hvp6+W21JoQFjAUJa+wIhAJNYILp6NhdNVEOJBFwZdSG54di6iY+orRsmmlGh+3vF","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":1741275},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"8890a41e780ac4470f87b9848920ab6106edaf48","scripts":{"lint":"eslint src --ext .ts","test":"vitest run","build":"tsup","typecheck":"tsc --noEmit","test:watch":"vitest","prepublishOnly":"npm run build"},"_npmUser":{"name":"andy-liquid-labs","email":"andy@liquid-labs.xyz"},"repository":{"url":"git+https://github.com/elliottech/lighter-ts-sdk.git","type":"git"},"_npmVersion":"9.6.4","description":"TypeScript SDK for Lighter - signing & hashing of Lighter transactions","directories":{},"_nodeVersion":"20.0.0","dependencies":{"axios":"^1.13.3","js-sha256":"^0.11.1","reconnecting-websocket":"^4.4.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","eslint":"^8.55.0","vitest":"^1.0.0","typescript":"^5.3.0","@types/node":"^25.0.10","@typescript-eslint/parser":"^6.13.0","@typescript-eslint/eslint-plugin":"^6.13.0"},"_npmOperationalInternal":{"tmp":"tmp/lighter-ts-sdk_1.0.4_1770564054543_0.33032932172328633","host":"s3://npm-registry-packages-npm-production"}},"1.0.5":{"name":"@andy-liquid-labs/lighter-ts-sdk","version":"1.0.5","keywords":["lighter","sdk","trading","crypto","signing"],"author":"","license":"MIT","_id":"@andy-liquid-labs/lighter-ts-sdk@1.0.5","maintainers":[{"name":"andy-liquid-labs","email":"andy@liquid-labs.xyz"}],"homepage":"https://github.com/elliottech/lighter-ts-sdk#readme","bugs":{"url":"https://github.com/elliottech/lighter-ts-sdk/issues"},"dist":{"shasum":"fc0fbc4bb38b87a0dd1e83a293ee3731c466a4a2","tarball":"https://registry.npmjs.org/@andy-liquid-labs/lighter-ts-sdk/-/lighter-ts-sdk-1.0.5.tgz","fileCount":85,"integrity":"sha512-yXGkRU83CHegneDXoir/7oj+eZJ0wkyO4QRoGymuOXYwMsq7QfI00dzO7zy9o7R0t061Nay8EuEXfITL5mNrKw==","signatures":[{"sig":"MEUCID5u4ilS+0pEl/Ynu/KqICdPavDRPIn9fuS7QwSxheOiAiEA+iq+XrsjM6Kqz4xAs5JKayvfe71TMxh4GBcKav34gos=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":1741346},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"1849ee9bf28d4c5162b578e9bb8fb8ae601bfa65","scripts":{"lint":"eslint src --ext .ts","test":"vitest run","build":"tsup","typecheck":"tsc --noEmit","test:watch":"vitest","prepublishOnly":"npm run build"},"_npmUser":{"name":"andy-liquid-labs","email":"andy@liquid-labs.xyz"},"repository":{"url":"git+https://github.com/elliottech/lighter-ts-sdk.git","type":"git"},"_npmVersion":"9.6.4","description":"TypeScript SDK for Lighter - signing & hashing of Lighter transactions","directories":{},"_nodeVersion":"20.0.0","dependencies":{"axios":"^1.13.3","js-sha256":"^0.11.1","reconnecting-websocket":"^4.4.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","eslint":"^8.55.0","vitest":"^1.0.0","typescript":"^5.3.0","@types/node":"^25.0.10","@typescript-eslint/parser":"^6.13.0","@typescript-eslint/eslint-plugin":"^6.13.0"},"_npmOperationalInternal":{"tmp":"tmp/lighter-ts-sdk_1.0.5_1770607922790_0.27141618600226525","host":"s3://npm-registry-packages-npm-production"}},"1.0.6":{"name":"@andy-liquid-labs/lighter-ts-sdk","version":"1.0.6","description":"TypeScript SDK for Lighter - signing & hashing of Lighter transactions","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","require":"./dist/index.js","import":"./dist/index.mjs"}},"scripts":{"build":"tsup","test":"vitest run","test:watch":"vitest","lint":"eslint src --ext .ts","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"keywords":["lighter","sdk","trading","crypto","signing"],"author":"","license":"MIT","repository":{"type":"git","url":"git+https://github.com/elliottech/lighter-ts-sdk.git"},"devDependencies":{"@types/node":"^25.0.10","@typescript-eslint/eslint-plugin":"^6.13.0","@typescript-eslint/parser":"^6.13.0","eslint":"^8.55.0","tsup":"^8.0.0","typescript":"^5.3.0","vitest":"^1.0.0"},"engines":{"node":">=18.0.0"},"dependencies":{"axios":"^1.13.3","js-sha256":"^0.11.1","reconnecting-websocket":"^4.4.0"},"gitHead":"6111f1c88c4c88c48d9750e27ec59822013eae50","bugs":{"url":"https://github.com/elliottech/lighter-ts-sdk/issues"},"homepage":"https://github.com/elliottech/lighter-ts-sdk#readme","_id":"@andy-liquid-labs/lighter-ts-sdk@1.0.6","_nodeVersion":"20.0.0","_npmVersion":"9.6.4","dist":{"integrity":"sha512-i7bjzIMR0PlViPmG1nV3J82CxtZQ55xTzPnWiV+EDdlw1m111J0I8SYKq6/zePtHpValrPqbIdvuY4caSQqy6Q==","shasum":"488b26a0b6f45f4df367a4aaecc64092a6f83595","tarball":"https://registry.npmjs.org/@andy-liquid-labs/lighter-ts-sdk/-/lighter-ts-sdk-1.0.6.tgz","fileCount":85,"unpackedSize":1756335,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIAqL6iGYq3EoqOfHC2E6G6X7jBdg8CZRHgVY/KaEssY5AiEAhOPWbsbeqYDtxvlP9UdqWuUxY5mbEtTlJ7Ps+dRnQkc="}]},"_npmUser":{"name":"andy-liquid-labs","email":"andy@liquid-labs.xyz"},"directories":{},"maintainers":[{"name":"andy-liquid-labs","email":"andy@liquid-labs.xyz"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/lighter-ts-sdk_1.0.6_1773651194029_0.5121524547376939"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-03T04:40:09.695Z","modified":"2026-03-16T08:53:14.339Z","1.0.0":"2026-02-03T04:40:10.035Z","1.0.1":"2026-02-03T08:31:13.671Z","1.0.2":"2026-02-05T07:13:17.498Z","1.0.3":"2026-02-05T09:47:09.419Z","1.0.4":"2026-02-08T15:20:54.721Z","1.0.5":"2026-02-09T03:32:03.011Z","1.0.6":"2026-03-16T08:53:14.204Z"},"bugs":{"url":"https://github.com/elliottech/lighter-ts-sdk/issues"},"license":"MIT","homepage":"https://github.com/elliottech/lighter-ts-sdk#readme","keywords":["lighter","sdk","trading","crypto","signing"],"repository":{"type":"git","url":"git+https://github.com/elliottech/lighter-ts-sdk.git"},"description":"TypeScript SDK for Lighter - signing & hashing of Lighter transactions","maintainers":[{"name":"andy-liquid-labs","email":"andy@liquid-labs.xyz"}],"readme":"# lighter-ts-sdk\n\nTypeScript SDK for Lighter - signing & hashing of Lighter transactions, plus HTTP and WebSocket clients.\n\nThis is the TypeScript equivalent of the [lighter-go](https://github.com/elliottech/lighter-go) SDK.\n\n## Installation\n\n```bash\nnpm install lighter-ts-sdk\n```\n\n## Quick Start\n\n```typescript\nimport {\n  createClient,\n  generateApiKey,\n  newHttpClient,\n  InfoClient,\n  ExchangeClient,\n  OrderType,\n  TimeInForce,\n} from 'lighter-ts-sdk';\n\n// Generate a new API key pair (optionally with a seed for deterministic generation)\nconst [privateKey, publicKey] = generateApiKey();\n// Or with a seed:\n// const [privateKey, publicKey] = generateApiKey('my-seed-string');\nconsole.log('Private Key:', privateKey);\nconsole.log('Public Key:', publicKey);\n\n// Create an HTTP client (for automatic nonce fetching)\nconst httpClient = newHttpClient('https://mainnet.zklighter.elliot.ai');\n\n// Create a TxClient for signing\nconst txClient = createClient(\n  httpClient,\n  privateKey,\n  1, // chainId\n  0, // apiKeyIndex\n  1n // accountIndex\n);\n\n// Use ExchangeClient to create and send orders\nconst exchangeClient = new ExchangeClient({\n  baseURL: 'https://mainnet.zklighter.elliot.ai',\n  txClient,\n});\n\n// Create and send an order\nconst result = await exchangeClient.createOrder({\n  marketIndex: 0,\n  clientOrderIndex: 1n,\n  baseAmount: 1000000n,\n  price: 50000,\n  isAsk: 0,\n  orderType: OrderType.Limit,\n  timeInForce: TimeInForce.GoodTillTime,\n  reduceOnly: 0,\n  triggerPrice: 0,\n  orderExpiry: BigInt(Date.now() + 3600000), // 1 hour\n});\n\nconsole.log('Transaction hash:', result.tx_hash);\n```\n\n## Clients\n\nThe SDK provides several client classes for different purposes:\n\n### InfoClient - Public API\n\nAccess public market data without authentication:\n\n```typescript\nimport { InfoClient } from 'lighter-ts-sdk';\n\nconst infoClient = new InfoClient({\n  baseURL: 'https://mainnet.zklighter.elliot.ai',\n});\n\n// Get order books\nconst orderBooks = await infoClient.getOrderBooks();\n\n// Get account info\nconst account = await infoClient.getAccount({ l1_address: '0x...' });\n\n// Get candles\nconst candles = await infoClient.getCandles({\n  market_id: 0,\n  resolution: '1h',\n  start_time: Date.now() - 86400000,\n  end_time: Date.now(),\n});\n\n// Get recent trades\nconst trades = await infoClient.getRecentTrades({ market_id: 0 });\n\n// Get funding rates\nconst fundingRates = await infoClient.getFundingRates({ market_id: 0 });\n```\n\n### InfoPrivateClient - Authenticated API\n\nAccess private account data with authentication:\n\n```typescript\nimport { InfoPrivateClient, createClient, newHttpClient } from 'lighter-ts-sdk';\n\nconst httpClient = newHttpClient('https://mainnet.zklighter.elliot.ai');\nconst txClient = createClient(httpClient, privateKey, 1, 0, 1n);\n\nconst privateClient = new InfoPrivateClient({\n  baseURL: 'https://mainnet.zklighter.elliot.ai',\n  txClient,\n});\n\n// Get active orders\nconst orders = await privateClient.getAccountActiveOrders({ account_index: 1 });\n\n// Get trade history\nconst trades = await privateClient.getTrades({\n  account_index: 1,\n  start_time: Date.now() - 86400000,\n});\n\n// Get PnL\nconst pnl = await privateClient.getPnl({ account_index: 1 });\n\n// Get deposit history\nconst deposits = await privateClient.getDepositHistory({ account_index: 1 });\n```\n\n### ExchangeClient - Transactions\n\nSign and send transactions:\n\n```typescript\nimport { ExchangeClient, createClient, newHttpClient } from 'lighter-ts-sdk';\n\nconst httpClient = newHttpClient('https://mainnet.zklighter.elliot.ai');\nconst txClient = createClient(httpClient, privateKey, 1, 0, 1n);\n\nconst exchangeClient = new ExchangeClient({\n  baseURL: 'https://mainnet.zklighter.elliot.ai',\n  txClient,\n});\n\n// Create order\nconst orderResult = await exchangeClient.createOrder({\n  marketIndex: 0,\n  clientOrderIndex: 1n,\n  baseAmount: 1000000n,\n  price: 50000,\n  isAsk: 0,\n  orderType: 1, // Limit\n  timeInForce: 1, // GoodTillTime\n  reduceOnly: 0,\n  triggerPrice: 0,\n  orderExpiry: BigInt(Date.now() + 3600000),\n});\n\n// Cancel order\nconst cancelResult = await exchangeClient.cancelOrder({\n  marketIndex: 0,\n  orderIndex: 123n,\n});\n\n// Cancel all orders\nconst cancelAllResult = await exchangeClient.cancelAllOrders({\n  timeInForce: 1,\n  time: BigInt(Date.now()),\n});\n\n// Withdraw\nconst withdrawResult = await exchangeClient.withdraw({\n  assetIndex: 0,\n  routeType: 0,\n  amount: 1000000n,\n});\n\n// Transfer\nconst transferResult = await exchangeClient.transfer({\n  toAccountIndex: 2n,\n  assetIndex: 0,\n  fromRouteType: 0,\n  toRouteType: 0,\n  amount: 1000000n,\n  usdcFee: 0n,\n  memo: 'test transfer',\n});\n\n// Update leverage\nconst leverageResult = await exchangeClient.updateLeverage({\n  marketIndex: 0,\n  initialMarginFraction: 100,\n  marginMode: 0,\n});\n```\n\n### WsClient - WebSocket\n\nReal-time data streams with handler callbacks. Subscription methods return an unsubscribe function for easy cleanup:\n\n```typescript\nimport { WsClient, createClient, newHttpClient } from 'lighter-ts-sdk';\n\nconst httpClient = newHttpClient('https://mainnet.zklighter.elliot.ai');\nconst txClient = createClient(httpClient, privateKey, 1, 0, 1n);\n\nconst wsClient = new WsClient({\n  url: 'wss://mainnet.zklighter.elliot.ai/stream',\n  onOpen: () => console.log('Connected'),\n  onClose: () => console.log('Disconnected'),\n  onError: (error) => console.error('Error:', error),\n  onMessage: (data) => console.log('Raw message:', data),\n});\n\n// Connect\nawait wsClient.connect();\n\n// Public subscriptions with handler callbacks (returns unsubscribe function)\nconst unsubOrderBook = wsClient.subscribeOrderBook(0, (update) => {\n  console.log('Order book:', update.order_book);\n});\n\nconst unsubMarketStats = wsClient.subscribeMarketStats('all', (update) => {\n  console.log('Market stats:', update.market_stats);\n});\n\nconst unsubTrades = wsClient.subscribeTrades(0, (update) => {\n  console.log('New trades:', update.trades);\n});\n\nconst unsubHeight = wsClient.subscribeHeight((update) => {\n  console.log('Block height:', update.height);\n});\n\n// Authenticated subscriptions (generate auth token manually)\nconst deadline = new Date(Date.now() + 7 * 60 * 60 * 1000); // 7 hours\nconst authToken = await txClient.getAuthToken(deadline);\n\nconst unsubAccountAll = wsClient.subscribeAccountAll(1, (update) => {\n  console.log('Account data:', update);\n});\n\nconst unsubAccountMarket = wsClient.subscribeAccountMarket(0, 1, authToken, (update) => {\n  console.log('Account market:', update);\n});\n\nconst unsubUserStats = wsClient.subscribeUserStats(1, (update) => {\n  console.log('User stats:', update.stats);\n});\n\nconst unsubAccountOrders = wsClient.subscribeAccountAllOrders(1, authToken, (update) => {\n  console.log('All orders:', update.orders);\n});\n\nconst unsubAccountAssets = wsClient.subscribeAccountAllAssets(1, authToken, (update) => {\n  console.log('All assets:', update.assets);\n});\n\nconst unsubNotifications = wsClient.subscribeNotifications(1, authToken, (update) => {\n  console.log('Notifications:', update.notifs);\n});\n\n// Unsubscribe by calling the returned function\nunsubOrderBook();\nunsubMarketStats();\n\n// Or disconnect entirely\nwsClient.disconnect();\n```\n\n## Direct Signing (Low-Level)\n\nFor advanced use cases, you can sign transactions directly without sending:\n\n```typescript\nimport { createClient, newHttpClient } from 'lighter-ts-sdk';\n\nconst httpClient = newHttpClient('https://mainnet.zklighter.elliot.ai');\nconst txClient = createClient(httpClient, privateKey, 1, 0, 1n);\n\n// Sign a create order transaction\nconst signedOrder = await txClient.signCreateOrder({\n  marketIndex: 0,\n  clientOrderIndex: 1n,\n  baseAmount: 1000000n,\n  price: 50000,\n  isAsk: 0,\n  type: 1,\n  timeInForce: 1,\n  reduceOnly: 0,\n  triggerPrice: 0,\n  orderExpiry: BigInt(Date.now() + 3600000),\n});\n\nconsole.log('Signed hash:', signedOrder.signedHash);\nconsole.log('Signature:', signedOrder.signature);\n```\n\n## API Key Generation\n\n```typescript\nimport { generateApiKey } from 'lighter-ts-sdk';\n\n// Generate random API key pair\nconst [privateKey, publicKey] = generateApiKey();\n\n// Generate deterministic API key from seed\nconst [privKey, pubKey] = generateApiKey('my-seed-string');\n```\n\n## Auth Tokens\n\nAuth tokens are used for authenticated HTTP & WebSocket endpoints:\n\n```typescript\n// Create an auth token valid for 7 hours\nconst token = await txClient.getAuthToken(new Date(Date.now() + 7 * 60 * 60 * 1000));\n```\n\n## Transaction Options\n\nSigning methods accept an optional `TransactOpts` object:\n\n```typescript\nconst tx = await txClient.signCreateOrder(orderReq, {\n  nonce: 42n, // If undefined, fetched from server\n  expiredAt: BigInt(Date.now() + 600000), // 10 minutes\n  apiKeyIndex: 0,\n  fromAccountIndex: 1n,\n});\n```\n\n## Constants\n\n```typescript\nimport {\n  OrderType,\n  TimeInForce,\n  GroupingType,\n  AssetRouteType,\n  MarginMode,\n  MarginDirection,\n  TxType,\n} from 'lighter-ts-sdk';\n\n// Order types\nOrderType.Market     // 0\nOrderType.Limit      // 1\nOrderType.StopLoss   // 2\nOrderType.TakeProfit // 3\n\n// Time in force\nTimeInForce.ImmediateOrCancel // 0\nTimeInForce.GoodTillTime      // 1\nTimeInForce.PostOnly          // 2\n```\n\n## Development\n\n```bash\n# Install dependencies\nnpm install\n\n# Build\nnpm run build\n\n# Run tests\nnpm test\n\n# Type check\nnpm run typecheck\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}