@mysten/deepbook-v3 1.5.8 → 1.6.2

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 (182) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/dist/client.d.mts +5 -0
  3. package/dist/client.d.mts.map +1 -1
  4. package/dist/client.mjs +7 -0
  5. package/dist/client.mjs.map +1 -1
  6. package/dist/contracts/deepbook/account.d.mts +18 -18
  7. package/dist/contracts/deepbook/account.d.mts.map +1 -1
  8. package/dist/contracts/deepbook/balance_manager.mjs +413 -0
  9. package/dist/contracts/deepbook/balance_manager.mjs.map +1 -0
  10. package/dist/contracts/deepbook/big_vector.mjs +43 -0
  11. package/dist/contracts/deepbook/big_vector.mjs.map +1 -0
  12. package/dist/contracts/deepbook/book.mjs +29 -0
  13. package/dist/contracts/deepbook/book.mjs.map +1 -0
  14. package/dist/contracts/deepbook/deep_price.d.mts +3 -3
  15. package/dist/contracts/deepbook/deep_price.d.mts.map +1 -1
  16. package/dist/contracts/deepbook/deep_price.mjs +1 -1
  17. package/dist/contracts/deepbook/deps/std/type_name.mjs +17 -0
  18. package/dist/contracts/deepbook/deps/std/type_name.mjs.map +1 -0
  19. package/dist/contracts/deepbook/deps/sui/bag.mjs +43 -0
  20. package/dist/contracts/deepbook/deps/sui/bag.mjs.map +1 -0
  21. package/dist/contracts/deepbook/deps/sui/balance.mjs +21 -0
  22. package/dist/contracts/deepbook/deps/sui/balance.mjs.map +1 -0
  23. package/dist/contracts/deepbook/deps/sui/table.mjs +38 -0
  24. package/dist/contracts/deepbook/deps/sui/table.mjs.map +1 -0
  25. package/dist/contracts/deepbook/deps/sui/vec_map.mjs +37 -0
  26. package/dist/contracts/deepbook/deps/sui/vec_map.mjs.map +1 -0
  27. package/dist/contracts/deepbook/deps/sui/versioned.mjs +19 -0
  28. package/dist/contracts/deepbook/deps/sui/versioned.mjs.map +1 -0
  29. package/dist/contracts/deepbook/governance.mjs +49 -0
  30. package/dist/contracts/deepbook/governance.mjs.map +1 -0
  31. package/dist/contracts/deepbook/history.mjs +56 -0
  32. package/dist/contracts/deepbook/history.mjs.map +1 -0
  33. package/dist/contracts/deepbook/order.d.mts +12 -12
  34. package/dist/contracts/deepbook/pool.mjs +1739 -0
  35. package/dist/contracts/deepbook/pool.mjs.map +1 -0
  36. package/dist/contracts/deepbook/registry.mjs +295 -0
  37. package/dist/contracts/deepbook/registry.mjs.map +1 -0
  38. package/dist/contracts/deepbook/state.mjs +89 -0
  39. package/dist/contracts/deepbook/state.mjs.map +1 -0
  40. package/dist/contracts/deepbook/trade_params.mjs +21 -0
  41. package/dist/contracts/deepbook/trade_params.mjs.map +1 -0
  42. package/dist/contracts/deepbook/vault.mjs +42 -0
  43. package/dist/contracts/deepbook/vault.mjs.map +1 -0
  44. package/dist/contracts/deepbook_margin/deps/deepbook/balance_manager.mjs +53 -0
  45. package/dist/contracts/deepbook_margin/deps/deepbook/balance_manager.mjs.map +1 -0
  46. package/dist/contracts/deepbook_margin/deps/std/type_name.mjs +17 -0
  47. package/dist/contracts/deepbook_margin/deps/std/type_name.mjs.map +1 -0
  48. package/dist/contracts/deepbook_margin/deps/sui/bag.mjs +43 -0
  49. package/dist/contracts/deepbook_margin/deps/sui/bag.mjs.map +1 -0
  50. package/dist/contracts/deepbook_margin/deps/sui/balance.mjs +21 -0
  51. package/dist/contracts/deepbook_margin/deps/sui/balance.mjs.map +1 -0
  52. package/dist/contracts/deepbook_margin/deps/sui/table.mjs +38 -0
  53. package/dist/contracts/deepbook_margin/deps/sui/table.mjs.map +1 -0
  54. package/dist/contracts/deepbook_margin/deps/sui/vec_map.mjs +37 -0
  55. package/dist/contracts/deepbook_margin/deps/sui/vec_map.mjs.map +1 -0
  56. package/dist/contracts/deepbook_margin/deps/sui/vec_set.mjs +26 -0
  57. package/dist/contracts/deepbook_margin/deps/sui/vec_set.mjs.map +1 -0
  58. package/dist/contracts/deepbook_margin/deps/sui/versioned.mjs +19 -0
  59. package/dist/contracts/deepbook_margin/deps/sui/versioned.mjs.map +1 -0
  60. package/dist/contracts/deepbook_margin/margin_manager.mjs +989 -0
  61. package/dist/contracts/deepbook_margin/margin_manager.mjs.map +1 -0
  62. package/dist/contracts/deepbook_margin/margin_pool.mjs +550 -0
  63. package/dist/contracts/deepbook_margin/margin_pool.mjs.map +1 -0
  64. package/dist/contracts/deepbook_margin/margin_registry.mjs +786 -0
  65. package/dist/contracts/deepbook_margin/margin_registry.mjs.map +1 -0
  66. package/dist/contracts/deepbook_margin/margin_state.mjs +30 -0
  67. package/dist/contracts/deepbook_margin/margin_state.mjs.map +1 -0
  68. package/dist/contracts/deepbook_margin/oracle.mjs +82 -0
  69. package/dist/contracts/deepbook_margin/oracle.mjs.map +1 -0
  70. package/dist/contracts/deepbook_margin/pool_proxy.mjs +644 -0
  71. package/dist/contracts/deepbook_margin/pool_proxy.mjs.map +1 -0
  72. package/dist/contracts/deepbook_margin/position_manager.mjs +32 -0
  73. package/dist/contracts/deepbook_margin/position_manager.mjs.map +1 -0
  74. package/dist/contracts/deepbook_margin/protocol_config.mjs +122 -0
  75. package/dist/contracts/deepbook_margin/protocol_config.mjs.map +1 -0
  76. package/dist/contracts/deepbook_margin/protocol_fees.mjs +58 -0
  77. package/dist/contracts/deepbook_margin/protocol_fees.mjs.map +1 -0
  78. package/dist/contracts/deepbook_margin/rate_limiter.mjs +26 -0
  79. package/dist/contracts/deepbook_margin/rate_limiter.mjs.map +1 -0
  80. package/dist/contracts/deepbook_margin/tpsl.mjs +171 -0
  81. package/dist/contracts/deepbook_margin/tpsl.mjs.map +1 -0
  82. package/dist/contracts/margin_liquidation/deps/sui/bag.mjs +43 -0
  83. package/dist/contracts/margin_liquidation/deps/sui/bag.mjs.map +1 -0
  84. package/dist/contracts/margin_liquidation/liquidation_vault.mjs +179 -0
  85. package/dist/contracts/margin_liquidation/liquidation_vault.mjs.map +1 -0
  86. package/dist/contracts/utils/index.d.mts +1 -1
  87. package/dist/contracts/utils/index.mjs +92 -3
  88. package/dist/contracts/utils/index.mjs.map +1 -1
  89. package/dist/queries/registryQueries.mjs +13 -0
  90. package/dist/queries/registryQueries.mjs.map +1 -1
  91. package/dist/transactions/balanceManager.d.mts.map +1 -1
  92. package/dist/transactions/balanceManager.mjs +119 -100
  93. package/dist/transactions/balanceManager.mjs.map +1 -1
  94. package/dist/transactions/deepbook.d.mts.map +1 -1
  95. package/dist/transactions/deepbook.mjs +464 -439
  96. package/dist/transactions/deepbook.mjs.map +1 -1
  97. package/dist/transactions/deepbookAdmin.d.mts.map +1 -1
  98. package/dist/transactions/deepbookAdmin.mjs +151 -135
  99. package/dist/transactions/deepbookAdmin.mjs.map +1 -1
  100. package/dist/transactions/flashLoans.d.mts.map +1 -1
  101. package/dist/transactions/flashLoans.mjs +29 -22
  102. package/dist/transactions/flashLoans.mjs.map +1 -1
  103. package/dist/transactions/governance.d.mts.map +1 -1
  104. package/dist/transactions/governance.mjs +34 -33
  105. package/dist/transactions/governance.mjs.map +1 -1
  106. package/dist/transactions/marginAdmin.d.mts +17 -7
  107. package/dist/transactions/marginAdmin.d.mts.map +1 -1
  108. package/dist/transactions/marginAdmin.mjs +186 -169
  109. package/dist/transactions/marginAdmin.mjs.map +1 -1
  110. package/dist/transactions/marginLiquidations.d.mts +3 -3
  111. package/dist/transactions/marginLiquidations.d.mts.map +1 -1
  112. package/dist/transactions/marginLiquidations.mjs +53 -54
  113. package/dist/transactions/marginLiquidations.mjs.map +1 -1
  114. package/dist/transactions/marginMaintainer.d.mts +5 -5
  115. package/dist/transactions/marginMaintainer.d.mts.map +1 -1
  116. package/dist/transactions/marginMaintainer.mjs +83 -83
  117. package/dist/transactions/marginMaintainer.mjs.map +1 -1
  118. package/dist/transactions/marginManager.d.mts +32 -32
  119. package/dist/transactions/marginManager.d.mts.map +1 -1
  120. package/dist/transactions/marginManager.mjs +330 -317
  121. package/dist/transactions/marginManager.mjs.map +1 -1
  122. package/dist/transactions/marginPool.d.mts +18 -18
  123. package/dist/transactions/marginPool.d.mts.map +1 -1
  124. package/dist/transactions/marginPool.mjs +93 -89
  125. package/dist/transactions/marginPool.mjs.map +1 -1
  126. package/dist/transactions/marginRegistry.d.mts +22 -15
  127. package/dist/transactions/marginRegistry.d.mts.map +1 -1
  128. package/dist/transactions/marginRegistry.mjs +101 -68
  129. package/dist/transactions/marginRegistry.mjs.map +1 -1
  130. package/dist/transactions/marginTPSL.d.mts +27 -9
  131. package/dist/transactions/marginTPSL.d.mts.map +1 -1
  132. package/dist/transactions/marginTPSL.mjs +108 -82
  133. package/dist/transactions/marginTPSL.mjs.map +1 -1
  134. package/dist/transactions/poolProxy.d.mts +37 -5
  135. package/dist/transactions/poolProxy.d.mts.map +1 -1
  136. package/dist/transactions/poolProxy.mjs +269 -189
  137. package/dist/transactions/poolProxy.mjs.map +1 -1
  138. package/dist/utils/constants.mjs +4 -4
  139. package/dist/utils/constants.mjs.map +1 -1
  140. package/package.json +3 -3
  141. package/src/client.ts +8 -0
  142. package/src/contracts/deepbook/balance_manager.ts +46 -5
  143. package/src/contracts/deepbook/constants.ts +13 -0
  144. package/src/contracts/deepbook/pool.ts +133 -0
  145. package/src/contracts/deepbook/registry.ts +136 -1
  146. package/src/contracts/deepbook_margin/deps/deepbook/balance_manager.ts +49 -0
  147. package/src/contracts/deepbook_margin/deps/std/type_name.ts +24 -0
  148. package/src/contracts/deepbook_margin/deps/sui/bag.ts +41 -0
  149. package/src/contracts/deepbook_margin/deps/sui/balance.ts +19 -0
  150. package/src/contracts/deepbook_margin/deps/sui/table.ts +36 -0
  151. package/src/contracts/deepbook_margin/deps/sui/vec_map.ts +33 -0
  152. package/src/contracts/deepbook_margin/deps/sui/vec_set.ts +22 -0
  153. package/src/contracts/deepbook_margin/deps/sui/versioned.ts +13 -0
  154. package/src/contracts/deepbook_margin/margin_constants.ts +329 -0
  155. package/src/contracts/deepbook_margin/margin_manager.ts +1772 -0
  156. package/src/contracts/deepbook_margin/margin_pool.ts +1129 -0
  157. package/src/contracts/deepbook_margin/margin_registry.ts +1207 -0
  158. package/src/contracts/deepbook_margin/margin_state.ts +26 -0
  159. package/src/contracts/deepbook_margin/oracle.ts +99 -0
  160. package/src/contracts/deepbook_margin/pool_proxy.ts +1298 -0
  161. package/src/contracts/deepbook_margin/position_manager.ts +28 -0
  162. package/src/contracts/deepbook_margin/protocol_config.ts +163 -0
  163. package/src/contracts/deepbook_margin/protocol_fees.ts +153 -0
  164. package/src/contracts/deepbook_margin/rate_limiter.ts +80 -0
  165. package/src/contracts/deepbook_margin/tpsl.ts +559 -0
  166. package/src/contracts/margin_liquidation/deps/sui/bag.ts +41 -0
  167. package/src/contracts/margin_liquidation/liquidation_vault.ts +401 -0
  168. package/src/queries/registryQueries.ts +15 -0
  169. package/src/transactions/balanceManager.ts +140 -90
  170. package/src/transactions/deepbook.ts +586 -494
  171. package/src/transactions/deepbookAdmin.ts +154 -146
  172. package/src/transactions/flashLoans.ts +29 -20
  173. package/src/transactions/governance.ts +50 -37
  174. package/src/transactions/marginAdmin.ts +247 -188
  175. package/src/transactions/marginLiquidations.ts +70 -55
  176. package/src/transactions/marginMaintainer.ts +106 -88
  177. package/src/transactions/marginManager.ts +414 -348
  178. package/src/transactions/marginPool.ts +140 -103
  179. package/src/transactions/marginRegistry.ts +103 -70
  180. package/src/transactions/marginTPSL.ts +151 -87
  181. package/src/transactions/poolProxy.ts +384 -205
  182. package/src/utils/constants.ts +4 -4
