@haneullabs/deepbook-v3 0.1.0

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 (378) hide show
  1. package/CHANGELOG.md +984 -0
  2. package/README.md +1 -0
  3. package/dist/cjs/client.d.ts +861 -0
  4. package/dist/cjs/client.js +1982 -0
  5. package/dist/cjs/client.js.map +7 -0
  6. package/dist/cjs/contracts/deepbook/account.d.ts +105 -0
  7. package/dist/cjs/contracts/deepbook/account.js +163 -0
  8. package/dist/cjs/contracts/deepbook/account.js.map +7 -0
  9. package/dist/cjs/contracts/deepbook/balance_manager.d.ts +268 -0
  10. package/dist/cjs/contracts/deepbook/balance_manager.js +361 -0
  11. package/dist/cjs/contracts/deepbook/balance_manager.js.map +7 -0
  12. package/dist/cjs/contracts/deepbook/balances.d.ts +10 -0
  13. package/dist/cjs/contracts/deepbook/balances.js +35 -0
  14. package/dist/cjs/contracts/deepbook/balances.js.map +7 -0
  15. package/dist/cjs/contracts/deepbook/big_vector.d.ts +62 -0
  16. package/dist/cjs/contracts/deepbook/big_vector.js +80 -0
  17. package/dist/cjs/contracts/deepbook/big_vector.js.map +7 -0
  18. package/dist/cjs/contracts/deepbook/book.d.ts +34 -0
  19. package/dist/cjs/contracts/deepbook/book.js +50 -0
  20. package/dist/cjs/contracts/deepbook/book.js.map +7 -0
  21. package/dist/cjs/contracts/deepbook/constants.d.ts +176 -0
  22. package/dist/cjs/contracts/deepbook/constants.js +338 -0
  23. package/dist/cjs/contracts/deepbook/constants.js.map +7 -0
  24. package/dist/cjs/contracts/deepbook/deep_price.d.ts +60 -0
  25. package/dist/cjs/contracts/deepbook/deep_price.js +87 -0
  26. package/dist/cjs/contracts/deepbook/deep_price.js.map +7 -0
  27. package/dist/cjs/contracts/deepbook/deps/std/type_name.d.ts +14 -0
  28. package/dist/cjs/contracts/deepbook/deps/std/type_name.js +42 -0
  29. package/dist/cjs/contracts/deepbook/deps/std/type_name.js.map +7 -0
  30. package/dist/cjs/contracts/deepbook/deps/sui/bag.d.ts +33 -0
  31. package/dist/cjs/contracts/deepbook/deps/sui/bag.js +47 -0
  32. package/dist/cjs/contracts/deepbook/deps/sui/bag.js.map +7 -0
  33. package/dist/cjs/contracts/deepbook/deps/sui/balance.d.ts +9 -0
  34. package/dist/cjs/contracts/deepbook/deps/sui/balance.js +33 -0
  35. package/dist/cjs/contracts/deepbook/deps/sui/balance.js.map +7 -0
  36. package/dist/cjs/contracts/deepbook/deps/sui/object.d.ts +5 -0
  37. package/dist/cjs/contracts/deepbook/deps/sui/object.js +33 -0
  38. package/dist/cjs/contracts/deepbook/deps/sui/object.js.map +7 -0
  39. package/dist/cjs/contracts/deepbook/deps/sui/table.d.ts +28 -0
  40. package/dist/cjs/contracts/deepbook/deps/sui/table.js +47 -0
  41. package/dist/cjs/contracts/deepbook/deps/sui/table.js.map +7 -0
  42. package/dist/cjs/contracts/deepbook/deps/sui/vec_map.d.ts +27 -0
  43. package/dist/cjs/contracts/deepbook/deps/sui/vec_map.js +45 -0
  44. package/dist/cjs/contracts/deepbook/deps/sui/vec_map.js.map +7 -0
  45. package/dist/cjs/contracts/deepbook/deps/sui/vec_set.d.ts +15 -0
  46. package/dist/cjs/contracts/deepbook/deps/sui/vec_set.js +35 -0
  47. package/dist/cjs/contracts/deepbook/deps/sui/vec_set.js.map +7 -0
  48. package/dist/cjs/contracts/deepbook/deps/sui/versioned.d.ts +7 -0
  49. package/dist/cjs/contracts/deepbook/deps/sui/versioned.js +45 -0
  50. package/dist/cjs/contracts/deepbook/deps/sui/versioned.js.map +7 -0
  51. package/dist/cjs/contracts/deepbook/ewma.d.ts +17 -0
  52. package/dist/cjs/contracts/deepbook/ewma.js +39 -0
  53. package/dist/cjs/contracts/deepbook/ewma.js.map +7 -0
  54. package/dist/cjs/contracts/deepbook/fill.d.ts +153 -0
  55. package/dist/cjs/contracts/deepbook/fill.js +251 -0
  56. package/dist/cjs/contracts/deepbook/fill.js.map +7 -0
  57. package/dist/cjs/contracts/deepbook/governance.d.ts +63 -0
  58. package/dist/cjs/contracts/deepbook/governance.js +79 -0
  59. package/dist/cjs/contracts/deepbook/governance.js.map +7 -0
  60. package/dist/cjs/contracts/deepbook/history.d.ts +60 -0
  61. package/dist/cjs/contracts/deepbook/history.js +78 -0
  62. package/dist/cjs/contracts/deepbook/history.js.map +7 -0
  63. package/dist/cjs/contracts/deepbook/math.d.ts +94 -0
  64. package/dist/cjs/contracts/deepbook/math.js +132 -0
  65. package/dist/cjs/contracts/deepbook/math.js.map +7 -0
  66. package/dist/cjs/contracts/deepbook/order.d.ts +135 -0
  67. package/dist/cjs/contracts/deepbook/order.js +218 -0
  68. package/dist/cjs/contracts/deepbook/order.js.map +7 -0
  69. package/dist/cjs/contracts/deepbook/order_info.d.ts +296 -0
  70. package/dist/cjs/contracts/deepbook/order_info.js +386 -0
  71. package/dist/cjs/contracts/deepbook/order_info.js.map +7 -0
  72. package/dist/cjs/contracts/deepbook/order_query.d.ts +85 -0
  73. package/dist/cjs/contracts/deepbook/order_query.js +96 -0
  74. package/dist/cjs/contracts/deepbook/order_query.js.map +7 -0
  75. package/dist/cjs/contracts/deepbook/pool.d.ts +1218 -0
  76. package/dist/cjs/contracts/deepbook/pool.js +1236 -0
  77. package/dist/cjs/contracts/deepbook/pool.js.map +7 -0
  78. package/dist/cjs/contracts/deepbook/registry.d.ts +134 -0
  79. package/dist/cjs/contracts/deepbook/registry.js +182 -0
  80. package/dist/cjs/contracts/deepbook/registry.js.map +7 -0
  81. package/dist/cjs/contracts/deepbook/state.d.ts +117 -0
  82. package/dist/cjs/contracts/deepbook/state.js +104 -0
  83. package/dist/cjs/contracts/deepbook/state.js.map +7 -0
  84. package/dist/cjs/contracts/deepbook/trade_params.d.ts +7 -0
  85. package/dist/cjs/contracts/deepbook/trade_params.js +35 -0
  86. package/dist/cjs/contracts/deepbook/trade_params.js.map +7 -0
  87. package/dist/cjs/contracts/deepbook/vault.d.ts +30 -0
  88. package/dist/cjs/contracts/deepbook/vault.js +65 -0
  89. package/dist/cjs/contracts/deepbook/vault.js.map +7 -0
  90. package/dist/cjs/contracts/utils/index.d.ts +25 -0
  91. package/dist/cjs/contracts/utils/index.js +148 -0
  92. package/dist/cjs/contracts/utils/index.js.map +7 -0
  93. package/dist/cjs/index.d.ts +23 -0
  94. package/dist/cjs/index.js +81 -0
  95. package/dist/cjs/index.js.map +7 -0
  96. package/dist/cjs/package.json +4 -0
  97. package/dist/cjs/pyth/PriceServiceConnection.d.ts +26 -0
  98. package/dist/cjs/pyth/PriceServiceConnection.js +68 -0
  99. package/dist/cjs/pyth/PriceServiceConnection.js.map +7 -0
  100. package/dist/cjs/pyth/pyth-helpers.d.ts +7 -0
  101. package/dist/cjs/pyth/pyth-helpers.js +36 -0
  102. package/dist/cjs/pyth/pyth-helpers.js.map +7 -0
  103. package/dist/cjs/pyth/pyth.d.ts +65 -0
  104. package/dist/cjs/pyth/pyth.js +269 -0
  105. package/dist/cjs/pyth/pyth.js.map +7 -0
  106. package/dist/cjs/transactions/balanceManager.d.ts +168 -0
  107. package/dist/cjs/transactions/balanceManager.js +384 -0
  108. package/dist/cjs/transactions/balanceManager.js.map +7 -0
  109. package/dist/cjs/transactions/deepbook.d.ts +477 -0
  110. package/dist/cjs/transactions/deepbook.js +1335 -0
  111. package/dist/cjs/transactions/deepbook.js.map +7 -0
  112. package/dist/cjs/transactions/deepbookAdmin.d.ts +105 -0
  113. package/dist/cjs/transactions/deepbookAdmin.js +334 -0
  114. package/dist/cjs/transactions/deepbookAdmin.js.map +7 -0
  115. package/dist/cjs/transactions/flashLoans.d.ts +56 -0
  116. package/dist/cjs/transactions/flashLoans.js +124 -0
  117. package/dist/cjs/transactions/flashLoans.js.map +7 -0
  118. package/dist/cjs/transactions/governance.d.ts +42 -0
  119. package/dist/cjs/transactions/governance.js +135 -0
  120. package/dist/cjs/transactions/governance.js.map +7 -0
  121. package/dist/cjs/transactions/marginAdmin.d.ts +133 -0
  122. package/dist/cjs/transactions/marginAdmin.js +393 -0
  123. package/dist/cjs/transactions/marginAdmin.js.map +7 -0
  124. package/dist/cjs/transactions/marginLiquidations.d.ts +61 -0
  125. package/dist/cjs/transactions/marginLiquidations.js +173 -0
  126. package/dist/cjs/transactions/marginLiquidations.js.map +7 -0
  127. package/dist/cjs/transactions/marginMaintainer.d.ts +80 -0
  128. package/dist/cjs/transactions/marginMaintainer.js +251 -0
  129. package/dist/cjs/transactions/marginMaintainer.js.map +7 -0
  130. package/dist/cjs/transactions/marginManager.d.ts +236 -0
  131. package/dist/cjs/transactions/marginManager.js +688 -0
  132. package/dist/cjs/transactions/marginManager.js.map +7 -0
  133. package/dist/cjs/transactions/marginPool.d.ts +134 -0
  134. package/dist/cjs/transactions/marginPool.js +330 -0
  135. package/dist/cjs/transactions/marginPool.js.map +7 -0
  136. package/dist/cjs/transactions/marginRegistry.d.ts +94 -0
  137. package/dist/cjs/transactions/marginRegistry.js +221 -0
  138. package/dist/cjs/transactions/marginRegistry.js.map +7 -0
  139. package/dist/cjs/transactions/marginTPSL.d.ts +93 -0
  140. package/dist/cjs/transactions/marginTPSL.js +286 -0
  141. package/dist/cjs/transactions/marginTPSL.js.map +7 -0
  142. package/dist/cjs/transactions/poolProxy.d.ts +104 -0
  143. package/dist/cjs/transactions/poolProxy.js +435 -0
  144. package/dist/cjs/transactions/poolProxy.js.map +7 -0
  145. package/dist/cjs/types/bcs.d.ts +5 -0
  146. package/dist/cjs/types/bcs.js +33 -0
  147. package/dist/cjs/types/bcs.js.map +7 -0
  148. package/dist/cjs/types/index.d.ts +218 -0
  149. package/dist/cjs/types/index.js +38 -0
  150. package/dist/cjs/types/index.js.map +7 -0
  151. package/dist/cjs/utils/config.d.ts +65 -0
  152. package/dist/cjs/utils/config.js +144 -0
  153. package/dist/cjs/utils/config.js.map +7 -0
  154. package/dist/cjs/utils/constants.d.ts +76 -0
  155. package/dist/cjs/utils/constants.js +382 -0
  156. package/dist/cjs/utils/constants.js.map +7 -0
  157. package/dist/cjs/utils/errors.d.ts +42 -0
  158. package/dist/cjs/utils/errors.js +70 -0
  159. package/dist/cjs/utils/errors.js.map +7 -0
  160. package/dist/cjs/utils/validation.d.ts +50 -0
  161. package/dist/cjs/utils/validation.js +67 -0
  162. package/dist/cjs/utils/validation.js.map +7 -0
  163. package/dist/esm/client.d.ts +861 -0
  164. package/dist/esm/client.js +1967 -0
  165. package/dist/esm/client.js.map +7 -0
  166. package/dist/esm/contracts/deepbook/account.d.ts +105 -0
  167. package/dist/esm/contracts/deepbook/account.js +133 -0
  168. package/dist/esm/contracts/deepbook/account.js.map +7 -0
  169. package/dist/esm/contracts/deepbook/balance_manager.d.ts +268 -0
  170. package/dist/esm/contracts/deepbook/balance_manager.js +331 -0
  171. package/dist/esm/contracts/deepbook/balance_manager.js.map +7 -0
  172. package/dist/esm/contracts/deepbook/balances.d.ts +10 -0
  173. package/dist/esm/contracts/deepbook/balances.js +15 -0
  174. package/dist/esm/contracts/deepbook/balances.js.map +7 -0
  175. package/dist/esm/contracts/deepbook/big_vector.d.ts +62 -0
  176. package/dist/esm/contracts/deepbook/big_vector.js +50 -0
  177. package/dist/esm/contracts/deepbook/big_vector.js.map +7 -0
  178. package/dist/esm/contracts/deepbook/book.d.ts +34 -0
  179. package/dist/esm/contracts/deepbook/book.js +20 -0
  180. package/dist/esm/contracts/deepbook/book.js.map +7 -0
  181. package/dist/esm/contracts/deepbook/constants.d.ts +176 -0
  182. package/dist/esm/contracts/deepbook/constants.js +318 -0
  183. package/dist/esm/contracts/deepbook/constants.js.map +7 -0
  184. package/dist/esm/contracts/deepbook/deep_price.d.ts +60 -0
  185. package/dist/esm/contracts/deepbook/deep_price.js +67 -0
  186. package/dist/esm/contracts/deepbook/deep_price.js.map +7 -0
  187. package/dist/esm/contracts/deepbook/deps/std/type_name.d.ts +14 -0
  188. package/dist/esm/contracts/deepbook/deps/std/type_name.js +22 -0
  189. package/dist/esm/contracts/deepbook/deps/std/type_name.js.map +7 -0
  190. package/dist/esm/contracts/deepbook/deps/sui/bag.d.ts +33 -0
  191. package/dist/esm/contracts/deepbook/deps/sui/bag.js +17 -0
  192. package/dist/esm/contracts/deepbook/deps/sui/bag.js.map +7 -0
  193. package/dist/esm/contracts/deepbook/deps/sui/balance.d.ts +9 -0
  194. package/dist/esm/contracts/deepbook/deps/sui/balance.js +13 -0
  195. package/dist/esm/contracts/deepbook/deps/sui/balance.js.map +7 -0
  196. package/dist/esm/contracts/deepbook/deps/sui/object.d.ts +5 -0
  197. package/dist/esm/contracts/deepbook/deps/sui/object.js +13 -0
  198. package/dist/esm/contracts/deepbook/deps/sui/object.js.map +7 -0
  199. package/dist/esm/contracts/deepbook/deps/sui/table.d.ts +28 -0
  200. package/dist/esm/contracts/deepbook/deps/sui/table.js +17 -0
  201. package/dist/esm/contracts/deepbook/deps/sui/table.js.map +7 -0
  202. package/dist/esm/contracts/deepbook/deps/sui/vec_map.d.ts +27 -0
  203. package/dist/esm/contracts/deepbook/deps/sui/vec_map.js +25 -0
  204. package/dist/esm/contracts/deepbook/deps/sui/vec_map.js.map +7 -0
  205. package/dist/esm/contracts/deepbook/deps/sui/vec_set.d.ts +15 -0
  206. package/dist/esm/contracts/deepbook/deps/sui/vec_set.js +15 -0
  207. package/dist/esm/contracts/deepbook/deps/sui/vec_set.js.map +7 -0
  208. package/dist/esm/contracts/deepbook/deps/sui/versioned.d.ts +7 -0
  209. package/dist/esm/contracts/deepbook/deps/sui/versioned.js +15 -0
  210. package/dist/esm/contracts/deepbook/deps/sui/versioned.js.map +7 -0
  211. package/dist/esm/contracts/deepbook/ewma.d.ts +17 -0
  212. package/dist/esm/contracts/deepbook/ewma.js +19 -0
  213. package/dist/esm/contracts/deepbook/ewma.js.map +7 -0
  214. package/dist/esm/contracts/deepbook/fill.d.ts +153 -0
  215. package/dist/esm/contracts/deepbook/fill.js +221 -0
  216. package/dist/esm/contracts/deepbook/fill.js.map +7 -0
  217. package/dist/esm/contracts/deepbook/governance.d.ts +63 -0
  218. package/dist/esm/contracts/deepbook/governance.js +49 -0
  219. package/dist/esm/contracts/deepbook/governance.js.map +7 -0
  220. package/dist/esm/contracts/deepbook/history.d.ts +60 -0
  221. package/dist/esm/contracts/deepbook/history.js +48 -0
  222. package/dist/esm/contracts/deepbook/history.js.map +7 -0
  223. package/dist/esm/contracts/deepbook/math.d.ts +94 -0
  224. package/dist/esm/contracts/deepbook/math.js +112 -0
  225. package/dist/esm/contracts/deepbook/math.js.map +7 -0
  226. package/dist/esm/contracts/deepbook/order.d.ts +135 -0
  227. package/dist/esm/contracts/deepbook/order.js +188 -0
  228. package/dist/esm/contracts/deepbook/order.js.map +7 -0
  229. package/dist/esm/contracts/deepbook/order_info.d.ts +296 -0
  230. package/dist/esm/contracts/deepbook/order_info.js +356 -0
  231. package/dist/esm/contracts/deepbook/order_info.js.map +7 -0
  232. package/dist/esm/contracts/deepbook/order_query.d.ts +85 -0
  233. package/dist/esm/contracts/deepbook/order_query.js +66 -0
  234. package/dist/esm/contracts/deepbook/order_query.js.map +7 -0
  235. package/dist/esm/contracts/deepbook/pool.d.ts +1218 -0
  236. package/dist/esm/contracts/deepbook/pool.js +1206 -0
  237. package/dist/esm/contracts/deepbook/pool.js.map +7 -0
  238. package/dist/esm/contracts/deepbook/registry.d.ts +134 -0
  239. package/dist/esm/contracts/deepbook/registry.js +152 -0
  240. package/dist/esm/contracts/deepbook/registry.js.map +7 -0
  241. package/dist/esm/contracts/deepbook/state.d.ts +117 -0
  242. package/dist/esm/contracts/deepbook/state.js +74 -0
  243. package/dist/esm/contracts/deepbook/state.js.map +7 -0
  244. package/dist/esm/contracts/deepbook/trade_params.d.ts +7 -0
  245. package/dist/esm/contracts/deepbook/trade_params.js +15 -0
  246. package/dist/esm/contracts/deepbook/trade_params.js.map +7 -0
  247. package/dist/esm/contracts/deepbook/vault.d.ts +30 -0
  248. package/dist/esm/contracts/deepbook/vault.js +35 -0
  249. package/dist/esm/contracts/deepbook/vault.js.map +7 -0
  250. package/dist/esm/contracts/utils/index.d.ts +25 -0
  251. package/dist/esm/contracts/utils/index.js +128 -0
  252. package/dist/esm/contracts/utils/index.js.map +7 -0
  253. package/dist/esm/index.d.ts +23 -0
  254. package/dist/esm/index.js +81 -0
  255. package/dist/esm/index.js.map +7 -0
  256. package/dist/esm/package.json +4 -0
  257. package/dist/esm/pyth/PriceServiceConnection.d.ts +26 -0
  258. package/dist/esm/pyth/PriceServiceConnection.js +38 -0
  259. package/dist/esm/pyth/PriceServiceConnection.js.map +7 -0
  260. package/dist/esm/pyth/pyth-helpers.d.ts +7 -0
  261. package/dist/esm/pyth/pyth-helpers.js +16 -0
  262. package/dist/esm/pyth/pyth-helpers.js.map +7 -0
  263. package/dist/esm/pyth/pyth.d.ts +65 -0
  264. package/dist/esm/pyth/pyth.js +249 -0
  265. package/dist/esm/pyth/pyth.js.map +7 -0
  266. package/dist/esm/transactions/balanceManager.d.ts +168 -0
  267. package/dist/esm/transactions/balanceManager.js +364 -0
  268. package/dist/esm/transactions/balanceManager.js.map +7 -0
  269. package/dist/esm/transactions/deepbook.d.ts +477 -0
  270. package/dist/esm/transactions/deepbook.js +1321 -0
  271. package/dist/esm/transactions/deepbook.js.map +7 -0
  272. package/dist/esm/transactions/deepbookAdmin.d.ts +105 -0
  273. package/dist/esm/transactions/deepbookAdmin.js +314 -0
  274. package/dist/esm/transactions/deepbookAdmin.js.map +7 -0
  275. package/dist/esm/transactions/flashLoans.d.ts +56 -0
  276. package/dist/esm/transactions/flashLoans.js +104 -0
  277. package/dist/esm/transactions/flashLoans.js.map +7 -0
  278. package/dist/esm/transactions/governance.d.ts +42 -0
  279. package/dist/esm/transactions/governance.js +115 -0
  280. package/dist/esm/transactions/governance.js.map +7 -0
  281. package/dist/esm/transactions/marginAdmin.d.ts +133 -0
  282. package/dist/esm/transactions/marginAdmin.js +373 -0
  283. package/dist/esm/transactions/marginAdmin.js.map +7 -0
  284. package/dist/esm/transactions/marginLiquidations.d.ts +61 -0
  285. package/dist/esm/transactions/marginLiquidations.js +153 -0
  286. package/dist/esm/transactions/marginLiquidations.js.map +7 -0
  287. package/dist/esm/transactions/marginMaintainer.d.ts +80 -0
  288. package/dist/esm/transactions/marginMaintainer.js +231 -0
  289. package/dist/esm/transactions/marginMaintainer.js.map +7 -0
  290. package/dist/esm/transactions/marginManager.d.ts +236 -0
  291. package/dist/esm/transactions/marginManager.js +668 -0
  292. package/dist/esm/transactions/marginManager.js.map +7 -0
  293. package/dist/esm/transactions/marginPool.d.ts +134 -0
  294. package/dist/esm/transactions/marginPool.js +310 -0
  295. package/dist/esm/transactions/marginPool.js.map +7 -0
  296. package/dist/esm/transactions/marginRegistry.d.ts +94 -0
  297. package/dist/esm/transactions/marginRegistry.js +201 -0
  298. package/dist/esm/transactions/marginRegistry.js.map +7 -0
  299. package/dist/esm/transactions/marginTPSL.d.ts +93 -0
  300. package/dist/esm/transactions/marginTPSL.js +266 -0
  301. package/dist/esm/transactions/marginTPSL.js.map +7 -0
  302. package/dist/esm/transactions/poolProxy.d.ts +104 -0
  303. package/dist/esm/transactions/poolProxy.js +415 -0
  304. package/dist/esm/transactions/poolProxy.js.map +7 -0
  305. package/dist/esm/types/bcs.d.ts +5 -0
  306. package/dist/esm/types/bcs.js +13 -0
  307. package/dist/esm/types/bcs.js.map +7 -0
  308. package/dist/esm/types/index.d.ts +218 -0
  309. package/dist/esm/types/index.js +18 -0
  310. package/dist/esm/types/index.js.map +7 -0
  311. package/dist/esm/utils/config.d.ts +65 -0
  312. package/dist/esm/utils/config.js +135 -0
  313. package/dist/esm/utils/config.js.map +7 -0
  314. package/dist/esm/utils/constants.d.ts +76 -0
  315. package/dist/esm/utils/constants.js +362 -0
  316. package/dist/esm/utils/constants.js.map +7 -0
  317. package/dist/esm/utils/errors.d.ts +42 -0
  318. package/dist/esm/utils/errors.js +50 -0
  319. package/dist/esm/utils/errors.js.map +7 -0
  320. package/dist/esm/utils/validation.d.ts +50 -0
  321. package/dist/esm/utils/validation.js +47 -0
  322. package/dist/esm/utils/validation.js.map +7 -0
  323. package/dist/tsconfig.esm.tsbuildinfo +1 -0
  324. package/dist/tsconfig.tsbuildinfo +1 -0
  325. package/package.json +63 -0
  326. package/src/client.ts +2451 -0
  327. package/src/contracts/deepbook/account.ts +199 -0
  328. package/src/contracts/deepbook/balance_manager.ts +532 -0
  329. package/src/contracts/deepbook/balances.ts +19 -0
  330. package/src/contracts/deepbook/big_vector.ts +74 -0
  331. package/src/contracts/deepbook/book.ts +24 -0
  332. package/src/contracts/deepbook/constants.ts +458 -0
  333. package/src/contracts/deepbook/deep_price.ts +84 -0
  334. package/src/contracts/deepbook/deps/std/type_name.ts +23 -0
  335. package/src/contracts/deepbook/deps/sui/bag.ts +41 -0
  336. package/src/contracts/deepbook/deps/sui/balance.ts +18 -0
  337. package/src/contracts/deepbook/deps/sui/object.ts +14 -0
  338. package/src/contracts/deepbook/deps/sui/table.ts +36 -0
  339. package/src/contracts/deepbook/deps/sui/vec_map.ts +33 -0
  340. package/src/contracts/deepbook/deps/sui/vec_set.ts +22 -0
  341. package/src/contracts/deepbook/deps/sui/versioned.ts +13 -0
  342. package/src/contracts/deepbook/ewma.ts +26 -0
  343. package/src/contracts/deepbook/fill.ts +336 -0
  344. package/src/contracts/deepbook/governance.ts +52 -0
  345. package/src/contracts/deepbook/history.ts +51 -0
  346. package/src/contracts/deepbook/math.ts +210 -0
  347. package/src/contracts/deepbook/order.ts +269 -0
  348. package/src/contracts/deepbook/order_info.ts +513 -0
  349. package/src/contracts/deepbook/order_query.ts +115 -0
  350. package/src/contracts/deepbook/pool.ts +2269 -0
  351. package/src/contracts/deepbook/registry.ts +242 -0
  352. package/src/contracts/deepbook/state.ts +74 -0
  353. package/src/contracts/deepbook/trade_params.ts +16 -0
  354. package/src/contracts/deepbook/vault.ts +37 -0
  355. package/src/contracts/utils/index.ts +184 -0
  356. package/src/index.ts +95 -0
  357. package/src/pyth/PriceServiceConnection.ts +48 -0
  358. package/src/pyth/pyth-helpers.ts +23 -0
  359. package/src/pyth/pyth.ts +305 -0
  360. package/src/transactions/balanceManager.ts +399 -0
  361. package/src/transactions/deepbook.ts +1519 -0
  362. package/src/transactions/deepbookAdmin.ts +332 -0
  363. package/src/transactions/flashLoans.ts +123 -0
  364. package/src/transactions/governance.ts +123 -0
  365. package/src/transactions/marginAdmin.ts +396 -0
  366. package/src/transactions/marginLiquidations.ts +175 -0
  367. package/src/transactions/marginMaintainer.ts +280 -0
  368. package/src/transactions/marginManager.ts +708 -0
  369. package/src/transactions/marginPool.ts +339 -0
  370. package/src/transactions/marginRegistry.ts +212 -0
  371. package/src/transactions/marginTPSL.ts +296 -0
  372. package/src/transactions/poolProxy.ts +438 -0
  373. package/src/types/bcs.ts +8 -0
  374. package/src/types/index.ts +255 -0
  375. package/src/utils/config.ts +177 -0
  376. package/src/utils/constants.ts +374 -0
  377. package/src/utils/errors.ts +67 -0
  378. package/src/utils/validation.ts +91 -0
