@mysten/deepbook-v3 0.18.0 → 0.19.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 +12 -0
- package/dist/cjs/client.d.ts +28 -2
- package/dist/cjs/client.js +64 -2
- package/dist/cjs/client.js.map +3 -3
- package/dist/cjs/index.d.ts +12 -3
- package/dist/cjs/index.js +24 -1
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs/pyth/PriceServiceConnection.d.ts +26 -0
- package/dist/cjs/pyth/PriceServiceConnection.js +68 -0
- package/dist/cjs/pyth/PriceServiceConnection.js.map +7 -0
- package/dist/cjs/pyth/pyth-helpers.d.ts +7 -0
- package/dist/cjs/pyth/pyth-helpers.js +36 -0
- package/dist/cjs/pyth/pyth-helpers.js.map +7 -0
- package/dist/cjs/pyth/pyth.d.ts +65 -0
- package/dist/cjs/pyth/pyth.js +269 -0
- package/dist/cjs/pyth/pyth.js.map +7 -0
- package/dist/cjs/transactions/deepbook.js +14 -19
- package/dist/cjs/transactions/deepbook.js.map +2 -2
- package/dist/cjs/transactions/deepbookAdmin.d.ts +2 -2
- package/dist/cjs/transactions/deepbookAdmin.js.map +2 -2
- package/dist/cjs/transactions/marginAdmin.d.ts +102 -0
- package/dist/cjs/transactions/marginAdmin.js +316 -0
- package/dist/cjs/transactions/marginAdmin.js.map +7 -0
- package/dist/cjs/transactions/marginMaintainer.d.ts +74 -0
- package/dist/cjs/transactions/marginMaintainer.js +215 -0
- package/dist/cjs/transactions/marginMaintainer.js.map +7 -0
- package/dist/cjs/transactions/marginManager.d.ts +120 -0
- package/dist/cjs/transactions/marginManager.js +389 -0
- package/dist/cjs/transactions/marginManager.js.map +7 -0
- package/dist/cjs/transactions/marginPool.d.ts +40 -0
- package/dist/cjs/transactions/marginPool.js +120 -0
- package/dist/cjs/transactions/marginPool.js.map +7 -0
- package/dist/cjs/transactions/poolProxy.d.ts +104 -0
- package/dist/cjs/transactions/poolProxy.js +435 -0
- package/dist/cjs/transactions/poolProxy.js.map +7 -0
- package/dist/cjs/types/index.d.ts +58 -1
- package/dist/cjs/types/index.js.map +2 -2
- package/dist/cjs/utils/config.d.ts +29 -3
- package/dist/cjs/utils/config.js +41 -3
- package/dist/cjs/utils/config.js.map +2 -2
- package/dist/cjs/utils/constants.d.ts +36 -1
- package/dist/cjs/utils/constants.js +53 -7
- package/dist/cjs/utils/constants.js.map +2 -2
- package/dist/esm/client.d.ts +28 -2
- package/dist/esm/client.js +70 -3
- package/dist/esm/client.js.map +2 -2
- package/dist/esm/index.d.ts +12 -3
- package/dist/esm/index.js +31 -1
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/pyth/PriceServiceConnection.d.ts +26 -0
- package/dist/esm/pyth/PriceServiceConnection.js +38 -0
- package/dist/esm/pyth/PriceServiceConnection.js.map +7 -0
- package/dist/esm/pyth/pyth-helpers.d.ts +7 -0
- package/dist/esm/pyth/pyth-helpers.js +16 -0
- package/dist/esm/pyth/pyth-helpers.js.map +7 -0
- package/dist/esm/pyth/pyth.d.ts +65 -0
- package/dist/esm/pyth/pyth.js +249 -0
- package/dist/esm/pyth/pyth.js.map +7 -0
- package/dist/esm/transactions/deepbook.js +14 -19
- package/dist/esm/transactions/deepbook.js.map +2 -2
- package/dist/esm/transactions/deepbookAdmin.d.ts +2 -2
- package/dist/esm/transactions/deepbookAdmin.js.map +2 -2
- package/dist/esm/transactions/marginAdmin.d.ts +102 -0
- package/dist/esm/transactions/marginAdmin.js +296 -0
- package/dist/esm/transactions/marginAdmin.js.map +7 -0
- package/dist/esm/transactions/marginMaintainer.d.ts +74 -0
- package/dist/esm/transactions/marginMaintainer.js +195 -0
- package/dist/esm/transactions/marginMaintainer.js.map +7 -0
- package/dist/esm/transactions/marginManager.d.ts +120 -0
- package/dist/esm/transactions/marginManager.js +369 -0
- package/dist/esm/transactions/marginManager.js.map +7 -0
- package/dist/esm/transactions/marginPool.d.ts +40 -0
- package/dist/esm/transactions/marginPool.js +100 -0
- package/dist/esm/transactions/marginPool.js.map +7 -0
- package/dist/esm/transactions/poolProxy.d.ts +104 -0
- package/dist/esm/transactions/poolProxy.js +415 -0
- package/dist/esm/transactions/poolProxy.js.map +7 -0
- package/dist/esm/types/index.d.ts +58 -1
- package/dist/esm/types/index.js.map +2 -2
- package/dist/esm/utils/config.d.ts +29 -3
- package/dist/esm/utils/config.js +46 -4
- package/dist/esm/utils/config.js.map +2 -2
- package/dist/esm/utils/constants.d.ts +36 -1
- package/dist/esm/utils/constants.js +53 -7
- package/dist/esm/utils/constants.js.map +2 -2
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -4
- package/src/client.ts +94 -2
- package/src/index.ts +58 -3
- package/src/pyth/PriceServiceConnection.ts +48 -0
- package/src/pyth/pyth-helpers.ts +23 -0
- package/src/pyth/pyth.ts +305 -0
- package/src/transactions/deepbook.ts +14 -19
- package/src/transactions/deepbookAdmin.ts +2 -2
- package/src/transactions/marginAdmin.ts +309 -0
- package/src/transactions/marginMaintainer.ts +214 -0
- package/src/transactions/marginManager.ts +389 -0
- package/src/transactions/marginPool.ts +105 -0
- package/src/transactions/poolProxy.ts +438 -0
- package/src/types/index.ts +66 -1
- package/src/utils/config.ts +60 -2
- package/src/utils/constants.ts +51 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @mysten/deepbook-v3
|
|
2
2
|
|
|
3
|
+
## 0.19.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- fd91249: Margin package functionality
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [ca92487]
|
|
12
|
+
- Updated dependencies [5ab3c0a]
|
|
13
|
+
- @mysten/sui@1.39.0
|
|
14
|
+
|
|
3
15
|
## 0.18.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/dist/cjs/client.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import type { SuiClient } from '@mysten/sui/client';
|
|
2
|
+
import { Transaction } from '@mysten/sui/transactions';
|
|
2
3
|
import { BalanceManagerContract } from './transactions/balanceManager.js';
|
|
3
4
|
import { DeepBookContract } from './transactions/deepbook.js';
|
|
4
5
|
import { DeepBookAdminContract } from './transactions/deepbookAdmin.js';
|
|
5
6
|
import { FlashLoanContract } from './transactions/flashLoans.js';
|
|
6
7
|
import { GovernanceContract } from './transactions/governance.js';
|
|
7
|
-
import type { BalanceManager, Environment } from './types/index.js';
|
|
8
|
+
import type { BalanceManager, Environment, MarginManager } from './types/index.js';
|
|
8
9
|
import type { CoinMap, PoolMap } from './utils/constants.js';
|
|
10
|
+
import { MarginAdminContract } from './transactions/marginAdmin.js';
|
|
11
|
+
import { MarginMaintainerContract } from './transactions/marginMaintainer.js';
|
|
12
|
+
import { MarginPoolContract } from './transactions/marginPool.js';
|
|
13
|
+
import { MarginManagerContract } from './transactions/marginManager.js';
|
|
14
|
+
import { PoolProxyContract } from './transactions/poolProxy.js';
|
|
9
15
|
/**
|
|
10
16
|
* DeepBookClient class for managing DeepBook operations.
|
|
11
17
|
*/
|
|
@@ -17,25 +23,38 @@ export declare class DeepBookClient {
|
|
|
17
23
|
deepBookAdmin: DeepBookAdminContract;
|
|
18
24
|
flashLoans: FlashLoanContract;
|
|
19
25
|
governance: GovernanceContract;
|
|
26
|
+
marginAdmin: MarginAdminContract;
|
|
27
|
+
marginMaintainer: MarginMaintainerContract;
|
|
28
|
+
marginPool: MarginPoolContract;
|
|
29
|
+
marginManager: MarginManagerContract;
|
|
30
|
+
poolProxy: PoolProxyContract;
|
|
20
31
|
/**
|
|
21
32
|
* @param {SuiClient} client SuiClient instance
|
|
22
33
|
* @param {string} address Address of the client
|
|
23
34
|
* @param {Environment} env Environment configuration
|
|
24
35
|
* @param {Object.<string, BalanceManager>} [balanceManagers] Optional initial BalanceManager map
|
|
36
|
+
* @param {Object.<string, MarginManager>} [marginManagers] Optional initial MarginManager map
|
|
25
37
|
* @param {CoinMap} [coins] Optional initial CoinMap
|
|
26
38
|
* @param {PoolMap} [pools] Optional initial PoolMap
|
|
27
39
|
* @param {string} [adminCap] Optional admin capability
|
|
40
|
+
* @param {string} [marginAdminCap] Optional margin admin capability
|
|
41
|
+
* @param {string} [marginMaintainerCap] Optional margin maintainer capability
|
|
28
42
|
*/
|
|
29
|
-
constructor({ client, address, env, balanceManagers, coins, pools, adminCap, }: {
|
|
43
|
+
constructor({ client, address, env, balanceManagers, marginManagers, coins, pools, adminCap, marginAdminCap, marginMaintainerCap, }: {
|
|
30
44
|
client: SuiClient;
|
|
31
45
|
address: string;
|
|
32
46
|
env: Environment;
|
|
33
47
|
balanceManagers?: {
|
|
34
48
|
[key: string]: BalanceManager;
|
|
35
49
|
};
|
|
50
|
+
marginManagers?: {
|
|
51
|
+
[key: string]: MarginManager;
|
|
52
|
+
};
|
|
36
53
|
coins?: CoinMap;
|
|
37
54
|
pools?: PoolMap;
|
|
38
55
|
adminCap?: string;
|
|
56
|
+
marginAdminCap?: string;
|
|
57
|
+
marginMaintainerCap?: string;
|
|
39
58
|
});
|
|
40
59
|
/**
|
|
41
60
|
* @description Check the balance of a balance manager for a specific coin
|
|
@@ -330,4 +349,11 @@ export declare class DeepBookClient {
|
|
|
330
349
|
quote: number;
|
|
331
350
|
deep: number;
|
|
332
351
|
}>;
|
|
352
|
+
getPriceInfoObject(tx: Transaction, coinKey: string): Promise<string>;
|
|
353
|
+
/**
|
|
354
|
+
* @description Get the age of the price info object for a specific coin
|
|
355
|
+
* @param {string} coinKey Key of the coin
|
|
356
|
+
* @returns {Promise<string>} The arrival time of the price info object
|
|
357
|
+
*/
|
|
358
|
+
getPriceInfoObjectAge(coinKey: string): Promise<any>;
|
|
333
359
|
}
|
package/dist/cjs/client.js
CHANGED
|
@@ -38,6 +38,13 @@ var import_deepbookAdmin = require("./transactions/deepbookAdmin.js");
|
|
|
38
38
|
var import_flashLoans = require("./transactions/flashLoans.js");
|
|
39
39
|
var import_governance = require("./transactions/governance.js");
|
|
40
40
|
var import_config = require("./utils/config.js");
|
|
41
|
+
var import_marginAdmin = require("./transactions/marginAdmin.js");
|
|
42
|
+
var import_marginMaintainer = require("./transactions/marginMaintainer.js");
|
|
43
|
+
var import_marginPool = require("./transactions/marginPool.js");
|
|
44
|
+
var import_marginManager = require("./transactions/marginManager.js");
|
|
45
|
+
var import_pyth = require("./pyth/pyth.js");
|
|
46
|
+
var import_pyth2 = require("./pyth/pyth.js");
|
|
47
|
+
var import_poolProxy = require("./transactions/poolProxy.js");
|
|
41
48
|
var _config, _address;
|
|
42
49
|
class DeepBookClient {
|
|
43
50
|
/**
|
|
@@ -45,18 +52,24 @@ class DeepBookClient {
|
|
|
45
52
|
* @param {string} address Address of the client
|
|
46
53
|
* @param {Environment} env Environment configuration
|
|
47
54
|
* @param {Object.<string, BalanceManager>} [balanceManagers] Optional initial BalanceManager map
|
|
55
|
+
* @param {Object.<string, MarginManager>} [marginManagers] Optional initial MarginManager map
|
|
48
56
|
* @param {CoinMap} [coins] Optional initial CoinMap
|
|
49
57
|
* @param {PoolMap} [pools] Optional initial PoolMap
|
|
50
58
|
* @param {string} [adminCap] Optional admin capability
|
|
59
|
+
* @param {string} [marginAdminCap] Optional margin admin capability
|
|
60
|
+
* @param {string} [marginMaintainerCap] Optional margin maintainer capability
|
|
51
61
|
*/
|
|
52
62
|
constructor({
|
|
53
63
|
client,
|
|
54
64
|
address,
|
|
55
65
|
env,
|
|
56
66
|
balanceManagers,
|
|
67
|
+
marginManagers,
|
|
57
68
|
coins,
|
|
58
69
|
pools,
|
|
59
|
-
adminCap
|
|
70
|
+
adminCap,
|
|
71
|
+
marginAdminCap,
|
|
72
|
+
marginMaintainerCap
|
|
60
73
|
}) {
|
|
61
74
|
__privateAdd(this, _config);
|
|
62
75
|
__privateAdd(this, _address);
|
|
@@ -66,15 +79,23 @@ class DeepBookClient {
|
|
|
66
79
|
address: __privateGet(this, _address),
|
|
67
80
|
env,
|
|
68
81
|
balanceManagers,
|
|
82
|
+
marginManagers,
|
|
69
83
|
coins,
|
|
70
84
|
pools,
|
|
71
|
-
adminCap
|
|
85
|
+
adminCap,
|
|
86
|
+
marginAdminCap,
|
|
87
|
+
marginMaintainerCap
|
|
72
88
|
}));
|
|
73
89
|
this.balanceManager = new import_balanceManager.BalanceManagerContract(__privateGet(this, _config));
|
|
74
90
|
this.deepBook = new import_deepbook.DeepBookContract(__privateGet(this, _config));
|
|
75
91
|
this.deepBookAdmin = new import_deepbookAdmin.DeepBookAdminContract(__privateGet(this, _config));
|
|
76
92
|
this.flashLoans = new import_flashLoans.FlashLoanContract(__privateGet(this, _config));
|
|
77
93
|
this.governance = new import_governance.GovernanceContract(__privateGet(this, _config));
|
|
94
|
+
this.marginAdmin = new import_marginAdmin.MarginAdminContract(__privateGet(this, _config));
|
|
95
|
+
this.marginMaintainer = new import_marginMaintainer.MarginMaintainerContract(__privateGet(this, _config));
|
|
96
|
+
this.marginPool = new import_marginPool.MarginPoolContract(__privateGet(this, _config));
|
|
97
|
+
this.marginManager = new import_marginManager.MarginManagerContract(__privateGet(this, _config));
|
|
98
|
+
this.poolProxy = new import_poolProxy.PoolProxyContract(__privateGet(this, _config));
|
|
78
99
|
}
|
|
79
100
|
/**
|
|
80
101
|
* @description Check the balance of a balance manager for a specific coin
|
|
@@ -648,6 +669,47 @@ class DeepBookClient {
|
|
|
648
669
|
deep: deepBalance / import_config.DEEP_SCALAR
|
|
649
670
|
};
|
|
650
671
|
}
|
|
672
|
+
async getPriceInfoObject(tx, coinKey) {
|
|
673
|
+
const currentTime = Date.now();
|
|
674
|
+
const dbusdcPriceInfoObjectAge = await this.getPriceInfoObjectAge(coinKey) * 1e3;
|
|
675
|
+
if (currentTime - dbusdcPriceInfoObjectAge < import_config.PRICE_INFO_OBJECT_MAX_AGE) {
|
|
676
|
+
return await __privateGet(this, _config).getCoin(coinKey).priceInfoObjectId;
|
|
677
|
+
}
|
|
678
|
+
const endpoint = __privateGet(this, _config).env === "testnet" ? "https://hermes-beta.pyth.network" : "https://hermes.pyth.network";
|
|
679
|
+
const connection = new import_pyth.SuiPriceServiceConnection(endpoint);
|
|
680
|
+
const priceIDs = [
|
|
681
|
+
__privateGet(this, _config).getCoin(coinKey).feed
|
|
682
|
+
// ASSET/USD price ID
|
|
683
|
+
];
|
|
684
|
+
const priceUpdateData = await connection.getPriceFeedsUpdateData(priceIDs);
|
|
685
|
+
const wormholeStateId = __privateGet(this, _config).pyth.wormholeStateId;
|
|
686
|
+
const pythStateId = __privateGet(this, _config).pyth.pythStateId;
|
|
687
|
+
const client = new import_pyth2.SuiPythClient(this.client, pythStateId, wormholeStateId);
|
|
688
|
+
return (await client.updatePriceFeeds(tx, priceUpdateData, priceIDs))[0];
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* @description Get the age of the price info object for a specific coin
|
|
692
|
+
* @param {string} coinKey Key of the coin
|
|
693
|
+
* @returns {Promise<string>} The arrival time of the price info object
|
|
694
|
+
*/
|
|
695
|
+
async getPriceInfoObjectAge(coinKey) {
|
|
696
|
+
const priceInfoObjectId = __privateGet(this, _config).getCoin(coinKey).priceInfoObjectId;
|
|
697
|
+
const res = await this.client.getObject({
|
|
698
|
+
id: priceInfoObjectId,
|
|
699
|
+
options: {
|
|
700
|
+
showContent: true
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
if (!res.data?.content) {
|
|
704
|
+
throw new Error(`Price info object not found for ${coinKey}`);
|
|
705
|
+
}
|
|
706
|
+
if ("fields" in res.data.content) {
|
|
707
|
+
const fields = res.data.content.fields;
|
|
708
|
+
return fields.price_info?.fields?.arrival_time;
|
|
709
|
+
} else {
|
|
710
|
+
throw new Error(`Invalid price info object structure for ${coinKey}`);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
651
713
|
}
|
|
652
714
|
_config = new WeakMap();
|
|
653
715
|
_address = new WeakMap();
|
package/dist/cjs/client.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/client.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { bcs } from '@mysten/sui/bcs';\nimport { Account, Order, OrderDeepPrice, VecSet } from './types/bcs.js';\nimport type { SuiClient } from '@mysten/sui/client';\nimport { Transaction } from '@mysten/sui/transactions';\nimport { normalizeSuiAddress } from '@mysten/sui/utils';\n\nimport { BalanceManagerContract } from './transactions/balanceManager.js';\nimport { DeepBookContract } from './transactions/deepbook.js';\nimport { DeepBookAdminContract } from './transactions/deepbookAdmin.js';\nimport { FlashLoanContract } from './transactions/flashLoans.js';\nimport { GovernanceContract } from './transactions/governance.js';\nimport type { BalanceManager, Environment } from './types/index.js';\nimport { DEEP_SCALAR, DeepBookConfig, FLOAT_SCALAR } from './utils/config.js';\nimport type { CoinMap, PoolMap } from './utils/constants.js';\n\n/**\n * DeepBookClient class for managing DeepBook operations.\n */\nexport class DeepBookClient {\n\tclient: SuiClient;\n\t#config: DeepBookConfig;\n\t#address: string;\n\tbalanceManager: BalanceManagerContract;\n\tdeepBook: DeepBookContract;\n\tdeepBookAdmin: DeepBookAdminContract;\n\tflashLoans: FlashLoanContract;\n\tgovernance: GovernanceContract;\n\n\t/**\n\t * @param {SuiClient} client SuiClient instance\n\t * @param {string} address Address of the client\n\t * @param {Environment} env Environment configuration\n\t * @param {Object.<string, BalanceManager>} [balanceManagers] Optional initial BalanceManager map\n\t * @param {CoinMap} [coins] Optional initial CoinMap\n\t * @param {PoolMap} [pools] Optional initial PoolMap\n\t * @param {string} [adminCap] Optional admin capability\n\t */\n\tconstructor({\n\t\tclient,\n\t\taddress,\n\t\tenv,\n\t\tbalanceManagers,\n\t\tcoins,\n\t\tpools,\n\t\tadminCap,\n\t}: {\n\t\tclient: SuiClient;\n\t\taddress: string;\n\t\tenv: Environment;\n\t\tbalanceManagers?: { [key: string]: BalanceManager };\n\t\tcoins?: CoinMap;\n\t\tpools?: PoolMap;\n\t\tadminCap?: string;\n\t}) {\n\t\tthis.client = client;\n\t\tthis.#address = normalizeSuiAddress(address);\n\t\tthis.#config = new DeepBookConfig({\n\t\t\taddress: this.#address,\n\t\t\tenv,\n\t\t\tbalanceManagers,\n\t\t\tcoins,\n\t\t\tpools,\n\t\t\tadminCap,\n\t\t});\n\t\tthis.balanceManager = new BalanceManagerContract(this.#config);\n\t\tthis.deepBook = new DeepBookContract(this.#config);\n\t\tthis.deepBookAdmin = new DeepBookAdminContract(this.#config);\n\t\tthis.flashLoans = new FlashLoanContract(this.#config);\n\t\tthis.governance = new GovernanceContract(this.#config);\n\t}\n\n\t/**\n\t * @description Check the balance of a balance manager for a specific coin\n\t * @param {string} managerKey Key of the balance manager\n\t * @param {string} coinKey Key of the coin\n\t * @returns {Promise<{ coinType: string, balance: number }>} An object with coin type and balance\n\t */\n\tasync checkManagerBalance(managerKey: string, coinKey: string) {\n\t\tconst tx = new Transaction();\n\t\tconst coin = this.#config.getCoin(coinKey);\n\n\t\ttx.add(this.balanceManager.checkManagerBalance(managerKey, coinKey));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: this.#address,\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst bytes = res.results![0].returnValues![0][0];\n\t\tconst parsed_balance = bcs.U64.parse(new Uint8Array(bytes));\n\t\tconst balanceNumber = Number(parsed_balance);\n\t\tconst adjusted_balance = balanceNumber / coin.scalar;\n\n\t\treturn {\n\t\t\tcoinType: coin.type,\n\t\t\tbalance: Number(adjusted_balance.toFixed(9)),\n\t\t};\n\t}\n\n\t/**\n\t * @description Check if a pool is whitelisted\n\t * @param {string} poolKey Key of the pool\n\t * @returns {Promise<boolean>} Boolean indicating if the pool is whitelisted\n\t */\n\tasync whitelisted(poolKey: string) {\n\t\tconst tx = new Transaction();\n\n\t\ttx.add(this.deepBook.whitelisted(poolKey));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst bytes = res.results![0].returnValues![0][0];\n\t\tconst whitelisted = bcs.Bool.parse(new Uint8Array(bytes));\n\n\t\treturn whitelisted;\n\t}\n\n\t/**\n\t * @description Get the quote quantity out for a given base quantity\n\t * @param {string} poolKey Key of the pool\n\t * @param {number} baseQuantity Base quantity to convert\n\t * @returns {Promise<{ baseQuantity: number, baseOut: number, quoteOut: number, deepRequired: number }>}\n\t * An object with base quantity, base out, quote out, and deep required for the dry run\n\t */\n\tasync getQuoteQuantityOut(poolKey: string, baseQuantity: number) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseScalar = this.#config.getCoin(pool.baseCoin).scalar;\n\t\tconst quoteScalar = this.#config.getCoin(pool.quoteCoin).scalar;\n\n\t\ttx.add(this.deepBook.getQuoteQuantityOut(poolKey, baseQuantity));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst baseOut = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![0][0])));\n\t\tconst quoteOut = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![1][0])));\n\t\tconst deepRequired = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![2][0])));\n\n\t\treturn {\n\t\t\tbaseQuantity,\n\t\t\tbaseOut: Number((baseOut / baseScalar).toFixed(9)),\n\t\t\tquoteOut: Number((quoteOut / quoteScalar).toFixed(9)),\n\t\t\tdeepRequired: Number((deepRequired / DEEP_SCALAR).toFixed(9)),\n\t\t};\n\t}\n\n\t/**\n\t * @description Get the base quantity out for a given quote quantity\n\t * @param {string} poolKey Key of the pool\n\t * @param {number} quoteQuantity Quote quantity to convert\n\t * @returns {Promise<{ quoteQuantity: number, baseOut: number, quoteOut: number, deepRequired: number }>}\n\t * An object with quote quantity, base out, quote out, and deep required for the dry run\n\t */\n\tasync getBaseQuantityOut(poolKey: string, quoteQuantity: number) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseScalar = this.#config.getCoin(pool.baseCoin).scalar;\n\t\tconst quoteScalar = this.#config.getCoin(pool.quoteCoin).scalar;\n\n\t\ttx.add(this.deepBook.getBaseQuantityOut(poolKey, quoteQuantity));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst baseOut = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![0][0])));\n\t\tconst quoteOut = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![1][0])));\n\t\tconst deepRequired = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![2][0])));\n\n\t\treturn {\n\t\t\tquoteQuantity: quoteQuantity,\n\t\t\tbaseOut: Number((baseOut / baseScalar).toFixed(9)),\n\t\t\tquoteOut: Number((quoteOut / quoteScalar).toFixed(9)),\n\t\t\tdeepRequired: Number((deepRequired / DEEP_SCALAR).toFixed(9)),\n\t\t};\n\t}\n\n\t/**\n\t * @description Get the output quantities for given base and quote quantities. Only one quantity can be non-zero\n\t * @param {string} poolKey Key of the pool\n\t * @param {number} baseQuantity Base quantity to convert\n\t * @param {number} quoteQuantity Quote quantity to convert\n\t * @returns {Promise<{ baseQuantity: number, quoteQuantity: number, baseOut: number, quoteOut: number, deepRequired: number }>}\n\t * An object with base quantity, quote quantity, base out, quote out, and deep required for the dry run\n\t */\n\tasync getQuantityOut(poolKey: string, baseQuantity: number, quoteQuantity: number) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseScalar = this.#config.getCoin(pool.baseCoin).scalar;\n\t\tconst quoteScalar = this.#config.getCoin(pool.quoteCoin).scalar;\n\n\t\ttx.add(this.deepBook.getQuantityOut(poolKey, baseQuantity, quoteQuantity));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst baseOut = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![0][0])));\n\t\tconst quoteOut = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![1][0])));\n\t\tconst deepRequired = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![2][0])));\n\n\t\treturn {\n\t\t\tbaseQuantity,\n\t\t\tquoteQuantity,\n\t\t\tbaseOut: Number((baseOut / baseScalar).toFixed(9)),\n\t\t\tquoteOut: Number((quoteOut / quoteScalar).toFixed(9)),\n\t\t\tdeepRequired: Number((deepRequired / DEEP_SCALAR).toFixed(9)),\n\t\t};\n\t}\n\n\t/**\n\t * @description Get open orders for a balance manager in a pool\n\t * @param {string} poolKey Key of the pool\n\t * @param {string} managerKey Key of the balance manager\n\t * @returns {Promise<Array>} An array of open order IDs\n\t */\n\tasync accountOpenOrders(poolKey: string, managerKey: string) {\n\t\tconst tx = new Transaction();\n\n\t\ttx.add(this.deepBook.accountOpenOrders(poolKey, managerKey));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst order_ids = res.results![0].returnValues![0][0];\n\n\t\treturn VecSet(bcs.u128()).parse(new Uint8Array(order_ids)).contents;\n\t}\n\n\t/**\n\t * @description Get the order information for a specific order in a pool\n\t * @param {string} poolKey Key of the pool\n\t * @param {string} orderId Order ID\n\t * @returns {Promise<Object>} A promise that resolves to an object containing the order information\n\t */\n\tasync getOrder(poolKey: string, orderId: string) {\n\t\tconst tx = new Transaction();\n\n\t\ttx.add(this.deepBook.getOrder(poolKey, orderId));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\ttry {\n\t\t\tconst orderInformation = res.results![0].returnValues![0][0];\n\t\t\treturn Order.parse(new Uint8Array(orderInformation));\n\t\t} catch (e) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * @description Get the order information for a specific order in a pool, with normalized price\n\t * @param {string} poolKey Key of the pool\n\t * @param {string} orderId Order ID\n\t * @returns {Promise<Object>} A promise that resolves to an object containing the order information with normalized price\n\t */\n\tasync getOrderNormalized(poolKey: string, orderId: string) {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.deepBook.getOrder(poolKey, orderId));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\ttry {\n\t\t\tconst orderInformation = res.results![0].returnValues![0][0];\n\t\t\tconst orderInfo = Order.parse(new Uint8Array(orderInformation));\n\n\t\t\tif (!orderInfo) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst baseCoin = this.#config.getCoin(this.#config.getPool(poolKey).baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(this.#config.getPool(poolKey).quoteCoin);\n\t\t\tconst { isBid, price: rawPrice } = this.decodeOrderId(BigInt(orderInfo.order_id));\n\t\t\tconst normalizedPrice = (rawPrice * baseCoin.scalar) / quoteCoin.scalar / FLOAT_SCALAR;\n\n\t\t\tconst normalizedOrderInfo = {\n\t\t\t\t...orderInfo,\n\t\t\t\tquantity: String((Number(orderInfo.quantity) / baseCoin.scalar).toFixed(9)),\n\t\t\t\tfilled_quantity: String((Number(orderInfo.filled_quantity) / baseCoin.scalar).toFixed(9)),\n\t\t\t\torder_deep_price: {\n\t\t\t\t\t...orderInfo.order_deep_price,\n\t\t\t\t\tdeep_per_asset: String(\n\t\t\t\t\t\t(Number(orderInfo.order_deep_price.deep_per_asset) / DEEP_SCALAR).toFixed(9),\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\tisBid,\n\t\t\t\tnormalized_price: normalizedPrice.toFixed(9),\n\t\t\t};\n\t\t\treturn normalizedOrderInfo;\n\t\t} catch (e) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * @description Retrieves information for multiple specific orders in a pool.\n\t * @param {string} poolKey - The key identifying the pool from which to retrieve order information.\n\t * @param {string[]} orderIds - List of order IDs to retrieve information for.\n\t * @returns {Promise<Object[] | null>} A promise that resolves to an array of order objects, each containing details such as\n\t * balance manager ID, order ID, client order ID, quantity, filled quantity, fee information, order price, epoch, status,\n\t * and expiration timestamp. Returns `null` if the retrieval fails.\n\t */\n\tasync getOrders(poolKey: string, orderIds: string[]) {\n\t\tconst tx = new Transaction();\n\n\t\ttx.add(this.deepBook.getOrders(poolKey, orderIds));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\ttry {\n\t\t\tconst orderInformation = res.results![0].returnValues![0][0];\n\t\t\treturn bcs.vector(Order).parse(new Uint8Array(orderInformation));\n\t\t} catch (e) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * @description Get level 2 order book specifying range of price\n\t * @param {string} poolKey Key of the pool\n\t * @param {number} priceLow Lower bound of the price range\n\t * @param {number} priceHigh Upper bound of the price range\n\t * @param {boolean} isBid Whether to get bid or ask orders\n\t * @returns {Promise<{ prices: Array<number>, quantities: Array<number> }>}\n\t * An object with arrays of prices and quantities\n\t */\n\tasync getLevel2Range(poolKey: string, priceLow: number, priceHigh: number, isBid: boolean) {\n\t\tconst tx = new 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\n\t\ttx.add(this.deepBook.getLevel2Range(poolKey, priceLow, priceHigh, isBid));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst prices = res.results![0].returnValues![0][0];\n\t\tconst parsed_prices = bcs.vector(bcs.u64()).parse(new Uint8Array(prices));\n\t\tconst quantities = res.results![0].returnValues![1][0];\n\t\tconst parsed_quantities = bcs.vector(bcs.u64()).parse(new Uint8Array(quantities));\n\n\t\treturn {\n\t\t\tprices: parsed_prices.map((price) =>\n\t\t\t\tNumber(((Number(price) / FLOAT_SCALAR / quoteCoin.scalar) * baseCoin.scalar).toFixed(9)),\n\t\t\t),\n\t\t\tquantities: parsed_quantities.map((price) =>\n\t\t\t\tNumber((Number(price) / baseCoin.scalar).toFixed(9)),\n\t\t\t),\n\t\t};\n\t}\n\n\t/**\n\t * @description Get level 2 order book ticks from mid-price for a pool\n\t * @param {string} poolKey Key of the pool\n\t * @param {number} ticks Number of ticks from mid-price\n\t * @returns {Promise<{ bid_prices: Array<number>, bid_quantities: Array<number>, ask_prices: Array<number>, ask_quantities: Array<number> }>}\n\t * An object with arrays of prices and quantities\n\t */\n\tasync getLevel2TicksFromMid(poolKey: string, ticks: number) {\n\t\tconst tx = new 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\n\t\ttx.add(this.deepBook.getLevel2TicksFromMid(poolKey, ticks));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst bid_prices = res.results![0].returnValues![0][0];\n\t\tconst bid_parsed_prices = bcs.vector(bcs.u64()).parse(new Uint8Array(bid_prices));\n\t\tconst bid_quantities = res.results![0].returnValues![1][0];\n\t\tconst bid_parsed_quantities = bcs.vector(bcs.u64()).parse(new Uint8Array(bid_quantities));\n\n\t\tconst ask_prices = res.results![0].returnValues![2][0];\n\t\tconst ask_parsed_prices = bcs.vector(bcs.u64()).parse(new Uint8Array(ask_prices));\n\t\tconst ask_quantities = res.results![0].returnValues![3][0];\n\t\tconst ask_parsed_quantities = bcs.vector(bcs.u64()).parse(new Uint8Array(ask_quantities));\n\n\t\treturn {\n\t\t\tbid_prices: bid_parsed_prices.map((price) =>\n\t\t\t\tNumber(((Number(price) / FLOAT_SCALAR / quoteCoin.scalar) * baseCoin.scalar).toFixed(9)),\n\t\t\t),\n\t\t\tbid_quantities: bid_parsed_quantities.map((quantity) =>\n\t\t\t\tNumber((Number(quantity) / baseCoin.scalar).toFixed(9)),\n\t\t\t),\n\t\t\task_prices: ask_parsed_prices.map((price) =>\n\t\t\t\tNumber(((Number(price) / FLOAT_SCALAR / quoteCoin.scalar) * baseCoin.scalar).toFixed(9)),\n\t\t\t),\n\t\t\task_quantities: ask_parsed_quantities.map((quantity) =>\n\t\t\t\tNumber((Number(quantity) / baseCoin.scalar).toFixed(9)),\n\t\t\t),\n\t\t};\n\t}\n\n\t/**\n\t * @description Get the vault balances for a pool\n\t * @param {string} poolKey Key of the pool\n\t * @returns {Promise<{ base: number, quote: number, deep: number }>}\n\t * An object with base, quote, and deep balances in the vault\n\t */\n\tasync vaultBalances(poolKey: string) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseScalar = this.#config.getCoin(pool.baseCoin).scalar;\n\t\tconst quoteScalar = this.#config.getCoin(pool.quoteCoin).scalar;\n\n\t\ttx.add(this.deepBook.vaultBalances(poolKey));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst baseInVault = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![0][0])));\n\t\tconst quoteInVault = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![1][0])));\n\t\tconst deepInVault = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![2][0])));\n\n\t\treturn {\n\t\t\tbase: Number((baseInVault / baseScalar).toFixed(9)),\n\t\t\tquote: Number((quoteInVault / quoteScalar).toFixed(9)),\n\t\t\tdeep: Number((deepInVault / DEEP_SCALAR).toFixed(9)),\n\t\t};\n\t}\n\n\t/**\n\t * @description Get the pool ID by asset types\n\t * @param {string} baseType Type of the base asset\n\t * @param {string} quoteType Type of the quote asset\n\t * @returns {Promise<string>} The address of the pool\n\t */\n\tasync getPoolIdByAssets(baseType: string, quoteType: string) {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.deepBook.getPoolIdByAssets(baseType, quoteType));\n\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst address = bcs.Address.parse(new Uint8Array(res.results![0].returnValues![0][0]));\n\n\t\treturn address;\n\t}\n\n\t/**\n\t * @description Get the mid price for a pool\n\t * @param {string} poolKey Key of the pool\n\t * @returns {Promise<number>} The mid price\n\t */\n\tasync midPrice(poolKey: string) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\ttx.add(this.deepBook.midPrice(poolKey));\n\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst bytes = res.results![0].returnValues![0][0];\n\t\tconst parsed_mid_price = Number(bcs.U64.parse(new Uint8Array(bytes)));\n\t\tconst adjusted_mid_price =\n\t\t\t(parsed_mid_price * baseCoin.scalar) / quoteCoin.scalar / FLOAT_SCALAR;\n\n\t\treturn Number(adjusted_mid_price.toFixed(9));\n\t}\n\n\t/**\n\t * @description Get the trade parameters for a given pool, including taker fee, maker fee, and stake required.\n\t * @param {string} poolKey Key of the pool\n\t * @returns {Promise<{ takerFee: number, makerFee: number, stakeRequired: number }>}\n\t */\n\tasync poolTradeParams(poolKey: string) {\n\t\tconst tx = new Transaction();\n\n\t\ttx.add(this.deepBook.poolTradeParams(poolKey));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst takerFee = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![0][0])));\n\t\tconst makerFee = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![1][0])));\n\t\tconst stakeRequired = Number(\n\t\t\tbcs.U64.parse(new Uint8Array(res.results![0].returnValues![2][0])),\n\t\t);\n\n\t\treturn {\n\t\t\ttakerFee: Number(takerFee / FLOAT_SCALAR),\n\t\t\tmakerFee: Number(makerFee / FLOAT_SCALAR),\n\t\t\tstakeRequired: Number(stakeRequired / DEEP_SCALAR),\n\t\t};\n\t}\n\n\t/**\n\t * @description Get the trade parameters for a given pool, including tick size, lot size, and min size.\n\t * @param {string} poolKey Key of the pool\n\t * @returns {Promise<{ tickSize: number, lotSize: number, minSize: number }>}\n\t */\n\tasync poolBookParams(poolKey: string) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseScalar = this.#config.getCoin(pool.baseCoin).scalar;\n\t\tconst quoteScalar = this.#config.getCoin(pool.quoteCoin).scalar;\n\n\t\ttx.add(this.deepBook.poolBookParams(poolKey));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst tickSize = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![0][0])));\n\t\tconst lotSize = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![1][0])));\n\t\tconst minSize = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![2][0])));\n\n\t\treturn {\n\t\t\ttickSize: Number((tickSize * baseScalar) / quoteScalar / FLOAT_SCALAR),\n\t\t\tlotSize: Number(lotSize / baseScalar),\n\t\t\tminSize: Number(minSize / baseScalar),\n\t\t};\n\t}\n\n\t/**\n\t * @description Get the account information for a given pool and balance manager\n\t * @param {string} poolKey Key of the pool\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @returns {Promise<Object>} A promise that resolves to an object containing the account information\n\t */\n\tasync account(poolKey: string, managerKey: string) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseScalar = this.#config.getCoin(pool.baseCoin).scalar;\n\t\tconst quoteScalar = this.#config.getCoin(pool.quoteCoin).scalar;\n\n\t\ttx.add(this.deepBook.account(poolKey, managerKey));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst accountInformation = res.results![0].returnValues![0][0];\n\t\tconst accountInfo = Account.parse(new Uint8Array(accountInformation));\n\n\t\treturn {\n\t\t\tepoch: accountInfo.epoch,\n\t\t\topen_orders: accountInfo.open_orders,\n\t\t\ttaker_volume: Number(accountInfo.taker_volume) / baseScalar,\n\t\t\tmaker_volume: Number(accountInfo.maker_volume) / baseScalar,\n\t\t\tactive_stake: Number(accountInfo.active_stake) / DEEP_SCALAR,\n\t\t\tinactive_stake: Number(accountInfo.inactive_stake) / DEEP_SCALAR,\n\t\t\tcreated_proposal: accountInfo.created_proposal,\n\t\t\tvoted_proposal: accountInfo.voted_proposal,\n\t\t\tunclaimed_rebates: {\n\t\t\t\tbase: Number(accountInfo.unclaimed_rebates.base) / baseScalar,\n\t\t\t\tquote: Number(accountInfo.unclaimed_rebates.quote) / quoteScalar,\n\t\t\t\tdeep: Number(accountInfo.unclaimed_rebates.deep) / DEEP_SCALAR,\n\t\t\t},\n\t\t\tsettled_balances: {\n\t\t\t\tbase: Number(accountInfo.settled_balances.base) / baseScalar,\n\t\t\t\tquote: Number(accountInfo.settled_balances.quote) / quoteScalar,\n\t\t\t\tdeep: Number(accountInfo.settled_balances.deep) / DEEP_SCALAR,\n\t\t\t},\n\t\t\towed_balances: {\n\t\t\t\tbase: Number(accountInfo.owed_balances.base) / baseScalar,\n\t\t\t\tquote: Number(accountInfo.owed_balances.quote) / quoteScalar,\n\t\t\t\tdeep: Number(accountInfo.owed_balances.deep) / DEEP_SCALAR,\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * @description Get the locked balances for a pool and balance manager\n\t * @param {string} poolKey Key of the pool\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @returns {Promise<{ base: number, quote: number, deep: number }>}\n\t * An object with base, quote, and deep locked for the balance manager in the pool\n\t */\n\tasync lockedBalance(poolKey: string, balanceManagerKey: string) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseScalar = this.#config.getCoin(pool.baseCoin).scalar;\n\t\tconst quoteScalar = this.#config.getCoin(pool.quoteCoin).scalar;\n\n\t\ttx.add(this.deepBook.lockedBalance(poolKey, balanceManagerKey));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst baseLocked = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![0][0])));\n\t\tconst quoteLocked = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![1][0])));\n\t\tconst deepLocked = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![2][0])));\n\n\t\treturn {\n\t\t\tbase: Number((baseLocked / baseScalar).toFixed(9)),\n\t\t\tquote: Number((quoteLocked / quoteScalar).toFixed(9)),\n\t\t\tdeep: Number((deepLocked / DEEP_SCALAR).toFixed(9)),\n\t\t};\n\t}\n\n\t/**\n\t * @description Get the DEEP price conversion for a pool\n\t * @param {string} poolKey Key of the pool\n\t * @returns {Promise<{ asset_is_base: bool, deep_per_quote: number }>} Deep price conversion\n\t */\n\tasync getPoolDeepPrice(poolKey: string) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\ttx.add(this.deepBook.getPoolDeepPrice(poolKey));\n\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\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst poolDeepPriceBytes = res.results![0].returnValues![0][0];\n\t\tconst poolDeepPrice = OrderDeepPrice.parse(new Uint8Array(poolDeepPriceBytes));\n\n\t\tif (poolDeepPrice.asset_is_base) {\n\t\t\treturn {\n\t\t\t\tasset_is_base: poolDeepPrice.asset_is_base,\n\t\t\t\tdeep_per_base:\n\t\t\t\t\t((Number(poolDeepPrice.deep_per_asset) / FLOAT_SCALAR) * baseCoin.scalar) /\n\t\t\t\t\tdeepCoin.scalar,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tasset_is_base: poolDeepPrice.asset_is_base,\n\t\t\t\tdeep_per_quote:\n\t\t\t\t\t((Number(poolDeepPrice.deep_per_asset) / FLOAT_SCALAR) * quoteCoin.scalar) /\n\t\t\t\t\tdeepCoin.scalar,\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * @description Decode the order ID to get bid/ask status, price, and orderId\n\t * @param {bigint} encodedOrderId Encoded order ID\n\t * @returns {Object} Object containing isBid, price, and orderId\n\t */\n\tdecodeOrderId(encodedOrderId: bigint): { isBid: boolean; price: number; orderId: number } {\n\t\tconst isBid = encodedOrderId >> 127n === 0n;\n\t\tconst price = Number((encodedOrderId >> 64n) & ((1n << 63n) - 1n));\n\t\tconst orderId = Number(encodedOrderId & ((1n << 64n) - 1n));\n\n\t\treturn { isBid, price, orderId };\n\t}\n\n\t/**\n\t * @description Get all balance manager IDs for a given owner\n\t * @param {string} owner The owner address to get balance manager IDs for\n\t * @returns {Promise<string[]>} Array of balance manager ID strings\n\t */\n\tasync getBalanceManagerIds(owner: string): Promise<string[]> {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.deepBook.getBalanceManagerIds(owner));\n\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst bytes = res.results![0].returnValues![0][0];\n\t\tconst vecOfAddresses = bcs.vector(bcs.Address).parse(new Uint8Array(bytes));\n\n\t\treturn vecOfAddresses.map((id: string) => normalizeSuiAddress(id));\n\t}\n\n\t/**\n\t * @description Get the owner of the referral\n\t * @param {string} referral The ID of the referral to get the owner of\n\t * @returns {Promise<string>} The owner of the referral\n\t */\n\tasync referralOwner(referral: string) {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.balanceManager.referralOwner(referral));\n\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst bytes = res.results![0].returnValues![0][0];\n\t\tconst owner = bcs.Address.parse(new Uint8Array(bytes));\n\n\t\treturn owner;\n\t}\n\n\t/**\n\t * @description Get the referral balances for a pool and referral\n\t * @param {string} poolKey Key of the pool\n\t * @param {string} referral The referral ID to get balances for\n\t * @returns {Promise<{ base: number, quote: number, deep: number }>} Object with base, quote, and deep balances\n\t */\n\tasync getReferralBalances(\n\t\tpoolKey: string,\n\t\treferral: string,\n\t): Promise<{ base: number; quote: number; deep: number }> {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseScalar = this.#config.getCoin(pool.baseCoin).scalar;\n\t\tconst quoteScalar = this.#config.getCoin(pool.quoteCoin).scalar;\n\n\t\ttx.add(this.deepBook.getReferralBalances(poolKey, referral));\n\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\t// The function returns three u64 values: (base, quote, deep)\n\t\tconst baseBytes = res.results![0].returnValues![0][0];\n\t\tconst quoteBytes = res.results![0].returnValues![1][0];\n\t\tconst deepBytes = res.results![0].returnValues![2][0];\n\n\t\tconst baseBalance = Number(bcs.U64.parse(new Uint8Array(baseBytes)));\n\t\tconst quoteBalance = Number(bcs.U64.parse(new Uint8Array(quoteBytes)));\n\t\tconst deepBalance = Number(bcs.U64.parse(new Uint8Array(deepBytes)));\n\n\t\treturn {\n\t\t\tbase: baseBalance / baseScalar,\n\t\t\tquote: quoteBalance / quoteScalar,\n\t\t\tdeep: deepBalance / DEEP_SCALAR,\n\t\t};\n\t}\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAoB;AACpB,IAAAA,cAAuD;AAEvD,0BAA4B;AAC5B,mBAAoC;AAEpC,4BAAuC;AACvC,sBAAiC;AACjC,2BAAsC;AACtC,wBAAkC;AAClC,wBAAmC;AAEnC,oBAA0D;AAd1D;AAoBO,MAAM,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmB3B,YAAY;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,GAQG;AAjCH;AACA;AAiCC,SAAK,SAAS;AACd,uBAAK,cAAW,kCAAoB,OAAO;AAC3C,uBAAK,SAAU,IAAI,6BAAe;AAAA,MACjC,SAAS,mBAAK;AAAA,MACd;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAC;AACD,SAAK,iBAAiB,IAAI,6CAAuB,mBAAK,QAAO;AAC7D,SAAK,WAAW,IAAI,iCAAiB,mBAAK,QAAO;AACjD,SAAK,gBAAgB,IAAI,2CAAsB,mBAAK,QA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AAAA,IACnB,CAAC;AAGD,UAAM,YAAY,IAAI,QAAS,CAAC,EAAE,aAAc,CAAC,EAAE,CAAC;AACpD,UAAM,aAAa,IAAI,QAAS,CAAC,EAAE,aAAc,CAAC,EAAE,CAAC;AACrD,UAAM,YAAY,IAAI,QAAS,CAAC,EAAE,aAAc,CAAC,EAAE,CAAC;AAEpD,UAAM,cAAc,OAAO,eAAI,IAAI,MAAM,IAAI,WAAW,SAAS,CAAC,CAAC;AACnE,UAAM,eAAe,OAAO,eAAI,IAAI,MAAM,IAAI,WAAW,UAAU,CAAC,CAAC;AACrE,UAAM,cAAc,OAAO,eAAI,IAAI,MAAM,IAAI,WAAW,SAAS,CAAC,CAAC;AAEnE,WAAO;AAAA,MACN,MAAM,cAAc;AAAA,MACpB,OAAO,eAAe;AAAA,MACtB,MAAM,cAAc;AAAA,IACrB;AAAA,EACD;AACD;AAptBC;AACA;",
|
|
6
|
-
"names": ["import_bcs"]
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { bcs } from '@mysten/sui/bcs';\nimport { Account, Order, OrderDeepPrice, VecSet } from './types/bcs.js';\nimport type { SuiClient } from '@mysten/sui/client';\nimport { Transaction } from '@mysten/sui/transactions';\nimport { normalizeSuiAddress } from '@mysten/sui/utils';\n\nimport { BalanceManagerContract } from './transactions/balanceManager.js';\nimport { DeepBookContract } from './transactions/deepbook.js';\nimport { DeepBookAdminContract } from './transactions/deepbookAdmin.js';\nimport { FlashLoanContract } from './transactions/flashLoans.js';\nimport { GovernanceContract } from './transactions/governance.js';\nimport type { BalanceManager, Environment, MarginManager } from './types/index.js';\nimport {\n\tDEEP_SCALAR,\n\tDeepBookConfig,\n\tFLOAT_SCALAR,\n\tPRICE_INFO_OBJECT_MAX_AGE,\n} from './utils/config.js';\nimport type { CoinMap, PoolMap } from './utils/constants.js';\nimport { MarginAdminContract } from './transactions/marginAdmin.js';\nimport { MarginMaintainerContract } from './transactions/marginMaintainer.js';\nimport { MarginPoolContract } from './transactions/marginPool.js';\nimport { MarginManagerContract } from './transactions/marginManager.js';\nimport { SuiPriceServiceConnection } from './pyth/pyth.js';\nimport { SuiPythClient } from './pyth/pyth.js';\nimport { PoolProxyContract } from './transactions/poolProxy.js';\n\n/**\n * DeepBookClient class for managing DeepBook operations.\n */\nexport class DeepBookClient {\n\tclient: SuiClient;\n\t#config: DeepBookConfig;\n\t#address: string;\n\tbalanceManager: BalanceManagerContract;\n\tdeepBook: DeepBookContract;\n\tdeepBookAdmin: DeepBookAdminContract;\n\tflashLoans: FlashLoanContract;\n\tgovernance: GovernanceContract;\n\tmarginAdmin: MarginAdminContract;\n\tmarginMaintainer: MarginMaintainerContract;\n\tmarginPool: MarginPoolContract;\n\tmarginManager: MarginManagerContract;\n\tpoolProxy: PoolProxyContract;\n\n\t/**\n\t * @param {SuiClient} client SuiClient instance\n\t * @param {string} address Address of the client\n\t * @param {Environment} env Environment configuration\n\t * @param {Object.<string, BalanceManager>} [balanceManagers] Optional initial BalanceManager map\n\t * @param {Object.<string, MarginManager>} [marginManagers] Optional initial MarginManager map\n\t * @param {CoinMap} [coins] Optional initial CoinMap\n\t * @param {PoolMap} [pools] Optional initial PoolMap\n\t * @param {string} [adminCap] Optional admin capability\n\t * @param {string} [marginAdminCap] Optional margin admin capability\n\t * @param {string} [marginMaintainerCap] Optional margin maintainer capability\n\t */\n\tconstructor({\n\t\tclient,\n\t\taddress,\n\t\tenv,\n\t\tbalanceManagers,\n\t\tmarginManagers,\n\t\tcoins,\n\t\tpools,\n\t\tadminCap,\n\t\tmarginAdminCap,\n\t\tmarginMaintainerCap,\n\t}: {\n\t\tclient: SuiClient;\n\t\taddress: string;\n\t\tenv: Environment;\n\t\tbalanceManagers?: { [key: string]: BalanceManager };\n\t\tmarginManagers?: { [key: string]: MarginManager };\n\t\tcoins?: CoinMap;\n\t\tpools?: PoolMap;\n\t\tadminCap?: string;\n\t\tmarginAdminCap?: string;\n\t\tmarginMaintainerCap?: string;\n\t}) {\n\t\tthis.client = client;\n\t\tthis.#address = normalizeSuiAddress(address);\n\t\tthis.#config = new DeepBookConfig({\n\t\t\taddress: this.#address,\n\t\t\tenv,\n\t\t\tbalanceManagers,\n\t\t\tmarginManagers,\n\t\t\tcoins,\n\t\t\tpools,\n\t\t\tadminCap,\n\t\t\tmarginAdminCap,\n\t\t\tmarginMaintainerCap,\n\t\t});\n\t\tthis.balanceManager = new BalanceManagerContract(this.#config);\n\t\tthis.deepBook = new DeepBookContract(this.#config);\n\t\tthis.deepBookAdmin = new DeepBookAdminContract(this.#config);\n\t\tthis.flashLoans = new FlashLoanContract(this.#config);\n\t\tthis.governance = new GovernanceContract(this.#config);\n\t\tthis.marginAdmin = new MarginAdminContract(this.#config);\n\t\tthis.marginMaintainer = new MarginMaintainerContract(this.#config);\n\t\tthis.marginPool = new MarginPoolContract(this.#config);\n\t\tthis.marginManager = new MarginManagerContract(this.#config);\n\t\tthis.poolProxy = new PoolProxyContract(this.#config);\n\t}\n\n\t/**\n\t * @description Check the balance of a balance manager for a specific coin\n\t * @param {string} managerKey Key of the balance manager\n\t * @param {string} coinKey Key of the coin\n\t * @returns {Promise<{ coinType: string, balance: number }>} An object with coin type and balance\n\t */\n\tasync checkManagerBalance(managerKey: string, coinKey: string) {\n\t\tconst tx = new Transaction();\n\t\tconst coin = this.#config.getCoin(coinKey);\n\n\t\ttx.add(this.balanceManager.checkManagerBalance(managerKey, coinKey));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: this.#address,\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst bytes = res.results![0].returnValues![0][0];\n\t\tconst parsed_balance = bcs.U64.parse(new Uint8Array(bytes));\n\t\tconst balanceNumber = Number(parsed_balance);\n\t\tconst adjusted_balance = balanceNumber / coin.scalar;\n\n\t\treturn {\n\t\t\tcoinType: coin.type,\n\t\t\tbalance: Number(adjusted_balance.toFixed(9)),\n\t\t};\n\t}\n\n\t/**\n\t * @description Check if a pool is whitelisted\n\t * @param {string} poolKey Key of the pool\n\t * @returns {Promise<boolean>} Boolean indicating if the pool is whitelisted\n\t */\n\tasync whitelisted(poolKey: string) {\n\t\tconst tx = new Transaction();\n\n\t\ttx.add(this.deepBook.whitelisted(poolKey));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst bytes = res.results![0].returnValues![0][0];\n\t\tconst whitelisted = bcs.Bool.parse(new Uint8Array(bytes));\n\n\t\treturn whitelisted;\n\t}\n\n\t/**\n\t * @description Get the quote quantity out for a given base quantity\n\t * @param {string} poolKey Key of the pool\n\t * @param {number} baseQuantity Base quantity to convert\n\t * @returns {Promise<{ baseQuantity: number, baseOut: number, quoteOut: number, deepRequired: number }>}\n\t * An object with base quantity, base out, quote out, and deep required for the dry run\n\t */\n\tasync getQuoteQuantityOut(poolKey: string, baseQuantity: number) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseScalar = this.#config.getCoin(pool.baseCoin).scalar;\n\t\tconst quoteScalar = this.#config.getCoin(pool.quoteCoin).scalar;\n\n\t\ttx.add(this.deepBook.getQuoteQuantityOut(poolKey, baseQuantity));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst baseOut = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![0][0])));\n\t\tconst quoteOut = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![1][0])));\n\t\tconst deepRequired = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![2][0])));\n\n\t\treturn {\n\t\t\tbaseQuantity,\n\t\t\tbaseOut: Number((baseOut / baseScalar).toFixed(9)),\n\t\t\tquoteOut: Number((quoteOut / quoteScalar).toFixed(9)),\n\t\t\tdeepRequired: Number((deepRequired / DEEP_SCALAR).toFixed(9)),\n\t\t};\n\t}\n\n\t/**\n\t * @description Get the base quantity out for a given quote quantity\n\t * @param {string} poolKey Key of the pool\n\t * @param {number} quoteQuantity Quote quantity to convert\n\t * @returns {Promise<{ quoteQuantity: number, baseOut: number, quoteOut: number, deepRequired: number }>}\n\t * An object with quote quantity, base out, quote out, and deep required for the dry run\n\t */\n\tasync getBaseQuantityOut(poolKey: string, quoteQuantity: number) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseScalar = this.#config.getCoin(pool.baseCoin).scalar;\n\t\tconst quoteScalar = this.#config.getCoin(pool.quoteCoin).scalar;\n\n\t\ttx.add(this.deepBook.getBaseQuantityOut(poolKey, quoteQuantity));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst baseOut = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![0][0])));\n\t\tconst quoteOut = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![1][0])));\n\t\tconst deepRequired = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![2][0])));\n\n\t\treturn {\n\t\t\tquoteQuantity: quoteQuantity,\n\t\t\tbaseOut: Number((baseOut / baseScalar).toFixed(9)),\n\t\t\tquoteOut: Number((quoteOut / quoteScalar).toFixed(9)),\n\t\t\tdeepRequired: Number((deepRequired / DEEP_SCALAR).toFixed(9)),\n\t\t};\n\t}\n\n\t/**\n\t * @description Get the output quantities for given base and quote quantities. Only one quantity can be non-zero\n\t * @param {string} poolKey Key of the pool\n\t * @param {number} baseQuantity Base quantity to convert\n\t * @param {number} quoteQuantity Quote quantity to convert\n\t * @returns {Promise<{ baseQuantity: number, quoteQuantity: number, baseOut: number, quoteOut: number, deepRequired: number }>}\n\t * An object with base quantity, quote quantity, base out, quote out, and deep required for the dry run\n\t */\n\tasync getQuantityOut(poolKey: string, baseQuantity: number, quoteQuantity: number) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseScalar = this.#config.getCoin(pool.baseCoin).scalar;\n\t\tconst quoteScalar = this.#config.getCoin(pool.quoteCoin).scalar;\n\n\t\ttx.add(this.deepBook.getQuantityOut(poolKey, baseQuantity, quoteQuantity));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst baseOut = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![0][0])));\n\t\tconst quoteOut = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![1][0])));\n\t\tconst deepRequired = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![2][0])));\n\n\t\treturn {\n\t\t\tbaseQuantity,\n\t\t\tquoteQuantity,\n\t\t\tbaseOut: Number((baseOut / baseScalar).toFixed(9)),\n\t\t\tquoteOut: Number((quoteOut / quoteScalar).toFixed(9)),\n\t\t\tdeepRequired: Number((deepRequired / DEEP_SCALAR).toFixed(9)),\n\t\t};\n\t}\n\n\t/**\n\t * @description Get open orders for a balance manager in a pool\n\t * @param {string} poolKey Key of the pool\n\t * @param {string} managerKey Key of the balance manager\n\t * @returns {Promise<Array>} An array of open order IDs\n\t */\n\tasync accountOpenOrders(poolKey: string, managerKey: string) {\n\t\tconst tx = new Transaction();\n\n\t\ttx.add(this.deepBook.accountOpenOrders(poolKey, managerKey));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst order_ids = res.results![0].returnValues![0][0];\n\n\t\treturn VecSet(bcs.u128()).parse(new Uint8Array(order_ids)).contents;\n\t}\n\n\t/**\n\t * @description Get the order information for a specific order in a pool\n\t * @param {string} poolKey Key of the pool\n\t * @param {string} orderId Order ID\n\t * @returns {Promise<Object>} A promise that resolves to an object containing the order information\n\t */\n\tasync getOrder(poolKey: string, orderId: string) {\n\t\tconst tx = new Transaction();\n\n\t\ttx.add(this.deepBook.getOrder(poolKey, orderId));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\ttry {\n\t\t\tconst orderInformation = res.results![0].returnValues![0][0];\n\t\t\treturn Order.parse(new Uint8Array(orderInformation));\n\t\t} catch (e) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * @description Get the order information for a specific order in a pool, with normalized price\n\t * @param {string} poolKey Key of the pool\n\t * @param {string} orderId Order ID\n\t * @returns {Promise<Object>} A promise that resolves to an object containing the order information with normalized price\n\t */\n\tasync getOrderNormalized(poolKey: string, orderId: string) {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.deepBook.getOrder(poolKey, orderId));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\ttry {\n\t\t\tconst orderInformation = res.results![0].returnValues![0][0];\n\t\t\tconst orderInfo = Order.parse(new Uint8Array(orderInformation));\n\n\t\t\tif (!orderInfo) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst baseCoin = this.#config.getCoin(this.#config.getPool(poolKey).baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(this.#config.getPool(poolKey).quoteCoin);\n\t\t\tconst { isBid, price: rawPrice } = this.decodeOrderId(BigInt(orderInfo.order_id));\n\t\t\tconst normalizedPrice = (rawPrice * baseCoin.scalar) / quoteCoin.scalar / FLOAT_SCALAR;\n\n\t\t\tconst normalizedOrderInfo = {\n\t\t\t\t...orderInfo,\n\t\t\t\tquantity: String((Number(orderInfo.quantity) / baseCoin.scalar).toFixed(9)),\n\t\t\t\tfilled_quantity: String((Number(orderInfo.filled_quantity) / baseCoin.scalar).toFixed(9)),\n\t\t\t\torder_deep_price: {\n\t\t\t\t\t...orderInfo.order_deep_price,\n\t\t\t\t\tdeep_per_asset: String(\n\t\t\t\t\t\t(Number(orderInfo.order_deep_price.deep_per_asset) / DEEP_SCALAR).toFixed(9),\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\tisBid,\n\t\t\t\tnormalized_price: normalizedPrice.toFixed(9),\n\t\t\t};\n\t\t\treturn normalizedOrderInfo;\n\t\t} catch (e) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * @description Retrieves information for multiple specific orders in a pool.\n\t * @param {string} poolKey - The key identifying the pool from which to retrieve order information.\n\t * @param {string[]} orderIds - List of order IDs to retrieve information for.\n\t * @returns {Promise<Object[] | null>} A promise that resolves to an array of order objects, each containing details such as\n\t * balance manager ID, order ID, client order ID, quantity, filled quantity, fee information, order price, epoch, status,\n\t * and expiration timestamp. Returns `null` if the retrieval fails.\n\t */\n\tasync getOrders(poolKey: string, orderIds: string[]) {\n\t\tconst tx = new Transaction();\n\n\t\ttx.add(this.deepBook.getOrders(poolKey, orderIds));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\ttry {\n\t\t\tconst orderInformation = res.results![0].returnValues![0][0];\n\t\t\treturn bcs.vector(Order).parse(new Uint8Array(orderInformation));\n\t\t} catch (e) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * @description Get level 2 order book specifying range of price\n\t * @param {string} poolKey Key of the pool\n\t * @param {number} priceLow Lower bound of the price range\n\t * @param {number} priceHigh Upper bound of the price range\n\t * @param {boolean} isBid Whether to get bid or ask orders\n\t * @returns {Promise<{ prices: Array<number>, quantities: Array<number> }>}\n\t * An object with arrays of prices and quantities\n\t */\n\tasync getLevel2Range(poolKey: string, priceLow: number, priceHigh: number, isBid: boolean) {\n\t\tconst tx = new 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\n\t\ttx.add(this.deepBook.getLevel2Range(poolKey, priceLow, priceHigh, isBid));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst prices = res.results![0].returnValues![0][0];\n\t\tconst parsed_prices = bcs.vector(bcs.u64()).parse(new Uint8Array(prices));\n\t\tconst quantities = res.results![0].returnValues![1][0];\n\t\tconst parsed_quantities = bcs.vector(bcs.u64()).parse(new Uint8Array(quantities));\n\n\t\treturn {\n\t\t\tprices: parsed_prices.map((price) =>\n\t\t\t\tNumber(((Number(price) / FLOAT_SCALAR / quoteCoin.scalar) * baseCoin.scalar).toFixed(9)),\n\t\t\t),\n\t\t\tquantities: parsed_quantities.map((price) =>\n\t\t\t\tNumber((Number(price) / baseCoin.scalar).toFixed(9)),\n\t\t\t),\n\t\t};\n\t}\n\n\t/**\n\t * @description Get level 2 order book ticks from mid-price for a pool\n\t * @param {string} poolKey Key of the pool\n\t * @param {number} ticks Number of ticks from mid-price\n\t * @returns {Promise<{ bid_prices: Array<number>, bid_quantities: Array<number>, ask_prices: Array<number>, ask_quantities: Array<number> }>}\n\t * An object with arrays of prices and quantities\n\t */\n\tasync getLevel2TicksFromMid(poolKey: string, ticks: number) {\n\t\tconst tx = new 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\n\t\ttx.add(this.deepBook.getLevel2TicksFromMid(poolKey, ticks));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst bid_prices = res.results![0].returnValues![0][0];\n\t\tconst bid_parsed_prices = bcs.vector(bcs.u64()).parse(new Uint8Array(bid_prices));\n\t\tconst bid_quantities = res.results![0].returnValues![1][0];\n\t\tconst bid_parsed_quantities = bcs.vector(bcs.u64()).parse(new Uint8Array(bid_quantities));\n\n\t\tconst ask_prices = res.results![0].returnValues![2][0];\n\t\tconst ask_parsed_prices = bcs.vector(bcs.u64()).parse(new Uint8Array(ask_prices));\n\t\tconst ask_quantities = res.results![0].returnValues![3][0];\n\t\tconst ask_parsed_quantities = bcs.vector(bcs.u64()).parse(new Uint8Array(ask_quantities));\n\n\t\treturn {\n\t\t\tbid_prices: bid_parsed_prices.map((price) =>\n\t\t\t\tNumber(((Number(price) / FLOAT_SCALAR / quoteCoin.scalar) * baseCoin.scalar).toFixed(9)),\n\t\t\t),\n\t\t\tbid_quantities: bid_parsed_quantities.map((quantity) =>\n\t\t\t\tNumber((Number(quantity) / baseCoin.scalar).toFixed(9)),\n\t\t\t),\n\t\t\task_prices: ask_parsed_prices.map((price) =>\n\t\t\t\tNumber(((Number(price) / FLOAT_SCALAR / quoteCoin.scalar) * baseCoin.scalar).toFixed(9)),\n\t\t\t),\n\t\t\task_quantities: ask_parsed_quantities.map((quantity) =>\n\t\t\t\tNumber((Number(quantity) / baseCoin.scalar).toFixed(9)),\n\t\t\t),\n\t\t};\n\t}\n\n\t/**\n\t * @description Get the vault balances for a pool\n\t * @param {string} poolKey Key of the pool\n\t * @returns {Promise<{ base: number, quote: number, deep: number }>}\n\t * An object with base, quote, and deep balances in the vault\n\t */\n\tasync vaultBalances(poolKey: string) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseScalar = this.#config.getCoin(pool.baseCoin).scalar;\n\t\tconst quoteScalar = this.#config.getCoin(pool.quoteCoin).scalar;\n\n\t\ttx.add(this.deepBook.vaultBalances(poolKey));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst baseInVault = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![0][0])));\n\t\tconst quoteInVault = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![1][0])));\n\t\tconst deepInVault = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![2][0])));\n\n\t\treturn {\n\t\t\tbase: Number((baseInVault / baseScalar).toFixed(9)),\n\t\t\tquote: Number((quoteInVault / quoteScalar).toFixed(9)),\n\t\t\tdeep: Number((deepInVault / DEEP_SCALAR).toFixed(9)),\n\t\t};\n\t}\n\n\t/**\n\t * @description Get the pool ID by asset types\n\t * @param {string} baseType Type of the base asset\n\t * @param {string} quoteType Type of the quote asset\n\t * @returns {Promise<string>} The address of the pool\n\t */\n\tasync getPoolIdByAssets(baseType: string, quoteType: string) {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.deepBook.getPoolIdByAssets(baseType, quoteType));\n\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst address = bcs.Address.parse(new Uint8Array(res.results![0].returnValues![0][0]));\n\n\t\treturn address;\n\t}\n\n\t/**\n\t * @description Get the mid price for a pool\n\t * @param {string} poolKey Key of the pool\n\t * @returns {Promise<number>} The mid price\n\t */\n\tasync midPrice(poolKey: string) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\ttx.add(this.deepBook.midPrice(poolKey));\n\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst bytes = res.results![0].returnValues![0][0];\n\t\tconst parsed_mid_price = Number(bcs.U64.parse(new Uint8Array(bytes)));\n\t\tconst adjusted_mid_price =\n\t\t\t(parsed_mid_price * baseCoin.scalar) / quoteCoin.scalar / FLOAT_SCALAR;\n\n\t\treturn Number(adjusted_mid_price.toFixed(9));\n\t}\n\n\t/**\n\t * @description Get the trade parameters for a given pool, including taker fee, maker fee, and stake required.\n\t * @param {string} poolKey Key of the pool\n\t * @returns {Promise<{ takerFee: number, makerFee: number, stakeRequired: number }>}\n\t */\n\tasync poolTradeParams(poolKey: string) {\n\t\tconst tx = new Transaction();\n\n\t\ttx.add(this.deepBook.poolTradeParams(poolKey));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst takerFee = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![0][0])));\n\t\tconst makerFee = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![1][0])));\n\t\tconst stakeRequired = Number(\n\t\t\tbcs.U64.parse(new Uint8Array(res.results![0].returnValues![2][0])),\n\t\t);\n\n\t\treturn {\n\t\t\ttakerFee: Number(takerFee / FLOAT_SCALAR),\n\t\t\tmakerFee: Number(makerFee / FLOAT_SCALAR),\n\t\t\tstakeRequired: Number(stakeRequired / DEEP_SCALAR),\n\t\t};\n\t}\n\n\t/**\n\t * @description Get the trade parameters for a given pool, including tick size, lot size, and min size.\n\t * @param {string} poolKey Key of the pool\n\t * @returns {Promise<{ tickSize: number, lotSize: number, minSize: number }>}\n\t */\n\tasync poolBookParams(poolKey: string) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseScalar = this.#config.getCoin(pool.baseCoin).scalar;\n\t\tconst quoteScalar = this.#config.getCoin(pool.quoteCoin).scalar;\n\n\t\ttx.add(this.deepBook.poolBookParams(poolKey));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst tickSize = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![0][0])));\n\t\tconst lotSize = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![1][0])));\n\t\tconst minSize = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![2][0])));\n\n\t\treturn {\n\t\t\ttickSize: Number((tickSize * baseScalar) / quoteScalar / FLOAT_SCALAR),\n\t\t\tlotSize: Number(lotSize / baseScalar),\n\t\t\tminSize: Number(minSize / baseScalar),\n\t\t};\n\t}\n\n\t/**\n\t * @description Get the account information for a given pool and balance manager\n\t * @param {string} poolKey Key of the pool\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @returns {Promise<Object>} A promise that resolves to an object containing the account information\n\t */\n\tasync account(poolKey: string, managerKey: string) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseScalar = this.#config.getCoin(pool.baseCoin).scalar;\n\t\tconst quoteScalar = this.#config.getCoin(pool.quoteCoin).scalar;\n\n\t\ttx.add(this.deepBook.account(poolKey, managerKey));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst accountInformation = res.results![0].returnValues![0][0];\n\t\tconst accountInfo = Account.parse(new Uint8Array(accountInformation));\n\n\t\treturn {\n\t\t\tepoch: accountInfo.epoch,\n\t\t\topen_orders: accountInfo.open_orders,\n\t\t\ttaker_volume: Number(accountInfo.taker_volume) / baseScalar,\n\t\t\tmaker_volume: Number(accountInfo.maker_volume) / baseScalar,\n\t\t\tactive_stake: Number(accountInfo.active_stake) / DEEP_SCALAR,\n\t\t\tinactive_stake: Number(accountInfo.inactive_stake) / DEEP_SCALAR,\n\t\t\tcreated_proposal: accountInfo.created_proposal,\n\t\t\tvoted_proposal: accountInfo.voted_proposal,\n\t\t\tunclaimed_rebates: {\n\t\t\t\tbase: Number(accountInfo.unclaimed_rebates.base) / baseScalar,\n\t\t\t\tquote: Number(accountInfo.unclaimed_rebates.quote) / quoteScalar,\n\t\t\t\tdeep: Number(accountInfo.unclaimed_rebates.deep) / DEEP_SCALAR,\n\t\t\t},\n\t\t\tsettled_balances: {\n\t\t\t\tbase: Number(accountInfo.settled_balances.base) / baseScalar,\n\t\t\t\tquote: Number(accountInfo.settled_balances.quote) / quoteScalar,\n\t\t\t\tdeep: Number(accountInfo.settled_balances.deep) / DEEP_SCALAR,\n\t\t\t},\n\t\t\towed_balances: {\n\t\t\t\tbase: Number(accountInfo.owed_balances.base) / baseScalar,\n\t\t\t\tquote: Number(accountInfo.owed_balances.quote) / quoteScalar,\n\t\t\t\tdeep: Number(accountInfo.owed_balances.deep) / DEEP_SCALAR,\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * @description Get the locked balances for a pool and balance manager\n\t * @param {string} poolKey Key of the pool\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @returns {Promise<{ base: number, quote: number, deep: number }>}\n\t * An object with base, quote, and deep locked for the balance manager in the pool\n\t */\n\tasync lockedBalance(poolKey: string, balanceManagerKey: string) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseScalar = this.#config.getCoin(pool.baseCoin).scalar;\n\t\tconst quoteScalar = this.#config.getCoin(pool.quoteCoin).scalar;\n\n\t\ttx.add(this.deepBook.lockedBalance(poolKey, balanceManagerKey));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst baseLocked = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![0][0])));\n\t\tconst quoteLocked = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![1][0])));\n\t\tconst deepLocked = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![2][0])));\n\n\t\treturn {\n\t\t\tbase: Number((baseLocked / baseScalar).toFixed(9)),\n\t\t\tquote: Number((quoteLocked / quoteScalar).toFixed(9)),\n\t\t\tdeep: Number((deepLocked / DEEP_SCALAR).toFixed(9)),\n\t\t};\n\t}\n\n\t/**\n\t * @description Get the DEEP price conversion for a pool\n\t * @param {string} poolKey Key of the pool\n\t * @returns {Promise<{ asset_is_base: bool, deep_per_quote: number }>} Deep price conversion\n\t */\n\tasync getPoolDeepPrice(poolKey: string) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\ttx.add(this.deepBook.getPoolDeepPrice(poolKey));\n\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\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst poolDeepPriceBytes = res.results![0].returnValues![0][0];\n\t\tconst poolDeepPrice = OrderDeepPrice.parse(new Uint8Array(poolDeepPriceBytes));\n\n\t\tif (poolDeepPrice.asset_is_base) {\n\t\t\treturn {\n\t\t\t\tasset_is_base: poolDeepPrice.asset_is_base,\n\t\t\t\tdeep_per_base:\n\t\t\t\t\t((Number(poolDeepPrice.deep_per_asset) / FLOAT_SCALAR) * baseCoin.scalar) /\n\t\t\t\t\tdeepCoin.scalar,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tasset_is_base: poolDeepPrice.asset_is_base,\n\t\t\t\tdeep_per_quote:\n\t\t\t\t\t((Number(poolDeepPrice.deep_per_asset) / FLOAT_SCALAR) * quoteCoin.scalar) /\n\t\t\t\t\tdeepCoin.scalar,\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * @description Decode the order ID to get bid/ask status, price, and orderId\n\t * @param {bigint} encodedOrderId Encoded order ID\n\t * @returns {Object} Object containing isBid, price, and orderId\n\t */\n\tdecodeOrderId(encodedOrderId: bigint): { isBid: boolean; price: number; orderId: number } {\n\t\tconst isBid = encodedOrderId >> 127n === 0n;\n\t\tconst price = Number((encodedOrderId >> 64n) & ((1n << 63n) - 1n));\n\t\tconst orderId = Number(encodedOrderId & ((1n << 64n) - 1n));\n\n\t\treturn { isBid, price, orderId };\n\t}\n\n\t/**\n\t * @description Get all balance manager IDs for a given owner\n\t * @param {string} owner The owner address to get balance manager IDs for\n\t * @returns {Promise<string[]>} Array of balance manager ID strings\n\t */\n\tasync getBalanceManagerIds(owner: string): Promise<string[]> {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.deepBook.getBalanceManagerIds(owner));\n\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst bytes = res.results![0].returnValues![0][0];\n\t\tconst vecOfAddresses = bcs.vector(bcs.Address).parse(new Uint8Array(bytes));\n\n\t\treturn vecOfAddresses.map((id: string) => normalizeSuiAddress(id));\n\t}\n\n\t/**\n\t * @description Get the owner of the referral\n\t * @param {string} referral The ID of the referral to get the owner of\n\t * @returns {Promise<string>} The owner of the referral\n\t */\n\tasync referralOwner(referral: string) {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.balanceManager.referralOwner(referral));\n\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst bytes = res.results![0].returnValues![0][0];\n\t\tconst owner = bcs.Address.parse(new Uint8Array(bytes));\n\n\t\treturn owner;\n\t}\n\n\t/**\n\t * @description Get the referral balances for a pool and referral\n\t * @param {string} poolKey Key of the pool\n\t * @param {string} referral The referral ID to get balances for\n\t * @returns {Promise<{ base: number, quote: number, deep: number }>} Object with base, quote, and deep balances\n\t */\n\tasync getReferralBalances(\n\t\tpoolKey: string,\n\t\treferral: string,\n\t): Promise<{ base: number; quote: number; deep: number }> {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseScalar = this.#config.getCoin(pool.baseCoin).scalar;\n\t\tconst quoteScalar = this.#config.getCoin(pool.quoteCoin).scalar;\n\n\t\ttx.add(this.deepBook.getReferralBalances(poolKey, referral));\n\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\t// The function returns three u64 values: (base, quote, deep)\n\t\tconst baseBytes = res.results![0].returnValues![0][0];\n\t\tconst quoteBytes = res.results![0].returnValues![1][0];\n\t\tconst deepBytes = res.results![0].returnValues![2][0];\n\n\t\tconst baseBalance = Number(bcs.U64.parse(new Uint8Array(baseBytes)));\n\t\tconst quoteBalance = Number(bcs.U64.parse(new Uint8Array(quoteBytes)));\n\t\tconst deepBalance = Number(bcs.U64.parse(new Uint8Array(deepBytes)));\n\n\t\treturn {\n\t\t\tbase: baseBalance / baseScalar,\n\t\t\tquote: quoteBalance / quoteScalar,\n\t\t\tdeep: deepBalance / DEEP_SCALAR,\n\t\t};\n\t}\n\n\tasync getPriceInfoObject(tx: Transaction, coinKey: string): Promise<string> {\n\t\tconst currentTime = Date.now();\n\t\tconst dbusdcPriceInfoObjectAge = (await this.getPriceInfoObjectAge(coinKey)) * 1000;\n\t\tif (currentTime - dbusdcPriceInfoObjectAge < PRICE_INFO_OBJECT_MAX_AGE) {\n\t\t\treturn await this.#config.getCoin(coinKey).priceInfoObjectId!;\n\t\t}\n\n\t\t// Initialize connection to the Sui Price Service\n\t\tconst endpoint =\n\t\t\tthis.#config.env === 'testnet'\n\t\t\t\t? 'https://hermes-beta.pyth.network'\n\t\t\t\t: 'https://hermes.pyth.network';\n\t\tconst connection = new SuiPriceServiceConnection(endpoint);\n\n\t\t// List of price feed IDs\n\t\tconst priceIDs = [\n\t\t\tthis.#config.getCoin(coinKey).feed!, // ASSET/USD price ID\n\t\t];\n\n\t\t// Fetch price feed update data\n\t\tconst priceUpdateData = await connection.getPriceFeedsUpdateData(priceIDs);\n\n\t\t// Initialize Sui Client and Pyth Client\n\t\tconst wormholeStateId = this.#config.pyth.wormholeStateId;\n\t\tconst pythStateId = this.#config.pyth.pythStateId;\n\n\t\tconst client = new SuiPythClient(this.client, pythStateId, wormholeStateId);\n\n\t\treturn (await client.updatePriceFeeds(tx, priceUpdateData, priceIDs))[0]; // returns priceInfoObjectIds\n\t}\n\n\t/**\n\t * @description Get the age of the price info object for a specific coin\n\t * @param {string} coinKey Key of the coin\n\t * @returns {Promise<string>} The arrival time of the price info object\n\t */\n\tasync getPriceInfoObjectAge(coinKey: string) {\n\t\tconst priceInfoObjectId = this.#config.getCoin(coinKey).priceInfoObjectId!;\n\t\tconst res = await this.client.getObject({\n\t\t\tid: priceInfoObjectId,\n\t\t\toptions: {\n\t\t\t\tshowContent: true,\n\t\t\t},\n\t\t});\n\n\t\tif (!res.data?.content) {\n\t\t\tthrow new Error(`Price info object not found for ${coinKey}`);\n\t\t}\n\n\t\t// Type guard to check if content has fields property\n\t\tif ('fields' in res.data.content) {\n\t\t\tconst fields = res.data.content.fields as any;\n\t\t\treturn fields.price_info?.fields?.arrival_time;\n\t\t} else {\n\t\t\tthrow new Error(`Invalid price info object structure for ${coinKey}`);\n\t\t}\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAoB;AACpB,IAAAA,cAAuD;AAEvD,0BAA4B;AAC5B,mBAAoC;AAEpC,4BAAuC;AACvC,sBAAiC;AACjC,2BAAsC;AACtC,wBAAkC;AAClC,wBAAmC;AAEnC,oBAKO;AAEP,yBAAoC;AACpC,8BAAyC;AACzC,wBAAmC;AACnC,2BAAsC;AACtC,kBAA0C;AAC1C,IAAAC,eAA8B;AAC9B,uBAAkC;AA3BlC;AAgCO,MAAM,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA2B3B,YAAY;AAAA,IACX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A;",
|
|
6
|
+
"names": ["import_bcs", "import_pyth"]
|
|
7
7
|
}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
export { DeepBookClient } from './client.js';
|
|
2
|
+
export { DeepBookConfig } from './utils/config.js';
|
|
2
3
|
export { BalanceManagerContract } from './transactions/balanceManager.js';
|
|
3
4
|
export { DeepBookContract } from './transactions/deepbook.js';
|
|
4
5
|
export { DeepBookAdminContract } from './transactions/deepbookAdmin.js';
|
|
5
6
|
export { FlashLoanContract } from './transactions/flashLoans.js';
|
|
6
7
|
export { GovernanceContract } from './transactions/governance.js';
|
|
7
|
-
export {
|
|
8
|
+
export { MarginAdminContract } from './transactions/marginAdmin.js';
|
|
9
|
+
export { MarginMaintainerContract } from './transactions/marginMaintainer.js';
|
|
10
|
+
export { MarginManagerContract } from './transactions/marginManager.js';
|
|
11
|
+
export { MarginPoolContract } from './transactions/marginPool.js';
|
|
12
|
+
export { PoolProxyContract } from './transactions/poolProxy.js';
|
|
13
|
+
export { SuiPythClient, SuiPriceServiceConnection } from './pyth/pyth.js';
|
|
8
14
|
export { Account, Balances, Order, OrderDeepPrice, VecSet } from './types/bcs.js';
|
|
9
|
-
export type { BalanceManager, Coin, Pool } from './types/index.js';
|
|
10
|
-
export type {
|
|
15
|
+
export type { BalanceManager, Coin, Pool, MarginManager, MarginPool, Environment, Config, } from './types/index.js';
|
|
16
|
+
export type { PlaceLimitOrderParams, PlaceMarketOrderParams, PlaceMarginLimitOrderParams, PlaceMarginMarketOrderParams, SwapParams, ProposalParams, MarginProposalParams, CreatePoolAdminParams, CreatePermissionlessPoolParams, SetEwmaParams, PoolConfigParams, MarginPoolConfigParams, InterestConfigParams, } from './types/index.js';
|
|
17
|
+
export { OrderType, SelfMatchingOptions } from './types/index.js';
|
|
18
|
+
export type { CoinMap, PoolMap, MarginPoolMap } from './utils/constants.js';
|
|
19
|
+
export { DEEP_SCALAR, FLOAT_SCALAR, GAS_BUDGET, MAX_TIMESTAMP, POOL_CREATION_FEE, PRICE_INFO_OBJECT_MAX_AGE, } from './utils/config.js';
|
package/dist/cjs/index.js
CHANGED
|
@@ -21,23 +21,46 @@ __export(index_exports, {
|
|
|
21
21
|
Account: () => import_bcs.Account,
|
|
22
22
|
BalanceManagerContract: () => import_balanceManager.BalanceManagerContract,
|
|
23
23
|
Balances: () => import_bcs.Balances,
|
|
24
|
+
DEEP_SCALAR: () => import_config2.DEEP_SCALAR,
|
|
24
25
|
DeepBookAdminContract: () => import_deepbookAdmin.DeepBookAdminContract,
|
|
25
26
|
DeepBookClient: () => import_client.DeepBookClient,
|
|
26
27
|
DeepBookConfig: () => import_config.DeepBookConfig,
|
|
27
28
|
DeepBookContract: () => import_deepbook.DeepBookContract,
|
|
29
|
+
FLOAT_SCALAR: () => import_config2.FLOAT_SCALAR,
|
|
28
30
|
FlashLoanContract: () => import_flashLoans.FlashLoanContract,
|
|
31
|
+
GAS_BUDGET: () => import_config2.GAS_BUDGET,
|
|
29
32
|
GovernanceContract: () => import_governance.GovernanceContract,
|
|
33
|
+
MAX_TIMESTAMP: () => import_config2.MAX_TIMESTAMP,
|
|
34
|
+
MarginAdminContract: () => import_marginAdmin.MarginAdminContract,
|
|
35
|
+
MarginMaintainerContract: () => import_marginMaintainer.MarginMaintainerContract,
|
|
36
|
+
MarginManagerContract: () => import_marginManager.MarginManagerContract,
|
|
37
|
+
MarginPoolContract: () => import_marginPool.MarginPoolContract,
|
|
30
38
|
Order: () => import_bcs.Order,
|
|
31
39
|
OrderDeepPrice: () => import_bcs.OrderDeepPrice,
|
|
40
|
+
OrderType: () => import_types.OrderType,
|
|
41
|
+
POOL_CREATION_FEE: () => import_config2.POOL_CREATION_FEE,
|
|
42
|
+
PRICE_INFO_OBJECT_MAX_AGE: () => import_config2.PRICE_INFO_OBJECT_MAX_AGE,
|
|
43
|
+
PoolProxyContract: () => import_poolProxy.PoolProxyContract,
|
|
44
|
+
SelfMatchingOptions: () => import_types.SelfMatchingOptions,
|
|
45
|
+
SuiPriceServiceConnection: () => import_pyth.SuiPriceServiceConnection,
|
|
46
|
+
SuiPythClient: () => import_pyth.SuiPythClient,
|
|
32
47
|
VecSet: () => import_bcs.VecSet
|
|
33
48
|
});
|
|
34
49
|
module.exports = __toCommonJS(index_exports);
|
|
35
50
|
var import_client = require("./client.js");
|
|
51
|
+
var import_config = require("./utils/config.js");
|
|
36
52
|
var import_balanceManager = require("./transactions/balanceManager.js");
|
|
37
53
|
var import_deepbook = require("./transactions/deepbook.js");
|
|
38
54
|
var import_deepbookAdmin = require("./transactions/deepbookAdmin.js");
|
|
39
55
|
var import_flashLoans = require("./transactions/flashLoans.js");
|
|
40
56
|
var import_governance = require("./transactions/governance.js");
|
|
41
|
-
var
|
|
57
|
+
var import_marginAdmin = require("./transactions/marginAdmin.js");
|
|
58
|
+
var import_marginMaintainer = require("./transactions/marginMaintainer.js");
|
|
59
|
+
var import_marginManager = require("./transactions/marginManager.js");
|
|
60
|
+
var import_marginPool = require("./transactions/marginPool.js");
|
|
61
|
+
var import_poolProxy = require("./transactions/poolProxy.js");
|
|
62
|
+
var import_pyth = require("./pyth/pyth.js");
|
|
42
63
|
var import_bcs = require("./types/bcs.js");
|
|
64
|
+
var import_types = require("./types/index.js");
|
|
65
|
+
var import_config2 = require("./utils/config.js");
|
|
43
66
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport { DeepBookClient } from './client.js';\nexport { BalanceManagerContract } from './transactions/balanceManager.js';\nexport { DeepBookContract } from './transactions/deepbook.js';\nexport { DeepBookAdminContract } from './transactions/deepbookAdmin.js';\nexport { FlashLoanContract } from './transactions/flashLoans.js';\nexport { GovernanceContract } from './transactions/governance.js';\nexport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n// Main client and configuration\nexport { DeepBookClient } from './client.js';\nexport { DeepBookConfig } from './utils/config.js';\n\n// Core contract classes\nexport { BalanceManagerContract } from './transactions/balanceManager.js';\nexport { DeepBookContract } from './transactions/deepbook.js';\nexport { DeepBookAdminContract } from './transactions/deepbookAdmin.js';\nexport { FlashLoanContract } from './transactions/flashLoans.js';\nexport { GovernanceContract } from './transactions/governance.js';\n\n// Margin trading contracts\nexport { MarginAdminContract } from './transactions/marginAdmin.js';\nexport { MarginMaintainerContract } from './transactions/marginMaintainer.js';\nexport { MarginManagerContract } from './transactions/marginManager.js';\nexport { MarginPoolContract } from './transactions/marginPool.js';\nexport { PoolProxyContract } from './transactions/poolProxy.js';\n\n// Pyth price feed integration\nexport { SuiPythClient, SuiPriceServiceConnection } from './pyth/pyth.js';\n\n// BCS types for parsing on-chain data\nexport { Account, Balances, Order, OrderDeepPrice, VecSet } from './types/bcs.js';\n\n// TypeScript interfaces and types\nexport type {\n\tBalanceManager,\n\tCoin,\n\tPool,\n\tMarginManager,\n\tMarginPool,\n\tEnvironment,\n\tConfig,\n} from './types/index.js';\n\n// Trading parameter interfaces\nexport type {\n\tPlaceLimitOrderParams,\n\tPlaceMarketOrderParams,\n\tPlaceMarginLimitOrderParams,\n\tPlaceMarginMarketOrderParams,\n\tSwapParams,\n\tProposalParams,\n\tMarginProposalParams,\n\tCreatePoolAdminParams,\n\tCreatePermissionlessPoolParams,\n\tSetEwmaParams,\n\tPoolConfigParams,\n\tMarginPoolConfigParams,\n\tInterestConfigParams,\n} from './types/index.js';\n\n// Enums for trading\nexport { OrderType, SelfMatchingOptions } from './types/index.js';\n\n// Constants and configuration maps\nexport type { CoinMap, PoolMap, MarginPoolMap } from './utils/constants.js';\nexport {\n\tDEEP_SCALAR,\n\tFLOAT_SCALAR,\n\tGAS_BUDGET,\n\tMAX_TIMESTAMP,\n\tPOOL_CREATION_FEE,\n\tPRICE_INFO_OBJECT_MAX_AGE,\n} from './utils/config.js';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,oBAA+B;AAC/B,oBAA+B;AAG/B,4BAAuC;AACvC,sBAAiC;AACjC,2BAAsC;AACtC,wBAAkC;AAClC,wBAAmC;AAGnC,yBAAoC;AACpC,8BAAyC;AACzC,2BAAsC;AACtC,wBAAmC;AACnC,uBAAkC;AAGlC,kBAAyD;AAGzD,iBAAiE;AA+BjE,mBAA+C;AAI/C,IAAAA,iBAOO;",
|
|
6
|
+
"names": ["import_config"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type HexString = string;
|
|
2
|
+
export type PriceFeedRequestConfig = {
|
|
3
|
+
verbose?: boolean;
|
|
4
|
+
binary?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export type PriceServiceConnectionConfig = {
|
|
7
|
+
timeout?: number;
|
|
8
|
+
httpRetries?: number;
|
|
9
|
+
};
|
|
10
|
+
export declare class PriceServiceConnection {
|
|
11
|
+
private httpClient;
|
|
12
|
+
/**
|
|
13
|
+
* Constructs a new Connection.
|
|
14
|
+
*
|
|
15
|
+
* @param endpoint endpoint URL to the price service.
|
|
16
|
+
* @param config Optional configuration for custom setups.
|
|
17
|
+
*/
|
|
18
|
+
constructor(endpoint: string, config?: PriceServiceConnectionConfig);
|
|
19
|
+
/**
|
|
20
|
+
* Fetch latest VAAs of given price IDs.
|
|
21
|
+
*
|
|
22
|
+
* @param priceIds Array of hex-encoded price IDs.
|
|
23
|
+
* @returns Array of base64 encoded VAAs.
|
|
24
|
+
*/
|
|
25
|
+
getLatestVaas(priceIds: HexString[]): Promise<string[]>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var PriceServiceConnection_exports = {};
|
|
30
|
+
__export(PriceServiceConnection_exports, {
|
|
31
|
+
PriceServiceConnection: () => PriceServiceConnection
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(PriceServiceConnection_exports);
|
|
34
|
+
var import_axios = __toESM(require("axios"));
|
|
35
|
+
var import_axios_retry = __toESM(require("axios-retry"));
|
|
36
|
+
class PriceServiceConnection {
|
|
37
|
+
/**
|
|
38
|
+
* Constructs a new Connection.
|
|
39
|
+
*
|
|
40
|
+
* @param endpoint endpoint URL to the price service.
|
|
41
|
+
* @param config Optional configuration for custom setups.
|
|
42
|
+
*/
|
|
43
|
+
constructor(endpoint, config) {
|
|
44
|
+
this.httpClient = import_axios.default.create({
|
|
45
|
+
baseURL: endpoint,
|
|
46
|
+
timeout: config?.timeout || 5e3
|
|
47
|
+
});
|
|
48
|
+
(0, import_axios_retry.default)(this.httpClient, {
|
|
49
|
+
retries: config?.httpRetries || 3,
|
|
50
|
+
retryDelay: import_axios_retry.default.exponentialDelay
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Fetch latest VAAs of given price IDs.
|
|
55
|
+
*
|
|
56
|
+
* @param priceIds Array of hex-encoded price IDs.
|
|
57
|
+
* @returns Array of base64 encoded VAAs.
|
|
58
|
+
*/
|
|
59
|
+
async getLatestVaas(priceIds) {
|
|
60
|
+
const response = await this.httpClient.get("/api/latest_vaas", {
|
|
61
|
+
params: {
|
|
62
|
+
ids: priceIds
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
return response.data;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=PriceServiceConnection.js.map
|