@@ -9,6 +9,9 @@ import type { PoolConfigParams } from '../types/index.js';
9
9
  import { FLOAT_SCALAR } from '../utils/config.js';
10
10
  import { convertRate } from '../utils/conversion.js';
11
11
  import { hexToBytes } from '@noble/hashes/utils.js';
12
+ import * as marginRegistryMoveCalls from '../contracts/deepbook_margin/margin_registry.js';
13
+ import * as marginPoolMoveCalls from '../contracts/deepbook_margin/margin_pool.js';
14
+ import * as oracleMoveCalls from '../contracts/deepbook_margin/oracle.js';
12
15
 
13
16
  /**
14
17
  * MarginAdminContract class for managing admin actions.
@@ -40,14 +43,12 @@ export class MarginAdminContract {
40
43
  * @returns A function that takes a Transaction object
41
44
  */
42
45
  mintMaintainerCap = () => (tx: Transaction) => {
43
- return tx.moveCall({
44
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::mint_maintainer_cap`,
45
- arguments: [
46
- tx.object(this.#config.MARGIN_REGISTRY_ID),
47
- tx.object(this.#marginAdminCap()),
48
- tx.object.clock(),
49
- ],
50
- });
46
+ return tx.add(
47
+ marginRegistryMoveCalls.mintMaintainerCap({
48
+ package: this.#config.MARGIN_PACKAGE_ID,
49
+ arguments: { self: this.#config.MARGIN_REGISTRY_ID, AdminCap: this.#marginAdminCap() },
50
+ }),
51
+ );
51
52
  };
52
53
 
53
54
  /**
@@ -55,6 +56,10 @@ export class MarginAdminContract {
55
56
  * @returns A function that takes a Transaction object
56
57
  */
57
58
  revokeMaintainerCap = (maintainerCapId: string) => (tx: Transaction) => {
59
+ // NOTE: left as a positional moveCall (not codegen). The original passes
60
+ // `maintainerCapId` as an object reference (`tx.object`), whereas the
61
+ // generated binding encodes it as a pure `ID` value — migrating would change
62
+ // the emitted PTB. Kept verbatim to stay byte-identical.
58
63
  tx.moveCall({
59
64
  target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::revoke_maintainer_cap`,
60
65
  arguments: [
@@ -77,17 +82,18 @@ export class MarginAdminContract {
77
82
  const pool = this.#config.getPool(poolKey);
78
83
  const baseCoin = this.#config.getCoin(pool.baseCoin);
79
84
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
80
- tx.moveCall({
81
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::register_deepbook_pool`,
82
- arguments: [
83
- tx.object(this.#config.MARGIN_REGISTRY_ID),
84
- tx.object(this.#marginAdminCap()),
85
- tx.object(pool.address),
86
- poolConfig,
87
- tx.object.clock(),
88
- ],
89
- typeArguments: [baseCoin.type, quoteCoin.type],
90
- });
85
+ tx.add(
86
+ marginRegistryMoveCalls.registerDeepbookPool({
87
+ package: this.#config.MARGIN_PACKAGE_ID,
88
+ arguments: {
89
+ self: this.#config.MARGIN_REGISTRY_ID,
90
+ AdminCap: this.#marginAdminCap(),
91
+ pool: pool.address,
92
+ poolConfig,
93
+ },
94
+ typeArguments: [baseCoin.type, quoteCoin.type],
95
+ }),
96
+ );
91
97
  };
92
98
 
93
99
  /**
@@ -99,16 +105,17 @@ export class MarginAdminContract {
99
105
  const pool = this.#config.getPool(poolKey);
100
106
  const baseCoin = this.#config.getCoin(pool.baseCoin);
101
107
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
102
- tx.moveCall({
103
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::enable_deepbook_pool`,
104
- arguments: [
105
- tx.object(this.#config.MARGIN_REGISTRY_ID),
106
- tx.object(this.#marginAdminCap()),
107
- tx.object(pool.address),
108
- tx.object.clock(),
109
- ],
110
- typeArguments: [baseCoin.type, quoteCoin.type],
111
- });
108
+ tx.add(
109
+ marginRegistryMoveCalls.enableDeepbookPool({
110
+ package: this.#config.MARGIN_PACKAGE_ID,
111
+ arguments: {
112
+ self: this.#config.MARGIN_REGISTRY_ID,
113
+ AdminCap: this.#marginAdminCap(),
114
+ pool: pool.address,
115
+ },
116
+ typeArguments: [baseCoin.type, quoteCoin.type],
117
+ }),
118
+ );
112
119
  };
113
120
 
114
121
  /**
@@ -120,16 +127,17 @@ export class MarginAdminContract {
120
127
  const pool = this.#config.getPool(poolKey);
121
128
  const baseCoin = this.#config.getCoin(pool.baseCoin);
122
129
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
123
- tx.moveCall({
124
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::disable_deepbook_pool`,
125
- arguments: [
126
- tx.object(this.#config.MARGIN_REGISTRY_ID),
127
- tx.object(this.#marginAdminCap()),
128
- tx.object(pool.address),
129
- tx.object.clock(),
130
- ],
131
- typeArguments: [baseCoin.type, quoteCoin.type],
132
- });
130
+ tx.add(
131
+ marginRegistryMoveCalls.disableDeepbookPool({
132
+ package: this.#config.MARGIN_PACKAGE_ID,
133
+ arguments: {
134
+ self: this.#config.MARGIN_REGISTRY_ID,
135
+ AdminCap: this.#marginAdminCap(),
136
+ pool: pool.address,
137
+ },
138
+ typeArguments: [baseCoin.type, quoteCoin.type],
139
+ }),
140
+ );
133
141
  };
134
142
 
135
143
  /**
@@ -142,17 +150,18 @@ export class MarginAdminContract {
142
150
  const pool = this.#config.getPool(poolKey);
143
151
  const baseCoin = this.#config.getCoin(pool.baseCoin);
144
152
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
145
- tx.moveCall({
146
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::update_risk_params`,
147
- arguments: [
148
- tx.object(this.#config.MARGIN_REGISTRY_ID),
149
- tx.object(this.#marginAdminCap()),
150
- tx.object(pool.address),
151
- poolConfig,
152
- tx.object.clock(),
153
- ],
154
- typeArguments: [baseCoin.type, quoteCoin.type],
155
- });
153
+ tx.add(
154
+ marginRegistryMoveCalls.updateRiskParams({
155
+ package: this.#config.MARGIN_PACKAGE_ID,
156
+ arguments: {
157
+ self: this.#config.MARGIN_REGISTRY_ID,
158
+ AdminCap: this.#marginAdminCap(),
159
+ pool: pool.address,
160
+ poolConfig,
161
+ },
162
+ typeArguments: [baseCoin.type, quoteCoin.type],
163
+ }),
164
+ );
156
165
  };
157
166
 
158
167
  /**
@@ -169,17 +178,18 @@ export class MarginAdminContract {
169
178
  const pool = this.#config.getPool(poolKey);
170
179
  const baseCoin = this.#config.getCoin(pool.baseCoin);
171
180
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
172
- tx.moveCall({
173
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::set_price_tolerance`,
174
- arguments: [
175
- tx.object(this.#config.MARGIN_REGISTRY_ID),
176
- tx.object(this.#marginAdminCap()),
177
- tx.object(pool.address),
178
- tx.pure.u64(convertRate(tolerance, FLOAT_SCALAR)),
179
- tx.object.clock(),
180
- ],
181
- typeArguments: [baseCoin.type, quoteCoin.type],
182
- });
181
+ tx.add(
182
+ marginRegistryMoveCalls.setPriceTolerance({
183
+ package: this.#config.MARGIN_PACKAGE_ID,
184
+ arguments: {
185
+ self: this.#config.MARGIN_REGISTRY_ID,
186
+ AdminCap: this.#marginAdminCap(),
187
+ pool: pool.address,
188
+ tolerance: convertRate(tolerance, FLOAT_SCALAR),
189
+ },
190
+ typeArguments: [baseCoin.type, quoteCoin.type],
191
+ }),
192
+ );
183
193
  };
184
194
 
185
195
  /**
@@ -194,17 +204,18 @@ export class MarginAdminContract {
194
204
  const pool = this.#config.getPool(poolKey);
195
205
  const baseCoin = this.#config.getCoin(pool.baseCoin);
196
206
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
197
- tx.moveCall({
198
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::set_max_price_age`,
199
- arguments: [
200
- tx.object(this.#config.MARGIN_REGISTRY_ID),
201
- tx.object(this.#marginAdminCap()),
202
- tx.object(pool.address),
203
- tx.pure.u64(maxAgeMs),
204
- tx.object.clock(),
205
- ],
206
- typeArguments: [baseCoin.type, quoteCoin.type],
207
- });
207
+ tx.add(
208
+ marginRegistryMoveCalls.setMaxPriceAge({
209
+ package: this.#config.MARGIN_PACKAGE_ID,
210
+ arguments: {
211
+ self: this.#config.MARGIN_REGISTRY_ID,
212
+ AdminCap: this.#marginAdminCap(),
213
+ pool: pool.address,
214
+ maxAgeMs,
215
+ },
216
+ typeArguments: [baseCoin.type, quoteCoin.type],
217
+ }),
218
+ );
208
219
  };
209
220
 
210
221
  /**
@@ -221,19 +232,48 @@ export class MarginAdminContract {
221
232
  const pool = this.#config.getPool(poolKey);
222
233
  const baseCoin = this.#config.getCoin(pool.baseCoin);
223
234
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
224
- tx.moveCall({
225
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::set_max_order_ttl`,
226
- arguments: [
227
- tx.object(this.#config.MARGIN_REGISTRY_ID),
228
- tx.object(this.#marginAdminCap()),
229
- tx.object(pool.address),
230
- tx.pure.u64(maxOrderTtlMs),
231
- tx.object.clock(),
232
- ],
233
- typeArguments: [baseCoin.type, quoteCoin.type],
234
- });
235
+ tx.add(
236
+ marginRegistryMoveCalls.setMaxOrderTtl({
237
+ package: this.#config.MARGIN_PACKAGE_ID,
238
+ arguments: {
239
+ self: this.#config.MARGIN_REGISTRY_ID,
240
+ AdminCap: this.#marginAdminCap(),
241
+ pool: pool.address,
242
+ maxOrderTtlMs,
243
+ },
244
+ typeArguments: [baseCoin.type, quoteCoin.type],
245
+ }),
246
+ );
235
247
  };
236
248
 
249
+ /**
250
+ * @description Set the minimum risk ratio required to open a new position on
251
+ * a pool. Distinct from the borrow floor: this gates position opening, not
252
+ * borrowing. Stored in 9-decimal float scaling (1.0 = `FLOAT_SCALAR`); the SDK
253
+ * applies the scaling, so callers pass a human-readable ratio (e.g. `1.25`).
254
+ * @param {string} poolKey The key of the pool to update
255
+ * @param {number | bigint} minOpenRiskRatio Minimum open risk ratio (e.g. 1.25)
256
+ * @returns A function that takes a Transaction object
257
+ */
258
+ setMinOpenRiskRatio =
259
+ (poolKey: string, minOpenRiskRatio: number | bigint) => (tx: Transaction) => {
260
+ const pool = this.#config.getPool(poolKey);
261
+ const baseCoin = this.#config.getCoin(pool.baseCoin);
262
+ const quoteCoin = this.#config.getCoin(pool.quoteCoin);
263
+ tx.add(
264
+ marginRegistryMoveCalls.setMinOpenRiskRatio({
265
+ package: this.#config.MARGIN_PACKAGE_ID,
266
+ arguments: {
267
+ self: this.#config.MARGIN_REGISTRY_ID,
268
+ AdminCap: this.#marginAdminCap(),
269
+ pool: pool.address,
270
+ minOpenRiskRatio: convertRate(minOpenRiskRatio, FLOAT_SCALAR),
271
+ },
272
+ typeArguments: [baseCoin.type, quoteCoin.type],
273
+ }),
274
+ );
275
+ };
276
+
237
277
  /**
238
278
  * @description Add the PythConfig to the margin registry
239
279
  * @param {Transaction} tx The transaction object
@@ -241,15 +281,17 @@ export class MarginAdminContract {
241
281
  * @returns A function that takes a Transaction object
242
282
  */
243
283
  addConfig = (config: TransactionArgument) => (tx: Transaction) => {
244
- tx.moveCall({
245
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::add_config`,
246
- arguments: [
247
- tx.object(this.#config.MARGIN_REGISTRY_ID),
248
- tx.object(this.#marginAdminCap()),
249
- config,
250
- ],
251
- typeArguments: [`${this.#config.MARGIN_PACKAGE_ID}::oracle::PythConfig`],
252
- });
284
+ tx.add(
285
+ marginRegistryMoveCalls.addConfig({
286
+ package: this.#config.MARGIN_PACKAGE_ID,
287
+ arguments: {
288
+ self: this.#config.MARGIN_REGISTRY_ID,
289
+ AdminCap: this.#marginAdminCap(),
290
+ config,
291
+ },
292
+ typeArguments: [`${this.#config.MARGIN_PACKAGE_ID}::oracle::PythConfig`],
293
+ }),
294
+ );
253
295
  };
254
296
 
255
297
  /**
@@ -258,11 +300,13 @@ export class MarginAdminContract {
258
300
  * @returns A function that takes a Transaction object
259
301
  */
260
302
  removeConfig = () => (tx: Transaction) => {
261
- tx.moveCall({
262
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::remove_config`,
263
- arguments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.object(this.#marginAdminCap())],
264
- typeArguments: [`${this.#config.MARGIN_PACKAGE_ID}::oracle::PythConfig`],
265
- });
303
+ tx.add(
304
+ marginRegistryMoveCalls.removeConfig({
305
+ package: this.#config.MARGIN_PACKAGE_ID,
306
+ arguments: { self: this.#config.MARGIN_REGISTRY_ID, AdminCap: this.#marginAdminCap() },
307
+ typeArguments: [`${this.#config.MARGIN_PACKAGE_ID}::oracle::PythConfig`],
308
+ }),
309
+ );
266
310
  };
267
311
 
268
312
  /**
@@ -271,14 +315,16 @@ export class MarginAdminContract {
271
315
  * @returns A function that takes a Transaction object
272
316
  */
273
317
  enableVersion = (version: number) => (tx: Transaction) => {
274
- tx.moveCall({
275
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::enable_version`,
276
- arguments: [
277
- tx.object(this.#config.MARGIN_REGISTRY_ID),
278
- tx.pure.u64(version),
279
- tx.object(this.#marginAdminCap()),
280
- ],
281
- });
318
+ tx.add(
319
+ marginRegistryMoveCalls.enableVersion({
320
+ package: this.#config.MARGIN_PACKAGE_ID,
321
+ arguments: {
322
+ self: this.#config.MARGIN_REGISTRY_ID,
323
+ version,
324
+ AdminCap: this.#marginAdminCap(),
325
+ },
326
+ }),
327
+ );
282
328
  };
283
329
 
284
330
  /**
@@ -287,14 +333,16 @@ export class MarginAdminContract {
287
333
  * @returns A function that takes a Transaction object
288
334
  */
289
335
  disableVersion = (version: number) => (tx: Transaction) => {
290
- tx.moveCall({
291
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::disable_version`,
292
- arguments: [
293
- tx.object(this.#config.MARGIN_REGISTRY_ID),
294
- tx.pure.u64(version),
295
- tx.object(this.#marginAdminCap()),
296
- ],
297
- });
336
+ tx.add(
337
+ marginRegistryMoveCalls.disableVersion({
338
+ package: this.#config.MARGIN_PACKAGE_ID,
339
+ arguments: {
340
+ self: this.#config.MARGIN_REGISTRY_ID,
341
+ version,
342
+ AdminCap: this.#marginAdminCap(),
343
+ },
344
+ }),
345
+ );
298
346
  };
299
347
 
300
348
  /**
@@ -315,19 +363,21 @@ export class MarginAdminContract {
315
363
  userLiquidationReward,
316
364
  poolLiquidationReward,
317
365
  } = poolConfigParams;
318
- return tx.moveCall({
319
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::new_pool_config`,
320
- arguments: [
321
- tx.object(this.#config.MARGIN_REGISTRY_ID),
322
- tx.pure.u64(convertRate(minWithdrawRiskRatio, FLOAT_SCALAR)),
323
- tx.pure.u64(convertRate(minBorrowRiskRatio, FLOAT_SCALAR)),
324
- tx.pure.u64(convertRate(liquidationRiskRatio, FLOAT_SCALAR)),
325
- tx.pure.u64(convertRate(targetLiquidationRiskRatio, FLOAT_SCALAR)),
326
- tx.pure.u64(convertRate(userLiquidationReward, FLOAT_SCALAR)),
327
- tx.pure.u64(convertRate(poolLiquidationReward, FLOAT_SCALAR)),
328
- ],
329
- typeArguments: [baseCoin.type, quoteCoin.type],
330
- });
366
+ return tx.add(
367
+ marginRegistryMoveCalls.newPoolConfig({
368
+ package: this.#config.MARGIN_PACKAGE_ID,
369
+ arguments: {
370
+ self: this.#config.MARGIN_REGISTRY_ID,
371
+ minWithdrawRiskRatio: convertRate(minWithdrawRiskRatio, FLOAT_SCALAR),
372
+ minBorrowRiskRatio: convertRate(minBorrowRiskRatio, FLOAT_SCALAR),
373
+ liquidationRiskRatio: convertRate(liquidationRiskRatio, FLOAT_SCALAR),
374
+ targetLiquidationRiskRatio: convertRate(targetLiquidationRiskRatio, FLOAT_SCALAR),
375
+ userLiquidationReward: convertRate(userLiquidationReward, FLOAT_SCALAR),
376
+ poolLiquidationReward: convertRate(poolLiquidationReward, FLOAT_SCALAR),
377
+ },
378
+ typeArguments: [baseCoin.type, quoteCoin.type],
379
+ }),
380
+ );
331
381
  };
332
382
 
333
383
  /**
@@ -340,14 +390,16 @@ export class MarginAdminContract {
340
390
  const pool = this.#config.getPool(poolKey);
341
391
  const baseCoin = this.#config.getCoin(pool.baseCoin);
342
392
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
343
- tx.moveCall({
344
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::new_pool_config_with_leverage`,
345
- arguments: [
346
- tx.object(this.#config.MARGIN_REGISTRY_ID),
347
- tx.pure.u64(convertRate(leverage, FLOAT_SCALAR)),
348
- ],
349
- typeArguments: [baseCoin.type, quoteCoin.type],
350
- });
393
+ tx.add(
394
+ marginRegistryMoveCalls.newPoolConfigWithLeverage({
395
+ package: this.#config.MARGIN_PACKAGE_ID,
396
+ arguments: {
397
+ self: this.#config.MARGIN_REGISTRY_ID,
398
+ leverage: convertRate(leverage, FLOAT_SCALAR),
399
+ },
400
+ typeArguments: [baseCoin.type, quoteCoin.type],
401
+ }),
402
+ );
351
403
  };
352
404
 
353
405
  /**
@@ -366,16 +418,18 @@ export class MarginAdminContract {
366
418
  const priceFeedInput = new Uint8Array(
367
419
  hexToBytes(coin['feed']!.startsWith('0x') ? coin.feed!.slice(2) : coin['feed']),
368
420
  );
369
- return tx.moveCall({
370
- target: `${this.#config.MARGIN_PACKAGE_ID}::oracle::new_coin_type_data_from_currency`,
371
- arguments: [
372
- tx.object(coin.currencyId!),
373
- tx.pure.vector('u8', priceFeedInput),
374
- tx.pure.u64(maxConfBps),
375
- tx.pure.u64(maxEwmaDifferenceBps),
376
- ],
377
- typeArguments: [coin.type],
378
- });
421
+ return tx.add(
422
+ oracleMoveCalls.newCoinTypeDataFromCurrency({
423
+ package: this.#config.MARGIN_PACKAGE_ID,
424
+ arguments: {
425
+ currency: coin.currencyId!,
426
+ priceFeedId: Array.from(priceFeedInput),
427
+ maxConfBps,
428
+ maxEwmaDifferenceBps,
429
+ },
430
+ typeArguments: [coin.type],
431
+ }),
432
+ );
379
433
  };
380
434
 
381
435
  /**
@@ -396,16 +450,18 @@ export class MarginAdminContract {
396
450
  this.newCoinTypeData(setup.coinKey, setup.maxConfBps, setup.maxEwmaDifferenceBps)(tx),
397
451
  );
398
452
  }
399
- return tx.moveCall({
400
- target: `${this.#config.MARGIN_PACKAGE_ID}::oracle::new_pyth_config`,
401
- arguments: [
402
- tx.makeMoveVec({
403
- elements: coinTypeDataList,
404
- type: `${this.#config.MARGIN_PACKAGE_ID}::oracle::CoinTypeData`,
405
- }),
406
- tx.pure.u64(maxAgeSeconds),
407
- ],
408
- });
453
+ return tx.add(
454
+ oracleMoveCalls.newPythConfig({
455
+ package: this.#config.MARGIN_PACKAGE_ID,
456
+ arguments: {
457
+ setups: tx.makeMoveVec({
458
+ elements: coinTypeDataList,
459
+ type: `${this.#config.MARGIN_PACKAGE_ID}::oracle::CoinTypeData`,
460
+ }),
461
+ maxAgeSecs: maxAgeSeconds,
462
+ },
463
+ }),
464
+ );
409
465
  };
410
466
 
411
467
  /**
@@ -413,14 +469,12 @@ export class MarginAdminContract {
413
469
  * @returns A function that takes a Transaction object
414
470
  */
415
471
  mintPauseCap = () => (tx: Transaction) => {
416
- return tx.moveCall({
417
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::mint_pause_cap`,
418
- arguments: [
419
- tx.object(this.#config.MARGIN_REGISTRY_ID),
420
- tx.object(this.#marginAdminCap()),
421
- tx.object.clock(),
422
- ],
423
- });
472
+ return tx.add(
473
+ marginRegistryMoveCalls.mintPauseCap({
474
+ package: this.#config.MARGIN_PACKAGE_ID,
475
+ arguments: { self: this.#config.MARGIN_REGISTRY_ID, AdminCap: this.#marginAdminCap() },
476
+ }),
477
+ );
424
478
  };
425
479
 
426
480
  /**
@@ -429,15 +483,16 @@ export class MarginAdminContract {
429
483
  * @returns A function that takes a Transaction object
430
484
  */
431
485
  revokePauseCap = (pauseCapId: string) => (tx: Transaction) => {
432
- tx.moveCall({
433
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::revoke_pause_cap`,
434
- arguments: [
435
- tx.object(this.#config.MARGIN_REGISTRY_ID),
436
- tx.object(this.#marginAdminCap()),
437
- tx.object.clock(),
438
- tx.pure.id(pauseCapId),
439
- ],
440
- });
486
+ tx.add(
487
+ marginRegistryMoveCalls.revokePauseCap({
488
+ package: this.#config.MARGIN_PACKAGE_ID,
489
+ arguments: {
490
+ self: this.#config.MARGIN_REGISTRY_ID,
491
+ AdminCap: this.#marginAdminCap(),
492
+ pauseCapId,
493
+ },
494
+ }),
495
+ );
441
496
  };
442
497
 
443
498
  /**
@@ -447,14 +502,16 @@ export class MarginAdminContract {
447
502
  * @returns A function that takes a Transaction object
448
503
  */
449
504
  disableVersionPauseCap = (version: number, pauseCapId: string) => (tx: Transaction) => {
450
- tx.moveCall({
451
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::disable_version_pause_cap`,
452
- arguments: [
453
- tx.object(this.#config.MARGIN_REGISTRY_ID),
454
- tx.pure.u64(version),
455
- tx.object(pauseCapId),
456
- ],
457
- });
505
+ tx.add(
506
+ marginRegistryMoveCalls.disableVersionPauseCap({
507
+ package: this.#config.MARGIN_PACKAGE_ID,
508
+ arguments: {
509
+ self: this.#config.MARGIN_REGISTRY_ID,
510
+ version,
511
+ pauseCap: pauseCapId,
512
+ },
513
+ }),
514
+ );
458
515
  };
459
516
 
460
517
  /**
@@ -466,14 +523,16 @@ export class MarginAdminContract {
466
523
  adminWithdrawDefaultReferralFees = (coinKey: string) => (tx: Transaction) => {
467
524
  const coin = this.#config.getCoin(coinKey);
468
525
  const marginPool = this.#config.getMarginPool(coinKey);
469
- return tx.moveCall({
470
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::admin_withdraw_default_referral_fees`,
471
- arguments: [
472
- tx.object(marginPool.address),
473
- tx.object(this.#config.MARGIN_REGISTRY_ID),
474
- tx.object(this.#marginAdminCap()),
475
- ],
476
- typeArguments: [coin.type],
477
- });
526
+ return tx.add(
527
+ marginPoolMoveCalls.adminWithdrawDefaultReferralFees({
528
+ package: this.#config.MARGIN_PACKAGE_ID,
529
+ arguments: {
530
+ self: marginPool.address,
531
+ registry: this.#config.MARGIN_REGISTRY_ID,
532
+ AdminCap: this.#marginAdminCap(),
533
+ },
534
+ typeArguments: [coin.type],
535
+ }),
536
+ );
478
537
  };
479
538
  }