@@ -0,0 +1,861 @@
1
+ import type { HaneulClient } from '@haneullabs/haneul/client';
2
+ import { Transaction } from '@haneullabs/haneul/transactions';
3
+ import { BalanceManagerContract } from './transactions/balanceManager.js';
4
+ import { DeepBookContract } from './transactions/deepbook.js';
5
+ import { DeepBookAdminContract } from './transactions/deepbookAdmin.js';
6
+ import { FlashLoanContract } from './transactions/flashLoans.js';
7
+ import { GovernanceContract } from './transactions/governance.js';
8
+ import type { BalanceManager, Environment, MarginManager, CanPlaceLimitOrderParams, CanPlaceMarketOrderParams } from './types/index.js';
9
+ import type { CoinMap, PoolMap } from './utils/constants.js';
10
+ import { MarginAdminContract } from './transactions/marginAdmin.js';
11
+ import { MarginMaintainerContract } from './transactions/marginMaintainer.js';
12
+ import { MarginPoolContract } from './transactions/marginPool.js';
13
+ import { MarginManagerContract } from './transactions/marginManager.js';
14
+ import { MarginRegistryContract } from './transactions/marginRegistry.js';
15
+ import { MarginLiquidationsContract } from './transactions/marginLiquidations.js';
16
+ import { PoolProxyContract } from './transactions/poolProxy.js';
17
+ import { MarginTPSLContract } from './transactions/marginTPSL.js';
18
+ /**
19
+ * DeepBookClient class for managing DeepBook operations.
20
+ */
21
+ export declare class DeepBookClient {
22
+ #private;
23
+ client: HaneulClient;
24
+ balanceManager: BalanceManagerContract;
25
+ deepBook: DeepBookContract;
26
+ deepBookAdmin: DeepBookAdminContract;
27
+ flashLoans: FlashLoanContract;
28
+ governance: GovernanceContract;
29
+ marginAdmin: MarginAdminContract;
30
+ marginMaintainer: MarginMaintainerContract;
31
+ marginPool: MarginPoolContract;
32
+ marginManager: MarginManagerContract;
33
+ marginRegistry: MarginRegistryContract;
34
+ marginLiquidations: MarginLiquidationsContract;
35
+ poolProxy: PoolProxyContract;
36
+ marginTPSL: MarginTPSLContract;
37
+ /**
38
+ * @param {HaneulClient} client HaneulClient instance
39
+ * @param {string} address Address of the client
40
+ * @param {Environment} env Environment configuration
41
+ * @param {Object.<string, BalanceManager>} [balanceManagers] Optional initial BalanceManager map
42
+ * @param {Object.<string, MarginManager>} [marginManagers] Optional initial MarginManager map
43
+ * @param {CoinMap} [coins] Optional initial CoinMap
44
+ * @param {PoolMap} [pools] Optional initial PoolMap
45
+ * @param {string} [adminCap] Optional admin capability
46
+ * @param {string} [marginAdminCap] Optional margin admin capability
47
+ * @param {string} [marginMaintainerCap] Optional margin maintainer capability
48
+ */
49
+ constructor({ client, address, env, balanceManagers, marginManagers, coins, pools, adminCap, marginAdminCap, marginMaintainerCap, }: {
50
+ client: HaneulClient;
51
+ address: string;
52
+ env: Environment;
53
+ balanceManagers?: {
54
+ [key: string]: BalanceManager;
55
+ };
56
+ marginManagers?: {
57
+ [key: string]: MarginManager;
58
+ };
59
+ coins?: CoinMap;
60
+ pools?: PoolMap;
61
+ adminCap?: string;
62
+ marginAdminCap?: string;
63
+ marginMaintainerCap?: string;
64
+ });
65
+ /**
66
+ * @description Check the balance of a balance manager for a specific coin
67
+ * @param {string} managerKey Key of the balance manager
68
+ * @param {string} coinKey Key of the coin
69
+ * @returns {Promise<{ coinType: string, balance: number }>} An object with coin type and balance
70
+ */
71
+ checkManagerBalance(managerKey: string, coinKey: string): Promise<{
72
+ coinType: string;
73
+ balance: number;
74
+ }>;
75
+ /**
76
+ * @description Check if a pool is whitelisted
77
+ * @param {string} poolKey Key of the pool
78
+ * @returns {Promise<boolean>} Boolean indicating if the pool is whitelisted
79
+ */
80
+ whitelisted(poolKey: string): Promise<boolean>;
81
+ /**
82
+ * @description Get the quote quantity out for a given base quantity
83
+ * @param {string} poolKey Key of the pool
84
+ * @param {number} baseQuantity Base quantity to convert
85
+ * @returns {Promise<{ baseQuantity: number, baseOut: number, quoteOut: number, deepRequired: number }>}
86
+ * An object with base quantity, base out, quote out, and deep required for the dry run
87
+ */
88
+ getQuoteQuantityOut(poolKey: string, baseQuantity: number): Promise<{
89
+ baseQuantity: number;
90
+ baseOut: number;
91
+ quoteOut: number;
92
+ deepRequired: number;
93
+ }>;
94
+ /**
95
+ * @description Get the base quantity out for a given quote quantity
96
+ * @param {string} poolKey Key of the pool
97
+ * @param {number} quoteQuantity Quote quantity to convert
98
+ * @returns {Promise<{ quoteQuantity: number, baseOut: number, quoteOut: number, deepRequired: number }>}
99
+ * An object with quote quantity, base out, quote out, and deep required for the dry run
100
+ */
101
+ getBaseQuantityOut(poolKey: string, quoteQuantity: number): Promise<{
102
+ quoteQuantity: number;
103
+ baseOut: number;
104
+ quoteOut: number;
105
+ deepRequired: number;
106
+ }>;
107
+ /**
108
+ * @description Get the output quantities for given base and quote quantities. Only one quantity can be non-zero
109
+ * @param {string} poolKey Key of the pool
110
+ * @param {number} baseQuantity Base quantity to convert
111
+ * @param {number} quoteQuantity Quote quantity to convert
112
+ * @returns {Promise<{ baseQuantity: number, quoteQuantity: number, baseOut: number, quoteOut: number, deepRequired: number }>}
113
+ * An object with base quantity, quote quantity, base out, quote out, and deep required for the dry run
114
+ */
115
+ getQuantityOut(poolKey: string, baseQuantity: number, quoteQuantity: number): Promise<{
116
+ baseQuantity: number;
117
+ quoteQuantity: number;
118
+ baseOut: number;
119
+ quoteOut: number;
120
+ deepRequired: number;
121
+ }>;
122
+ /**
123
+ * @description Get open orders for a balance manager in a pool
124
+ * @param {string} poolKey Key of the pool
125
+ * @param {string} managerKey Key of the balance manager
126
+ * @returns {Promise<Array>} An array of open order IDs
127
+ */
128
+ accountOpenOrders(poolKey: string, managerKey: string): Promise<string[]>;
129
+ /**
130
+ * @description Get the order information for a specific order in a pool
131
+ * @param {string} poolKey Key of the pool
132
+ * @param {string} orderId Order ID
133
+ * @returns {Promise<Object>} A promise that resolves to an object containing the order information
134
+ */
135
+ getOrder(poolKey: string, orderId: string): Promise<{
136
+ balance_manager_id: string;
137
+ order_id: string;
138
+ client_order_id: string;
139
+ quantity: string;
140
+ filled_quantity: string;
141
+ fee_is_deep: boolean;
142
+ order_deep_price: {
143
+ asset_is_base: boolean;
144
+ deep_per_asset: string;
145
+ };
146
+ epoch: string;
147
+ status: number;
148
+ expire_timestamp: string;
149
+ } | null>;
150
+ /**
151
+ * @description Get the order information for a specific order in a pool, with normalized price
152
+ * @param {string} poolKey Key of the pool
153
+ * @param {string} orderId Order ID
154
+ * @returns {Promise<Object>} A promise that resolves to an object containing the order information with normalized price
155
+ */
156
+ getOrderNormalized(poolKey: string, orderId: string): Promise<{
157
+ quantity: string;
158
+ filled_quantity: string;
159
+ order_deep_price: {
160
+ deep_per_asset: string;
161
+ asset_is_base: boolean;
162
+ };
163
+ isBid: boolean;
164
+ normalized_price: string;
165
+ balance_manager_id: string;
166
+ order_id: string;
167
+ client_order_id: string;
168
+ fee_is_deep: boolean;
169
+ epoch: string;
170
+ status: number;
171
+ expire_timestamp: string;
172
+ } | null>;
173
+ /**
174
+ * @description Retrieves information for multiple specific orders in a pool.
175
+ * @param {string} poolKey - The key identifying the pool from which to retrieve order information.
176
+ * @param {string[]} orderIds - List of order IDs to retrieve information for.
177
+ * @returns {Promise<Object[] | null>} A promise that resolves to an array of order objects, each containing details such as
178
+ * balance manager ID, order ID, client order ID, quantity, filled quantity, fee information, order price, epoch, status,
179
+ * and expiration timestamp. Returns `null` if the retrieval fails.
180
+ */
181
+ getOrders(poolKey: string, orderIds: string[]): Promise<{
182
+ balance_manager_id: string;
183
+ order_id: string;
184
+ client_order_id: string;
185
+ quantity: string;
186
+ filled_quantity: string;
187
+ fee_is_deep: boolean;
188
+ order_deep_price: {
189
+ asset_is_base: boolean;
190
+ deep_per_asset: string;
191
+ };
192
+ epoch: string;
193
+ status: number;
194
+ expire_timestamp: string;
195
+ }[] | null>;
196
+ /**
197
+ * @description Get level 2 order book specifying range of price
198
+ * @param {string} poolKey Key of the pool
199
+ * @param {number} priceLow Lower bound of the price range
200
+ * @param {number} priceHigh Upper bound of the price range
201
+ * @param {boolean} isBid Whether to get bid or ask orders
202
+ * @returns {Promise<{ prices: Array<number>, quantities: Array<number> }>}
203
+ * An object with arrays of prices and quantities
204
+ */
205
+ getLevel2Range(poolKey: string, priceLow: number, priceHigh: number, isBid: boolean): Promise<{
206
+ prices: number[];
207
+ quantities: number[];
208
+ }>;
209
+ /**
210
+ * @description Get level 2 order book ticks from mid-price for a pool
211
+ * @param {string} poolKey Key of the pool
212
+ * @param {number} ticks Number of ticks from mid-price
213
+ * @returns {Promise<{ bid_prices: Array<number>, bid_quantities: Array<number>, ask_prices: Array<number>, ask_quantities: Array<number> }>}
214
+ * An object with arrays of prices and quantities
215
+ */
216
+ getLevel2TicksFromMid(poolKey: string, ticks: number): Promise<{
217
+ bid_prices: number[];
218
+ bid_quantities: number[];
219
+ ask_prices: number[];
220
+ ask_quantities: number[];
221
+ }>;
222
+ /**
223
+ * @description Get the vault balances for a pool
224
+ * @param {string} poolKey Key of the pool
225
+ * @returns {Promise<{ base: number, quote: number, deep: number }>}
226
+ * An object with base, quote, and deep balances in the vault
227
+ */
228
+ vaultBalances(poolKey: string): Promise<{
229
+ base: number;
230
+ quote: number;
231
+ deep: number;
232
+ }>;
233
+ /**
234
+ * @description Get the pool ID by asset types
235
+ * @param {string} baseType Type of the base asset
236
+ * @param {string} quoteType Type of the quote asset
237
+ * @returns {Promise<string>} The address of the pool
238
+ */
239
+ getPoolIdByAssets(baseType: string, quoteType: string): Promise<string>;
240
+ /**
241
+ * @description Get the mid price for a pool
242
+ * @param {string} poolKey Key of the pool
243
+ * @returns {Promise<number>} The mid price
244
+ */
245
+ midPrice(poolKey: string): Promise<number>;
246
+ /**
247
+ * @description Get the trade parameters for a given pool, including taker fee, maker fee, and stake required.
248
+ * @param {string} poolKey Key of the pool
249
+ * @returns {Promise<{ takerFee: number, makerFee: number, stakeRequired: number }>}
250
+ */
251
+ poolTradeParams(poolKey: string): Promise<{
252
+ takerFee: number;
253
+ makerFee: number;
254
+ stakeRequired: number;
255
+ }>;
256
+ /**
257
+ * @description Get the trade parameters for a given pool, including tick size, lot size, and min size.
258
+ * @param {string} poolKey Key of the pool
259
+ * @returns {Promise<{ tickSize: number, lotSize: number, minSize: number }>}
260
+ */
261
+ poolBookParams(poolKey: string): Promise<{
262
+ tickSize: number;
263
+ lotSize: number;
264
+ minSize: number;
265
+ }>;
266
+ /**
267
+ * @description Get the account information for a given pool and balance manager
268
+ * @param {string} poolKey Key of the pool
269
+ * @param {string} managerKey The key of the BalanceManager
270
+ * @returns {Promise<Object>} A promise that resolves to an object containing the account information
271
+ */
272
+ account(poolKey: string, managerKey: string): Promise<{
273
+ epoch: string;
274
+ open_orders: {
275
+ contents: string[];
276
+ };
277
+ taker_volume: number;
278
+ maker_volume: number;
279
+ active_stake: number;
280
+ inactive_stake: number;
281
+ created_proposal: boolean;
282
+ voted_proposal: string | null;
283
+ unclaimed_rebates: {
284
+ base: number;
285
+ quote: number;
286
+ deep: number;
287
+ };
288
+ settled_balances: {
289
+ base: number;
290
+ quote: number;
291
+ deep: number;
292
+ };
293
+ owed_balances: {
294
+ base: number;
295
+ quote: number;
296
+ deep: number;
297
+ };
298
+ }>;
299
+ /**
300
+ * @description Get the locked balances for a pool and balance manager
301
+ * @param {string} poolKey Key of the pool
302
+ * @param {string} managerKey The key of the BalanceManager
303
+ * @returns {Promise<{ base: number, quote: number, deep: number }>}
304
+ * An object with base, quote, and deep locked for the balance manager in the pool
305
+ */
306
+ lockedBalance(poolKey: string, balanceManagerKey: string): Promise<{
307
+ base: number;
308
+ quote: number;
309
+ deep: number;
310
+ }>;
311
+ /**
312
+ * @description Get the DEEP price conversion for a pool
313
+ * @param {string} poolKey Key of the pool
314
+ * @returns {Promise<{ asset_is_base: bool, deep_per_quote: number }>} Deep price conversion
315
+ */
316
+ getPoolDeepPrice(poolKey: string): Promise<{
317
+ asset_is_base: true;
318
+ deep_per_base: number;
319
+ deep_per_quote?: undefined;
320
+ } | {
321
+ asset_is_base: false;
322
+ deep_per_quote: number;
323
+ deep_per_base?: undefined;
324
+ }>;
325
+ /**
326
+ * @description Decode the order ID to get bid/ask status, price, and orderId
327
+ * @param {bigint} encodedOrderId Encoded order ID
328
+ * @returns {Object} Object containing isBid, price, and orderId
329
+ */
330
+ decodeOrderId(encodedOrderId: bigint): {
331
+ isBid: boolean;
332
+ price: number;
333
+ orderId: number;
334
+ };
335
+ /**
336
+ * @description Get all balance manager IDs for a given owner
337
+ * @param {string} owner The owner address to get balance manager IDs for
338
+ * @returns {Promise<string[]>} Array of balance manager ID strings
339
+ */
340
+ getBalanceManagerIds(owner: string): Promise<string[]>;
341
+ /**
342
+ * @description Get the owner of the referral (DeepBookPoolReferral)
343
+ * @param {string} referral The ID of the referral to get the owner of
344
+ * @returns {Promise<string>} The owner of the referral
345
+ */
346
+ balanceManagerReferralOwner(referral: string): Promise<string>;
347
+ /**
348
+ * @description Get the referral balances for a pool and referral (DeepBookPoolReferral)
349
+ * @param {string} poolKey Key of the pool
350
+ * @param {string} referral The referral ID to get balances for
351
+ * @returns {Promise<{ base: number, quote: number, deep: number }>} Object with base, quote, and deep balances
352
+ */
353
+ getPoolReferralBalances(poolKey: string, referral: string): Promise<{
354
+ base: number;
355
+ quote: number;
356
+ deep: number;
357
+ }>;
358
+ /**
359
+ * @description Get the pool ID associated with a referral (DeepBookPoolReferral)
360
+ * @param {string} referral The referral (DeepBookPoolReferral) to get the pool ID for
361
+ * @returns {Promise<string>} The pool ID
362
+ */
363
+ balanceManagerReferralPoolId(referral: string): Promise<string>;
364
+ /**
365
+ * @description Get the multiplier for a referral (DeepBookPoolReferral)
366
+ * @param {string} poolKey Key of the pool
367
+ * @param {string} referral The referral (DeepBookPoolReferral) to get the multiplier for
368
+ * @returns {Promise<number>} The multiplier value
369
+ */
370
+ poolReferralMultiplier(poolKey: string, referral: string): Promise<number>;
371
+ /**
372
+ * @description Get the referral ID from a balance manager for a specific pool
373
+ * @param {string} managerKey Key of the balance manager
374
+ * @param {string} poolKey Key of the pool to get the referral for
375
+ * @returns {Promise<string | null>} The referral ID or null if not set
376
+ */
377
+ getBalanceManagerReferralId(managerKey: string, poolKey: string): Promise<string | null>;
378
+ getPriceInfoObject(tx: Transaction, coinKey: string): Promise<string>;
379
+ /**
380
+ * @description Get the age of the price info object for a specific coin
381
+ * @param {string} coinKey Key of the coin
382
+ * @returns {Promise<string>} The arrival time of the price info object
383
+ */
384
+ getPriceInfoObjectAge(coinKey: string): Promise<any>;
385
+ /**
386
+ * @description Get the margin pool ID
387
+ * @param {string} coinKey The key to identify the margin pool
388
+ * @returns {Promise<string>} The margin pool ID
389
+ */
390
+ getMarginPoolId(coinKey: string): Promise<string>;
391
+ /**
392
+ * @description Check if a deepbook pool is allowed for borrowing from margin pool
393
+ * @param {string} coinKey The key to identify the margin pool
394
+ * @param {string} deepbookPoolId The ID of the deepbook pool
395
+ * @returns {Promise<boolean>} Whether the deepbook pool is allowed
396
+ */
397
+ isDeepbookPoolAllowed(coinKey: string, deepbookPoolId: string): Promise<boolean>;
398
+ /**
399
+ * @description Get the total supply amount in the margin pool
400
+ * @param {string} coinKey The key to identify the margin pool
401
+ * @param {number} decimals Number of decimal places to show (default: 6)
402
+ * @returns {Promise<string>} The total supply amount as a string
403
+ */
404
+ getMarginPoolTotalSupply(coinKey: string, decimals?: number): Promise<string>;
405
+ /**
406
+ * @description Get the total supply shares in the margin pool
407
+ * @param {string} coinKey The key to identify the margin pool
408
+ * @param {number} decimals Number of decimal places to show (default: 6)
409
+ * @returns {Promise<string>} The total supply shares as a string
410
+ */
411
+ getMarginPoolSupplyShares(coinKey: string, decimals?: number): Promise<string>;
412
+ /**
413
+ * @description Get the total borrow amount in the margin pool
414
+ * @param {string} coinKey The key to identify the margin pool
415
+ * @param {number} decimals Number of decimal places to show (default: 6)
416
+ * @returns {Promise<string>} The total borrow amount as a string
417
+ */
418
+ getMarginPoolTotalBorrow(coinKey: string, decimals?: number): Promise<string>;
419
+ /**
420
+ * @description Get the total borrow shares in the margin pool
421
+ * @param {string} coinKey The key to identify the margin pool
422
+ * @param {number} decimals Number of decimal places to show (default: 6)
423
+ * @returns {Promise<string>} The total borrow shares as a string
424
+ */
425
+ getMarginPoolBorrowShares(coinKey: string, decimals?: number): Promise<string>;
426
+ /**
427
+ * @description Get the last update timestamp of the margin pool
428
+ * @param {string} coinKey The key to identify the margin pool
429
+ * @returns {Promise<number>} The last update timestamp in milliseconds
430
+ */
431
+ getMarginPoolLastUpdateTimestamp(coinKey: string): Promise<number>;
432
+ /**
433
+ * @description Get the supply cap of the margin pool
434
+ * @param {string} coinKey The key to identify the margin pool
435
+ * @param {number} decimals Number of decimal places to show (default: 6)
436
+ * @returns {Promise<string>} The supply cap as a string
437
+ */
438
+ getMarginPoolSupplyCap(coinKey: string, decimals?: number): Promise<string>;
439
+ /**
440
+ * @description Get the max utilization rate of the margin pool
441
+ * @param {string} coinKey The key to identify the margin pool
442
+ * @returns {Promise<number>} The max utilization rate (as a decimal, e.g., 0.95 for 95%)
443
+ */
444
+ getMarginPoolMaxUtilizationRate(coinKey: string): Promise<number>;
445
+ /**
446
+ * @description Get the protocol spread of the margin pool
447
+ * @param {string} coinKey The key to identify the margin pool
448
+ * @returns {Promise<number>} The protocol spread (as a decimal)
449
+ */
450
+ getMarginPoolProtocolSpread(coinKey: string): Promise<number>;
451
+ /**
452
+ * @description Get the minimum borrow amount for the margin pool
453
+ * @param {string} coinKey The key to identify the margin pool
454
+ * @param {number} decimals Number of decimal places to show (default: 6)
455
+ * @returns {Promise<string>} The minimum borrow amount as a string
456
+ */
457
+ getMarginPoolMinBorrow(coinKey: string, decimals?: number): Promise<string>;
458
+ /**
459
+ * @description Get the current interest rate of the margin pool
460
+ * @param {string} coinKey The key to identify the margin pool
461
+ * @returns {Promise<number>} The current interest rate (as a decimal)
462
+ */
463
+ getMarginPoolInterestRate(coinKey: string): Promise<number>;
464
+ /**
465
+ * @description Get user supply shares for a supplier cap
466
+ * @param {string} coinKey The key to identify the margin pool
467
+ * @param {string} supplierCapId The ID of the supplier cap
468
+ * @param {number} decimals Number of decimal places to show (default: 6)
469
+ * @returns {Promise<string>} The user's supply shares as a string
470
+ */
471
+ getUserSupplyShares(coinKey: string, supplierCapId: string, decimals?: number): Promise<string>;
472
+ /**
473
+ * @description Get user supply amount for a supplier cap
474
+ * @param {string} coinKey The key to identify the margin pool
475
+ * @param {string} supplierCapId The ID of the supplier cap
476
+ * @param {number} decimals Number of decimal places to show (default: 6)
477
+ * @returns {Promise<string>} The user's supply amount as a string
478
+ */
479
+ getUserSupplyAmount(coinKey: string, supplierCapId: string, decimals?: number): Promise<string>;
480
+ /**
481
+ * @description Get the owner address of a margin manager
482
+ * @param {string} marginManagerKey The key to identify the margin manager
483
+ * @returns {Promise<string>} The owner address
484
+ */
485
+ getMarginManagerOwner(marginManagerKey: string): Promise<string>;
486
+ /**
487
+ * @description Get the DeepBook pool ID associated with a margin manager
488
+ * @param {string} marginManagerKey The key to identify the margin manager
489
+ * @returns {Promise<string>} The DeepBook pool ID
490
+ */
491
+ getMarginManagerDeepbookPool(marginManagerKey: string): Promise<string>;
492
+ /**
493
+ * @description Get the margin pool ID (if any) associated with a margin manager
494
+ * @param {string} marginManagerKey The key to identify the margin manager
495
+ * @returns {Promise<string | null>} The margin pool ID or null if no active loan
496
+ */
497
+ getMarginManagerMarginPoolId(marginManagerKey: string): Promise<string | null>;
498
+ /**
499
+ * @description Get borrowed shares for both base and quote assets
500
+ * @param {string} marginManagerKey The key to identify the margin manager
501
+ * @returns {Promise<{baseShares: string, quoteShares: string}>} The borrowed shares
502
+ */
503
+ getMarginManagerBorrowedShares(marginManagerKey: string): Promise<{
504
+ baseShares: string;
505
+ quoteShares: string;
506
+ }>;
507
+ /**
508
+ * @description Get borrowed base shares
509
+ * @param {string} marginManagerKey The key to identify the margin manager
510
+ * @returns {Promise<string>} The borrowed base shares
511
+ */
512
+ getMarginManagerBorrowedBaseShares(marginManagerKey: string): Promise<string>;
513
+ /**
514
+ * @description Get borrowed quote shares
515
+ * @param {string} marginManagerKey The key to identify the margin manager
516
+ * @returns {Promise<string>} The borrowed quote shares
517
+ */
518
+ getMarginManagerBorrowedQuoteShares(marginManagerKey: string): Promise<string>;
519
+ /**
520
+ * @description Check if margin manager has base asset debt
521
+ * @param {string} marginManagerKey The key to identify the margin manager
522
+ * @returns {Promise<boolean>} True if has base debt, false otherwise
523
+ */
524
+ getMarginManagerHasBaseDebt(marginManagerKey: string): Promise<boolean>;
525
+ /**
526
+ * @description Get the balance manager ID for a margin manager
527
+ * @param {string} marginManagerKey The key to identify the margin manager
528
+ * @returns {Promise<string>} The balance manager ID
529
+ */
530
+ getMarginManagerBalanceManagerId(marginManagerKey: string): Promise<string>;
531
+ /**
532
+ * @description Calculate assets (base and quote) for a margin manager
533
+ * @param {string} marginManagerKey The key to identify the margin manager
534
+ * @param {number} decimals Number of decimal places to show (default: 6)
535
+ * @returns {Promise<{baseAsset: string, quoteAsset: string}>} The base and quote assets
536
+ */
537
+ getMarginManagerAssets(marginManagerKey: string, decimals?: number): Promise<{
538
+ baseAsset: string;
539
+ quoteAsset: string;
540
+ }>;
541
+ /**
542
+ * @description Calculate debts (base and quote) for a margin manager
543
+ * NOTE: This function automatically determines whether to use base or quote margin pool
544
+ * based on hasBaseDebt. You don't need to specify the debt coin type.
545
+ * @param {string} marginManagerKey The key to identify the margin manager
546
+ * @param {number} decimals Number of decimal places to show (default: 6)
547
+ * @returns {Promise<{baseDebt: string, quoteDebt: string}>} The base and quote debts
548
+ */
549
+ getMarginManagerDebts(marginManagerKey: string, decimals?: number): Promise<{
550
+ baseDebt: string;
551
+ quoteDebt: string;
552
+ }>;
553
+ /**
554
+ * @description Get comprehensive state information for a margin manager
555
+ * @param {string} marginManagerKey The key to identify the margin manager
556
+ * @param {number} decimals Number of decimal places to show (default: 6)
557
+ * @returns {Promise<{
558
+ * managerId: string,
559
+ * deepbookPoolId: string,
560
+ * riskRatio: number,
561
+ * baseAsset: string,
562
+ * quoteAsset: string,
563
+ * baseDebt: string,
564
+ * quoteDebt: string,
565
+ * basePythPrice: string,
566
+ * basePythDecimals: number,
567
+ * quotePythPrice: string,
568
+ * quotePythDecimals: number
569
+ * }>} Comprehensive margin manager state
570
+ */
571
+ getMarginManagerState(marginManagerKey: string, decimals?: number): Promise<{
572
+ managerId: string;
573
+ deepbookPoolId: string;
574
+ riskRatio: number;
575
+ baseAsset: string;
576
+ quoteAsset: string;
577
+ baseDebt: string;
578
+ quoteDebt: string;
579
+ basePythPrice: string;
580
+ basePythDecimals: number;
581
+ quotePythPrice: string;
582
+ quotePythDecimals: number;
583
+ currentPrice: bigint;
584
+ lowestTriggerAbovePrice: bigint;
585
+ highestTriggerBelowPrice: bigint;
586
+ }>;
587
+ /**
588
+ * @description Get the base asset balance of a margin manager
589
+ * @param {string} marginManagerKey The key to identify the margin manager
590
+ * @param {number} decimals Number of decimal places to show (default: 6)
591
+ * @returns {Promise<string>} The base asset balance
592
+ */
593
+ getMarginManagerBaseBalance(marginManagerKey: string, decimals?: number): Promise<string>;
594
+ /**
595
+ * @description Get the quote asset balance of a margin manager
596
+ * @param {string} marginManagerKey The key to identify the margin manager
597
+ * @param {number} decimals Number of decimal places to show (default: 6)
598
+ * @returns {Promise<string>} The quote asset balance
599
+ */
600
+ getMarginManagerQuoteBalance(marginManagerKey: string, decimals?: number): Promise<string>;
601
+ /**
602
+ * @description Get the DEEP token balance of a margin manager
603
+ * @param {string} marginManagerKey The key to identify the margin manager
604
+ * @param {number} decimals Number of decimal places to show (default: 6)
605
+ * @returns {Promise<string>} The DEEP token balance
606
+ */
607
+ getMarginManagerDeepBalance(marginManagerKey: string, decimals?: number): Promise<string>;
608
+ /**
609
+ * @description Get all conditional order IDs for a margin manager
610
+ * @param {string} marginManagerKey The key to identify the margin manager
611
+ * @returns {Promise<string[]>} Array of conditional order IDs
612
+ */
613
+ getConditionalOrderIds(marginManagerKey: string): Promise<string[]>;
614
+ /**
615
+ * @description Get the lowest trigger price for trigger_above orders
616
+ * Returns MAX_U64 if there are no trigger_above orders
617
+ * @param {string} marginManagerKey The key to identify the margin manager
618
+ * @returns {Promise<bigint>} The lowest trigger above price
619
+ */
620
+ getLowestTriggerAbovePrice(marginManagerKey: string): Promise<bigint>;
621
+ /**
622
+ * @description Get the highest trigger price for trigger_below orders
623
+ * Returns 0 if there are no trigger_below orders
624
+ * @param {string} marginManagerKey The key to identify the margin manager
625
+ * @returns {Promise<bigint>} The highest trigger below price
626
+ */
627
+ getHighestTriggerBelowPrice(marginManagerKey: string): Promise<bigint>;
628
+ /**
629
+ * @description Check if a deepbook pool is enabled for margin trading
630
+ * @param {string} poolKey The key to identify the pool
631
+ * @returns {Promise<boolean>} True if the pool is enabled for margin trading
632
+ */
633
+ isPoolEnabledForMargin(poolKey: string): Promise<boolean>;
634
+ /**
635
+ * @description Get the margin manager IDs for a given owner address
636
+ * @param {string} owner The owner address
637
+ * @returns {Promise<string[]>} Array of margin manager IDs
638
+ */
639
+ getMarginManagerIdsForOwner(owner: string): Promise<string[]>;
640
+ /**
641
+ * @description Get the base margin pool ID for a deepbook pool
642
+ * @param {string} poolKey The key to identify the pool
643
+ * @returns {Promise<string>} The base margin pool ID
644
+ */
645
+ getBaseMarginPoolId(poolKey: string): Promise<string>;
646
+ /**
647
+ * @description Get the quote margin pool ID for a deepbook pool
648
+ * @param {string} poolKey The key to identify the pool
649
+ * @returns {Promise<string>} The quote margin pool ID
650
+ */
651
+ getQuoteMarginPoolId(poolKey: string): Promise<string>;
652
+ /**
653
+ * @description Get the minimum withdraw risk ratio for a deepbook pool
654
+ * @param {string} poolKey The key to identify the pool
655
+ * @returns {Promise<number>} The minimum withdraw risk ratio as a decimal (e.g., 1.5 for 150%)
656
+ */
657
+ getMinWithdrawRiskRatio(poolKey: string): Promise<number>;
658
+ /**
659
+ * @description Get the minimum borrow risk ratio for a deepbook pool
660
+ * @param {string} poolKey The key to identify the pool
661
+ * @returns {Promise<number>} The minimum borrow risk ratio as a decimal (e.g., 1.25 for 125%)
662
+ */
663
+ getMinBorrowRiskRatio(poolKey: string): Promise<number>;
664
+ /**
665
+ * @description Get the liquidation risk ratio for a deepbook pool
666
+ * @param {string} poolKey The key to identify the pool
667
+ * @returns {Promise<number>} The liquidation risk ratio as a decimal (e.g., 1.125 for 112.5%)
668
+ */
669
+ getLiquidationRiskRatio(poolKey: string): Promise<number>;
670
+ /**
671
+ * @description Get the target liquidation risk ratio for a deepbook pool
672
+ * @param {string} poolKey The key to identify the pool
673
+ * @returns {Promise<number>} The target liquidation risk ratio as a decimal (e.g., 1.25 for 125%)
674
+ */
675
+ getTargetLiquidationRiskRatio(poolKey: string): Promise<number>;
676
+ /**
677
+ * @description Get the user liquidation reward for a deepbook pool
678
+ * @param {string} poolKey The key to identify the pool
679
+ * @returns {Promise<number>} The user liquidation reward as a decimal (e.g., 0.05 for 5%)
680
+ */
681
+ getUserLiquidationReward(poolKey: string): Promise<number>;
682
+ /**
683
+ * @description Get the pool liquidation reward for a deepbook pool
684
+ * @param {string} poolKey The key to identify the pool
685
+ * @returns {Promise<number>} The pool liquidation reward as a decimal (e.g., 0.05 for 5%)
686
+ */
687
+ getPoolLiquidationReward(poolKey: string): Promise<number>;
688
+ /**
689
+ * @description Get all allowed maintainer cap IDs
690
+ * @returns {Promise<string[]>} Array of allowed maintainer cap IDs
691
+ */
692
+ getAllowedMaintainers(): Promise<string[]>;
693
+ /**
694
+ * @description Get all allowed pause cap IDs
695
+ * @returns {Promise<string[]>} Array of allowed pause cap IDs
696
+ */
697
+ getAllowedPauseCaps(): Promise<string[]>;
698
+ /**
699
+ * @description Check if a pool is a stable pool
700
+ * @param {string} poolKey Key of the pool
701
+ * @returns {Promise<boolean>} Whether the pool is a stable pool
702
+ */
703
+ stablePool(poolKey: string): Promise<boolean>;
704
+ /**
705
+ * @description Check if a pool is registered
706
+ * @param {string} poolKey Key of the pool
707
+ * @returns {Promise<boolean>} Whether the pool is registered
708
+ */
709
+ registeredPool(poolKey: string): Promise<boolean>;
710
+ /**
711
+ * @description Get the quote quantity out using input token as fee
712
+ * @param {string} poolKey Key of the pool
713
+ * @param {number} baseQuantity Base quantity
714
+ * @returns {Promise<{baseQuantity: number, baseOut: number, quoteOut: number, deepRequired: number}>}
715
+ */
716
+ getQuoteQuantityOutInputFee(poolKey: string, baseQuantity: number): Promise<{
717
+ baseQuantity: number;
718
+ baseOut: number;
719
+ quoteOut: number;
720
+ deepRequired: number;
721
+ }>;
722
+ /**
723
+ * @description Get the base quantity out using input token as fee
724
+ * @param {string} poolKey Key of the pool
725
+ * @param {number} quoteQuantity Quote quantity
726
+ * @returns {Promise<{quoteQuantity: number, baseOut: number, quoteOut: number, deepRequired: number}>}
727
+ */
728
+ getBaseQuantityOutInputFee(poolKey: string, quoteQuantity: number): Promise<{
729
+ quoteQuantity: number;
730
+ baseOut: number;
731
+ quoteOut: number;
732
+ deepRequired: number;
733
+ }>;
734
+ /**
735
+ * @description Get the quantity out using input token as fee
736
+ * @param {string} poolKey Key of the pool
737
+ * @param {number} baseQuantity Base quantity
738
+ * @param {number} quoteQuantity Quote quantity
739
+ * @returns {Promise<{baseQuantity: number, quoteQuantity: number, baseOut: number, quoteOut: number, deepRequired: number}>}
740
+ */
741
+ getQuantityOutInputFee(poolKey: string, baseQuantity: number, quoteQuantity: number): Promise<{
742
+ baseQuantity: number;
743
+ quoteQuantity: number;
744
+ baseOut: number;
745
+ quoteOut: number;
746
+ deepRequired: number;
747
+ }>;
748
+ /**
749
+ * @description Get the base quantity needed to receive target quote quantity
750
+ * @param {string} poolKey Key of the pool
751
+ * @param {number} targetQuoteQuantity Target quote quantity
752
+ * @param {boolean} payWithDeep Whether to pay fees with DEEP
753
+ * @returns {Promise<{baseIn: number, quoteOut: number, deepRequired: number}>}
754
+ */
755
+ getBaseQuantityIn(poolKey: string, targetQuoteQuantity: number, payWithDeep: boolean): Promise<{
756
+ baseIn: number;
757
+ quoteOut: number;
758
+ deepRequired: number;
759
+ }>;
760
+ /**
761
+ * @description Get the quote quantity needed to receive target base quantity
762
+ * @param {string} poolKey Key of the pool
763
+ * @param {number} targetBaseQuantity Target base quantity
764
+ * @param {boolean} payWithDeep Whether to pay fees with DEEP
765
+ * @returns {Promise<{baseOut: number, quoteIn: number, deepRequired: number}>}
766
+ */
767
+ getQuoteQuantityIn(poolKey: string, targetBaseQuantity: number, payWithDeep: boolean): Promise<{
768
+ baseOut: number;
769
+ quoteIn: number;
770
+ deepRequired: number;
771
+ }>;
772
+ /**
773
+ * @description Get account order details for a balance manager
774
+ * @param {string} poolKey Key of the pool
775
+ * @param {string} managerKey Key of the balance manager
776
+ * @returns {Promise<Array>} Array of order details
777
+ */
778
+ getAccountOrderDetails(poolKey: string, managerKey: string): Promise<{
779
+ balance_manager_id: string;
780
+ order_id: string;
781
+ client_order_id: string;
782
+ quantity: string;
783
+ filled_quantity: string;
784
+ fee_is_deep: boolean;
785
+ order_deep_price: {
786
+ asset_is_base: boolean;
787
+ deep_per_asset: string;
788
+ };
789
+ epoch: string;
790
+ status: number;
791
+ expire_timestamp: string;
792
+ }[]>;
793
+ /**
794
+ * @description Get the DEEP required for an order
795
+ * @param {string} poolKey Key of the pool
796
+ * @param {number} baseQuantity Base quantity
797
+ * @param {number} price Price
798
+ * @returns {Promise<{deepRequiredTaker: number, deepRequiredMaker: number}>}
799
+ */
800
+ getOrderDeepRequired(poolKey: string, baseQuantity: number, price: number): Promise<{
801
+ deepRequiredTaker: number;
802
+ deepRequiredMaker: number;
803
+ }>;
804
+ /**
805
+ * @description Check if account exists for a balance manager
806
+ * @param {string} poolKey Key of the pool
807
+ * @param {string} managerKey Key of the balance manager
808
+ * @returns {Promise<boolean>} Whether account exists
809
+ */
810
+ accountExists(poolKey: string, managerKey: string): Promise<boolean>;
811
+ /**
812
+ * @description Get the next epoch trade parameters
813
+ * @param {string} poolKey Key of the pool
814
+ * @returns {Promise<{takerFee: number, makerFee: number, stakeRequired: number}>}
815
+ */
816
+ poolTradeParamsNext(poolKey: string): Promise<{
817
+ takerFee: number;
818
+ makerFee: number;
819
+ stakeRequired: number;
820
+ }>;
821
+ /**
822
+ * @description Get the quorum for a pool
823
+ * @param {string} poolKey Key of the pool
824
+ * @returns {Promise<number>} The quorum amount in DEEP
825
+ */
826
+ quorum(poolKey: string): Promise<number>;
827
+ /**
828
+ * @description Get the pool ID
829
+ * @param {string} poolKey Key of the pool
830
+ * @returns {Promise<string>} The pool ID
831
+ */
832
+ poolId(poolKey: string): Promise<string>;
833
+ /**
834
+ * @description Check if a limit order can be placed
835
+ * @param {CanPlaceLimitOrderParams} params Parameters for checking limit order placement
836
+ * @returns {Promise<boolean>} Whether order can be placed
837
+ */
838
+ canPlaceLimitOrder(params: CanPlaceLimitOrderParams): Promise<boolean>;
839
+ /**
840
+ * @description Check if a market order can be placed
841
+ * @param {CanPlaceMarketOrderParams} params Parameters for checking market order placement
842
+ * @returns {Promise<boolean>} Whether order can be placed
843
+ */
844
+ canPlaceMarketOrder(params: CanPlaceMarketOrderParams): Promise<boolean>;
845
+ /**
846
+ * @description Check if market order params are valid
847
+ * @param {string} poolKey Key of the pool
848
+ * @param {number} quantity Quantity
849
+ * @returns {Promise<boolean>} Whether params are valid
850
+ */
851
+ checkMarketOrderParams(poolKey: string, quantity: number): Promise<boolean>;
852
+ /**
853
+ * @description Check if limit order params are valid
854
+ * @param {string} poolKey Key of the pool
855
+ * @param {number} price Price
856
+ * @param {number} quantity Quantity
857
+ * @param {number} expireTimestamp Expiration timestamp
858
+ * @returns {Promise<boolean>} Whether params are valid
859
+ */
860
+ checkLimitOrderParams(poolKey: string, price: number, quantity: number, expireTimestamp: number): Promise<boolean>;
861
+ }