@mysten/deepbook-v3 1.6.7 → 2.0.0
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.
- package/CHANGELOG.md +52 -0
- package/dist/_virtual/rolldown_runtime.mjs +18 -0
- package/dist/client.d.mts +9 -6
- package/dist/client.d.mts.map +1 -1
- package/dist/client.mjs +3 -2
- package/dist/client.mjs.map +1 -1
- package/dist/contracts/deepbook/account.d.mts +18 -18
- package/dist/contracts/deepbook/account.d.mts.map +1 -1
- package/dist/contracts/deepbook/deep_price.d.mts +3 -3
- package/dist/contracts/deepbook/deep_price.d.mts.map +1 -1
- package/dist/contracts/deepbook_margin/margin_manager.mjs +1 -319
- package/dist/contracts/deepbook_margin/margin_manager.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/margin_manager_upgraded.mjs +386 -0
- package/dist/contracts/deepbook_margin/margin_manager_upgraded.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/oracle.mjs +9 -0
- package/dist/contracts/deepbook_margin/oracle.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/pool_proxy.mjs +1 -383
- package/dist/contracts/deepbook_margin/pool_proxy.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/pool_proxy_upgraded.mjs +340 -0
- package/dist/contracts/deepbook_margin/pool_proxy_upgraded.mjs.map +1 -0
- package/dist/contracts/margin_liquidation/liquidation_vault.mjs +33 -17
- package/dist/contracts/margin_liquidation/liquidation_vault.mjs.map +1 -1
- package/dist/index.d.mts +4 -3
- package/dist/index.mjs +2 -2
- package/dist/pyth/PriceServiceConnection.d.mts +18 -3
- package/dist/pyth/PriceServiceConnection.d.mts.map +1 -1
- package/dist/pyth/PriceServiceConnection.mjs +35 -4
- package/dist/pyth/PriceServiceConnection.mjs.map +1 -1
- package/dist/queries/priceFeedQueries.mjs +50 -18
- package/dist/queries/priceFeedQueries.mjs.map +1 -1
- package/dist/transactions/balanceManager.d.mts +12 -12
- package/dist/transactions/deepbook.d.mts +20 -20
- package/dist/transactions/deepbookAdmin.d.mts +4 -4
- package/dist/transactions/deepbookAdmin.d.mts.map +1 -1
- package/dist/transactions/marginAdmin.d.mts +7 -7
- package/dist/transactions/marginAdmin.d.mts.map +1 -1
- package/dist/transactions/marginAdmin.mjs +2 -2
- package/dist/transactions/marginAdmin.mjs.map +1 -1
- package/dist/transactions/marginLiquidations.d.mts.map +1 -1
- package/dist/transactions/marginLiquidations.mjs +19 -7
- package/dist/transactions/marginLiquidations.mjs.map +1 -1
- package/dist/transactions/marginMaintainer.d.mts +5 -5
- package/dist/transactions/marginManager.d.mts +32 -32
- package/dist/transactions/marginManager.d.mts.map +1 -1
- package/dist/transactions/marginManager.mjs +43 -34
- package/dist/transactions/marginManager.mjs.map +1 -1
- package/dist/transactions/marginPool.d.mts +18 -18
- package/dist/transactions/marginTPSL.d.mts +10 -10
- package/dist/transactions/marginTPSL.d.mts.map +1 -1
- package/dist/transactions/marginTPSL.mjs +19 -10
- package/dist/transactions/marginTPSL.mjs.map +1 -1
- package/dist/transactions/poolProxy.d.mts +8 -8
- package/dist/transactions/poolProxy.d.mts.map +1 -1
- package/dist/transactions/poolProxy.mjs +34 -27
- package/dist/transactions/poolProxy.mjs.map +1 -1
- package/dist/types/index.d.mts +16 -1
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/utils/config.d.mts +30 -10
- package/dist/utils/config.d.mts.map +1 -1
- package/dist/utils/config.mjs +33 -4
- package/dist/utils/config.mjs.map +1 -1
- package/dist/utils/constants.d.mts +32 -1
- package/dist/utils/constants.d.mts.map +1 -1
- package/dist/utils/constants.mjs +54 -23
- package/dist/utils/constants.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +9 -1
- package/src/contracts/deepbook_margin/margin_manager.ts +140 -10
- package/src/contracts/deepbook_margin/margin_manager_upgraded.ts +651 -0
- package/src/contracts/deepbook_margin/oracle.ts +59 -0
- package/src/contracts/deepbook_margin/pool_proxy.ts +600 -584
- package/src/contracts/deepbook_margin/pool_proxy_upgraded.ts +614 -0
- package/src/contracts/margin_liquidation/liquidation_vault.ts +142 -0
- package/src/index.ts +4 -0
- package/src/pyth/PriceServiceConnection.ts +69 -8
- package/src/queries/priceFeedQueries.ts +74 -24
- package/src/transactions/marginAdmin.ts +2 -4
- package/src/transactions/marginLiquidations.ts +20 -6
- package/src/transactions/marginManager.ts +43 -33
- package/src/transactions/marginTPSL.ts +19 -9
- package/src/transactions/poolProxy.ts +34 -30
- package/src/types/index.ts +16 -0
- package/src/utils/config.ts +69 -9
- package/src/utils/constants.ts +88 -25
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { convertPrice, convertQuantity } from "../utils/conversion.mjs";
|
|
2
2
|
import { FLOAT_SCALAR } from "../utils/config.mjs";
|
|
3
|
-
import { _new, account, accountExists, accountOpenOrders, balanceManager, balanceManagerId, baseBalance,
|
|
3
|
+
import { _new, account, accountExists, accountOpenOrders, balanceManager, balanceManagerId, baseBalance, borrowedBaseShares, borrowedQuoteShares, borrowedShares, calculateAssets, calculateDebts, canPlaceLimitOrder, canPlaceMarketOrder, deepBalance, deepbookPool, getAccountOrderDetails, getBalanceManagerReferralId, hasBaseDebt, lockedBalance, marginPoolId, newWithInitializer, owner, quoteBalance, registerMarginManager, repayBase, repayQuote, setMarginManagerReferral, share, unregisterMarginManager, unsetMarginManagerReferral } from "../contracts/deepbook_margin/margin_manager.mjs";
|
|
4
|
+
import { margin_manager_upgraded_exports } from "../contracts/deepbook_margin/margin_manager_upgraded.mjs";
|
|
4
5
|
import { coinWithBalance } from "@mysten/sui/transactions";
|
|
5
6
|
|
|
6
7
|
//#region src/transactions/marginManager.ts
|
|
@@ -96,13 +97,13 @@ var MarginManagerContract = class {
|
|
|
96
97
|
type: depositCoin.type,
|
|
97
98
|
balance: convertQuantity(params.amount, depositCoin.scalar)
|
|
98
99
|
}) : params.coin;
|
|
99
|
-
tx.add(deposit({
|
|
100
|
+
tx.add(this.#oracleCalls.deposit({
|
|
100
101
|
package: this.#config.MARGIN_PACKAGE_ID,
|
|
101
102
|
arguments: {
|
|
102
103
|
self: manager,
|
|
103
104
|
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
104
|
-
baseOracle: baseCoin
|
|
105
|
-
quoteOracle: quoteCoin
|
|
105
|
+
baseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),
|
|
106
|
+
quoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),
|
|
106
107
|
coin
|
|
107
108
|
},
|
|
108
109
|
typeArguments: [
|
|
@@ -122,13 +123,13 @@ var MarginManagerContract = class {
|
|
|
122
123
|
type: baseCoin.type,
|
|
123
124
|
balance: convertQuantity(params.amount, baseCoin.scalar)
|
|
124
125
|
}) : params.coin;
|
|
125
|
-
tx.add(deposit({
|
|
126
|
+
tx.add(this.#oracleCalls.deposit({
|
|
126
127
|
package: this.#config.MARGIN_PACKAGE_ID,
|
|
127
128
|
arguments: {
|
|
128
129
|
self: manager.address,
|
|
129
130
|
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
130
|
-
baseOracle: baseCoin
|
|
131
|
-
quoteOracle: quoteCoin
|
|
131
|
+
baseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),
|
|
132
|
+
quoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),
|
|
132
133
|
coin
|
|
133
134
|
},
|
|
134
135
|
typeArguments: [
|
|
@@ -148,13 +149,13 @@ var MarginManagerContract = class {
|
|
|
148
149
|
type: quoteCoin.type,
|
|
149
150
|
balance: convertQuantity(params.amount, quoteCoin.scalar)
|
|
150
151
|
}) : params.coin;
|
|
151
|
-
tx.add(deposit({
|
|
152
|
+
tx.add(this.#oracleCalls.deposit({
|
|
152
153
|
package: this.#config.MARGIN_PACKAGE_ID,
|
|
153
154
|
arguments: {
|
|
154
155
|
self: manager.address,
|
|
155
156
|
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
156
|
-
baseOracle: baseCoin
|
|
157
|
-
quoteOracle: quoteCoin
|
|
157
|
+
baseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),
|
|
158
|
+
quoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),
|
|
158
159
|
coin
|
|
159
160
|
},
|
|
160
161
|
typeArguments: [
|
|
@@ -175,13 +176,13 @@ var MarginManagerContract = class {
|
|
|
175
176
|
type: deepCoin.type,
|
|
176
177
|
balance: convertQuantity(params.amount, deepCoin.scalar)
|
|
177
178
|
}) : params.coin;
|
|
178
|
-
tx.add(deposit({
|
|
179
|
+
tx.add(this.#oracleCalls.deposit({
|
|
179
180
|
package: this.#config.MARGIN_PACKAGE_ID,
|
|
180
181
|
arguments: {
|
|
181
182
|
self: manager.address,
|
|
182
183
|
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
183
|
-
baseOracle: baseCoin
|
|
184
|
-
quoteOracle: quoteCoin
|
|
184
|
+
baseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),
|
|
185
|
+
quoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),
|
|
185
186
|
coin
|
|
186
187
|
},
|
|
187
188
|
typeArguments: [
|
|
@@ -198,15 +199,15 @@ var MarginManagerContract = class {
|
|
|
198
199
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
199
200
|
const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
|
|
200
201
|
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
201
|
-
return tx.add(withdraw({
|
|
202
|
+
return tx.add(this.#oracleCalls.withdraw({
|
|
202
203
|
package: this.#config.MARGIN_PACKAGE_ID,
|
|
203
204
|
arguments: {
|
|
204
205
|
self: manager.address,
|
|
205
206
|
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
206
207
|
baseMarginPool: baseMarginPool.address,
|
|
207
208
|
quoteMarginPool: quoteMarginPool.address,
|
|
208
|
-
baseOracle: baseCoin
|
|
209
|
-
quoteOracle: quoteCoin
|
|
209
|
+
baseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),
|
|
210
|
+
quoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),
|
|
210
211
|
pool: pool.address,
|
|
211
212
|
withdrawAmount: convertQuantity(amount, baseCoin.scalar)
|
|
212
213
|
},
|
|
@@ -224,15 +225,15 @@ var MarginManagerContract = class {
|
|
|
224
225
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
225
226
|
const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
|
|
226
227
|
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
227
|
-
return tx.add(withdraw({
|
|
228
|
+
return tx.add(this.#oracleCalls.withdraw({
|
|
228
229
|
package: this.#config.MARGIN_PACKAGE_ID,
|
|
229
230
|
arguments: {
|
|
230
231
|
self: manager.address,
|
|
231
232
|
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
232
233
|
baseMarginPool: baseMarginPool.address,
|
|
233
234
|
quoteMarginPool: quoteMarginPool.address,
|
|
234
|
-
baseOracle: baseCoin
|
|
235
|
-
quoteOracle: quoteCoin
|
|
235
|
+
baseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),
|
|
236
|
+
quoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),
|
|
236
237
|
pool: pool.address,
|
|
237
238
|
withdrawAmount: convertQuantity(amount, quoteCoin.scalar)
|
|
238
239
|
},
|
|
@@ -251,15 +252,15 @@ var MarginManagerContract = class {
|
|
|
251
252
|
const deepCoin = this.#config.getCoin("DEEP");
|
|
252
253
|
const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
|
|
253
254
|
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
254
|
-
return tx.add(withdraw({
|
|
255
|
+
return tx.add(this.#oracleCalls.withdraw({
|
|
255
256
|
package: this.#config.MARGIN_PACKAGE_ID,
|
|
256
257
|
arguments: {
|
|
257
258
|
self: manager.address,
|
|
258
259
|
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
259
260
|
baseMarginPool: baseMarginPool.address,
|
|
260
261
|
quoteMarginPool: quoteMarginPool.address,
|
|
261
|
-
baseOracle: baseCoin
|
|
262
|
-
quoteOracle: quoteCoin
|
|
262
|
+
baseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),
|
|
263
|
+
quoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),
|
|
263
264
|
pool: pool.address,
|
|
264
265
|
withdrawAmount: convertQuantity(amount, deepCoin.scalar)
|
|
265
266
|
},
|
|
@@ -276,14 +277,14 @@ var MarginManagerContract = class {
|
|
|
276
277
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
277
278
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
278
279
|
const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
|
|
279
|
-
return tx.add(borrowBase({
|
|
280
|
+
return tx.add(this.#oracleCalls.borrowBase({
|
|
280
281
|
package: this.#config.MARGIN_PACKAGE_ID,
|
|
281
282
|
arguments: {
|
|
282
283
|
self: manager.address,
|
|
283
284
|
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
284
285
|
baseMarginPool: baseMarginPool.address,
|
|
285
|
-
baseOracle: baseCoin
|
|
286
|
-
quoteOracle: quoteCoin
|
|
286
|
+
baseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),
|
|
287
|
+
quoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),
|
|
287
288
|
pool: pool.address,
|
|
288
289
|
loanAmount: convertQuantity(amount, baseCoin.scalar)
|
|
289
290
|
},
|
|
@@ -296,14 +297,14 @@ var MarginManagerContract = class {
|
|
|
296
297
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
297
298
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
298
299
|
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
299
|
-
return tx.add(borrowQuote({
|
|
300
|
+
return tx.add(this.#oracleCalls.borrowQuote({
|
|
300
301
|
package: this.#config.MARGIN_PACKAGE_ID,
|
|
301
302
|
arguments: {
|
|
302
303
|
self: manager.address,
|
|
303
304
|
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
304
305
|
quoteMarginPool: quoteMarginPool.address,
|
|
305
|
-
baseOracle: baseCoin
|
|
306
|
-
quoteOracle: quoteCoin
|
|
306
|
+
baseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),
|
|
307
|
+
quoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),
|
|
307
308
|
pool: pool.address,
|
|
308
309
|
loanAmount: convertQuantity(amount, quoteCoin.scalar)
|
|
309
310
|
},
|
|
@@ -351,13 +352,13 @@ var MarginManagerContract = class {
|
|
|
351
352
|
const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
|
|
352
353
|
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
353
354
|
const marginPool = debtIsBase ? baseMarginPool : quoteMarginPool;
|
|
354
|
-
return tx.add(liquidate({
|
|
355
|
+
return tx.add(this.#oracleCalls.liquidate({
|
|
355
356
|
package: this.#config.MARGIN_PACKAGE_ID,
|
|
356
357
|
arguments: {
|
|
357
358
|
self: managerAddress,
|
|
358
359
|
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
359
|
-
baseOracle: baseCoin
|
|
360
|
-
quoteOracle: quoteCoin
|
|
360
|
+
baseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),
|
|
361
|
+
quoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),
|
|
361
362
|
marginPool: marginPool.address,
|
|
362
363
|
pool: pool.address,
|
|
363
364
|
repayCoin
|
|
@@ -515,13 +516,13 @@ var MarginManagerContract = class {
|
|
|
515
516
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
516
517
|
const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
|
|
517
518
|
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
518
|
-
return tx.add(managerState({
|
|
519
|
+
return tx.add(this.#oracleCalls.managerState({
|
|
519
520
|
package: this.#config.MARGIN_PACKAGE_ID,
|
|
520
521
|
arguments: {
|
|
521
522
|
self: marginManagerId,
|
|
522
523
|
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
523
|
-
baseOracle: baseCoin
|
|
524
|
-
quoteOracle: quoteCoin
|
|
524
|
+
baseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),
|
|
525
|
+
quoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),
|
|
525
526
|
pool: pool.address,
|
|
526
527
|
baseMarginPool: baseMarginPool.address,
|
|
527
528
|
quoteMarginPool: quoteMarginPool.address
|
|
@@ -686,6 +687,14 @@ var MarginManagerContract = class {
|
|
|
686
687
|
};
|
|
687
688
|
this.#config = config;
|
|
688
689
|
}
|
|
690
|
+
/**
|
|
691
|
+
* Oracle-taking entrypoints live in the parallel `_upgraded` module, which takes Pyth's
|
|
692
|
+
* upgraded-Core `PriceInfoObject`. Entrypoints with no oracle argument stay on the base
|
|
693
|
+
* module, which is the only place they exist.
|
|
694
|
+
*/
|
|
695
|
+
get #oracleCalls() {
|
|
696
|
+
return margin_manager_upgraded_exports;
|
|
697
|
+
}
|
|
689
698
|
};
|
|
690
699
|
|
|
691
700
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marginManager.mjs","names":["#config","marginManagerMoveCalls._new","marginManagerMoveCalls.newWithInitializer","marginManagerMoveCalls.share","marginManagerMoveCalls.registerMarginManager","marginManagerMoveCalls.unregisterMarginManager","marginManagerMoveCalls.deposit","marginManagerMoveCalls.withdraw","marginManagerMoveCalls.borrowBase","marginManagerMoveCalls.borrowQuote","marginManagerMoveCalls.repayBase","marginManagerMoveCalls.repayQuote","marginManagerMoveCalls.liquidate","marginManagerMoveCalls.setMarginManagerReferral","marginManagerMoveCalls.unsetMarginManagerReferral","marginManagerMoveCalls.owner","marginManagerMoveCalls.deepbookPool","marginManagerMoveCalls.marginPoolId","marginManagerMoveCalls.borrowedShares","marginManagerMoveCalls.borrowedBaseShares","marginManagerMoveCalls.borrowedQuoteShares","marginManagerMoveCalls.hasBaseDebt","marginManagerMoveCalls.balanceManager","marginManagerMoveCalls.calculateAssets","marginManagerMoveCalls.calculateDebts","marginManagerMoveCalls.managerState","marginManagerMoveCalls.baseBalance","marginManagerMoveCalls.quoteBalance","marginManagerMoveCalls.deepBalance","marginManagerMoveCalls.balanceManagerId","marginManagerMoveCalls.getBalanceManagerReferralId","marginManagerMoveCalls.accountExists","marginManagerMoveCalls.account","marginManagerMoveCalls.accountOpenOrders","marginManagerMoveCalls.getAccountOrderDetails","marginManagerMoveCalls.lockedBalance","marginManagerMoveCalls.canPlaceLimitOrder","marginManagerMoveCalls.canPlaceMarketOrder"],"sources":["../../src/transactions/marginManager.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { Transaction, TransactionArgument } from '@mysten/sui/transactions';\nimport { coinWithBalance } from '@mysten/sui/transactions';\n\nimport type { DeepBookConfig } from '../utils/config.js';\nimport type { DepositParams, DepositDuringInitParams } from '../types/index.js';\nimport { FLOAT_SCALAR } from '../utils/config.js';\nimport { convertPrice, convertQuantity } from '../utils/conversion.js';\nimport * as marginManagerMoveCalls from '../contracts/deepbook_margin/margin_manager.js';\n\n/**\n * MarginManagerContract class for managing MarginManager operations.\n */\nexport class MarginManagerContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for MarginManagerContract\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * @description Create a new margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewMarginManager = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.add(\n\t\t\tmarginManagerMoveCalls._new({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tdeepbookRegistry: this.#config.REGISTRY_ID,\n\t\t\t\t\tmarginRegistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Create a new margin manager with an initializer\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewMarginManagerWithInitializer = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst [manager, initializer] = tx.add(\n\t\t\tmarginManagerMoveCalls.newWithInitializer({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tdeepbookRegistry: this.#config.REGISTRY_ID,\n\t\t\t\t\tmarginRegistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t\treturn { manager, initializer };\n\t};\n\n\t/**\n\t * @description Share a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {TransactionArgument} manager The margin manager to share\n\t * @param {TransactionArgument} initializer The initializer for the manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tshareMarginManager =\n\t\t(poolKey: string, manager: TransactionArgument, initializer: TransactionArgument) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\ttx.add(\n\t\t\t\tmarginManagerMoveCalls.share({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: { manager, initializer },\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Register a margin manager back to the margin registry. Lets\n\t * owners restore visibility of a manager that was unregistered by another\n\t * platform.\n\t * @param {string} managerKey The key to identify the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tregisterMarginManager = (managerKey: string) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.add(\n\t\t\tmarginManagerMoveCalls.registerMarginManager({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: manager.address, marginRegistry: this.#config.MARGIN_REGISTRY_ID },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Unregister a margin manager from the margin registry. Aborts\n\t * if the manager holds any outstanding debt or base/quote/DEEP balance.\n\t * @param {string} managerKey The key to identify the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tunregisterMarginManager = (managerKey: string) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.add(\n\t\t\tmarginManagerMoveCalls.unregisterMarginManager({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: manager.address, marginRegistry: this.#config.MARGIN_REGISTRY_ID },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Deposit into a margin manager during initialization (before sharing).\n\t * Use this when you need to deposit funds into a newly created manager in the same transaction.\n\t * @param {DepositDuringInitParams} params The deposit parameters\n\t * @returns A function that takes a Transaction object\n\t */\n\tdepositDuringInitialization = (params: DepositDuringInitParams) => (tx: Transaction) => {\n\t\tconst { manager, poolKey, coinType } = params;\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\t// Get the deposit coin from config using the coinType key (e.g., 'SUI', 'DBUSDC', 'DEEP')\n\t\tconst depositCoin = this.#config.getCoin(coinType);\n\n\t\t// If amount is provided, create a coin with balance; otherwise use the provided coin\n\t\tconst coin =\n\t\t\t'amount' in params && params.amount !== undefined\n\t\t\t\t? coinWithBalance({\n\t\t\t\t\t\ttype: depositCoin.type,\n\t\t\t\t\t\tbalance: convertQuantity(params.amount, depositCoin.scalar),\n\t\t\t\t\t})\n\t\t\t\t: params.coin;\n\n\t\ttx.add(\n\t\t\tmarginManagerMoveCalls.deposit({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: manager,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tbaseOracle: baseCoin.priceInfoObjectId!,\n\t\t\t\t\tquoteOracle: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\tcoin,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, depositCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Deposit base into a margin manager\n\t * @param {DepositParams} params The deposit parameters\n\t * @returns A function that takes a Transaction object\n\t */\n\tdepositBase = (params: DepositParams) => (tx: Transaction) => {\n\t\tconst { managerKey } = params;\n\t\tconst manager = this.#config.getMarginManager(managerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst coin =\n\t\t\t'amount' in params && params.amount !== undefined\n\t\t\t\t? coinWithBalance({\n\t\t\t\t\t\ttype: baseCoin.type,\n\t\t\t\t\t\tbalance: convertQuantity(params.amount, baseCoin.scalar),\n\t\t\t\t\t})\n\t\t\t\t: params.coin;\n\t\ttx.add(\n\t\t\tmarginManagerMoveCalls.deposit({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: manager.address,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tbaseOracle: baseCoin.priceInfoObjectId!,\n\t\t\t\t\tquoteOracle: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\tcoin,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, baseCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Deposit quote into a margin manager\n\t * @param {DepositParams} params The deposit parameters\n\t * @returns A function that takes a Transaction object\n\t */\n\tdepositQuote = (params: DepositParams) => (tx: Transaction) => {\n\t\tconst { managerKey } = params;\n\t\tconst manager = this.#config.getMarginManager(managerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst coin =\n\t\t\t'amount' in params && params.amount !== undefined\n\t\t\t\t? coinWithBalance({\n\t\t\t\t\t\ttype: quoteCoin.type,\n\t\t\t\t\t\tbalance: convertQuantity(params.amount, quoteCoin.scalar),\n\t\t\t\t\t})\n\t\t\t\t: params.coin;\n\t\ttx.add(\n\t\t\tmarginManagerMoveCalls.deposit({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: manager.address,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tbaseOracle: baseCoin.priceInfoObjectId!,\n\t\t\t\t\tquoteOracle: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\tcoin,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Deposit deep into a margin manager\n\t * @param {DepositParams} params The deposit parameters\n\t * @returns A function that takes a Transaction object\n\t */\n\tdepositDeep = (params: DepositParams) => (tx: Transaction) => {\n\t\tconst { managerKey } = params;\n\t\tconst manager = this.#config.getMarginManager(managerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst deepCoin = this.#config.getCoin('DEEP');\n\t\tconst coin =\n\t\t\t'amount' in params && params.amount !== undefined\n\t\t\t\t? coinWithBalance({\n\t\t\t\t\t\ttype: deepCoin.type,\n\t\t\t\t\t\tbalance: convertQuantity(params.amount, deepCoin.scalar),\n\t\t\t\t\t})\n\t\t\t\t: params.coin;\n\t\ttx.add(\n\t\t\tmarginManagerMoveCalls.deposit({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: manager.address,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tbaseOracle: baseCoin.priceInfoObjectId!,\n\t\t\t\t\tquoteOracle: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\tcoin,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, deepCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Withdraw base from a margin manager\n\t * @param {string} managerKey The key to identify the manager\n\t * @param {number} amount The amount to withdraw\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawBase = (managerKey: string, amount: number) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.withdraw({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: manager.address,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t\tbaseOracle: baseCoin.priceInfoObjectId!,\n\t\t\t\t\tquoteOracle: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\twithdrawAmount: convertQuantity(amount, baseCoin.scalar),\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, baseCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Withdraw quote from a margin manager\n\t * @param {string} managerKey The key to identify the manager\n\t * @param {number} amount The amount to withdraw\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawQuote = (managerKey: string, amount: number) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.withdraw({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: manager.address,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t\tbaseOracle: baseCoin.priceInfoObjectId!,\n\t\t\t\t\tquoteOracle: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\twithdrawAmount: convertQuantity(amount, quoteCoin.scalar),\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Withdraw deep from a margin manager\n\t * @param {string} managerKey The key to identify the manager\n\t * @param {number} amount The amount to withdraw\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawDeep = (managerKey: string, amount: number) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst deepCoin = this.#config.getCoin('DEEP');\n\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.withdraw({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: manager.address,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t\tbaseOracle: baseCoin.priceInfoObjectId!,\n\t\t\t\t\tquoteOracle: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\twithdrawAmount: convertQuantity(amount, deepCoin.scalar),\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, deepCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Borrow base from a margin manager\n\t * @param {string} managerKey The key to identify the manager\n\t * @param {number} amount The amount to borrow\n\t * @returns A function that takes a Transaction object\n\t */\n\tborrowBase = (managerKey: string, amount: number) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.borrowBase({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: manager.address,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\tbaseOracle: baseCoin.priceInfoObjectId!,\n\t\t\t\t\tquoteOracle: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tloanAmount: convertQuantity(amount, baseCoin.scalar),\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Borrow quote from a margin manager\n\t * @param {string} managerKey The key to identify the manager\n\t * @param {number} amount The amount to borrow\n\t * @returns A function that takes a Transaction object\n\t */\n\tborrowQuote = (managerKey: string, amount: number) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.borrowQuote({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: manager.address,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t\tbaseOracle: baseCoin.priceInfoObjectId!,\n\t\t\t\t\tquoteOracle: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tloanAmount: convertQuantity(amount, quoteCoin.scalar),\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Repay base from a margin manager\n\t * @param {string} managerKey The key to identify the manager\n\t * @param {number} amount The amount to repay\n\t * @returns A function that takes a Transaction object\n\t */\n\trepayBase = (managerKey: string, amount?: number) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.repayBase({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: manager.address,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginPool: baseMarginPool.address,\n\t\t\t\t\tamount: amount !== undefined ? convertQuantity(amount, baseCoin.scalar) : null,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Repay quote from a margin manager\n\t * @param {string} managerKey The key to identify the manager\n\t * @param {number} amount The amount to repay\n\t * @returns A function that takes a Transaction object\n\t */\n\trepayQuote = (managerKey: string, amount?: number) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.repayQuote({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: manager.address,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginPool: quoteMarginPool.address,\n\t\t\t\t\tamount: amount !== undefined ? convertQuantity(amount, quoteCoin.scalar) : null,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Liquidate a margin manager\n\t * @param {string} managerAddress The address of the manager to liquidate\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {boolean} debtIsBase Whether the debt is in base\n\t * @param {TransactionArgument} repayCoin The coin to repay\n\t * @returns A function that takes a Transaction object\n\t */\n\tliquidate =\n\t\t(\n\t\t\tmanagerAddress: string,\n\t\t\tpoolKey: string,\n\t\t\tdebtIsBase: boolean,\n\t\t\trepayCoin: TransactionArgument,\n\t\t) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\t\tconst marginPool = debtIsBase ? baseMarginPool : quoteMarginPool;\n\t\t\treturn tx.add(\n\t\t\t\tmarginManagerMoveCalls.liquidate({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tself: managerAddress,\n\t\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\t\tbaseOracle: baseCoin.priceInfoObjectId!,\n\t\t\t\t\t\tquoteOracle: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\t\tmarginPool: marginPool.address,\n\t\t\t\t\t\tpool: pool.address,\n\t\t\t\t\t\trepayCoin,\n\t\t\t\t\t},\n\t\t\t\t\ttypeArguments: [\n\t\t\t\t\t\tbaseCoin.type,\n\t\t\t\t\t\tquoteCoin.type,\n\t\t\t\t\t\tdebtIsBase ? baseCoin.type : quoteCoin.type,\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Set the referral for a margin manager (DeepBookPoolReferral)\n\t * @param {string} managerKey The key to identify the margin manager\n\t * @param {string} referral The referral (DeepBookPoolReferral) to set\n\t * @returns A function that takes a Transaction object\n\t */\n\tsetMarginManagerReferral = (managerKey: string, referral: string) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.add(\n\t\t\tmarginManagerMoveCalls.setMarginManagerReferral({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: manager.address, referralCap: referral },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Unset the referral for a margin manager\n\t * @param {string} managerKey The key to identify the margin manager\n\t * @param {string} poolKey The key of the pool to unset the referral for\n\t * @returns A function that takes a Transaction object\n\t */\n\tunsetMarginManagerReferral = (managerKey: string, poolKey: string) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.add(\n\t\t\tmarginManagerMoveCalls.unsetMarginManagerReferral({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: manager.address, poolId: pool.address },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t// === Read-Only Functions ===\n\n\t/**\n\t * @description Get the owner address of a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\townerByPoolKey = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.owner({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the DeepBook pool ID associated with a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tdeepbookPool = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.deepbookPool({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the margin pool ID (if any) associated with a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tmarginPoolId = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.marginPoolId({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get borrowed shares for both base and quote assets\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tborrowedShares = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.borrowedShares({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get borrowed base shares\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tborrowedBaseShares = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.borrowedBaseShares({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get borrowed quote shares\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tborrowedQuoteShares = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.borrowedQuoteShares({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Check if margin manager has base asset debt\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\thasBaseDebt = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.hasBaseDebt({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the balance manager ID for a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tbalanceManager = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.balanceManager({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Calculate assets (base and quote) for a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tcalculateAssets = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.calculateAssets({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId, pool: pool.address },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Calculate debts (base and quote) for a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} coinKey The key to identify the debt coin (base or quote)\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tcalculateDebts =\n\t\t(poolKey: string, coinKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst debtCoin = this.#config.getCoin(coinKey);\n\t\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\t\treturn tx.add(\n\t\t\t\tmarginManagerMoveCalls.calculateDebts({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: { self: marginManagerId, marginPool: marginPool.address },\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, debtCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Get comprehensive state information for a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t * @returns Returns (manager_id, deepbook_pool_id, risk_ratio, base_asset, quote_asset,\n\t * base_debt, quote_debt, base_pyth_price, base_pyth_decimals,\n\t * quote_pyth_price, quote_pyth_decimals)\n\t */\n\tmanagerState = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.managerState({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: marginManagerId,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tbaseOracle: baseCoin.priceInfoObjectId!,\n\t\t\t\t\tquoteOracle: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the base asset balance of a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tbaseBalance = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.baseBalance({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the quote asset balance of a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tquoteBalance = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.quoteBalance({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the DEEP token balance of a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tdeepBalance = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.deepBalance({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the underlying BalanceManager ID for a margin manager.\n\t * Returns an ID (not a `&BalanceManager`), so it composes in PTBs unlike\n\t * `balanceManager`.\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tbalanceManagerId = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.balanceManagerId({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the BalanceManager referral ID for a pool (Option<ID>).\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetBalanceManagerReferralId = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.getBalanceManagerReferralId({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId, poolId: pool.address },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Check if the margin manager's account exists in the pool.\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\taccountExists = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.accountExists({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId, pool: pool.address },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the pool account data for the margin manager.\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\taccount = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.account({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId, pool: pool.address },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the open order IDs for the margin manager's account in\n\t * the pool.\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\taccountOpenOrders = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.accountOpenOrders({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId, pool: pool.address },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get full order details for the margin manager's account in\n\t * the pool.\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetAccountOrderDetails = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.getAccountOrderDetails({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId, pool: pool.address },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get locked balances (base, quote, deep) for the margin\n\t * manager's account in the pool.\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tlockedBalance = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.lockedBalance({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId, pool: pool.address },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Check whether a limit order can be placed given the\n\t * manager's current state.\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @param {number | bigint} price Limit price\n\t * @param {number | bigint} quantity Order quantity (base units)\n\t * @param {boolean} isBid True for bid, false for ask\n\t * @param {boolean} payWithDeep Whether to pay fees in DEEP\n\t * @param {number | bigint} expireTimestamp Order expiration timestamp (ms)\n\t * @returns A function that takes a Transaction object\n\t */\n\tcanPlaceLimitOrder =\n\t\t(\n\t\t\tpoolKey: string,\n\t\t\tmarginManagerId: string,\n\t\t\tprice: number | bigint,\n\t\t\tquantity: number | bigint,\n\t\t\tisBid: boolean,\n\t\t\tpayWithDeep: boolean,\n\t\t\texpireTimestamp: number | bigint,\n\t\t) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst inputPrice = convertPrice(price, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar);\n\t\t\tconst inputQuantity = convertQuantity(quantity, baseCoin.scalar);\n\t\t\treturn tx.add(\n\t\t\t\tmarginManagerMoveCalls.canPlaceLimitOrder({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tself: marginManagerId,\n\t\t\t\t\t\tpool: pool.address,\n\t\t\t\t\t\tprice: inputPrice,\n\t\t\t\t\t\tquantity: inputQuantity,\n\t\t\t\t\t\tisBid,\n\t\t\t\t\t\tpayWithDeep,\n\t\t\t\t\t\texpireTimestamp,\n\t\t\t\t\t},\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Check whether a market order can be placed given the\n\t * manager's current state.\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @param {number | bigint} quantity Order quantity (base units)\n\t * @param {boolean} isBid True for bid, false for ask\n\t * @param {boolean} payWithDeep Whether to pay fees in DEEP\n\t * @returns A function that takes a Transaction object\n\t */\n\tcanPlaceMarketOrder =\n\t\t(\n\t\t\tpoolKey: string,\n\t\t\tmarginManagerId: string,\n\t\t\tquantity: number | bigint,\n\t\t\tisBid: boolean,\n\t\t\tpayWithDeep: boolean,\n\t\t) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst inputQuantity = convertQuantity(quantity, baseCoin.scalar);\n\t\t\treturn tx.add(\n\t\t\t\tmarginManagerMoveCalls.canPlaceMarketOrder({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tself: marginManagerId,\n\t\t\t\t\t\tpool: pool.address,\n\t\t\t\t\t\tquantity: inputQuantity,\n\t\t\t\t\t\tisBid,\n\t\t\t\t\t\tpayWithDeep,\n\t\t\t\t\t},\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n}\n"],"mappings":";;;;;;;;;AAcA,IAAa,wBAAb,MAAmC;CAClC;;;;CAKA,YAAY,QAAwB;2BAShB,aAAqB,OAAoB;GAC5D,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;GAC1C,MAAM,WAAW,MAAKA,OAAQ,QAAQ,KAAK,SAAS;GACpD,MAAM,YAAY,MAAKA,OAAQ,QAAQ,KAAK,UAAU;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AM,UAAU,KAAK;IAC9C,CAAC,CACF;;AAlhCF,QAAKA,SAAU"}
|
|
1
|
+
{"version":3,"file":"marginManager.mjs","names":["#config","marginManagerMoveCalls._new","marginManagerMoveCalls.newWithInitializer","marginManagerMoveCalls.share","marginManagerMoveCalls.registerMarginManager","marginManagerMoveCalls.unregisterMarginManager","#oracleCalls","marginManagerMoveCalls.repayBase","marginManagerMoveCalls.repayQuote","marginManagerMoveCalls.setMarginManagerReferral","marginManagerMoveCalls.unsetMarginManagerReferral","marginManagerMoveCalls.owner","marginManagerMoveCalls.deepbookPool","marginManagerMoveCalls.marginPoolId","marginManagerMoveCalls.borrowedShares","marginManagerMoveCalls.borrowedBaseShares","marginManagerMoveCalls.borrowedQuoteShares","marginManagerMoveCalls.hasBaseDebt","marginManagerMoveCalls.balanceManager","marginManagerMoveCalls.calculateAssets","marginManagerMoveCalls.calculateDebts","marginManagerMoveCalls.baseBalance","marginManagerMoveCalls.quoteBalance","marginManagerMoveCalls.deepBalance","marginManagerMoveCalls.balanceManagerId","marginManagerMoveCalls.getBalanceManagerReferralId","marginManagerMoveCalls.accountExists","marginManagerMoveCalls.account","marginManagerMoveCalls.accountOpenOrders","marginManagerMoveCalls.getAccountOrderDetails","marginManagerMoveCalls.lockedBalance","marginManagerMoveCalls.canPlaceLimitOrder","marginManagerMoveCalls.canPlaceMarketOrder","marginManagerUpgradedMoveCalls"],"sources":["../../src/transactions/marginManager.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { Transaction, TransactionArgument } from '@mysten/sui/transactions';\nimport { coinWithBalance } from '@mysten/sui/transactions';\n\nimport type { DeepBookConfig } from '../utils/config.js';\nimport type { DepositParams, DepositDuringInitParams } from '../types/index.js';\nimport { FLOAT_SCALAR } from '../utils/config.js';\nimport { convertPrice, convertQuantity } from '../utils/conversion.js';\nimport * as marginManagerMoveCalls from '../contracts/deepbook_margin/margin_manager.js';\nimport * as marginManagerUpgradedMoveCalls from '../contracts/deepbook_margin/margin_manager_upgraded.js';\n\n/**\n * MarginManagerContract class for managing MarginManager operations.\n */\nexport class MarginManagerContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for MarginManagerContract\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * Oracle-taking entrypoints live in the parallel `_upgraded` module, which takes Pyth's\n\t * upgraded-Core `PriceInfoObject`. Entrypoints with no oracle argument stay on the base\n\t * module, which is the only place they exist.\n\t */\n\tget #oracleCalls() {\n\t\treturn marginManagerUpgradedMoveCalls;\n\t}\n\n\t/**\n\t * @description Create a new margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewMarginManager = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.add(\n\t\t\tmarginManagerMoveCalls._new({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tdeepbookRegistry: this.#config.REGISTRY_ID,\n\t\t\t\t\tmarginRegistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Create a new margin manager with an initializer\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewMarginManagerWithInitializer = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst [manager, initializer] = tx.add(\n\t\t\tmarginManagerMoveCalls.newWithInitializer({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tdeepbookRegistry: this.#config.REGISTRY_ID,\n\t\t\t\t\tmarginRegistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t\treturn { manager, initializer };\n\t};\n\n\t/**\n\t * @description Share a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {TransactionArgument} manager The margin manager to share\n\t * @param {TransactionArgument} initializer The initializer for the manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tshareMarginManager =\n\t\t(poolKey: string, manager: TransactionArgument, initializer: TransactionArgument) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\ttx.add(\n\t\t\t\tmarginManagerMoveCalls.share({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: { manager, initializer },\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Register a margin manager back to the margin registry. Lets\n\t * owners restore visibility of a manager that was unregistered by another\n\t * platform.\n\t * @param {string} managerKey The key to identify the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tregisterMarginManager = (managerKey: string) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.add(\n\t\t\tmarginManagerMoveCalls.registerMarginManager({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: manager.address, marginRegistry: this.#config.MARGIN_REGISTRY_ID },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Unregister a margin manager from the margin registry. Aborts\n\t * if the manager holds any outstanding debt or base/quote/DEEP balance.\n\t * @param {string} managerKey The key to identify the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tunregisterMarginManager = (managerKey: string) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.add(\n\t\t\tmarginManagerMoveCalls.unregisterMarginManager({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: manager.address, marginRegistry: this.#config.MARGIN_REGISTRY_ID },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Deposit into a margin manager during initialization (before sharing).\n\t * Use this when you need to deposit funds into a newly created manager in the same transaction.\n\t * @param {DepositDuringInitParams} params The deposit parameters\n\t * @returns A function that takes a Transaction object\n\t */\n\tdepositDuringInitialization = (params: DepositDuringInitParams) => (tx: Transaction) => {\n\t\tconst { manager, poolKey, coinType } = params;\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\t// Get the deposit coin from config using the coinType key (e.g., 'SUI', 'DBUSDC', 'DEEP')\n\t\tconst depositCoin = this.#config.getCoin(coinType);\n\n\t\t// If amount is provided, create a coin with balance; otherwise use the provided coin\n\t\tconst coin =\n\t\t\t'amount' in params && params.amount !== undefined\n\t\t\t\t? coinWithBalance({\n\t\t\t\t\t\ttype: depositCoin.type,\n\t\t\t\t\t\tbalance: convertQuantity(params.amount, depositCoin.scalar),\n\t\t\t\t\t})\n\t\t\t\t: params.coin;\n\n\t\ttx.add(\n\t\t\tthis.#oracleCalls.deposit({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: manager,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tbaseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),\n\t\t\t\t\tquoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),\n\t\t\t\t\tcoin,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, depositCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Deposit base into a margin manager\n\t * @param {DepositParams} params The deposit parameters\n\t * @returns A function that takes a Transaction object\n\t */\n\tdepositBase = (params: DepositParams) => (tx: Transaction) => {\n\t\tconst { managerKey } = params;\n\t\tconst manager = this.#config.getMarginManager(managerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst coin =\n\t\t\t'amount' in params && params.amount !== undefined\n\t\t\t\t? coinWithBalance({\n\t\t\t\t\t\ttype: baseCoin.type,\n\t\t\t\t\t\tbalance: convertQuantity(params.amount, baseCoin.scalar),\n\t\t\t\t\t})\n\t\t\t\t: params.coin;\n\t\ttx.add(\n\t\t\tthis.#oracleCalls.deposit({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: manager.address,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tbaseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),\n\t\t\t\t\tquoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),\n\t\t\t\t\tcoin,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, baseCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Deposit quote into a margin manager\n\t * @param {DepositParams} params The deposit parameters\n\t * @returns A function that takes a Transaction object\n\t */\n\tdepositQuote = (params: DepositParams) => (tx: Transaction) => {\n\t\tconst { managerKey } = params;\n\t\tconst manager = this.#config.getMarginManager(managerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst coin =\n\t\t\t'amount' in params && params.amount !== undefined\n\t\t\t\t? coinWithBalance({\n\t\t\t\t\t\ttype: quoteCoin.type,\n\t\t\t\t\t\tbalance: convertQuantity(params.amount, quoteCoin.scalar),\n\t\t\t\t\t})\n\t\t\t\t: params.coin;\n\t\ttx.add(\n\t\t\tthis.#oracleCalls.deposit({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: manager.address,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tbaseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),\n\t\t\t\t\tquoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),\n\t\t\t\t\tcoin,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Deposit deep into a margin manager\n\t * @param {DepositParams} params The deposit parameters\n\t * @returns A function that takes a Transaction object\n\t */\n\tdepositDeep = (params: DepositParams) => (tx: Transaction) => {\n\t\tconst { managerKey } = params;\n\t\tconst manager = this.#config.getMarginManager(managerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst deepCoin = this.#config.getCoin('DEEP');\n\t\tconst coin =\n\t\t\t'amount' in params && params.amount !== undefined\n\t\t\t\t? coinWithBalance({\n\t\t\t\t\t\ttype: deepCoin.type,\n\t\t\t\t\t\tbalance: convertQuantity(params.amount, deepCoin.scalar),\n\t\t\t\t\t})\n\t\t\t\t: params.coin;\n\t\ttx.add(\n\t\t\tthis.#oracleCalls.deposit({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: manager.address,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tbaseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),\n\t\t\t\t\tquoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),\n\t\t\t\t\tcoin,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, deepCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Withdraw base from a margin manager\n\t * @param {string} managerKey The key to identify the manager\n\t * @param {number} amount The amount to withdraw\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawBase = (managerKey: string, amount: number) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tthis.#oracleCalls.withdraw({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: manager.address,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t\tbaseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),\n\t\t\t\t\tquoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\twithdrawAmount: convertQuantity(amount, baseCoin.scalar),\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, baseCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Withdraw quote from a margin manager\n\t * @param {string} managerKey The key to identify the manager\n\t * @param {number} amount The amount to withdraw\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawQuote = (managerKey: string, amount: number) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tthis.#oracleCalls.withdraw({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: manager.address,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t\tbaseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),\n\t\t\t\t\tquoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\twithdrawAmount: convertQuantity(amount, quoteCoin.scalar),\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Withdraw deep from a margin manager\n\t * @param {string} managerKey The key to identify the manager\n\t * @param {number} amount The amount to withdraw\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawDeep = (managerKey: string, amount: number) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst deepCoin = this.#config.getCoin('DEEP');\n\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tthis.#oracleCalls.withdraw({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: manager.address,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t\tbaseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),\n\t\t\t\t\tquoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\twithdrawAmount: convertQuantity(amount, deepCoin.scalar),\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, deepCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Borrow base from a margin manager\n\t * @param {string} managerKey The key to identify the manager\n\t * @param {number} amount The amount to borrow\n\t * @returns A function that takes a Transaction object\n\t */\n\tborrowBase = (managerKey: string, amount: number) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\treturn tx.add(\n\t\t\tthis.#oracleCalls.borrowBase({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: manager.address,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\tbaseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),\n\t\t\t\t\tquoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tloanAmount: convertQuantity(amount, baseCoin.scalar),\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Borrow quote from a margin manager\n\t * @param {string} managerKey The key to identify the manager\n\t * @param {number} amount The amount to borrow\n\t * @returns A function that takes a Transaction object\n\t */\n\tborrowQuote = (managerKey: string, amount: number) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tthis.#oracleCalls.borrowQuote({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: manager.address,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t\tbaseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),\n\t\t\t\t\tquoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tloanAmount: convertQuantity(amount, quoteCoin.scalar),\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Repay base from a margin manager\n\t * @param {string} managerKey The key to identify the manager\n\t * @param {number} amount The amount to repay\n\t * @returns A function that takes a Transaction object\n\t */\n\trepayBase = (managerKey: string, amount?: number) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.repayBase({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: manager.address,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginPool: baseMarginPool.address,\n\t\t\t\t\tamount: amount !== undefined ? convertQuantity(amount, baseCoin.scalar) : null,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Repay quote from a margin manager\n\t * @param {string} managerKey The key to identify the manager\n\t * @param {number} amount The amount to repay\n\t * @returns A function that takes a Transaction object\n\t */\n\trepayQuote = (managerKey: string, amount?: number) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.repayQuote({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: manager.address,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginPool: quoteMarginPool.address,\n\t\t\t\t\tamount: amount !== undefined ? convertQuantity(amount, quoteCoin.scalar) : null,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Liquidate a margin manager\n\t * @param {string} managerAddress The address of the manager to liquidate\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {boolean} debtIsBase Whether the debt is in base\n\t * @param {TransactionArgument} repayCoin The coin to repay\n\t * @returns A function that takes a Transaction object\n\t */\n\tliquidate =\n\t\t(\n\t\t\tmanagerAddress: string,\n\t\t\tpoolKey: string,\n\t\t\tdebtIsBase: boolean,\n\t\t\trepayCoin: TransactionArgument,\n\t\t) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\t\tconst marginPool = debtIsBase ? baseMarginPool : quoteMarginPool;\n\t\t\treturn tx.add(\n\t\t\t\tthis.#oracleCalls.liquidate({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tself: managerAddress,\n\t\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\t\tbaseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),\n\t\t\t\t\t\tquoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),\n\t\t\t\t\t\tmarginPool: marginPool.address,\n\t\t\t\t\t\tpool: pool.address,\n\t\t\t\t\t\trepayCoin,\n\t\t\t\t\t},\n\t\t\t\t\ttypeArguments: [\n\t\t\t\t\t\tbaseCoin.type,\n\t\t\t\t\t\tquoteCoin.type,\n\t\t\t\t\t\tdebtIsBase ? baseCoin.type : quoteCoin.type,\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Set the referral for a margin manager (DeepBookPoolReferral)\n\t * @param {string} managerKey The key to identify the margin manager\n\t * @param {string} referral The referral (DeepBookPoolReferral) to set\n\t * @returns A function that takes a Transaction object\n\t */\n\tsetMarginManagerReferral = (managerKey: string, referral: string) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.add(\n\t\t\tmarginManagerMoveCalls.setMarginManagerReferral({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: manager.address, referralCap: referral },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Unset the referral for a margin manager\n\t * @param {string} managerKey The key to identify the margin manager\n\t * @param {string} poolKey The key of the pool to unset the referral for\n\t * @returns A function that takes a Transaction object\n\t */\n\tunsetMarginManagerReferral = (managerKey: string, poolKey: string) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.add(\n\t\t\tmarginManagerMoveCalls.unsetMarginManagerReferral({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: manager.address, poolId: pool.address },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t// === Read-Only Functions ===\n\n\t/**\n\t * @description Get the owner address of a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\townerByPoolKey = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.owner({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the DeepBook pool ID associated with a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tdeepbookPool = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.deepbookPool({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the margin pool ID (if any) associated with a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tmarginPoolId = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.marginPoolId({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get borrowed shares for both base and quote assets\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tborrowedShares = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.borrowedShares({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get borrowed base shares\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tborrowedBaseShares = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.borrowedBaseShares({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get borrowed quote shares\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tborrowedQuoteShares = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.borrowedQuoteShares({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Check if margin manager has base asset debt\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\thasBaseDebt = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.hasBaseDebt({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the balance manager ID for a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tbalanceManager = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.balanceManager({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Calculate assets (base and quote) for a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tcalculateAssets = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.calculateAssets({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId, pool: pool.address },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Calculate debts (base and quote) for a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} coinKey The key to identify the debt coin (base or quote)\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tcalculateDebts =\n\t\t(poolKey: string, coinKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst debtCoin = this.#config.getCoin(coinKey);\n\t\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\t\treturn tx.add(\n\t\t\t\tmarginManagerMoveCalls.calculateDebts({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: { self: marginManagerId, marginPool: marginPool.address },\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, debtCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Get comprehensive state information for a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t * @returns Returns (manager_id, deepbook_pool_id, risk_ratio, base_asset, quote_asset,\n\t * base_debt, quote_debt, base_pyth_price, base_pyth_decimals,\n\t * quote_pyth_price, quote_pyth_decimals)\n\t */\n\tmanagerState = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tthis.#oracleCalls.managerState({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: marginManagerId,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tbaseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),\n\t\t\t\t\tquoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the base asset balance of a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tbaseBalance = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.baseBalance({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the quote asset balance of a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tquoteBalance = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.quoteBalance({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the DEEP token balance of a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tdeepBalance = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.deepBalance({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the underlying BalanceManager ID for a margin manager.\n\t * Returns an ID (not a `&BalanceManager`), so it composes in PTBs unlike\n\t * `balanceManager`.\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tbalanceManagerId = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.balanceManagerId({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the BalanceManager referral ID for a pool (Option<ID>).\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetBalanceManagerReferralId = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.getBalanceManagerReferralId({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId, poolId: pool.address },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Check if the margin manager's account exists in the pool.\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\taccountExists = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.accountExists({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId, pool: pool.address },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the pool account data for the margin manager.\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\taccount = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.account({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId, pool: pool.address },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the open order IDs for the margin manager's account in\n\t * the pool.\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\taccountOpenOrders = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.accountOpenOrders({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId, pool: pool.address },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get full order details for the margin manager's account in\n\t * the pool.\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetAccountOrderDetails = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.getAccountOrderDetails({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId, pool: pool.address },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get locked balances (base, quote, deep) for the margin\n\t * manager's account in the pool.\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tlockedBalance = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.lockedBalance({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId, pool: pool.address },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Check whether a limit order can be placed given the\n\t * manager's current state.\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @param {number | bigint} price Limit price\n\t * @param {number | bigint} quantity Order quantity (base units)\n\t * @param {boolean} isBid True for bid, false for ask\n\t * @param {boolean} payWithDeep Whether to pay fees in DEEP\n\t * @param {number | bigint} expireTimestamp Order expiration timestamp (ms)\n\t * @returns A function that takes a Transaction object\n\t */\n\tcanPlaceLimitOrder =\n\t\t(\n\t\t\tpoolKey: string,\n\t\t\tmarginManagerId: string,\n\t\t\tprice: number | bigint,\n\t\t\tquantity: number | bigint,\n\t\t\tisBid: boolean,\n\t\t\tpayWithDeep: boolean,\n\t\t\texpireTimestamp: number | bigint,\n\t\t) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst inputPrice = convertPrice(price, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar);\n\t\t\tconst inputQuantity = convertQuantity(quantity, baseCoin.scalar);\n\t\t\treturn tx.add(\n\t\t\t\tmarginManagerMoveCalls.canPlaceLimitOrder({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tself: marginManagerId,\n\t\t\t\t\t\tpool: pool.address,\n\t\t\t\t\t\tprice: inputPrice,\n\t\t\t\t\t\tquantity: inputQuantity,\n\t\t\t\t\t\tisBid,\n\t\t\t\t\t\tpayWithDeep,\n\t\t\t\t\t\texpireTimestamp,\n\t\t\t\t\t},\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Check whether a market order can be placed given the\n\t * manager's current state.\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @param {number | bigint} quantity Order quantity (base units)\n\t * @param {boolean} isBid True for bid, false for ask\n\t * @param {boolean} payWithDeep Whether to pay fees in DEEP\n\t * @returns A function that takes a Transaction object\n\t */\n\tcanPlaceMarketOrder =\n\t\t(\n\t\t\tpoolKey: string,\n\t\t\tmarginManagerId: string,\n\t\t\tquantity: number | bigint,\n\t\t\tisBid: boolean,\n\t\t\tpayWithDeep: boolean,\n\t\t) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst inputQuantity = convertQuantity(quantity, baseCoin.scalar);\n\t\t\treturn tx.add(\n\t\t\t\tmarginManagerMoveCalls.canPlaceMarketOrder({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tself: marginManagerId,\n\t\t\t\t\t\tpool: pool.address,\n\t\t\t\t\t\tquantity: inputQuantity,\n\t\t\t\t\t\tisBid,\n\t\t\t\t\t\tpayWithDeep,\n\t\t\t\t\t},\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n}\n"],"mappings":";;;;;;;;;;AAeA,IAAa,wBAAb,MAAmC;CAClC;;;;CAKA,YAAY,QAAwB;2BAkBhB,aAAqB,OAAoB;GAC5D,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;GAC1C,MAAM,WAAW,MAAKA,OAAQ,QAAQ,KAAK,SAAS;GACpD,MAAM,YAAY,MAAKA,OAAQ,QAAQ,KAAK,UAAU;AACtD,MAAG,IACFC,KAA4B;IAC3B,SAAS,MAAKD,OAAQ;IACtB,WAAW;KACV,MAAM,KAAK;KACX,kBAAkB,MAAKA,OAAQ;KAC/B,gBAAgB,MAAKA,OAAQ;KAC7B;IACD,eAAe,CAAC,SAAS,MAAM,UAAU,KAAK;IAC9C,CAAC,CACF;;0CAQiC,aAAqB,OAAoB;GAC3E,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;GAC1C,MAAM,WAAW,MAAKA,OAAQ,QAAQ,KAAK,SAAS;GACpD,MAAM,YAAY,MAAKA,OAAQ,QAAQ,KAAK,UAAU;GACtD,MAAM,CA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