@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,393 @@
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 __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
27
+ var marginAdmin_exports = {};
28
+ __export(marginAdmin_exports, {
29
+ MarginAdminContract: () => MarginAdminContract
30
+ });
31
+ module.exports = __toCommonJS(marginAdmin_exports);
32
+ var import_config = require("../utils/config.js");
33
+ var import_utils = require("@noble/hashes/utils");
34
+ var _config, _MarginAdminContract_instances, marginAdminCap_fn;
35
+ class MarginAdminContract {
36
+ /**
37
+ * @param {DeepBookConfig} config Configuration for MarginAdminContract
38
+ */
39
+ constructor(config) {
40
+ __privateAdd(this, _MarginAdminContract_instances);
41
+ __privateAdd(this, _config);
42
+ /**
43
+ * @description Mint a maintainer cap
44
+ * @returns A function that takes a Transaction object
45
+ */
46
+ this.mintMaintainerCap = () => (tx) => {
47
+ return tx.moveCall({
48
+ target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_registry::mint_maintainer_cap`,
49
+ arguments: [
50
+ tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
51
+ tx.object(__privateMethod(this, _MarginAdminContract_instances, marginAdminCap_fn).call(this)),
52
+ tx.object.clock()
53
+ ]
54
+ });
55
+ };
56
+ /**
57
+ * @description Revoke a maintainer cap
58
+ * @returns A function that takes a Transaction object
59
+ */
60
+ this.revokeMaintainerCap = (maintainerCapId) => (tx) => {
61
+ tx.moveCall({
62
+ target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_registry::revoke_maintainer_cap`,
63
+ arguments: [
64
+ tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
65
+ tx.object(__privateMethod(this, _MarginAdminContract_instances, marginAdminCap_fn).call(this)),
66
+ tx.object(maintainerCapId),
67
+ tx.object.clock()
68
+ ]
69
+ });
70
+ };
71
+ /**
72
+ * @description Register a deepbook pool
73
+ * @param {string} poolKey The key of the pool to be registered
74
+ * @param {TransactionArgument} poolConfig The configuration of the pool
75
+ * @returns A function that takes a Transaction object
76
+ */
77
+ this.registerDeepbookPool = (poolKey, poolConfig) => (tx) => {
78
+ const pool = __privateGet(this, _config).getPool(poolKey);
79
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
80
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
81
+ tx.moveCall({
82
+ target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_registry::register_deepbook_pool`,
83
+ arguments: [
84
+ tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
85
+ tx.object(__privateMethod(this, _MarginAdminContract_instances, marginAdminCap_fn).call(this)),
86
+ tx.object(pool.address),
87
+ poolConfig,
88
+ tx.object.clock()
89
+ ],
90
+ typeArguments: [baseCoin.type, quoteCoin.type]
91
+ });
92
+ };
93
+ /**
94
+ * @description Enable a deepbook pool for margin trading
95
+ * @param {string} poolKey The key of the pool to be enabled
96
+ * @returns A function that takes a Transaction object
97
+ */
98
+ this.enableDeepbookPool = (poolKey) => (tx) => {
99
+ const pool = __privateGet(this, _config).getPool(poolKey);
100
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
101
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
102
+ tx.moveCall({
103
+ target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_registry::enable_deepbook_pool`,
104
+ arguments: [
105
+ tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
106
+ tx.object(__privateMethod(this, _MarginAdminContract_instances, marginAdminCap_fn).call(this)),
107
+ tx.object(pool.address),
108
+ tx.object.clock()
109
+ ],
110
+ typeArguments: [baseCoin.type, quoteCoin.type]
111
+ });
112
+ };
113
+ /**
114
+ * @description Disable a deepbook pool from margin trading
115
+ * @param {string} poolKey The key of the pool to be disabled
116
+ * @returns A function that takes a Transaction object
117
+ */
118
+ this.disableDeepbookPool = (poolKey) => (tx) => {
119
+ const pool = __privateGet(this, _config).getPool(poolKey);
120
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
121
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
122
+ tx.moveCall({
123
+ target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_registry::disable_deepbook_pool`,
124
+ arguments: [
125
+ tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
126
+ tx.object(__privateMethod(this, _MarginAdminContract_instances, marginAdminCap_fn).call(this)),
127
+ tx.object(pool.address),
128
+ tx.object.clock()
129
+ ],
130
+ typeArguments: [baseCoin.type, quoteCoin.type]
131
+ });
132
+ };
133
+ /**
134
+ * @description Update the risk parameters for a margin
135
+ * @param {string} poolKey The key of the pool to be updated
136
+ * @param {TransactionArgument} poolConfig The configuration of the pool
137
+ * @returns A function that takes a Transaction object
138
+ */
139
+ this.updateRiskParams = (poolKey, poolConfig) => (tx) => {
140
+ const pool = __privateGet(this, _config).getPool(poolKey);
141
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
142
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
143
+ tx.moveCall({
144
+ target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_registry::update_risk_params`,
145
+ arguments: [
146
+ tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
147
+ tx.object(__privateMethod(this, _MarginAdminContract_instances, marginAdminCap_fn).call(this)),
148
+ tx.object(pool.address),
149
+ poolConfig,
150
+ tx.object.clock()
151
+ ],
152
+ typeArguments: [baseCoin.type, quoteCoin.type]
153
+ });
154
+ };
155
+ /**
156
+ * @description Add the PythConfig to the margin registry
157
+ * @param {Transaction} tx The transaction object
158
+ * @param {TransactionArgument} config The config to be added
159
+ * @returns A function that takes a Transaction object
160
+ */
161
+ this.addConfig = (config) => (tx) => {
162
+ tx.moveCall({
163
+ target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_registry::add_config`,
164
+ arguments: [
165
+ tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
166
+ tx.object(__privateMethod(this, _MarginAdminContract_instances, marginAdminCap_fn).call(this)),
167
+ config
168
+ ],
169
+ typeArguments: [`${__privateGet(this, _config).MARGIN_PACKAGE_ID}::oracle::PythConfig`]
170
+ });
171
+ };
172
+ /**
173
+ * @description Remove the PythConfig from the margin registry
174
+ * @param {Transaction} tx The transaction object
175
+ * @returns A function that takes a Transaction object
176
+ */
177
+ this.removeConfig = () => (tx) => {
178
+ tx.moveCall({
179
+ target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_registry::remove_config`,
180
+ arguments: [tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID), tx.object(__privateMethod(this, _MarginAdminContract_instances, marginAdminCap_fn).call(this))],
181
+ typeArguments: [`${__privateGet(this, _config).MARGIN_PACKAGE_ID}::oracle::PythConfig`]
182
+ });
183
+ };
184
+ /**
185
+ * @description Enable a specific version
186
+ * @param {number} version The version to be enabled
187
+ * @returns A function that takes a Transaction object
188
+ */
189
+ this.enableVersion = (version) => (tx) => {
190
+ tx.moveCall({
191
+ target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_registry::enable_version`,
192
+ arguments: [
193
+ tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
194
+ tx.pure.u64(version),
195
+ tx.object(__privateMethod(this, _MarginAdminContract_instances, marginAdminCap_fn).call(this))
196
+ ]
197
+ });
198
+ };
199
+ /**
200
+ * @description Disable a specific version
201
+ * @param {number} version The version to be disabled
202
+ * @returns A function that takes a Transaction object
203
+ */
204
+ this.disableVersion = (version) => (tx) => {
205
+ tx.moveCall({
206
+ target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_registry::disable_version`,
207
+ arguments: [
208
+ tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
209
+ tx.pure.u64(version),
210
+ tx.object(__privateMethod(this, _MarginAdminContract_instances, marginAdminCap_fn).call(this))
211
+ ]
212
+ });
213
+ };
214
+ /**
215
+ * @description Create a new pool config
216
+ * @param {string} poolKey The key to identify the pool
217
+ * @param {PoolConfigParams} poolConfigParams The parameters for the pool config
218
+ * @returns A function that takes a Transaction object
219
+ */
220
+ this.newPoolConfig = (poolKey, poolConfigParams) => (tx) => {
221
+ const pool = __privateGet(this, _config).getPool(poolKey);
222
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
223
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
224
+ const {
225
+ minWithdrawRiskRatio,
226
+ minBorrowRiskRatio,
227
+ liquidationRiskRatio,
228
+ targetLiquidationRiskRatio,
229
+ userLiquidationReward,
230
+ poolLiquidationReward
231
+ } = poolConfigParams;
232
+ return tx.moveCall({
233
+ target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_registry::new_pool_config`,
234
+ arguments: [
235
+ tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
236
+ tx.pure.u64(minWithdrawRiskRatio * import_config.FLOAT_SCALAR),
237
+ tx.pure.u64(minBorrowRiskRatio * import_config.FLOAT_SCALAR),
238
+ tx.pure.u64(liquidationRiskRatio * import_config.FLOAT_SCALAR),
239
+ tx.pure.u64(targetLiquidationRiskRatio * import_config.FLOAT_SCALAR),
240
+ tx.pure.u64(userLiquidationReward * import_config.FLOAT_SCALAR),
241
+ tx.pure.u64(poolLiquidationReward * import_config.FLOAT_SCALAR)
242
+ ],
243
+ typeArguments: [baseCoin.type, quoteCoin.type]
244
+ });
245
+ };
246
+ /**
247
+ * @description Create a new pool config with leverage
248
+ * @param {string} poolKey The key to identify the pool
249
+ * @param {number} leverage The leverage for the pool
250
+ * @returns A function that takes a Transaction object
251
+ */
252
+ this.newPoolConfigWithLeverage = (poolKey, leverage) => (tx) => {
253
+ const pool = __privateGet(this, _config).getPool(poolKey);
254
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
255
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
256
+ tx.moveCall({
257
+ target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_registry::new_pool_config_with_leverage`,
258
+ arguments: [tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID), tx.pure.u64(leverage * import_config.FLOAT_SCALAR)],
259
+ typeArguments: [baseCoin.type, quoteCoin.type]
260
+ });
261
+ };
262
+ /**
263
+ * @description Create a new coin type data
264
+ * @param {string} coinKey The key to identify the coin
265
+ * @param {number} maxConfBps The maximum confidence interval in basis points
266
+ * @param {number} maxEwmaDifferenceBps The maximum EWMA difference in basis points
267
+ * @returns A function that takes a Transaction object
268
+ */
269
+ this.newCoinTypeData = (coinKey, maxConfBps, maxEwmaDifferenceBps) => (tx) => {
270
+ const coin = __privateGet(this, _config).getCoin(coinKey);
271
+ if (!coin.feed) {
272
+ throw new Error("Coin feed not found");
273
+ }
274
+ const priceFeedInput = new Uint8Array(
275
+ (0, import_utils.hexToBytes)(coin["feed"].startsWith("0x") ? coin.feed.slice(2) : coin["feed"])
276
+ );
277
+ return tx.moveCall({
278
+ target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::oracle::new_coin_type_data_from_currency`,
279
+ arguments: [
280
+ tx.object(coin.currencyId),
281
+ tx.pure.vector("u8", priceFeedInput),
282
+ tx.pure.u64(maxConfBps),
283
+ tx.pure.u64(maxEwmaDifferenceBps)
284
+ ],
285
+ typeArguments: [coin.type]
286
+ });
287
+ };
288
+ /**
289
+ * @description Create a new Pyth config
290
+ * @param {Array<{coinKey: string, maxConfBps: number, maxEwmaDifferenceBps: number}>} coinSetups The coins with their oracle config to be added to the Pyth config
291
+ * @param {number} maxAgeSeconds The max age in seconds for the Pyth config
292
+ * @returns A function that takes a Transaction object
293
+ */
294
+ this.newPythConfig = (coinSetups, maxAgeSeconds) => (tx) => {
295
+ const coinTypeDataList = [];
296
+ for (const setup of coinSetups) {
297
+ coinTypeDataList.push(
298
+ this.newCoinTypeData(setup.coinKey, setup.maxConfBps, setup.maxEwmaDifferenceBps)(tx)
299
+ );
300
+ }
301
+ return tx.moveCall({
302
+ target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::oracle::new_pyth_config`,
303
+ arguments: [
304
+ tx.makeMoveVec({
305
+ elements: coinTypeDataList,
306
+ type: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::oracle::CoinTypeData`
307
+ }),
308
+ tx.pure.u64(maxAgeSeconds)
309
+ ]
310
+ });
311
+ };
312
+ /**
313
+ * @description Mint a pause cap
314
+ * @returns A function that takes a Transaction object
315
+ */
316
+ this.mintPauseCap = () => (tx) => {
317
+ return tx.moveCall({
318
+ target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_registry::mint_pause_cap`,
319
+ arguments: [
320
+ tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
321
+ tx.object(__privateMethod(this, _MarginAdminContract_instances, marginAdminCap_fn).call(this)),
322
+ tx.object.clock()
323
+ ]
324
+ });
325
+ };
326
+ /**
327
+ * @description Revoke a pause cap
328
+ * @param {string} pauseCapId The ID of the pause cap to revoke
329
+ * @returns A function that takes a Transaction object
330
+ */
331
+ this.revokePauseCap = (pauseCapId) => (tx) => {
332
+ tx.moveCall({
333
+ target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_registry::revoke_pause_cap`,
334
+ arguments: [
335
+ tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
336
+ tx.object(__privateMethod(this, _MarginAdminContract_instances, marginAdminCap_fn).call(this)),
337
+ tx.object.clock(),
338
+ tx.pure.id(pauseCapId)
339
+ ]
340
+ });
341
+ };
342
+ /**
343
+ * @description Disable a version using pause cap
344
+ * @param {number} version The version to disable
345
+ * @param {string} pauseCapId The ID of the pause cap
346
+ * @returns A function that takes a Transaction object
347
+ */
348
+ this.disableVersionPauseCap = (version, pauseCapId) => (tx) => {
349
+ tx.moveCall({
350
+ target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_registry::disable_version_pause_cap`,
351
+ arguments: [
352
+ tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
353
+ tx.pure.u64(version),
354
+ tx.object(pauseCapId)
355
+ ]
356
+ });
357
+ };
358
+ /**
359
+ * @description Withdraw the default referral fees (admin only)
360
+ * The default referral at 0x0 doesn't have a SupplyReferral object
361
+ * @param {string} coinKey The key to identify the margin pool
362
+ * @returns A function that takes a Transaction object and returns a Coin<Asset>
363
+ */
364
+ this.adminWithdrawDefaultReferralFees = (coinKey) => (tx) => {
365
+ const coin = __privateGet(this, _config).getCoin(coinKey);
366
+ const marginPool = __privateGet(this, _config).getMarginPool(coinKey);
367
+ return tx.moveCall({
368
+ target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_pool::admin_withdraw_default_referral_fees`,
369
+ arguments: [
370
+ tx.object(marginPool.address),
371
+ tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
372
+ tx.object(__privateMethod(this, _MarginAdminContract_instances, marginAdminCap_fn).call(this))
373
+ ],
374
+ typeArguments: [coin.type]
375
+ });
376
+ };
377
+ __privateSet(this, _config, config);
378
+ }
379
+ }
380
+ _config = new WeakMap();
381
+ _MarginAdminContract_instances = new WeakSet();
382
+ /**
383
+ * @returns The admin capability required for admin operations
384
+ * @throws Error if the admin capability is not set
385
+ */
386
+ marginAdminCap_fn = function() {
387
+ const marginAdminCap = __privateGet(this, _config).marginAdminCap;
388
+ if (!marginAdminCap) {
389
+ throw new Error("MARGIN_ADMIN_CAP environment variable not set");
390
+ }
391
+ return marginAdminCap;
392
+ };
393
+ //# sourceMappingURL=marginAdmin.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/transactions/marginAdmin.ts"],
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { Transaction } from '@haneullabs/haneul/transactions';\n\nimport type { DeepBookConfig } from '../utils/config.js';\nimport type { TransactionArgument } from '@haneullabs/haneul/transactions';\nimport type { PoolConfigParams } from '../types/index.js';\nimport { FLOAT_SCALAR } from '../utils/config.js';\nimport { hexToBytes } from '@noble/hashes/utils';\n\n/**\n * MarginAdminContract class for managing admin actions.\n */\nexport class MarginAdminContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for MarginAdminContract\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * @returns The admin capability required for admin operations\n\t * @throws Error if the admin capability is not set\n\t */\n\t#marginAdminCap() {\n\t\tconst marginAdminCap = this.#config.marginAdminCap;\n\t\tif (!marginAdminCap) {\n\t\t\tthrow new Error('MARGIN_ADMIN_CAP environment variable not set');\n\t\t}\n\t\treturn marginAdminCap;\n\t}\n\n\t/**\n\t * @description Mint a maintainer cap\n\t * @returns A function that takes a Transaction object\n\t */\n\tmintMaintainerCap = () => (tx: Transaction) => {\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::mint_maintainer_cap`,\n\t\t\targuments: [\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(this.#marginAdminCap()),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @description Revoke a maintainer cap\n\t * @returns A function that takes a Transaction object\n\t */\n\trevokeMaintainerCap = (maintainerCapId: string) => (tx: Transaction) => {\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::revoke_maintainer_cap`,\n\t\t\targuments: [\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(this.#marginAdminCap()),\n\t\t\t\ttx.object(maintainerCapId),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @description Register a deepbook pool\n\t * @param {string} poolKey The key of the pool to be registered\n\t * @param {TransactionArgument} poolConfig The configuration of the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tregisterDeepbookPool =\n\t\t(poolKey: string, poolConfig: TransactionArgument) => (tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::register_deepbook_pool`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\t\ttx.object(this.#marginAdminCap()),\n\t\t\t\t\ttx.object(pool.address),\n\t\t\t\t\tpoolConfig,\n\t\t\t\t\ttx.object.clock(),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Enable a deepbook pool for margin trading\n\t * @param {string} poolKey The key of the pool to be enabled\n\t * @returns A function that takes a Transaction object\n\t */\n\tenableDeepbookPool = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::enable_deepbook_pool`,\n\t\t\targuments: [\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(this.#marginAdminCap()),\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Disable a deepbook pool from margin trading\n\t * @param {string} poolKey The key of the pool to be disabled\n\t * @returns A function that takes a Transaction object\n\t */\n\tdisableDeepbookPool = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::disable_deepbook_pool`,\n\t\t\targuments: [\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(this.#marginAdminCap()),\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Update the risk parameters for a margin\n\t * @param {string} poolKey The key of the pool to be updated\n\t * @param {TransactionArgument} poolConfig The configuration of the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tupdateRiskParams = (poolKey: string, poolConfig: TransactionArgument) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::update_risk_params`,\n\t\t\targuments: [\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(this.#marginAdminCap()),\n\t\t\t\ttx.object(pool.address),\n\t\t\t\tpoolConfig,\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Add the PythConfig to the margin registry\n\t * @param {Transaction} tx The transaction object\n\t * @param {TransactionArgument} config The config to be added\n\t * @returns A function that takes a Transaction object\n\t */\n\taddConfig = (config: TransactionArgument) => (tx: Transaction) => {\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::add_config`,\n\t\t\targuments: [\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(this.#marginAdminCap()),\n\t\t\t\tconfig,\n\t\t\t],\n\t\t\ttypeArguments: [`${this.#config.MARGIN_PACKAGE_ID}::oracle::PythConfig`],\n\t\t});\n\t};\n\n\t/**\n\t * @description Remove the PythConfig from the margin registry\n\t * @param {Transaction} tx The transaction object\n\t * @returns A function that takes a Transaction object\n\t */\n\tremoveConfig = () => (tx: Transaction) => {\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::remove_config`,\n\t\t\targuments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.object(this.#marginAdminCap())],\n\t\t\ttypeArguments: [`${this.#config.MARGIN_PACKAGE_ID}::oracle::PythConfig`],\n\t\t});\n\t};\n\n\t/**\n\t * @description Enable a specific version\n\t * @param {number} version The version to be enabled\n\t * @returns A function that takes a Transaction object\n\t */\n\tenableVersion = (version: number) => (tx: Transaction) => {\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::enable_version`,\n\t\t\targuments: [\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.pure.u64(version),\n\t\t\t\ttx.object(this.#marginAdminCap()),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @description Disable a specific version\n\t * @param {number} version The version to be disabled\n\t * @returns A function that takes a Transaction object\n\t */\n\tdisableVersion = (version: number) => (tx: Transaction) => {\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::disable_version`,\n\t\t\targuments: [\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.pure.u64(version),\n\t\t\t\ttx.object(this.#marginAdminCap()),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @description Create a new pool config\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {PoolConfigParams} poolConfigParams The parameters for the pool config\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewPoolConfig = (poolKey: string, poolConfigParams: PoolConfigParams) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst {\n\t\t\tminWithdrawRiskRatio,\n\t\t\tminBorrowRiskRatio,\n\t\t\tliquidationRiskRatio,\n\t\t\ttargetLiquidationRiskRatio,\n\t\t\tuserLiquidationReward,\n\t\t\tpoolLiquidationReward,\n\t\t} = poolConfigParams;\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::new_pool_config`,\n\t\t\targuments: [\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.pure.u64(minWithdrawRiskRatio * FLOAT_SCALAR),\n\t\t\t\ttx.pure.u64(minBorrowRiskRatio * FLOAT_SCALAR),\n\t\t\t\ttx.pure.u64(liquidationRiskRatio * FLOAT_SCALAR),\n\t\t\t\ttx.pure.u64(targetLiquidationRiskRatio * FLOAT_SCALAR),\n\t\t\t\ttx.pure.u64(userLiquidationReward * FLOAT_SCALAR),\n\t\t\t\ttx.pure.u64(poolLiquidationReward * FLOAT_SCALAR),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Create a new pool config with leverage\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} leverage The leverage for the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewPoolConfigWithLeverage = (poolKey: string, leverage: number) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::new_pool_config_with_leverage`,\n\t\t\targuments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.pure.u64(leverage * FLOAT_SCALAR)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Create a new coin type data\n\t * @param {string} coinKey The key to identify the coin\n\t * @param {number} maxConfBps The maximum confidence interval in basis points\n\t * @param {number} maxEwmaDifferenceBps The maximum EWMA difference in basis points\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewCoinTypeData =\n\t\t(coinKey: string, maxConfBps: number, maxEwmaDifferenceBps: number) => (tx: Transaction) => {\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tif (!coin.feed) {\n\t\t\t\tthrow new Error('Coin feed not found');\n\t\t\t}\n\t\t\tconst priceFeedInput = new Uint8Array(\n\t\t\t\thexToBytes(coin['feed']!.startsWith('0x') ? coin.feed!.slice(2) : coin['feed']),\n\t\t\t);\n\t\t\treturn tx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::oracle::new_coin_type_data_from_currency`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(coin.currencyId!),\n\t\t\t\t\ttx.pure.vector('u8', priceFeedInput),\n\t\t\t\t\ttx.pure.u64(maxConfBps),\n\t\t\t\t\ttx.pure.u64(maxEwmaDifferenceBps),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [coin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Create a new Pyth config\n\t * @param {Array<{coinKey: string, maxConfBps: number, maxEwmaDifferenceBps: number}>} coinSetups The coins with their oracle config to be added to the Pyth config\n\t * @param {number} maxAgeSeconds The max age in seconds for the Pyth config\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewPythConfig =\n\t\t(\n\t\t\tcoinSetups: Array<{ coinKey: string; maxConfBps: number; maxEwmaDifferenceBps: number }>,\n\t\t\tmaxAgeSeconds: number,\n\t\t) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst coinTypeDataList = [];\n\t\t\tfor (const setup of coinSetups) {\n\t\t\t\tcoinTypeDataList.push(\n\t\t\t\t\tthis.newCoinTypeData(setup.coinKey, setup.maxConfBps, setup.maxEwmaDifferenceBps)(tx),\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn tx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::oracle::new_pyth_config`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.makeMoveVec({\n\t\t\t\t\t\telements: coinTypeDataList,\n\t\t\t\t\t\ttype: `${this.#config.MARGIN_PACKAGE_ID}::oracle::CoinTypeData`,\n\t\t\t\t\t}),\n\t\t\t\t\ttx.pure.u64(maxAgeSeconds),\n\t\t\t\t],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Mint a pause cap\n\t * @returns A function that takes a Transaction object\n\t */\n\tmintPauseCap = () => (tx: Transaction) => {\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::mint_pause_cap`,\n\t\t\targuments: [\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(this.#marginAdminCap()),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @description Revoke a pause cap\n\t * @param {string} pauseCapId The ID of the pause cap to revoke\n\t * @returns A function that takes a Transaction object\n\t */\n\trevokePauseCap = (pauseCapId: string) => (tx: Transaction) => {\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::revoke_pause_cap`,\n\t\t\targuments: [\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(this.#marginAdminCap()),\n\t\t\t\ttx.object.clock(),\n\t\t\t\ttx.pure.id(pauseCapId),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @description Disable a version using pause cap\n\t * @param {number} version The version to disable\n\t * @param {string} pauseCapId The ID of the pause cap\n\t * @returns A function that takes a Transaction object\n\t */\n\tdisableVersionPauseCap = (version: number, pauseCapId: string) => (tx: Transaction) => {\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::disable_version_pause_cap`,\n\t\t\targuments: [\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.pure.u64(version),\n\t\t\t\ttx.object(pauseCapId),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @description Withdraw the default referral fees (admin only)\n\t * The default referral at 0x0 doesn't have a SupplyReferral object\n\t * @param {string} coinKey The key to identify the margin pool\n\t * @returns A function that takes a Transaction object and returns a Coin<Asset>\n\t */\n\tadminWithdrawDefaultReferralFees = (coinKey: string) => (tx: Transaction) => {\n\t\tconst coin = this.#config.getCoin(coinKey);\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::admin_withdraw_default_referral_fees`,\n\t\t\targuments: [\n\t\t\t\ttx.object(marginPool.address),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(this.#marginAdminCap()),\n\t\t\t],\n\t\t\ttypeArguments: [coin.type],\n\t\t});\n\t};\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,oBAA6B;AAC7B,mBAA2B;AAT3B;AAcO,MAAM,oBAAoB;AAAA;AAAA;AAAA;AAAA,EAMhC,YAAY,QAAwB;AAN9B;AACN;AAyBA;AAAA;AAAA;AAAA;AAAA,6BAAoB,MAAM,CAAC,OAAoB;AAC9C,aAAO,GAAG,SAAS;AAAA,QAClB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ACtF,SAAG,SAAS;AAAA,QACX,QAAQ,GAAG,mBAAK,SAAQ,iBAAiB;AAAA,QACzC,WAAW;AAAA,UACV,GAAG,OAAO,mBAAK,SAAQ,kBAAkB;AAAA,UACzC,GAAG,KAAK,IAAI,OAAO;AAAA,UACnB,GAAG,OAAO,UAAU;AAAA,QACrB;AAAA,MACD,CAAC;AAAA,IACF;AAQA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4CAAmC,CAAC,YAAoB,CAAC,OAAoB;AAC5E,YAAM,OAAO,mBAAK,SAAQ,QAAQ,OAAO;AACzC,YAAM,aAAa,mBAAK,SAAQ,cAAc,OAAO;AACrD,aAAO,GAAG,SAAS;AAAA,QAClB,QAAQ,GAAG,mBAAK,SAAQ,iBAAiB;AAAA,QACzC,WAAW;AAAA,UACV,GAAG,OAAO,WAAW,OAAO;AAAA,UAC5B,GAAG,OAAO,mBAAK,SAAQ,kBAAkB;AAAA,UACzC,GAAG,OAAO,sBAAK,mDAAL,UAAsB;AAAA,QACjC;AAAA,QACA,eAAe,CAAC,KAAK,IAAI;AAAA,MAC1B,CAAC;AAAA,IACF;AArXC,uBAAK,SAAU;AAAA,EAChB;AAqXD;AA5XC;AADM;AAAA;AAAA;AAAA;AAAA;AAcN,oBAAe,WAAG;AACjB,QAAM,iBAAiB,mBAAK,SAAQ;AACpC,MAAI,CAAC,gBAAgB;AACpB,UAAM,IAAI,MAAM,+CAA+C;AAAA,EAChE;AACA,SAAO;AACR;",
6
+ "names": []
7
+ }
@@ -0,0 +1,61 @@
1
+ import type { Transaction } from '@haneullabs/haneul/transactions';
2
+ import type { DeepBookConfig } from '../utils/config.js';
3
+ /**
4
+ * MarginLiquidationsContract class for managing LiquidationVault operations.
5
+ */
6
+ export declare class MarginLiquidationsContract {
7
+ #private;
8
+ /**
9
+ * @param {DeepBookConfig} config Configuration for MarginLiquidationsContract
10
+ */
11
+ constructor(config: DeepBookConfig);
12
+ /**
13
+ * @description Create a new liquidation vault
14
+ * @param {string} liquidationAdminCap The liquidation admin cap object ID
15
+ * @returns A function that takes a Transaction object
16
+ */
17
+ createLiquidationVault: (liquidationAdminCap: string) => (tx: Transaction) => void;
18
+ /**
19
+ * @description Deposit coins into a liquidation vault
20
+ * @param {string} vaultId The liquidation vault object ID
21
+ * @param {string} liquidationAdminCap The liquidation admin cap object ID
22
+ * @param {string} coinKey The key to identify the coin type
23
+ * @param {number} amount The amount to deposit
24
+ * @returns A function that takes a Transaction object
25
+ */
26
+ deposit: (vaultId: string, liquidationAdminCap: string, coinKey: string, amount: number) => (tx: Transaction) => void;
27
+ /**
28
+ * @description Withdraw coins from a liquidation vault
29
+ * @param {string} vaultId The liquidation vault object ID
30
+ * @param {string} liquidationAdminCap The liquidation admin cap object ID
31
+ * @param {string} coinKey The key to identify the coin type
32
+ * @param {number} amount The amount to withdraw
33
+ * @returns A function that takes a Transaction object and returns the withdrawn coin
34
+ */
35
+ withdraw: (vaultId: string, liquidationAdminCap: string, coinKey: string, amount: number) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
36
+ /**
37
+ * @description Liquidate a margin manager by repaying base debt
38
+ * @param {string} vaultId The liquidation vault object ID
39
+ * @param {string} managerAddress The margin manager address to liquidate
40
+ * @param {string} poolKey The key to identify the pool
41
+ * @param {number} [repayAmount] The amount to repay (in base asset units), or undefined for full liquidation
42
+ * @returns A function that takes a Transaction object
43
+ */
44
+ liquidateBase: (vaultId: string, managerAddress: string, poolKey: string, repayAmount?: number) => (tx: Transaction) => void;
45
+ /**
46
+ * @description Liquidate a margin manager by repaying quote debt
47
+ * @param {string} vaultId The liquidation vault object ID
48
+ * @param {string} managerAddress The margin manager address to liquidate
49
+ * @param {string} poolKey The key to identify the pool
50
+ * @param {number} [repayAmount] The amount to repay (in quote asset units), or undefined for full liquidation
51
+ * @returns A function that takes a Transaction object
52
+ */
53
+ liquidateQuote: (vaultId: string, managerAddress: string, poolKey: string, repayAmount?: number) => (tx: Transaction) => void;
54
+ /**
55
+ * @description Get the balance of a specific coin type in the liquidation vault
56
+ * @param {string} vaultId The liquidation vault object ID
57
+ * @param {string} coinKey The key to identify the coin type
58
+ * @returns A function that takes a Transaction object
59
+ */
60
+ balance: (vaultId: string, coinKey: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
61
+ }