lighter-ts-sdk 1.0.9-beta-rust.0 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (526) hide show
  1. package/README.md +404 -448
  2. package/dist/browser/index.html +20 -0
  3. package/dist/browser/lighter-ts-sdk.browser.js +33885 -0
  4. package/dist/browser/lighter-ts-sdk.browser.js.map +7 -0
  5. package/dist/cjs/api/account-api.d.ts +251 -0
  6. package/dist/cjs/api/account-api.d.ts.map +1 -0
  7. package/dist/cjs/api/account-api.js +203 -0
  8. package/dist/cjs/api/account-api.js.map +1 -0
  9. package/dist/cjs/api/announcement-api.d.ts.map +1 -0
  10. package/dist/cjs/api/announcement-api.js.map +1 -0
  11. package/dist/cjs/api/api-client.d.ts.map +1 -0
  12. package/dist/cjs/api/api-client.js +146 -0
  13. package/dist/cjs/api/api-client.js.map +1 -0
  14. package/dist/cjs/api/block-api.d.ts.map +1 -0
  15. package/dist/cjs/api/block-api.js.map +1 -0
  16. package/dist/{api → cjs/api}/bridge-api.d.ts +34 -0
  17. package/dist/cjs/api/bridge-api.d.ts.map +1 -0
  18. package/dist/cjs/api/bridge-api.js +173 -0
  19. package/dist/cjs/api/bridge-api.js.map +1 -0
  20. package/dist/{api → cjs/api}/candlestick-api.d.ts +3 -0
  21. package/dist/cjs/api/candlestick-api.d.ts.map +1 -0
  22. package/dist/cjs/api/candlestick-api.js +21 -0
  23. package/dist/cjs/api/candlestick-api.js.map +1 -0
  24. package/dist/cjs/api/explorer-api-client.d.ts +32 -0
  25. package/dist/cjs/api/explorer-api-client.d.ts.map +1 -0
  26. package/dist/cjs/api/explorer-api-client.js +138 -0
  27. package/dist/cjs/api/explorer-api-client.js.map +1 -0
  28. package/dist/cjs/api/funding-api.d.ts.map +1 -0
  29. package/dist/cjs/api/funding-api.js.map +1 -0
  30. package/dist/cjs/api/info-api.d.ts +43 -0
  31. package/dist/cjs/api/info-api.d.ts.map +1 -0
  32. package/dist/cjs/api/info-api.js +52 -0
  33. package/dist/cjs/api/info-api.js.map +1 -0
  34. package/dist/cjs/api/logs-api.d.ts +198 -0
  35. package/dist/cjs/api/logs-api.d.ts.map +1 -0
  36. package/dist/cjs/api/logs-api.js +256 -0
  37. package/dist/cjs/api/logs-api.js.map +1 -0
  38. package/dist/{api → cjs/api}/notification-api.d.ts +28 -0
  39. package/dist/cjs/api/notification-api.d.ts.map +1 -0
  40. package/dist/cjs/api/notification-api.js +108 -0
  41. package/dist/cjs/api/notification-api.js.map +1 -0
  42. package/dist/{api → cjs/api}/order-api.d.ts +22 -5
  43. package/dist/cjs/api/order-api.d.ts.map +1 -0
  44. package/dist/cjs/api/order-api.js +181 -0
  45. package/dist/cjs/api/order-api.js.map +1 -0
  46. package/dist/{api → cjs/api}/referral-api.d.ts +9 -0
  47. package/dist/cjs/api/referral-api.d.ts.map +1 -0
  48. package/dist/cjs/api/referral-api.js +53 -0
  49. package/dist/cjs/api/referral-api.js.map +1 -0
  50. package/dist/cjs/api/root-api.d.ts +15 -0
  51. package/dist/cjs/api/root-api.d.ts.map +1 -0
  52. package/dist/cjs/api/root-api.js +18 -0
  53. package/dist/cjs/api/root-api.js.map +1 -0
  54. package/dist/cjs/api/search-api.d.ts +211 -0
  55. package/dist/cjs/api/search-api.d.ts.map +1 -0
  56. package/dist/cjs/api/search-api.js +112 -0
  57. package/dist/cjs/api/search-api.js.map +1 -0
  58. package/dist/{api → cjs/api}/transaction-api.d.ts +4 -0
  59. package/dist/cjs/api/transaction-api.d.ts.map +1 -0
  60. package/dist/cjs/api/transaction-api.js +173 -0
  61. package/dist/cjs/api/transaction-api.js.map +1 -0
  62. package/dist/{api → cjs/api}/ws-client.d.ts +1 -0
  63. package/dist/cjs/api/ws-client.d.ts.map +1 -0
  64. package/dist/cjs/api/ws-client.js +139 -0
  65. package/dist/cjs/api/ws-client.js.map +1 -0
  66. package/dist/{api → cjs/api}/ws-order-client.d.ts +1 -0
  67. package/dist/cjs/api/ws-order-client.d.ts.map +1 -0
  68. package/dist/cjs/api/ws-order-client.js +451 -0
  69. package/dist/cjs/api/ws-order-client.js.map +1 -0
  70. package/dist/cjs/bridge/l1-bridge-client.d.ts.map +1 -0
  71. package/dist/cjs/bridge/l1-bridge-client.js.map +1 -0
  72. package/dist/{index.d.ts → cjs/index.d.ts} +21 -23
  73. package/dist/cjs/index.d.ts.map +1 -0
  74. package/dist/cjs/index.js +175 -0
  75. package/dist/cjs/index.js.map +1 -0
  76. package/dist/cjs/package.json +3 -0
  77. package/dist/{signer → cjs/signer}/wasm-signer-client.d.ts +93 -139
  78. package/dist/cjs/signer/wasm-signer-client.d.ts.map +1 -0
  79. package/dist/cjs/signer/wasm-signer-client.js +2263 -0
  80. package/dist/cjs/signer/wasm-signer-client.js.map +1 -0
  81. package/dist/{signer → cjs/signer}/wasm-signer.d.ts +16 -9
  82. package/dist/cjs/signer/wasm-signer.d.ts.map +1 -0
  83. package/dist/cjs/signer/wasm-signer.js +937 -0
  84. package/dist/cjs/signer/wasm-signer.js.map +1 -0
  85. package/dist/{types → cjs/types}/api.d.ts +13 -0
  86. package/dist/cjs/types/api.d.ts.map +1 -0
  87. package/dist/cjs/types/api.js.map +1 -0
  88. package/dist/cjs/types/config.d.ts.map +1 -0
  89. package/dist/cjs/types/config.js.map +1 -0
  90. package/dist/cjs/types/generated/openapi.d.ts.map +1 -0
  91. package/dist/cjs/types/generated/openapi.js.map +1 -0
  92. package/dist/cjs/types/index.d.ts.map +1 -0
  93. package/dist/cjs/types/index.js.map +1 -0
  94. package/dist/cjs/types/trading.d.ts.map +1 -0
  95. package/dist/cjs/types/trading.js.map +1 -0
  96. package/dist/cjs/types/transaction.d.ts.map +1 -0
  97. package/dist/cjs/types/transaction.js.map +1 -0
  98. package/dist/cjs/utils/configuration.d.ts.map +1 -0
  99. package/dist/cjs/utils/configuration.js.map +1 -0
  100. package/dist/cjs/utils/environment.d.ts +70 -0
  101. package/dist/cjs/utils/environment.d.ts.map +1 -0
  102. package/dist/cjs/utils/environment.js +214 -0
  103. package/dist/cjs/utils/environment.js.map +1 -0
  104. package/dist/cjs/utils/exceptions.d.ts.map +1 -0
  105. package/dist/cjs/utils/exceptions.js.map +1 -0
  106. package/dist/cjs/utils/index.d.ts.map +1 -0
  107. package/dist/cjs/utils/index.js.map +1 -0
  108. package/dist/cjs/utils/logger.d.ts.map +1 -0
  109. package/dist/cjs/utils/logger.js.map +1 -0
  110. package/dist/cjs/utils/market-helper.d.ts.map +1 -0
  111. package/dist/cjs/utils/market-helper.js.map +1 -0
  112. package/dist/cjs/utils/nonce-cache.d.ts.map +1 -0
  113. package/dist/cjs/utils/nonce-cache.js.map +1 -0
  114. package/dist/cjs/utils/nonce-manager.d.ts.map +1 -0
  115. package/dist/cjs/utils/nonce-manager.js.map +1 -0
  116. package/dist/cjs/utils/order-status-checker.d.ts.map +1 -0
  117. package/dist/cjs/utils/order-status-checker.js.map +1 -0
  118. package/dist/cjs/utils/price-utils.d.ts.map +1 -0
  119. package/dist/cjs/utils/price-utils.js.map +1 -0
  120. package/dist/cjs/utils/request-batcher.d.ts.map +1 -0
  121. package/dist/cjs/utils/request-batcher.js.map +1 -0
  122. package/dist/esm/api/account-api.d.ts +251 -0
  123. package/dist/esm/api/account-api.d.ts.map +1 -0
  124. package/dist/esm/api/account-api.js +199 -0
  125. package/dist/esm/api/account-api.js.map +1 -0
  126. package/dist/esm/api/announcement-api.d.ts +27 -0
  127. package/dist/esm/api/announcement-api.d.ts.map +1 -0
  128. package/dist/esm/api/announcement-api.js +21 -0
  129. package/dist/esm/api/announcement-api.js.map +1 -0
  130. package/dist/esm/api/api-client.d.ts +23 -0
  131. package/dist/esm/api/api-client.d.ts.map +1 -0
  132. package/dist/esm/api/api-client.js +139 -0
  133. package/dist/esm/api/api-client.js.map +1 -0
  134. package/dist/esm/api/block-api.d.ts +24 -0
  135. package/dist/esm/api/block-api.d.ts.map +1 -0
  136. package/dist/esm/api/block-api.js +18 -0
  137. package/dist/esm/api/block-api.js.map +1 -0
  138. package/dist/esm/api/bridge-api.d.ts +112 -0
  139. package/dist/esm/api/bridge-api.d.ts.map +1 -0
  140. package/dist/esm/api/bridge-api.js +169 -0
  141. package/dist/esm/api/bridge-api.js.map +1 -0
  142. package/dist/esm/api/candlestick-api.d.ts +30 -0
  143. package/dist/esm/api/candlestick-api.d.ts.map +1 -0
  144. package/dist/esm/api/candlestick-api.js +17 -0
  145. package/dist/esm/api/candlestick-api.js.map +1 -0
  146. package/dist/esm/api/explorer-api-client.d.ts +32 -0
  147. package/dist/esm/api/explorer-api-client.d.ts.map +1 -0
  148. package/dist/esm/api/explorer-api-client.js +131 -0
  149. package/dist/esm/api/explorer-api-client.js.map +1 -0
  150. package/dist/esm/api/funding-api.d.ts +28 -0
  151. package/dist/esm/api/funding-api.d.ts.map +1 -0
  152. package/dist/esm/api/funding-api.js +21 -0
  153. package/dist/esm/api/funding-api.js.map +1 -0
  154. package/dist/esm/api/info-api.d.ts +43 -0
  155. package/dist/esm/api/info-api.d.ts.map +1 -0
  156. package/dist/esm/api/info-api.js +48 -0
  157. package/dist/esm/api/info-api.js.map +1 -0
  158. package/dist/esm/api/logs-api.d.ts +198 -0
  159. package/dist/esm/api/logs-api.d.ts.map +1 -0
  160. package/dist/esm/api/logs-api.js +252 -0
  161. package/dist/esm/api/logs-api.js.map +1 -0
  162. package/dist/esm/api/notification-api.d.ts +55 -0
  163. package/dist/esm/api/notification-api.d.ts.map +1 -0
  164. package/dist/esm/api/notification-api.js +104 -0
  165. package/dist/esm/api/notification-api.js.map +1 -0
  166. package/dist/esm/api/order-api.d.ts +294 -0
  167. package/dist/esm/api/order-api.d.ts.map +1 -0
  168. package/dist/esm/api/order-api.js +177 -0
  169. package/dist/esm/api/order-api.js.map +1 -0
  170. package/dist/esm/api/referral-api.d.ts +46 -0
  171. package/dist/esm/api/referral-api.d.ts.map +1 -0
  172. package/dist/esm/api/referral-api.js +49 -0
  173. package/dist/esm/api/referral-api.js.map +1 -0
  174. package/dist/esm/api/root-api.d.ts +15 -0
  175. package/dist/esm/api/root-api.d.ts.map +1 -0
  176. package/dist/esm/api/root-api.js +14 -0
  177. package/dist/esm/api/root-api.js.map +1 -0
  178. package/dist/esm/api/search-api.d.ts +211 -0
  179. package/dist/esm/api/search-api.d.ts.map +1 -0
  180. package/dist/esm/api/search-api.js +108 -0
  181. package/dist/esm/api/search-api.js.map +1 -0
  182. package/dist/esm/api/transaction-api.d.ts +120 -0
  183. package/dist/esm/api/transaction-api.d.ts.map +1 -0
  184. package/dist/esm/api/transaction-api.js +169 -0
  185. package/dist/esm/api/transaction-api.js.map +1 -0
  186. package/dist/esm/api/ws-client.d.ts +22 -0
  187. package/dist/esm/api/ws-client.d.ts.map +1 -0
  188. package/dist/esm/api/ws-client.js +132 -0
  189. package/dist/esm/api/ws-client.js.map +1 -0
  190. package/dist/esm/api/ws-order-client.d.ts +84 -0
  191. package/dist/esm/api/ws-order-client.d.ts.map +1 -0
  192. package/dist/esm/api/ws-order-client.js +444 -0
  193. package/dist/esm/api/ws-order-client.js.map +1 -0
  194. package/dist/esm/bridge/l1-bridge-client.d.ts +49 -0
  195. package/dist/esm/bridge/l1-bridge-client.d.ts.map +1 -0
  196. package/dist/esm/bridge/l1-bridge-client.js +172 -0
  197. package/dist/esm/bridge/l1-bridge-client.js.map +1 -0
  198. package/dist/esm/browser-check.js +33637 -0
  199. package/dist/esm/index.d.ts +94 -0
  200. package/dist/esm/index.d.ts.map +1 -0
  201. package/dist/esm/index.js +100 -0
  202. package/dist/esm/index.js.map +1 -0
  203. package/dist/esm/signer/wasm-signer-client.d.ts +593 -0
  204. package/dist/esm/signer/wasm-signer-client.d.ts.map +1 -0
  205. package/dist/esm/signer/wasm-signer-client.js +2236 -0
  206. package/dist/esm/signer/wasm-signer-client.js.map +1 -0
  207. package/dist/esm/signer/wasm-signer.d.ts +373 -0
  208. package/dist/esm/signer/wasm-signer.d.ts.map +1 -0
  209. package/dist/esm/signer/wasm-signer.js +932 -0
  210. package/dist/esm/signer/wasm-signer.js.map +1 -0
  211. package/dist/esm/types/api.d.ts +198 -0
  212. package/dist/esm/types/api.d.ts.map +1 -0
  213. package/dist/esm/types/api.js +6 -0
  214. package/dist/esm/types/api.js.map +1 -0
  215. package/dist/esm/types/config.d.ts +66 -0
  216. package/dist/esm/types/config.d.ts.map +1 -0
  217. package/dist/esm/types/config.js +6 -0
  218. package/dist/{types → esm/types}/config.js.map +1 -1
  219. package/dist/esm/types/generated/openapi.d.ts +5007 -0
  220. package/dist/esm/types/generated/openapi.d.ts.map +1 -0
  221. package/dist/esm/types/generated/openapi.js +6 -0
  222. package/dist/esm/types/generated/openapi.js.map +1 -0
  223. package/dist/esm/types/index.d.ts +32 -0
  224. package/dist/esm/types/index.d.ts.map +1 -0
  225. package/dist/esm/types/index.js +8 -0
  226. package/dist/esm/types/index.js.map +1 -0
  227. package/dist/esm/types/trading.d.ts +43 -0
  228. package/dist/esm/types/trading.d.ts.map +1 -0
  229. package/dist/esm/types/trading.js +22 -0
  230. package/dist/esm/types/trading.js.map +1 -0
  231. package/dist/esm/types/transaction.d.ts +57 -0
  232. package/dist/esm/types/transaction.d.ts.map +1 -0
  233. package/dist/esm/types/transaction.js +26 -0
  234. package/dist/esm/types/transaction.js.map +1 -0
  235. package/dist/esm/utils/configuration.d.ts +19 -0
  236. package/dist/esm/utils/configuration.d.ts.map +1 -0
  237. package/dist/esm/utils/configuration.js +51 -0
  238. package/dist/esm/utils/configuration.js.map +1 -0
  239. package/dist/esm/utils/environment.d.ts +70 -0
  240. package/dist/esm/utils/environment.d.ts.map +1 -0
  241. package/dist/esm/utils/environment.js +198 -0
  242. package/dist/esm/utils/environment.js.map +1 -0
  243. package/dist/esm/utils/exceptions.d.ts +57 -0
  244. package/dist/esm/utils/exceptions.d.ts.map +1 -0
  245. package/dist/esm/utils/exceptions.js +105 -0
  246. package/dist/esm/utils/exceptions.js.map +1 -0
  247. package/dist/esm/utils/index.d.ts +14 -0
  248. package/dist/esm/utils/index.d.ts.map +1 -0
  249. package/dist/esm/utils/index.js +22 -0
  250. package/dist/esm/utils/index.js.map +1 -0
  251. package/dist/esm/utils/logger.d.ts +35 -0
  252. package/dist/esm/utils/logger.d.ts.map +1 -0
  253. package/dist/esm/utils/logger.js +92 -0
  254. package/dist/esm/utils/logger.js.map +1 -0
  255. package/dist/esm/utils/market-helper.d.ts +62 -0
  256. package/dist/esm/utils/market-helper.d.ts.map +1 -0
  257. package/dist/esm/utils/market-helper.js +96 -0
  258. package/dist/esm/utils/market-helper.js.map +1 -0
  259. package/dist/esm/utils/nonce-cache.d.ts +37 -0
  260. package/dist/esm/utils/nonce-cache.d.ts.map +1 -0
  261. package/dist/esm/utils/nonce-cache.js +132 -0
  262. package/dist/esm/utils/nonce-cache.js.map +1 -0
  263. package/dist/esm/utils/nonce-manager.d.ts +79 -0
  264. package/dist/esm/utils/nonce-manager.d.ts.map +1 -0
  265. package/dist/esm/utils/nonce-manager.js +123 -0
  266. package/dist/esm/utils/nonce-manager.js.map +1 -0
  267. package/dist/esm/utils/order-status-checker.d.ts +29 -0
  268. package/dist/esm/utils/order-status-checker.d.ts.map +1 -0
  269. package/dist/esm/utils/order-status-checker.js +93 -0
  270. package/dist/esm/utils/order-status-checker.js.map +1 -0
  271. package/dist/esm/utils/price-utils.d.ts +86 -0
  272. package/dist/esm/utils/price-utils.d.ts.map +1 -0
  273. package/dist/esm/utils/price-utils.js +206 -0
  274. package/dist/esm/utils/price-utils.js.map +1 -0
  275. package/dist/esm/utils/request-batcher.d.ts +45 -0
  276. package/dist/esm/utils/request-batcher.d.ts.map +1 -0
  277. package/dist/esm/utils/request-batcher.js +161 -0
  278. package/dist/esm/utils/request-batcher.js.map +1 -0
  279. package/dist/examples/examples/cancel_order.js +90 -0
  280. package/dist/examples/examples/create_limit_order.js +213 -0
  281. package/dist/examples/examples/create_market_order.js +191 -0
  282. package/dist/examples/examples/explorer_logs_example.js +228 -0
  283. package/dist/examples/examples/explorer_search_example.js +196 -0
  284. package/dist/examples/examples/market_data.js +183 -0
  285. package/dist/examples/public_pool_deposit.js +67 -0
  286. package/dist/examples/public_pool_info.js +75 -0
  287. package/dist/{api → examples/src/api}/account-api.js +37 -13
  288. package/dist/examples/src/api/announcement-api.js +24 -0
  289. package/dist/{api → examples/src/api}/api-client.js +0 -17
  290. package/dist/examples/src/api/block-api.js +21 -0
  291. package/dist/{api → examples/src/api}/bridge-api.js +0 -1
  292. package/dist/{api → examples/src/api}/candlestick-api.js +5 -3
  293. package/dist/examples/src/api/explorer-api-client.js +127 -0
  294. package/dist/examples/src/api/funding-api.js +24 -0
  295. package/dist/examples/src/api/info-api.js +43 -0
  296. package/dist/examples/src/api/logs-api.js +255 -0
  297. package/dist/{api → examples/src/api}/notification-api.js +0 -1
  298. package/dist/{api → examples/src/api}/order-api.js +41 -9
  299. package/dist/{api → examples/src/api}/referral-api.js +0 -1
  300. package/dist/{api → examples/src/api}/root-api.js +4 -1
  301. package/dist/examples/src/api/search-api.js +111 -0
  302. package/dist/{api → examples/src/api}/transaction-api.js +7 -1
  303. package/dist/{api → examples/src/api}/ws-client.js +0 -1
  304. package/dist/{api → examples/src/api}/ws-order-client.js +1 -1
  305. package/dist/examples/src/bridge/l1-bridge-client.js +175 -0
  306. package/dist/{index.js → examples/src/index.js} +32 -22
  307. package/dist/{signer → examples/src/signer}/wasm-signer-client.js +881 -773
  308. package/dist/{signer → examples/src/signer}/wasm-signer.js +119 -67
  309. package/dist/examples/src/types/api.js +6 -0
  310. package/dist/examples/src/types/config.js +6 -0
  311. package/dist/examples/src/types/generated/openapi.js +6 -0
  312. package/dist/examples/src/types/index.js +23 -0
  313. package/dist/examples/src/types/trading.js +24 -0
  314. package/dist/examples/src/types/transaction.js +28 -0
  315. package/dist/examples/src/utils/configuration.js +54 -0
  316. package/dist/examples/src/utils/environment.js +213 -0
  317. package/dist/examples/src/utils/exceptions.js +122 -0
  318. package/dist/examples/src/utils/logger.js +95 -0
  319. package/dist/examples/src/utils/market-helper.js +99 -0
  320. package/dist/examples/src/utils/nonce-cache.js +135 -0
  321. package/dist/examples/src/utils/nonce-manager.js +129 -0
  322. package/dist/examples/src/utils/order-status-checker.js +98 -0
  323. package/dist/examples/src/utils/price-utils.js +228 -0
  324. package/dist/examples/src/utils/request-batcher.js +167 -0
  325. package/dist/umd/index.html +63 -0
  326. package/dist/umd/lighter-signer.wasm +0 -0
  327. package/dist/umd/lighter-ts-sdk.js +33893 -0
  328. package/dist/umd/lighter-ts-sdk.js.map +7 -0
  329. package/dist/umd/lighter-ts-sdk.min.js +25 -0
  330. package/dist/umd/lighter-ts-sdk.min.js.map +7 -0
  331. package/dist/umd/package.json +13 -0
  332. package/dist/umd/signer-import-check.html +29 -0
  333. package/dist/umd/signer-umd-check.html +29 -0
  334. package/dist/umd/wasm_exec.js +575 -0
  335. package/docs/API.md +11 -26
  336. package/docs/ExplorerApi.md +536 -0
  337. package/docs/GettingStarted.md +91 -50
  338. package/docs/MarginManagement.md +628 -0
  339. package/docs/MarketHelper.md +3 -11
  340. package/docs/MigrationGuide.md +34 -28
  341. package/docs/SignerClient.md +60 -92
  342. package/docs/TransactionApi.md +3 -3
  343. package/docs/TransactionMonitoring.md +520 -0
  344. package/docs/Utilities.md +26 -26
  345. package/docs/WsClient.md +7 -8
  346. package/docs/types/WasmSignerConfig.md +6 -6
  347. package/examples/README.md +52 -57
  348. package/examples/cancel_all_orders.ts +125 -122
  349. package/examples/cancel_order.ts +78 -104
  350. package/examples/change_account_tier.ts +82 -110
  351. package/examples/close_all_positions.ts +405 -411
  352. package/examples/close_position.ts +166 -173
  353. package/examples/create_auth_token.ts +3 -1
  354. package/examples/create_grouped_ioc_with_attached_sl_tp.ts +180 -185
  355. package/examples/create_grouped_orders.ts +205 -203
  356. package/examples/create_limit_order.ts +88 -172
  357. package/examples/create_market_order.ts +124 -177
  358. package/examples/create_market_order_max_slippage.ts +121 -126
  359. package/examples/create_position_tied_sl_tp.ts +210 -215
  360. package/examples/create_subaccount.ts +80 -79
  361. package/examples/create_twap_order.ts +84 -114
  362. package/examples/create_with_multiple_keys.ts +116 -102
  363. package/examples/deposit_to_subaccount.ts +142 -153
  364. package/examples/live_smoke.ts +253 -0
  365. package/examples/margin_eth_add_collateral_http.ts +75 -0
  366. package/examples/margin_eth_remove_collateral_http.ts +76 -0
  367. package/examples/market_data.ts +23 -26
  368. package/examples/modify_order.ts +259 -268
  369. package/examples/multi_client_advanced.ts +3 -1
  370. package/examples/onboarding.ts +3 -1
  371. package/examples/public_pool_deposit.ts +80 -0
  372. package/examples/public_pool_info.ts +83 -0
  373. package/examples/public_pool_operations.ts +152 -171
  374. package/examples/public_pool_withdraw.ts +78 -0
  375. package/examples/revoke_api_key.ts +3 -1
  376. package/examples/send_tx_batch.ts +110 -125
  377. package/examples/spot/README.md +19 -10
  378. package/examples/spot/cancel_spot_order.ts +2 -2
  379. package/examples/spot/create_market_spot_orders.ts +5 -68
  380. package/examples/spot/create_spot_limit_order.ts +3 -3
  381. package/examples/spot/create_spot_limit_order_with_sltp.ts +9 -44
  382. package/examples/spot/create_spot_twap_order.ts +4 -3
  383. package/examples/spot/modify_spot_order.ts +1 -1
  384. package/examples/spot_get_account_assets_http.ts +86 -0
  385. package/examples/system_setup.ts +225 -222
  386. package/examples/transfer_spot_perp.ts +167 -127
  387. package/examples/update_margin.ts +101 -160
  388. package/examples/update_margin_leverage.ts +110 -118
  389. package/examples/withdraw_fast.ts +3 -1
  390. package/examples/withdraw_to_l1.ts +3 -1
  391. package/package.json +33 -23
  392. package/wasm/lighter-signer.wasm +0 -0
  393. package/wasm/wasm_exec.js +575 -0
  394. package/dist/api/account-api.d.ts +0 -148
  395. package/dist/api/account-api.d.ts.map +0 -1
  396. package/dist/api/account-api.js.map +0 -1
  397. package/dist/api/announcement-api.d.ts.map +0 -1
  398. package/dist/api/announcement-api.js.map +0 -1
  399. package/dist/api/api-client.d.ts.map +0 -1
  400. package/dist/api/api-client.js.map +0 -1
  401. package/dist/api/block-api.d.ts.map +0 -1
  402. package/dist/api/block-api.js.map +0 -1
  403. package/dist/api/bridge-api.d.ts.map +0 -1
  404. package/dist/api/bridge-api.js.map +0 -1
  405. package/dist/api/candlestick-api.d.ts.map +0 -1
  406. package/dist/api/candlestick-api.js.map +0 -1
  407. package/dist/api/funding-api.d.ts.map +0 -1
  408. package/dist/api/funding-api.js.map +0 -1
  409. package/dist/api/notification-api.d.ts.map +0 -1
  410. package/dist/api/notification-api.js.map +0 -1
  411. package/dist/api/order-api.d.ts.map +0 -1
  412. package/dist/api/order-api.js.map +0 -1
  413. package/dist/api/referral-api.d.ts.map +0 -1
  414. package/dist/api/referral-api.js.map +0 -1
  415. package/dist/api/root-api.d.ts +0 -8
  416. package/dist/api/root-api.d.ts.map +0 -1
  417. package/dist/api/root-api.js.map +0 -1
  418. package/dist/api/transaction-api.d.ts.map +0 -1
  419. package/dist/api/transaction-api.js.map +0 -1
  420. package/dist/api/ws-client.d.ts.map +0 -1
  421. package/dist/api/ws-client.js.map +0 -1
  422. package/dist/api/ws-order-client.d.ts.map +0 -1
  423. package/dist/api/ws-order-client.js.map +0 -1
  424. package/dist/bridge/l1-bridge-client.d.ts.map +0 -1
  425. package/dist/bridge/l1-bridge-client.js.map +0 -1
  426. package/dist/index.d.ts.map +0 -1
  427. package/dist/index.js.map +0 -1
  428. package/dist/signer/rust-wasm-adapter.d.ts +0 -99
  429. package/dist/signer/rust-wasm-adapter.d.ts.map +0 -1
  430. package/dist/signer/rust-wasm-adapter.js +0 -186
  431. package/dist/signer/rust-wasm-adapter.js.map +0 -1
  432. package/dist/signer/wasm-signer-client.d.ts.map +0 -1
  433. package/dist/signer/wasm-signer-client.js.map +0 -1
  434. package/dist/signer/wasm-signer.d.ts.map +0 -1
  435. package/dist/signer/wasm-signer.js.map +0 -1
  436. package/dist/types/api.d.ts.map +0 -1
  437. package/dist/types/api.js.map +0 -1
  438. package/dist/types/config.d.ts.map +0 -1
  439. package/dist/types/generated/openapi.d.ts.map +0 -1
  440. package/dist/types/generated/openapi.js.map +0 -1
  441. package/dist/types/index.d.ts.map +0 -1
  442. package/dist/types/index.js.map +0 -1
  443. package/dist/types/trading.d.ts.map +0 -1
  444. package/dist/types/trading.js.map +0 -1
  445. package/dist/types/transaction.d.ts.map +0 -1
  446. package/dist/types/transaction.js.map +0 -1
  447. package/dist/utils/configuration.d.ts.map +0 -1
  448. package/dist/utils/configuration.js.map +0 -1
  449. package/dist/utils/detect-environment.d.ts +0 -59
  450. package/dist/utils/detect-environment.d.ts.map +0 -1
  451. package/dist/utils/detect-environment.js +0 -133
  452. package/dist/utils/detect-environment.js.map +0 -1
  453. package/dist/utils/exceptions.d.ts.map +0 -1
  454. package/dist/utils/exceptions.js.map +0 -1
  455. package/dist/utils/index.d.ts.map +0 -1
  456. package/dist/utils/index.js.map +0 -1
  457. package/dist/utils/logger.d.ts.map +0 -1
  458. package/dist/utils/logger.js.map +0 -1
  459. package/dist/utils/market-helper.d.ts.map +0 -1
  460. package/dist/utils/market-helper.js.map +0 -1
  461. package/dist/utils/nonce-cache.d.ts.map +0 -1
  462. package/dist/utils/nonce-cache.js.map +0 -1
  463. package/dist/utils/nonce-manager.d.ts.map +0 -1
  464. package/dist/utils/nonce-manager.js.map +0 -1
  465. package/dist/utils/order-status-checker.d.ts.map +0 -1
  466. package/dist/utils/order-status-checker.js.map +0 -1
  467. package/dist/utils/price-utils.d.ts.map +0 -1
  468. package/dist/utils/price-utils.js.map +0 -1
  469. package/dist/utils/request-batcher.d.ts.map +0 -1
  470. package/dist/utils/request-batcher.js.map +0 -1
  471. package/dist/utils/transaction-types.d.ts +0 -36
  472. package/dist/utils/transaction-types.d.ts.map +0 -1
  473. package/dist/utils/transaction-types.js +0 -71
  474. package/dist/utils/transaction-types.js.map +0 -1
  475. package/examples/market_position.ts +0 -132
  476. package/examples/public_pool_burn_shares.ts +0 -89
  477. package/examples/public_pool_mint_shares.ts +0 -89
  478. package/examples/utils/account-helper.ts +0 -80
  479. package/examples/ws.ts +0 -50
  480. package/examples/ws_async.ts +0 -112
  481. package/examples/ws_ping_pong.ts +0 -267
  482. package/examples/ws_send_batch_tx.ts +0 -203
  483. package/examples/ws_send_tx.ts +0 -196
  484. package/lighter-wasm/BUILD.md +0 -252
  485. package/lighter-wasm/README.md +0 -218
  486. package/lighter-wasm/package.json +0 -53
  487. /package/dist/{api → cjs/api}/announcement-api.d.ts +0 -0
  488. /package/dist/{api → cjs/api}/announcement-api.js +0 -0
  489. /package/dist/{api → cjs/api}/api-client.d.ts +0 -0
  490. /package/dist/{api → cjs/api}/block-api.d.ts +0 -0
  491. /package/dist/{api → cjs/api}/block-api.js +0 -0
  492. /package/dist/{api → cjs/api}/funding-api.d.ts +0 -0
  493. /package/dist/{api → cjs/api}/funding-api.js +0 -0
  494. /package/dist/{bridge → cjs/bridge}/l1-bridge-client.d.ts +0 -0
  495. /package/dist/{bridge → cjs/bridge}/l1-bridge-client.js +0 -0
  496. /package/dist/{types → cjs/types}/api.js +0 -0
  497. /package/dist/{types → cjs/types}/config.d.ts +0 -0
  498. /package/dist/{types → cjs/types}/config.js +0 -0
  499. /package/dist/{types → cjs/types}/generated/openapi.d.ts +0 -0
  500. /package/dist/{types → cjs/types}/generated/openapi.js +0 -0
  501. /package/dist/{types → cjs/types}/index.d.ts +0 -0
  502. /package/dist/{types → cjs/types}/index.js +0 -0
  503. /package/dist/{types → cjs/types}/trading.d.ts +0 -0
  504. /package/dist/{types → cjs/types}/trading.js +0 -0
  505. /package/dist/{types → cjs/types}/transaction.d.ts +0 -0
  506. /package/dist/{types → cjs/types}/transaction.js +0 -0
  507. /package/dist/{utils → cjs/utils}/configuration.d.ts +0 -0
  508. /package/dist/{utils → cjs/utils}/configuration.js +0 -0
  509. /package/dist/{utils → cjs/utils}/exceptions.d.ts +0 -0
  510. /package/dist/{utils → cjs/utils}/exceptions.js +0 -0
  511. /package/dist/{utils → cjs/utils}/index.d.ts +0 -0
  512. /package/dist/{utils → cjs/utils}/index.js +0 -0
  513. /package/dist/{utils → cjs/utils}/logger.d.ts +0 -0
  514. /package/dist/{utils → cjs/utils}/logger.js +0 -0
  515. /package/dist/{utils → cjs/utils}/market-helper.d.ts +0 -0
  516. /package/dist/{utils → cjs/utils}/market-helper.js +0 -0
  517. /package/dist/{utils → cjs/utils}/nonce-cache.d.ts +0 -0
  518. /package/dist/{utils → cjs/utils}/nonce-cache.js +0 -0
  519. /package/dist/{utils → cjs/utils}/nonce-manager.d.ts +0 -0
  520. /package/dist/{utils → cjs/utils}/nonce-manager.js +0 -0
  521. /package/dist/{utils → cjs/utils}/order-status-checker.d.ts +0 -0
  522. /package/dist/{utils → cjs/utils}/order-status-checker.js +0 -0
  523. /package/dist/{utils → cjs/utils}/price-utils.d.ts +0 -0
  524. /package/dist/{utils → cjs/utils}/price-utils.js +0 -0
  525. /package/dist/{utils → cjs/utils}/request-batcher.d.ts +0 -0
  526. /package/dist/{utils → cjs/utils}/request-batcher.js +0 -0
