@haneullabs/deepbook-v3 0.1.0 → 1.2.1

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 (612) hide show
  1. package/CHANGELOG.md +342 -81
  2. package/dist/client.d.mts +238 -0
  3. package/dist/client.d.mts.map +1 -0
  4. package/dist/client.mjs +397 -0
  5. package/dist/client.mjs.map +1 -0
  6. package/dist/contracts/deepbook/account.d.mts +37 -0
  7. package/dist/contracts/deepbook/account.d.mts.map +1 -0
  8. package/dist/contracts/deepbook/account.mjs +31 -0
  9. package/dist/contracts/deepbook/account.mjs.map +1 -0
  10. package/dist/contracts/deepbook/balances.d.mts +12 -0
  11. package/dist/contracts/deepbook/balances.d.mts.map +1 -0
  12. package/dist/contracts/deepbook/balances.mjs +24 -0
  13. package/dist/contracts/deepbook/balances.mjs.map +1 -0
  14. package/dist/contracts/deepbook/deep_price.d.mts +12 -0
  15. package/dist/contracts/deepbook/deep_price.d.mts.map +1 -0
  16. package/dist/contracts/deepbook/deep_price.mjs +49 -0
  17. package/dist/contracts/deepbook/deep_price.mjs.map +1 -0
  18. package/dist/contracts/deepbook/deps/haneul/vec_set.d.mts +21 -0
  19. package/dist/contracts/deepbook/deps/haneul/vec_set.d.mts.map +1 -0
  20. package/dist/contracts/deepbook/deps/haneul/vec_set.mjs +26 -0
  21. package/dist/contracts/deepbook/deps/haneul/vec_set.mjs.map +1 -0
  22. package/dist/contracts/deepbook/order.d.mts +23 -0
  23. package/dist/contracts/deepbook/order.d.mts.map +1 -0
  24. package/dist/contracts/deepbook/order.mjs +63 -0
  25. package/dist/contracts/deepbook/order.mjs.map +1 -0
  26. package/dist/contracts/pyth/data_source.mjs +20 -0
  27. package/dist/contracts/pyth/data_source.mjs.map +1 -0
  28. package/dist/contracts/pyth/deps/0x0000000000000000000000000000000000000000000000000000000000000002/package.mjs +21 -0
  29. package/dist/contracts/pyth/deps/0x0000000000000000000000000000000000000000000000000000000000000002/package.mjs.map +1 -0
  30. package/dist/contracts/pyth/deps/0x0000000000000000000000000000000000000000000000000000000000000002/table.mjs +19 -0
  31. package/dist/contracts/pyth/deps/0x0000000000000000000000000000000000000000000000000000000000000002/table.mjs.map +1 -0
  32. package/dist/contracts/pyth/deps/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/bytes32.mjs +16 -0
  33. package/dist/contracts/pyth/deps/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/bytes32.mjs.map +1 -0
  34. package/dist/contracts/pyth/deps/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/consumed_vaas.mjs +16 -0
  35. package/dist/contracts/pyth/deps/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/consumed_vaas.mjs.map +1 -0
  36. package/dist/contracts/pyth/deps/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/external_address.mjs +16 -0
  37. package/dist/contracts/pyth/deps/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/external_address.mjs.map +1 -0
  38. package/dist/contracts/pyth/deps/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/set.mjs +16 -0
  39. package/dist/contracts/pyth/deps/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/set.mjs.map +1 -0
  40. package/dist/contracts/pyth/i64.mjs +19 -0
  41. package/dist/contracts/pyth/i64.mjs.map +1 -0
  42. package/dist/contracts/pyth/price.mjs +22 -0
  43. package/dist/contracts/pyth/price.mjs.map +1 -0
  44. package/dist/contracts/pyth/price_feed.mjs +21 -0
  45. package/dist/contracts/pyth/price_feed.mjs.map +1 -0
  46. package/dist/contracts/pyth/price_identifier.mjs +16 -0
  47. package/dist/contracts/pyth/price_identifier.mjs.map +1 -0
  48. package/dist/contracts/pyth/price_info.mjs +28 -0
  49. package/dist/contracts/pyth/price_info.mjs.map +1 -0
  50. package/dist/contracts/pyth/state.mjs +36 -0
  51. package/dist/contracts/pyth/state.mjs.map +1 -0
  52. package/dist/contracts/utils/index.d.mts +34 -0
  53. package/dist/contracts/utils/index.d.mts.map +1 -0
  54. package/dist/contracts/utils/index.mjs +35 -0
  55. package/dist/contracts/utils/index.mjs.map +1 -0
  56. package/dist/contracts/wormhole/bytes32.mjs +16 -0
  57. package/dist/contracts/wormhole/bytes32.mjs.map +1 -0
  58. package/dist/contracts/wormhole/consumed_vaas.mjs +16 -0
  59. package/dist/contracts/wormhole/consumed_vaas.mjs.map +1 -0
  60. package/dist/contracts/wormhole/deps/0x0000000000000000000000000000000000000000000000000000000000000002/balance.mjs +16 -0
  61. package/dist/contracts/wormhole/deps/0x0000000000000000000000000000000000000000000000000000000000000002/balance.mjs.map +1 -0
  62. package/dist/contracts/wormhole/deps/0x0000000000000000000000000000000000000000000000000000000000000002/package.mjs +21 -0
  63. package/dist/contracts/wormhole/deps/0x0000000000000000000000000000000000000000000000000000000000000002/package.mjs.map +1 -0
  64. package/dist/contracts/wormhole/deps/0x0000000000000000000000000000000000000000000000000000000000000002/table.mjs +19 -0
  65. package/dist/contracts/wormhole/deps/0x0000000000000000000000000000000000000000000000000000000000000002/table.mjs.map +1 -0
  66. package/dist/contracts/wormhole/external_address.mjs +16 -0
  67. package/dist/contracts/wormhole/external_address.mjs.map +1 -0
  68. package/dist/contracts/wormhole/fee_collector.mjs +20 -0
  69. package/dist/contracts/wormhole/fee_collector.mjs.map +1 -0
  70. package/dist/contracts/wormhole/set.mjs +16 -0
  71. package/dist/contracts/wormhole/set.mjs.map +1 -0
  72. package/dist/contracts/wormhole/state.mjs +31 -0
  73. package/dist/contracts/wormhole/state.mjs.map +1 -0
  74. package/dist/index.d.mts +25 -0
  75. package/dist/index.mjs +26 -0
  76. package/dist/pyth/PriceServiceConnection.d.mts +26 -0
  77. package/dist/pyth/PriceServiceConnection.d.mts.map +1 -0
  78. package/dist/pyth/PriceServiceConnection.mjs +35 -0
  79. package/dist/pyth/PriceServiceConnection.mjs.map +1 -0
  80. package/dist/pyth/pyth-helpers.mjs +18 -0
  81. package/dist/pyth/pyth-helpers.mjs.map +1 -0
  82. package/dist/pyth/pyth.d.mts +69 -0
  83. package/dist/pyth/pyth.d.mts.map +1 -0
  84. package/dist/pyth/pyth.mjs +220 -0
  85. package/dist/pyth/pyth.mjs.map +1 -0
  86. package/dist/queries/accountQueries.mjs +104 -0
  87. package/dist/queries/accountQueries.mjs.map +1 -0
  88. package/dist/queries/balanceManagerQueries.mjs +113 -0
  89. package/dist/queries/balanceManagerQueries.mjs.map +1 -0
  90. package/dist/queries/context.mjs +15 -0
  91. package/dist/queries/context.mjs.map +1 -0
  92. package/dist/queries/marginManagerQueries.mjs +365 -0
  93. package/dist/queries/marginManagerQueries.mjs.map +1 -0
  94. package/dist/queries/marginPoolQueries.mjs +184 -0
  95. package/dist/queries/marginPoolQueries.mjs.map +1 -0
  96. package/dist/queries/orderQueries.mjs +165 -0
  97. package/dist/queries/orderQueries.mjs.map +1 -0
  98. package/dist/queries/poolQueries.mjs +234 -0
  99. package/dist/queries/poolQueries.mjs.map +1 -0
  100. package/dist/queries/priceFeedQueries.mjs +83 -0
  101. package/dist/queries/priceFeedQueries.mjs.map +1 -0
  102. package/dist/queries/quantityQueries.mjs +216 -0
  103. package/dist/queries/quantityQueries.mjs.map +1 -0
  104. package/dist/queries/referralQueries.mjs +96 -0
  105. package/dist/queries/referralQueries.mjs.map +1 -0
  106. package/dist/queries/registryQueries.mjs +162 -0
  107. package/dist/queries/registryQueries.mjs.map +1 -0
  108. package/dist/queries/tpslQueries.mjs +62 -0
  109. package/dist/queries/tpslQueries.mjs.map +1 -0
  110. package/dist/transactions/balanceManager.d.mts +174 -0
  111. package/dist/transactions/balanceManager.d.mts.map +1 -0
  112. package/dist/transactions/balanceManager.mjs +234 -0
  113. package/dist/transactions/balanceManager.mjs.map +1 -0
  114. package/dist/transactions/deepbook.d.mts +490 -0
  115. package/dist/transactions/deepbook.d.mts.map +1 -0
  116. package/dist/transactions/deepbook.mjs +979 -0
  117. package/dist/transactions/deepbook.mjs.map +1 -0
  118. package/dist/transactions/deepbookAdmin.d.mts +111 -0
  119. package/dist/transactions/deepbookAdmin.d.mts.map +1 -0
  120. package/dist/transactions/deepbookAdmin.mjs +222 -0
  121. package/dist/transactions/deepbookAdmin.mjs.map +1 -0
  122. package/dist/transactions/flashLoans.d.mts +61 -0
  123. package/dist/transactions/flashLoans.d.mts.map +1 -0
  124. package/dist/transactions/flashLoans.mjs +77 -0
  125. package/dist/transactions/flashLoans.mjs.map +1 -0
  126. package/dist/transactions/governance.d.mts +47 -0
  127. package/dist/transactions/governance.d.mts.map +1 -0
  128. package/dist/transactions/governance.mjs +91 -0
  129. package/dist/transactions/governance.mjs.map +1 -0
  130. package/dist/transactions/marginAdmin.d.mts +138 -0
  131. package/dist/transactions/marginAdmin.d.mts.map +1 -0
  132. package/dist/transactions/marginAdmin.mjs +250 -0
  133. package/dist/transactions/marginAdmin.mjs.map +1 -0
  134. package/dist/transactions/marginLiquidations.d.mts +67 -0
  135. package/dist/transactions/marginLiquidations.d.mts.map +1 -0
  136. package/dist/transactions/marginLiquidations.mjs +110 -0
  137. package/dist/transactions/marginLiquidations.mjs.map +1 -0
  138. package/dist/transactions/marginMaintainer.d.mts +86 -0
  139. package/dist/transactions/marginMaintainer.d.mts.map +1 -0
  140. package/dist/transactions/marginMaintainer.mjs +161 -0
  141. package/dist/transactions/marginMaintainer.mjs.map +1 -0
  142. package/dist/transactions/marginManager.d.mts +247 -0
  143. package/dist/transactions/marginManager.d.mts.map +1 -0
  144. package/dist/transactions/marginManager.mjs +548 -0
  145. package/dist/transactions/marginManager.mjs.map +1 -0
  146. package/dist/transactions/marginPool.d.mts +140 -0
  147. package/dist/transactions/marginPool.d.mts.map +1 -0
  148. package/dist/transactions/marginPool.mjs +207 -0
  149. package/dist/transactions/marginPool.mjs.map +1 -0
  150. package/dist/transactions/marginRegistry.d.mts +100 -0
  151. package/dist/transactions/marginRegistry.d.mts.map +1 -0
  152. package/dist/transactions/marginRegistry.mjs +128 -0
  153. package/dist/transactions/marginRegistry.mjs.map +1 -0
  154. package/dist/transactions/marginTPSL.d.mts +100 -0
  155. package/dist/transactions/marginTPSL.d.mts.map +1 -0
  156. package/dist/transactions/marginTPSL.mjs +173 -0
  157. package/dist/transactions/marginTPSL.mjs.map +1 -0
  158. package/dist/transactions/poolProxy.d.mts +123 -0
  159. package/dist/transactions/poolProxy.d.mts.map +1 -0
  160. package/dist/transactions/poolProxy.mjs +336 -0
  161. package/dist/transactions/poolProxy.mjs.map +1 -0
  162. package/dist/types/bcs.d.mts +5 -0
  163. package/dist/types/bcs.mjs +7 -0
  164. package/dist/types/index.d.mts +374 -0
  165. package/dist/types/index.d.mts.map +1 -0
  166. package/dist/types/index.mjs +18 -0
  167. package/dist/types/index.mjs.map +1 -0
  168. package/dist/utils/config.d.mts +90 -0
  169. package/dist/utils/config.d.mts.map +1 -0
  170. package/dist/utils/config.mjs +104 -0
  171. package/dist/utils/config.mjs.map +1 -0
  172. package/dist/utils/constants.d.mts +93 -0
  173. package/dist/utils/constants.d.mts.map +1 -0
  174. package/dist/utils/constants.mjs +408 -0
  175. package/dist/utils/constants.mjs.map +1 -0
  176. package/dist/utils/conversion.mjs +26 -0
  177. package/dist/utils/conversion.mjs.map +1 -0
  178. package/dist/utils/errors.d.mts +46 -0
  179. package/dist/utils/errors.d.mts.map +1 -0
  180. package/dist/utils/errors.mjs +59 -0
  181. package/dist/utils/errors.mjs.map +1 -0
  182. package/dist/{cjs/utils/validation.d.ts → utils/validation.d.mts} +11 -7
  183. package/dist/utils/validation.d.mts.map +1 -0
  184. package/dist/utils/validation.mjs +76 -0
  185. package/dist/utils/validation.mjs.map +1 -0
  186. package/package.json +30 -26
  187. package/src/client.ts +467 -2255
  188. package/src/contracts/deepbook/account.ts +15 -15
  189. package/src/contracts/deepbook/balance_manager.ts +343 -57
  190. package/src/contracts/deepbook/balances.ts +3 -2
  191. package/src/contracts/deepbook/big_vector.ts +6 -7
  192. package/src/contracts/deepbook/book.ts +3 -2
  193. package/src/contracts/deepbook/constants.ts +95 -3
  194. package/src/contracts/deepbook/deep_price.ts +7 -7
  195. package/src/contracts/deepbook/deps/{sui → haneul}/bag.ts +8 -8
  196. package/src/contracts/deepbook/deps/{sui → haneul}/balance.ts +4 -3
  197. package/src/contracts/deepbook/deps/{sui → haneul}/table.ts +6 -6
  198. package/src/contracts/deepbook/deps/{sui → haneul}/vec_map.ts +4 -4
  199. package/src/contracts/deepbook/deps/{sui → haneul}/vec_set.ts +4 -4
  200. package/src/contracts/deepbook/deps/{sui → haneul}/versioned.ts +4 -4
  201. package/src/contracts/deepbook/deps/std/type_name.ts +3 -2
  202. package/src/contracts/deepbook/ewma.ts +14 -3
  203. package/src/contracts/deepbook/fill.ts +21 -21
  204. package/src/contracts/deepbook/governance.ts +4 -3
  205. package/src/contracts/deepbook/history.ts +4 -3
  206. package/src/contracts/deepbook/math.ts +15 -15
  207. package/src/contracts/deepbook/order.ts +16 -16
  208. package/src/contracts/deepbook/order_info.ts +39 -27
  209. package/src/contracts/deepbook/order_query.ts +12 -12
  210. package/src/contracts/deepbook/pool.ts +883 -526
  211. package/src/contracts/deepbook/registry.ts +149 -38
  212. package/src/contracts/deepbook/state.ts +14 -3
  213. package/src/contracts/deepbook/trade_params.ts +3 -2
  214. package/src/contracts/deepbook/vault.ts +5 -4
  215. package/src/contracts/pyth/batch_price_attestation.ts +92 -0
  216. package/src/contracts/pyth/contract_upgrade.ts +54 -0
  217. package/src/contracts/pyth/data_source.ts +64 -0
  218. package/src/contracts/pyth/deps/0x0000000000000000000000000000000000000000000000000000000000000002/package.ts +15 -0
  219. package/src/contracts/pyth/deps/0x0000000000000000000000000000000000000000000000000000000000000002/table.ts +13 -0
  220. package/src/contracts/pyth/deps/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/bytes32.ts +12 -0
  221. package/src/contracts/pyth/deps/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/consumed_vaas.ts +13 -0
  222. package/src/contracts/pyth/deps/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/external_address.ts +13 -0
  223. package/src/contracts/pyth/deps/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/set.ts +12 -0
  224. package/src/contracts/pyth/deserialize.ts +117 -0
  225. package/src/contracts/pyth/event.ts +20 -0
  226. package/src/contracts/pyth/governance.ts +113 -0
  227. package/src/contracts/pyth/governance_action.ts +130 -0
  228. package/src/contracts/pyth/governance_instruction.ts +98 -0
  229. package/src/contracts/pyth/hot_potato_vector.ts +70 -0
  230. package/src/contracts/pyth/i64.ts +94 -0
  231. package/src/contracts/pyth/merkle_tree.ts +41 -0
  232. package/src/contracts/pyth/migrate.ts +29 -0
  233. package/src/contracts/pyth/price.ts +102 -0
  234. package/src/contracts/pyth/price_feed.ts +101 -0
  235. package/src/contracts/pyth/price_identifier.ts +46 -0
  236. package/src/contracts/pyth/price_info.ts +220 -0
  237. package/src/contracts/pyth/price_status.ts +74 -0
  238. package/src/contracts/pyth/pyth.ts +236 -0
  239. package/src/contracts/pyth/set.ts +93 -0
  240. package/src/contracts/pyth/set_data_sources.ts +14 -0
  241. package/src/contracts/pyth/set_fee_recipient.ts +13 -0
  242. package/src/contracts/pyth/set_governance_data_source.ts +16 -0
  243. package/src/contracts/pyth/set_stale_price_threshold.ts +13 -0
  244. package/src/contracts/pyth/set_update_fee.ts +14 -0
  245. package/src/contracts/pyth/setup.ts +12 -0
  246. package/src/contracts/pyth/state.ts +227 -0
  247. package/src/contracts/pyth/version_control.ts +25 -0
  248. package/src/contracts/utils/index.ts +100 -50
  249. package/src/contracts/wormhole/bytes32.ts +12 -0
  250. package/src/contracts/wormhole/consumed_vaas.ts +13 -0
  251. package/src/contracts/wormhole/deps/0x0000000000000000000000000000000000000000000000000000000000000002/balance.ts +12 -0
  252. package/src/contracts/wormhole/deps/0x0000000000000000000000000000000000000000000000000000000000000002/package.ts +15 -0
  253. package/src/contracts/wormhole/deps/0x0000000000000000000000000000000000000000000000000000000000000002/table.ts +13 -0
  254. package/src/contracts/wormhole/external_address.ts +13 -0
  255. package/src/contracts/wormhole/fee_collector.ts +15 -0
  256. package/src/contracts/wormhole/set.ts +12 -0
  257. package/src/contracts/wormhole/state.ts +25 -0
  258. package/src/index.ts +44 -3
  259. package/src/pyth/pyth.ts +51 -50
  260. package/src/queries/accountQueries.ts +117 -0
  261. package/src/queries/balanceManagerQueries.ts +156 -0
  262. package/src/queries/context.ts +44 -0
  263. package/src/queries/index.ts +16 -0
  264. package/src/queries/marginManagerQueries.ts +575 -0
  265. package/src/queries/marginPoolQueries.ts +226 -0
  266. package/src/queries/orderQueries.ts +202 -0
  267. package/src/queries/poolQueries.ts +266 -0
  268. package/src/queries/priceFeedQueries.ts +141 -0
  269. package/src/queries/quantityQueries.ts +266 -0
  270. package/src/queries/referralQueries.ts +112 -0
  271. package/src/queries/registryQueries.ts +185 -0
  272. package/src/queries/tpslQueries.ts +88 -0
  273. package/src/transactions/balanceManager.ts +5 -4
  274. package/src/transactions/deepbook.ts +117 -84
  275. package/src/transactions/deepbookAdmin.ts +10 -9
  276. package/src/transactions/flashLoans.ts +5 -4
  277. package/src/transactions/governance.ts +5 -4
  278. package/src/transactions/marginAdmin.ts +12 -8
  279. package/src/transactions/marginLiquidations.ts +5 -4
  280. package/src/transactions/marginMaintainer.ts +28 -16
  281. package/src/transactions/marginManager.ts +78 -29
  282. package/src/transactions/marginPool.ts +7 -7
  283. package/src/transactions/marginTPSL.ts +16 -11
  284. package/src/transactions/poolProxy.ts +62 -11
  285. package/src/types/bcs.ts +1 -1
  286. package/src/types/index.ts +217 -53
  287. package/src/utils/config.ts +38 -17
  288. package/src/utils/constants.ts +73 -18
  289. package/src/utils/conversion.ts +33 -0
  290. package/src/utils/validation.ts +1 -1
  291. package/dist/cjs/client.d.ts +0 -861
  292. package/dist/cjs/client.js +0 -1982
  293. package/dist/cjs/client.js.map +0 -7
  294. package/dist/cjs/contracts/deepbook/account.d.ts +0 -105
  295. package/dist/cjs/contracts/deepbook/account.js +0 -163
  296. package/dist/cjs/contracts/deepbook/account.js.map +0 -7
  297. package/dist/cjs/contracts/deepbook/balance_manager.d.ts +0 -268
  298. package/dist/cjs/contracts/deepbook/balance_manager.js +0 -361
  299. package/dist/cjs/contracts/deepbook/balance_manager.js.map +0 -7
  300. package/dist/cjs/contracts/deepbook/balances.d.ts +0 -10
  301. package/dist/cjs/contracts/deepbook/balances.js +0 -35
  302. package/dist/cjs/contracts/deepbook/balances.js.map +0 -7
  303. package/dist/cjs/contracts/deepbook/big_vector.d.ts +0 -62
  304. package/dist/cjs/contracts/deepbook/big_vector.js +0 -80
  305. package/dist/cjs/contracts/deepbook/big_vector.js.map +0 -7
  306. package/dist/cjs/contracts/deepbook/book.d.ts +0 -34
  307. package/dist/cjs/contracts/deepbook/book.js +0 -50
  308. package/dist/cjs/contracts/deepbook/book.js.map +0 -7
  309. package/dist/cjs/contracts/deepbook/constants.d.ts +0 -176
  310. package/dist/cjs/contracts/deepbook/constants.js +0 -338
  311. package/dist/cjs/contracts/deepbook/constants.js.map +0 -7
  312. package/dist/cjs/contracts/deepbook/deep_price.d.ts +0 -60
  313. package/dist/cjs/contracts/deepbook/deep_price.js +0 -87
  314. package/dist/cjs/contracts/deepbook/deep_price.js.map +0 -7
  315. package/dist/cjs/contracts/deepbook/deps/std/type_name.d.ts +0 -14
  316. package/dist/cjs/contracts/deepbook/deps/std/type_name.js +0 -42
  317. package/dist/cjs/contracts/deepbook/deps/std/type_name.js.map +0 -7
  318. package/dist/cjs/contracts/deepbook/deps/sui/bag.d.ts +0 -33
  319. package/dist/cjs/contracts/deepbook/deps/sui/bag.js +0 -47
  320. package/dist/cjs/contracts/deepbook/deps/sui/bag.js.map +0 -7
  321. package/dist/cjs/contracts/deepbook/deps/sui/balance.d.ts +0 -9
  322. package/dist/cjs/contracts/deepbook/deps/sui/balance.js +0 -33
  323. package/dist/cjs/contracts/deepbook/deps/sui/balance.js.map +0 -7
  324. package/dist/cjs/contracts/deepbook/deps/sui/object.d.ts +0 -5
  325. package/dist/cjs/contracts/deepbook/deps/sui/object.js +0 -33
  326. package/dist/cjs/contracts/deepbook/deps/sui/object.js.map +0 -7
  327. package/dist/cjs/contracts/deepbook/deps/sui/table.d.ts +0 -28
  328. package/dist/cjs/contracts/deepbook/deps/sui/table.js +0 -47
  329. package/dist/cjs/contracts/deepbook/deps/sui/table.js.map +0 -7
  330. package/dist/cjs/contracts/deepbook/deps/sui/vec_map.d.ts +0 -27
  331. package/dist/cjs/contracts/deepbook/deps/sui/vec_map.js +0 -45
  332. package/dist/cjs/contracts/deepbook/deps/sui/vec_map.js.map +0 -7
  333. package/dist/cjs/contracts/deepbook/deps/sui/vec_set.d.ts +0 -15
  334. package/dist/cjs/contracts/deepbook/deps/sui/vec_set.js +0 -35
  335. package/dist/cjs/contracts/deepbook/deps/sui/vec_set.js.map +0 -7
  336. package/dist/cjs/contracts/deepbook/deps/sui/versioned.d.ts +0 -7
  337. package/dist/cjs/contracts/deepbook/deps/sui/versioned.js +0 -45
  338. package/dist/cjs/contracts/deepbook/deps/sui/versioned.js.map +0 -7
  339. package/dist/cjs/contracts/deepbook/ewma.d.ts +0 -17
  340. package/dist/cjs/contracts/deepbook/ewma.js +0 -39
  341. package/dist/cjs/contracts/deepbook/ewma.js.map +0 -7
  342. package/dist/cjs/contracts/deepbook/fill.d.ts +0 -153
  343. package/dist/cjs/contracts/deepbook/fill.js +0 -251
  344. package/dist/cjs/contracts/deepbook/fill.js.map +0 -7
  345. package/dist/cjs/contracts/deepbook/governance.d.ts +0 -63
  346. package/dist/cjs/contracts/deepbook/governance.js +0 -79
  347. package/dist/cjs/contracts/deepbook/governance.js.map +0 -7
  348. package/dist/cjs/contracts/deepbook/history.d.ts +0 -60
  349. package/dist/cjs/contracts/deepbook/history.js +0 -78
  350. package/dist/cjs/contracts/deepbook/history.js.map +0 -7
  351. package/dist/cjs/contracts/deepbook/math.d.ts +0 -94
  352. package/dist/cjs/contracts/deepbook/math.js +0 -132
  353. package/dist/cjs/contracts/deepbook/math.js.map +0 -7
  354. package/dist/cjs/contracts/deepbook/order.d.ts +0 -135
  355. package/dist/cjs/contracts/deepbook/order.js +0 -218
  356. package/dist/cjs/contracts/deepbook/order.js.map +0 -7
  357. package/dist/cjs/contracts/deepbook/order_info.d.ts +0 -296
  358. package/dist/cjs/contracts/deepbook/order_info.js +0 -386
  359. package/dist/cjs/contracts/deepbook/order_info.js.map +0 -7
  360. package/dist/cjs/contracts/deepbook/order_query.d.ts +0 -85
  361. package/dist/cjs/contracts/deepbook/order_query.js +0 -96
  362. package/dist/cjs/contracts/deepbook/order_query.js.map +0 -7
  363. package/dist/cjs/contracts/deepbook/pool.d.ts +0 -1218
  364. package/dist/cjs/contracts/deepbook/pool.js +0 -1236
  365. package/dist/cjs/contracts/deepbook/pool.js.map +0 -7
  366. package/dist/cjs/contracts/deepbook/registry.d.ts +0 -134
  367. package/dist/cjs/contracts/deepbook/registry.js +0 -182
  368. package/dist/cjs/contracts/deepbook/registry.js.map +0 -7
  369. package/dist/cjs/contracts/deepbook/state.d.ts +0 -117
  370. package/dist/cjs/contracts/deepbook/state.js +0 -104
  371. package/dist/cjs/contracts/deepbook/state.js.map +0 -7
  372. package/dist/cjs/contracts/deepbook/trade_params.d.ts +0 -7
  373. package/dist/cjs/contracts/deepbook/trade_params.js +0 -35
  374. package/dist/cjs/contracts/deepbook/trade_params.js.map +0 -7
  375. package/dist/cjs/contracts/deepbook/vault.d.ts +0 -30
  376. package/dist/cjs/contracts/deepbook/vault.js +0 -65
  377. package/dist/cjs/contracts/deepbook/vault.js.map +0 -7
  378. package/dist/cjs/contracts/utils/index.d.ts +0 -25
  379. package/dist/cjs/contracts/utils/index.js +0 -148
  380. package/dist/cjs/contracts/utils/index.js.map +0 -7
  381. package/dist/cjs/index.d.ts +0 -23
  382. package/dist/cjs/index.js +0 -81
  383. package/dist/cjs/index.js.map +0 -7
  384. package/dist/cjs/package.json +0 -4
  385. package/dist/cjs/pyth/PriceServiceConnection.d.ts +0 -26
  386. package/dist/cjs/pyth/PriceServiceConnection.js +0 -68
  387. package/dist/cjs/pyth/PriceServiceConnection.js.map +0 -7
  388. package/dist/cjs/pyth/pyth-helpers.d.ts +0 -7
  389. package/dist/cjs/pyth/pyth-helpers.js +0 -36
  390. package/dist/cjs/pyth/pyth-helpers.js.map +0 -7
  391. package/dist/cjs/pyth/pyth.d.ts +0 -65
  392. package/dist/cjs/pyth/pyth.js +0 -269
  393. package/dist/cjs/pyth/pyth.js.map +0 -7
  394. package/dist/cjs/transactions/balanceManager.d.ts +0 -168
  395. package/dist/cjs/transactions/balanceManager.js +0 -384
  396. package/dist/cjs/transactions/balanceManager.js.map +0 -7
  397. package/dist/cjs/transactions/deepbook.d.ts +0 -477
  398. package/dist/cjs/transactions/deepbook.js +0 -1335
  399. package/dist/cjs/transactions/deepbook.js.map +0 -7
  400. package/dist/cjs/transactions/deepbookAdmin.d.ts +0 -105
  401. package/dist/cjs/transactions/deepbookAdmin.js +0 -334
  402. package/dist/cjs/transactions/deepbookAdmin.js.map +0 -7
  403. package/dist/cjs/transactions/flashLoans.d.ts +0 -56
  404. package/dist/cjs/transactions/flashLoans.js +0 -124
  405. package/dist/cjs/transactions/flashLoans.js.map +0 -7
  406. package/dist/cjs/transactions/governance.d.ts +0 -42
  407. package/dist/cjs/transactions/governance.js +0 -135
  408. package/dist/cjs/transactions/governance.js.map +0 -7
  409. package/dist/cjs/transactions/marginAdmin.d.ts +0 -133
  410. package/dist/cjs/transactions/marginAdmin.js +0 -393
  411. package/dist/cjs/transactions/marginAdmin.js.map +0 -7
  412. package/dist/cjs/transactions/marginLiquidations.d.ts +0 -61
  413. package/dist/cjs/transactions/marginLiquidations.js +0 -173
  414. package/dist/cjs/transactions/marginLiquidations.js.map +0 -7
  415. package/dist/cjs/transactions/marginMaintainer.d.ts +0 -80
  416. package/dist/cjs/transactions/marginMaintainer.js +0 -251
  417. package/dist/cjs/transactions/marginMaintainer.js.map +0 -7
  418. package/dist/cjs/transactions/marginManager.d.ts +0 -236
  419. package/dist/cjs/transactions/marginManager.js +0 -688
  420. package/dist/cjs/transactions/marginManager.js.map +0 -7
  421. package/dist/cjs/transactions/marginPool.d.ts +0 -134
  422. package/dist/cjs/transactions/marginPool.js +0 -330
  423. package/dist/cjs/transactions/marginPool.js.map +0 -7
  424. package/dist/cjs/transactions/marginRegistry.d.ts +0 -94
  425. package/dist/cjs/transactions/marginRegistry.js +0 -221
  426. package/dist/cjs/transactions/marginRegistry.js.map +0 -7
  427. package/dist/cjs/transactions/marginTPSL.d.ts +0 -93
  428. package/dist/cjs/transactions/marginTPSL.js +0 -286
  429. package/dist/cjs/transactions/marginTPSL.js.map +0 -7
  430. package/dist/cjs/transactions/poolProxy.d.ts +0 -104
  431. package/dist/cjs/transactions/poolProxy.js +0 -435
  432. package/dist/cjs/transactions/poolProxy.js.map +0 -7
  433. package/dist/cjs/types/bcs.d.ts +0 -5
  434. package/dist/cjs/types/bcs.js +0 -33
  435. package/dist/cjs/types/bcs.js.map +0 -7
  436. package/dist/cjs/types/index.d.ts +0 -218
  437. package/dist/cjs/types/index.js +0 -38
  438. package/dist/cjs/types/index.js.map +0 -7
  439. package/dist/cjs/utils/config.d.ts +0 -65
  440. package/dist/cjs/utils/config.js +0 -144
  441. package/dist/cjs/utils/config.js.map +0 -7
  442. package/dist/cjs/utils/constants.d.ts +0 -76
  443. package/dist/cjs/utils/constants.js +0 -382
  444. package/dist/cjs/utils/constants.js.map +0 -7
  445. package/dist/cjs/utils/errors.d.ts +0 -42
  446. package/dist/cjs/utils/errors.js +0 -70
  447. package/dist/cjs/utils/errors.js.map +0 -7
  448. package/dist/cjs/utils/validation.js +0 -67
  449. package/dist/cjs/utils/validation.js.map +0 -7
  450. package/dist/esm/client.d.ts +0 -861
  451. package/dist/esm/client.js +0 -1967
  452. package/dist/esm/client.js.map +0 -7
  453. package/dist/esm/contracts/deepbook/account.d.ts +0 -105
  454. package/dist/esm/contracts/deepbook/account.js +0 -133
  455. package/dist/esm/contracts/deepbook/account.js.map +0 -7
  456. package/dist/esm/contracts/deepbook/balance_manager.d.ts +0 -268
  457. package/dist/esm/contracts/deepbook/balance_manager.js +0 -331
  458. package/dist/esm/contracts/deepbook/balance_manager.js.map +0 -7
  459. package/dist/esm/contracts/deepbook/balances.d.ts +0 -10
  460. package/dist/esm/contracts/deepbook/balances.js +0 -15
  461. package/dist/esm/contracts/deepbook/balances.js.map +0 -7
  462. package/dist/esm/contracts/deepbook/big_vector.d.ts +0 -62
  463. package/dist/esm/contracts/deepbook/big_vector.js +0 -50
  464. package/dist/esm/contracts/deepbook/big_vector.js.map +0 -7
  465. package/dist/esm/contracts/deepbook/book.d.ts +0 -34
  466. package/dist/esm/contracts/deepbook/book.js +0 -20
  467. package/dist/esm/contracts/deepbook/book.js.map +0 -7
  468. package/dist/esm/contracts/deepbook/constants.d.ts +0 -176
  469. package/dist/esm/contracts/deepbook/constants.js +0 -318
  470. package/dist/esm/contracts/deepbook/constants.js.map +0 -7
  471. package/dist/esm/contracts/deepbook/deep_price.d.ts +0 -60
  472. package/dist/esm/contracts/deepbook/deep_price.js +0 -67
  473. package/dist/esm/contracts/deepbook/deep_price.js.map +0 -7
  474. package/dist/esm/contracts/deepbook/deps/std/type_name.d.ts +0 -14
  475. package/dist/esm/contracts/deepbook/deps/std/type_name.js +0 -22
  476. package/dist/esm/contracts/deepbook/deps/std/type_name.js.map +0 -7
  477. package/dist/esm/contracts/deepbook/deps/sui/bag.d.ts +0 -33
  478. package/dist/esm/contracts/deepbook/deps/sui/bag.js +0 -17
  479. package/dist/esm/contracts/deepbook/deps/sui/bag.js.map +0 -7
  480. package/dist/esm/contracts/deepbook/deps/sui/balance.d.ts +0 -9
  481. package/dist/esm/contracts/deepbook/deps/sui/balance.js +0 -13
  482. package/dist/esm/contracts/deepbook/deps/sui/balance.js.map +0 -7
  483. package/dist/esm/contracts/deepbook/deps/sui/object.d.ts +0 -5
  484. package/dist/esm/contracts/deepbook/deps/sui/object.js +0 -13
  485. package/dist/esm/contracts/deepbook/deps/sui/object.js.map +0 -7
  486. package/dist/esm/contracts/deepbook/deps/sui/table.d.ts +0 -28
  487. package/dist/esm/contracts/deepbook/deps/sui/table.js +0 -17
  488. package/dist/esm/contracts/deepbook/deps/sui/table.js.map +0 -7
  489. package/dist/esm/contracts/deepbook/deps/sui/vec_map.d.ts +0 -27
  490. package/dist/esm/contracts/deepbook/deps/sui/vec_map.js +0 -25
  491. package/dist/esm/contracts/deepbook/deps/sui/vec_map.js.map +0 -7
  492. package/dist/esm/contracts/deepbook/deps/sui/vec_set.d.ts +0 -15
  493. package/dist/esm/contracts/deepbook/deps/sui/vec_set.js +0 -15
  494. package/dist/esm/contracts/deepbook/deps/sui/vec_set.js.map +0 -7
  495. package/dist/esm/contracts/deepbook/deps/sui/versioned.d.ts +0 -7
  496. package/dist/esm/contracts/deepbook/deps/sui/versioned.js +0 -15
  497. package/dist/esm/contracts/deepbook/deps/sui/versioned.js.map +0 -7
  498. package/dist/esm/contracts/deepbook/ewma.d.ts +0 -17
  499. package/dist/esm/contracts/deepbook/ewma.js +0 -19
  500. package/dist/esm/contracts/deepbook/ewma.js.map +0 -7
  501. package/dist/esm/contracts/deepbook/fill.d.ts +0 -153
  502. package/dist/esm/contracts/deepbook/fill.js +0 -221
  503. package/dist/esm/contracts/deepbook/fill.js.map +0 -7
  504. package/dist/esm/contracts/deepbook/governance.d.ts +0 -63
  505. package/dist/esm/contracts/deepbook/governance.js +0 -49
  506. package/dist/esm/contracts/deepbook/governance.js.map +0 -7
  507. package/dist/esm/contracts/deepbook/history.d.ts +0 -60
  508. package/dist/esm/contracts/deepbook/history.js +0 -48
  509. package/dist/esm/contracts/deepbook/history.js.map +0 -7
  510. package/dist/esm/contracts/deepbook/math.d.ts +0 -94
  511. package/dist/esm/contracts/deepbook/math.js +0 -112
  512. package/dist/esm/contracts/deepbook/math.js.map +0 -7
  513. package/dist/esm/contracts/deepbook/order.d.ts +0 -135
  514. package/dist/esm/contracts/deepbook/order.js +0 -188
  515. package/dist/esm/contracts/deepbook/order.js.map +0 -7
  516. package/dist/esm/contracts/deepbook/order_info.d.ts +0 -296
  517. package/dist/esm/contracts/deepbook/order_info.js +0 -356
  518. package/dist/esm/contracts/deepbook/order_info.js.map +0 -7
  519. package/dist/esm/contracts/deepbook/order_query.d.ts +0 -85
  520. package/dist/esm/contracts/deepbook/order_query.js +0 -66
  521. package/dist/esm/contracts/deepbook/order_query.js.map +0 -7
  522. package/dist/esm/contracts/deepbook/pool.d.ts +0 -1218
  523. package/dist/esm/contracts/deepbook/pool.js +0 -1206
  524. package/dist/esm/contracts/deepbook/pool.js.map +0 -7
  525. package/dist/esm/contracts/deepbook/registry.d.ts +0 -134
  526. package/dist/esm/contracts/deepbook/registry.js +0 -152
  527. package/dist/esm/contracts/deepbook/registry.js.map +0 -7
  528. package/dist/esm/contracts/deepbook/state.d.ts +0 -117
  529. package/dist/esm/contracts/deepbook/state.js +0 -74
  530. package/dist/esm/contracts/deepbook/state.js.map +0 -7
  531. package/dist/esm/contracts/deepbook/trade_params.d.ts +0 -7
  532. package/dist/esm/contracts/deepbook/trade_params.js +0 -15
  533. package/dist/esm/contracts/deepbook/trade_params.js.map +0 -7
  534. package/dist/esm/contracts/deepbook/vault.d.ts +0 -30
  535. package/dist/esm/contracts/deepbook/vault.js +0 -35
  536. package/dist/esm/contracts/deepbook/vault.js.map +0 -7
  537. package/dist/esm/contracts/utils/index.d.ts +0 -25
  538. package/dist/esm/contracts/utils/index.js +0 -128
  539. package/dist/esm/contracts/utils/index.js.map +0 -7
  540. package/dist/esm/index.d.ts +0 -23
  541. package/dist/esm/index.js +0 -81
  542. package/dist/esm/index.js.map +0 -7
  543. package/dist/esm/package.json +0 -4
  544. package/dist/esm/pyth/PriceServiceConnection.d.ts +0 -26
  545. package/dist/esm/pyth/PriceServiceConnection.js +0 -38
  546. package/dist/esm/pyth/PriceServiceConnection.js.map +0 -7
  547. package/dist/esm/pyth/pyth-helpers.d.ts +0 -7
  548. package/dist/esm/pyth/pyth-helpers.js +0 -16
  549. package/dist/esm/pyth/pyth-helpers.js.map +0 -7
  550. package/dist/esm/pyth/pyth.d.ts +0 -65
  551. package/dist/esm/pyth/pyth.js +0 -249
  552. package/dist/esm/pyth/pyth.js.map +0 -7
  553. package/dist/esm/transactions/balanceManager.d.ts +0 -168
  554. package/dist/esm/transactions/balanceManager.js +0 -364
  555. package/dist/esm/transactions/balanceManager.js.map +0 -7
  556. package/dist/esm/transactions/deepbook.d.ts +0 -477
  557. package/dist/esm/transactions/deepbook.js +0 -1321
  558. package/dist/esm/transactions/deepbook.js.map +0 -7
  559. package/dist/esm/transactions/deepbookAdmin.d.ts +0 -105
  560. package/dist/esm/transactions/deepbookAdmin.js +0 -314
  561. package/dist/esm/transactions/deepbookAdmin.js.map +0 -7
  562. package/dist/esm/transactions/flashLoans.d.ts +0 -56
  563. package/dist/esm/transactions/flashLoans.js +0 -104
  564. package/dist/esm/transactions/flashLoans.js.map +0 -7
  565. package/dist/esm/transactions/governance.d.ts +0 -42
  566. package/dist/esm/transactions/governance.js +0 -115
  567. package/dist/esm/transactions/governance.js.map +0 -7
  568. package/dist/esm/transactions/marginAdmin.d.ts +0 -133
  569. package/dist/esm/transactions/marginAdmin.js +0 -373
  570. package/dist/esm/transactions/marginAdmin.js.map +0 -7
  571. package/dist/esm/transactions/marginLiquidations.d.ts +0 -61
  572. package/dist/esm/transactions/marginLiquidations.js +0 -153
  573. package/dist/esm/transactions/marginLiquidations.js.map +0 -7
  574. package/dist/esm/transactions/marginMaintainer.d.ts +0 -80
  575. package/dist/esm/transactions/marginMaintainer.js +0 -231
  576. package/dist/esm/transactions/marginMaintainer.js.map +0 -7
  577. package/dist/esm/transactions/marginManager.d.ts +0 -236
  578. package/dist/esm/transactions/marginManager.js +0 -668
  579. package/dist/esm/transactions/marginManager.js.map +0 -7
  580. package/dist/esm/transactions/marginPool.d.ts +0 -134
  581. package/dist/esm/transactions/marginPool.js +0 -310
  582. package/dist/esm/transactions/marginPool.js.map +0 -7
  583. package/dist/esm/transactions/marginRegistry.d.ts +0 -94
  584. package/dist/esm/transactions/marginRegistry.js +0 -201
  585. package/dist/esm/transactions/marginRegistry.js.map +0 -7
  586. package/dist/esm/transactions/marginTPSL.d.ts +0 -93
  587. package/dist/esm/transactions/marginTPSL.js +0 -266
  588. package/dist/esm/transactions/marginTPSL.js.map +0 -7
  589. package/dist/esm/transactions/poolProxy.d.ts +0 -104
  590. package/dist/esm/transactions/poolProxy.js +0 -415
  591. package/dist/esm/transactions/poolProxy.js.map +0 -7
  592. package/dist/esm/types/bcs.d.ts +0 -5
  593. package/dist/esm/types/bcs.js +0 -13
  594. package/dist/esm/types/bcs.js.map +0 -7
  595. package/dist/esm/types/index.d.ts +0 -218
  596. package/dist/esm/types/index.js +0 -18
  597. package/dist/esm/types/index.js.map +0 -7
  598. package/dist/esm/utils/config.d.ts +0 -65
  599. package/dist/esm/utils/config.js +0 -135
  600. package/dist/esm/utils/config.js.map +0 -7
  601. package/dist/esm/utils/constants.d.ts +0 -76
  602. package/dist/esm/utils/constants.js +0 -362
  603. package/dist/esm/utils/constants.js.map +0 -7
  604. package/dist/esm/utils/errors.d.ts +0 -42
  605. package/dist/esm/utils/errors.js +0 -50
  606. package/dist/esm/utils/errors.js.map +0 -7
  607. package/dist/esm/utils/validation.d.ts +0 -50
  608. package/dist/esm/utils/validation.js +0 -47
  609. package/dist/esm/utils/validation.js.map +0 -7
  610. package/dist/tsconfig.esm.tsbuildinfo +0 -1
  611. package/dist/tsconfig.tsbuildinfo +0 -1
  612. package/src/contracts/deepbook/deps/sui/object.ts +0 -14
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marginAdmin.mjs","names":["#config","#marginAdminCap","config"],"sources":["../../src/transactions/marginAdmin.ts"],"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 { convertRate } from '../utils/conversion.js';\nimport { hexToBytes } from '@noble/hashes/utils.js';\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(convertRate(minWithdrawRiskRatio, FLOAT_SCALAR)),\n\t\t\t\ttx.pure.u64(convertRate(minBorrowRiskRatio, FLOAT_SCALAR)),\n\t\t\t\ttx.pure.u64(convertRate(liquidationRiskRatio, FLOAT_SCALAR)),\n\t\t\t\ttx.pure.u64(convertRate(targetLiquidationRiskRatio, FLOAT_SCALAR)),\n\t\t\t\ttx.pure.u64(convertRate(userLiquidationReward, FLOAT_SCALAR)),\n\t\t\t\ttx.pure.u64(convertRate(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: [\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.pure.u64(convertRate(leverage, 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 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"],"mappings":";;;;;;;;AAeA,IAAa,sBAAb,MAAiC;CAChC;;;;CAKA,YAAY,QAAwB;kCAoBT,OAAoB;AAC9C,UAAO,GAAG,SAAS;IAClB,QAAQ,GAAG,MAAKA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B,CAAC;KACjC;IACD,eAAe,CAAC,KAAK,KAAK;IAC1B,CAAC;;AAvXF,QAAKD,SAAU;;;;;;CAOhB,kBAAkB;EACjB,MAAM,iBAAiB,MAAKA,OAAQ;AACpC,MAAI,CAAC,eACJ,OAAM,IAAI,MAAM,gDAAgD;AAEjE,SAAO"}
@@ -0,0 +1,67 @@
1
+ import { DeepBookConfig } from "../utils/config.mjs";
2
+ import * as _haneullabs_haneul_transactions113 from "@haneullabs/haneul/transactions";
3
+ import { Transaction } from "@haneullabs/haneul/transactions";
4
+
5
+ //#region src/transactions/marginLiquidations.d.ts
6
+ /**
7
+ * MarginLiquidationsContract class for managing LiquidationVault operations.
8
+ */
9
+ declare class MarginLiquidationsContract {
10
+ #private;
11
+ /**
12
+ * @param {DeepBookConfig} config Configuration for MarginLiquidationsContract
13
+ */
14
+ constructor(config: DeepBookConfig);
15
+ /**
16
+ * @description Create a new liquidation vault
17
+ * @param {string} liquidationAdminCap The liquidation admin cap object ID
18
+ * @returns A function that takes a Transaction object
19
+ */
20
+ createLiquidationVault: (liquidationAdminCap: string) => (tx: Transaction) => void;
21
+ /**
22
+ * @description Deposit coins into a liquidation vault
23
+ * @param {string} vaultId The liquidation vault object ID
24
+ * @param {string} liquidationAdminCap The liquidation admin cap object ID
25
+ * @param {string} coinKey The key to identify the coin type
26
+ * @param {number} amount The amount to deposit
27
+ * @returns A function that takes a Transaction object
28
+ */
29
+ deposit: (vaultId: string, liquidationAdminCap: string, coinKey: string, amount: number) => (tx: Transaction) => void;
30
+ /**
31
+ * @description Withdraw coins from a liquidation vault
32
+ * @param {string} vaultId The liquidation vault object ID
33
+ * @param {string} liquidationAdminCap The liquidation admin cap object ID
34
+ * @param {string} coinKey The key to identify the coin type
35
+ * @param {number} amount The amount to withdraw
36
+ * @returns A function that takes a Transaction object and returns the withdrawn coin
37
+ */
38
+ withdraw: (vaultId: string, liquidationAdminCap: string, coinKey: string, amount: number) => (tx: Transaction) => _haneullabs_haneul_transactions113.TransactionResult;
39
+ /**
40
+ * @description Liquidate a margin manager by repaying base debt
41
+ * @param {string} vaultId The liquidation vault object ID
42
+ * @param {string} managerAddress The margin manager address to liquidate
43
+ * @param {string} poolKey The key to identify the pool
44
+ * @param {number} [repayAmount] The amount to repay (in base asset units), or undefined for full liquidation
45
+ * @returns A function that takes a Transaction object
46
+ */
47
+ liquidateBase: (vaultId: string, managerAddress: string, poolKey: string, repayAmount?: number) => (tx: Transaction) => void;
48
+ /**
49
+ * @description Liquidate a margin manager by repaying quote debt
50
+ * @param {string} vaultId The liquidation vault object ID
51
+ * @param {string} managerAddress The margin manager address to liquidate
52
+ * @param {string} poolKey The key to identify the pool
53
+ * @param {number} [repayAmount] The amount to repay (in quote asset units), or undefined for full liquidation
54
+ * @returns A function that takes a Transaction object
55
+ */
56
+ liquidateQuote: (vaultId: string, managerAddress: string, poolKey: string, repayAmount?: number) => (tx: Transaction) => void;
57
+ /**
58
+ * @description Get the balance of a specific coin type in the liquidation vault
59
+ * @param {string} vaultId The liquidation vault object ID
60
+ * @param {string} coinKey The key to identify the coin type
61
+ * @returns A function that takes a Transaction object
62
+ */
63
+ balance: (vaultId: string, coinKey: string) => (tx: Transaction) => _haneullabs_haneul_transactions113.TransactionResult;
64
+ }
65
+ //#endregion
66
+ export { MarginLiquidationsContract };
67
+ //# sourceMappingURL=marginLiquidations.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marginLiquidations.d.mts","names":[],"sources":["../../src/transactions/marginLiquidations.ts"],"mappings":";;;;;;;;cAWa,0BAAA;EAAA;;;;cAMA,MAAA,EAAQ,cAAA;EAiDd;;;;;EAxCN,sBAAA,GAA0B,mBAAA,cAAiC,EAAA,EAAI,WAAA;EA6IC;;;;;;;;EA9HhE,OAAA,GACE,OAAA,UAAiB,mBAAA,UAA6B,OAAA,UAAiB,MAAA,cAC/D,EAAA,EAAI,WAAA;EAjBqD;;;;;;;;EAsC3D,QAAA,GACE,OAAA,UAAiB,mBAAA,UAA6B,OAAA,UAAiB,MAAA,cAC/D,EAAA,EAAI,WAAA,KAAW,kCAAA,CAAA,iBAAA;EADf;;;;;;;;EAsBF,aAAA,GACE,OAAA,UAAiB,cAAA,UAAwB,OAAA,UAAiB,WAAA,eAC1D,EAAA,EAAI,WAAA;EADa;;;;;;;;EAuCnB,cAAA,GACE,OAAA,UAAiB,cAAA,UAAwB,OAAA,UAAiB,WAAA,eAC1D,EAAA,EAAI,WAAA;EADsD;;;;;;EAuC5D,OAAA,GAAW,OAAA,UAAiB,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,kCAAA,CAAA,iBAAA;AAAA"}
@@ -0,0 +1,110 @@
1
+ import { convertQuantity } from "../utils/conversion.mjs";
2
+ import { coinWithBalance } from "@haneullabs/haneul/transactions";
3
+
4
+ //#region src/transactions/marginLiquidations.ts
5
+ /**
6
+ * MarginLiquidationsContract class for managing LiquidationVault operations.
7
+ */
8
+ var MarginLiquidationsContract = class {
9
+ #config;
10
+ /**
11
+ * @param {DeepBookConfig} config Configuration for MarginLiquidationsContract
12
+ */
13
+ constructor(config) {
14
+ this.createLiquidationVault = (liquidationAdminCap) => (tx) => {
15
+ tx.moveCall({
16
+ target: `${this.#config.LIQUIDATION_PACKAGE_ID}::liquidation_vault::create_liquidation_vault`,
17
+ arguments: [tx.object(liquidationAdminCap)]
18
+ });
19
+ };
20
+ this.deposit = (vaultId, liquidationAdminCap, coinKey, amount) => (tx) => {
21
+ const coin = this.#config.getCoin(coinKey);
22
+ const depositCoin = coinWithBalance({
23
+ type: coin.type,
24
+ balance: convertQuantity(amount, coin.scalar)
25
+ });
26
+ tx.moveCall({
27
+ target: `${this.#config.LIQUIDATION_PACKAGE_ID}::liquidation_vault::deposit`,
28
+ arguments: [
29
+ tx.object(vaultId),
30
+ tx.object(liquidationAdminCap),
31
+ depositCoin
32
+ ],
33
+ typeArguments: [coin.type]
34
+ });
35
+ };
36
+ this.withdraw = (vaultId, liquidationAdminCap, coinKey, amount) => (tx) => {
37
+ const coin = this.#config.getCoin(coinKey);
38
+ return tx.moveCall({
39
+ target: `${this.#config.LIQUIDATION_PACKAGE_ID}::liquidation_vault::withdraw`,
40
+ arguments: [
41
+ tx.object(vaultId),
42
+ tx.object(liquidationAdminCap),
43
+ tx.pure.u64(convertQuantity(amount, coin.scalar))
44
+ ],
45
+ typeArguments: [coin.type]
46
+ });
47
+ };
48
+ this.liquidateBase = (vaultId, managerAddress, poolKey, repayAmount) => (tx) => {
49
+ const pool = this.#config.getPool(poolKey);
50
+ const baseCoin = this.#config.getCoin(pool.baseCoin);
51
+ const quoteCoin = this.#config.getCoin(pool.quoteCoin);
52
+ const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
53
+ const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
54
+ const repayAmountArg = repayAmount !== void 0 ? tx.pure.option("u64", convertQuantity(repayAmount, baseCoin.scalar)) : tx.pure.option("u64", null);
55
+ tx.moveCall({
56
+ target: `${this.#config.LIQUIDATION_PACKAGE_ID}::liquidation_vault::liquidate_base`,
57
+ arguments: [
58
+ tx.object(vaultId),
59
+ tx.object(managerAddress),
60
+ tx.object(this.#config.MARGIN_REGISTRY_ID),
61
+ tx.object(baseCoin.priceInfoObjectId),
62
+ tx.object(quoteCoin.priceInfoObjectId),
63
+ tx.object(baseMarginPool.address),
64
+ tx.object(quoteMarginPool.address),
65
+ tx.object(pool.address),
66
+ repayAmountArg,
67
+ tx.object.clock()
68
+ ],
69
+ typeArguments: [baseCoin.type, quoteCoin.type]
70
+ });
71
+ };
72
+ this.liquidateQuote = (vaultId, managerAddress, poolKey, repayAmount) => (tx) => {
73
+ const pool = this.#config.getPool(poolKey);
74
+ const baseCoin = this.#config.getCoin(pool.baseCoin);
75
+ const quoteCoin = this.#config.getCoin(pool.quoteCoin);
76
+ const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
77
+ const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
78
+ const repayAmountArg = repayAmount !== void 0 ? tx.pure.option("u64", convertQuantity(repayAmount, quoteCoin.scalar)) : tx.pure.option("u64", null);
79
+ tx.moveCall({
80
+ target: `${this.#config.LIQUIDATION_PACKAGE_ID}::liquidation_vault::liquidate_quote`,
81
+ arguments: [
82
+ tx.object(vaultId),
83
+ tx.object(managerAddress),
84
+ tx.object(this.#config.MARGIN_REGISTRY_ID),
85
+ tx.object(baseCoin.priceInfoObjectId),
86
+ tx.object(quoteCoin.priceInfoObjectId),
87
+ tx.object(baseMarginPool.address),
88
+ tx.object(quoteMarginPool.address),
89
+ tx.object(pool.address),
90
+ repayAmountArg,
91
+ tx.object.clock()
92
+ ],
93
+ typeArguments: [baseCoin.type, quoteCoin.type]
94
+ });
95
+ };
96
+ this.balance = (vaultId, coinKey) => (tx) => {
97
+ const coin = this.#config.getCoin(coinKey);
98
+ return tx.moveCall({
99
+ target: `${this.#config.LIQUIDATION_PACKAGE_ID}::liquidation_vault::balance`,
100
+ arguments: [tx.object(vaultId)],
101
+ typeArguments: [coin.type]
102
+ });
103
+ };
104
+ this.#config = config;
105
+ }
106
+ };
107
+
108
+ //#endregion
109
+ export { MarginLiquidationsContract };
110
+ //# sourceMappingURL=marginLiquidations.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marginLiquidations.mjs","names":["#config"],"sources":["../../src/transactions/marginLiquidations.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { Transaction } from '@haneullabs/haneul/transactions';\nimport { coinWithBalance } from '@haneullabs/haneul/transactions';\n\nimport type { DeepBookConfig } from '../utils/config.js';\nimport { convertQuantity } from '../utils/conversion.js';\n\n/**\n * MarginLiquidationsContract class for managing LiquidationVault operations.\n */\nexport class MarginLiquidationsContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for MarginLiquidationsContract\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * @description Create a new liquidation vault\n\t * @param {string} liquidationAdminCap The liquidation admin cap object ID\n\t * @returns A function that takes a Transaction object\n\t */\n\tcreateLiquidationVault = (liquidationAdminCap: string) => (tx: Transaction) => {\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.LIQUIDATION_PACKAGE_ID}::liquidation_vault::create_liquidation_vault`,\n\t\t\targuments: [tx.object(liquidationAdminCap)],\n\t\t});\n\t};\n\n\t/**\n\t * @description Deposit coins into a liquidation vault\n\t * @param {string} vaultId The liquidation vault object ID\n\t * @param {string} liquidationAdminCap The liquidation admin cap object ID\n\t * @param {string} coinKey The key to identify the coin type\n\t * @param {number} amount The amount to deposit\n\t * @returns A function that takes a Transaction object\n\t */\n\tdeposit =\n\t\t(vaultId: string, liquidationAdminCap: string, coinKey: string, amount: number) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tconst depositCoin = coinWithBalance({\n\t\t\t\ttype: coin.type,\n\t\t\t\tbalance: convertQuantity(amount, coin.scalar),\n\t\t\t});\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.LIQUIDATION_PACKAGE_ID}::liquidation_vault::deposit`,\n\t\t\t\targuments: [tx.object(vaultId), tx.object(liquidationAdminCap), depositCoin],\n\t\t\t\ttypeArguments: [coin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Withdraw coins from a liquidation vault\n\t * @param {string} vaultId The liquidation vault object ID\n\t * @param {string} liquidationAdminCap The liquidation admin cap object ID\n\t * @param {string} coinKey The key to identify the coin type\n\t * @param {number} amount The amount to withdraw\n\t * @returns A function that takes a Transaction object and returns the withdrawn coin\n\t */\n\twithdraw =\n\t\t(vaultId: string, liquidationAdminCap: string, coinKey: string, amount: number) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\treturn tx.moveCall({\n\t\t\t\ttarget: `${this.#config.LIQUIDATION_PACKAGE_ID}::liquidation_vault::withdraw`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(vaultId),\n\t\t\t\t\ttx.object(liquidationAdminCap),\n\t\t\t\t\ttx.pure.u64(convertQuantity(amount, coin.scalar)),\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 Liquidate a margin manager by repaying base debt\n\t * @param {string} vaultId The liquidation vault object ID\n\t * @param {string} managerAddress The margin manager address to liquidate\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} [repayAmount] The amount to repay (in base asset units), or undefined for full liquidation\n\t * @returns A function that takes a Transaction object\n\t */\n\tliquidateBase =\n\t\t(vaultId: string, managerAddress: string, poolKey: string, repayAmount?: number) =>\n\t\t(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\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\n\t\t\tconst repayAmountArg =\n\t\t\t\trepayAmount !== undefined\n\t\t\t\t\t? tx.pure.option('u64', convertQuantity(repayAmount, baseCoin.scalar))\n\t\t\t\t\t: tx.pure.option('u64', null);\n\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.LIQUIDATION_PACKAGE_ID}::liquidation_vault::liquidate_base`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(vaultId),\n\t\t\t\t\ttx.object(managerAddress),\n\t\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\t\ttx.object(baseMarginPool.address),\n\t\t\t\t\ttx.object(quoteMarginPool.address),\n\t\t\t\t\ttx.object(pool.address),\n\t\t\t\t\trepayAmountArg,\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 Liquidate a margin manager by repaying quote debt\n\t * @param {string} vaultId The liquidation vault object ID\n\t * @param {string} managerAddress The margin manager address to liquidate\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} [repayAmount] The amount to repay (in quote asset units), or undefined for full liquidation\n\t * @returns A function that takes a Transaction object\n\t */\n\tliquidateQuote =\n\t\t(vaultId: string, managerAddress: string, poolKey: string, repayAmount?: number) =>\n\t\t(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\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\n\t\t\tconst repayAmountArg =\n\t\t\t\trepayAmount !== undefined\n\t\t\t\t\t? tx.pure.option('u64', convertQuantity(repayAmount, quoteCoin.scalar))\n\t\t\t\t\t: tx.pure.option('u64', null);\n\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.LIQUIDATION_PACKAGE_ID}::liquidation_vault::liquidate_quote`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(vaultId),\n\t\t\t\t\ttx.object(managerAddress),\n\t\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\t\ttx.object(baseMarginPool.address),\n\t\t\t\t\ttx.object(quoteMarginPool.address),\n\t\t\t\t\ttx.object(pool.address),\n\t\t\t\t\trepayAmountArg,\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// === Read-Only Functions ===\n\n\t/**\n\t * @description Get the balance of a specific coin type in the liquidation vault\n\t * @param {string} vaultId The liquidation vault object ID\n\t * @param {string} coinKey The key to identify the coin type\n\t * @returns A function that takes a Transaction object\n\t */\n\tbalance = (vaultId: string, coinKey: string) => (tx: Transaction) => {\n\t\tconst coin = this.#config.getCoin(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.LIQUIDATION_PACKAGE_ID}::liquidation_vault::balance`,\n\t\t\targuments: [tx.object(vaultId)],\n\t\t\ttypeArguments: [coin.type],\n\t\t});\n\t};\n}\n"],"mappings":";;;;;;;AAWA,IAAa,6BAAb,MAAwC;CACvC;;;;CAKA,YAAY,QAAwB;iCASV,yBAAiC,OAAoB;AAC9E,MAAG,SAAS;IACX,QAAQ,GAAG,MAAKA,OAAQ,uBAAuB;IAC/C,WAAW,CAAC,GAAG,OAAO,oBAAoB,CAAC;IAC3C,CAAC;;kBAYD,SAAiB,qBAA6B,SAAiB,YAC/D,OAAoB;GACpB,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;GAC1C,MAAM,cAAc,gBAAgB;IACnC,MAAM,KAAK;IACX,SAAS,gBAAgB,QAAQ,KAAK,OAAO;IAC7C,CAAC;AACF,MAAG,SAAS;IACX,QAAQ,GAAG,MAAKA,OAAQ,uBAAuB;IAC/C,WAAW;KAAC,GAAG,OAAO,QAAQ;KAAE,GAAG,OAAO,oBAAoB;KAAE;KAAY;IAC5E,eAAe,CAAC,KAAK,KAAK;IAC1B,CAAC;;mBAYF,SAAiB,qBAA6B,SAAiB,YAC/D,OAAoB;GACpB,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;AAC1C,UAAO,GAAG,SAAS;IAClB,QAAQ,GAAG,MAAKA,OAAQ,uBAAuB;IAC/C,WAAW;KACV,GAAG,OAAO,QAAQ;KAClB,GAAG,OAAO,oBAAoB;KAC9B,GAAG,KAAK,IAAI,gBAAgB,QAAQ,KAAK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B,SACb,GAAG,KAAK,OAAO,OAAO,gBAAgB,aAAa,UAAU,OAAO,CAAC,GACrE,GAAG,KAAK,OAAO,OAAO,KAAK;AAE/B,MAAG,SAAS;IACX,QAAQ,GAAG,MAAKA,OAAQ,uBAAuB;IAC/C,WAAW;KACV,GAAG,OAAO,QAAQ;KAClB,GAAG,OAAO,eAAe;KACzB,GAAG,OAAO,MAAKA,OAAQ,mBAAmB;KAC1C,GAAG,OAAO,SAAS,kBAAmB;KACtC,GAAG,OAAO,UAAU,kBAAmB;KACvC,GAAG,OAAO,eAAe,QAAQ;KACjC,GAAG,OAAO,gBAAgB,QAAQ;KAClC,GAAG,OAAO,KAAK,QAAQ;KACvB;KACA,GAAG,OAAO,OAAO;KACjB;IACD,eAAe,CAAC,SAAS,MAAM,UAAU,KAAK;IAC9C,CAAC;;kBAWO,SAAiB,aAAqB,OAAoB;GACpE,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;AAC1C,UAAO,GAAG,SAAS;IAClB,QAAQ,GAAG,MAAKA,OAAQ,uBAAuB;IAC/C,WAAW,CAAC,GAAG,OAAO,QAAQ,CAAC;IAC/B,eAAe,CAAC,KAAK,KAAK;IAC1B,CAAC;;AA3JF,QAAKA,SAAU"}
@@ -0,0 +1,86 @@
1
+ import { InterestConfigParams, MarginPoolConfigParams } from "../types/index.mjs";
2
+ import { DeepBookConfig } from "../utils/config.mjs";
3
+ import * as _haneullabs_haneul_transactions65 from "@haneullabs/haneul/transactions";
4
+ import { Transaction, TransactionArgument, TransactionObjectArgument } from "@haneullabs/haneul/transactions";
5
+
6
+ //#region src/transactions/marginMaintainer.d.ts
7
+ /**
8
+ * DeepBookMaintainerContract class for managing maintainer actions.
9
+ */
10
+ declare class MarginMaintainerContract {
11
+ #private;
12
+ /**
13
+ * @param {DeepBookConfig} config Configuration for MarginMaintainerContract
14
+ */
15
+ constructor(config: DeepBookConfig);
16
+ /**
17
+ * @description Create a new margin pool
18
+ * @param {string} coinKey The key to identify the coin
19
+ * @param {TransactionArgument} poolConfig The configuration for the pool
20
+ * @returns A function that takes a Transaction object
21
+ */
22
+ createMarginPool: (coinKey: string, poolConfig: TransactionArgument) => (tx: Transaction) => void;
23
+ /**
24
+ * @description Create a new protocol config
25
+ * @param {string} coinKey The key to identify the coin
26
+ * @param {MarginPoolConfigParams} marginPoolConfig The configuration for the margin pool (with optional rate limit)
27
+ * @param {InterestConfigParams} interestConfig The configuration for the interest
28
+ * @returns A function that takes a Transaction object
29
+ */
30
+ newProtocolConfig: (coinKey: string, marginPoolConfig: MarginPoolConfigParams, interestConfig: InterestConfigParams) => (tx: Transaction) => _haneullabs_haneul_transactions65.TransactionResult;
31
+ /**
32
+ * @description Create a new margin pool config
33
+ * @param {string} coinKey The key to identify the coin
34
+ * @param {MarginPoolConfigParams} marginPoolConfig The configuration for the margin pool
35
+ * @returns A function that takes a Transaction object
36
+ */
37
+ newMarginPoolConfig: (coinKey: string, marginPoolConfig: MarginPoolConfigParams) => (tx: Transaction) => _haneullabs_haneul_transactions65.TransactionResult;
38
+ /**
39
+ * @description Create a new margin pool config with rate limit
40
+ * @param {string} coinKey The key to identify the coin
41
+ * @param {MarginPoolConfigParams} marginPoolConfig The configuration for the margin pool with rate limit
42
+ * @returns A function that takes a Transaction object
43
+ */
44
+ newMarginPoolConfigWithRateLimit: (coinKey: string, marginPoolConfig: Required<Pick<MarginPoolConfigParams, "rateLimitCapacity" | "rateLimitRefillRatePerMs" | "rateLimitEnabled">> & MarginPoolConfigParams) => (tx: Transaction) => _haneullabs_haneul_transactions65.TransactionResult;
45
+ /**
46
+ * @description Create a new interest config
47
+ * @param {InterestConfigParams} interestConfig The configuration for the interest
48
+ * @returns A function that takes a Transaction object
49
+ */
50
+ newInterestConfig: (interestConfig: InterestConfigParams) => (tx: Transaction) => _haneullabs_haneul_transactions65.TransactionResult;
51
+ /**
52
+ * @description Enable a deepbook pool for loan
53
+ * @param {string} deepbookPoolKey The key to identify the deepbook pool
54
+ * @param {string} coinKey The key to identify the margin pool
55
+ * @param {TransactionObjectArgument} marginPoolCap The margin pool cap
56
+ * @returns A function that takes a Transaction object
57
+ */
58
+ enableDeepbookPoolForLoan: (deepbookPoolKey: string, coinKey: string, marginPoolCap: TransactionObjectArgument) => (tx: Transaction) => void;
59
+ /**
60
+ * @description Disable a deepbook pool for loan
61
+ * @param {string} deepbookPoolKey The key to identify the deepbook pool
62
+ * @param {string} coinKey The key to identify the margin pool
63
+ * @param {TransactionObjectArgument} marginPoolCap The margin pool cap
64
+ * @returns A function that takes a Transaction object
65
+ */
66
+ disableDeepbookPoolForLoan: (deepbookPoolKey: string, coinKey: string, marginPoolCap: TransactionObjectArgument) => (tx: Transaction) => void;
67
+ /**
68
+ * @description Update the interest params
69
+ * @param {string} coinKey The key to identify the margin pool
70
+ * @param {TransactionObjectArgument} marginPoolCap The margin pool cap
71
+ * @param {InterestConfigParams} interestConfig The configuration for the interest
72
+ * @returns A function that takes a Transaction object
73
+ */
74
+ updateInterestParams: (coinKey: string, marginPoolCap: TransactionObjectArgument, interestConfig: InterestConfigParams) => (tx: Transaction) => void;
75
+ /**
76
+ * @description Update the margin pool config
77
+ * @param {string} coinKey The key to identify the margin pool
78
+ * @param {TransactionObjectArgument} marginPoolCap The margin pool cap
79
+ * @param {MarginPoolConfigParams} marginPoolConfig The configuration for the margin pool (with optional rate limit)
80
+ * @returns A function that takes a Transaction object
81
+ */
82
+ updateMarginPoolConfig: (coinKey: string, marginPoolCap: TransactionObjectArgument, marginPoolConfig: MarginPoolConfigParams) => (tx: Transaction) => void;
83
+ }
84
+ //#endregion
85
+ export { MarginMaintainerContract };
86
+ //# sourceMappingURL=marginMaintainer.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marginMaintainer.d.mts","names":[],"sources":["../../src/transactions/marginMaintainer.ts"],"mappings":";;;;;;;;;cAiBa,wBAAA;EAAA;;;;cAMA,MAAA,EAAQ,cAAA;EA8CA;;;;;;EAxBpB,gBAAA,GAAoB,OAAA,UAAiB,UAAA,EAAY,mBAAA,MAAyB,EAAA,EAAI,WAAA;EA+E1E;;;;;;;EA1DJ,iBAAA,GAEE,OAAA,UACA,gBAAA,EAAkB,sBAAA,EAClB,cAAA,EAAgB,oBAAA,MAEhB,EAAA,EAAI,WAAA,KAAW,iCAAA,CAAA,iBAAA;EAwF6D;;;;;;EA9D9E,mBAAA,GACE,OAAA,UAAiB,gBAAA,EAAkB,sBAAA,MAA4B,EAAA,EAAI,WAAA,KAAW,iCAAA,CAAA,iBAAA;EAyI1E;;;;;;EArHN,gCAAA,GAEE,OAAA,UACA,gBAAA,EAAkB,QAAA,CACjB,IAAA,CACC,sBAAA,4EAID,sBAAA,MAED,EAAA,EAAI,WAAA,KAAW,iCAAA,CAAA,iBAAA;;;;;;EA8BjB,iBAAA,GAAqB,cAAA,EAAgB,oBAAA,MAA0B,EAAA,EAAI,WAAA,KAAW,iCAAA,CAAA,iBAAA;EAnHzC;;;;;;;EAuIrC,yBAAA,GACE,eAAA,UAAyB,OAAA,UAAiB,aAAA,EAAe,yBAAA,MACzD,EAAA,EAAI,WAAA;EAhHJ;;;;;;;EAuIF,0BAAA,GACE,eAAA,UAAyB,OAAA,UAAiB,aAAA,EAAe,yBAAA,MACzD,EAAA,EAAI,WAAA;EA5G+D;;;;;;;EAmIrE,oBAAA,GAEE,OAAA,UACA,aAAA,EAAe,yBAAA,EACf,cAAA,EAAgB,oBAAA,MAEhB,EAAA,EAAI,WAAA;EA5GH;;;;;;;EAmIH,sBAAA,GAEE,OAAA,UACA,aAAA,EAAe,yBAAA,EACf,gBAAA,EAAkB,sBAAA,MAElB,EAAA,EAAI,WAAA;AAAA"}
@@ -0,0 +1,161 @@
1
+ import { convertQuantity, convertRate } from "../utils/conversion.mjs";
2
+ import { FLOAT_SCALAR } from "../utils/config.mjs";
3
+
4
+ //#region src/transactions/marginMaintainer.ts
5
+ /**
6
+ * DeepBookMaintainerContract class for managing maintainer actions.
7
+ */
8
+ var MarginMaintainerContract = class {
9
+ #config;
10
+ /**
11
+ * @param {DeepBookConfig} config Configuration for MarginMaintainerContract
12
+ */
13
+ constructor(config) {
14
+ this.createMarginPool = (coinKey, poolConfig) => (tx) => {
15
+ const coin = this.#config.getCoin(coinKey);
16
+ tx.moveCall({
17
+ target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::create_margin_pool`,
18
+ arguments: [
19
+ tx.object(this.#config.MARGIN_REGISTRY_ID),
20
+ poolConfig,
21
+ tx.object(this.#marginMaintainerCap()),
22
+ tx.object.clock()
23
+ ],
24
+ typeArguments: [coin.type]
25
+ });
26
+ };
27
+ this.newProtocolConfig = (coinKey, marginPoolConfig, interestConfig) => (tx) => {
28
+ const marginPoolConfigObject = marginPoolConfig.rateLimitCapacity !== void 0 && marginPoolConfig.rateLimitRefillRatePerMs !== void 0 && marginPoolConfig.rateLimitEnabled !== void 0 ? this.newMarginPoolConfigWithRateLimit(coinKey, {
29
+ ...marginPoolConfig,
30
+ rateLimitCapacity: marginPoolConfig.rateLimitCapacity,
31
+ rateLimitRefillRatePerMs: marginPoolConfig.rateLimitRefillRatePerMs,
32
+ rateLimitEnabled: marginPoolConfig.rateLimitEnabled
33
+ })(tx) : this.newMarginPoolConfig(coinKey, marginPoolConfig)(tx);
34
+ const interestConfigObject = this.newInterestConfig(interestConfig)(tx);
35
+ return tx.moveCall({
36
+ target: `${this.#config.MARGIN_PACKAGE_ID}::protocol_config::new_protocol_config`,
37
+ arguments: [marginPoolConfigObject, interestConfigObject]
38
+ });
39
+ };
40
+ this.newMarginPoolConfig = (coinKey, marginPoolConfig) => (tx) => {
41
+ const coin = this.#config.getCoin(coinKey);
42
+ const { supplyCap, maxUtilizationRate, referralSpread, minBorrow } = marginPoolConfig;
43
+ return tx.moveCall({
44
+ target: `${this.#config.MARGIN_PACKAGE_ID}::protocol_config::new_margin_pool_config`,
45
+ arguments: [
46
+ tx.pure.u64(convertQuantity(supplyCap, coin.scalar)),
47
+ tx.pure.u64(convertRate(maxUtilizationRate, FLOAT_SCALAR)),
48
+ tx.pure.u64(convertRate(referralSpread, FLOAT_SCALAR)),
49
+ tx.pure.u64(convertQuantity(minBorrow, coin.scalar))
50
+ ]
51
+ });
52
+ };
53
+ this.newMarginPoolConfigWithRateLimit = (coinKey, marginPoolConfig) => (tx) => {
54
+ const coin = this.#config.getCoin(coinKey);
55
+ const { supplyCap, maxUtilizationRate, referralSpread, minBorrow, rateLimitCapacity, rateLimitRefillRatePerMs, rateLimitEnabled } = marginPoolConfig;
56
+ return tx.moveCall({
57
+ target: `${this.#config.MARGIN_PACKAGE_ID}::protocol_config::new_margin_pool_config_with_rate_limit`,
58
+ arguments: [
59
+ tx.pure.u64(convertQuantity(supplyCap, coin.scalar)),
60
+ tx.pure.u64(convertRate(maxUtilizationRate, FLOAT_SCALAR)),
61
+ tx.pure.u64(convertRate(referralSpread, FLOAT_SCALAR)),
62
+ tx.pure.u64(convertQuantity(minBorrow, coin.scalar)),
63
+ tx.pure.u64(convertQuantity(rateLimitCapacity, coin.scalar)),
64
+ tx.pure.u64(convertQuantity(rateLimitRefillRatePerMs, coin.scalar)),
65
+ tx.pure.bool(rateLimitEnabled)
66
+ ]
67
+ });
68
+ };
69
+ this.newInterestConfig = (interestConfig) => (tx) => {
70
+ const { baseRate, baseSlope, optimalUtilization, excessSlope } = interestConfig;
71
+ return tx.moveCall({
72
+ target: `${this.#config.MARGIN_PACKAGE_ID}::protocol_config::new_interest_config`,
73
+ arguments: [
74
+ tx.pure.u64(convertRate(baseRate, FLOAT_SCALAR)),
75
+ tx.pure.u64(convertRate(baseSlope, FLOAT_SCALAR)),
76
+ tx.pure.u64(convertRate(optimalUtilization, FLOAT_SCALAR)),
77
+ tx.pure.u64(convertRate(excessSlope, FLOAT_SCALAR))
78
+ ]
79
+ });
80
+ };
81
+ this.enableDeepbookPoolForLoan = (deepbookPoolKey, coinKey, marginPoolCap) => (tx) => {
82
+ const deepbookPool = this.#config.getPool(deepbookPoolKey);
83
+ const marginPool = this.#config.getMarginPool(coinKey);
84
+ tx.moveCall({
85
+ target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::enable_deepbook_pool_for_loan`,
86
+ arguments: [
87
+ tx.object(marginPool.address),
88
+ tx.object(this.#config.MARGIN_REGISTRY_ID),
89
+ tx.pure.id(deepbookPool.address),
90
+ tx.object(marginPoolCap),
91
+ tx.object.clock()
92
+ ],
93
+ typeArguments: [marginPool.type]
94
+ });
95
+ };
96
+ this.disableDeepbookPoolForLoan = (deepbookPoolKey, coinKey, marginPoolCap) => (tx) => {
97
+ const deepbookPool = this.#config.getPool(deepbookPoolKey);
98
+ const marginPool = this.#config.getMarginPool(coinKey);
99
+ tx.moveCall({
100
+ target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::disable_deepbook_pool_for_loan`,
101
+ arguments: [
102
+ tx.object(marginPool.address),
103
+ tx.object(this.#config.MARGIN_REGISTRY_ID),
104
+ tx.pure.id(deepbookPool.address),
105
+ tx.object(marginPoolCap),
106
+ tx.object.clock()
107
+ ],
108
+ typeArguments: [marginPool.type]
109
+ });
110
+ };
111
+ this.updateInterestParams = (coinKey, marginPoolCap, interestConfig) => (tx) => {
112
+ const marginPool = this.#config.getMarginPool(coinKey);
113
+ const interestConfigObject = this.newInterestConfig(interestConfig)(tx);
114
+ tx.moveCall({
115
+ target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::update_interest_params`,
116
+ arguments: [
117
+ tx.object(marginPool.address),
118
+ tx.object(this.#config.MARGIN_REGISTRY_ID),
119
+ interestConfigObject,
120
+ tx.object(marginPoolCap),
121
+ tx.object.clock()
122
+ ],
123
+ typeArguments: [marginPool.type]
124
+ });
125
+ };
126
+ this.updateMarginPoolConfig = (coinKey, marginPoolCap, marginPoolConfig) => (tx) => {
127
+ const marginPool = this.#config.getMarginPool(coinKey);
128
+ const marginPoolConfigObject = marginPoolConfig.rateLimitCapacity !== void 0 && marginPoolConfig.rateLimitRefillRatePerMs !== void 0 && marginPoolConfig.rateLimitEnabled !== void 0 ? this.newMarginPoolConfigWithRateLimit(coinKey, {
129
+ ...marginPoolConfig,
130
+ rateLimitCapacity: marginPoolConfig.rateLimitCapacity,
131
+ rateLimitRefillRatePerMs: marginPoolConfig.rateLimitRefillRatePerMs,
132
+ rateLimitEnabled: marginPoolConfig.rateLimitEnabled
133
+ })(tx) : this.newMarginPoolConfig(coinKey, marginPoolConfig)(tx);
134
+ tx.moveCall({
135
+ target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::update_margin_pool_config`,
136
+ arguments: [
137
+ tx.object(marginPool.address),
138
+ tx.object(this.#config.MARGIN_REGISTRY_ID),
139
+ marginPoolConfigObject,
140
+ tx.object(marginPoolCap),
141
+ tx.object.clock()
142
+ ],
143
+ typeArguments: [marginPool.type]
144
+ });
145
+ };
146
+ this.#config = config;
147
+ }
148
+ /**
149
+ * @returns The admin capability required for admin operations
150
+ * @throws Error if the admin capability is not set
151
+ */
152
+ #marginMaintainerCap() {
153
+ const marginMaintainerCap = this.#config.marginMaintainerCap;
154
+ if (!marginMaintainerCap) throw new Error("MARGIN_ADMIN_CAP environment variable not set");
155
+ return marginMaintainerCap;
156
+ }
157
+ };
158
+
159
+ //#endregion
160
+ export { MarginMaintainerContract };
161
+ //# sourceMappingURL=marginMaintainer.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marginMaintainer.mjs","names":["#config","#marginMaintainerCap"],"sources":["../../src/transactions/marginMaintainer.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type {\n\tTransaction,\n\tTransactionArgument,\n\tTransactionObjectArgument,\n} from '@haneullabs/haneul/transactions';\n\nimport type { DeepBookConfig } from '../utils/config.js';\nimport type { MarginPoolConfigParams, InterestConfigParams } from '../types/index.js';\nimport { FLOAT_SCALAR } from '../utils/config.js';\nimport { convertQuantity, convertRate } from '../utils/conversion.js';\n\n/**\n * DeepBookMaintainerContract class for managing maintainer actions.\n */\nexport class MarginMaintainerContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for MarginMaintainerContract\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#marginMaintainerCap() {\n\t\tconst marginMaintainerCap = this.#config.marginMaintainerCap;\n\t\tif (!marginMaintainerCap) {\n\t\t\tthrow new Error('MARGIN_ADMIN_CAP environment variable not set');\n\t\t}\n\t\treturn marginMaintainerCap;\n\t}\n\n\t/**\n\t * @description Create a new margin pool\n\t * @param {string} coinKey The key to identify the coin\n\t * @param {TransactionArgument} poolConfig The configuration for the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tcreateMarginPool = (coinKey: string, poolConfig: TransactionArgument) => (tx: Transaction) => {\n\t\tconst coin = this.#config.getCoin(coinKey);\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::create_margin_pool`,\n\t\t\targuments: [\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\tpoolConfig,\n\t\t\t\ttx.object(this.#marginMaintainerCap()),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [coin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Create a new protocol config\n\t * @param {string} coinKey The key to identify the coin\n\t * @param {MarginPoolConfigParams} marginPoolConfig The configuration for the margin pool (with optional rate limit)\n\t * @param {InterestConfigParams} interestConfig The configuration for the interest\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewProtocolConfig =\n\t\t(\n\t\t\tcoinKey: string,\n\t\t\tmarginPoolConfig: MarginPoolConfigParams,\n\t\t\tinterestConfig: InterestConfigParams,\n\t\t) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst hasRateLimit =\n\t\t\t\tmarginPoolConfig.rateLimitCapacity !== undefined &&\n\t\t\t\tmarginPoolConfig.rateLimitRefillRatePerMs !== undefined &&\n\t\t\t\tmarginPoolConfig.rateLimitEnabled !== undefined;\n\t\t\tconst marginPoolConfigObject = hasRateLimit\n\t\t\t\t? this.newMarginPoolConfigWithRateLimit(coinKey, {\n\t\t\t\t\t\t...marginPoolConfig,\n\t\t\t\t\t\trateLimitCapacity: marginPoolConfig.rateLimitCapacity!,\n\t\t\t\t\t\trateLimitRefillRatePerMs: marginPoolConfig.rateLimitRefillRatePerMs!,\n\t\t\t\t\t\trateLimitEnabled: marginPoolConfig.rateLimitEnabled!,\n\t\t\t\t\t})(tx)\n\t\t\t\t: this.newMarginPoolConfig(coinKey, marginPoolConfig)(tx);\n\t\t\tconst interestConfigObject = this.newInterestConfig(interestConfig)(tx);\n\t\t\treturn tx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::protocol_config::new_protocol_config`,\n\t\t\t\targuments: [marginPoolConfigObject, interestConfigObject],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Create a new margin pool config\n\t * @param {string} coinKey The key to identify the coin\n\t * @param {MarginPoolConfigParams} marginPoolConfig The configuration for the margin pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewMarginPoolConfig =\n\t\t(coinKey: string, marginPoolConfig: MarginPoolConfigParams) => (tx: Transaction) => {\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tconst { supplyCap, maxUtilizationRate, referralSpread, minBorrow } = marginPoolConfig;\n\t\t\treturn tx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::protocol_config::new_margin_pool_config`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.pure.u64(convertQuantity(supplyCap, coin.scalar)),\n\t\t\t\t\ttx.pure.u64(convertRate(maxUtilizationRate, FLOAT_SCALAR)),\n\t\t\t\t\ttx.pure.u64(convertRate(referralSpread, FLOAT_SCALAR)),\n\t\t\t\t\ttx.pure.u64(convertQuantity(minBorrow, coin.scalar)),\n\t\t\t\t],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Create a new margin pool config with rate limit\n\t * @param {string} coinKey The key to identify the coin\n\t * @param {MarginPoolConfigParams} marginPoolConfig The configuration for the margin pool with rate limit\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewMarginPoolConfigWithRateLimit =\n\t\t(\n\t\t\tcoinKey: string,\n\t\t\tmarginPoolConfig: Required<\n\t\t\t\tPick<\n\t\t\t\t\tMarginPoolConfigParams,\n\t\t\t\t\t'rateLimitCapacity' | 'rateLimitRefillRatePerMs' | 'rateLimitEnabled'\n\t\t\t\t>\n\t\t\t> &\n\t\t\t\tMarginPoolConfigParams,\n\t\t) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tconst {\n\t\t\t\tsupplyCap,\n\t\t\t\tmaxUtilizationRate,\n\t\t\t\treferralSpread,\n\t\t\t\tminBorrow,\n\t\t\t\trateLimitCapacity,\n\t\t\t\trateLimitRefillRatePerMs,\n\t\t\t\trateLimitEnabled,\n\t\t\t} = marginPoolConfig;\n\t\t\treturn tx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::protocol_config::new_margin_pool_config_with_rate_limit`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.pure.u64(convertQuantity(supplyCap, coin.scalar)),\n\t\t\t\t\ttx.pure.u64(convertRate(maxUtilizationRate, FLOAT_SCALAR)),\n\t\t\t\t\ttx.pure.u64(convertRate(referralSpread, FLOAT_SCALAR)),\n\t\t\t\t\ttx.pure.u64(convertQuantity(minBorrow, coin.scalar)),\n\t\t\t\t\ttx.pure.u64(convertQuantity(rateLimitCapacity, coin.scalar)),\n\t\t\t\t\ttx.pure.u64(convertQuantity(rateLimitRefillRatePerMs, coin.scalar)),\n\t\t\t\t\ttx.pure.bool(rateLimitEnabled),\n\t\t\t\t],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Create a new interest config\n\t * @param {InterestConfigParams} interestConfig The configuration for the interest\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewInterestConfig = (interestConfig: InterestConfigParams) => (tx: Transaction) => {\n\t\tconst { baseRate, baseSlope, optimalUtilization, excessSlope } = interestConfig;\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::protocol_config::new_interest_config`,\n\t\t\targuments: [\n\t\t\t\ttx.pure.u64(convertRate(baseRate, FLOAT_SCALAR)),\n\t\t\t\ttx.pure.u64(convertRate(baseSlope, FLOAT_SCALAR)),\n\t\t\t\ttx.pure.u64(convertRate(optimalUtilization, FLOAT_SCALAR)),\n\t\t\t\ttx.pure.u64(convertRate(excessSlope, FLOAT_SCALAR)),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @description Enable a deepbook pool for loan\n\t * @param {string} deepbookPoolKey The key to identify the deepbook pool\n\t * @param {string} coinKey The key to identify the margin pool\n\t * @param {TransactionObjectArgument} marginPoolCap The margin pool cap\n\t * @returns A function that takes a Transaction object\n\t */\n\tenableDeepbookPoolForLoan =\n\t\t(deepbookPoolKey: string, coinKey: string, marginPoolCap: TransactionObjectArgument) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst deepbookPool = this.#config.getPool(deepbookPoolKey);\n\t\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::enable_deepbook_pool_for_loan`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(marginPool.address),\n\t\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\t\ttx.pure.id(deepbookPool.address),\n\t\t\t\t\ttx.object(marginPoolCap),\n\t\t\t\t\ttx.object.clock(),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Disable a deepbook pool for loan\n\t * @param {string} deepbookPoolKey The key to identify the deepbook pool\n\t * @param {string} coinKey The key to identify the margin pool\n\t * @param {TransactionObjectArgument} marginPoolCap The margin pool cap\n\t * @returns A function that takes a Transaction object\n\t */\n\tdisableDeepbookPoolForLoan =\n\t\t(deepbookPoolKey: string, coinKey: string, marginPoolCap: TransactionObjectArgument) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst deepbookPool = this.#config.getPool(deepbookPoolKey);\n\t\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::disable_deepbook_pool_for_loan`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(marginPool.address),\n\t\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\t\ttx.pure.id(deepbookPool.address),\n\t\t\t\t\ttx.object(marginPoolCap),\n\t\t\t\t\ttx.object.clock(),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Update the interest params\n\t * @param {string} coinKey The key to identify the margin pool\n\t * @param {TransactionObjectArgument} marginPoolCap The margin pool cap\n\t * @param {InterestConfigParams} interestConfig The configuration for the interest\n\t * @returns A function that takes a Transaction object\n\t */\n\tupdateInterestParams =\n\t\t(\n\t\t\tcoinKey: string,\n\t\t\tmarginPoolCap: TransactionObjectArgument,\n\t\t\tinterestConfig: InterestConfigParams,\n\t\t) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\t\tconst interestConfigObject = this.newInterestConfig(interestConfig)(tx);\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::update_interest_params`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(marginPool.address),\n\t\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\t\tinterestConfigObject,\n\t\t\t\t\ttx.object(marginPoolCap),\n\t\t\t\t\ttx.object.clock(),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Update the margin pool config\n\t * @param {string} coinKey The key to identify the margin pool\n\t * @param {TransactionObjectArgument} marginPoolCap The margin pool cap\n\t * @param {MarginPoolConfigParams} marginPoolConfig The configuration for the margin pool (with optional rate limit)\n\t * @returns A function that takes a Transaction object\n\t */\n\tupdateMarginPoolConfig =\n\t\t(\n\t\t\tcoinKey: string,\n\t\t\tmarginPoolCap: TransactionObjectArgument,\n\t\t\tmarginPoolConfig: MarginPoolConfigParams,\n\t\t) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\t\tconst hasRateLimit =\n\t\t\t\tmarginPoolConfig.rateLimitCapacity !== undefined &&\n\t\t\t\tmarginPoolConfig.rateLimitRefillRatePerMs !== undefined &&\n\t\t\t\tmarginPoolConfig.rateLimitEnabled !== undefined;\n\t\t\tconst marginPoolConfigObject = hasRateLimit\n\t\t\t\t? this.newMarginPoolConfigWithRateLimit(coinKey, {\n\t\t\t\t\t\t...marginPoolConfig,\n\t\t\t\t\t\trateLimitCapacity: marginPoolConfig.rateLimitCapacity!,\n\t\t\t\t\t\trateLimitRefillRatePerMs: marginPoolConfig.rateLimitRefillRatePerMs!,\n\t\t\t\t\t\trateLimitEnabled: marginPoolConfig.rateLimitEnabled!,\n\t\t\t\t\t})(tx)\n\t\t\t\t: this.newMarginPoolConfig(coinKey, marginPoolConfig)(tx);\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::update_margin_pool_config`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(marginPool.address),\n\t\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\t\tmarginPoolConfigObject,\n\t\t\t\t\ttx.object(marginPoolCap),\n\t\t\t\t\ttx.object.clock(),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [mar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