@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
@@ -7,6 +7,7 @@ import type { DeepBookConfig } from '../utils/config.js';
7
7
  import type { DepositParams, DepositDuringInitParams } from '../types/index.js';
8
8
  import { FLOAT_SCALAR } from '../utils/config.js';
9
9
  import { convertPrice, convertQuantity } from '../utils/conversion.js';
10
+ import * as marginManagerMoveCalls from '../contracts/deepbook_margin/margin_manager.js';
10
11
 
11
12
  /**
12
13
  * MarginManagerContract class for managing MarginManager operations.
@@ -30,16 +31,17 @@ export class MarginManagerContract {
30
31
  const pool = this.#config.getPool(poolKey);
31
32
  const baseCoin = this.#config.getCoin(pool.baseCoin);
32
33
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
33
- tx.moveCall({
34
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::new`,
35
- arguments: [
36
- tx.object(pool.address),
37
- tx.object(this.#config.REGISTRY_ID),
38
- tx.object(this.#config.MARGIN_REGISTRY_ID),
39
- tx.object.clock(),
40
- ],
41
- typeArguments: [baseCoin.type, quoteCoin.type],
42
- });
34
+ tx.add(
35
+ marginManagerMoveCalls._new({
36
+ package: this.#config.MARGIN_PACKAGE_ID,
37
+ arguments: {
38
+ pool: pool.address,
39
+ deepbookRegistry: this.#config.REGISTRY_ID,
40
+ marginRegistry: this.#config.MARGIN_REGISTRY_ID,
41
+ },
42
+ typeArguments: [baseCoin.type, quoteCoin.type],
43
+ }),
44
+ );
43
45
  };
44
46
 
45
47
  /**
@@ -51,16 +53,17 @@ export class MarginManagerContract {
51
53
  const pool = this.#config.getPool(poolKey);
52
54
  const baseCoin = this.#config.getCoin(pool.baseCoin);
53
55
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
54
- const [manager, initializer] = tx.moveCall({
55
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::new_with_initializer`,
56
- arguments: [
57
- tx.object(pool.address),
58
- tx.object(this.#config.REGISTRY_ID),
59
- tx.object(this.#config.MARGIN_REGISTRY_ID),
60
- tx.object.clock(),
61
- ],
62
- typeArguments: [baseCoin.type, quoteCoin.type],
63
- });
56
+ const [manager, initializer] = tx.add(
57
+ marginManagerMoveCalls.newWithInitializer({
58
+ package: this.#config.MARGIN_PACKAGE_ID,
59
+ arguments: {
60
+ pool: pool.address,
61
+ deepbookRegistry: this.#config.REGISTRY_ID,
62
+ marginRegistry: this.#config.MARGIN_REGISTRY_ID,
63
+ },
64
+ typeArguments: [baseCoin.type, quoteCoin.type],
65
+ }),
66
+ );
64
67
  return { manager, initializer };
65
68
  };
66
69
 
@@ -77,11 +80,13 @@ export class MarginManagerContract {
77
80
  const pool = this.#config.getPool(poolKey);
78
81
  const baseCoin = this.#config.getCoin(pool.baseCoin);
79
82
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
80
- tx.moveCall({
81
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::share`,
82
- arguments: [manager, initializer],
83
- typeArguments: [baseCoin.type, quoteCoin.type],
84
- });
83
+ tx.add(
84
+ marginManagerMoveCalls.share({
85
+ package: this.#config.MARGIN_PACKAGE_ID,
86
+ arguments: { manager, initializer },
87
+ typeArguments: [baseCoin.type, quoteCoin.type],
88
+ }),
89
+ );
85
90
  };
86
91
 
87
92
  /**
@@ -96,11 +101,13 @@ export class MarginManagerContract {
96
101
  const pool = this.#config.getPool(manager.poolKey);
97
102
  const baseCoin = this.#config.getCoin(pool.baseCoin);
98
103
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
99
- tx.moveCall({
100
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::register_margin_manager`,
101
- arguments: [tx.object(manager.address), tx.object(this.#config.MARGIN_REGISTRY_ID)],
102
- typeArguments: [baseCoin.type, quoteCoin.type],
103
- });
104
+ tx.add(
105
+ marginManagerMoveCalls.registerMarginManager({
106
+ package: this.#config.MARGIN_PACKAGE_ID,
107
+ arguments: { self: manager.address, marginRegistry: this.#config.MARGIN_REGISTRY_ID },
108
+ typeArguments: [baseCoin.type, quoteCoin.type],
109
+ }),
110
+ );
104
111
  };
105
112
 
106
113
  /**
@@ -114,11 +121,13 @@ export class MarginManagerContract {
114
121
  const pool = this.#config.getPool(manager.poolKey);
115
122
  const baseCoin = this.#config.getCoin(pool.baseCoin);
116
123
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
117
- tx.moveCall({
118
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::unregister_margin_manager`,
119
- arguments: [tx.object(manager.address), tx.object(this.#config.MARGIN_REGISTRY_ID)],
120
- typeArguments: [baseCoin.type, quoteCoin.type],
121
- });
124
+ tx.add(
125
+ marginManagerMoveCalls.unregisterMarginManager({
126
+ package: this.#config.MARGIN_PACKAGE_ID,
127
+ arguments: { self: manager.address, marginRegistry: this.#config.MARGIN_REGISTRY_ID },
128
+ typeArguments: [baseCoin.type, quoteCoin.type],
129
+ }),
130
+ );
122
131
  };
123
132
 
124
133
  /**
@@ -145,18 +154,19 @@ export class MarginManagerContract {
145
154
  })
146
155
  : params.coin;
147
156
 
148
- tx.moveCall({
149
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::deposit`,
150
- arguments: [
151
- manager,
152
- tx.object(this.#config.MARGIN_REGISTRY_ID),
153
- tx.object(baseCoin.priceInfoObjectId!),
154
- tx.object(quoteCoin.priceInfoObjectId!),
155
- coin,
156
- tx.object.clock(),
157
- ],
158
- typeArguments: [baseCoin.type, quoteCoin.type, depositCoin.type],
159
- });
157
+ tx.add(
158
+ marginManagerMoveCalls.deposit({
159
+ package: this.#config.MARGIN_PACKAGE_ID,
160
+ arguments: {
161
+ self: manager,
162
+ registry: this.#config.MARGIN_REGISTRY_ID,
163
+ baseOracle: baseCoin.priceInfoObjectId!,
164
+ quoteOracle: quoteCoin.priceInfoObjectId!,
165
+ coin,
166
+ },
167
+ typeArguments: [baseCoin.type, quoteCoin.type, depositCoin.type],
168
+ }),
169
+ );
160
170
  };
161
171
 
162
172
  /**
@@ -177,18 +187,19 @@ export class MarginManagerContract {
177
187
  balance: convertQuantity(params.amount, baseCoin.scalar),
178
188
  })
179
189
  : params.coin;
180
- tx.moveCall({
181
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::deposit`,
182
- arguments: [
183
- tx.object(manager.address),
184
- tx.object(this.#config.MARGIN_REGISTRY_ID),
185
- tx.object(baseCoin.priceInfoObjectId!),
186
- tx.object(quoteCoin.priceInfoObjectId!),
187
- coin,
188
- tx.object.clock(),
189
- ],
190
- typeArguments: [baseCoin.type, quoteCoin.type, baseCoin.type],
191
- });
190
+ tx.add(
191
+ marginManagerMoveCalls.deposit({
192
+ package: this.#config.MARGIN_PACKAGE_ID,
193
+ arguments: {
194
+ self: manager.address,
195
+ registry: this.#config.MARGIN_REGISTRY_ID,
196
+ baseOracle: baseCoin.priceInfoObjectId!,
197
+ quoteOracle: quoteCoin.priceInfoObjectId!,
198
+ coin,
199
+ },
200
+ typeArguments: [baseCoin.type, quoteCoin.type, baseCoin.type],
201
+ }),
202
+ );
192
203
  };
193
204
 
194
205
  /**
@@ -209,18 +220,19 @@ export class MarginManagerContract {
209
220
  balance: convertQuantity(params.amount, quoteCoin.scalar),
210
221
  })
211
222
  : params.coin;
212
- tx.moveCall({
213
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::deposit`,
214
- arguments: [
215
- tx.object(manager.address),
216
- tx.object(this.#config.MARGIN_REGISTRY_ID),
217
- tx.object(baseCoin.priceInfoObjectId!),
218
- tx.object(quoteCoin.priceInfoObjectId!),
219
- coin,
220
- tx.object.clock(),
221
- ],
222
- typeArguments: [baseCoin.type, quoteCoin.type, quoteCoin.type],
223
- });
223
+ tx.add(
224
+ marginManagerMoveCalls.deposit({
225
+ package: this.#config.MARGIN_PACKAGE_ID,
226
+ arguments: {
227
+ self: manager.address,
228
+ registry: this.#config.MARGIN_REGISTRY_ID,
229
+ baseOracle: baseCoin.priceInfoObjectId!,
230
+ quoteOracle: quoteCoin.priceInfoObjectId!,
231
+ coin,
232
+ },
233
+ typeArguments: [baseCoin.type, quoteCoin.type, quoteCoin.type],
234
+ }),
235
+ );
224
236
  };
225
237
 
226
238
  /**
@@ -242,18 +254,19 @@ export class MarginManagerContract {
242
254
  balance: convertQuantity(params.amount, deepCoin.scalar),
243
255
  })
244
256
  : params.coin;
245
- tx.moveCall({
246
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::deposit`,
247
- arguments: [
248
- tx.object(manager.address),
249
- tx.object(this.#config.MARGIN_REGISTRY_ID),
250
- tx.object(baseCoin.priceInfoObjectId!),
251
- tx.object(quoteCoin.priceInfoObjectId!),
252
- coin,
253
- tx.object.clock(),
254
- ],
255
- typeArguments: [baseCoin.type, quoteCoin.type, deepCoin.type],
256
- });
257
+ tx.add(
258
+ marginManagerMoveCalls.deposit({
259
+ package: this.#config.MARGIN_PACKAGE_ID,
260
+ arguments: {
261
+ self: manager.address,
262
+ registry: this.#config.MARGIN_REGISTRY_ID,
263
+ baseOracle: baseCoin.priceInfoObjectId!,
264
+ quoteOracle: quoteCoin.priceInfoObjectId!,
265
+ coin,
266
+ },
267
+ typeArguments: [baseCoin.type, quoteCoin.type, deepCoin.type],
268
+ }),
269
+ );
257
270
  };
258
271
 
259
272
  /**
@@ -269,21 +282,22 @@ export class MarginManagerContract {
269
282
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
270
283
  const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
271
284
  const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
272
- return tx.moveCall({
273
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::withdraw`,
274
- arguments: [
275
- tx.object(manager.address),
276
- tx.object(this.#config.MARGIN_REGISTRY_ID),
277
- tx.object(baseMarginPool.address),
278
- tx.object(quoteMarginPool.address),
279
- tx.object(baseCoin.priceInfoObjectId!),
280
- tx.object(quoteCoin.priceInfoObjectId!),
281
- tx.object(pool.address),
282
- tx.pure.u64(convertQuantity(amount, baseCoin.scalar)),
283
- tx.object.clock(),
284
- ],
285
- typeArguments: [baseCoin.type, quoteCoin.type, baseCoin.type],
286
- });
285
+ return tx.add(
286
+ marginManagerMoveCalls.withdraw({
287
+ package: this.#config.MARGIN_PACKAGE_ID,
288
+ arguments: {
289
+ self: manager.address,
290
+ registry: this.#config.MARGIN_REGISTRY_ID,
291
+ baseMarginPool: baseMarginPool.address,
292
+ quoteMarginPool: quoteMarginPool.address,
293
+ baseOracle: baseCoin.priceInfoObjectId!,
294
+ quoteOracle: quoteCoin.priceInfoObjectId!,
295
+ pool: pool.address,
296
+ withdrawAmount: convertQuantity(amount, baseCoin.scalar),
297
+ },
298
+ typeArguments: [baseCoin.type, quoteCoin.type, baseCoin.type],
299
+ }),
300
+ );
287
301
  };
288
302
 
289
303
  /**
@@ -299,21 +313,22 @@ export class MarginManagerContract {
299
313
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
300
314
  const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
301
315
  const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
302
- return tx.moveCall({
303
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::withdraw`,
304
- arguments: [
305
- tx.object(manager.address),
306
- tx.object(this.#config.MARGIN_REGISTRY_ID),
307
- tx.object(baseMarginPool.address),
308
- tx.object(quoteMarginPool.address),
309
- tx.object(baseCoin.priceInfoObjectId!),
310
- tx.object(quoteCoin.priceInfoObjectId!),
311
- tx.object(pool.address),
312
- tx.pure.u64(convertQuantity(amount, quoteCoin.scalar)),
313
- tx.object.clock(),
314
- ],
315
- typeArguments: [baseCoin.type, quoteCoin.type, quoteCoin.type],
316
- });
316
+ return tx.add(
317
+ marginManagerMoveCalls.withdraw({
318
+ package: this.#config.MARGIN_PACKAGE_ID,
319
+ arguments: {
320
+ self: manager.address,
321
+ registry: this.#config.MARGIN_REGISTRY_ID,
322
+ baseMarginPool: baseMarginPool.address,
323
+ quoteMarginPool: quoteMarginPool.address,
324
+ baseOracle: baseCoin.priceInfoObjectId!,
325
+ quoteOracle: quoteCoin.priceInfoObjectId!,
326
+ pool: pool.address,
327
+ withdrawAmount: convertQuantity(amount, quoteCoin.scalar),
328
+ },
329
+ typeArguments: [baseCoin.type, quoteCoin.type, quoteCoin.type],
330
+ }),
331
+ );
317
332
  };
318
333
 
319
334
  /**
@@ -330,21 +345,22 @@ export class MarginManagerContract {
330
345
  const deepCoin = this.#config.getCoin('DEEP');
331
346
  const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
332
347
  const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
333
- return tx.moveCall({
334
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::withdraw`,
335
- arguments: [
336
- tx.object(manager.address),
337
- tx.object(this.#config.MARGIN_REGISTRY_ID),
338
- tx.object(baseMarginPool.address),
339
- tx.object(quoteMarginPool.address),
340
- tx.object(baseCoin.priceInfoObjectId!),
341
- tx.object(quoteCoin.priceInfoObjectId!),
342
- tx.object(pool.address),
343
- tx.pure.u64(convertQuantity(amount, deepCoin.scalar)),
344
- tx.object.clock(),
345
- ],
346
- typeArguments: [baseCoin.type, quoteCoin.type, deepCoin.type],
347
- });
348
+ return tx.add(
349
+ marginManagerMoveCalls.withdraw({
350
+ package: this.#config.MARGIN_PACKAGE_ID,
351
+ arguments: {
352
+ self: manager.address,
353
+ registry: this.#config.MARGIN_REGISTRY_ID,
354
+ baseMarginPool: baseMarginPool.address,
355
+ quoteMarginPool: quoteMarginPool.address,
356
+ baseOracle: baseCoin.priceInfoObjectId!,
357
+ quoteOracle: quoteCoin.priceInfoObjectId!,
358
+ pool: pool.address,
359
+ withdrawAmount: convertQuantity(amount, deepCoin.scalar),
360
+ },
361
+ typeArguments: [baseCoin.type, quoteCoin.type, deepCoin.type],
362
+ }),
363
+ );
348
364
  };
349
365
 
350
366
  /**
@@ -359,20 +375,21 @@ export class MarginManagerContract {
359
375
  const baseCoin = this.#config.getCoin(pool.baseCoin);
360
376
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
361
377
  const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
362
- return tx.moveCall({
363
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::borrow_base`,
364
- arguments: [
365
- tx.object(manager.address),
366
- tx.object(this.#config.MARGIN_REGISTRY_ID),
367
- tx.object(baseMarginPool.address),
368
- tx.object(baseCoin.priceInfoObjectId!),
369
- tx.object(quoteCoin.priceInfoObjectId!),
370
- tx.object(pool.address),
371
- tx.pure.u64(convertQuantity(amount, baseCoin.scalar)),
372
- tx.object.clock(),
373
- ],
374
- typeArguments: [baseCoin.type, quoteCoin.type],
375
- });
378
+ return tx.add(
379
+ marginManagerMoveCalls.borrowBase({
380
+ package: this.#config.MARGIN_PACKAGE_ID,
381
+ arguments: {
382
+ self: manager.address,
383
+ registry: this.#config.MARGIN_REGISTRY_ID,
384
+ baseMarginPool: baseMarginPool.address,
385
+ baseOracle: baseCoin.priceInfoObjectId!,
386
+ quoteOracle: quoteCoin.priceInfoObjectId!,
387
+ pool: pool.address,
388
+ loanAmount: convertQuantity(amount, baseCoin.scalar),
389
+ },
390
+ typeArguments: [baseCoin.type, quoteCoin.type],
391
+ }),
392
+ );
376
393
  };
377
394
 
378
395
  /**
@@ -387,20 +404,21 @@ export class MarginManagerContract {
387
404
  const baseCoin = this.#config.getCoin(pool.baseCoin);
388
405
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
389
406
  const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
390
- return tx.moveCall({
391
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::borrow_quote`,
392
- arguments: [
393
- tx.object(manager.address),
394
- tx.object(this.#config.MARGIN_REGISTRY_ID),
395
- tx.object(quoteMarginPool.address),
396
- tx.object(baseCoin.priceInfoObjectId!),
397
- tx.object(quoteCoin.priceInfoObjectId!),
398
- tx.object(pool.address),
399
- tx.pure.u64(convertQuantity(amount, quoteCoin.scalar)),
400
- tx.object.clock(),
401
- ],
402
- typeArguments: [baseCoin.type, quoteCoin.type],
403
- });
407
+ return tx.add(
408
+ marginManagerMoveCalls.borrowQuote({
409
+ package: this.#config.MARGIN_PACKAGE_ID,
410
+ arguments: {
411
+ self: manager.address,
412
+ registry: this.#config.MARGIN_REGISTRY_ID,
413
+ quoteMarginPool: quoteMarginPool.address,
414
+ baseOracle: baseCoin.priceInfoObjectId!,
415
+ quoteOracle: quoteCoin.priceInfoObjectId!,
416
+ pool: pool.address,
417
+ loanAmount: convertQuantity(amount, quoteCoin.scalar),
418
+ },
419
+ typeArguments: [baseCoin.type, quoteCoin.type],
420
+ }),
421
+ );
404
422
  };
405
423
 
406
424
  /**
@@ -415,20 +433,18 @@ export class MarginManagerContract {
415
433
  const baseCoin = this.#config.getCoin(pool.baseCoin);
416
434
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
417
435
  const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
418
- return tx.moveCall({
419
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::repay_base`,
420
- arguments: [
421
- tx.object(manager.address),
422
- tx.object(this.#config.MARGIN_REGISTRY_ID),
423
- tx.object(baseMarginPool.address),
424
- tx.object.option({
425
- type: 'u64',
426
- value: amount ? tx.pure.u64(convertQuantity(amount, baseCoin.scalar)) : null,
427
- }),
428
- tx.object.clock(),
429
- ],
430
- typeArguments: [baseCoin.type, quoteCoin.type],
431
- });
436
+ return tx.add(
437
+ marginManagerMoveCalls.repayBase({
438
+ package: this.#config.MARGIN_PACKAGE_ID,
439
+ arguments: {
440
+ self: manager.address,
441
+ registry: this.#config.MARGIN_REGISTRY_ID,
442
+ marginPool: baseMarginPool.address,
443
+ amount: amount !== undefined ? convertQuantity(amount, baseCoin.scalar) : null,
444
+ },
445
+ typeArguments: [baseCoin.type, quoteCoin.type],
446
+ }),
447
+ );
432
448
  };
433
449
 
434
450
  /**
@@ -443,20 +459,18 @@ export class MarginManagerContract {
443
459
  const baseCoin = this.#config.getCoin(pool.baseCoin);
444
460
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
445
461
  const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
446
- return tx.moveCall({
447
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::repay_quote`,
448
- arguments: [
449
- tx.object(manager.address),
450
- tx.object(this.#config.MARGIN_REGISTRY_ID),
451
- tx.object(quoteMarginPool.address),
452
- tx.object.option({
453
- type: 'u64',
454
- value: amount ? tx.pure.u64(convertQuantity(amount, quoteCoin.scalar)) : null,
455
- }),
456
- tx.object.clock(),
457
- ],
458
- typeArguments: [baseCoin.type, quoteCoin.type],
459
- });
462
+ return tx.add(
463
+ marginManagerMoveCalls.repayQuote({
464
+ package: this.#config.MARGIN_PACKAGE_ID,
465
+ arguments: {
466
+ self: manager.address,
467
+ registry: this.#config.MARGIN_REGISTRY_ID,
468
+ marginPool: quoteMarginPool.address,
469
+ amount: amount !== undefined ? convertQuantity(amount, quoteCoin.scalar) : null,
470
+ },
471
+ typeArguments: [baseCoin.type, quoteCoin.type],
472
+ }),
473
+ );
460
474
  };
461
475
 
462
476
  /**
@@ -481,20 +495,25 @@ export class MarginManagerContract {
481
495
  const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
482
496
  const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
483
497
  const marginPool = debtIsBase ? baseMarginPool : quoteMarginPool;
484
- return tx.moveCall({
485
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::liquidate`,
486
- arguments: [
487
- tx.object(managerAddress),
488
- tx.object(this.#config.MARGIN_REGISTRY_ID),
489
- tx.object(baseCoin.priceInfoObjectId!),
490
- tx.object(quoteCoin.priceInfoObjectId!),
491
- tx.object(marginPool.address),
492
- tx.object(pool.address),
493
- repayCoin,
494
- tx.object.clock(),
495
- ],
496
- typeArguments: [baseCoin.type, quoteCoin.type, debtIsBase ? baseCoin.type : quoteCoin.type],
497
- });
498
+ return tx.add(
499
+ marginManagerMoveCalls.liquidate({
500
+ package: this.#config.MARGIN_PACKAGE_ID,
501
+ arguments: {
502
+ self: managerAddress,
503
+ registry: this.#config.MARGIN_REGISTRY_ID,
504
+ baseOracle: baseCoin.priceInfoObjectId!,
505
+ quoteOracle: quoteCoin.priceInfoObjectId!,
506
+ marginPool: marginPool.address,
507
+ pool: pool.address,
508
+ repayCoin,
509
+ },
510
+ typeArguments: [
511
+ baseCoin.type,
512
+ quoteCoin.type,
513
+ debtIsBase ? baseCoin.type : quoteCoin.type,
514
+ ],
515
+ }),
516
+ );
498
517
  };
499
518
 
500
519
  /**
@@ -509,11 +528,13 @@ export class MarginManagerContract {
509
528
  const baseCoin = this.#config.getCoin(pool.baseCoin);
510
529
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
511
530
 
512
- tx.moveCall({
513
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::set_margin_manager_referral`,
514
- arguments: [tx.object(manager.address), tx.object(referral)],
515
- typeArguments: [baseCoin.type, quoteCoin.type],
516
- });
531
+ tx.add(
532
+ marginManagerMoveCalls.setMarginManagerReferral({
533
+ package: this.#config.MARGIN_PACKAGE_ID,
534
+ arguments: { self: manager.address, referralCap: referral },
535
+ typeArguments: [baseCoin.type, quoteCoin.type],
536
+ }),
537
+ );
517
538
  };
518
539
 
519
540
  /**
@@ -528,11 +549,13 @@ export class MarginManagerContract {
528
549
  const baseCoin = this.#config.getCoin(pool.baseCoin);
529
550
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
530
551
 
531
- tx.moveCall({
532
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::unset_margin_manager_referral`,
533
- arguments: [tx.object(manager.address), tx.pure.id(pool.address)],
534
- typeArguments: [baseCoin.type, quoteCoin.type],
535
- });
552
+ tx.add(
553
+ marginManagerMoveCalls.unsetMarginManagerReferral({
554
+ package: this.#config.MARGIN_PACKAGE_ID,
555
+ arguments: { self: manager.address, poolId: pool.address },
556
+ typeArguments: [baseCoin.type, quoteCoin.type],
557
+ }),
558
+ );
536
559
  };
537
560
 
538
561
  // === Read-Only Functions ===
@@ -547,11 +570,13 @@ export class MarginManagerContract {
547
570
  const pool = this.#config.getPool(poolKey);
548
571
  const baseCoin = this.#config.getCoin(pool.baseCoin);
549
572
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
550
- return tx.moveCall({
551
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::owner`,
552
- arguments: [tx.object(marginManagerId)],
553
- typeArguments: [baseCoin.type, quoteCoin.type],
554
- });
573
+ return tx.add(
574
+ marginManagerMoveCalls.owner({
575
+ package: this.#config.MARGIN_PACKAGE_ID,
576
+ arguments: { self: marginManagerId },
577
+ typeArguments: [baseCoin.type, quoteCoin.type],
578
+ }),
579
+ );
555
580
  };
556
581
 
557
582
  /**
@@ -564,11 +589,13 @@ export class MarginManagerContract {
564
589
  const pool = this.#config.getPool(poolKey);
565
590
  const baseCoin = this.#config.getCoin(pool.baseCoin);
566
591
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
567
- return tx.moveCall({
568
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::deepbook_pool`,
569
- arguments: [tx.object(marginManagerId)],
570
- typeArguments: [baseCoin.type, quoteCoin.type],
571
- });
592
+ return tx.add(
593
+ marginManagerMoveCalls.deepbookPool({
594
+ package: this.#config.MARGIN_PACKAGE_ID,
595
+ arguments: { self: marginManagerId },
596
+ typeArguments: [baseCoin.type, quoteCoin.type],
597
+ }),
598
+ );
572
599
  };
573
600
 
574
601
  /**
@@ -581,11 +608,13 @@ export class MarginManagerContract {
581
608
  const pool = this.#config.getPool(poolKey);
582
609
  const baseCoin = this.#config.getCoin(pool.baseCoin);
583
610
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
584
- return tx.moveCall({
585
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::margin_pool_id`,
586
- arguments: [tx.object(marginManagerId)],
587
- typeArguments: [baseCoin.type, quoteCoin.type],
588
- });
611
+ return tx.add(
612
+ marginManagerMoveCalls.marginPoolId({
613
+ package: this.#config.MARGIN_PACKAGE_ID,
614
+ arguments: { self: marginManagerId },
615
+ typeArguments: [baseCoin.type, quoteCoin.type],
616
+ }),
617
+ );
589
618
  };
590
619
 
591
620
  /**
@@ -598,11 +627,13 @@ export class MarginManagerContract {
598
627
  const pool = this.#config.getPool(poolKey);
599
628
  const baseCoin = this.#config.getCoin(pool.baseCoin);
600
629
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
601
- return tx.moveCall({
602
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::borrowed_shares`,
603
- arguments: [tx.object(marginManagerId)],
604
- typeArguments: [baseCoin.type, quoteCoin.type],
605
- });
630
+ return tx.add(
631
+ marginManagerMoveCalls.borrowedShares({
632
+ package: this.#config.MARGIN_PACKAGE_ID,
633
+ arguments: { self: marginManagerId },
634
+ typeArguments: [baseCoin.type, quoteCoin.type],
635
+ }),
636
+ );
606
637
  };
607
638
 
608
639
  /**
@@ -615,11 +646,13 @@ export class MarginManagerContract {
615
646
  const pool = this.#config.getPool(poolKey);
616
647
  const baseCoin = this.#config.getCoin(pool.baseCoin);
617
648
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
618
- return tx.moveCall({
619
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::borrowed_base_shares`,
620
- arguments: [tx.object(marginManagerId)],
621
- typeArguments: [baseCoin.type, quoteCoin.type],
622
- });
649
+ return tx.add(
650
+ marginManagerMoveCalls.borrowedBaseShares({
651
+ package: this.#config.MARGIN_PACKAGE_ID,
652
+ arguments: { self: marginManagerId },
653
+ typeArguments: [baseCoin.type, quoteCoin.type],
654
+ }),
655
+ );
623
656
  };
624
657
 
625
658
  /**
@@ -632,11 +665,13 @@ export class MarginManagerContract {
632
665
  const pool = this.#config.getPool(poolKey);
633
666
  const baseCoin = this.#config.getCoin(pool.baseCoin);
634
667
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
635
- return tx.moveCall({
636
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::borrowed_quote_shares`,
637
- arguments: [tx.object(marginManagerId)],
638
- typeArguments: [baseCoin.type, quoteCoin.type],
639
- });
668
+ return tx.add(
669
+ marginManagerMoveCalls.borrowedQuoteShares({
670
+ package: this.#config.MARGIN_PACKAGE_ID,
671
+ arguments: { self: marginManagerId },
672
+ typeArguments: [baseCoin.type, quoteCoin.type],
673
+ }),
674
+ );
640
675
  };
641
676
 
642
677
  /**
@@ -649,11 +684,13 @@ export class MarginManagerContract {
649
684
  const pool = this.#config.getPool(poolKey);
650
685
  const baseCoin = this.#config.getCoin(pool.baseCoin);
651
686
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
652
- return tx.moveCall({
653
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::has_base_debt`,
654
- arguments: [tx.object(marginManagerId)],
655
- typeArguments: [baseCoin.type, quoteCoin.type],
656
- });
687
+ return tx.add(
688
+ marginManagerMoveCalls.hasBaseDebt({
689
+ package: this.#config.MARGIN_PACKAGE_ID,
690
+ arguments: { self: marginManagerId },
691
+ typeArguments: [baseCoin.type, quoteCoin.type],
692
+ }),
693
+ );
657
694
  };
658
695
 
659
696
  /**
@@ -666,11 +703,13 @@ export class MarginManagerContract {
666
703
  const pool = this.#config.getPool(poolKey);
667
704
  const baseCoin = this.#config.getCoin(pool.baseCoin);
668
705
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
669
- return tx.moveCall({
670
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::balance_manager`,
671
- arguments: [tx.object(marginManagerId)],
672
- typeArguments: [baseCoin.type, quoteCoin.type],
673
- });
706
+ return tx.add(
707
+ marginManagerMoveCalls.balanceManager({
708
+ package: this.#config.MARGIN_PACKAGE_ID,
709
+ arguments: { self: marginManagerId },
710
+ typeArguments: [baseCoin.type, quoteCoin.type],
711
+ }),
712
+ );
674
713
  };
675
714
 
676
715
  /**
@@ -683,11 +722,13 @@ export class MarginManagerContract {
683
722
  const pool = this.#config.getPool(poolKey);
684
723
  const baseCoin = this.#config.getCoin(pool.baseCoin);
685
724
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
686
- return tx.moveCall({
687
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::calculate_assets`,
688
- arguments: [tx.object(marginManagerId), tx.object(pool.address)],
689
- typeArguments: [baseCoin.type, quoteCoin.type],
690
- });
725
+ return tx.add(
726
+ marginManagerMoveCalls.calculateAssets({
727
+ package: this.#config.MARGIN_PACKAGE_ID,
728
+ arguments: { self: marginManagerId, pool: pool.address },
729
+ typeArguments: [baseCoin.type, quoteCoin.type],
730
+ }),
731
+ );
691
732
  };
692
733
 
693
734
  /**
@@ -704,11 +745,13 @@ export class MarginManagerContract {
704
745
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
705
746
  const debtCoin = this.#config.getCoin(coinKey);
706
747
  const marginPool = this.#config.getMarginPool(coinKey);
707
- return tx.moveCall({
708
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::calculate_debts`,
709
- arguments: [tx.object(marginManagerId), tx.object(marginPool.address), tx.object.clock()],
710
- typeArguments: [baseCoin.type, quoteCoin.type, debtCoin.type],
711
- });
748
+ return tx.add(
749
+ marginManagerMoveCalls.calculateDebts({
750
+ package: this.#config.MARGIN_PACKAGE_ID,
751
+ arguments: { self: marginManagerId, marginPool: marginPool.address },
752
+ typeArguments: [baseCoin.type, quoteCoin.type, debtCoin.type],
753
+ }),
754
+ );
712
755
  };
713
756
 
714
757
  /**
@@ -726,20 +769,21 @@ export class MarginManagerContract {
726
769
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
727
770
  const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
728
771
  const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
729
- return tx.moveCall({
730
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::manager_state`,
731
- arguments: [
732
- tx.object(marginManagerId),
733
- tx.object(this.#config.MARGIN_REGISTRY_ID),
734
- tx.object(baseCoin.priceInfoObjectId!),
735
- tx.object(quoteCoin.priceInfoObjectId!),
736
- tx.object(pool.address),
737
- tx.object(baseMarginPool.address),
738
- tx.object(quoteMarginPool.address),
739
- tx.object.clock(),
740
- ],
741
- typeArguments: [baseCoin.type, quoteCoin.type],
742
- });
772
+ return tx.add(
773
+ marginManagerMoveCalls.managerState({
774
+ package: this.#config.MARGIN_PACKAGE_ID,
775
+ arguments: {
776
+ self: marginManagerId,
777
+ registry: this.#config.MARGIN_REGISTRY_ID,
778
+ baseOracle: baseCoin.priceInfoObjectId!,
779
+ quoteOracle: quoteCoin.priceInfoObjectId!,
780
+ pool: pool.address,
781
+ baseMarginPool: baseMarginPool.address,
782
+ quoteMarginPool: quoteMarginPool.address,
783
+ },
784
+ typeArguments: [baseCoin.type, quoteCoin.type],
785
+ }),
786
+ );
743
787
  };
744
788
 
745
789
  /**
@@ -752,11 +796,13 @@ export class MarginManagerContract {
752
796
  const pool = this.#config.getPool(poolKey);
753
797
  const baseCoin = this.#config.getCoin(pool.baseCoin);
754
798
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
755
- return tx.moveCall({
756
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::base_balance`,
757
- arguments: [tx.object(marginManagerId)],
758
- typeArguments: [baseCoin.type, quoteCoin.type],
759
- });
799
+ return tx.add(
800
+ marginManagerMoveCalls.baseBalance({
801
+ package: this.#config.MARGIN_PACKAGE_ID,
802
+ arguments: { self: marginManagerId },
803
+ typeArguments: [baseCoin.type, quoteCoin.type],
804
+ }),
805
+ );
760
806
  };
761
807
 
762
808
  /**
@@ -769,11 +815,13 @@ export class MarginManagerContract {
769
815
  const pool = this.#config.getPool(poolKey);
770
816
  const baseCoin = this.#config.getCoin(pool.baseCoin);
771
817
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
772
- return tx.moveCall({
773
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::quote_balance`,
774
- arguments: [tx.object(marginManagerId)],
775
- typeArguments: [baseCoin.type, quoteCoin.type],
776
- });
818
+ return tx.add(
819
+ marginManagerMoveCalls.quoteBalance({
820
+ package: this.#config.MARGIN_PACKAGE_ID,
821
+ arguments: { self: marginManagerId },
822
+ typeArguments: [baseCoin.type, quoteCoin.type],
823
+ }),
824
+ );
777
825
  };
778
826
 
779
827
  /**
@@ -786,11 +834,13 @@ export class MarginManagerContract {
786
834
  const pool = this.#config.getPool(poolKey);
787
835
  const baseCoin = this.#config.getCoin(pool.baseCoin);
788
836
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
789
- return tx.moveCall({
790
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::deep_balance`,
791
- arguments: [tx.object(marginManagerId)],
792
- typeArguments: [baseCoin.type, quoteCoin.type],
793
- });
837
+ return tx.add(
838
+ marginManagerMoveCalls.deepBalance({
839
+ package: this.#config.MARGIN_PACKAGE_ID,
840
+ arguments: { self: marginManagerId },
841
+ typeArguments: [baseCoin.type, quoteCoin.type],
842
+ }),
843
+ );
794
844
  };
795
845
 
796
846
  /**
@@ -805,11 +855,13 @@ export class MarginManagerContract {
805
855
  const pool = this.#config.getPool(poolKey);
806
856
  const baseCoin = this.#config.getCoin(pool.baseCoin);
807
857
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
808
- return tx.moveCall({
809
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::balance_manager_id`,
810
- arguments: [tx.object(marginManagerId)],
811
- typeArguments: [baseCoin.type, quoteCoin.type],
812
- });
858
+ return tx.add(
859
+ marginManagerMoveCalls.balanceManagerId({
860
+ package: this.#config.MARGIN_PACKAGE_ID,
861
+ arguments: { self: marginManagerId },
862
+ typeArguments: [baseCoin.type, quoteCoin.type],
863
+ }),
864
+ );
813
865
  };
814
866
 
815
867
  /**
@@ -822,11 +874,13 @@ export class MarginManagerContract {
822
874
  const pool = this.#config.getPool(poolKey);
823
875
  const baseCoin = this.#config.getCoin(pool.baseCoin);
824
876
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
825
- return tx.moveCall({
826
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::get_balance_manager_referral_id`,
827
- arguments: [tx.object(marginManagerId), tx.pure.id(pool.address)],
828
- typeArguments: [baseCoin.type, quoteCoin.type],
829
- });
877
+ return tx.add(
878
+ marginManagerMoveCalls.getBalanceManagerReferralId({
879
+ package: this.#config.MARGIN_PACKAGE_ID,
880
+ arguments: { self: marginManagerId, poolId: pool.address },
881
+ typeArguments: [baseCoin.type, quoteCoin.type],
882
+ }),
883
+ );
830
884
  };
831
885
 
832
886
  /**
@@ -839,11 +893,13 @@ export class MarginManagerContract {
839
893
  const pool = this.#config.getPool(poolKey);
840
894
  const baseCoin = this.#config.getCoin(pool.baseCoin);
841
895
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
842
- return tx.moveCall({
843
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::account_exists`,
844
- arguments: [tx.object(marginManagerId), tx.object(pool.address)],
845
- typeArguments: [baseCoin.type, quoteCoin.type],
846
- });
896
+ return tx.add(
897
+ marginManagerMoveCalls.accountExists({
898
+ package: this.#config.MARGIN_PACKAGE_ID,
899
+ arguments: { self: marginManagerId, pool: pool.address },
900
+ typeArguments: [baseCoin.type, quoteCoin.type],
901
+ }),
902
+ );
847
903
  };
848
904
 
849
905
  /**
@@ -856,11 +912,13 @@ export class MarginManagerContract {
856
912
  const pool = this.#config.getPool(poolKey);
857
913
  const baseCoin = this.#config.getCoin(pool.baseCoin);
858
914
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
859
- return tx.moveCall({
860
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::account`,
861
- arguments: [tx.object(marginManagerId), tx.object(pool.address)],
862
- typeArguments: [baseCoin.type, quoteCoin.type],
863
- });
915
+ return tx.add(
916
+ marginManagerMoveCalls.account({
917
+ package: this.#config.MARGIN_PACKAGE_ID,
918
+ arguments: { self: marginManagerId, pool: pool.address },
919
+ typeArguments: [baseCoin.type, quoteCoin.type],
920
+ }),
921
+ );
864
922
  };
865
923
 
866
924
  /**
@@ -874,11 +932,13 @@ export class MarginManagerContract {
874
932
  const pool = this.#config.getPool(poolKey);
875
933
  const baseCoin = this.#config.getCoin(pool.baseCoin);
876
934
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
877
- return tx.moveCall({
878
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::account_open_orders`,
879
- arguments: [tx.object(marginManagerId), tx.object(pool.address)],
880
- typeArguments: [baseCoin.type, quoteCoin.type],
881
- });
935
+ return tx.add(
936
+ marginManagerMoveCalls.accountOpenOrders({
937
+ package: this.#config.MARGIN_PACKAGE_ID,
938
+ arguments: { self: marginManagerId, pool: pool.address },
939
+ typeArguments: [baseCoin.type, quoteCoin.type],
940
+ }),
941
+ );
882
942
  };
883
943
 
884
944
  /**
@@ -892,11 +952,13 @@ export class MarginManagerContract {
892
952
  const pool = this.#config.getPool(poolKey);
893
953
  const baseCoin = this.#config.getCoin(pool.baseCoin);
894
954
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
895
- return tx.moveCall({
896
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::get_account_order_details`,
897
- arguments: [tx.object(marginManagerId), tx.object(pool.address)],
898
- typeArguments: [baseCoin.type, quoteCoin.type],
899
- });
955
+ return tx.add(
956
+ marginManagerMoveCalls.getAccountOrderDetails({
957
+ package: this.#config.MARGIN_PACKAGE_ID,
958
+ arguments: { self: marginManagerId, pool: pool.address },
959
+ typeArguments: [baseCoin.type, quoteCoin.type],
960
+ }),
961
+ );
900
962
  };
901
963
 
902
964
  /**
@@ -910,11 +972,13 @@ export class MarginManagerContract {
910
972
  const pool = this.#config.getPool(poolKey);
911
973
  const baseCoin = this.#config.getCoin(pool.baseCoin);
912
974
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
913
- return tx.moveCall({
914
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::locked_balance`,
915
- arguments: [tx.object(marginManagerId), tx.object(pool.address)],
916
- typeArguments: [baseCoin.type, quoteCoin.type],
917
- });
975
+ return tx.add(
976
+ marginManagerMoveCalls.lockedBalance({
977
+ package: this.#config.MARGIN_PACKAGE_ID,
978
+ arguments: { self: marginManagerId, pool: pool.address },
979
+ typeArguments: [baseCoin.type, quoteCoin.type],
980
+ }),
981
+ );
918
982
  };
919
983
 
920
984
  /**
@@ -945,20 +1009,21 @@ export class MarginManagerContract {
945
1009
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
946
1010
  const inputPrice = convertPrice(price, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar);
947
1011
  const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
948
- return tx.moveCall({
949
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::can_place_limit_order`,
950
- arguments: [
951
- tx.object(marginManagerId),
952
- tx.object(pool.address),
953
- tx.pure.u64(inputPrice),
954
- tx.pure.u64(inputQuantity),
955
- tx.pure.bool(isBid),
956
- tx.pure.bool(payWithDeep),
957
- tx.pure.u64(expireTimestamp),
958
- tx.object.clock(),
959
- ],
960
- typeArguments: [baseCoin.type, quoteCoin.type],
961
- });
1012
+ return tx.add(
1013
+ marginManagerMoveCalls.canPlaceLimitOrder({
1014
+ package: this.#config.MARGIN_PACKAGE_ID,
1015
+ arguments: {
1016
+ self: marginManagerId,
1017
+ pool: pool.address,
1018
+ price: inputPrice,
1019
+ quantity: inputQuantity,
1020
+ isBid,
1021
+ payWithDeep,
1022
+ expireTimestamp,
1023
+ },
1024
+ typeArguments: [baseCoin.type, quoteCoin.type],
1025
+ }),
1026
+ );
962
1027
  };
963
1028
 
964
1029
  /**
@@ -984,17 +1049,18 @@ export class MarginManagerContract {
984
1049
  const baseCoin = this.#config.getCoin(pool.baseCoin);
985
1050
  const quoteCoin = this.#config.getCoin(pool.quoteCoin);
986
1051
  const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
987
- return tx.moveCall({
988
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::can_place_market_order`,
989
- arguments: [
990
- tx.object(marginManagerId),
991
- tx.object(pool.address),
992
- tx.pure.u64(inputQuantity),
993
- tx.pure.bool(isBid),
994
- tx.pure.bool(payWithDeep),
995
- tx.object.clock(),
996
- ],
997
- typeArguments: [baseCoin.type, quoteCoin.type],
998
- });
1052
+ return tx.add(
1053
+ marginManagerMoveCalls.canPlaceMarketOrder({
1054
+ package: this.#config.MARGIN_PACKAGE_ID,
1055
+ arguments: {
1056
+ self: marginManagerId,
1057
+ pool: pool.address,
1058
+ quantity: inputQuantity,
1059
+ isBid,
1060
+ payWithDeep,
1061
+ },
1062
+ typeArguments: [baseCoin.type, quoteCoin.type],
1063
+ }),
1064
+ );
999
1065
  };
1000
1066
  }