package/README.md CHANGED
@@ -2,54 +2,18 @@
2
2
 
3
3
  A complete TypeScript SDK for Lighter Protocol - trade perpetual futures with built-in stop-loss and take-profit orders, position management, and comprehensive error handling.
4
4
 
5
- ## Status Overview
5
+ ## 🔐 Signer Integration
6
6
 
7
- | Component | Status | Notes |
8
- |-----------|--------|-------|
9
- | **Node.js** | Supported | Ready for production use |
10
- | **Browser (Chrome/Firefox/Safari)** | Supported | Uses Rust WASM in browser |
11
- | **WASM Cryptography** | Verified | Optimized Rust WASM signer |
12
- | **Documentation** | Complete | Setup guides included |
13
-
14
- ---
15
-
16
- ## Quick Navigation
17
-
18
- - **[Get Started Quickly](#quick-start)** - 5 minutes (both Node.js & Browser)
19
- - **[Node.js Setup](#nodejs-setup)** - Install, configure, and verify
20
- - **[Browser Setup](#browser-setup)** - Vite, HTTP server, or Webpack
21
- - **Testing** - Not included in release build
22
- - **[Core Concepts](#-core-concepts)** - API reference and examples
23
-
24
- ---
25
-
26
- ## Signer Integration
27
-
28
- This SDK uses **Rust WASM** for cryptographic signing operations, providing:
7
+ This SDK uses a WASM signer for cryptographic operations. The signer is compiled during the build process.
29
8
 
30
9
  **Key Features:**
31
- - **99% smaller binary size** (136 KB vs 13.5 MB)
32
- - **7x faster initialization** (1.4 ms vs 10+ ms)
33
- - **Optimized signatures** (0.67 ms per signature)
34
- - **Production-ready** with verified mainnet transactions
35
- - Support for all transaction types
36
- - Multiple API key support
37
- - Automatic error recovery and nonce management
38
-
39
- ### Rust WASM Performance
40
-
41
- | Metric | Value |
42
- |--------|-------|
43
- | **Binary Size** | 136 KB |
44
- | **Initialization** | ~1.4 ms |
45
- | **Per Signature** | ~0.67 ms |
46
- | **API Coverage** | 100% |
10
+ - Uses a WASM signer for transaction signing
11
+ - Automatic error recovery and nonce management
12
+ - Support for all transaction types
13
+ - Multiple API key support
14
+ - Production-ready and battle-tested
47
15
 
48
- **Architecture**: The SDK uses a single **Rust WASM** signer for all cryptographic operations in both Node.js and Browser environments.
49
-
50
- For detailed information, see [lighter-wasm/README.md](./lighter-wasm/README.md)
51
-
52
- ## Installation
16
+ ## 📦 Installation
53
17
 
54
18
  ```bash
55
19
  npm install lighter-ts-sdk
@@ -57,323 +21,10 @@ npm install lighter-ts-sdk
57
21
  yarn add lighter-ts-sdk
58
22
  ```
59
23
 
60
- ## Quick Start
61
-
62
- ### Node.js (5 minutes)
63
-
64
- ```bash
65
- # 1. Install
66
- npm install lighter-ts-sdk
67
-
68
- # 2. Create .env
69
- echo "API_PRIVATE_KEY=your_key_here" > .env
70
-
71
- # 3. Use
72
- ```
73
-
74
- ```typescript
75
- import { SignerClient } from 'lighter-ts-sdk';
76
-
77
- const client = new SignerClient({
78
- url: 'https://mainnet.zklighter.elliot.ai',
79
- privateKey: process.env.API_PRIVATE_KEY!,
80
- accountIndex: 0,
81
- apiKeyIndex: 0
82
- });
83
-
84
- await client.initialize();
85
-
86
- // Create an order
87
- const [tx, hash, error] = await client.createOrder({
88
- marketIndex: 0,
89
- baseAmount: 10000,
90
- isAsk: false
91
- });
92
-
93
- console.log(error ? 'Failed' : 'Order created:', hash);
94
- ```
95
-
96
- ### Browser (5 minutes)
97
-
98
- ```bash
99
- # 1. Start WASM server
100
- npm run serve:wasm
101
-
102
- # 2. Create HTML
103
- ```
104
-
105
- ```html
106
- <!DOCTYPE html>
107
- <html>
108
- <head><title>Trading</title></head>
109
- <body>
110
- <h1>Trading with WASM</h1>
111
- <button onclick="signOrder()">Sign Order</button>
112
-
113
- <script type="module">
114
- import init, { SignerInstance } from 'http://localhost:8080/signer_wasm.js';
115
-
116
- await init('http://localhost:8080/signer_wasm_bg.wasm');
117
-
118
- window.signer = new SignerInstance('YOUR_PRIVATE_KEY');
119
- window.signOrder = () => {
120
- const sig = window.signer.signCreateOrder('{"action":"create_order"}');
121
- console.log('Signed:', sig);
122
- };
123
- </script>
124
- </body>
125
- </html>
126
- ```
127
-
128
- ---
129
-
130
- ## 🌐 Environment Setup Guide
131
-
132
- ### Node.js Setup
133
-
134
- **1. Install the SDK**
135
-
136
- ```bash
137
- npm install lighter-ts-sdk
138
- ```
139
-
140
- **2. Create `.env` file**
141
-
142
- ```bash
143
- cp .env.example .env
144
- ```
145
-
146
- Then edit `.env` with your values:
147
-
148
- ```bash
149
- API_PRIVATE_KEY=your_80_character_hex_private_key
150
- ACCOUNT_INDEX=0
151
- API_KEY_INDEX=0
152
- BASE_URL=https://mainnet.zklighter.elliot.ai
153
- ```
154
-
155
- **3. Initialize the client**
156
-
157
- ```typescript
158
- import { SignerClient } from 'lighter-ts-sdk';
159
- import dotenv from 'dotenv';
160
-
161
- dotenv.config();
162
-
163
- const signerClient = new SignerClient({
164
- url: process.env.BASE_URL!,
165
- privateKey: process.env.API_PRIVATE_KEY!,
166
- accountIndex: parseInt(process.env.ACCOUNT_INDEX!),
167
- apiKeyIndex: parseInt(process.env.API_KEY_INDEX!)
168
- });
169
-
170
- // Initialize WASM signer (required for cryptographic operations)
171
- await signerClient.initialize();
172
- await signerClient.ensureWasmClient();
173
-
174
- console.log('Client initialized with WASM signer');
175
- ```
176
-
177
- **4. Use the client**
178
-
179
- ```typescript
180
- // Create an order
181
- const [tx, hash, error] = await signerClient.createOrder({
182
- marketIndex: 0,
183
- clientOrderIndex: Date.now(),
184
- baseAmount: 10000,
185
- isAsk: false
186
- });
187
-
188
- if (!error) {
189
- console.log('Order created:', hash);
190
- await signerClient.waitForTransaction(hash);
191
- }
192
- ```
193
-
194
- **WASM in Node.js:**
195
- - Location: `wasm/rust-nodejs/`
196
- - Automatically initialized when using `SignerClient`
197
- - Direct access: `require('./wasm/rust-nodejs/signer_wasm.js')`
198
-
199
- ---
200
-
201
- ### Browser Setup
202
-
203
- **Option 1: Using Vite/React/Vue**
204
-
205
- ```bash
206
- # 1. Create your frontend app
207
- npm create vite@latest my-app -- --template react
208
- cd my-app
209
- npm install
210
-
211
- # 2. Copy WASM files
212
- cp -r node_modules/lighter-ts-sdk/wasm/rust-web public/wasm
213
-
214
- # 3. Create your trading component
215
- ```
216
-
217
- ```typescript
218
- // src/pages/Trade.tsx
219
- import { useEffect, useState } from 'react';
220
-
221
- export function Trade() {
222
- const [signer, setSigner] = useState<any>(null);
223
- const [publicKey, setPublicKey] = useState<string>('');
224
-
225
- useEffect(() => {
226
- async function initWasm() {
227
- // Load WASM module
228
- const wasmModule = await import('/wasm/signer_wasm.js');
229
-
230
- // Initialize WASM
231
- await wasmModule.default('/wasm/signer_wasm_bg.wasm');
232
-
233
- // Create signer instance
234
- const signerInstance = new wasmModule.SignerInstance(
235
- process.env.REACT_APP_PRIVATE_KEY!
236
- );
237
-
238
- setSigner(signerInstance);
239
- setPublicKey(signerInstance.getPublicKey());
240
- }
241
-
242
- initWasm().catch(console.error);
243
- }, []);
244
-
245
- const signOrder = () => {
246
- if (!signer) return;
247
-
248
- const orderData = {
249
- action: 'create_order',
250
- symbol: 'BTC-USD',
251
- side: 'BUY',
252
- quantity: 1,
253
- timestamp: Date.now()
254
- };
255
-
256
- const signature = signer.signCreateOrder(JSON.stringify(orderData));
257
- console.log('Order signed:', signature);
258
- };
259
-
260
- return (
261
- <div>
262
- <h1>Trading App</h1>
263
- <p>Account: {publicKey?.substring(0, 20)}...</p>
264
- <button onClick={signOrder}>Sign Order</button>
265
- </div>
266
- );
267
- }
268
- ```
269
-
270
- **4. Serve with `vite` (has correct MIME types)**
271
-
272
- ```bash
273
- npm run dev
274
- ```
275
-
276
- ---
277
-
278
- **Option 2: Manual HTTP Server**
279
-
280
- ```bash
281
- # Start the included HTTP server
282
- npm run serve:wasm
283
-
284
- # Output:
285
- # WASM HTTP Server
286
- # Server: http://localhost:8080
287
- # WASM Directory: .../wasm/rust-web
288
- ```
289
-
290
- Then load in your HTML:
291
-
292
- ```html
293
- <!DOCTYPE html>
294
- <html>
295
- <head>
296
- <title>Trading App</title>
297
- </head>
298
- <body>
299
- <h1>Trading with WASM</h1>
300
- <div id="status">Loading WASM...</div>
301
- <div id="account">Account: -</div>
302
- <button onclick="signOrder()">Sign Order</button>
303
-
304
- <script type="module">
305
- import init, { SignerInstance } from 'http://localhost:8080/signer_wasm.js';
306
-
307
- // Initialize WASM
308
- await init('http://localhost:8080/signer_wasm_bg.wasm');
309
-
310
- // Create signer
311
- window.signer = new SignerInstance('YOUR_80_HEX_PRIVATE_KEY');
312
- const publicKey = window.signer.getPublicKey();
313
-
314
- document.getElementById('status').textContent = 'WASM Ready';
315
- document.getElementById('account').textContent = `Account: ${publicKey.substring(0, 20)}...`;
316
-
317
- window.signOrder = function() {
318
- const orderData = {
319
- action: 'create_order',
320
- symbol: 'BTC-USD',
321
- side: 'BUY',
322
- quantity: 1,
323
- timestamp: Date.now()
324
- };
325
-
326
- const signature = window.signer.signCreateOrder(JSON.stringify(orderData));
327
- console.log('Signed:', signature);
328
- alert('Order signed! Check console.');
329
- };
330
- </script>
331
- </body>
332
- </html>
333
- ```
334
-
335
- **Option 3: Using Webpack/Rollup**
336
-
337
- 1. Copy `wasm/rust-web/` to your public assets
338
- 2. Configure your bundler to handle `.wasm` files:
339
-
340
- ```javascript
341
- // webpack.config.js
342
- module.exports = {
343
- module: {
344
- rules: [
345
- {
346
- test: /\.wasm$/,
347
- type: 'webassembly/async',
348
- },
349
- ],
350
- },
351
- };
352
- ```
353
-
354
- **WASM in Browser:**
355
- - Location: `wasm/rust-web/`
356
- - Must be served over HTTP (not file://)
357
- - Server must send `Content-Type: application/wasm`
358
- - Direct WASM file: `signer_wasm_bg.wasm`
359
- - JS bindings: `signer_wasm.js`
360
- - TypeScript definitions: `signer_wasm.d.ts`
361
-
362
- ---
363
-
364
- ### Troubleshooting
365
-
366
- | Issue | Solution |
367
- |-------|----------|
368
- | **"Cannot load WASM from file://"** | Use HTTP server: `npm run serve:wasm` |
369
- | **"WASM not found 404"** | Verify `wasm/rust-web/` exists; run `npm run build:wasm` |
370
- | **"Wrong MIME type"** | Ensure server sends `Content-Type: application/wasm` for `.wasm` files |
371
- | **Import errors in browser** | Use correct import paths; check module exports |
372
- | **Signature mismatch** | Ensure same private key used in both environments |
373
- ## What Does This SDK Do?
24
+ ## 🚀 What Does This SDK Do?
374
25
 
375
26
  The Lighter TypeScript SDK provides everything you need to:
376
- - **Trade perpetual futures** on Lighter Protocol
27
+ - **Trade perpetual futures and SPOT Markets** on Lighter Protocol
377
28
  - **Create orders** (Market, Limit, TWAP) with automatic SL/TP
378
29
  - **Manage positions** (open, close, update leverage)
379
30
  - **Transfer funds** between accounts
@@ -426,26 +77,42 @@ async function placeOrder() {
426
77
  await signerClient.initialize();
427
78
  await signerClient.ensureWasmClient();
428
79
 
429
- // Create an order
430
- const result = await signerClient.createOrder({
431
- marketIndex: 0,
432
- clientOrderIndex: Date.now(),
433
- baseAmount: 10000,
434
- isAsk: false,
435
- orderType: OrderType.MARKET
80
+ // Create a market order with SL/TP using OTOCO
81
+ const result = await signerClient.createOtocoOrder({
82
+ mainOrder: {
83
+ marketIndex: 0, // ETH market
84
+ clientOrderIndex: Date.now(), // Unique ID
85
+ baseAmount: 10000, // 0.01 ETH (scaled: 1 ETH = 1,000,000)
86
+ isAsk: false, // BUY (true = SELL)
87
+ orderType: OrderType.MARKET,
88
+
89
+ // Slippage protection
90
+ idealPrice: 400000, // Ideal price ($4000)
91
+ maxSlippage: 0.001 // Max 0.1% slippage
92
+ },
93
+ // Automatic stop-loss
94
+ stopLoss: {
95
+ triggerPrice: 380000, // Stop loss at $3800
96
+ isLimit: false // Market SL
97
+ },
98
+ // Automatic take-profit
99
+ takeProfit: {
100
+ triggerPrice: 420000, // Take profit at $4200
101
+ isLimit: false // Market TP
102
+ }
436
103
  });
437
104
 
438
105
  // Check if order succeeded
439
- if (result[2]) {
440
- console.error('Order failed:', result[2]);
106
+ if (result.error || !result.hash) {
107
+ console.error('Order failed:', result.error);
441
108
  return;
442
109
  }
443
110
 
444
- console.log('Order created');
445
- console.log('Order hash:', result[1]);
111
+ console.log(' OTOCO order created!');
112
+ console.log('Grouped order hash:', result.hash);
446
113
 
447
114
  // Wait for transaction confirmation
448
- await signerClient.waitForTransaction(result[1], 30000);
115
+ await signerClient.waitForTransaction(result.hash, 30000);
449
116
 
450
117
  await signerClient.close();
451
118
  }
@@ -501,20 +168,214 @@ takeProfit: {
501
168
 
502
169
  **Note for TWAP orders**: TWAP orders execute over time, creating positions gradually. SL/TP cannot be created in the same batch as TWAP orders. You should create SL/TP orders separately after the TWAP has started creating positions.
503
170
 
504
- ## Common Operations
171
+ ## 🌐 Network-Aware Transaction Status Monitoring
172
+
173
+ Lighter Protocol transactions go through multiple network states. Use `waitForTransaction()` to monitor status changes with automatic error handling and recovery:
174
+
175
+ ```typescript
176
+ // Transaction status constants
177
+ enum TransactionStatus {
178
+ PENDING = 0, // Initial state, not yet queued
179
+ QUEUED = 1, // Queued for processing
180
+ COMMITTED = 2, // Committed to block
181
+ EXECUTED = 3, // Successfully executed
182
+ FAILED = 4, // Execution failed
183
+ REJECTED = 5 // Transaction rejected
184
+ }
185
+
186
+ // Monitor transaction with built-in retry logic
187
+ try {
188
+ const txResult = await signerClient.waitForTransaction(
189
+ txHash,
190
+ 30000, // maxWaitTime: wait up to 30 seconds
191
+ 2000 // pollInterval: check status every 2 seconds
192
+ );
193
+
194
+ console.log('Status:', txResult.status); // Will be EXECUTED (3) if successful
195
+ console.log('✅ Transaction confirmed on-chain');
196
+ } catch (error) {
197
+ // Error handling is centralized here
198
+ if (error.message.includes('timeout')) {
199
+ console.error('❌ Transaction didn\'t confirm within timeout');
200
+ } else if (error.message.includes('FAILED') || error.message.includes('REJECTED')) {
201
+ console.error('❌ Transaction failed:', error.message);
202
+ } else {
203
+ console.error('❌ Unexpected error:', error.message);
204
+ }
205
+ }
206
+
207
+ // Advanced: Manual status polling for fine-grained control
208
+ const checkStatus = async (hash: string) => {
209
+ const txResult = await signerClient.getTransaction(hash);
210
+
211
+ switch (txResult.status) {
212
+ case SignerClient.TX_STATUS_PENDING:
213
+ console.log('⏳ Still pending...');
214
+ break;
215
+ case SignerClient.TX_STATUS_QUEUED:
216
+ console.log('📋 Queued for processing');
217
+ break;
218
+ case SignerClient.TX_STATUS_COMMITTED:
219
+ console.log('✍️ Committed to block');
220
+ break;
221
+ case SignerClient.TX_STATUS_EXECUTED:
222
+ console.log('✅ Transaction executed successfully');
223
+ break;
224
+ case SignerClient.TX_STATUS_FAILED:
225
+ console.error('❌ Transaction execution failed');
226
+ break;
227
+ case SignerClient.TX_STATUS_REJECTED:
228
+ console.error('❌ Transaction was rejected');
229
+ break;
230
+ }
231
+
232
+ return txResult;
233
+ };
234
+
235
+ // Pattern: Fire-and-forget with error handling
236
+ const result = await signerClient.createOrder(orderParams);
237
+ if (result.hash) {
238
+ // Schedule async confirmation check (don't block)
239
+ signerClient.waitForTransaction(result.hash, 60000).catch(err => {
240
+ console.error('Transaction confirmation failed:', err);
241
+ // Handle error (alert user, retry, etc.)
242
+ });
243
+ }
244
+ ```
245
+
246
+ **Key Points:**
247
+ - `waitForTransaction()` centralizes error handling and automatic retries
248
+ - No need to parse transaction status manually after wait
249
+ - Throw errors are detected and propagated with context
250
+ - Use timeout to prevent indefinite waits in production systems
251
+
252
+ ## 💰 Margin Management with Direction Constants
253
+
254
+ Lighter Protocol supports both cross-margin and isolated-margin modes. Margin direction constants determine whether you're adding or removing collateral:
255
+
256
+ ### Margin Mode Constants
257
+
258
+ ```typescript
259
+ // Margin mode
260
+ SignerClient.CROSS_MARGIN_MODE = 0 // Shared collateral across markets
261
+ SignerClient.ISOLATED_MARGIN_MODE = 1 // Per-market collateral
262
+
263
+ // Margin direction (when updating isolated margin)
264
+ SignerClient.ISOLATED_MARGIN_REMOVE_COLLATERAL = 0 // Remove collateral from position
265
+ SignerClient.ISOLATED_MARGIN_ADD_COLLATERAL = 1 // Add collateral to position
266
+ ```
267
+
268
+ ### Adding Margin (Collateral) to Isolated Position
269
+
270
+ ```typescript
271
+ // Add 100 USDC collateral to ETH position in isolated mode
272
+ const [marginInfo, txHash, error] = await signerClient.updateMargin(
273
+ 0, // marketIndex: 0 = ETH/USDC
274
+ 100, // usdcAmount: 100 USDC to add
275
+ SignerClient.ISOLATED_MARGIN_ADD_COLLATERAL // direction: 1
276
+ );
277
+
278
+ if (error) {
279
+ console.error('Failed to add margin:', error);
280
+ } else {
281
+ console.log('✅ Margin added:', txHash);
282
+
283
+ // Wait for confirmation
284
+ await signerClient.waitForTransaction(txHash, 30000);
285
+ console.log('✅ Margin update confirmed');
286
+ }
287
+ ```
288
+
289
+ ### Removing Margin (Collateral) from Isolated Position
290
+
291
+ ```typescript
292
+ // Remove 50 USDC collateral from ETH position
293
+ const [marginInfo, txHash, error] = await signerClient.updateMargin(
294
+ 0, // marketIndex: 0 = ETH/USDC
295
+ 50, // usdcAmount: 50 USDC to remove
296
+ SignerClient.ISOLATED_MARGIN_REMOVE_COLLATERAL // direction: 0
297
+ );
298
+
299
+ if (error) {
300
+ console.error('Failed to remove margin:', error);
301
+ } else {
302
+ console.log('✅ Margin removed:', txHash);
303
+
304
+ // Wait for confirmation
305
+ await signerClient.waitForTransaction(txHash, 30000);
306
+ console.log('✅ Margin removal confirmed');
307
+ }
308
+ ```
309
+
310
+ ### Cross-Margin vs Isolated-Margin Workflows
311
+
312
+ ```typescript
313
+ // === CROSS-MARGIN MODE ===
314
+ // Step 1: Update leverage to cross-margin
315
+ const [crossInfo1, crossHash1, crossErr1] = await signerClient.updateLeverage(
316
+ 0, // marketIndex
317
+ SignerClient.CROSS_MARGIN_MODE, // mode: 0
318
+ 5 // leverage: 5x
319
+ );
320
+
321
+ // Step 2: Create order (no margin updates needed - uses account balance)
322
+ const result = await signerClient.createMarketOrder({
323
+ marketIndex: 0,
324
+ baseAmount: 10000,
325
+ isAsk: false
326
+ });
327
+
328
+ // === ISOLATED-MARGIN MODE ===
329
+ // Step 1: Update leverage to isolated-margin
330
+ const [isolatedInfo1, isolatedHash1, isolatedErr1] = await signerClient.updateLeverage(
331
+ 0, // marketIndex
332
+ SignerClient.ISOLATED_MARGIN_MODE, // mode: 1
333
+ 20 // leverage: 20x (IMF = 10000/20 = 500)
334
+ );
335
+
336
+ // Step 2: Create order
337
+ const result = await signerClient.createMarketOrder({
338
+ marketIndex: 0,
339
+ baseAmount: 10000,
340
+ isAsk: false
341
+ });
342
+
343
+ // Step 3: Manage collateral dynamically
344
+ // Add more collateral if position grows risky
345
+ await signerClient.updateMargin(
346
+ 0,
347
+ 200, // Add 200 USDC
348
+ SignerClient.ISOLATED_MARGIN_ADD_COLLATERAL
349
+ );
350
+
351
+ // Remove collateral if position has buffer
352
+ await signerClient.updateMargin(
353
+ 0,
354
+ 100, // Remove 100 USDC
355
+ SignerClient.ISOLATED_MARGIN_REMOVE_COLLATERAL
356
+ );
357
+ ```
358
+
359
+ **Important:**
360
+ - Cross-margin pools collateral across all markets
361
+ - Isolated margin requires explicit collateral management per-market
362
+ - `direction` parameter is only used for isolated-margin positions
363
+ - Always verify sufficient collateral before removing it
364
+
365
+ ## �🔧 Common Operations
505
366
 
506
367
  ### Create a Market Order
507
368
 
508
369
  ```typescript
509
- const [tx, hash, error] = await signerClient.createOrder({
370
+ const [tx, hash, error] = await signerClient.createMarketOrder({
510
371
  marketIndex: 0,
511
372
  clientOrderIndex: Date.now(),
512
- baseAmount: 10000,
513
- isAsk: false,
514
- orderType: OrderType.MARKET
373
+ baseAmount: 10000, // Amount (0.01 ETH)
374
+ avgExecutionPrice: 400000, // Max execution price ($4000)
375
+ isAsk: false // BUY
515
376
  });
516
377
 
517
- if (error) {
378
+ if (error || !hash) {
518
379
  console.error('Failed:', error);
519
380
  return;
520
381
  }
@@ -526,16 +387,20 @@ if (error) {
526
387
  const [tx, hash, error] = await signerClient.createOrder({
527
388
  marketIndex: 0,
528
389
  clientOrderIndex: Date.now(),
529
- baseAmount: 10000,
530
- price: 400000,
531
- isAsk: false,
390
+ baseAmount: 10000, // Amount (0.01 ETH)
391
+ price: 400000, // Limit price ($4000)
392
+ isAsk: false, // BUY
532
393
  orderType: OrderType.LIMIT,
533
- orderExpiry: Date.now() + (60 * 60 * 1000)
394
+ orderExpiry: Date.now() + (60 * 60 * 1000) // Expires in 1 hour
534
395
  });
535
396
 
536
- if (!error) {
537
- await signerClient.waitForTransaction(hash);
397
+ if (error || !hash) {
398
+ console.error('Failed:', error);
399
+ return;
538
400
  }
401
+
402
+ // Wait for it to fill
403
+ await signerClient.waitForTransaction(hash);
539
404
  ```
540
405
 
541
406
  ### Cancel an Order
@@ -552,7 +417,7 @@ if (error) {
552
417
  }
553
418
 
554
419
  await signerClient.waitForTransaction(hash);
555
- console.log('Order cancelled');
420
+ console.log('Order cancelled');
556
421
  ```
557
422
 
558
423
  ### Close a Position
@@ -573,7 +438,7 @@ if (error) {
573
438
  }
574
439
 
575
440
  await signerClient.waitForTransaction(hash);
576
- console.log('Position closed');
441
+ console.log('Position closed');
577
442
  ```
578
443
 
579
444
  ### Check Order Status
@@ -589,12 +454,15 @@ console.log('Status:', status.status); // 0=pending, 1=queued, 2=committed, 3=ex
589
454
 
590
455
  #### Order Management
591
456
  ```typescript
457
+ // Create an OTOCO order (entry + SL + TP)
458
+ createOtocoOrder(params) -> Promise<{ tx, hash, error }>
459
+
460
+ // Create an OCO order (one cancels other)
461
+ createOcoOrder(params) -> Promise<{ tx, hash, error }>
462
+
592
463
  // Create a single order
593
464
  createOrder(params) -> Promise<[txInfo, txHash, error]>
594
465
 
595
- // Create multiple orders (OTOCO, OTOMA, or OTOTCO grouping)
596
- createGroupedOrders(groupingType, orders) -> Promise<[txInfo, txHash, error]>
597
-
598
466
  // Cancel a specific order
599
467
  cancelOrder(params) -> Promise<[txInfo, txHash, error]>
600
468
 
@@ -623,44 +491,54 @@ waitForTransaction(txHash, maxWaitTime, pollInterval) -> Promise<Transaction>
623
491
  ### Order Parameters
624
492
 
625
493
  ```typescript
626
- interface UnifiedOrderParams {
627
- marketIndex: number; // Market ID (0 = ETH)
628
- clientOrderIndex: number; // Unique ID (use Date.now())
629
- baseAmount: number; // Amount in units (1 ETH = 1,000,000)
630
- isAsk: boolean; // true = SELL, false = BUY
631
- orderType: OrderType; // MARKET, LIMIT, or TWAP
632
-
633
- // For market orders
634
- idealPrice?: number; // Target price
635
- maxSlippage?: number; // Max slippage (e.g., 0.001 = 0.1%)
636
-
637
- // For limit orders
638
- price?: number; // Limit price
639
-
640
- // Optional SL/TP (automatically reduce-only)
641
- stopLoss?: {
494
+ // For OTOCO orders (entry + SL/TP)
495
+ interface OtocoOrderParams {
496
+ mainOrder: {
497
+ marketIndex: number; // Market ID (0 = ETH)
498
+ baseAmount: number; // Amount in units
499
+ isAsk: boolean; // true = SELL, false = BUY
500
+ orderType: OrderType.LIMIT | OrderType.MARKET;
501
+ price?: number; // For LIMIT orders
502
+ avgExecutionPrice?: number; // For MARKET orders
503
+ maxSlippage?: number; // Max slippage (0.001 = 0.1%)
504
+ idealPrice?: number; // Target price
505
+ };
506
+ stopLoss: {
642
507
  triggerPrice: number;
508
+ price?: number;
643
509
  isLimit?: boolean;
644
510
  };
645
- takeProfit?: {
511
+ takeProfit: {
646
512
  triggerPrice: number;
513
+ price?: number;
647
514
  isLimit?: boolean;
648
515
  };
649
-
650
- // Optional
651
- orderExpiry?: number; // Expiry timestamp (milliseconds)
516
+ nonce?: number;
517
+ }
518
+
519
+ // For single orders
520
+ interface CreateOrderParams {
521
+ marketIndex: number;
522
+ clientOrderIndex: number;
523
+ baseAmount: number;
524
+ price: number;
525
+ isAsk: boolean;
526
+ orderType?: OrderType;
527
+ timeInForce?: TimeInForce;
528
+ reduceOnly?: boolean;
529
+ orderExpiry?: number;
652
530
  }
653
531
  ```
654
532
 
655
- ## Tips for Beginners
533
+ ## 💡 Tips for Beginners
656
534
 
657
535
  ### 1. Always Use Environment Variables
658
536
 
659
537
  ```typescript
660
- // Do not hardcode credentials
538
+ // DON'T hardcode credentials
661
539
  const privateKey = '0xabc123...';
662
540
 
663
- // Use environment variables
541
+ // DO use environment variables
664
542
  const privateKey = process.env.API_PRIVATE_KEY;
665
543
  ```
666
544
 
@@ -670,13 +548,16 @@ const privateKey = process.env.API_PRIVATE_KEY;
670
548
  try {
671
549
  const [tx, hash, error] = await signerClient.createOrder(params);
672
550
 
673
- if (error) {
551
+ if (error || !hash) {
674
552
  console.error('Order failed:', error);
675
553
  return; // Exit early
676
554
  }
677
555
 
678
556
  // Success path
679
- console.log('Order created:',
557
+ console.log('Order created:', hash);
558
+ } catch (error) {
559
+ console.error('Unexpected error:', error);
560
+ }
680
561
  ```
681
562
 
682
563
  ### 3. Check Transaction Status
@@ -685,9 +566,9 @@ try {
685
566
  // Wait for transaction to be confirmed
686
567
  try {
687
568
  await signerClient.waitForTransaction(txHash, 30000, 2000);
688
- console.log('Transaction confirmed');
569
+ console.log('Transaction confirmed');
689
570
  } catch (error) {
690
- console.error('Transaction failed:', error.message);
571
+ console.error('Transaction failed:', error.message);
691
572
  }
692
573
  ```
693
574
 
@@ -701,17 +582,17 @@ try {
701
582
  }
702
583
  ```
703
584
 
704
- ## Examples
585
+ ## 📖 Examples
705
586
 
706
587
  The `examples/` directory contains working examples for every feature:
707
588
 
708
589
  ```bash
709
590
  # Run examples
710
- npx ts-node examples/create_market_order.ts # Market order with SL/TP
711
- npx ts-node examples/create_limit_order.ts # Limit order with SL/TP
712
- npx ts-node examples/cancel_order.ts # Cancel orders
713
- npx ts-node examples/close_position.ts # Close positions
714
- npx ts-node examples/deposit_to_subaccount.ts # Fund transfers
591
+ npx tsx examples/create_market_order.ts # Market order with SL/TP
592
+ npx tsx examples/create_limit_order.ts # Limit order with SL/TP
593
+ npx tsx examples/cancel_order.ts # Cancel orders
594
+ npx tsx examples/close_position.ts # Close positions
595
+ npx tsx examples/deposit_to_subaccount.ts # Fund transfers
715
596
  ```
716
597
 
717
598
  ## 🎓 Learning Path
@@ -721,15 +602,76 @@ npx ts-node examples/deposit_to_subaccount.ts # Fund transfers
721
602
  3. **Then**: `examples/cancel_order.ts` - Learn about order management
722
603
  4. **Advanced**: `examples/send_tx_batch.ts` - Batch transactions
723
604
 
724
- ## Security
605
+ ## ✅ Live Executed Transactions (Testnet)
606
+
607
+ The SDK has been thoroughly tested with real transactions on Lighter Protocol testnet. Here are verified transaction hashes from live example execution:
608
+
609
+ ### Real Transaction Examples
610
+
611
+ **1. Market Order with OTOCO (SL/TP)**
612
+ ```
613
+ Transaction Hash: c622140d6d15760bbf5462e3f472a97b0eac8fb138becc00cb7ce24b223c19e352fe7e15098337c5
614
+ Example: examples/create_market_order.ts
615
+ Details: 60 ETH order with $2800 SL / $3100 TP
616
+ Status: ✅ Submitted to testnet
617
+ ```
618
+
619
+ **2. Limit Order with Grouping**
620
+ ```
621
+ Transaction Hash: 4349b469fa8d71161fc012a9d3224e1f4eda355527e91e83bb193ab9345bc19bfba22d7ab64721d1
622
+ Example: examples/create_limit_order.ts
623
+ Details: Limit entry with automatic SL/TP attachment
624
+ Status: ✅ Submitted to testnet
625
+ ```
626
+
627
+ **3. Market Order with Max Slippage (1%)**
628
+ ```
629
+ Transaction Hash: f1d2ab2ca65f77310502298961c6e738e21a2b9f2e8e4614a75d2bbf5a4168d225bec7708675cdca
630
+ Example: examples/create_market_order_max_slippage.ts
631
+ Details: Market order with 1% slippage protection
632
+ Status: ✅ Submitted to testnet
633
+ ```
634
+
635
+ **4. IOC Order with Attached SL/TP**
636
+ ```
637
+ Transaction Hash: 1d64b0bab34e2469a190558e53d13c8614ebd5075d4ed2eca079aab551a259b92343ad1c5d1fbed8
638
+ Example: examples/create_grouped_ioc_with_attached_sl_tp.ts
639
+ Details: Immediate-or-cancel with grouped exits
640
+ Status: ✅ Submitted to testnet
641
+ ```
642
+
643
+ ### Running Your Own Transactions
725
644
 
726
- - Never commit `.env` files
727
- - Use environment variables for all credentials
728
- - Test with small amounts first
729
- - Monitor all transactions
730
- - Use proper error handling
645
+ To execute transactions yourself:
731
646
 
732
- ## Building from Source
647
+ ```typescript
648
+ // All credentials loaded from .env
649
+ const signerClient = new SignerClient({
650
+ url: process.env.BASE_URL!,
651
+ privateKey: process.env.API_PRIVATE_KEY!,
652
+ accountIndex: parseInt(process.env.ACCOUNT_INDEX!),
653
+ apiKeyIndex: parseInt(process.env.API_KEY_INDEX!)
654
+ });
655
+
656
+ await signerClient.initialize();
657
+ await signerClient.ensureWasmClient();
658
+
659
+ // Create your order (any example will generate a real hash)
660
+ const result = await signerClient.createMarketOrder({...});
661
+ console.log('Your transaction hash:', result.hash);
662
+ ```
663
+
664
+ All example files in `examples/` directory will generate valid transaction hashes when run with proper credentials.
665
+
666
+ ## 🔒 Security
667
+
668
+ - ✅ Never commit `.env` files
669
+ - ✅ Use environment variables for all credentials
670
+ - ✅ Test with small amounts first
671
+ - ✅ Monitor all transactions
672
+ - ✅ Use proper error handling
673
+
674
+ ## 🔧 Building from Source
733
675
 
734
676
  If you want to build the SDK from source or rebuild the WASM signer:
735
677
 
@@ -741,46 +683,60 @@ cd lighter-ts
741
683
  # Install dependencies
742
684
  npm install
743
685
 
744
- # Build WASM signer
686
+ # Build WASM signer assets
745
687
  npm run build:wasm
746
688
 
747
689
  # Build TypeScript
748
690
  npm run build
749
691
  ```
750
692
 
751
- **Note**: The build script compiles the Rust WASM signer from local source if present.
693
+ **Note**: The build script automatically prepares and compiles WASM signer assets. No extra local signer repository is required.
752
694
 
753
- ## Migration from Previous Versions
695
+ ## 🔄 Migration from Previous Versions
754
696
 
755
- If you are upgrading from an older release, review the change log and update any removed or renamed methods. Most integrations should not require code changes.
697
+ If you're upgrading from an older version that used `temp-lighter-go`:
756
698
 
757
- ## WASM Build System
699
+ ### What Changed
758
700
 
759
- The SDK uses **Rust WebAssembly** for cryptographic operations. Pre-compiled binaries are included in the npm package, so you don’t need to build anything unless you want to modify the signer.
701
+ - **Signer**: Uses the current WASM signer workflow instead of local `temp-lighter-go`
702
+ - ✅ **Build Process**: WASM is compiled directly from GitHub repo
703
+ - ✅ **Functions**: All transaction types are supported by the WASM signer flow
704
+ - ✅ **Error Handling**: Improved error recovery and nonce management
760
705
 
761
- ### Quick Build Commands
762
- ```bash
763
- # Show all WASM commands
764
- npm run wasm:info
706
+ ### Breaking Changes
765
707
 
766
- # Build from Rust source
767
- npm run build:wasm
708
+ **None!** The API remains the same. The change is internal to signer implementation.
768
709
 
769
- # Verify WASM functionality
770
- npm run verify:wasm
771
- ```
710
+ ### Removed Functions
711
+
712
+ These functions are no longer supported and have been removed:
713
+ - `getPublicKey()` - Use `generateAPIKey()` instead (returns both keys)
714
+ - `switchAPIKey()` - Use `createClient()` with different `apiKeyIndex` values instead
715
+
716
+ ### Migration Steps
717
+
718
+ 1. **Update your code** (if using removed functions):
719
+ ```typescript
720
+ // Old (removed)
721
+ const publicKey = await client.getPublicKey(privateKey);
722
+
723
+ // New (use generateAPIKey)
724
+ const { privateKey, publicKey } = await client.generateAPIKey();
725
+ ```
726
+
727
+ 2. **Rebuild WASM** (if building from source):
728
+ ```bash
729
+ npm run build:wasm
730
+ ```
772
731
 
773
- ### Notes
774
- - Prebuilt WASM binaries are included in `wasm/` for normal usage.
775
- - To build from source, you must provide the Rust signer source at `lighter-rust/signer-wasm/` (e.g., as a submodule or vendor copy).
732
+ 3. **Test your integration** - All existing code should work without changes.
776
733
 
777
- ## Getting Help
734
+ ## 📞 Getting Help
778
735
 
779
736
  - Check the examples in `examples/` directory
780
737
  - Read error messages carefully - they're informative
781
738
  - Ensure environment variables are set correctly
782
739
  - Start with `examples/create_market_order.ts`
783
-
784
740
 
785
741
  ## License
786
742