@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
@@ -1,4 +1,5 @@
1
1
  import { convertQuantity } from "../utils/conversion.mjs";
2
+ import { borrowShares, deepbookPoolAllowed, id, interestRate, lastUpdateTimestamp, maxUtilizationRate, minBorrow, mintSupplierCap, mintSupplyReferral, protocolSpread, supplyCap, supplyShares, totalBorrow, totalSupply, userSupplyAmount, userSupplyShares, withdraw, withdrawReferralFees } from "../contracts/deepbook_margin/margin_pool.mjs";
2
3
  import { coinWithBalance } from "@mysten/sui/transactions";
3
4
 
4
5
  //#region src/transactions/marginPool.ts
@@ -12,10 +13,10 @@ var MarginPoolContract = class {
12
13
  */
13
14
  constructor(config) {
14
15
  this.mintSupplierCap = () => (tx) => {
15
- return tx.moveCall({
16
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::mint_supplier_cap`,
17
- arguments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.object.clock()]
18
- });
16
+ return tx.add(mintSupplierCap({
17
+ package: this.#config.MARGIN_PACKAGE_ID,
18
+ arguments: { registry: this.#config.MARGIN_REGISTRY_ID }
19
+ }));
19
20
  };
20
21
  this.supplyToMarginPool = (coinKey, supplierCap, amountToDeposit, referralId) => (tx) => {
21
22
  tx.setSenderIfNotSet(this.#config.address);
@@ -46,157 +47,160 @@ var MarginPoolContract = class {
46
47
  const marginPool = this.#config.getMarginPool(coinKey);
47
48
  const coin = this.#config.getCoin(coinKey);
48
49
  const withdrawInput = amountToWithdraw !== void 0 ? convertQuantity(amountToWithdraw, coin.scalar) : null;
49
- return tx.moveCall({
50
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::withdraw`,
51
- arguments: [
52
- tx.object(marginPool.address),
53
- tx.object(this.#config.MARGIN_REGISTRY_ID),
50
+ return tx.add(withdraw({
51
+ package: this.#config.MARGIN_PACKAGE_ID,
52
+ arguments: {
53
+ self: marginPool.address,
54
+ registry: this.#config.MARGIN_REGISTRY_ID,
54
55
  supplierCap,
55
- tx.pure.option("u64", withdrawInput),
56
- tx.object.clock()
57
- ],
56
+ amount: withdrawInput
57
+ },
58
58
  typeArguments: [marginPool.type]
59
- });
59
+ }));
60
60
  };
61
61
  this.mintSupplyReferral = (coinKey) => (tx) => {
62
62
  const marginPool = this.#config.getMarginPool(coinKey);
63
- tx.moveCall({
64
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::mint_supply_referral`,
65
- arguments: [
66
- tx.object(marginPool.address),
67
- tx.object(this.#config.MARGIN_REGISTRY_ID),
68
- tx.object.clock()
69
- ],
63
+ tx.add(mintSupplyReferral({
64
+ package: this.#config.MARGIN_PACKAGE_ID,
65
+ arguments: {
66
+ self: marginPool.address,
67
+ registry: this.#config.MARGIN_REGISTRY_ID
68
+ },
70
69
  typeArguments: [marginPool.type]
71
- });
70
+ }));
72
71
  };
73
72
  this.withdrawReferralFees = (coinKey, referralId) => (tx) => {
74
73
  const marginPool = this.#config.getMarginPool(coinKey);
75
- return tx.moveCall({
76
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::withdraw_referral_fees`,
77
- arguments: [
78
- tx.object(marginPool.address),
79
- tx.object(this.#config.MARGIN_REGISTRY_ID),
80
- tx.object(referralId)
81
- ],
74
+ return tx.add(withdrawReferralFees({
75
+ package: this.#config.MARGIN_PACKAGE_ID,
76
+ arguments: {
77
+ self: marginPool.address,
78
+ registry: this.#config.MARGIN_REGISTRY_ID,
79
+ referral: referralId
80
+ },
82
81
  typeArguments: [marginPool.type]
83
- });
82
+ }));
84
83
  };
85
84
  this.getId = (coinKey) => (tx) => {
86
85
  const marginPool = this.#config.getMarginPool(coinKey);
87
- return tx.moveCall({
88
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::id`,
89
- arguments: [tx.object(marginPool.address)],
86
+ return tx.add(id({
87
+ package: this.#config.MARGIN_PACKAGE_ID,
88
+ arguments: { self: marginPool.address },
90
89
  typeArguments: [marginPool.type]
91
- });
90
+ }));
92
91
  };
93
92
  this.deepbookPoolAllowed = (coinKey, deepbookPoolId) => (tx) => {
94
93
  const marginPool = this.#config.getMarginPool(coinKey);
95
- return tx.moveCall({
96
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::deepbook_pool_allowed`,
97
- arguments: [tx.object(marginPool.address), tx.pure.id(deepbookPoolId)],
94
+ return tx.add(deepbookPoolAllowed({
95
+ package: this.#config.MARGIN_PACKAGE_ID,
96
+ arguments: {
97
+ self: marginPool.address,
98
+ deepbookPoolId
99
+ },
98
100
  typeArguments: [marginPool.type]
99
- });
101
+ }));
100
102
  };
101
103
  this.totalSupply = (coinKey) => (tx) => {
102
104
  const marginPool = this.#config.getMarginPool(coinKey);
103
- return tx.moveCall({
104
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::total_supply`,
105
- arguments: [tx.object(marginPool.address)],
105
+ return tx.add(totalSupply({
106
+ package: this.#config.MARGIN_PACKAGE_ID,
107
+ arguments: { self: marginPool.address },
106
108
  typeArguments: [marginPool.type]
107
- });
109
+ }));
108
110
  };
109
111
  this.supplyShares = (coinKey) => (tx) => {
110
112
  const marginPool = this.#config.getMarginPool(coinKey);
111
- return tx.moveCall({
112
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::supply_shares`,
113
- arguments: [tx.object(marginPool.address)],
113
+ return tx.add(supplyShares({
114
+ package: this.#config.MARGIN_PACKAGE_ID,
115
+ arguments: { self: marginPool.address },
114
116
  typeArguments: [marginPool.type]
115
- });
117
+ }));
116
118
  };
117
119
  this.totalBorrow = (coinKey) => (tx) => {
118
120
  const marginPool = this.#config.getMarginPool(coinKey);
119
- return tx.moveCall({
120
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::total_borrow`,
121
- arguments: [tx.object(marginPool.address)],
121
+ return tx.add(totalBorrow({
122
+ package: this.#config.MARGIN_PACKAGE_ID,
123
+ arguments: { self: marginPool.address },
122
124
  typeArguments: [marginPool.type]
123
- });
125
+ }));
124
126
  };
125
127
  this.borrowShares = (coinKey) => (tx) => {
126
128
  const marginPool = this.#config.getMarginPool(coinKey);
127
- return tx.moveCall({
128
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::borrow_shares`,
129
- arguments: [tx.object(marginPool.address)],
129
+ return tx.add(borrowShares({
130
+ package: this.#config.MARGIN_PACKAGE_ID,
131
+ arguments: { self: marginPool.address },
130
132
  typeArguments: [marginPool.type]
131
- });
133
+ }));
132
134
  };
133
135
  this.lastUpdateTimestamp = (coinKey) => (tx) => {
134
136
  const marginPool = this.#config.getMarginPool(coinKey);
135
- return tx.moveCall({
136
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::last_update_timestamp`,
137
- arguments: [tx.object(marginPool.address)],
137
+ return tx.add(lastUpdateTimestamp({
138
+ package: this.#config.MARGIN_PACKAGE_ID,
139
+ arguments: { self: marginPool.address },
138
140
  typeArguments: [marginPool.type]
139
- });
141
+ }));
140
142
  };
141
143
  this.supplyCap = (coinKey) => (tx) => {
142
144
  const marginPool = this.#config.getMarginPool(coinKey);
143
- return tx.moveCall({
144
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::supply_cap`,
145
- arguments: [tx.object(marginPool.address)],
145
+ return tx.add(supplyCap({
146
+ package: this.#config.MARGIN_PACKAGE_ID,
147
+ arguments: { self: marginPool.address },
146
148
  typeArguments: [marginPool.type]
147
- });
149
+ }));
148
150
  };
149
151
  this.maxUtilizationRate = (coinKey) => (tx) => {
150
152
  const marginPool = this.#config.getMarginPool(coinKey);
151
- return tx.moveCall({
152
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::max_utilization_rate`,
153
- arguments: [tx.object(marginPool.address)],
153
+ return tx.add(maxUtilizationRate({
154
+ package: this.#config.MARGIN_PACKAGE_ID,
155
+ arguments: { self: marginPool.address },
154
156
  typeArguments: [marginPool.type]
155
- });
157
+ }));
156
158
  };
157
159
  this.protocolSpread = (coinKey) => (tx) => {
158
160
  const marginPool = this.#config.getMarginPool(coinKey);
159
- return tx.moveCall({
160
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::protocol_spread`,
161
- arguments: [tx.object(marginPool.address)],
161
+ return tx.add(protocolSpread({
162
+ package: this.#config.MARGIN_PACKAGE_ID,
163
+ arguments: { self: marginPool.address },
162
164
  typeArguments: [marginPool.type]
163
- });
165
+ }));
164
166
  };
165
167
  this.minBorrow = (coinKey) => (tx) => {
166
168
  const marginPool = this.#config.getMarginPool(coinKey);
167
- return tx.moveCall({
168
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::min_borrow`,
169
- arguments: [tx.object(marginPool.address)],
169
+ return tx.add(minBorrow({
170
+ package: this.#config.MARGIN_PACKAGE_ID,
171
+ arguments: { self: marginPool.address },
170
172
  typeArguments: [marginPool.type]
171
- });
173
+ }));
172
174
  };
173
175
  this.interestRate = (coinKey) => (tx) => {
174
176
  const marginPool = this.#config.getMarginPool(coinKey);
175
- return tx.moveCall({
176
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::interest_rate`,
177
- arguments: [tx.object(marginPool.address)],
177
+ return tx.add(interestRate({
178
+ package: this.#config.MARGIN_PACKAGE_ID,
179
+ arguments: { self: marginPool.address },
178
180
  typeArguments: [marginPool.type]
179
- });
181
+ }));
180
182
  };
181
183
  this.userSupplyShares = (coinKey, supplierCapId) => (tx) => {
182
184
  const marginPool = this.#config.getMarginPool(coinKey);
183
- return tx.moveCall({
184
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::user_supply_shares`,
185
- arguments: [tx.object(marginPool.address), tx.pure.id(supplierCapId)],
185
+ return tx.add(userSupplyShares({
186
+ package: this.#config.MARGIN_PACKAGE_ID,
187
+ arguments: {
188
+ self: marginPool.address,
189
+ supplierCapId
190
+ },
186
191
  typeArguments: [marginPool.type]
187
- });
192
+ }));
188
193
  };
189
194
  this.userSupplyAmount = (coinKey, supplierCapId) => (tx) => {
190
195
  const marginPool = this.#config.getMarginPool(coinKey);
191
- return tx.moveCall({
192
- target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::user_supply_amount`,
193
- arguments: [
194
- tx.object(marginPool.address),
195
- tx.pure.id(supplierCapId),
196
- tx.object.clock()
197
- ],
196
+ return tx.add(userSupplyAmount({
197
+ package: this.#config.MARGIN_PACKAGE_ID,
198
+ arguments: {
199
+ self: marginPool.address,
200
+ supplierCapId
201
+ },
198
202
  typeArguments: [marginPool.type]
199
- });
203
+ }));
200
204
  };
201
205
  this.#config = config;
202
206
  }
@@ -1 +1 @@
1
- {"version":3,"file":"marginPool.mjs","names":["#config"],"sources":["../../src/transactions/marginPool.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { coinWithBalance } from '@mysten/sui/transactions';\nimport type { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';\n\nimport type { DeepBookConfig } from '../utils/config.js';\nimport { convertQuantity } from '../utils/conversion.js';\n\n/**\n * MarginPoolContract class for managing MarginPool operations.\n */\nexport class MarginPoolContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for MarginPoolContract\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * @description Mint a supplier cap for margin pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tmintSupplierCap = () => (tx: Transaction) => {\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::mint_supplier_cap`,\n\t\t\targuments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.object.clock()],\n\t\t});\n\t};\n\n\t/**\n\t * @description Supply to a margin pool\n\t * @param {string} coinKey The key to identify the pool\n\t * @param {TransactionObjectArgument} supplierCap The supplier cap object\n\t * @param {number} amountToDeposit The amount to deposit\n\t * @param {string} referralId The ID of the referral\n\t * @returns A function that takes a Transaction object\n\t */\n\tsupplyToMarginPool =\n\t\t(\n\t\t\tcoinKey: string,\n\t\t\tsupplierCap: TransactionObjectArgument,\n\t\t\tamountToDeposit: number,\n\t\t\treferralId?: string,\n\t\t) =>\n\t\t(tx: Transaction) => {\n\t\t\ttx.setSenderIfNotSet(this.#config.address);\n\t\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tconst depositInput = convertQuantity(amountToDeposit, coin.scalar);\n\t\t\tconst supply = coinWithBalance({\n\t\t\t\ttype: coin.type,\n\t\t\t\tbalance: depositInput,\n\t\t\t});\n\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::supply`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(marginPool.address),\n\t\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\t\tsupplierCap,\n\t\t\t\t\tsupply,\n\t\t\t\t\ttx.object.option({\n\t\t\t\t\t\ttype: '0x2::object::ID',\n\t\t\t\t\t\tvalue: referralId ? tx.pure.id(referralId) : null,\n\t\t\t\t\t}),\n\t\t\t\t\ttx.object.clock(),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Withdraw from a margin pool. If amountToWithdraw is not provided, withdraws all.\n\t * @param {string} coinKey The key to identify the pool\n\t * @param {TransactionObjectArgument} supplierCap The supplier cap object\n\t * @param {number} [amountToWithdraw] The amount to withdraw. If omitted, withdraws all.\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawFromMarginPool =\n\t\t(coinKey: string, supplierCap: TransactionObjectArgument, amountToWithdraw?: number) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tconst withdrawInput =\n\t\t\t\tamountToWithdraw !== undefined ? convertQuantity(amountToWithdraw, coin.scalar) : null;\n\t\t\treturn tx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::withdraw`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(marginPool.address),\n\t\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\t\tsupplierCap,\n\t\t\t\t\ttx.pure.option('u64', withdrawInput),\n\t\t\t\t\ttx.object.clock(),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Mint a referral for a margin pool\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tmintSupplyReferral = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::mint_supply_referral`,\n\t\t\targuments: [\n\t\t\t\ttx.object(marginPool.address),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Withdraw referral fees from a margin pool\n\t * @param {string} coinKey The key to identify the pool\n\t * @param {string} referralId The ID of the referral\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawReferralFees = (coinKey: string, referralId: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::withdraw_referral_fees`,\n\t\t\targuments: [\n\t\t\t\ttx.object(marginPool.address),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(referralId),\n\t\t\t],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t// === Read-only/View Functions ===\n\n\t/**\n\t * @description Get the margin pool ID\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetId = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::id`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Check if a deepbook pool is allowed for borrowing\n\t * @param {string} coinKey The key to identify the margin pool\n\t * @param {string} deepbookPoolId The ID of the deepbook pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tdeepbookPoolAllowed = (coinKey: string, deepbookPoolId: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::deepbook_pool_allowed`,\n\t\t\targuments: [tx.object(marginPool.address), tx.pure.id(deepbookPoolId)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the total supply amount\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\ttotalSupply = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::total_supply`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the total supply shares\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tsupplyShares = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::supply_shares`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the total borrow amount\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\ttotalBorrow = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::total_borrow`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the total borrow shares\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tborrowShares = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::borrow_shares`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the last update timestamp\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tlastUpdateTimestamp = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::last_update_timestamp`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the supply cap\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tsupplyCap = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::supply_cap`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the max utilization rate\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tmaxUtilizationRate = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::max_utilization_rate`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the protocol spread\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tprotocolSpread = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::protocol_spread`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the minimum borrow amount\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tminBorrow = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::min_borrow`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the current interest rate\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tinterestRate = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::interest_rate`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get user supply shares for a supplier cap\n\t * @param {string} coinKey The key to identify the pool\n\t * @param {string} supplierCapId The ID of the supplier cap\n\t * @returns A function that takes a Transaction object\n\t */\n\tuserSupplyShares = (coinKey: string, supplierCapId: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::user_supply_shares`,\n\t\t\targuments: [tx.object(marginPool.address), tx.pure.id(supplierCapId)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get user supply amount for a supplier cap\n\t * @param {string} coinKey The key to identify the pool\n\t * @param {string} supplierCapId The ID of the supplier cap\n\t * @returns A function that takes a Transaction object\n\t */\n\tuserSupplyAmount = (coinKey: string, supplierCapId: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::user_supply_amount`,\n\t\t\targuments: [tx.object(marginPool.address), tx.pure.id(supplierCapId), tx.object.clock()],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n}\n"],"mappings":";;;;;;;AAWA,IAAa,qBAAb,MAAgC;CAC/B;;;;CAKA,YAAY,QAAwB;gCAQX,OAAoB;AAC5C,UAAO,GAAG,SAAS;IAClB,QAAQ,GAAG,MAAKA,OAAQ,kBAAkB;IAC1C,WAAW,CAAC,GAAG,OAAO,MAAKA,OAAQ,mBAAmB,EAAE,GAAG,OAAO,OAAO,CAAC;IAC1E,CAAC;;6BAaD,SACA,aACA,iBACA,gBAEA,OAAoB;AACpB,MAAG,kBAAkB,MAAKA,OAAQ,QAAQ;GAC1C,MAAM,aAAa,MAAKA,OAAQ,cAAc,QAAQ;GACtD,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;GAC1C,MAAM,eAAe,gBAAgB,iBAAiB,KAAK,OAAO;GAClE,MAAM,SAAS,gBAAgB;IAC9B,MAAM,KAAK;IACX,SAAS;IACT,CAAC;AAEF,MAAG,SAAS;IACX,QAAQ,GAAG,MAAKA,OAAQ,kBAAkB;IAC1C,WAAW;KACV,GAAG,OAAO,WAAW,QAAQ;KAC7B,GAAG,OAAO,MAAKA,OAAQ,mBAAmB;KAC1C;KACA;KACA,GAAG,OAAO,OAAO;MAChB,MAAM;MACN,OAAO,aAAa,GAAG,KAAK,GAAG,WAAW,GAAG;MAC7C,CAAC;KACF,GAAG,OAAO,OAAO;KACjB;IACD,eAAe,CAAC,WAAW,KAA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D,UAAO,GAAG,SAAS;IAClB,QAAQ,GAAG,MAAKA,OAAQ,kBAAkB;IAC1C,WAAW,CAAC,GAAG,OAAO,WAAW,QAAQ,CAAC;IAC1C,eAAe,CAAC,WAAW,KAAK;IAChC,CAAC;;2BASiB,SAAiB,mBAA2B,OAAoB;GACnF,MAAM,aAAa,MAAKA,OAAQ,cAAc,QAAQ;AACtD,UAAO,GAAG,SAAS;IAClB,QAAQ,GAAG,MAAKA,OAAQ,kBAAkB;IAC1C,WAAW,CAAC,GAAG,OAAO,WAAW,QAAQ,EAAE,GAAG,KAAK,GAAG,cAAc,CAAC;IACrE,eAAe,CAAC,WAAW,KAAK;IAChC,CAAC;;2BASiB,SAAiB,mBAA2B,OAAoB;GACnF,MAAM,aAAa,MAAKA,OAAQ,cAAc,QAAQ;AACtD,UAAO,GAAG,SAAS;IAClB,QAAQ,GAAG,MAAKA,OAAQ,kBAAkB;IAC1C,WAAW;KAAC,GAAG,OAAO,WAAW,QAAQ;KAAE,GAAG,KAAK,GAAG,cAAc;KAAE,GAAG,OAAO,OAAO;KAAC;IACxF,eAAe,CAAC,WAAW,KAAK;IAChC,CAAC;;AA9TF,QAAKA,SAAU"}
1
+ {"version":3,"file":"marginPool.mjs","names":["marginPoolMoveCalls.mintSupplierCap","#config","marginPoolMoveCalls.withdraw","marginPoolMoveCalls.mintSupplyReferral","marginPoolMoveCalls.withdrawReferralFees","marginPoolMoveCalls.id","marginPoolMoveCalls.deepbookPoolAllowed","marginPoolMoveCalls.totalSupply","marginPoolMoveCalls.supplyShares","marginPoolMoveCalls.totalBorrow","marginPoolMoveCalls.borrowShares","marginPoolMoveCalls.lastUpdateTimestamp","marginPoolMoveCalls.supplyCap","marginPoolMoveCalls.maxUtilizationRate","marginPoolMoveCalls.protocolSpread","marginPoolMoveCalls.minBorrow","marginPoolMoveCalls.interestRate","marginPoolMoveCalls.userSupplyShares","marginPoolMoveCalls.userSupplyAmount"],"sources":["../../src/transactions/marginPool.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { coinWithBalance } from '@mysten/sui/transactions';\nimport type { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';\n\nimport type { DeepBookConfig } from '../utils/config.js';\nimport { convertQuantity } from '../utils/conversion.js';\nimport * as marginPoolMoveCalls from '../contracts/deepbook_margin/margin_pool.js';\n\n/**\n * MarginPoolContract class for managing MarginPool operations.\n */\nexport class MarginPoolContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for MarginPoolContract\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * @description Mint a supplier cap for margin pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tmintSupplierCap = () => (tx: Transaction) => {\n\t\treturn tx.add(\n\t\t\tmarginPoolMoveCalls.mintSupplierCap({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { registry: this.#config.MARGIN_REGISTRY_ID },\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Supply to a margin pool\n\t * @param {string} coinKey The key to identify the pool\n\t * @param {TransactionObjectArgument} supplierCap The supplier cap object\n\t * @param {number} amountToDeposit The amount to deposit\n\t * @param {string} referralId The ID of the referral\n\t * @returns A function that takes a Transaction object\n\t */\n\tsupplyToMarginPool =\n\t\t(\n\t\t\tcoinKey: string,\n\t\t\tsupplierCap: TransactionObjectArgument,\n\t\t\tamountToDeposit: number,\n\t\t\treferralId?: string,\n\t\t) =>\n\t\t(tx: Transaction) => {\n\t\t\ttx.setSenderIfNotSet(this.#config.address);\n\t\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tconst depositInput = convertQuantity(amountToDeposit, coin.scalar);\n\t\t\tconst supply = coinWithBalance({\n\t\t\t\ttype: coin.type,\n\t\t\t\tbalance: depositInput,\n\t\t\t});\n\n\t\t\t// NOTE: left as a positional moveCall (not codegen). This builder's\n\t\t\t// coinWithBalance + `tx.object.option` (an on-chain option::none MoveCall\n\t\t\t// for the Option<ID> referral) interleave commands in a way that a\n\t\t\t// generated named-arg call reorders — so migrating it would change the\n\t\t\t// emitted PTB. Kept verbatim to stay byte-identical.\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::supply`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(marginPool.address),\n\t\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\t\tsupplierCap,\n\t\t\t\t\tsupply,\n\t\t\t\t\ttx.object.option({\n\t\t\t\t\t\ttype: '0x2::object::ID',\n\t\t\t\t\t\tvalue: referralId ? tx.pure.id(referralId) : null,\n\t\t\t\t\t}),\n\t\t\t\t\ttx.object.clock(),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Withdraw from a margin pool. If amountToWithdraw is not provided, withdraws all.\n\t * @param {string} coinKey The key to identify the pool\n\t * @param {TransactionObjectArgument} supplierCap The supplier cap object\n\t * @param {number} [amountToWithdraw] The amount to withdraw. If omitted, withdraws all.\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawFromMarginPool =\n\t\t(coinKey: string, supplierCap: TransactionObjectArgument, amountToWithdraw?: number) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tconst withdrawInput =\n\t\t\t\tamountToWithdraw !== undefined ? convertQuantity(amountToWithdraw, coin.scalar) : null;\n\t\t\treturn tx.add(\n\t\t\t\tmarginPoolMoveCalls.withdraw({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tself: marginPool.address,\n\t\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\t\tsupplierCap,\n\t\t\t\t\t\tamount: withdrawInput,\n\t\t\t\t\t},\n\t\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Mint a referral for a margin pool\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tmintSupplyReferral = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\ttx.add(\n\t\t\tmarginPoolMoveCalls.mintSupplyReferral({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address, registry: this.#config.MARGIN_REGISTRY_ID },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Withdraw referral fees from a margin pool\n\t * @param {string} coinKey The key to identify the pool\n\t * @param {string} referralId The ID of the referral\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawReferralFees = (coinKey: string, referralId: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.add(\n\t\t\tmarginPoolMoveCalls.withdrawReferralFees({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: marginPool.address,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\treferral: referralId,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t// === Read-only/View Functions ===\n\n\t/**\n\t * @description Get the margin pool ID\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetId = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.add(\n\t\t\tmarginPoolMoveCalls.id({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Check if a deepbook pool is allowed for borrowing\n\t * @param {string} coinKey The key to identify the margin pool\n\t * @param {string} deepbookPoolId The ID of the deepbook pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tdeepbookPoolAllowed = (coinKey: string, deepbookPoolId: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.add(\n\t\t\tmarginPoolMoveCalls.deepbookPoolAllowed({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address, deepbookPoolId },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the total supply amount\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\ttotalSupply = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.add(\n\t\t\tmarginPoolMoveCalls.totalSupply({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the total supply shares\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tsupplyShares = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.add(\n\t\t\tmarginPoolMoveCalls.supplyShares({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the total borrow amount\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\ttotalBorrow = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.add(\n\t\t\tmarginPoolMoveCalls.totalBorrow({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the total borrow shares\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tborrowShares = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.add(\n\t\t\tmarginPoolMoveCalls.borrowShares({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the last update timestamp\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tlastUpdateTimestamp = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.add(\n\t\t\tmarginPoolMoveCalls.lastUpdateTimestamp({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the supply cap\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tsupplyCap = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.add(\n\t\t\tmarginPoolMoveCalls.supplyCap({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the max utilization rate\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tmaxUtilizationRate = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.add(\n\t\t\tmarginPoolMoveCalls.maxUtilizationRate({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the protocol spread\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tprotocolSpread = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.add(\n\t\t\tmarginPoolMoveCalls.protocolSpread({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the minimum borrow amount\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tminBorrow = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.add(\n\t\t\tmarginPoolMoveCalls.minBorrow({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the current interest rate\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tinterestRate = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.add(\n\t\t\tmarginPoolMoveCalls.interestRate({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get user supply shares for a supplier cap\n\t * @param {string} coinKey The key to identify the pool\n\t * @param {string} supplierCapId The ID of the supplier cap\n\t * @returns A function that takes a Transaction object\n\t */\n\tuserSupplyShares = (coinKey: string, supplierCapId: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.add(\n\t\t\tmarginPoolMoveCalls.userSupplyShares({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address, supplierCapId },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get user supply amount for a supplier cap\n\t * @param {string} coinKey The key to identify the pool\n\t * @param {string} supplierCapId The ID of the supplier cap\n\t * @returns A function that takes a Transaction object\n\t */\n\tuserSupplyAmount = (coinKey: string, supplierCapId: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.add(\n\t\t\tmarginPoolMoveCalls.userSupplyAmount({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address, supplierCapId },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\n\t\t);\n\t};\n}\n"],"mappings":";;;;;;;;AAYA,IAAa,qBAAb,MAAgC;CAC/B;;;;CAKA,YAAY,QAAwB;gCAQX,OAAoB;AAC5C,UAAO,GAAG,IACTA,gBAAoC;IACnC,SAAS,MAAKC,OAAQ;IACtB,WAAW,EAAE,UAAU,MAAKA,OAAQ,oBAAoB;IACxD,CAAC,CACF;;6BAaA,SACA,aACA,iBACA,gBAEA,OAAoB;AACpB,MAAG,kB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AAE,MAAM,WAAW,SAAS;IACvC,eAAe,CAAC,WAAW,KAAK;IAChC,CAAC,CACF;;uBAQc,aAAqB,OAAoB;GACxD,MAAM,aAAa,MAAKA,OAAQ,cAAc,QAAQ;AACtD,UAAO,GAAG,IACTe,aAAiC;IAChC,SAAS,MAAKf,OAAQ;IACtB,WAAW,EAAE,MAAM,WAAW,SAAS;IACvC,eAAe,CAAC,WAAW,KAAK;IAChC,CAAC,CACF;;2BASkB,SAAiB,mBAA2B,OAAoB;GACnF,MAAM,aAAa,MAAKA,OAAQ,cAAc,QAAQ;AACtD,UAAO,GAAG,IACTgB,iBAAqC;IACpC,SAAS,MAAKhB,OAAQ;IACtB,WAAW;KAAE,MAAM,WAAW;KAAS;KAAe;IACtD,eAAe,CAAC,WAAW,KAAK;IAChC,CAAC,CACF;;2BASkB,SAAiB,mBAA2B,OAAoB;GACnF,MAAM,aAAa,MAAKA,OAAQ,cAAc,QAAQ;AACtD,UAAO,GAAG,IACTiB,iBAAqC;IACpC,SAAS,MAAKjB,OAAQ;IACtB,WAAW;KAAE,MAAM,WAAW;KAAS;KAAe;IACtD,eAAe,CAAC,WAAW,KAAK;IAChC,CAAC,CACF;;AAlWD,QAAKA,SAAU"}
@@ -1,5 +1,5 @@
1
1
  import { DeepBookConfig } from "../utils/config.mjs";
2
- import * as _mysten_sui_transactions102 from "@mysten/sui/transactions";
2
+ import * as _mysten_sui_transactions106 from "@mysten/sui/transactions";
3
3
  import { Transaction } from "@mysten/sui/transactions";
4
4
 
5
5
  //#region src/transactions/marginRegistry.d.ts
@@ -17,83 +17,90 @@ declare class MarginRegistryContract {
17
17
  * @param {string} poolKey The key to identify the pool
18
18
  * @returns A function that takes a Transaction object
19
19
  */
20
- poolEnabled: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions102.TransactionResult;
20
+ poolEnabled: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions106.TransactionResult;
21
21
  /**
22
22
  * @description Get the margin pool ID for a given asset
23
23
  * @param {string} coinKey The key to identify the coin
24
24
  * @returns A function that takes a Transaction object
25
25
  */
26
- getMarginPoolId: (coinKey: string) => (tx: Transaction) => _mysten_sui_transactions102.TransactionResult;
26
+ getMarginPoolId: (coinKey: string) => (tx: Transaction) => _mysten_sui_transactions106.TransactionResult;
27
27
  /**
28
28
  * @description Get the margin pool IDs (base and quote) for a deepbook pool
29
29
  * @param {string} poolKey The key to identify the pool
30
30
  * @returns A function that takes a Transaction object
31
31
  */
32
- getDeepbookPoolMarginPoolIds: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions102.TransactionResult;
32
+ getDeepbookPoolMarginPoolIds: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions106.TransactionResult;
33
33
  /**
34
34
  * @description Get the margin manager IDs for a given owner
35
35
  * @param {string} owner The owner address
36
36
  * @returns A function that takes a Transaction object
37
37
  */
38
- getMarginManagerIds: (owner: string) => (tx: Transaction) => _mysten_sui_transactions102.TransactionResult;
38
+ getMarginManagerIds: (owner: string) => (tx: Transaction) => _mysten_sui_transactions106.TransactionResult;
39
39
  /**
40
40
  * @description Get the base margin pool ID for a deepbook pool
41
41
  * @param {string} poolKey The key to identify the pool
42
42
  * @returns A function that takes a Transaction object
43
43
  */
44
- baseMarginPoolId: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions102.TransactionResult;
44
+ baseMarginPoolId: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions106.TransactionResult;
45
45
  /**
46
46
  * @description Get the quote margin pool ID for a deepbook pool
47
47
  * @param {string} poolKey The key to identify the pool
48
48
  * @returns A function that takes a Transaction object
49
49
  */
50
- quoteMarginPoolId: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions102.TransactionResult;
50
+ quoteMarginPoolId: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions106.TransactionResult;
51
51
  /**
52
52
  * @description Get the minimum withdraw risk ratio for a deepbook pool
53
53
  * @param {string} poolKey The key to identify the pool
54
54
  * @returns A function that takes a Transaction object
55
55
  */
56
- minWithdrawRiskRatio: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions102.TransactionResult;
56
+ minWithdrawRiskRatio: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions106.TransactionResult;
57
57
  /**
58
58
  * @description Get the minimum borrow risk ratio for a deepbook pool
59
59
  * @param {string} poolKey The key to identify the pool
60
60
  * @returns A function that takes a Transaction object
61
61
  */
62
- minBorrowRiskRatio: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions102.TransactionResult;
62
+ minBorrowRiskRatio: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions106.TransactionResult;
63
+ /**
64
+ * @description Get the minimum risk ratio required to open a new position on
65
+ * a deepbook pool. Distinct from `minBorrowRiskRatio`, which gates borrowing.
66
+ * @param {string} poolKey The key to identify the pool
67
+ * @returns A function that takes a Transaction object
68
+ */
69
+ minOpenRiskRatio: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions106.TransactionResult;
63
70
  /**
64
71
  * @description Get the liquidation risk ratio for a deepbook pool
65
72
  * @param {string} poolKey The key to identify the pool
66
73
  * @returns A function that takes a Transaction object
67
74
  */
68
- liquidationRiskRatio: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions102.TransactionResult;
75
+ liquidationRiskRatio: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions106.TransactionResult;
69
76
  /**
70
77
  * @description Get the target liquidation risk ratio for a deepbook pool
71
78
  * @param {string} poolKey The key to identify the pool
72
79
  * @returns A function that takes a Transaction object
73
80
  */
74
- targetLiquidationRiskRatio: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions102.TransactionResult;
81
+ targetLiquidationRiskRatio: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions106.TransactionResult;
75
82
  /**
76
83
  * @description Get the user liquidation reward for a deepbook pool
77
84
  * @param {string} poolKey The key to identify the pool
78
85
  * @returns A function that takes a Transaction object
79
86
  */
80
- userLiquidationReward: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions102.TransactionResult;
87
+ userLiquidationReward: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions106.TransactionResult;
81
88
  /**
82
89
  * @description Get the pool liquidation reward for a deepbook pool
83
90
  * @param {string} poolKey The key to identify the pool
84
91
  * @returns A function that takes a Transaction object
85
92
  */
86
- poolLiquidationReward: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions102.TransactionResult;
93
+ poolLiquidationReward: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions106.TransactionResult;
87
94
  /**
88
95
  * @description Get all allowed maintainer cap IDs
89
96
  * @returns A function that takes a Transaction object
90
97
  */
91
- allowedMaintainers: () => (tx: Transaction) => _mysten_sui_transactions102.TransactionResult;
98
+ allowedMaintainers: () => (tx: Transaction) => _mysten_sui_transactions106.TransactionResult;
92
99
  /**
93
100
  * @description Get all allowed pause cap IDs
94
101
  * @returns A function that takes a Transaction object
95
102
  */
96
- allowedPauseCaps: () => (tx: Transaction) => _mysten_sui_transactions102.TransactionResult;
103
+ allowedPauseCaps: () => (tx: Transaction) => _mysten_sui_transactions106.TransactionResult;
97
104
  }
98
105
  //#endregion
99
106
  export { MarginRegistryContract };
@@ -1 +1 @@
1
- {"version":3,"file":"marginRegistry.d.mts","names":[],"sources":["../../src/transactions/marginRegistry.ts"],"mappings":";;;;;;;;cASa,sBAAA;EAAA;;;;cAMA,MAAA,EAAQ,cAAA;EAyBwB;;;;;EAhB5C,WAAA,GAAe,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EAyDN;;;;;EAzC7C,eAAA,GAAmB,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EAmFR;;;;;EArE/C,4BAAA,GAAgC,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EA+GlB;;;;;EAjGlD,mBAAA,GAAuB,KAAA,cAAmB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAA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