@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
@@ -5,6 +5,7 @@ import { coinWithBalance } from '@mysten/sui/transactions';
5
5
 
6
6
  import type { DeepBookConfig } from '../utils/config.js';
7
7
  import { convertQuantity } from '../utils/conversion.js';
8
+ import * as liquidationVaultMoveCalls from '../contracts/margin_liquidation/liquidation_vault.js';
8
9
 
9
10
  /**
10
11
  * MarginLiquidationsContract class for managing LiquidationVault operations.
@@ -25,10 +26,12 @@ export class MarginLiquidationsContract {
25
26
  * @returns A function that takes a Transaction object
26
27
  */
27
28
  createLiquidationVault = (liquidationAdminCap: string) => (tx: Transaction) => {
28
- tx.moveCall({
29
- target: `${this.#config.LIQUIDATION_PACKAGE_ID}::liquidation_vault::create_liquidation_vault`,
30
- arguments: [tx.object(liquidationAdminCap)],
31
- });
29
+ tx.add(
30
+ liquidationVaultMoveCalls.createLiquidationVault({
31
+ package: this.#config.LIQUIDATION_PACKAGE_ID,
32
+ arguments: { LiquidationCap: liquidationAdminCap },
33
+ }),
34
+ );
32
35
  };
33
36
 
