@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,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/pyth/pyth.ts"],
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@haneullabs/haneul/bcs';\nimport type { HaneulClient } from '@haneullabs/haneul/client';\nimport type { Transaction } from '@haneullabs/haneul/transactions';\nimport { coinWithBalance } from '@haneullabs/haneul/transactions';\nimport { fromBase64, fromHex, parseStructTag } from '@haneullabs/haneul/utils';\n\nimport type { HexString } from './PriceServiceConnection.js';\nimport { PriceServiceConnection } from './PriceServiceConnection.js';\nimport { extractVaaBytesFromAccumulatorMessage } from './pyth-helpers.js';\n\nconst MAX_ARGUMENT_SIZE = 16 * 1024;\nexport type ObjectId = string;\nexport class HaneulPriceServiceConnection extends PriceServiceConnection {\n\t/**\n\t * Fetch price feed update data.\n\t *\n\t * @param priceIds Array of hex-encoded price IDs.\n\t * @returns Array of buffers containing the price update data.\n\t */\n\tasync getPriceFeedsUpdateData(priceIds: HexString[]): Promise<Uint8Array[]> {\n\t\tconst latestVaas = await this.getLatestVaas(priceIds);\n\t\treturn latestVaas.map((vaa) => fromBase64(vaa));\n\t}\n}\nexport class HaneulPythClient {\n\t#pythPackageId?: Promise<ObjectId>;\n\t#wormholePackageId?: Promise<ObjectId>;\n\t#priceFeedObjectIdCache: Map<HexString, Promise<ObjectId>> = new Map();\n\t#priceTableInfo?: Promise<{ id: ObjectId; fieldType: ObjectId }>;\n\t#baseUpdateFee?: Promise<number>;\n\tprovider: HaneulClient;\n\tpythStateId: ObjectId;\n\twormholeStateId: ObjectId;\n\n\tconstructor(provider: HaneulClient, pythStateId: ObjectId, wormholeStateId: ObjectId) {\n\t\tthis.provider = provider;\n\t\tthis.pythStateId = pythStateId;\n\t\tthis.wormholeStateId = wormholeStateId;\n\t}\n\t/**\n\t * Verifies the VAAs using the Wormhole contract.\n\t *\n\t * @param vaas Array of VAA buffers to verify.\n\t * @param tx Transaction block to add commands to.\n\t * @returns Array of verified VAAs.\n\t */\n\tasync verifyVaas(vaas: Uint8Array[], tx: Transaction) {\n\t\tconst wormholePackageId = await this.getWormholePackageId();\n\t\tconst verifiedVaas = [];\n\t\tfor (const vaa of vaas) {\n\t\t\tconst [verifiedVaa] = tx.moveCall({\n\t\t\t\ttarget: `${wormholePackageId}::vaa::parse_and_verify`,\n\t\t\t\targuments: [tx.object(this.wormholeStateId), tx.pure.vector('u8', vaa), tx.object.clock()],\n\t\t\t});\n\t\t\tverifiedVaas.push(verifiedVaa);\n\t\t}\n\t\treturn verifiedVaas;\n\t}\n\t/**\n\t * Adds the necessary commands for updating the Pyth price feeds to the transaction block.\n\t *\n\t * @param tx Transaction block to add commands to.\n\t * @param updates Array of price feed updates received from the price service.\n\t * @param feedIds Array of feed IDs to update (in hex format).\n\t */\n\tasync updatePriceFeeds(\n\t\ttx: Transaction,\n\t\tupdates: Uint8Array[],\n\t\tfeedIds: HexString[],\n\t): Promise<ObjectId[]> {\n\t\tconst packageId = await this.getPythPackageId();\n\t\tlet priceUpdatesHotPotato;\n\t\tif (updates.length > 1) {\n\t\t\tthrow new Error(\n\t\t\t\t'SDK does not support sending multiple accumulator messages in a single transaction',\n\t\t\t);\n\t\t}\n\t\tconst vaa = extractVaaBytesFromAccumulatorMessage(updates[0]);\n\t\tconst verifiedVaas = await this.verifyVaas([vaa], tx);\n\t\t[priceUpdatesHotPotato] = tx.moveCall({\n\t\t\ttarget: `${packageId}::pyth::create_authenticated_price_infos_using_accumulator`,\n\t\t\targuments: [\n\t\t\t\ttx.object(this.pythStateId),\n\t\t\t\ttx.pure(\n\t\t\t\t\tbcs\n\t\t\t\t\t\t.vector(bcs.U8)\n\t\t\t\t\t\t.serialize(Array.from(updates[0]), {\n\t\t\t\t\t\t\tmaxSize: MAX_ARGUMENT_SIZE,\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.toBytes(),\n\t\t\t\t),\n\t\t\t\tverifiedVaas[0],\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t});\n\t\tconst priceInfoObjects: ObjectId[] = [];\n\t\tconst baseUpdateFee = await this.getBaseUpdateFee();\n\t\tfor (const feedId of feedIds) {\n\t\t\tconst priceInfoObjectId = await this.getPriceFeedObjectId(feedId);\n\t\t\tif (!priceInfoObjectId) {\n\t\t\t\tthrow new Error(`Price feed ${feedId} not found, please create it first`);\n\t\t\t}\n\t\t\tpriceInfoObjects.push(priceInfoObjectId);\n\t\t\t[priceUpdatesHotPotato] = tx.moveCall({\n\t\t\t\ttarget: `${packageId}::pyth::update_single_price_feed`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(this.pythStateId),\n\t\t\t\t\tpriceUpdatesHotPotato,\n\t\t\t\t\ttx.object(priceInfoObjectId),\n\t\t\t\t\tcoinWithBalance({ balance: baseUpdateFee }),\n\t\t\t\t\ttx.object.clock(),\n\t\t\t\t],\n\t\t\t});\n\t\t}\n\t\ttx.moveCall({\n\t\t\ttarget: `${packageId}::hot_potato_vector::destroy`,\n\t\t\targuments: [priceUpdatesHotPotato],\n\t\t\ttypeArguments: [`${packageId}::price_info::PriceInfo`],\n\t\t});\n\t\treturn priceInfoObjects;\n\t}\n\t/**\n\t * Get the price feed object ID for a given feed ID, caching the promise.\n\t * @param feedId\n\t */\n\tgetPriceFeedObjectId(feedId: HexString): Promise<ObjectId | undefined> {\n\t\tif (!this.#priceFeedObjectIdCache.has(feedId)) {\n\t\t\tthis.#priceFeedObjectIdCache.set(\n\t\t\t\tfeedId,\n\t\t\t\tthis.#fetchPriceFeedObjectId(feedId).catch((err) => {\n\t\t\t\t\t// Remove failed promises from the cache to allow retries\n\t\t\t\t\tthis.#priceFeedObjectIdCache.delete(feedId);\n\t\t\t\t\tthrow err;\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\treturn this.#priceFeedObjectIdCache.get(feedId)!;\n\t}\n\n\t/**\n\t * Fetches the price feed object ID for a given feed ID (no caching).\n\t * Throws an error if the object is not found.\n\t */\n\tasync #fetchPriceFeedObjectId(feedId: HexString): Promise<ObjectId> {\n\t\tconst { id: tableId, fieldType } = await this.getPriceTableInfo();\n\t\tconst result = await this.provider.getDynamicFieldObject({\n\t\t\tparentId: tableId,\n\t\t\tname: {\n\t\t\t\ttype: `${fieldType}::price_identifier::PriceIdentifier`,\n\t\t\t\tvalue: {\n\t\t\t\t\tbytes: Array.from(fromHex(feedId)),\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\tif (!result.data || !result.data.content) {\n\t\t\tthrow new Error(`Price feed object ID for feed ID ${feedId} not found.`);\n\t\t}\n\t\tif (result.data.content.dataType !== 'moveObject') {\n\t\t\tthrow new Error('Price feed type mismatch');\n\t\t}\n\n\t\tconst fields = result.data.content.fields as { value: string };\n\t\treturn fields.value;\n\t}\n\n\t/**\n\t * Fetches the price table object ID for the current state ID, caching the promise.\n\t * @returns Price table object ID and field type\n\t */\n\tgetPriceTableInfo(): Promise<{ id: ObjectId; fieldType: ObjectId }> {\n\t\tif (!this.#priceTableInfo) {\n\t\t\tconst promise = this.#fetchPriceTableInfo().catch((err) => {\n\t\t\t\t// Clear the cached promise on error\n\t\t\t\tthis.#priceTableInfo = undefined;\n\t\t\t\tthrow err;\n\t\t\t});\n\n\t\t\tthis.#priceTableInfo = promise;\n\t\t}\n\n\t\treturn this.#priceTableInfo;\n\t}\n\n\t/**\n\t * Fetches the price table object ID and field type (no caching).\n\t * @returns Price table object ID and field type\n\t */\n\tasync #fetchPriceTableInfo(): Promise<{ id: ObjectId; fieldType: ObjectId }> {\n\t\tconst result = await this.provider.getDynamicFieldObject({\n\t\t\tparentId: this.pythStateId,\n\t\t\tname: {\n\t\t\t\ttype: 'vector<u8>',\n\t\t\t\tvalue: 'price_info',\n\t\t\t},\n\t\t});\n\n\t\tif (!result.data || !result.data.type) {\n\t\t\tthrow new Error('Price Table not found, contract may not be initialized');\n\t\t}\n\n\t\tconst priceIdentifier = parseStructTag(result.data.type).typeParams[0];\n\t\tif (\n\t\t\ttypeof priceIdentifier === 'object' &&\n\t\t\tpriceIdentifier !== null &&\n\t\t\tpriceIdentifier.name === 'PriceIdentifier' &&\n\t\t\t'address' in priceIdentifier\n\t\t) {\n\t\t\treturn { id: result.data.objectId, fieldType: priceIdentifier.address };\n\t\t} else {\n\t\t\tthrow new Error('fieldType not found');\n\t\t}\n\t}\n\t/**\n\t * Fetches the package ID for the Wormhole contract, with caching.\n\t */\n\tgetWormholePackageId(): Promise<ObjectId> {\n\t\tif (!this.#wormholePackageId) {\n\t\t\tthis.#wormholePackageId = this.#fetchWormholePackageId();\n\t\t}\n\t\treturn this.#wormholePackageId;\n\t}\n\n\t/**\n\t * Fetches the package ID for the Wormhole contract (no caching).\n\t */\n\tasync #fetchWormholePackageId(): Promise<ObjectId> {\n\t\treturn await this.#getPackageId(this.wormholeStateId);\n\t}\n\n\t/**\n\t * Fetches the package ID for the Pyth contract, with caching.\n\t */\n\tgetPythPackageId(): Promise<ObjectId> {\n\t\tif (!this.#pythPackageId) {\n\t\t\tthis.#pythPackageId = this.#fetchPythPackageId();\n\t\t}\n\t\treturn this.#pythPackageId;\n\t}\n\n\t/**\n\t * Fetches the package ID for the Pyth contract (no caching).\n\t */\n\tasync #fetchPythPackageId(): Promise<ObjectId> {\n\t\treturn await this.#getPackageId(this.pythStateId);\n\t}\n\n\t/**\n\t * Fetches the package ID for a given object.\n\t *\n\t * @param objectId Object ID to fetch the package ID for.\n\t */\n\tasync #getPackageId(objectId: ObjectId): Promise<ObjectId> {\n\t\tconst result = await this.provider.getObject({\n\t\t\tid: objectId,\n\t\t\toptions: { showContent: true },\n\t\t});\n\n\t\tif (\n\t\t\tresult.data?.content?.dataType === 'moveObject' &&\n\t\t\t'upgrade_cap' in result.data.content.fields\n\t\t) {\n\t\t\tconst fields = result.data.content.fields as {\n\t\t\t\tupgrade_cap: {\n\t\t\t\t\tfields: {\n\t\t\t\t\t\tpackage: ObjectId;\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t};\n\t\t\treturn fields.upgrade_cap.fields.package;\n\t\t}\n\n\t\tthrow new Error(`Cannot fetch package ID for object ${objectId}`);\n\t}\n\t/**\n\t * Gets the base update fee from the Pyth state object.\n\t */\n\tasync #fetchBaseUpdateFee(): Promise<number> {\n\t\tconst result = await this.provider.getObject({\n\t\t\tid: this.pythStateId,\n\t\t\toptions: { showContent: true },\n\t\t});\n\n\t\tif (!result.data || result.data.content?.dataType !== 'moveObject') {\n\t\t\tthrow new Error('Unable to fetch Pyth state object');\n\t\t}\n\n\t\tconst fields = result.data.content.fields as { base_update_fee: number };\n\t\treturn fields.base_update_fee;\n\t}\n\n\t/**\n\t * Returns the cached base update fee, fetching it if necessary.\n\t */\n\tgetBaseUpdateFee(): Promise<number> {\n\t\tif (!this.#baseUpdateFee) {\n\t\t\tthis.#baseUpdateFee = this.#fetchBaseUpdateFee();\n\t\t}\n\t\treturn this.#baseUpdateFee;\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAAoB;AAGpB,0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Y,OAAO;AAAA,EAClC;AAEA,QAAM,IAAI,MAAM,sCAAsC,QAAQ,EAAE;AACjE;AAIM,wBAAmB,iBAAoB;AAC5C,QAAM,SAAS,MAAM,KAAK,SAAS,UAAU;AAAA,IAC5C,IAAI,KAAK;AAAA,IACT,SAAS,EAAE,aAAa,KAAK;AAAA,EAC9B,CAAC;AAED,MAAI,CAAC,OAAO,QAAQ,OAAO,KAAK,SAAS,aAAa,cAAc;AACnE,UAAM,IAAI,MAAM,mCAAmC;AAAA,EACpD;AAEA,QAAM,SAAS,OAAO,KAAK,QAAQ;AACnC,SAAO,OAAO;AACf;",
6
+ "names": []
7
+ }
@@ -0,0 +1,168 @@
1
+ import type { Transaction, TransactionArgument } from '@haneullabs/haneul/transactions';
2
+ import type { DeepBookConfig } from '../utils/config.js';
3
+ /**
4
+ * BalanceManagerContract class for managing BalanceManager operations.
5
+ */
6
+ export declare class BalanceManagerContract {
7
+ #private;
8
+ /**
9
+ * @param {DeepBookConfig} config Configuration for BalanceManagerContract
10
+ */
11
+ constructor(config: DeepBookConfig);
12
+ /**
13
+ * @description Create and share a new BalanceManager
14
+ * @returns A function that takes a Transaction object
15
+ */
16
+ createAndShareBalanceManager: () => (tx: Transaction) => void;
17
+ /**
18
+ * @description Create a new BalanceManager, manually set the owner. Returns the manager.
19
+ * @returns A function that takes a Transaction object
20
+ */
21
+ createBalanceManagerWithOwner: (ownerAddress: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
22
+ /**
23
+ * @description Share the BalanceManager
24
+ * @param {TransactionArgument} manager The BalanceManager to share
25
+ * @returns A function that takes a Transaction object
26
+ */
27
+ shareBalanceManager: (manager: TransactionArgument) => (tx: Transaction) => void;
28
+ /**
29
+ * @description Deposit funds into the BalanceManager
30
+ * @param {string} managerKey The key of the BalanceManager
31
+ * @param {string} coinKey The key of the coin to deposit
32
+ * @param {number} amountToDeposit The amount to deposit
33
+ * @returns A function that takes a Transaction object
34
+ */
35
+ depositIntoManager: (managerKey: string, coinKey: string, amountToDeposit: number) => (tx: Transaction) => void;
36
+ /**
37
+ * @description Withdraw funds from the BalanceManager
38
+ * @param {string} managerKey The key of the BalanceManager
39
+ * @param {string} coinKey The key of the coin to withdraw
40
+ * @param {number} amountToWithdraw The amount to withdraw
41
+ * @param {string} recipient The recipient of the withdrawn funds
42
+ * @returns A function that takes a Transaction object
43
+ */
44
+ withdrawFromManager: (managerKey: string, coinKey: string, amountToWithdraw: number, recipient: string) => (tx: Transaction) => void;
45
+ /**
46
+ * @description Withdraw all funds from the BalanceManager
47
+ * @param {string} managerKey The key of the BalanceManager
48
+ * @param {string} coinKey The key of the coin to withdraw
49
+ * @param {string} recipient The recipient of the withdrawn funds
50
+ * @returns A function that takes a Transaction object
51
+ */
52
+ withdrawAllFromManager: (managerKey: string, coinKey: string, recipient: string) => (tx: Transaction) => void;
53
+ /**
54
+ * @description Check the balance of the BalanceManager
55
+ * @param {string} managerKey The key of the BalanceManager
56
+ * @param {string} coinKey The key of the coin to check the balance of
57
+ * @returns A function that takes a Transaction object
58
+ */
59
+ checkManagerBalance: (managerKey: string, coinKey: string) => (tx: Transaction) => void;
60
+ /**
61
+ * @description Generate a trade proof for the BalanceManager. Calls the appropriate function based on whether tradeCap is set.
62
+ * @param {string} managerKey The key of the BalanceManager
63
+ * @returns A function that takes a Transaction object
64
+ */
65
+ generateProof: (managerKey: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
66
+ /**
67
+ * @description Generate a trade proof as the owner
68
+ * @param {string} managerId The ID of the BalanceManager
69
+ * @returns A function that takes a Transaction object
70
+ */
71
+ generateProofAsOwner: (managerId: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
72
+ /**
73
+ * @description Generate a trade proof as a trader
74
+ * @param {string} managerId The ID of the BalanceManager
75
+ * @param {string} tradeCapId The ID of the tradeCap
76
+ * @returns A function that takes a Transaction object
77
+ */
78
+ generateProofAsTrader: (managerId: string, tradeCapId: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
79
+ /**
80
+ * @description Mint a TradeCap
81
+ * @param {string} managerKey The name of the BalanceManager
82
+ * @returns A function that takes a Transaction object
83
+ */
84
+ mintTradeCap: (managerKey: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
85
+ /**
86
+ * @description Mint a DepositCap
87
+ * @param {string} managerKey The name of the BalanceManager
88
+ * @returns A function that takes a Transaction object
89
+ */
90
+ mintDepositCap: (managerKey: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
91
+ /**
92
+ * @description Mint a WithdrawalCap
93
+ * @param {string} managerKey The name of the BalanceManager
94
+ * @returns A function that takes a Transaction object
95
+ */
96
+ mintWithdrawalCap: (managerKey: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
97
+ /**
98
+ * @description Deposit using the DepositCap
99
+ * @param {string} managerKey The name of the BalanceManager
100
+ * @param {string} coinKey The name of the coin to deposit
101
+ * @param {number} amountToDeposit The amount to deposit
102
+ * @returns A function that takes a Transaction object
103
+ */
104
+ depositWithCap: (managerKey: string, coinKey: string, amountToDeposit: number) => (tx: Transaction) => void;
105
+ /**
106
+ * @description Withdraw using the WithdrawCap
107
+ * @param {string} managerKey The name of the BalanceManager
108
+ * @param {string} coinKey The name of the coin to withdraw
109
+ * @param {number} amountToWithdraw The amount to withdraw
110
+ * @returns A function that takes a Transaction object
111
+ */
112
+ withdrawWithCap: (managerKey: string, coinKey: string, amountToWithdraw: number) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
113
+ /**
114
+ * @description Set the referral for the BalanceManager for a specific pool
115
+ * @param {string} managerKey The name of the BalanceManager
116
+ * @param {string} referral The referral (DeepBookPoolReferral) to set the BalanceManager to
117
+ * @param {TransactionArgument} tradeCap The tradeCap for permission checking
118
+ * @returns A function that takes a Transaction object
119
+ */
120
+ setBalanceManagerReferral: (managerKey: string, referral: string, tradeCap: TransactionArgument) => (tx: Transaction) => void;
121
+ /**
122
+ * @description Unset the referral for the BalanceManager for a specific pool
123
+ * @param {string} managerKey The name of the BalanceManager
124
+ * @param {string} poolKey The key of the pool to unset the referral for
125
+ * @param {TransactionArgument} tradeCap The tradeCap for permission checking
126
+ * @returns A function that takes a Transaction object
127
+ */
128
+ unsetBalanceManagerReferral: (managerKey: string, poolKey: string, tradeCap: TransactionArgument) => (tx: Transaction) => void;
129
+ registerBalanceManager: (managerKey: string) => (tx: Transaction) => void;
130
+ /**
131
+ * @description Get the owner of the BalanceManager
132
+ * @param {string} managerKey The key of the BalanceManager
133
+ * @returns A function that takes a Transaction object
134
+ */
135
+ owner: (managerKey: string) => (tx: Transaction) => void;
136
+ /**
137
+ * @description Get the ID of the BalanceManager
138
+ * @param {string} managerKey The key of the BalanceManager
139
+ * @returns A function that takes a Transaction object
140
+ */
141
+ id: (managerKey: string) => (tx: Transaction) => void;
142
+ /**
143
+ * @description Get the owner of the referral (DeepBookPoolReferral)
144
+ * @param {string} referralId The ID of the referral to get the owner of
145
+ * @returns A function that takes a Transaction object
146
+ */
147
+ balanceManagerReferralOwner: (referralId: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
148
+ /**
149
+ * @description Get the pool ID associated with a referral (DeepBookPoolReferral)
150
+ * @param {string} referralId The ID of the referral to get the pool ID of
151
+ * @returns A function that takes a Transaction object
152
+ */
153
+ balanceManagerReferralPoolId: (referralId: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
154
+ /**
155
+ * @description Get the referral ID from the balance manager for a specific pool
156
+ * @param {string} managerKey The name of the BalanceManager
157
+ * @param {string} poolKey Key of the pool to get the referral for
158
+ * @returns A function that takes a Transaction object
159
+ */
160
+ getBalanceManagerReferralId: (managerKey: string, poolKey: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
161
+ /**
162
+ * @description Revoke a TradeCap. This also revokes the associated DepositCap and WithdrawCap.
163
+ * @param {string} managerKey The name of the BalanceManager
164
+ * @param {string} tradeCapId The ID of the TradeCap to revoke
165
+ * @returns A function that takes a Transaction object
166
+ */
167
+ revokeTradeCap: (managerKey: string, tradeCapId: string) => (tx: Transaction) => void;
168
+ }
@@ -0,0 +1,384 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __typeError = (msg) => {
7
+ throw TypeError(msg);
8
+ };
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
23
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
24
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
25
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
26
+ var balanceManager_exports = {};
27
+ __export(balanceManager_exports, {
28
+ BalanceManagerContract: () => BalanceManagerContract
29
+ });
30
+ module.exports = __toCommonJS(balanceManager_exports);
31
+ var import_transactions = require("@haneullabs/haneul/transactions");
32
+ var _config;
33
+ class BalanceManagerContract {
34
+ /**
35
+ * @param {DeepBookConfig} config Configuration for BalanceManagerContract
36
+ */
37
+ constructor(config) {
38
+ __privateAdd(this, _config);
39
+ /**
40
+ * @description Create and share a new BalanceManager
41
+ * @returns A function that takes a Transaction object
42
+ */
43
+ this.createAndShareBalanceManager = () => (tx) => {
44
+ const manager = tx.moveCall({
45
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::new`
46
+ });
47
+ tx.moveCall({
48
+ target: "0x2::transfer::public_share_object",
49
+ arguments: [manager],
50
+ typeArguments: [`${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::BalanceManager`]
51
+ });
52
+ };
53
+ /**
54
+ * @description Create a new BalanceManager, manually set the owner. Returns the manager.
55
+ * @returns A function that takes a Transaction object
56
+ */
57
+ this.createBalanceManagerWithOwner = (ownerAddress) => (tx) => {
58
+ return tx.moveCall({
59
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::new_with_custom_owner`,
60
+ arguments: [tx.pure.address(ownerAddress)]
61
+ });
62
+ };
63
+ /**
64
+ * @description Share the BalanceManager
65
+ * @param {TransactionArgument} manager The BalanceManager to share
66
+ * @returns A function that takes a Transaction object
67
+ */
68
+ this.shareBalanceManager = (manager) => (tx) => {
69
+ tx.moveCall({
70
+ target: "0x2::transfer::public_share_object",
71
+ arguments: [manager],
72
+ typeArguments: [`${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::BalanceManager`]
73
+ });
74
+ };
75
+ /**
76
+ * @description Deposit funds into the BalanceManager
77
+ * @param {string} managerKey The key of the BalanceManager
78
+ * @param {string} coinKey The key of the coin to deposit
79
+ * @param {number} amountToDeposit The amount to deposit
80
+ * @returns A function that takes a Transaction object
81
+ */
82
+ this.depositIntoManager = (managerKey, coinKey, amountToDeposit) => (tx) => {
83
+ tx.setSenderIfNotSet(__privateGet(this, _config).address);
84
+ const managerId = __privateGet(this, _config).getBalanceManager(managerKey).address;
85
+ const coin = __privateGet(this, _config).getCoin(coinKey);
86
+ const depositInput = Math.round(amountToDeposit * coin.scalar);
87
+ const deposit = (0, import_transactions.coinWithBalance)({
88
+ type: coin.type,
89
+ balance: depositInput
90
+ });
91
+ tx.moveCall({
92
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::deposit`,
93
+ arguments: [tx.object(managerId), deposit],
94
+ typeArguments: [coin.type]
95
+ });
96
+ };
97
+ /**
98
+ * @description Withdraw funds from the BalanceManager
99
+ * @param {string} managerKey The key of the BalanceManager
100
+ * @param {string} coinKey The key of the coin to withdraw
101
+ * @param {number} amountToWithdraw The amount to withdraw
102
+ * @param {string} recipient The recipient of the withdrawn funds
103
+ * @returns A function that takes a Transaction object
104
+ */
105
+ this.withdrawFromManager = (managerKey, coinKey, amountToWithdraw, recipient) => (tx) => {
106
+ const managerId = __privateGet(this, _config).getBalanceManager(managerKey).address;
107
+ const coin = __privateGet(this, _config).getCoin(coinKey);
108
+ const withdrawInput = Math.round(amountToWithdraw * coin.scalar);
109
+ const coinObject = tx.moveCall({
110
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::withdraw`,
111
+ arguments: [tx.object(managerId), tx.pure.u64(withdrawInput)],
112
+ typeArguments: [coin.type]
113
+ });
114
+ tx.transferObjects([coinObject], recipient);
115
+ };
116
+ /**
117
+ * @description Withdraw all funds from the BalanceManager
118
+ * @param {string} managerKey The key of the BalanceManager
119
+ * @param {string} coinKey The key of the coin to withdraw
120
+ * @param {string} recipient The recipient of the withdrawn funds
121
+ * @returns A function that takes a Transaction object
122
+ */
123
+ this.withdrawAllFromManager = (managerKey, coinKey, recipient) => (tx) => {
124
+ const managerId = __privateGet(this, _config).getBalanceManager(managerKey).address;
125
+ const coin = __privateGet(this, _config).getCoin(coinKey);
126
+ const withdrawalCoin = tx.moveCall({
127
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::withdraw_all`,
128
+ arguments: [tx.object(managerId)],
129
+ typeArguments: [coin.type]
130
+ });
131
+ tx.transferObjects([withdrawalCoin], recipient);
132
+ };
133
+ /**
134
+ * @description Check the balance of the BalanceManager
135
+ * @param {string} managerKey The key of the BalanceManager
136
+ * @param {string} coinKey The key of the coin to check the balance of
137
+ * @returns A function that takes a Transaction object
138
+ */
139
+ this.checkManagerBalance = (managerKey, coinKey) => (tx) => {
140
+ const managerId = __privateGet(this, _config).getBalanceManager(managerKey).address;
141
+ const coin = __privateGet(this, _config).getCoin(coinKey);
142
+ tx.moveCall({
143
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::balance`,
144
+ arguments: [tx.object(managerId)],
145
+ typeArguments: [coin.type]
146
+ });
147
+ };
148
+ /**
149
+ * @description Generate a trade proof for the BalanceManager. Calls the appropriate function based on whether tradeCap is set.
150
+ * @param {string} managerKey The key of the BalanceManager
151
+ * @returns A function that takes a Transaction object
152
+ */
153
+ this.generateProof = (managerKey) => (tx) => {
154
+ const balanceManager = __privateGet(this, _config).getBalanceManager(managerKey);
155
+ return tx.add(
156
+ balanceManager.tradeCap ? this.generateProofAsTrader(balanceManager.address, balanceManager.tradeCap) : this.generateProofAsOwner(balanceManager.address)
157
+ );
158
+ };
159
+ /**
160
+ * @description Generate a trade proof as the owner
161
+ * @param {string} managerId The ID of the BalanceManager
162
+ * @returns A function that takes a Transaction object
163
+ */
164
+ this.generateProofAsOwner = (managerId) => (tx) => {
165
+ return tx.moveCall({
166
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::generate_proof_as_owner`,
167
+ arguments: [tx.object(managerId)]
168
+ });
169
+ };
170
+ /**
171
+ * @description Generate a trade proof as a trader
172
+ * @param {string} managerId The ID of the BalanceManager
173
+ * @param {string} tradeCapId The ID of the tradeCap
174
+ * @returns A function that takes a Transaction object
175
+ */
176
+ this.generateProofAsTrader = (managerId, tradeCapId) => (tx) => {
177
+ return tx.moveCall({
178
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::generate_proof_as_trader`,
179
+ arguments: [tx.object(managerId), tx.object(tradeCapId)]
180
+ });
181
+ };
182
+ /**
183
+ * @description Mint a TradeCap
184
+ * @param {string} managerKey The name of the BalanceManager
185
+ * @returns A function that takes a Transaction object
186
+ */
187
+ this.mintTradeCap = (managerKey) => (tx) => {
188
+ const manager = __privateGet(this, _config).getBalanceManager(managerKey);
189
+ const managerId = manager.address;
190
+ return tx.moveCall({
191
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::mint_trade_cap`,
192
+ arguments: [tx.object(managerId)]
193
+ });
194
+ };
195
+ /**
196
+ * @description Mint a DepositCap
197
+ * @param {string} managerKey The name of the BalanceManager
198
+ * @returns A function that takes a Transaction object
199
+ */
200
+ this.mintDepositCap = (managerKey) => (tx) => {
201
+ const manager = __privateGet(this, _config).getBalanceManager(managerKey);
202
+ const managerId = manager.address;
203
+ return tx.moveCall({
204
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::mint_deposit_cap`,
205
+ arguments: [tx.object(managerId)]
206
+ });
207
+ };
208
+ /**
209
+ * @description Mint a WithdrawalCap
210
+ * @param {string} managerKey The name of the BalanceManager
211
+ * @returns A function that takes a Transaction object
212
+ */
213
+ this.mintWithdrawalCap = (managerKey) => (tx) => {
214
+ const manager = __privateGet(this, _config).getBalanceManager(managerKey);
215
+ const managerId = manager.address;
216
+ return tx.moveCall({
217
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::mint_withdraw_cap`,
218
+ arguments: [tx.object(managerId)]
219
+ });
220
+ };
221
+ /**
222
+ * @description Deposit using the DepositCap
223
+ * @param {string} managerKey The name of the BalanceManager
224
+ * @param {string} coinKey The name of the coin to deposit
225
+ * @param {number} amountToDeposit The amount to deposit
226
+ * @returns A function that takes a Transaction object
227
+ */
228
+ this.depositWithCap = (managerKey, coinKey, amountToDeposit) => (tx) => {
229
+ tx.setSenderIfNotSet(__privateGet(this, _config).address);
230
+ const manager = __privateGet(this, _config).getBalanceManager(managerKey);
231
+ const managerId = manager.address;
232
+ if (!manager.depositCap) {
233
+ throw new Error(`DepositCap not set for ${managerKey}`);
234
+ }
235
+ const depositCapId = manager.depositCap;
236
+ const coin = __privateGet(this, _config).getCoin(coinKey);
237
+ const depositInput = Math.round(amountToDeposit * coin.scalar);
238
+ const deposit = (0, import_transactions.coinWithBalance)({
239
+ type: coin.type,
240
+ balance: depositInput
241
+ });
242
+ tx.moveCall({
243
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::deposit_with_cap`,
244
+ arguments: [tx.object(managerId), tx.object(depositCapId), deposit],
245
+ typeArguments: [coin.type]
246
+ });
247
+ };
248
+ /**
249
+ * @description Withdraw using the WithdrawCap
250
+ * @param {string} managerKey The name of the BalanceManager
251
+ * @param {string} coinKey The name of the coin to withdraw
252
+ * @param {number} amountToWithdraw The amount to withdraw
253
+ * @returns A function that takes a Transaction object
254
+ */
255
+ this.withdrawWithCap = (managerKey, coinKey, amountToWithdraw) => (tx) => {
256
+ tx.setSenderIfNotSet(__privateGet(this, _config).address);
257
+ const manager = __privateGet(this, _config).getBalanceManager(managerKey);
258
+ const managerId = manager.address;
259
+ if (!manager.withdrawCap) {
260
+ throw new Error(`WithdrawCap not set for ${managerKey}`);
261
+ }
262
+ const withdrawCapId = manager.withdrawCap;
263
+ const coin = __privateGet(this, _config).getCoin(coinKey);
264
+ const withdrawAmount = Math.round(amountToWithdraw * coin.scalar);
265
+ return tx.moveCall({
266
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::withdraw_with_cap`,
267
+ arguments: [tx.object(managerId), tx.object(withdrawCapId), tx.pure.u64(withdrawAmount)],
268
+ typeArguments: [coin.type]
269
+ });
270
+ };
271
+ /**
272
+ * @description Set the referral for the BalanceManager for a specific pool
273
+ * @param {string} managerKey The name of the BalanceManager
274
+ * @param {string} referral The referral (DeepBookPoolReferral) to set the BalanceManager to
275
+ * @param {TransactionArgument} tradeCap The tradeCap for permission checking
276
+ * @returns A function that takes a Transaction object
277
+ */
278
+ this.setBalanceManagerReferral = (managerKey, referral, tradeCap) => (tx) => {
279
+ const managerId = __privateGet(this, _config).getBalanceManager(managerKey).address;
280
+ tx.moveCall({
281
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::set_balance_manager_referral`,
282
+ arguments: [tx.object(managerId), tx.object(referral), tradeCap]
283
+ });
284
+ };
285
+ /**
286
+ * @description Unset the referral for the BalanceManager for a specific pool
287
+ * @param {string} managerKey The name of the BalanceManager
288
+ * @param {string} poolKey The key of the pool to unset the referral for
289
+ * @param {TransactionArgument} tradeCap The tradeCap for permission checking
290
+ * @returns A function that takes a Transaction object
291
+ */
292
+ this.unsetBalanceManagerReferral = (managerKey, poolKey, tradeCap) => (tx) => {
293
+ const managerId = __privateGet(this, _config).getBalanceManager(managerKey).address;
294
+ const poolId = __privateGet(this, _config).getPool(poolKey).address;
295
+ tx.moveCall({
296
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::unset_balance_manager_referral`,
297
+ arguments: [tx.object(managerId), tx.pure.id(poolId), tradeCap]
298
+ });
299
+ };
300
+ this.registerBalanceManager = (managerKey) => (tx) => {
301
+ const managerId = __privateGet(this, _config).getBalanceManager(managerKey).address;
302
+ tx.moveCall({
303
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::register_balance_manager`,
304
+ arguments: [tx.object(managerId), tx.object(__privateGet(this, _config).REGISTRY_ID)]
305
+ });
306
+ };
307
+ /**
308
+ * @description Get the owner of the BalanceManager
309
+ * @param {string} managerKey The key of the BalanceManager
310
+ * @returns A function that takes a Transaction object
311
+ */
312
+ this.owner = (managerKey) => (tx) => {
313
+ const managerId = __privateGet(this, _config).getBalanceManager(managerKey).address;
314
+ tx.moveCall({
315
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::owner`,
316
+ arguments: [tx.object(managerId)]
317
+ });
318
+ };
319
+ /**
320
+ * @description Get the ID of the BalanceManager
321
+ * @param {string} managerKey The key of the BalanceManager
322
+ * @returns A function that takes a Transaction object
323
+ */
324
+ this.id = (managerKey) => (tx) => {
325
+ const managerId = __privateGet(this, _config).getBalanceManager(managerKey).address;
326
+ tx.moveCall({
327
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::id`,
328
+ arguments: [tx.object(managerId)]
329
+ });
330
+ };
331
+ /**
332
+ * @description Get the owner of the referral (DeepBookPoolReferral)
333
+ * @param {string} referralId The ID of the referral to get the owner of
334
+ * @returns A function that takes a Transaction object
335
+ */
336
+ this.balanceManagerReferralOwner = (referralId) => (tx) => {
337
+ return tx.moveCall({
338
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::balance_manager_referral_owner`,
339
+ arguments: [tx.object(referralId)]
340
+ });
341
+ };
342
+ /**
343
+ * @description Get the pool ID associated with a referral (DeepBookPoolReferral)
344
+ * @param {string} referralId The ID of the referral to get the pool ID of
345
+ * @returns A function that takes a Transaction object
346
+ */
347
+ this.balanceManagerReferralPoolId = (referralId) => (tx) => {
348
+ return tx.moveCall({
349
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::balance_manager_referral_pool_id`,
350
+ arguments: [tx.object(referralId)]
351
+ });
352
+ };
353
+ /**
354
+ * @description Get the referral ID from the balance manager for a specific pool
355
+ * @param {string} managerKey The name of the BalanceManager
356
+ * @param {string} poolKey Key of the pool to get the referral for
357
+ * @returns A function that takes a Transaction object
358
+ */
359
+ this.getBalanceManagerReferralId = (managerKey, poolKey) => (tx) => {
360
+ const managerId = __privateGet(this, _config).getBalanceManager(managerKey).address;
361
+ const poolId = __privateGet(this, _config).getPool(poolKey).address;
362
+ return tx.moveCall({
363
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::get_balance_manager_referral_id`,
364
+ arguments: [tx.object(managerId), tx.pure.id(poolId)]
365
+ });
366
+ };
367
+ /**
368
+ * @description Revoke a TradeCap. This also revokes the associated DepositCap and WithdrawCap.
369
+ * @param {string} managerKey The name of the BalanceManager
370
+ * @param {string} tradeCapId The ID of the TradeCap to revoke
371
+ * @returns A function that takes a Transaction object
372
+ */
373
+ this.revokeTradeCap = (managerKey, tradeCapId) => (tx) => {
374
+ const managerId = __privateGet(this, _config).getBalanceManager(managerKey).address;
375
+ tx.moveCall({
376
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::revoke_trade_cap`,
377
+ arguments: [tx.object(managerId), tx.pure.id(tradeCapId)]
378
+ });
379
+ };
380
+ __privateSet(this, _config, config);
381
+ }
382
+ }
383
+ _config = new WeakMap();
384
+ //# sourceMappingURL=balanceManager.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/transactions/balanceManager.ts"],
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { coinWithBalance } from '@haneullabs/haneul/transactions';\nimport type { Transaction, TransactionArgument } from '@haneullabs/haneul/transactions';\n\nimport type { DeepBookConfig } from '../utils/config.js';\n\n/**\n * BalanceManagerContract class for managing BalanceManager operations.\n */\nexport class BalanceManagerContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for BalanceManagerContract\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * @description Create and share a new BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tcreateAndShareBalanceManager = () => (tx: Transaction) => {\n\t\tconst manager = tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::new`,\n\t\t});\n\n\t\ttx.moveCall({\n\t\t\ttarget: '0x2::transfer::public_share_object',\n\t\t\targuments: [manager],\n\t\t\ttypeArguments: [`${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::BalanceManager`],\n\t\t});\n\t};\n\n\t/**\n\t * @description Create a new BalanceManager, manually set the owner. Returns the manager.\n\t * @returns A function that takes a Transaction object\n\t */\n\tcreateBalanceManagerWithOwner = (ownerAddress: string) => (tx: Transaction) => {\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::new_with_custom_owner`,\n\t\t\targuments: [tx.pure.address(ownerAddress)],\n\t\t});\n\t};\n\n\t/**\n\t * @description Share the BalanceManager\n\t * @param {TransactionArgument} manager The BalanceManager to share\n\t * @returns A function that takes a Transaction object\n\t */\n\tshareBalanceManager = (manager: TransactionArgument) => (tx: Transaction) => {\n\t\ttx.moveCall({\n\t\t\ttarget: '0x2::transfer::public_share_object',\n\t\t\targuments: [manager],\n\t\t\ttypeArguments: [`${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::BalanceManager`],\n\t\t});\n\t};\n\n\t/**\n\t * @description Deposit funds into the BalanceManager\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @param {string} coinKey The key of the coin to deposit\n\t * @param {number} amountToDeposit The amount to deposit\n\t * @returns A function that takes a Transaction object\n\t */\n\tdepositIntoManager =\n\t\t(managerKey: string, coinKey: string, amountToDeposit: number) => (tx: Transaction) => {\n\t\t\ttx.setSenderIfNotSet(this.#config.address);\n\t\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tconst depositInput = Math.round(amountToDeposit * coin.scalar);\n\t\t\tconst deposit = coinWithBalance({\n\t\t\t\ttype: coin.type,\n\t\t\t\tbalance: depositInput,\n\t\t\t});\n\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::deposit`,\n\t\t\t\targuments: [tx.object(managerId), deposit],\n\t\t\t\ttypeArguments: [coin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Withdraw funds from the BalanceManager\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @param {string} coinKey The key of the coin to withdraw\n\t * @param {number} amountToWithdraw The amount to withdraw\n\t * @param {string} recipient The recipient of the withdrawn funds\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawFromManager =\n\t\t(managerKey: string, coinKey: string, amountToWithdraw: number, recipient: string) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tconst withdrawInput = Math.round(amountToWithdraw * coin.scalar);\n\t\t\tconst coinObject = tx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::withdraw`,\n\t\t\t\targuments: [tx.object(managerId), tx.pure.u64(withdrawInput)],\n\t\t\t\ttypeArguments: [coin.type],\n\t\t\t});\n\n\t\t\ttx.transferObjects([coinObject], recipient);\n\t\t};\n\n\t/**\n\t * @description Withdraw all funds from the BalanceManager\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @param {string} coinKey The key of the coin to withdraw\n\t * @param {string} recipient The recipient of the withdrawn funds\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawAllFromManager =\n\t\t(managerKey: string, coinKey: string, recipient: string) => (tx: Transaction) => {\n\t\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tconst withdrawalCoin = tx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::withdraw_all`,\n\t\t\t\targuments: [tx.object(managerId)],\n\t\t\t\ttypeArguments: [coin.type],\n\t\t\t});\n\n\t\t\ttx.transferObjects([withdrawalCoin], recipient);\n\t\t};\n\n\t/**\n\t * @description Check the balance of the BalanceManager\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @param {string} coinKey The key of the coin to check the balance of\n\t * @returns A function that takes a Transaction object\n\t */\n\tcheckManagerBalance = (managerKey: string, coinKey: string) => (tx: Transaction) => {\n\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\tconst coin = this.#config.getCoin(coinKey);\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::balance`,\n\t\t\targuments: [tx.object(managerId)],\n\t\t\ttypeArguments: [coin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Generate a trade proof for the BalanceManager. Calls the appropriate function based on whether tradeCap is set.\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tgenerateProof = (managerKey: string) => (tx: Transaction) => {\n\t\tconst balanceManager = this.#config.getBalanceManager(managerKey);\n\t\treturn tx.add(\n\t\t\tbalanceManager.tradeCap\n\t\t\t\t? this.generateProofAsTrader(balanceManager.address, balanceManager.tradeCap)\n\t\t\t\t: this.generateProofAsOwner(balanceManager.address),\n\t\t);\n\t};\n\n\t/**\n\t * @description Generate a trade proof as the owner\n\t * @param {string} managerId The ID of the BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tgenerateProofAsOwner = (managerId: string) => (tx: Transaction) => {\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::generate_proof_as_owner`,\n\t\t\targuments: [tx.object(managerId)],\n\t\t});\n\t};\n\n\t/**\n\t * @description Generate a trade proof as a trader\n\t * @param {string} managerId The ID of the BalanceManager\n\t * @param {string} tradeCapId The ID of the tradeCap\n\t * @returns A function that takes a Transaction object\n\t */\n\tgenerateProofAsTrader = (managerId: string, tradeCapId: string) => (tx: Transaction) => {\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::generate_proof_as_trader`,\n\t\t\targuments: [tx.object(managerId), tx.object(tradeCapId)],\n\t\t});\n\t};\n\n\t/**\n\t * @description Mint a TradeCap\n\t * @param {string} managerKey The name of the BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tmintTradeCap = (managerKey: string) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getBalanceManager(managerKey);\n\t\tconst managerId = manager.address;\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::mint_trade_cap`,\n\t\t\targuments: [tx.object(managerId)],\n\t\t});\n\t};\n\n\t/**\n\t * @description Mint a DepositCap\n\t * @param {string} managerKey The name of the BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tmintDepositCap = (managerKey: string) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getBalanceManager(managerKey);\n\t\tconst managerId = manager.address;\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::mint_deposit_cap`,\n\t\t\targuments: [tx.object(managerId)],\n\t\t});\n\t};\n\n\t/**\n\t * @description Mint a WithdrawalCap\n\t * @param {string} managerKey The name of the BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tmintWithdrawalCap = (managerKey: string) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getBalanceManager(managerKey);\n\t\tconst managerId = manager.address;\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::mint_withdraw_cap`,\n\t\t\targuments: [tx.object(managerId)],\n\t\t});\n\t};\n\n\t/**\n\t * @description Deposit using the DepositCap\n\t * @param {string} managerKey The name of the BalanceManager\n\t * @param {string} coinKey The name of the coin to deposit\n\t * @param {number} amountToDeposit The amount to deposit\n\t * @returns A function that takes a Transaction object\n\t */\n\tdepositWithCap =\n\t\t(managerKey: string, coinKey: string, amountToDeposit: number) => (tx: Transaction) => {\n\t\t\ttx.setSenderIfNotSet(this.#config.address);\n\t\t\tconst manager = this.#config.getBalanceManager(managerKey);\n\t\t\tconst managerId = manager.address;\n\t\t\tif (!manager.depositCap) {\n\t\t\t\tthrow new Error(`DepositCap not set for ${managerKey}`);\n\t\t\t}\n\t\t\tconst depositCapId = manager.depositCap;\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tconst depositInput = Math.round(amountToDeposit * coin.scalar);\n\t\t\tconst deposit = coinWithBalance({\n\t\t\t\ttype: coin.type,\n\t\t\t\tbalance: depositInput,\n\t\t\t});\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::deposit_with_cap`,\n\t\t\t\targuments: [tx.object(managerId), tx.object(depositCapId), deposit],\n\t\t\t\ttypeArguments: [coin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Withdraw using the WithdrawCap\n\t * @param {string} managerKey The name of the BalanceManager\n\t * @param {string} coinKey The name of the coin to withdraw\n\t * @param {number} amountToWithdraw The amount to withdraw\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawWithCap =\n\t\t(managerKey: string, coinKey: string, amountToWithdraw: number) => (tx: Transaction) => {\n\t\t\ttx.setSenderIfNotSet(this.#config.address);\n\t\t\tconst manager = this.#config.getBalanceManager(managerKey);\n\t\t\tconst managerId = manager.address;\n\t\t\tif (!manager.withdrawCap) {\n\t\t\t\tthrow new Error(`WithdrawCap not set for ${managerKey}`);\n\t\t\t}\n\t\t\tconst withdrawCapId = manager.withdrawCap;\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tconst withdrawAmount = Math.round(amountToWithdraw * coin.scalar);\n\t\t\treturn tx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::withdraw_with_cap`,\n\t\t\t\targuments: [tx.object(managerId), tx.object(withdrawCapId), tx.pure.u64(withdrawAmount)],\n\t\t\t\ttypeArguments: [coin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Set the referral for the BalanceManager for a specific pool\n\t * @param {string} managerKey The name of the BalanceManager\n\t * @param {string} referral The referral (DeepBookPoolReferral) to set the BalanceManager to\n\t * @param {TransactionArgument} tradeCap The tradeCap for permission checking\n\t * @returns A function that takes a Transaction object\n\t */\n\tsetBalanceManagerReferral =\n\t\t(managerKey: string, referral: string, tradeCap: TransactionArgument) => (tx: Transaction) => {\n\t\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::set_balance_manager_referral`,\n\t\t\t\targuments: [tx.object(managerId), tx.object(referral), tradeCap],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Unset the referral for the BalanceManager for a specific pool\n\t * @param {string} managerKey The name of the BalanceManager\n\t * @param {string} poolKey The key of the pool to unset the referral for\n\t * @param {TransactionArgument} tradeCap The tradeCap for permission checking\n\t * @returns A function that takes a Transaction object\n\t */\n\tunsetBalanceManagerReferral =\n\t\t(managerKey: string, poolKey: string, tradeCap: TransactionArgument) => (tx: Transaction) => {\n\t\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\t\tconst poolId = this.#config.getPool(poolKey).address;\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::unset_balance_manager_referral`,\n\t\t\t\targuments: [tx.object(managerId), tx.pure.id(poolId), tradeCap],\n\t\t\t});\n\t\t};\n\n\tregisterBalanceManager = (managerKey: string) => (tx: Transaction) => {\n\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::register_balance_manager`,\n\t\t\targuments: [tx.object(managerId), tx.object(this.#config.REGISTRY_ID)],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the owner of the BalanceManager\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\towner = (managerKey: string) => (tx: Transaction) => {\n\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::owner`,\n\t\t\targuments: [tx.object(managerId)],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the ID of the BalanceManager\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tid = (managerKey: string) => (tx: Transaction) => {\n\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::id`,\n\t\t\targuments: [tx.object(managerId)],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the owner of the referral (DeepBookPoolReferral)\n\t * @param {string} referralId The ID of the referral to get the owner of\n\t * @returns A function that takes a Transaction object\n\t */\n\tbalanceManagerReferralOwner = (referralId: string) => (tx: Transaction) => {\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::balance_manager_referral_owner`,\n\t\t\targuments: [tx.object(referralId)],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the pool ID associated with a referral (DeepBookPoolReferral)\n\t * @param {string} referralId The ID of the referral to get the pool ID of\n\t * @returns A function that takes a Transaction object\n\t */\n\tbalanceManagerReferralPoolId = (referralId: string) => (tx: Transaction) => {\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::balance_manager_referral_pool_id`,\n\t\t\targuments: [tx.object(referralId)],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the referral ID from the balance manager for a specific pool\n\t * @param {string} managerKey The name of the BalanceManager\n\t * @param {string} poolKey Key of the pool to get the referral for\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetBalanceManagerReferralId = (managerKey: string, poolKey: string) => (tx: Transaction) => {\n\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\tconst poolId = this.#config.getPool(poolKey).address;\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::get_balance_manager_referral_id`,\n\t\t\targuments: [tx.object(managerId), tx.pure.id(poolId)],\n\t\t});\n\t};\n\n\t/**\n\t * @description Revoke a TradeCap. This also revokes the associated DepositCap and WithdrawCap.\n\t * @param {string} managerKey The name of the BalanceManager\n\t * @param {string} tradeCapId The ID of the TradeCap to revoke\n\t * @returns A function that takes a Transaction object\n\t */\n\trevokeTradeCap = (managerKey: string, tradeCapId: string) => (tx: Transaction) => {\n\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::revoke_trade_cap`,\n\t\t\targuments: [tx.object(managerId), tx.pure.id(tradeCapId)],\n\t\t});\n\t};\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,0BAAgC;AAFhC;AAUO,MAAM,uBAAuB;AAAA;AAAA;AAAA;AAAA,EAMnC,YAAY,QAAwB;AALpC;AAaA;AAAA;AAAA;AAAA;AAAA,wCAA+B,MAAM,CAAC,OAAoB;AACzD,YAAM,UAAU,GAAG,SAAS;AAAA,QAC3B,QAAQ,GAAG,mBAAK,SAAQ,mBAAmB;AAAA,MAC5C,CAAC;AAED,SAAG,SAAS;AAAA,QACX,QAAQ;AAAA,QACR,WAAW,CAAC,OAAO;AAAA,QACnB,eAAe,CAAC,GAAG,mBAAK,SAAQ,mBAAmB,mCAAmC;AAAA,MACvF,CAAC;AAAA,IACF;AAMA;AAAA;AAAA;AAAA;AAAA,yCAAgC,CAAC,iBAAyB,CAAC,OAAoB;AAC9E,aAAO,GAAG,SAAS;AAAA,QAClB,QAAQ,GAAG,mBAAK,SAAQ,mBAAmB;AAAA,QAC3C,WAAW,CAAC,GAAG,KAAK,QAAQ,YAAY,CAAC;AAAA,MAC1C,CAAC;AAAA,IACF;AAOA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAsB,CAA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