34
37
  /**
@@ -47,11 +50,13 @@ export class MarginLiquidationsContract {
47
50
  type: coin.type,
48
51
  balance: convertQuantity(amount, coin.scalar),
49
52
  });
50
- tx.moveCall({
51
- target: `${this.#config.LIQUIDATION_PACKAGE_ID}::liquidation_vault::deposit`,
52
- arguments: [tx.object(vaultId), tx.object(liquidationAdminCap), depositCoin],
53
- typeArguments: [coin.type],
54
- });
53
+ tx.add(
54
+ liquidationVaultMoveCalls.deposit({
55
+ package: this.#config.LIQUIDATION_PACKAGE_ID,
56
+ arguments: { self: vaultId, LiquidationCap: liquidationAdminCap, coin: depositCoin },
57
+ typeArguments: [coin.type],
58
+ }),
59
+ );
55
60
  };
56
61
 
57
62
  /**
@@ -66,15 +71,17 @@ export class MarginLiquidationsContract {
66
71
  (vaultId: string, liquidationAdminCap: string, coinKey: string, amount: number) =>
67
72
  (tx: Transaction) => {
68
73
  const coin = this.#config.getCoin(coinKey);
69
- return tx.moveCall({
70
- target: `${this.#config.LIQUIDATION_PACKAGE_ID}::liquidation_vault::withdraw`,
71
- arguments: [
72
- tx.object(vaultId),
73
- tx.object(liquidationAdminCap),
74
- tx.pure.u64(convertQuantity(amount, coin.scalar)),
75
- ],
76
- typeArguments: [coin.type],
77
- });
74
+ return tx.add(
75
+ liquidationVaultMoveCalls.withdraw({
76
+ package: this.#config.LIQUIDATION_PACKAGE_ID,
77
+ arguments: {
78
+ self: vaultId,
79
+ LiquidationCap: liquidationAdminCap,
80
+ amount: convertQuantity(amount, coin.scalar),
81
+ },
82
+ typeArguments: [coin.type],
83
+ }),
84
+ );
78
85
  };
79
86
 
80
87
  /**
@@ -94,27 +101,30 @@ export class MarginLiquidationsContract {
94
101
  const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
95
102
  const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
96
103
 
104
+ // Build the Option arg first so its pure input registers ahead of the
105
+ // object inputs (matches the original positional ordering — byte-identical).
97
106
  const repayAmountArg =
98
107
  repayAmount !== undefined
99
108
  ? tx.pure.option('u64', convertQuantity(repayAmount, baseCoin.scalar))
100
109
  : tx.pure.option('u64', null);
101
110
 
102
- tx.moveCall({
103
- target: `${this.#config.LIQUIDATION_PACKAGE_ID}::liquidation_vault::liquidate_base`,
104
- arguments: [
105
- tx.object(vaultId),
106
- tx.object(managerAddress),
107
- tx.object(this.#config.MARGIN_REGISTRY_ID),
108
- tx.object(baseCoin.priceInfoObjectId!),
109
- tx.object(quoteCoin.priceInfoObjectId!),
110
- tx.object(baseMarginPool.address),
111
- tx.object(quoteMarginPool.address),
112
- tx.object(pool.address),
113
- repayAmountArg,
114
- tx.object.clock(),
115
- ],
116
- typeArguments: [baseCoin.type, quoteCoin.type],
117
- });
111
+ tx.add(
112
+ liquidationVaultMoveCalls.liquidateBase({
113
+ package: this.#config.LIQUIDATION_PACKAGE_ID,
114
+ arguments: {
115
+ self: vaultId,
116
+ marginManager: managerAddress,
117
+ registry: this.#config.MARGIN_REGISTRY_ID,
118
+ baseOracle: baseCoin.priceInfoObjectId!,
119
+ quoteOracle: quoteCoin.priceInfoObjectId!,
120
+ baseMarginPool: baseMarginPool.address,
121
+ quoteMarginPool: quoteMarginPool.address,
122
+ pool: pool.address,
123
+ repayAmount: repayAmountArg,
124
+ },
125
+ typeArguments: [baseCoin.type, quoteCoin.type],
126
+ }),
127
+ );
118
128
  };
119
129
 
120
130
  /**
@@ -134,27 +144,30 @@ export class MarginLiquidationsContract {
134
144
  const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
135
145
  const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
136
146
 
147
+ // Build the Option arg first so its pure input registers ahead of the
148
+ // object inputs (matches the original positional ordering — byte-identical).
137
149
  const repayAmountArg =
138
150
  repayAmount !== undefined
139
151
  ? tx.pure.option('u64', convertQuantity(repayAmount, quoteCoin.scalar))
140
152
  : tx.pure.option('u64', null);
141
153
 
142
- tx.moveCall({
143
- target: `${this.#config.LIQUIDATION_PACKAGE_ID}::liquidation_vault::liquidate_quote`,
144
- arguments: [
145
- tx.object(vaultId),
146
- tx.object(managerAddress),
147
- tx.object(this.#config.MARGIN_REGISTRY_ID),
148
- tx.object(baseCoin.priceInfoObjectId!),
149
- tx.object(quoteCoin.priceInfoObjectId!),
150
- tx.object(baseMarginPool.address),
151
- tx.object(quoteMarginPool.address),
152
- tx.object(pool.address),
153
- repayAmountArg,
154
- tx.object.clock(),
155
- ],
156
- typeArguments: [baseCoin.type, quoteCoin.type],
157
- });
154
+ tx.add(
155
+ liquidationVaultMoveCalls.liquidateQuote({
156
+ package: this.#config.LIQUIDATION_PACKAGE_ID,
157
+ arguments: {
158
+ self: vaultId,
159
+ marginManager: managerAddress,
160
+ registry: this.#config.MARGIN_REGISTRY_ID,
161
+ baseOracle: baseCoin.priceInfoObjectId!,
162
+ quoteOracle: quoteCoin.priceInfoObjectId!,
163
+ baseMarginPool: baseMarginPool.address,
164
+ quoteMarginPool: quoteMarginPool.address,
165
+ pool: pool.address,
166
+ repayAmount: repayAmountArg,
167
+ },
168
+ typeArguments: [baseCoin.type, quoteCoin.type],
169
+ }),
170
+ );
158
171
  };
159
172
 
160
173
  // === Read-Only Functions ===
@@ -167,10 +180,12 @@ export class MarginLiquidationsContract {
167
180
  */
168
181
  balance = (vaultId: string, coinKey: string) => (tx: Transaction) => {
169
182
  const coin = this.#config.getCoin(coinKey);
170
- return tx.moveCall({
171
- target: `${this.#config.LIQUIDATION_PACKAGE_ID}::liquidation_vault::balance`,
172
- arguments: [tx.object(vaultId)],
173
- typeArguments: [coin.type],
174
- });
183
+ return tx.add(
184
+ liquidationVaultMoveCalls.balance({
185
+ package: this.#config.LIQUIDATION_PACKAGE_ID,
186
+ arguments: { self: vaultId },
187
+ typeArguments: [coin.type],
188
+ }),
189
+ );
175
190
  };
176
191
  }
@@ -11,6 +11,8 @@ import type { DeepBookConfig } from '../utils/config.js';
11
11
  import type { MarginPoolConfigParams, InterestConfigParams } from '../types/index.js';
12
12
  import { FLOAT_SCALAR } from '../utils/config.js';
13
13
  import { convertQuantity, convertRate } from '../utils/conversion.js';
14
+ import * as marginPoolMoveCalls from '../contracts/deepbook_margin/margin_pool.js';
15
+ import * as protocolConfigMoveCalls from '../contracts/deepbook_margin/protocol_config.js';
14
16
 
15
17
  /**
16
18
  * DeepBookMaintainerContract class for managing maintainer actions.
@@ -45,16 +47,17 @@ export class MarginMaintainerContract {
45
47
  */
46
48
  createMarginPool = (coinKey: string, poolConfig: TransactionArgument) => (tx: Transaction) => {
47
49
  const coin = this.#config.getCoin(coinKey);
48
- tx.moveCall({
49
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::create_margin_pool`,
50
- arguments: [
51
- tx.object(this.#config.MARGIN_REGISTRY_ID),
52
- poolConfig,
53
- tx.object(this.#marginMaintainerCap()),
54
- tx.object.clock(),
55
- ],
56
- typeArguments: [coin.type],
57
- });
50
+ tx.add(
51
+ marginPoolMoveCalls.createMarginPool({
52
+ package: this.#config.MARGIN_PACKAGE_ID,
53
+ arguments: {
54
+ registry: this.#config.MARGIN_REGISTRY_ID,
55
+ config: poolConfig,
56
+ maintainerCap: this.#marginMaintainerCap(),
57
+ },
58
+ typeArguments: [coin.type],
59
+ }),
60
+ );
58
61
  };
59
62
 
60
63
  /**
@@ -84,10 +87,15 @@ export class MarginMaintainerContract {
84
87
  })(tx)
85
88
  : this.newMarginPoolConfig(coinKey, marginPoolConfig)(tx);
86
89
  const interestConfigObject = this.newInterestConfig(interestConfig)(tx);
87
- return tx.moveCall({
88
- target: `${this.#config.MARGIN_PACKAGE_ID}::protocol_config::new_protocol_config`,
89
- arguments: [marginPoolConfigObject, interestConfigObject],
90
- });
90
+ return tx.add(
91
+ protocolConfigMoveCalls.newProtocolConfig({
92
+ package: this.#config.MARGIN_PACKAGE_ID,
93
+ arguments: {
94
+ marginPoolConfig: marginPoolConfigObject,
95
+ interestConfig: interestConfigObject,
96
+ },
97
+ }),
98
+ );
91
99
  };
92
100
 
93
101
  /**
@@ -100,15 +108,17 @@ export class MarginMaintainerContract {
100
108
  (coinKey: string, marginPoolConfig: MarginPoolConfigParams) => (tx: Transaction) => {
101
109
  const coin = this.#config.getCoin(coinKey);
102
110
  const { supplyCap, maxUtilizationRate, protocolSpread, minBorrow } = marginPoolConfig;
103
- return tx.moveCall({
104
- target: `${this.#config.MARGIN_PACKAGE_ID}::protocol_config::new_margin_pool_config`,
105
- arguments: [
106
- tx.pure.u64(convertQuantity(supplyCap, coin.scalar)),
107
- tx.pure.u64(convertRate(maxUtilizationRate, FLOAT_SCALAR)),
108
- tx.pure.u64(convertRate(protocolSpread, FLOAT_SCALAR)),
109
- tx.pure.u64(convertQuantity(minBorrow, coin.scalar)),
110
- ],
111
- });
111
+ return tx.add(
112
+ protocolConfigMoveCalls.newMarginPoolConfig({
113
+ package: this.#config.MARGIN_PACKAGE_ID,
114
+ arguments: {
115
+ supplyCap: convertQuantity(supplyCap, coin.scalar),
116
+ maxUtilizationRate: convertRate(maxUtilizationRate, FLOAT_SCALAR),
117
+ protocolSpread: convertRate(protocolSpread, FLOAT_SCALAR),
118
+ minBorrow: convertQuantity(minBorrow, coin.scalar),
119
+ },
120
+ }),
121
+ );
112
122
  };
113
123
 
114
124
  /**
@@ -139,18 +149,20 @@ export class MarginMaintainerContract {
139
149
  rateLimitRefillRatePerMs,
140
150
  rateLimitEnabled,
141
151
  } = marginPoolConfig;
142
- return tx.moveCall({
143
- target: `${this.#config.MARGIN_PACKAGE_ID}::protocol_config::new_margin_pool_config_with_rate_limit`,
144
- arguments: [
145
- tx.pure.u64(convertQuantity(supplyCap, coin.scalar)),
146
- tx.pure.u64(convertRate(maxUtilizationRate, FLOAT_SCALAR)),
147
- tx.pure.u64(convertRate(protocolSpread, FLOAT_SCALAR)),
148
- tx.pure.u64(convertQuantity(minBorrow, coin.scalar)),
149
- tx.pure.u64(convertQuantity(rateLimitCapacity, coin.scalar)),
150
- tx.pure.u64(convertQuantity(rateLimitRefillRatePerMs, coin.scalar)),
151
- tx.pure.bool(rateLimitEnabled),
152
- ],
153
- });
152
+ return tx.add(
153
+ protocolConfigMoveCalls.newMarginPoolConfigWithRateLimit({
154
+ package: this.#config.MARGIN_PACKAGE_ID,
155
+ arguments: {
156
+ supplyCap: convertQuantity(supplyCap, coin.scalar),
157
+ maxUtilizationRate: convertRate(maxUtilizationRate, FLOAT_SCALAR),
158
+ protocolSpread: convertRate(protocolSpread, FLOAT_SCALAR),
159
+ minBorrow: convertQuantity(minBorrow, coin.scalar),
160
+ rateLimitCapacity: convertQuantity(rateLimitCapacity, coin.scalar),
161
+ rateLimitRefillRatePerMs: convertQuantity(rateLimitRefillRatePerMs, coin.scalar),
162
+ rateLimitEnabled,
163
+ },
164
+ }),
165
+ );
154
166
  };
155
167
 
156
168
  /**
@@ -160,15 +172,17 @@ export class MarginMaintainerContract {
160
172
  */
161
173
  newInterestConfig = (interestConfig: InterestConfigParams) => (tx: Transaction) => {
162
174
  const { baseRate, baseSlope, optimalUtilization, excessSlope } = interestConfig;
163
- return tx.moveCall({
164
- target: `${this.#config.MARGIN_PACKAGE_ID}::protocol_config::new_interest_config`,
165
- arguments: [
166
- tx.pure.u64(convertRate(baseRate, FLOAT_SCALAR)),
167
- tx.pure.u64(convertRate(baseSlope, FLOAT_SCALAR)),
168
- tx.pure.u64(convertRate(optimalUtilization, FLOAT_SCALAR)),
169
- tx.pure.u64(convertRate(excessSlope, FLOAT_SCALAR)),
170
- ],
171
- });
175
+ return tx.add(
176
+ protocolConfigMoveCalls.newInterestConfig({
177
+ package: this.#config.MARGIN_PACKAGE_ID,
178
+ arguments: {
179
+ baseRate: convertRate(baseRate, FLOAT_SCALAR),
180
+ baseSlope: convertRate(baseSlope, FLOAT_SCALAR),
181
+ optimalUtilization: convertRate(optimalUtilization, FLOAT_SCALAR),
182
+ excessSlope: convertRate(excessSlope, FLOAT_SCALAR),
183
+ },
184
+ }),
185
+ );
172
186
  };
173
187
 
174
188
  /**
@@ -183,17 +197,18 @@ export class MarginMaintainerContract {
183
197
  (tx: Transaction) => {
184
198
  const deepbookPool = this.#config.getPool(deepbookPoolKey);
185
199
  const marginPool = this.#config.getMarginPool(coinKey);
186
- tx.moveCall({
187
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::enable_deepbook_pool_for_loan`,
188
- arguments: [
189
- tx.object(marginPool.address),
190
- tx.object(this.#config.MARGIN_REGISTRY_ID),
191
- tx.pure.id(deepbookPool.address),
192
- tx.object(marginPoolCap),
193
- tx.object.clock(),
194
- ],
195
- typeArguments: [marginPool.type],
196
- });
200
+ tx.add(
201
+ marginPoolMoveCalls.enableDeepbookPoolForLoan({
202
+ package: this.#config.MARGIN_PACKAGE_ID,
203
+ arguments: {
204
+ self: marginPool.address,
205
+ registry: this.#config.MARGIN_REGISTRY_ID,
206
+ deepbookPoolId: deepbookPool.address,
207
+ marginPoolCap,
208
+ },
209
+ typeArguments: [marginPool.type],
210
+ }),
211
+ );
197
212
  };
198
213
 
199
214
  /**
@@ -208,17 +223,18 @@ export class MarginMaintainerContract {
208
223
  (tx: Transaction) => {
209
224
  const deepbookPool = this.#config.getPool(deepbookPoolKey);
210
225
  const marginPool = this.#config.getMarginPool(coinKey);
211
- tx.moveCall({
212
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::disable_deepbook_pool_for_loan`,
213
- arguments: [
214
- tx.object(marginPool.address),
215
- tx.object(this.#config.MARGIN_REGISTRY_ID),
216
- tx.pure.id(deepbookPool.address),
217
- tx.object(marginPoolCap),
218
- tx.object.clock(),
219
- ],
220
- typeArguments: [marginPool.type],
221
- });
226
+ tx.add(
227
+ marginPoolMoveCalls.disableDeepbookPoolForLoan({
228
+ package: this.#config.MARGIN_PACKAGE_ID,
229
+ arguments: {
230
+ self: marginPool.address,
231
+ registry: this.#config.MARGIN_REGISTRY_ID,
232
+ deepbookPoolId: deepbookPool.address,
233
+ marginPoolCap,
234
+ },
235
+ typeArguments: [marginPool.type],
236
+ }),
237
+ );
222
238
  };
223
239
 
224
240
  /**
@@ -237,17 +253,18 @@ export class MarginMaintainerContract {
237
253
  (tx: Transaction) => {
238
254
  const marginPool = this.#config.getMarginPool(coinKey);
239
255
  const interestConfigObject = this.newInterestConfig(interestConfig)(tx);
240
- tx.moveCall({
241
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::update_interest_params`,
242
- arguments: [
243
- tx.object(marginPool.address),
244
- tx.object(this.#config.MARGIN_REGISTRY_ID),
245
- interestConfigObject,
246
- tx.object(marginPoolCap),
247
- tx.object.clock(),
248
- ],
249
- typeArguments: [marginPool.type],
250
- });
256
+ tx.add(
257
+ marginPoolMoveCalls.updateInterestParams({
258
+ package: this.#config.MARGIN_PACKAGE_ID,
259
+ arguments: {
260
+ self: marginPool.address,
261
+ registry: this.#config.MARGIN_REGISTRY_ID,
262
+ interestConfig: interestConfigObject,
263
+ marginPoolCap,
264
+ },
265
+ typeArguments: [marginPool.type],
266
+ }),
267
+ );
251
268
  };
252
269
 
253
270
  /**
@@ -277,16 +294,17 @@ export class MarginMaintainerContract {
277
294
  rateLimitEnabled: marginPoolConfig.rateLimitEnabled!,
278
295
  })(tx)
279
296
  : this.newMarginPoolConfig(coinKey, marginPoolConfig)(tx);
280
- tx.moveCall({
281
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::update_margin_pool_config`,
282
- arguments: [
283
- tx.object(marginPool.address),
284
- tx.object(this.#config.MARGIN_REGISTRY_ID),
285
- marginPoolConfigObject,
286
- tx.object(marginPoolCap),
287
- tx.object.clock(),
288
- ],
289
- typeArguments: [marginPool.type],
290
- });
297
+ tx.add(
298
+ marginPoolMoveCalls.updateMarginPoolConfig({
299
+ package: this.#config.MARGIN_PACKAGE_ID,
300
+ arguments: {
301
+ self: marginPool.address,
302
+ registry: this.#config.MARGIN_REGISTRY_ID,
303
+ marginPoolConfig: marginPoolConfigObject,
304
+ marginPoolCap,
305
+ },
306
+ typeArguments: [marginPool.type],
307
+ }),
308
+ );
291
309
  };
292
310
  }