@mysten/deepbook-v3 1.3.0 → 1.3.1
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 +17 -0
- package/dist/contracts/deepbook/account.d.mts +1 -1
- package/dist/contracts/deepbook/account.mjs.map +1 -1
- package/dist/contracts/deepbook/deep_price.d.mts +1 -1
- package/dist/contracts/deepbook/deep_price.mjs.map +1 -1
- package/dist/contracts/deepbook/order.d.mts +1 -1
- package/dist/contracts/deepbook/order.mjs.map +1 -1
- package/dist/contracts/pyth/data_source.mjs.map +1 -1
- package/dist/contracts/pyth/i64.mjs.map +1 -1
- package/dist/contracts/pyth/price.mjs.map +1 -1
- package/dist/contracts/pyth/price_feed.mjs.map +1 -1
- package/dist/contracts/pyth/price_identifier.mjs.map +1 -1
- package/dist/contracts/pyth/price_info.mjs.map +1 -1
- package/dist/contracts/pyth/state.mjs.map +1 -1
- package/dist/contracts/utils/index.d.mts.map +1 -1
- package/dist/contracts/utils/index.mjs.map +1 -1
- package/dist/queries/accountQueries.mjs +3 -0
- package/dist/queries/accountQueries.mjs.map +1 -1
- package/dist/queries/balanceManagerQueries.mjs +5 -0
- package/dist/queries/balanceManagerQueries.mjs.map +1 -1
- package/dist/queries/marginManagerQueries.mjs +15 -0
- package/dist/queries/marginManagerQueries.mjs.map +1 -1
- package/dist/queries/marginPoolQueries.mjs +14 -0
- package/dist/queries/marginPoolQueries.mjs.map +1 -1
- package/dist/queries/orderQueries.mjs +7 -0
- package/dist/queries/orderQueries.mjs.map +1 -1
- package/dist/queries/poolQueries.mjs +15 -0
- package/dist/queries/poolQueries.mjs.map +1 -1
- package/dist/queries/quantityQueries.mjs +9 -0
- package/dist/queries/quantityQueries.mjs.map +1 -1
- package/dist/queries/referralQueries.mjs +5 -0
- package/dist/queries/referralQueries.mjs.map +1 -1
- package/dist/queries/registryQueries.mjs +12 -0
- package/dist/queries/registryQueries.mjs.map +1 -1
- package/dist/queries/tpslQueries.mjs +3 -0
- package/dist/queries/tpslQueries.mjs.map +1 -1
- package/package.json +4 -4
- package/src/contracts/deepbook/account.ts +20 -20
- package/src/contracts/deepbook/balance_manager.ts +3 -3
- package/src/contracts/deepbook/deep_price.ts +6 -6
- package/src/contracts/deepbook/fill.ts +34 -34
- package/src/contracts/deepbook/math.ts +2 -2
- package/src/contracts/deepbook/order.ts +24 -24
- package/src/contracts/deepbook/order_info.ts +46 -46
- package/src/contracts/deepbook/order_query.ts +5 -5
- package/src/contracts/deepbook/pool.ts +119 -33
- package/src/contracts/deepbook/registry.ts +3 -3
- package/src/contracts/pyth/batch_price_attestation.ts +5 -5
- package/src/contracts/pyth/contract_upgrade.ts +3 -3
- package/src/contracts/pyth/data_source.ts +4 -4
- package/src/contracts/pyth/deserialize.ts +8 -8
- package/src/contracts/pyth/governance.ts +7 -7
- package/src/contracts/pyth/governance_action.ts +2 -2
- package/src/contracts/pyth/governance_instruction.ts +6 -6
- package/src/contracts/pyth/hot_potato_vector.ts +5 -5
- package/src/contracts/pyth/i64.ts +4 -4
- package/src/contracts/pyth/merkle_tree.ts +3 -7
- package/src/contracts/pyth/migrate.ts +2 -2
- package/src/contracts/pyth/price.ts +7 -7
- package/src/contracts/pyth/price_feed.ts +7 -11
- package/src/contracts/pyth/price_identifier.ts +3 -3
- package/src/contracts/pyth/price_info.ts +9 -9
- package/src/contracts/pyth/price_status.ts +2 -2
- package/src/contracts/pyth/pyth.ts +12 -12
- package/src/contracts/pyth/set.ts +4 -4
- package/src/contracts/pyth/state.ts +5 -5
- package/src/contracts/utils/index.ts +3 -1
- package/src/queries/accountQueries.ts +3 -0
- package/src/queries/balanceManagerQueries.ts +5 -0
- package/src/queries/marginManagerQueries.ts +15 -0
- package/src/queries/marginPoolQueries.ts +14 -0
- package/src/queries/orderQueries.ts +7 -0
- package/src/queries/poolQueries.ts +15 -0
- package/src/queries/quantityQueries.ts +9 -0
- package/src/queries/referralQueries.ts +5 -0
- package/src/queries/registryQueries.ts +12 -0
- package/src/queries/tpslQueries.ts +3 -0
|
@@ -13,6 +13,7 @@ var MarginManagerQueries = class {
|
|
|
13
13
|
async getMarginManagerOwner(marginManagerKey) {
|
|
14
14
|
const manager = this.#ctx.config.getMarginManager(marginManagerKey);
|
|
15
15
|
const tx = new Transaction();
|
|
16
|
+
tx.setSender(this.#ctx.address);
|
|
16
17
|
tx.add(this.#ctx.marginManager.ownerByPoolKey(manager.poolKey, manager.address));
|
|
17
18
|
const bytes = (await this.#ctx.client.core.simulateTransaction({
|
|
18
19
|
transaction: tx,
|
|
@@ -26,6 +27,7 @@ var MarginManagerQueries = class {
|
|
|
26
27
|
async getMarginManagerDeepbookPool(marginManagerKey) {
|
|
27
28
|
const manager = this.#ctx.config.getMarginManager(marginManagerKey);
|
|
28
29
|
const tx = new Transaction();
|
|
30
|
+
tx.setSender(this.#ctx.address);
|
|
29
31
|
tx.add(this.#ctx.marginManager.deepbookPool(manager.poolKey, manager.address));
|
|
30
32
|
const bytes = (await this.#ctx.client.core.simulateTransaction({
|
|
31
33
|
transaction: tx,
|
|
@@ -39,6 +41,7 @@ var MarginManagerQueries = class {
|
|
|
39
41
|
async getMarginManagerMarginPoolId(marginManagerKey) {
|
|
40
42
|
const manager = this.#ctx.config.getMarginManager(marginManagerKey);
|
|
41
43
|
const tx = new Transaction();
|
|
44
|
+
tx.setSender(this.#ctx.address);
|
|
42
45
|
tx.add(this.#ctx.marginManager.marginPoolId(manager.poolKey, manager.address));
|
|
43
46
|
const bytes = (await this.#ctx.client.core.simulateTransaction({
|
|
44
47
|
transaction: tx,
|
|
@@ -53,6 +56,7 @@ var MarginManagerQueries = class {
|
|
|
53
56
|
async getMarginManagerBorrowedShares(marginManagerKey) {
|
|
54
57
|
const manager = this.#ctx.config.getMarginManager(marginManagerKey);
|
|
55
58
|
const tx = new Transaction();
|
|
59
|
+
tx.setSender(this.#ctx.address);
|
|
56
60
|
tx.add(this.#ctx.marginManager.borrowedShares(manager.poolKey, manager.address));
|
|
57
61
|
const res = await this.#ctx.client.core.simulateTransaction({
|
|
58
62
|
transaction: tx,
|
|
@@ -71,6 +75,7 @@ var MarginManagerQueries = class {
|
|
|
71
75
|
async getMarginManagerBorrowedBaseShares(marginManagerKey) {
|
|
72
76
|
const manager = this.#ctx.config.getMarginManager(marginManagerKey);
|
|
73
77
|
const tx = new Transaction();
|
|
78
|
+
tx.setSender(this.#ctx.address);
|
|
74
79
|
tx.add(this.#ctx.marginManager.borrowedBaseShares(manager.poolKey, manager.address));
|
|
75
80
|
const bytes = (await this.#ctx.client.core.simulateTransaction({
|
|
76
81
|
transaction: tx,
|
|
@@ -84,6 +89,7 @@ var MarginManagerQueries = class {
|
|
|
84
89
|
async getMarginManagerBorrowedQuoteShares(marginManagerKey) {
|
|
85
90
|
const manager = this.#ctx.config.getMarginManager(marginManagerKey);
|
|
86
91
|
const tx = new Transaction();
|
|
92
|
+
tx.setSender(this.#ctx.address);
|
|
87
93
|
tx.add(this.#ctx.marginManager.borrowedQuoteShares(manager.poolKey, manager.address));
|
|
88
94
|
const bytes = (await this.#ctx.client.core.simulateTransaction({
|
|
89
95
|
transaction: tx,
|
|
@@ -97,6 +103,7 @@ var MarginManagerQueries = class {
|
|
|
97
103
|
async getMarginManagerHasBaseDebt(marginManagerKey) {
|
|
98
104
|
const manager = this.#ctx.config.getMarginManager(marginManagerKey);
|
|
99
105
|
const tx = new Transaction();
|
|
106
|
+
tx.setSender(this.#ctx.address);
|
|
100
107
|
tx.add(this.#ctx.marginManager.hasBaseDebt(manager.poolKey, manager.address));
|
|
101
108
|
const bytes = (await this.#ctx.client.core.simulateTransaction({
|
|
102
109
|
transaction: tx,
|
|
@@ -124,6 +131,7 @@ var MarginManagerQueries = class {
|
|
|
124
131
|
async getMarginManagerAssets(marginManagerKey, decimals = 6) {
|
|
125
132
|
const manager = this.#ctx.config.getMarginManager(marginManagerKey);
|
|
126
133
|
const tx = new Transaction();
|
|
134
|
+
tx.setSender(this.#ctx.address);
|
|
127
135
|
tx.add(this.#ctx.marginManager.calculateAssets(manager.poolKey, manager.address));
|
|
128
136
|
const res = await this.#ctx.client.core.simulateTransaction({
|
|
129
137
|
transaction: tx,
|
|
@@ -148,6 +156,7 @@ var MarginManagerQueries = class {
|
|
|
148
156
|
const pool = this.#ctx.config.getPool(manager.poolKey);
|
|
149
157
|
const debtCoinKey = hasBaseDebt ? pool.baseCoin : pool.quoteCoin;
|
|
150
158
|
const tx = new Transaction();
|
|
159
|
+
tx.setSender(this.#ctx.address);
|
|
151
160
|
tx.add(this.#ctx.marginManager.calculateDebts(manager.poolKey, debtCoinKey, manager.address));
|
|
152
161
|
const res = await this.#ctx.client.core.simulateTransaction({
|
|
153
162
|
transaction: tx,
|
|
@@ -169,6 +178,7 @@ var MarginManagerQueries = class {
|
|
|
169
178
|
async getMarginManagerState(marginManagerKey, decimals = 6) {
|
|
170
179
|
const manager = this.#ctx.config.getMarginManager(marginManagerKey);
|
|
171
180
|
const tx = new Transaction();
|
|
181
|
+
tx.setSender(this.#ctx.address);
|
|
172
182
|
tx.add(this.#ctx.marginManager.managerState(manager.poolKey, manager.address));
|
|
173
183
|
const res = await this.#ctx.client.core.simulateTransaction({
|
|
174
184
|
transaction: tx,
|
|
@@ -217,6 +227,7 @@ var MarginManagerQueries = class {
|
|
|
217
227
|
const entries = Object.entries(marginManagers);
|
|
218
228
|
if (entries.length === 0) return {};
|
|
219
229
|
const tx = new Transaction();
|
|
230
|
+
tx.setSender(this.#ctx.address);
|
|
220
231
|
for (const [managerId, poolKey] of entries) tx.add(this.#ctx.marginManager.managerState(poolKey, managerId));
|
|
221
232
|
const res = await this.#ctx.client.core.simulateTransaction({
|
|
222
233
|
transaction: tx,
|
|
@@ -271,6 +282,7 @@ var MarginManagerQueries = class {
|
|
|
271
282
|
async getMarginManagerBaseBalance(marginManagerKey, decimals = 9) {
|
|
272
283
|
const manager = this.#ctx.config.getMarginManager(marginManagerKey);
|
|
273
284
|
const tx = new Transaction();
|
|
285
|
+
tx.setSender(this.#ctx.address);
|
|
274
286
|
tx.add(this.#ctx.marginManager.baseBalance(manager.poolKey, manager.address));
|
|
275
287
|
const res = await this.#ctx.client.core.simulateTransaction({
|
|
276
288
|
transaction: tx,
|
|
@@ -289,6 +301,7 @@ var MarginManagerQueries = class {
|
|
|
289
301
|
async getMarginManagerQuoteBalance(marginManagerKey, decimals = 9) {
|
|
290
302
|
const manager = this.#ctx.config.getMarginManager(marginManagerKey);
|
|
291
303
|
const tx = new Transaction();
|
|
304
|
+
tx.setSender(this.#ctx.address);
|
|
292
305
|
tx.add(this.#ctx.marginManager.quoteBalance(manager.poolKey, manager.address));
|
|
293
306
|
const res = await this.#ctx.client.core.simulateTransaction({
|
|
294
307
|
transaction: tx,
|
|
@@ -307,6 +320,7 @@ var MarginManagerQueries = class {
|
|
|
307
320
|
async getMarginManagerDeepBalance(marginManagerKey, decimals = 6) {
|
|
308
321
|
const manager = this.#ctx.config.getMarginManager(marginManagerKey);
|
|
309
322
|
const tx = new Transaction();
|
|
323
|
+
tx.setSender(this.#ctx.address);
|
|
310
324
|
tx.add(this.#ctx.marginManager.deepBalance(manager.poolKey, manager.address));
|
|
311
325
|
const res = await this.#ctx.client.core.simulateTransaction({
|
|
312
326
|
transaction: tx,
|
|
@@ -325,6 +339,7 @@ var MarginManagerQueries = class {
|
|
|
325
339
|
const entries = Object.entries(marginManagers);
|
|
326
340
|
if (entries.length === 0) return {};
|
|
327
341
|
const tx = new Transaction();
|
|
342
|
+
tx.setSender(this.#ctx.address);
|
|
328
343
|
for (const [managerId, poolKey] of entries) {
|
|
329
344
|
tx.add(this.#ctx.marginManager.baseBalance(poolKey, managerId));
|
|
330
345
|
tx.add(this.#ctx.marginManager.quoteBalance(poolKey, managerId));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marginManagerQueries.mjs","names":["#ctx"],"sources":["../../src/queries/marginManagerQueries.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@mysten/sui/bcs';\nimport { Transaction } from '@mysten/sui/transactions';\nimport { normalizeSuiAddress } from '@mysten/sui/utils';\n\nimport type {\n\tBorrowedShares,\n\tMarginManagerAssets,\n\tMarginManagerBalancesResult,\n\tMarginManagerDebts,\n\tMarginManagerState,\n} from '../types/index.js';\nimport { FLOAT_SCALAR } from '../utils/config.js';\nimport { formatTokenAmount } from './context.js';\nimport type { QueryContext } from './context.js';\n\nexport class MarginManagerQueries {\n\t#ctx: QueryContext;\n\n\tconstructor(ctx: QueryContext) {\n\t\tthis.#ctx = ctx;\n\t}\n\n\tasync getMarginManagerOwner(marginManagerKey: string): Promise<string> {\n\t\tconst manager = this.#ctx.config.getMarginManager(marginManagerKey);\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.marginManager.ownerByPoolKey(manager.poolKey, manager.address));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\treturn normalizeSuiAddress(bcs.Address.parse(bytes));\n\t}\n\n\tasync getMarginManagerDeepbookPool(marginManagerKey: string): Promise<string> {\n\t\tconst manager = this.#ctx.config.getMarginManager(marginManagerKey);\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.marginManager.deepbookPool(manager.poolKey, manager.address));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\treturn normalizeSuiAddress(bcs.Address.parse(bytes));\n\t}\n\n\tasync getMarginManagerMarginPoolId(marginManagerKey: string): Promise<string | null> {\n\t\tconst manager = this.#ctx.config.getMarginManager(marginManagerKey);\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.marginManager.marginPoolId(manager.poolKey, manager.address));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst option = bcs.option(bcs.Address).parse(bytes);\n\t\treturn option ? normalizeSuiAddress(option) : null;\n\t}\n\n\tasync getMarginManagerBorrowedShares(marginManagerKey: string): Promise<BorrowedShares> {\n\t\tconst manager = this.#ctx.config.getMarginManager(marginManagerKey);\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.marginManager.borrowedShares(manager.poolKey, manager.address));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst baseBytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst quoteBytes = res.commandResults![0].returnValues[1].bcs;\n\t\tconst baseShares = bcs.U64.parse(baseBytes).toString();\n\t\tconst quoteShares = bcs.U64.parse(quoteBytes).toString();\n\n\t\treturn { baseShares, quoteShares };\n\t}\n\n\tasync getMarginManagerBorrowedBaseShares(marginManagerKey: string): Promise<string> {\n\t\tconst manager = this.#ctx.config.getMarginManager(marginManagerKey);\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.marginManager.borrowedBaseShares(manager.poolKey, manager.address));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\treturn bcs.U64.parse(bytes).toString();\n\t}\n\n\tasync getMarginManagerBorrowedQuoteShares(marginManagerKey: string): Promise<string> {\n\t\tconst manager = this.#ctx.config.getMarginManager(marginManagerKey);\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.marginManager.borrowedQuoteShares(manager.poolKey, manager.address));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\treturn bcs.U64.parse(bytes).toString();\n\t}\n\n\tasync getMarginManagerHasBaseDebt(marginManagerKey: string): Promise<boolean> {\n\t\tconst manager = this.#ctx.config.getMarginManager(marginManagerKey);\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.marginManager.hasBaseDebt(manager.poolKey, manager.address));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\treturn bcs.bool().parse(bytes);\n\t}\n\n\tasync getMarginManagerBalanceManagerId(marginManagerAddress: string): Promise<string> {\n\t\tconst res = await this.#ctx.client.core.getObject({\n\t\t\tobjectId: marginManagerAddress,\n\t\t\tinclude: { content: true },\n\t\t});\n\n\t\tif (!res.object?.content) {\n\t\t\tthrow new Error(`Margin manager not found: ${marginManagerAddress}`);\n\t\t}\n\n\t\tconst MarginManagerBalanceManagerId = bcs.struct('MarginManagerBalanceManagerId', {\n\t\t\tid: bcs.Address,\n\t\t\towner: bcs.Address,\n\t\t\tdeepbook_pool: bcs.Address,\n\t\t\tmargin_pool_id: bcs.option(bcs.Address),\n\t\t\tbalance_manager_id: bcs.Address,\n\t\t});\n\n\t\tconst parsed = MarginManagerBalanceManagerId.parse(res.object.content);\n\t\treturn normalizeSuiAddress(parsed.balance_manager_id);\n\t}\n\n\tasync getMarginManagerAssets(\n\t\tmarginManagerKey: string,\n\t\tdecimals: number = 6,\n\t): Promise<MarginManagerAssets> {\n\t\tconst manager = this.#ctx.config.getMarginManager(marginManagerKey);\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.marginManager.calculateAssets(manager.poolKey, manager.address));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst baseBytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst quoteBytes = res.commandResults![0].returnValues[1].bcs;\n\t\tconst pool = this.#ctx.config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#ctx.config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#ctx.config.getCoin(pool.quoteCoin);\n\n\t\tconst baseAsset = formatTokenAmount(\n\t\t\tBigInt(bcs.U64.parse(baseBytes)),\n\t\t\tbaseCoin.scalar,\n\t\t\tdecimals,\n\t\t);\n\t\tconst quoteAsset = formatTokenAmount(\n\t\t\tBigInt(bcs.U64.parse(quoteBytes)),\n\t\t\tquoteCoin.scalar,\n\t\t\tdecimals,\n\t\t);\n\n\t\treturn { baseAsset, quoteAsset };\n\t}\n\n\tasync getMarginManagerDebts(\n\t\tmarginManagerKey: string,\n\t\tdecimals: number = 6,\n\t): Promise<MarginManagerDebts> {\n\t\tconst hasBaseDebt = await this.getMarginManagerHasBaseDebt(marginManagerKey);\n\n\t\tconst manager = this.#ctx.config.getMarginManager(marginManagerKey);\n\t\tconst pool = this.#ctx.config.getPool(manager.poolKey);\n\t\tconst debtCoinKey = hasBaseDebt ? pool.baseCoin : pool.quoteCoin;\n\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.marginManager.calculateDebts(manager.poolKey, debtCoinKey, manager.address));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tif (res.FailedTransaction) {\n\t\t\tthrow new Error(\n\t\t\t\t`Transaction failed: ${res.FailedTransaction.status.error?.message || 'Unknown error'}`,\n\t\t\t);\n\t\t}\n\n\t\tif (!res.commandResults || !res.commandResults[0] || !res.commandResults[0].returnValues) {\n\t\t\tthrow new Error(`Failed to get margin manager debts: ${'Unknown error'}`);\n\t\t}\n\n\t\tconst baseBytes = res.commandResults[0].returnValues[0].bcs;\n\t\tconst quoteBytes = res.commandResults[0].returnValues[1].bcs;\n\t\tconst debtCoin = this.#ctx.config.getCoin(debtCoinKey);\n\n\t\tconst baseDebt = formatTokenAmount(BigInt(bcs.U64.parse(baseBytes)), debtCoin.scalar, decimals);\n\t\tconst quoteDebt = formatTokenAmount(\n\t\t\tBigInt(bcs.U64.parse(quoteBytes)),\n\t\t\tdebtCoin.scalar,\n\t\t\tdecimals,\n\t\t);\n\n\t\treturn { baseDebt, quoteDebt };\n\t}\n\n\tasync getMarginManagerState(\n\t\tmarginManagerKey: string,\n\t\tdecimals: number = 6,\n\t): Promise<MarginManagerState> {\n\t\tconst manager = this.#ctx.config.getMarginManager(marginManagerKey);\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.marginManager.managerState(manager.poolKey, manager.address));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tif (res.FailedTransaction) {\n\t\t\tthrow new Error(\n\t\t\t\t`Transaction failed: ${res.FailedTransaction.status.error?.message || 'Unknown error'}`,\n\t\t\t);\n\t\t}\n\n\t\tif (!res.commandResults || !res.commandResults[0] || !res.commandResults[0].returnValues) {\n\t\t\tthrow new Error(`Failed to get margin manager state: Unknown error`);\n\t\t}\n\n\t\tconst pool = this.#ctx.config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#ctx.config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#ctx.config.getCoin(pool.quoteCoin);\n\n\t\tconst managerId = normalizeSuiAddress(\n\t\t\tbcs.Address.parse(res.commandResults[0].returnValues[0].bcs),\n\t\t);\n\t\tconst deepbookPoolId = normalizeSuiAddress(\n\t\t\tbcs.Address.parse(res.commandResults[0].returnValues[1].bcs),\n\t\t);\n\t\tconst riskRatio =\n\t\t\tNumber(bcs.U64.parse(res.commandResults[0].returnValues[2].bcs)) / FLOAT_SCALAR;\n\t\tconst baseAsset = formatTokenAmount(\n\t\t\tBigInt(bcs.U64.parse(res.commandResults[0].returnValues[3].bcs)),\n\t\t\tbaseCoin.scalar,\n\t\t\tdecimals,\n\t\t);\n\t\tconst quoteAsset = formatTokenAmount(\n\t\t\tBigInt(bcs.U64.parse(res.commandResults[0].returnValues[4].bcs)),\n\t\t\tquoteCoin.scalar,\n\t\t\tdecimals,\n\t\t);\n\t\tconst baseDebt = formatTokenAmount(\n\t\t\tBigInt(bcs.U64.parse(res.commandResults[0].returnValues[5].bcs)),\n\t\t\tbaseCoin.scalar,\n\t\t\tdecimals,\n\t\t);\n\t\tconst quoteDebt = formatTokenAmount(\n\t\t\tBigInt(bcs.U64.parse(res.commandResults[0].returnValues[6].bcs)),\n\t\t\tquoteCoin.scalar,\n\t\t\tdecimals,\n\t\t);\n\t\tconst basePythPrice = bcs.U64.parse(res.commandResults[0].returnValues[7].bcs);\n\t\tconst basePythDecimals = Number(\n\t\t\tbcs.u8().parse(new Uint8Array(res.commandResults[0].returnValues[8].bcs)),\n\t\t);\n\t\tconst quotePythPrice = bcs.U64.parse(res.commandResults[0].returnValues[9].bcs);\n\t\tconst quotePythDecimals = Number(\n\t\t\tbcs.u8().parse(new Uint8Array(res.commandResults[0].returnValues[10].bcs)),\n\t\t);\n\t\tconst currentPrice = BigInt(bcs.U64.parse(res.commandResults[0].returnValues[11].bcs));\n\t\tconst lowestTriggerAbovePrice = BigInt(\n\t\t\tbcs.U64.parse(res.commandResults[0].returnValues[12].bcs),\n\t\t);\n\t\tconst highestTriggerBelowPrice = BigInt(\n\t\t\tbcs.U64.parse(res.commandResults[0].returnValues[13].bcs),\n\t\t);\n\n\t\treturn {\n\t\t\tmanagerId,\n\t\t\tdeepbookPoolId,\n\t\t\triskRatio,\n\t\t\tbaseAsset,\n\t\t\tquoteAsset,\n\t\t\tbaseDebt,\n\t\t\tquoteDebt,\n\t\t\tbasePythPrice: basePythPrice.toString(),\n\t\t\tbasePythDecimals,\n\t\t\tquotePythPrice: quotePythPrice.toString(),\n\t\t\tquotePythDecimals,\n\t\t\tcurrentPrice,\n\t\t\tlowestTriggerAbovePrice,\n\t\t\thighestTriggerBelowPrice,\n\t\t};\n\t}\n\n\tasync getMarginManagerStates(\n\t\tmarginManagers: Record<string, string>,\n\t\tdecimals: number = 6,\n\t): Promise<Record<string, MarginManagerState>> {\n\t\tconst entries = Object.entries(marginManagers);\n\t\tif (entries.length === 0) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst tx = new Transaction();\n\n\t\tfor (const [managerId, poolKey] of entries) {\n\t\t\ttx.add(this.#ctx.marginManager.managerState(poolKey, managerId));\n\t\t}\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tif (res.FailedTransaction) {\n\t\t\tthrow new Error(\n\t\t\t\t`Transaction failed: ${res.FailedTransaction.status.error?.message || 'Unknown error'}`,\n\t\t\t);\n\t\t}\n\n\t\tif (!res.commandResults) {\n\t\t\tthrow new Error(`Failed to get margin manager states: Unknown error`);\n\t\t}\n\n\t\tconst results: Record<string, MarginManagerState> = {};\n\n\t\tfor (let i = 0; i < entries.length; i++) {\n\t\t\tconst commandResult = res.commandResults[i];\n\t\t\tif (!commandResult || !commandResult.returnValues) {\n\t\t\t\tthrow new Error(`Failed to get margin manager state for index ${i}: No return values`);\n\t\t\t}\n\n\t\t\tconst [, poolKey] = entries[i];\n\t\t\tconst pool = this.#ctx.config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#ctx.config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#ctx.config.getCoin(pool.quoteCoin);\n\n\t\t\tconst managerId = normalizeSuiAddress(bcs.Address.parse(commandResult.returnValues[0].bcs));\n\t\t\tconst deepbookPoolId = normalizeSuiAddress(\n\t\t\t\tbcs.Address.parse(commandResult.returnValues[1].bcs),\n\t\t\t);\n\t\t\tconst riskRatio = Number(bcs.U64.parse(commandResult.returnValues[2].bcs)) / FLOAT_SCALAR;\n\t\t\tconst baseAsset = formatTokenAmount(\n\t\t\t\tBigInt(bcs.U64.parse(commandResult.returnValues[3].bcs)),\n\t\t\t\tbaseCoin.scalar,\n\t\t\t\tdecimals,\n\t\t\t);\n\t\t\tconst quoteAsset = formatTokenAmount(\n\t\t\t\tBigInt(bcs.U64.parse(commandResult.returnValues[4].bcs)),\n\t\t\t\tquoteCoin.scalar,\n\t\t\t\tdecimals,\n\t\t\t);\n\t\t\tconst baseDebt = formatTokenAmount(\n\t\t\t\tBigInt(bcs.U64.parse(commandResult.returnValues[5].bcs)),\n\t\t\t\tbaseCoin.scalar,\n\t\t\t\tdecimals,\n\t\t\t);\n\t\t\tconst quoteDebt = formatTokenAmount(\n\t\t\t\tBigInt(bcs.U64.parse(commandResult.returnValues[6].bcs)),\n\t\t\t\tquoteCoin.scalar,\n\t\t\t\tdecimals,\n\t\t\t);\n\t\t\tconst basePythPrice = bcs.U64.parse(commandResult.returnValues[7].bcs);\n\t\t\tconst basePythDecimals = Number(\n\t\t\t\tbcs.u8().parse(new Uint8Array(commandResult.returnValues[8].bcs)),\n\t\t\t);\n\t\t\tconst quotePythPrice = bcs.U64.parse(commandResult.returnValues[9].bcs);\n\t\t\tconst quotePythDecimals = Number(\n\t\t\t\tbcs.u8().parse(new Uint8Array(commandResult.returnValues[10].bcs)),\n\t\t\t);\n\t\t\tconst currentPrice = BigInt(bcs.U64.parse(commandResult.returnValues[11].bcs));\n\t\t\tconst lowestTriggerAbovePrice = BigInt(bcs.U64.parse(commandResult.returnValues[12].bcs));\n\t\t\tconst highestTriggerBelowPrice = BigInt(bcs.U64.parse(commandResult.returnValues[13].bcs));\n\n\t\t\tresults[managerId] = {\n\t\t\t\tmanagerId,\n\t\t\t\tdeepbookPoolId,\n\t\t\t\triskRatio,\n\t\t\t\tbaseAsset,\n\t\t\t\tquoteAsset,\n\t\t\t\tbaseDebt,\n\t\t\t\tquoteDebt,\n\t\t\t\tbasePythPrice: basePythPrice.toString(),\n\t\t\t\tbasePythDecimals,\n\t\t\t\tquotePythPrice: quotePythPrice.toString(),\n\t\t\t\tquotePythDecimals,\n\t\t\t\tcurrentPrice,\n\t\t\t\tlowestTriggerAbovePrice,\n\t\t\t\thighestTriggerBelowPrice,\n\t\t\t};\n\t\t}\n\n\t\treturn results;\n\t}\n\n\tasync getMarginManagerBaseBalance(\n\t\tmarginManagerKey: string,\n\t\tdecimals: number = 9,\n\t): Promise<string> {\n\t\tconst manager = this.#ctx.config.getMarginManager(marginManagerKey);\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.marginManager.baseBalance(manager.poolKey, manager.address));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tif (res.FailedTransaction) {\n\t\t\tthrow new Error(\n\t\t\t\t`Transaction failed: ${res.FailedTransaction.status.error?.message || 'Unknown error'}`,\n\t\t\t);\n\t\t}\n\n\t\tif (!res.commandResults || !res.commandResults[0] || !res.commandResults[0].returnValues) {\n\t\t\tthrow new Error(`Failed to get margin manager base balance: Unknown error`);\n\t\t}\n\n\t\tconst bytes = res.commandResults[0].returnValues[0].bcs;\n\t\tconst pool = this.#ctx.config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#ctx.config.getCoin(pool.baseCoin);\n\n\t\treturn formatTokenAmount(BigInt(bcs.U64.parse(bytes)), baseCoin.scalar, decimals);\n\t}\n\n\tasync getMarginManagerQuoteBalance(\n\t\tmarginManagerKey: string,\n\t\tdecimals: number = 9,\n\t): Promise<string> {\n\t\tconst manager = this.#ctx.config.getMarginManager(marginManagerKey);\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.marginManager.quoteBalance(manager.poolKey, manager.address));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tif (res.FailedTransaction) {\n\t\t\tthrow new Error(\n\t\t\t\t`Transaction failed: ${res.FailedTransaction.status.error?.message || 'Unknown error'}`,\n\t\t\t);\n\t\t}\n\n\t\tif (!res.commandResults || !res.commandResults[0] || !res.commandResults[0].returnValues) {\n\t\t\tthrow new Error(`Failed to get margin manager quote balance: Unknown error`);\n\t\t}\n\n\t\tconst bytes = res.commandResults[0].returnValues[0].bcs;\n\t\tconst pool = this.#ctx.config.getPool(manager.poolKey);\n\t\tconst quoteCoin = this.#ctx.config.getCoin(pool.quoteCoin);\n\n\t\treturn formatTokenAmount(BigInt(bcs.U64.parse(bytes)), quoteCoin.scalar, decimals);\n\t}\n\n\tasync getMarginManagerDeepBalance(\n\t\tmarginManagerKey: string,\n\t\tdecimals: number = 6,\n\t): Promise<string> {\n\t\tconst manager = this.#ctx.config.getMarginManager(marginManagerKey);\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.marginManager.deepBalance(manager.poolKey, manager.address));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tif (res.FailedTransaction) {\n\t\t\tthrow new Error(\n\t\t\t\t`Transaction failed: ${res.FailedTransaction.status.error?.message || 'Unknown error'}`,\n\t\t\t);\n\t\t}\n\n\t\tif (!res.commandResults || !res.commandResults[0] || !res.commandResults[0].returnValues) {\n\t\t\tthrow new Error(`Failed to get margin manager DEEP balance: Unknown error`);\n\t\t}\n\n\t\tconst bytes = res.commandResults[0].returnValues[0].bcs;\n\t\tconst deepCoin = this.#ctx.config.getCoin('DEEP');\n\n\t\treturn formatTokenAmount(BigInt(bcs.U64.parse(bytes)), deepCoin.scalar, decimals);\n\t}\n\n\tasync getMarginManagerBalances(\n\t\tmarginManagers: Record<string, string>,\n\t\tdecimals: number = 9,\n\t): Promise<Record<string, MarginManagerBalancesResult>> {\n\t\tconst entries = Object.entries(marginManagers);\n\t\tif (entries.length === 0) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst tx = new Transaction();\n\n\t\tfor (const [managerId, poolKey] of entries) {\n\t\t\ttx.add(this.#ctx.marginManager.baseBalance(poolKey, managerId));\n\t\t\ttx.add(this.#ctx.marginManager.quoteBalance(poolKey, managerId));\n\t\t\ttx.add(this.#ctx.marginManager.deepBalance(poolKey, managerId));\n\t\t}\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tif (res.FailedTransaction) {\n\t\t\tthrow new Error(\n\t\t\t\t`Transaction failed: ${res.FailedTransaction.status.error?.message || 'Unknown error'}`,\n\t\t\t);\n\t\t}\n\n\t\tif (!res.commandResults) {\n\t\t\tthrow new Error('Failed to get margin manager balances: No command results');\n\t\t}\n\n\t\tconst results: Record<string, MarginManagerBalancesResult> = {};\n\t\tconst deepCoin = this.#ctx.config.getCoin('DEEP');\n\n\t\tfor (let i = 0; i < entries.length; i++) {\n\t\t\tconst [managerId, poolKey] = entries[i];\n\t\t\tconst pool = this.#ctx.config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#ctx.config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#ctx.config.getCoin(pool.quoteCoin);\n\n\t\t\tconst baseResult = res.commandResults[i * 3];\n\t\t\tconst quoteResult = res.commandResults[i * 3 + 1];\n\t\t\tconst deepResult = res.commandResults[i * 3 + 2];\n\n\t\t\tif (!baseResult?.returnValues || !quoteResult?.returnValues || !deepResult?.returnValues) {\n\t\t\t\tthrow new Error(`Failed to get balances for margin manager ${managerId}: No return values`);\n\t\t\t}\n\n\t\t\tresults[managerId] = {\n\t\t\t\tbase: formatTokenAmount(\n\t\t\t\t\tBigInt(bcs.U64.parse(baseResult.returnValues[0].bcs)),\n\t\t\t\t\tbaseCoin.scalar,\n\t\t\t\t\tdecimals,\n\t\t\t\t),\n\t\t\t\tquote: formatTokenAmount(\n\t\t\t\t\tBigInt(bcs.U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ACL,OAAO,IAAI,IAAI,MAAM,WAAW,aAAa,GAAG,IAAI,CAAC,EACrD,SAAS,QACT,SACA;IACD,OAAO,kBACN,OAAO,IAAI,IAAI,MAAM,YAAY,aAAa,GAAG,IAAI,CAAC,EACtD,UAAU,QACV,SACA;IACD,MAAM,kBACL,OAAO,IAAI,IAAI,MAAM,WAAW,aAAa,GAAG,IAAI,CAAC,EACrD,SAAS,QACT,SACA;IACD;;AAGF,SAAO"}
|
|
1
|
+
{"version":3,"file":"marginManagerQueries.mjs","names":["#ctx"],"sources":["../../src/queries/marginManagerQueries.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@mysten/sui/bcs';\nimport { Transaction } from '@mysten/sui/transactions';\nimport { normalizeSuiAddress } from '@mysten/sui/utils';\n\nimport type {\n\tBorrowedShares,\n\tMarginManagerAssets,\n\tMarginManagerBalancesResult,\n\tMarginManagerDebts,\n\tMarginManagerState,\n} from '../types/index.js';\nimport { FLOAT_SCALAR } from '../utils/config.js';\nimport { formatTokenAmount } from './context.js';\nimport type { QueryContext } from './context.js';\n\nexport class MarginManagerQueries {\n\t#ctx: QueryContext;\n\n\tconstructor(ctx: QueryContext) {\n\t\tthis.#ctx = ctx;\n\t}\n\n\tasync getMarginManagerOwner(marginManagerKey: string): Promise<string> {\n\t\tconst manager = this.#ctx.config.getMarginManager(marginManagerKey);\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginManager.ownerByPoolKey(manager.poolKey, manager.address));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\treturn normalizeSuiAddress(bcs.Address.parse(bytes));\n\t}\n\n\tasync getMarginManagerDeepbookPool(marginManagerKey: string): Promise<string> {\n\t\tconst manager = this.#ctx.config.getMarginManager(marginManagerKey);\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginManager.deepbookPool(manager.poolKey, manager.address));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\treturn normalizeSuiAddress(bcs.Address.parse(bytes));\n\t}\n\n\tasync getMarginManagerMarginPoolId(marginManagerKey: string): Promise<string | null> {\n\t\tconst manager = this.#ctx.config.getMarginManager(marginManagerKey);\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginManager.marginPoolId(manager.poolKey, manager.address));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst option = bcs.option(bcs.Address).parse(bytes);\n\t\treturn option ? normalizeSuiAddress(option) : null;\n\t}\n\n\tasync getMarginManagerBorrowedShares(marginManagerKey: string): Promise<BorrowedShares> {\n\t\tconst manager = this.#ctx.config.getMarginManager(marginManagerKey);\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginManager.borrowedShares(manager.poolKey, manager.address));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst baseBytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst quoteBytes = res.commandResults![0].returnValues[1].bcs;\n\t\tconst baseShares = bcs.U64.parse(baseBytes).toString();\n\t\tconst quoteShares = bcs.U64.parse(quoteBytes).toString();\n\n\t\treturn { baseShares, quoteShares };\n\t}\n\n\tasync getMarginManagerBorrowedBaseShares(marginManagerKey: string): Promise<string> {\n\t\tconst manager = this.#ctx.config.getMarginManager(marginManagerKey);\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginManager.borrowedBaseShares(manager.poolKey, manager.address));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\treturn bcs.U64.parse(bytes).toString();\n\t}\n\n\tasync getMarginManagerBorrowedQuoteShares(marginManagerKey: string): Promise<string> {\n\t\tconst manager = this.#ctx.config.getMarginManager(marginManagerKey);\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginManager.borrowedQuoteShares(manager.poolKey, manager.address));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\treturn bcs.U64.parse(bytes).toString();\n\t}\n\n\tasync getMarginManagerHasBaseDebt(marginManagerKey: string): Promise<boolean> {\n\t\tconst manager = this.#ctx.config.getMarginManager(marginManagerKey);\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginManager.hasBaseDebt(manager.poolKey, manager.address));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\treturn bcs.bool().parse(bytes);\n\t}\n\n\tasync getMarginManagerBalanceManagerId(marginManagerAddress: string): Promise<string> {\n\t\tconst res = await this.#ctx.client.core.getObject({\n\t\t\tobjectId: marginManagerAddress,\n\t\t\tinclude: { content: true },\n\t\t});\n\n\t\tif (!res.object?.content) {\n\t\t\tthrow new Error(`Margin manager not found: ${marginManagerAddress}`);\n\t\t}\n\n\t\tconst MarginManagerBalanceManagerId = bcs.struct('MarginManagerBalanceManagerId', {\n\t\t\tid: bcs.Address,\n\t\t\towner: bcs.Address,\n\t\t\tdeepbook_pool: bcs.Address,\n\t\t\tmargin_pool_id: bcs.option(bcs.Address),\n\t\t\tbalance_manager_id: bcs.Address,\n\t\t});\n\n\t\tconst parsed = MarginManagerBalanceManagerId.parse(res.object.content);\n\t\treturn normalizeSuiAddress(parsed.balance_manager_id);\n\t}\n\n\tasync getMarginManagerAssets(\n\t\tmarginManagerKey: string,\n\t\tdecimals: number = 6,\n\t): Promise<MarginManagerAssets> {\n\t\tconst manager = this.#ctx.config.getMarginManager(marginManagerKey);\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginManager.calculateAssets(manager.poolKey, manager.address));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst baseBytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst quoteBytes = res.commandResults![0].returnValues[1].bcs;\n\t\tconst pool = this.#ctx.config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#ctx.config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#ctx.config.getCoin(pool.quoteCoin);\n\n\t\tconst baseAsset = formatTokenAmount(\n\t\t\tBigInt(bcs.U64.parse(baseBytes)),\n\t\t\tbaseCoin.scalar,\n\t\t\tdecimals,\n\t\t);\n\t\tconst quoteAsset = formatTokenAmount(\n\t\t\tBigInt(bcs.U64.parse(quoteBytes)),\n\t\t\tquoteCoin.scalar,\n\t\t\tdecimals,\n\t\t);\n\n\t\treturn { baseAsset, quoteAsset };\n\t}\n\n\tasync getMarginManagerDebts(\n\t\tmarginManagerKey: string,\n\t\tdecimals: number = 6,\n\t): Promise<MarginManagerDebts> {\n\t\tconst hasBaseDebt = await this.getMarginManagerHasBaseDebt(marginManagerKey);\n\n\t\tconst manager = this.#ctx.config.getMarginManager(marginManagerKey);\n\t\tconst pool = this.#ctx.config.getPool(manager.poolKey);\n\t\tconst debtCoinKey = hasBaseDebt ? pool.baseCoin : pool.quoteCoin;\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginManager.calculateDebts(manager.poolKey, debtCoinKey, manager.address));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tif (res.FailedTransaction) {\n\t\t\tthrow new Error(\n\t\t\t\t`Transaction failed: ${res.FailedTransaction.status.error?.message || 'Unknown error'}`,\n\t\t\t);\n\t\t}\n\n\t\tif (!res.commandResults || !res.commandResults[0] || !res.commandResults[0].returnValues) {\n\t\t\tthrow new Error(`Failed to get margin manager debts: ${'Unknown error'}`);\n\t\t}\n\n\t\tconst baseBytes = res.commandResults[0].returnValues[0].bcs;\n\t\tconst quoteBytes = res.commandResults[0].returnValues[1].bcs;\n\t\tconst debtCoin = this.#ctx.config.getCoin(debtCoinKey);\n\n\t\tconst baseDebt = formatTokenAmount(BigInt(bcs.U64.parse(baseBytes)), debtCoin.scalar, decimals);\n\t\tconst quoteDebt = formatTokenAmount(\n\t\t\tBigInt(bcs.U64.parse(quoteBytes)),\n\t\t\tdebtCoin.scalar,\n\t\t\tdecimals,\n\t\t);\n\n\t\treturn { baseDebt, quoteDebt };\n\t}\n\n\tasync getMarginManagerState(\n\t\tmarginManagerKey: string,\n\t\tdecimals: number = 6,\n\t): Promise<MarginManagerState> {\n\t\tconst manager = this.#ctx.config.getMarginManager(marginManagerKey);\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginManager.managerState(manager.poolKey, manager.address));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tif (res.FailedTransaction) {\n\t\t\tthrow new Error(\n\t\t\t\t`Transaction failed: ${res.FailedTransaction.status.error?.message || 'Unknown error'}`,\n\t\t\t);\n\t\t}\n\n\t\tif (!res.commandResults || !res.commandResults[0] || !res.commandResults[0].returnValues) {\n\t\t\tthrow new Error(`Failed to get margin manager state: Unknown error`);\n\t\t}\n\n\t\tconst pool = this.#ctx.config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#ctx.config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#ctx.config.getCoin(pool.quoteCoin);\n\n\t\tconst managerId = normalizeSuiAddress(\n\t\t\tbcs.Address.parse(res.commandResults[0].returnValues[0].bcs),\n\t\t);\n\t\tconst deepbookPoolId = normalizeSuiAddress(\n\t\t\tbcs.Address.parse(res.commandResults[0].returnValues[1].bcs),\n\t\t);\n\t\tconst riskRatio =\n\t\t\tNumber(bcs.U64.parse(res.commandResults[0].returnValues[2].bcs)) / FLOAT_SCALAR;\n\t\tconst baseAsset = formatTokenAmount(\n\t\t\tBigInt(bcs.U64.parse(res.commandResults[0].returnValues[3].bcs)),\n\t\t\tbaseCoin.scalar,\n\t\t\tdecimals,\n\t\t);\n\t\tconst quoteAsset = formatTokenAmount(\n\t\t\tBigInt(bcs.U64.parse(res.commandResults[0].returnValues[4].bcs)),\n\t\t\tquoteCoin.scalar,\n\t\t\tdecimals,\n\t\t);\n\t\tconst baseDebt = formatTokenAmount(\n\t\t\tBigInt(bcs.U64.parse(res.commandResults[0].returnValues[5].bcs)),\n\t\t\tbaseCoin.scalar,\n\t\t\tdecimals,\n\t\t);\n\t\tconst quoteDebt = formatTokenAmount(\n\t\t\tBigInt(bcs.U64.parse(res.commandResults[0].returnValues[6].bcs)),\n\t\t\tquoteCoin.scalar,\n\t\t\tdecimals,\n\t\t);\n\t\tconst basePythPrice = bcs.U64.parse(res.commandResults[0].returnValues[7].bcs);\n\t\tconst basePythDecimals = Number(\n\t\t\tbcs.u8().parse(new Uint8Array(res.commandResults[0].returnValues[8].bcs)),\n\t\t);\n\t\tconst quotePythPrice = bcs.U64.parse(res.commandResults[0].returnValues[9].bcs);\n\t\tconst quotePythDecimals = Number(\n\t\t\tbcs.u8().parse(new Uint8Array(res.commandResults[0].returnValues[10].bcs)),\n\t\t);\n\t\tconst currentPrice = BigInt(bcs.U64.parse(res.commandResults[0].returnValues[11].bcs));\n\t\tconst lowestTriggerAbovePrice = BigInt(\n\t\t\tbcs.U64.parse(res.commandResults[0].returnValues[12].bcs),\n\t\t);\n\t\tconst highestTriggerBelowPrice = BigInt(\n\t\t\tbcs.U64.parse(res.commandResults[0].returnValues[13].bcs),\n\t\t);\n\n\t\treturn {\n\t\t\tmanagerId,\n\t\t\tdeepbookPoolId,\n\t\t\triskRatio,\n\t\t\tbaseAsset,\n\t\t\tquoteAsset,\n\t\t\tbaseDebt,\n\t\t\tquoteDebt,\n\t\t\tbasePythPrice: basePythPrice.toString(),\n\t\t\tbasePythDecimals,\n\t\t\tquotePythPrice: quotePythPrice.toString(),\n\t\t\tquotePythDecimals,\n\t\t\tcurrentPrice,\n\t\t\tlowestTriggerAbovePrice,\n\t\t\thighestTriggerBelowPrice,\n\t\t};\n\t}\n\n\tasync getMarginManagerStates(\n\t\tmarginManagers: Record<string, string>,\n\t\tdecimals: number = 6,\n\t): Promise<Record<string, MarginManagerState>> {\n\t\tconst entries = Object.entries(marginManagers);\n\t\tif (entries.length === 0) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\n\t\tfor (const [managerId, poolKey] of entries) {\n\t\t\ttx.add(this.#ctx.marginManager.managerState(poolKey, managerId));\n\t\t}\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tif (res.FailedTransaction) {\n\t\t\tthrow new Error(\n\t\t\t\t`Transaction failed: ${res.FailedTransaction.status.error?.message || 'Unknown error'}`,\n\t\t\t);\n\t\t}\n\n\t\tif (!res.commandResults) {\n\t\t\tthrow new Error(`Failed to get margin manager states: Unknown error`);\n\t\t}\n\n\t\tconst results: Record<string, MarginManagerState> = {};\n\n\t\tfor (let i = 0; i < entries.length; i++) {\n\t\t\tconst commandResult = res.commandResults[i];\n\t\t\tif (!commandResult || !commandResult.returnValues) {\n\t\t\t\tthrow new Error(`Failed to get margin manager state for index ${i}: No return values`);\n\t\t\t}\n\n\t\t\tconst [, poolKey] = entries[i];\n\t\t\tconst pool = this.#ctx.config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#ctx.config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#ctx.config.getCoin(pool.quoteCoin);\n\n\t\t\tconst managerId = normalizeSuiAddress(bcs.Address.parse(commandResult.returnValues[0].bcs));\n\t\t\tconst deepbookPoolId = normalizeSuiAddress(\n\t\t\t\tbcs.Address.parse(commandResult.returnValues[1].bcs),\n\t\t\t);\n\t\t\tconst riskRatio = Number(bcs.U64.parse(commandResult.returnValues[2].bcs)) / FLOAT_SCALAR;\n\t\t\tconst baseAsset = formatTokenAmount(\n\t\t\t\tBigInt(bcs.U64.parse(commandResult.returnValues[3].bcs)),\n\t\t\t\tbaseCoin.scalar,\n\t\t\t\tdecimals,\n\t\t\t);\n\t\t\tconst quoteAsset = formatTokenAmount(\n\t\t\t\tBigInt(bcs.U64.parse(commandResult.returnValues[4].bcs)),\n\t\t\t\tquoteCoin.scalar,\n\t\t\t\tdecimals,\n\t\t\t);\n\t\t\tconst baseDebt = formatTokenAmount(\n\t\t\t\tBigInt(bcs.U64.parse(commandResult.returnValues[5].bcs)),\n\t\t\t\tbaseCoin.scalar,\n\t\t\t\tdecimals,\n\t\t\t);\n\t\t\tconst quoteDebt = formatTokenAmount(\n\t\t\t\tBigInt(bcs.U64.parse(commandResult.returnValues[6].bcs)),\n\t\t\t\tquoteCoin.scalar,\n\t\t\t\tdecimals,\n\t\t\t);\n\t\t\tconst basePythPrice = bcs.U64.parse(commandResult.returnValues[7].bcs);\n\t\t\tconst basePythDecimals = Number(\n\t\t\t\tbcs.u8().parse(new Uint8Array(commandResult.returnValues[8].bcs)),\n\t\t\t);\n\t\t\tconst quotePythPrice = bcs.U64.parse(commandResult.returnValues[9].bcs);\n\t\t\tconst quotePythDecimals = Number(\n\t\t\t\tbcs.u8().parse(new Uint8Array(commandResult.returnValues[10].bcs)),\n\t\t\t);\n\t\t\tconst currentPrice = BigInt(bcs.U64.parse(commandResult.returnValues[11].bcs));\n\t\t\tconst lowestTriggerAbovePrice = BigInt(bcs.U64.parse(commandResult.returnValues[12].bcs));\n\t\t\tconst highestTriggerBelowPrice = BigInt(bcs.U64.parse(commandResult.returnValues[13].bcs));\n\n\t\t\tresults[managerId] = {\n\t\t\t\tmanagerId,\n\t\t\t\tdeepbookPoolId,\n\t\t\t\triskRatio,\n\t\t\t\tbaseAsset,\n\t\t\t\tquoteAsset,\n\t\t\t\tbaseDebt,\n\t\t\t\tquoteDebt,\n\t\t\t\tbasePythPrice: basePythPrice.toString(),\n\t\t\t\tbasePythDecimals,\n\t\t\t\tquotePythPrice: quotePythPrice.toString(),\n\t\t\t\tquotePythDecimals,\n\t\t\t\tcurrentPrice,\n\t\t\t\tlowestTriggerAbovePrice,\n\t\t\t\thighestTriggerBelowPrice,\n\t\t\t};\n\t\t}\n\n\t\treturn results;\n\t}\n\n\tasync getMarginManagerBaseBalance(\n\t\tmarginManagerKey: string,\n\t\tdecimals: number = 9,\n\t): Promise<string> {\n\t\tconst manager = this.#ctx.config.getMarginManager(marginManagerKey);\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginManager.baseBalance(manager.poolKey, manager.address));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tif (res.FailedTransaction) {\n\t\t\tthrow new Error(\n\t\t\t\t`Transaction failed: ${res.FailedTransaction.status.error?.message || 'Unknown error'}`,\n\t\t\t);\n\t\t}\n\n\t\tif (!res.commandResults || !res.commandResults[0] || !res.commandResults[0].returnValues) {\n\t\t\tthrow new Error(`Failed to get margin manager base balance: Unknown error`);\n\t\t}\n\n\t\tconst bytes = res.commandResults[0].returnValues[0].bcs;\n\t\tconst pool = this.#ctx.config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#ctx.config.getCoin(pool.baseCoin);\n\n\t\treturn formatTokenAmount(BigInt(bcs.U64.parse(bytes)), baseCoin.scalar, decimals);\n\t}\n\n\tasync getMarginManagerQuoteBalance(\n\t\tmarginManagerKey: string,\n\t\tdecimals: number = 9,\n\t): Promise<string> {\n\t\tconst manager = this.#ctx.config.getMarginManager(marginManagerKey);\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginManager.quoteBalance(manager.poolKey, manager.address));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tif (res.FailedTransaction) {\n\t\t\tthrow new Error(\n\t\t\t\t`Transaction failed: ${res.FailedTransaction.status.error?.message || 'Unknown error'}`,\n\t\t\t);\n\t\t}\n\n\t\tif (!res.commandResults || !res.commandResults[0] || !res.commandResults[0].returnValues) {\n\t\t\tthrow new Error(`Failed to get margin manager quote balance: Unknown error`);\n\t\t}\n\n\t\tconst bytes = res.commandResults[0].returnValues[0].bcs;\n\t\tconst pool = this.#ctx.config.getPool(manager.poolKey);\n\t\tconst quoteCoin = this.#ctx.config.getCoin(pool.quoteCoin);\n\n\t\treturn formatTokenAmount(BigInt(bcs.U64.parse(bytes)), quoteCoin.scalar, decimals);\n\t}\n\n\tasync getMarginManagerDeepBalance(\n\t\tmarginManagerKey: string,\n\t\tdecimals: number = 6,\n\t): Promise<string> {\n\t\tconst manager = this.#ctx.config.getMarginManager(marginManagerKey);\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginManager.deepBalance(manager.poolKey, manager.address));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tif (res.FailedTransaction) {\n\t\t\tthrow new Error(\n\t\t\t\t`Transaction failed: ${res.FailedTransaction.status.error?.message || 'Unknown error'}`,\n\t\t\t);\n\t\t}\n\n\t\tif (!res.commandResults || !res.commandResults[0] || !res.commandResults[0].returnValues) {\n\t\t\tthrow new Error(`Failed to get margin manager DEEP balance: Unknown error`);\n\t\t}\n\n\t\tconst bytes = res.commandResults[0].returnValues[0].bcs;\n\t\tconst deepCoin = this.#ctx.config.getCoin('DEEP');\n\n\t\treturn formatTokenAmount(BigInt(bcs.U64.parse(bytes)), deepCoin.scalar, decimals);\n\t}\n\n\tasync getMarginManagerBalances(\n\t\tmarginManagers: Record<string, string>,\n\t\tdecimals: number = 9,\n\t): Promise<Record<string, MarginManagerBalancesResult>> {\n\t\tconst entries = Object.entries(marginManagers);\n\t\tif (entries.length === 0) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\n\t\tfor (const [managerId, poolKey] of entries) {\n\t\t\ttx.add(this.#ctx.marginManager.baseBalance(poolKey, managerId));\n\t\t\ttx.add(this.#ctx.marginManager.quoteBalance(poolKey, managerId));\n\t\t\ttx.add(this.#ctx.marginManager.deepBalance(poolKey, managerId));\n\t\t}\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tif (res.FailedTransaction) {\n\t\t\tthrow new Error(\n\t\t\t\t`Transaction failed: ${res.FailedTransaction.status.error?.message || 'Unknown error'}`,\n\t\t\t);\n\t\t}\n\n\t\tif (!res.commandResults) {\n\t\t\tthrow new Error('Failed to get margin manager balances: No command results');\n\t\t}\n\n\t\tconst results: Record<string, MarginManagerBalancesResult> = {};\n\t\tconst deepCoin = this.#ctx.config.getCoin('DEEP');\n\n\t\tfor (let i = 0; i < entries.length; i++) {\n\t\t\tconst [managerId, poolKey] = entries[i];\n\t\t\tconst pool = this.#ctx.config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#ctx.config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#ctx.config.getCoin(pool.quoteCoin);\n\n\t\t\tconst baseResult = res.commandResults[i * 3];\n\t\t\tconst quoteResult = res.commandResults[i * 3 + 1];\n\t\t\tconst deepResult = res.commandResults[i * 3 + 2];\n\n\t\t\tif (!baseResult?.returnValues || !quoteResult?.returnValues || !deepResult?.returnValues) {\n\t\t\t\tthrow new Error(`Failed to get balances for margin manager ${managerId}: No return values`);\n\t\t\t}\n\n\t\t\tresults[managerId] = {\n\t\t\t\tbase: formatTokenAmount(\n\t\t\t\t\tBigInt(bcs.U64.parse(baseResult.returnValues[0].bcs)),\n\t\t\t\t\tbaseCoin.scalar,\n\t\t\t\t\tdecimals,\n\t\t\t\t),\n\t\t\t\tquote: formatTokenAmount(\n\t\t\t\t\tBigInt(bcs.U64.parse(quoteResult.returnValues[0].bcs)),\n\t\t\t\t\tquoteCoin.scalar,\n\t\t\t\t\tdecimals,\n\t\t\t\t),\n\t\t\t\tdeep: formatTokenAmount(\n\t\t\t\t\tBigInt(bcs.U64.parse(deepResult.returnValues[0].bcs)),\n\t\t\t\t\tdeepCoin.scalar,\n\t\t\t\t\tdecimals,\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\n\t\treturn results;\n\t}\n}\n"],"mappings":";;;;;;;AAkBA,IAAa,uBAAb,MAAkC;CACjC;CAEA,YAAY,KAAmB;AAC9B,QAAKA,MAAO;;CAGb,MAAM,sBAAsB,kBAA2C;EACtE,MA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C/C,MAAM,aAAa,IAAI,eAAe,IAAI,IAAI;AAE9C,OAAI,CAAC,YAAY,gBAAgB,CAAC,aAAa,gBAAgB,CAAC,YAAY,aAC3E,OAAM,IAAI,MAAM,6CAA6C,UAAU,oBAAoB;AAG5F,WAAQ,aAAa;IACpB,MAAM,kBACL,OAAO,IAAI,IAAI,MAAM,WAAW,aAAa,GAAG,IAAI,CAAC,EACrD,SAAS,QACT,SACA;IACD,OAAO,kBACN,OAAO,IAAI,IAAI,MAAM,YAAY,aAAa,GAAG,IAAI,CAAC,EACtD,UAAU,QACV,SACA;IACD,MAAM,kBACL,OAAO,IAAI,IAAI,MAAM,WAAW,aAAa,GAAG,IAAI,CAAC,EACrD,SAAS,QACT,SACA;IACD;;AAGF,SAAO"}
|
|
@@ -11,6 +11,7 @@ var MarginPoolQueries = class {
|
|
|
11
11
|
}
|
|
12
12
|
async getMarginPoolId(coinKey) {
|
|
13
13
|
const tx = new Transaction();
|
|
14
|
+
tx.setSender(this.#ctx.address);
|
|
14
15
|
tx.add(this.#ctx.marginPool.getId(coinKey));
|
|
15
16
|
const bytes = (await this.#ctx.client.core.simulateTransaction({
|
|
16
17
|
transaction: tx,
|
|
@@ -23,6 +24,7 @@ var MarginPoolQueries = class {
|
|
|
23
24
|
}
|
|
24
25
|
async isDeepbookPoolAllowed(coinKey, deepbookPoolId) {
|
|
25
26
|
const tx = new Transaction();
|
|
27
|
+
tx.setSender(this.#ctx.address);
|
|
26
28
|
tx.add(this.#ctx.marginPool.deepbookPoolAllowed(coinKey, deepbookPoolId));
|
|
27
29
|
const bytes = (await this.#ctx.client.core.simulateTransaction({
|
|
28
30
|
transaction: tx,
|
|
@@ -35,6 +37,7 @@ var MarginPoolQueries = class {
|
|
|
35
37
|
}
|
|
36
38
|
async getMarginPoolTotalSupply(coinKey, decimals = 6) {
|
|
37
39
|
const tx = new Transaction();
|
|
40
|
+
tx.setSender(this.#ctx.address);
|
|
38
41
|
tx.add(this.#ctx.marginPool.totalSupply(coinKey));
|
|
39
42
|
const bytes = (await this.#ctx.client.core.simulateTransaction({
|
|
40
43
|
transaction: tx,
|
|
@@ -47,6 +50,7 @@ var MarginPoolQueries = class {
|
|
|
47
50
|
}
|
|
48
51
|
async getMarginPoolSupplyShares(coinKey, decimals = 6) {
|
|
49
52
|
const tx = new Transaction();
|
|
53
|
+
tx.setSender(this.#ctx.address);
|
|
50
54
|
tx.add(this.#ctx.marginPool.supplyShares(coinKey));
|
|
51
55
|
const bytes = (await this.#ctx.client.core.simulateTransaction({
|
|
52
56
|
transaction: tx,
|
|
@@ -59,6 +63,7 @@ var MarginPoolQueries = class {
|
|
|
59
63
|
}
|
|
60
64
|
async getMarginPoolTotalBorrow(coinKey, decimals = 6) {
|
|
61
65
|
const tx = new Transaction();
|
|
66
|
+
tx.setSender(this.#ctx.address);
|
|
62
67
|
tx.add(this.#ctx.marginPool.totalBorrow(coinKey));
|
|
63
68
|
const bytes = (await this.#ctx.client.core.simulateTransaction({
|
|
64
69
|
transaction: tx,
|
|
@@ -71,6 +76,7 @@ var MarginPoolQueries = class {
|
|
|
71
76
|
}
|
|
72
77
|
async getMarginPoolBorrowShares(coinKey, decimals = 6) {
|
|
73
78
|
const tx = new Transaction();
|
|
79
|
+
tx.setSender(this.#ctx.address);
|
|
74
80
|
tx.add(this.#ctx.marginPool.borrowShares(coinKey));
|
|
75
81
|
const bytes = (await this.#ctx.client.core.simulateTransaction({
|
|
76
82
|
transaction: tx,
|
|
@@ -83,6 +89,7 @@ var MarginPoolQueries = class {
|
|
|
83
89
|
}
|
|
84
90
|
async getMarginPoolLastUpdateTimestamp(coinKey) {
|
|
85
91
|
const tx = new Transaction();
|
|
92
|
+
tx.setSender(this.#ctx.address);
|
|
86
93
|
tx.add(this.#ctx.marginPool.lastUpdateTimestamp(coinKey));
|
|
87
94
|
const bytes = (await this.#ctx.client.core.simulateTransaction({
|
|
88
95
|
transaction: tx,
|
|
@@ -95,6 +102,7 @@ var MarginPoolQueries = class {
|
|
|
95
102
|
}
|
|
96
103
|
async getMarginPoolSupplyCap(coinKey, decimals = 6) {
|
|
97
104
|
const tx = new Transaction();
|
|
105
|
+
tx.setSender(this.#ctx.address);
|
|
98
106
|
tx.add(this.#ctx.marginPool.supplyCap(coinKey));
|
|
99
107
|
const bytes = (await this.#ctx.client.core.simulateTransaction({
|
|
100
108
|
transaction: tx,
|
|
@@ -107,6 +115,7 @@ var MarginPoolQueries = class {
|
|
|
107
115
|
}
|
|
108
116
|
async getMarginPoolMaxUtilizationRate(coinKey) {
|
|
109
117
|
const tx = new Transaction();
|
|
118
|
+
tx.setSender(this.#ctx.address);
|
|
110
119
|
tx.add(this.#ctx.marginPool.maxUtilizationRate(coinKey));
|
|
111
120
|
const bytes = (await this.#ctx.client.core.simulateTransaction({
|
|
112
121
|
transaction: tx,
|
|
@@ -119,6 +128,7 @@ var MarginPoolQueries = class {
|
|
|
119
128
|
}
|
|
120
129
|
async getMarginPoolProtocolSpread(coinKey) {
|
|
121
130
|
const tx = new Transaction();
|
|
131
|
+
tx.setSender(this.#ctx.address);
|
|
122
132
|
tx.add(this.#ctx.marginPool.protocolSpread(coinKey));
|
|
123
133
|
const bytes = (await this.#ctx.client.core.simulateTransaction({
|
|
124
134
|
transaction: tx,
|
|
@@ -131,6 +141,7 @@ var MarginPoolQueries = class {
|
|
|
131
141
|
}
|
|
132
142
|
async getMarginPoolMinBorrow(coinKey, decimals = 6) {
|
|
133
143
|
const tx = new Transaction();
|
|
144
|
+
tx.setSender(this.#ctx.address);
|
|
134
145
|
tx.add(this.#ctx.marginPool.minBorrow(coinKey));
|
|
135
146
|
const bytes = (await this.#ctx.client.core.simulateTransaction({
|
|
136
147
|
transaction: tx,
|
|
@@ -143,6 +154,7 @@ var MarginPoolQueries = class {
|
|
|
143
154
|
}
|
|
144
155
|
async getMarginPoolInterestRate(coinKey) {
|
|
145
156
|
const tx = new Transaction();
|
|
157
|
+
tx.setSender(this.#ctx.address);
|
|
146
158
|
tx.add(this.#ctx.marginPool.interestRate(coinKey));
|
|
147
159
|
const bytes = (await this.#ctx.client.core.simulateTransaction({
|
|
148
160
|
transaction: tx,
|
|
@@ -155,6 +167,7 @@ var MarginPoolQueries = class {
|
|
|
155
167
|
}
|
|
156
168
|
async getUserSupplyShares(coinKey, supplierCapId, decimals = 6) {
|
|
157
169
|
const tx = new Transaction();
|
|
170
|
+
tx.setSender(this.#ctx.address);
|
|
158
171
|
tx.add(this.#ctx.marginPool.userSupplyShares(coinKey, supplierCapId));
|
|
159
172
|
const bytes = (await this.#ctx.client.core.simulateTransaction({
|
|
160
173
|
transaction: tx,
|
|
@@ -167,6 +180,7 @@ var MarginPoolQueries = class {
|
|
|
167
180
|
}
|
|
168
181
|
async getUserSupplyAmount(coinKey, supplierCapId, decimals = 6) {
|
|
169
182
|
const tx = new Transaction();
|
|
183
|
+
tx.setSender(this.#ctx.address);
|
|
170
184
|
tx.add(this.#ctx.marginPool.userSupplyAmount(coinKey, supplierCapId));
|
|
171
185
|
const bytes = (await this.#ctx.client.core.simulateTransaction({
|
|
172
186
|
transaction: tx,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marginPoolQueries.mjs","names":["#ctx"],"sources":["../../src/queries/marginPoolQueries.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@mysten/sui/bcs';\nimport { Transaction } from '@mysten/sui/transactions';\n\nimport { FLOAT_SCALAR } from '../utils/config.js';\nimport { formatTokenAmount } from './context.js';\nimport type { QueryContext } from './context.js';\n\nexport class MarginPoolQueries {\n\t#ctx: QueryContext;\n\n\tconstructor(ctx: QueryContext) {\n\t\tthis.#ctx = ctx;\n\t}\n\n\tasync getMarginPoolId(coinKey: string): Promise<string> {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.marginPool.getId(coinKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\treturn bcs.Address.parse(bytes);\n\t}\n\n\tasync isDeepbookPoolAllowed(coinKey: string, deepbookPoolId: string): Promise<boolean> {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.marginPool.deepbookPoolAllowed(coinKey, deepbookPoolId));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\treturn bcs.bool().parse(bytes);\n\t}\n\n\tasync getMarginPoolTotalSupply(coinKey: string, decimals: number = 6): Promise<string> {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.marginPool.totalSupply(coinKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst rawAmount = BigInt(bcs.U64.parse(bytes));\n\t\tconst coin = this.#ctx.config.getCoin(coinKey);\n\t\treturn formatTokenAmount(rawAmount, coin.scalar, decimals);\n\t}\n\n\tasync getMarginPoolSupplyShares(coinKey: string, decimals: number = 6): Promise<string> {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.marginPool.supplyShares(coinKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst rawShares = BigInt(bcs.U64.parse(bytes));\n\t\tconst coin = this.#ctx.config.getCoin(coinKey);\n\t\treturn formatTokenAmount(rawShares, coin.scalar, decimals);\n\t}\n\n\tasync getMarginPoolTotalBorrow(coinKey: string, decimals: number = 6): Promise<string> {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.marginPool.totalBorrow(coinKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst rawAmount = BigInt(bcs.U64.parse(bytes));\n\t\tconst coin = this.#ctx.config.getCoin(coinKey);\n\t\treturn formatTokenAmount(rawAmount, coin.scalar, decimals);\n\t}\n\n\tasync getMarginPoolBorrowShares(coinKey: string, decimals: number = 6): Promise<string> {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.marginPool.borrowShares(coinKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst rawShares = BigInt(bcs.U64.parse(bytes));\n\t\tconst coin = this.#ctx.config.getCoin(coinKey);\n\t\treturn formatTokenAmount(rawShares, coin.scalar, decimals);\n\t}\n\n\tasync getMarginPoolLastUpdateTimestamp(coinKey: string): Promise<number> {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.marginPool.lastUpdateTimestamp(coinKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\treturn Number(bcs.U64.parse(bytes));\n\t}\n\n\tasync getMarginPoolSupplyCap(coinKey: string, decimals: number = 6): Promise<string> {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.marginPool.supplyCap(coinKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst rawAmount = BigInt(bcs.U64.parse(bytes));\n\t\tconst coin = this.#ctx.config.getCoin(coinKey);\n\t\treturn formatTokenAmount(rawAmount, coin.scalar, decimals);\n\t}\n\n\tasync getMarginPoolMaxUtilizationRate(coinKey: string): Promise<number> {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.marginPool.maxUtilizationRate(coinKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst rawRate = Number(bcs.U64.parse(bytes));\n\t\treturn rawRate / FLOAT_SCALAR;\n\t}\n\n\tasync getMarginPoolProtocolSpread(coinKey: string): Promise<number> {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.marginPool.protocolSpread(coinKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst rawSpread = Number(bcs.U64.parse(bytes));\n\t\treturn rawSpread / FLOAT_SCALAR;\n\t}\n\n\tasync getMarginPoolMinBorrow(coinKey: string, decimals: number = 6): Promise<string> {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.marginPool.minBorrow(coinKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst rawAmount = BigInt(bcs.U64.parse(bytes));\n\t\tconst coin = this.#ctx.config.getCoin(coinKey);\n\t\treturn formatTokenAmount(rawAmount, coin.scalar, decimals);\n\t}\n\n\tasync getMarginPoolInterestRate(coinKey: string): Promise<number> {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.marginPool.interestRate(coinKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst rawRate = Number(bcs.U64.parse(bytes));\n\t\treturn rawRate / FLOAT_SCALAR;\n\t}\n\n\tasync getUserSupplyShares(\n\t\tcoinKey: string,\n\t\tsupplierCapId: string,\n\t\tdecimals: number = 6,\n\t): Promise<string> {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.marginPool.userSupplyShares(coinKey, supplierCapId));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst rawShares = BigInt(bcs.U64.parse(bytes));\n\t\tconst coin = this.#ctx.config.getCoin(coinKey);\n\t\treturn formatTokenAmount(rawShares, coin.scalar, decimals);\n\t}\n\n\tasync getUserSupplyAmount(\n\t\tcoinKey: string,\n\t\tsupplierCapId: string,\n\t\tdecimals: number = 6,\n\t): Promise<string> {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.marginPool.userSupplyAmount(coinKey, supplierCapId));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst rawAmount = BigInt(bcs.U64.parse(bytes));\n\t\tconst coin = this.#ctx.config.getCoin(coinKey);\n\t\treturn formatTokenAmount(rawAmount, coin.scalar, decimals);\n\t}\n}\n"],"mappings":";;;;;;AAUA,IAAa,oBAAb,MAA+B;CAC9B;CAEA,YAAY,KAAmB;AAC9B,QAAKA,MAAO;;CAGb,MAAM,gBAAgB,SAAkC;EACvD,MAAM,KAAK,IAAI,aAAa;AAC5B,KAAG,IAAI,MAAKA,IAAK,W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Aa;GACb,SAAS;IAAE,gBAAgB;IAAM,SAAS;IAAM;GAChD,CAAC,EAEgB,eAAgB,GAAG,aAAa,GAAG;AAGrD,SAAO,kBAFW,OAAO,IAAI,IAAI,MAAM,MAAM,CAAC,EACjC,MAAKA,IAAK,OAAO,QAAQ,QAAQ,CACL,QAAQ,SAAS"}
|
|
1
|
+
{"version":3,"file":"marginPoolQueries.mjs","names":["#ctx"],"sources":["../../src/queries/marginPoolQueries.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@mysten/sui/bcs';\nimport { Transaction } from '@mysten/sui/transactions';\n\nimport { FLOAT_SCALAR } from '../utils/config.js';\nimport { formatTokenAmount } from './context.js';\nimport type { QueryContext } from './context.js';\n\nexport class MarginPoolQueries {\n\t#ctx: QueryContext;\n\n\tconstructor(ctx: QueryContext) {\n\t\tthis.#ctx = ctx;\n\t}\n\n\tasync getMarginPoolId(coinKey: string): Promise<string> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginPool.getId(coinKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\treturn bcs.Address.parse(bytes);\n\t}\n\n\tasync isDeepbookPoolAllowed(coinKey: string, deepbookPoolId: string): Promise<boolean> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginPool.deepbookPoolAllowed(coinKey, deepbookPoolId));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\treturn bcs.bool().parse(bytes);\n\t}\n\n\tasync getMarginPoolTotalSupply(coinKey: string, decimals: number = 6): Promise<string> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginPool.totalSupply(coinKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst rawAmount = BigInt(bcs.U64.parse(bytes));\n\t\tconst coin = this.#ctx.config.getCoin(coinKey);\n\t\treturn formatTokenAmount(rawAmount, coin.scalar, decimals);\n\t}\n\n\tasync getMarginPoolSupplyShares(coinKey: string, decimals: number = 6): Promise<string> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginPool.supplyShares(coinKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst rawShares = BigInt(bcs.U64.parse(bytes));\n\t\tconst coin = this.#ctx.config.getCoin(coinKey);\n\t\treturn formatTokenAmount(rawShares, coin.scalar, decimals);\n\t}\n\n\tasync getMarginPoolTotalBorrow(coinKey: string, decimals: number = 6): Promise<string> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginPool.totalBorrow(coinKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst rawAmount = BigInt(bcs.U64.parse(bytes));\n\t\tconst coin = this.#ctx.config.getCoin(coinKey);\n\t\treturn formatTokenAmount(rawAmount, coin.scalar, decimals);\n\t}\n\n\tasync getMarginPoolBorrowShares(coinKey: string, decimals: number = 6): Promise<string> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginPool.borrowShares(coinKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst rawShares = BigInt(bcs.U64.parse(bytes));\n\t\tconst coin = this.#ctx.config.getCoin(coinKey);\n\t\treturn formatTokenAmount(rawShares, coin.scalar, decimals);\n\t}\n\n\tasync getMarginPoolLastUpdateTimestamp(coinKey: string): Promise<number> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginPool.lastUpdateTimestamp(coinKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\treturn Number(bcs.U64.parse(bytes));\n\t}\n\n\tasync getMarginPoolSupplyCap(coinKey: string, decimals: number = 6): Promise<string> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginPool.supplyCap(coinKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst rawAmount = BigInt(bcs.U64.parse(bytes));\n\t\tconst coin = this.#ctx.config.getCoin(coinKey);\n\t\treturn formatTokenAmount(rawAmount, coin.scalar, decimals);\n\t}\n\n\tasync getMarginPoolMaxUtilizationRate(coinKey: string): Promise<number> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginPool.maxUtilizationRate(coinKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst rawRate = Number(bcs.U64.parse(bytes));\n\t\treturn rawRate / FLOAT_SCALAR;\n\t}\n\n\tasync getMarginPoolProtocolSpread(coinKey: string): Promise<number> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginPool.protocolSpread(coinKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst rawSpread = Number(bcs.U64.parse(bytes));\n\t\treturn rawSpread / FLOAT_SCALAR;\n\t}\n\n\tasync getMarginPoolMinBorrow(coinKey: string, decimals: number = 6): Promise<string> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginPool.minBorrow(coinKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst rawAmount = BigInt(bcs.U64.parse(bytes));\n\t\tconst coin = this.#ctx.config.getCoin(coinKey);\n\t\treturn formatTokenAmount(rawAmount, coin.scalar, decimals);\n\t}\n\n\tasync getMarginPoolInterestRate(coinKey: string): Promise<number> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginPool.interestRate(coinKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst rawRate = Number(bcs.U64.parse(bytes));\n\t\treturn rawRate / FLOAT_SCALAR;\n\t}\n\n\tasync getUserSupplyShares(\n\t\tcoinKey: string,\n\t\tsupplierCapId: string,\n\t\tdecimals: number = 6,\n\t): Promise<string> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginPool.userSupplyShares(coinKey, supplierCapId));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst rawShares = BigInt(bcs.U64.parse(bytes));\n\t\tconst coin = this.#ctx.config.getCoin(coinKey);\n\t\treturn formatTokenAmount(rawShares, coin.scalar, decimals);\n\t}\n\n\tasync getUserSupplyAmount(\n\t\tcoinKey: string,\n\t\tsupplierCapId: string,\n\t\tdecimals: number = 6,\n\t): Promise<string> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginPool.userSupplyAmount(coinKey, supplierCapId));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst rawAmount = BigInt(bcs.U64.parse(bytes));\n\t\tconst coin = this.#ctx.config.getCoin(coinKey);\n\t\treturn formatTokenAmount(rawAmount, coin.scalar, decimals);\n\t}\n}\n"],"mappings":";;;;;;AAUA,IAAa,oBAAb,MAA+B;CAC9B;CAEA,YAAY,KAAmB;AAC9B,QAAKA,MAAO;;CAGb,MAAM,gBAAgB,SAAkC;EACvD,MAAM,KAAK,IAAI,aAAa;AAC5B,KAAG,UAAU,MAAKA,IAAK,QAAQ;AAC/B,KAAG,IAAI,MAAKA,IAAK,WAAW,MAAM,QAAQ,CAAC;EAO3C,MAAM,SALM,MAAM,MAAKA,IAAK,OAA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AAa;GACb,SAAS;IAAE,gBAAgB;IAAM,SAAS;IAAM;GAChD,CAAC,EAEgB,eAAgB,GAAG,aAAa,GAAG;AAGrD,SAAO,kBAFW,OAAO,IAAI,IAAI,MAAM,MAAM,CAAC,EACjC,MAAKA,IAAK,OAAO,QAAQ,QAAQ,CACL,QAAQ,SAAS;;CAG3D,MAAM,oBACL,SACA,eACA,WAAmB,GACD;EAClB,MAAM,KAAK,IAAI,aAAa;AAC5B,KAAG,UAAU,MAAKA,IAAK,QAAQ;AAC/B,KAAG,IAAI,MAAKA,IAAK,WAAW,iBAAiB,SAAS,cAAc,CAAC;EAOrE,MAAM,SALM,MAAM,MAAKA,IAAK,OAAO,KAAK,oBAAoB;GAC3D,aAAa;GACb,SAAS;IAAE,gBAAgB;IAAM,SAAS;IAAM;GAChD,CAAC,EAEgB,eAAgB,GAAG,aAAa,GAAG;AAGrD,SAAO,kBAFW,OAAO,IAAI,IAAI,MAAM,MAAM,CAAC,EACjC,MAAKA,IAAK,OAAO,QAAQ,QAAQ,CACL,QAAQ,SAAS"}
|
|
@@ -13,6 +13,7 @@ var OrderQueries = class {
|
|
|
13
13
|
}
|
|
14
14
|
async accountOpenOrders(poolKey, managerKey) {
|
|
15
15
|
const tx = new Transaction();
|
|
16
|
+
tx.setSender(this.#ctx.address);
|
|
16
17
|
tx.add(this.#ctx.deepBook.accountOpenOrders(poolKey, managerKey));
|
|
17
18
|
const order_ids = (await this.#ctx.client.core.simulateTransaction({
|
|
18
19
|
transaction: tx,
|
|
@@ -25,6 +26,7 @@ var OrderQueries = class {
|
|
|
25
26
|
}
|
|
26
27
|
async getOrder(poolKey, orderId) {
|
|
27
28
|
const tx = new Transaction();
|
|
29
|
+
tx.setSender(this.#ctx.address);
|
|
28
30
|
tx.add(this.#ctx.deepBook.getOrder(poolKey, orderId));
|
|
29
31
|
const res = await this.#ctx.client.core.simulateTransaction({
|
|
30
32
|
transaction: tx,
|
|
@@ -42,6 +44,7 @@ var OrderQueries = class {
|
|
|
42
44
|
}
|
|
43
45
|
async getOrderNormalized(poolKey, orderId) {
|
|
44
46
|
const tx = new Transaction();
|
|
47
|
+
tx.setSender(this.#ctx.address);
|
|
45
48
|
tx.add(this.#ctx.deepBook.getOrder(poolKey, orderId));
|
|
46
49
|
const res = await this.#ctx.client.core.simulateTransaction({
|
|
47
50
|
transaction: tx,
|
|
@@ -76,6 +79,7 @@ var OrderQueries = class {
|
|
|
76
79
|
}
|
|
77
80
|
async getOrders(poolKey, orderIds) {
|
|
78
81
|
const tx = new Transaction();
|
|
82
|
+
tx.setSender(this.#ctx.address);
|
|
79
83
|
tx.add(this.#ctx.deepBook.getOrders(poolKey, orderIds));
|
|
80
84
|
const res = await this.#ctx.client.core.simulateTransaction({
|
|
81
85
|
transaction: tx,
|
|
@@ -93,6 +97,7 @@ var OrderQueries = class {
|
|
|
93
97
|
}
|
|
94
98
|
async getLevel2Range(poolKey, priceLow, priceHigh, isBid) {
|
|
95
99
|
const tx = new Transaction();
|
|
100
|
+
tx.setSender(this.#ctx.address);
|
|
96
101
|
const pool = this.#ctx.config.getPool(poolKey);
|
|
97
102
|
const baseCoin = this.#ctx.config.getCoin(pool.baseCoin);
|
|
98
103
|
const quoteCoin = this.#ctx.config.getCoin(pool.quoteCoin);
|
|
@@ -115,6 +120,7 @@ var OrderQueries = class {
|
|
|
115
120
|
}
|
|
116
121
|
async getLevel2TicksFromMid(poolKey, ticks) {
|
|
117
122
|
const tx = new Transaction();
|
|
123
|
+
tx.setSender(this.#ctx.address);
|
|
118
124
|
const pool = this.#ctx.config.getPool(poolKey);
|
|
119
125
|
const baseCoin = this.#ctx.config.getCoin(pool.baseCoin);
|
|
120
126
|
const quoteCoin = this.#ctx.config.getCoin(pool.quoteCoin);
|
|
@@ -143,6 +149,7 @@ var OrderQueries = class {
|
|
|
143
149
|
}
|
|
144
150
|
async getAccountOrderDetails(poolKey, managerKey) {
|
|
145
151
|
const tx = new Transaction();
|
|
152
|
+
tx.setSender(this.#ctx.address);
|
|
146
153
|
tx.add(this.#ctx.deepBook.getAccountOrderDetails(poolKey, managerKey));
|
|
147
154
|
const res = await this.#ctx.client.core.simulateTransaction({
|
|
148
155
|
transaction: tx,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orderQueries.mjs","names":["#ctx"],"sources":["../../src/queries/orderQueries.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@mysten/sui/bcs';\nimport { Transaction } from '@mysten/sui/transactions';\n\nimport { Order } from '../types/bcs.js';\nimport { VecSet } from '../types/bcs.js';\nimport type { Level2Range, Level2TicksFromMid } from '../types/index.js';\nimport { DEEP_SCALAR, FLOAT_SCALAR } from '../utils/config.js';\nimport type { QueryContext } from './context.js';\n\nexport class OrderQueries {\n\t#ctx: QueryContext;\n\n\tconstructor(ctx: QueryContext) {\n\t\tthis.#ctx = ctx;\n\t}\n\n\tasync accountOpenOrders(poolKey: string, managerKey: string): Promise<string[]> {\n\t\tconst tx = new Transaction();\n\n\t\ttx.add(this.#ctx.deepBook.accountOpenOrders(poolKey, managerKey));\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst order_ids = res.commandResults![0].returnValues[0].bcs;\n\n\t\treturn VecSet(bcs.u128()).parse(new Uint8Array(order_ids)).contents;\n\t}\n\n\tasync getOrder(poolKey: string, orderId: string): Promise<ReturnType<typeof Order.parse> | null> {\n\t\tconst tx = new Transaction();\n\n\t\ttx.add(this.#ctx.deepBook.getOrder(poolKey, orderId));\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\ttry {\n\t\t\tconst orderInformation = res.commandResults![0].returnValues[0].bcs;\n\t\t\treturn Order.parse(new Uint8Array(orderInformation));\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tasync getOrderNormalized(poolKey: string, orderId: string) {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.deepBook.getOrder(poolKey, orderId));\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\ttry {\n\t\t\tconst orderInformation = res.commandResults![0].returnValues[0].bcs;\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.#ctx.config.getCoin(this.#ctx.config.getPool(poolKey).baseCoin);\n\t\t\tconst quoteCoin = this.#ctx.config.getCoin(this.#ctx.config.getPool(poolKey).quoteCoin);\n\n\t\t\tconst encodedOrderId = BigInt(orderInfo.order_id);\n\t\t\tconst isBid = encodedOrderId >> 127n === 0n;\n\t\t\tconst rawPrice = Number((encodedOrderId >> 64n) & ((1n << 63n) - 1n));\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 {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tasync getOrders(\n\t\tpoolKey: string,\n\t\torderIds: string[],\n\t): Promise<ReturnType<typeof Order.parse>[] | null> {\n\t\tconst tx = new Transaction();\n\n\t\ttx.add(this.#ctx.deepBook.getOrders(poolKey, orderIds));\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\ttry {\n\t\t\tconst orderInformation = res.commandResults![0].returnValues[0].bcs;\n\t\t\treturn bcs.vector(Order).parse(new Uint8Array(orderInformation));\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tasync getLevel2Range(\n\t\tpoolKey: string,\n\t\tpriceLow: number | bigint,\n\t\tpriceHigh: number | bigint,\n\t\tisBid: boolean,\n\t): Promise<Level2Range> {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#ctx.config.getPool(poolKey);\n\t\tconst baseCoin = this.#ctx.config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#ctx.config.getCoin(pool.quoteCoin);\n\n\t\ttx.add(this.#ctx.deepBook.getLevel2Range(poolKey, priceLow, priceHigh, isBid));\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst prices = res.commandResults![0].returnValues[0].bcs;\n\t\tconst parsed_prices = bcs.vector(bcs.u64()).parse(new Uint8Array(prices));\n\t\tconst quantities = res.commandResults![0].returnValues[1].bcs;\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\tasync getLevel2TicksFromMid(poolKey: string, ticks: number): Promise<Level2TicksFromMid> {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#ctx.config.getPool(poolKey);\n\t\tconst baseCoin = this.#ctx.config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#ctx.config.getCoin(pool.quoteCoin);\n\n\t\ttx.add(this.#ctx.deepBook.getLevel2TicksFromMid(poolKey, ticks));\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bid_prices = res.commandResults![0].returnValues[0].bcs;\n\t\tconst bid_parsed_prices = bcs.vector(bcs.u64()).parse(new Uint8Array(bid_prices));\n\t\tconst bid_quantities = res.commandResults![0].returnValues[1].bcs;\n\t\tconst bid_parsed_quantities = bcs.vector(bcs.u64()).parse(new Uint8Array(bid_quantities));\n\n\t\tconst ask_prices = res.commandResults![0].returnValues[2].bcs;\n\t\tconst ask_parsed_prices = bcs.vector(bcs.u64()).parse(new Uint8Array(ask_prices));\n\t\tconst ask_quantities = res.commandResults![0].returnValues[3].bcs;\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\tasync getAccountOrderDetails(\n\t\tpoolKey: string,\n\t\tmanagerKey: string,\n\t): Promise<ReturnType<typeof Order.parse>[] | []> {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.#ctx.deepBook.getAccountOrderDetails(poolKey, managerKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\ttry {\n\t\t\tconst orderInformation = res.commandResults![0].returnValues[0].bcs;\n\t\t\treturn bcs.vector(Order).parse(new Uint8Array(orderInformation));\n\t\t} catch {\n\t\t\treturn [];\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;AAYA,IAAa,eAAb,MAA0B;CACzB;CAEA,YAAY,KAAmB;AAC9B,QAAKA,MAAO;;CAGb,MAAM,kBAAkB,SAAiB,YAAuC;EAC/E,MAAM,KAAK,IAAI,aAAa;AAE5B,KAAG,IAAI,MAAKA,IAAK,SAAS,kBAAkB,SAAS,WAAW,CAAC;EAMjE,MAAM,aALM,MAAM,MAAKA,IAAK,OAAO,KAAK,oBAAoB;GAC3D,aAAa;GACb,SAAS;IAAE,gBAAgB;IAAM,SAAS;IAAM;GAChD,CAAC,EAEoB,eAAgB,GAAG,aAAa,GAAG;AAEzD,SAAO,OAAO,IAAI,MAAM,CAAC,CAAC,MAAM,IAAI,WAAW,UAAU,CAAC,CAAC;;CAG5D,MAAM,SAAS,SAAiB,SAAiE;EAChG,MAAM,KAAK,IAAI,aAAa;AAE5B,KAAG,IAAI,MAAKA,IAAK,SAAS,SAAS,SAAS,QAAQ,CAAC;EACrD,MAAM,MAAM,MAAM,MAAKA,IAAK,OAAO,KAAK,oBAAoB;GAC3D,aAAa;GACb,SAAS;IAAE,gBAAgB;IAAM,SAAS;IAAM;GAChD,CAAC;AAEF,MAAI;GACH,MAAM,mBAAmB,IAAI,eAAgB,GAAG,aAAa,GAAG;AAChE,UAAO,MAAM,MAAM,IAAI,WAAW,iBAAiB,CAAC;UAC7C;AACP,UAAO;;;CAIT,MAA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Ae,UAAU,SAAU,SAAS,QAAQ,QAAQ,EAAE,CAAC,CACxF;GACD,gBAAgB,sBAAsB,KAAK,aAC1C,QAAQ,OAAO,SAAS,GAAG,SAAS,QAAQ,QAAQ,EAAE,CAAC,CACvD;GACD;;CAGF,MAAM,uBACL,SACA,YACiD;EACjD,MAAM,KAAK,IAAI,aAAa;AAC5B,KAAG,IAAI,MAAKA,IAAK,SAAS,uBAAuB,SAAS,WAAW,CAAC;EAEtE,MAAM,MAAM,MAAM,MAAKA,IAAK,OAAO,KAAK,oBAAoB;GAC3D,aAAa;GACb,SAAS;IAAE,gBAAgB;IAAM,SAAS;IAAM;GAChD,CAAC;AAEF,MAAI;GACH,MAAM,mBAAmB,IAAI,eAAgB,GAAG,aAAa,GAAG;AAChE,UAAO,IAAI,OAAO,MAAM,CAAC,MAAM,IAAI,WAAW,iBAAiB,CAAC;UACzD;AACP,UAAO,EAAE"}
|
|
1
|
+
{"version":3,"file":"orderQueries.mjs","names":["#ctx"],"sources":["../../src/queries/orderQueries.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@mysten/sui/bcs';\nimport { Transaction } from '@mysten/sui/transactions';\n\nimport { Order } from '../types/bcs.js';\nimport { VecSet } from '../types/bcs.js';\nimport type { Level2Range, Level2TicksFromMid } from '../types/index.js';\nimport { DEEP_SCALAR, FLOAT_SCALAR } from '../utils/config.js';\nimport type { QueryContext } from './context.js';\n\nexport class OrderQueries {\n\t#ctx: QueryContext;\n\n\tconstructor(ctx: QueryContext) {\n\t\tthis.#ctx = ctx;\n\t}\n\n\tasync accountOpenOrders(poolKey: string, managerKey: string): Promise<string[]> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\n\t\ttx.add(this.#ctx.deepBook.accountOpenOrders(poolKey, managerKey));\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst order_ids = res.commandResults![0].returnValues[0].bcs;\n\n\t\treturn VecSet(bcs.u128()).parse(new Uint8Array(order_ids)).contents;\n\t}\n\n\tasync getOrder(poolKey: string, orderId: string): Promise<ReturnType<typeof Order.parse> | null> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\n\t\ttx.add(this.#ctx.deepBook.getOrder(poolKey, orderId));\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\ttry {\n\t\t\tconst orderInformation = res.commandResults![0].returnValues[0].bcs;\n\t\t\treturn Order.parse(new Uint8Array(orderInformation));\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tasync getOrderNormalized(poolKey: string, orderId: string) {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.deepBook.getOrder(poolKey, orderId));\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\ttry {\n\t\t\tconst orderInformation = res.commandResults![0].returnValues[0].bcs;\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.#ctx.config.getCoin(this.#ctx.config.getPool(poolKey).baseCoin);\n\t\t\tconst quoteCoin = this.#ctx.config.getCoin(this.#ctx.config.getPool(poolKey).quoteCoin);\n\n\t\t\tconst encodedOrderId = BigInt(orderInfo.order_id);\n\t\t\tconst isBid = encodedOrderId >> 127n === 0n;\n\t\t\tconst rawPrice = Number((encodedOrderId >> 64n) & ((1n << 63n) - 1n));\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 {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tasync getOrders(\n\t\tpoolKey: string,\n\t\torderIds: string[],\n\t): Promise<ReturnType<typeof Order.parse>[] | null> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\n\t\ttx.add(this.#ctx.deepBook.getOrders(poolKey, orderIds));\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\ttry {\n\t\t\tconst orderInformation = res.commandResults![0].returnValues[0].bcs;\n\t\t\treturn bcs.vector(Order).parse(new Uint8Array(orderInformation));\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tasync getLevel2Range(\n\t\tpoolKey: string,\n\t\tpriceLow: number | bigint,\n\t\tpriceHigh: number | bigint,\n\t\tisBid: boolean,\n\t): Promise<Level2Range> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\tconst pool = this.#ctx.config.getPool(poolKey);\n\t\tconst baseCoin = this.#ctx.config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#ctx.config.getCoin(pool.quoteCoin);\n\n\t\ttx.add(this.#ctx.deepBook.getLevel2Range(poolKey, priceLow, priceHigh, isBid));\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst prices = res.commandResults![0].returnValues[0].bcs;\n\t\tconst parsed_prices = bcs.vector(bcs.u64()).parse(new Uint8Array(prices));\n\t\tconst quantities = res.commandResults![0].returnValues[1].bcs;\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\tasync getLevel2TicksFromMid(poolKey: string, ticks: number): Promise<Level2TicksFromMid> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\tconst pool = this.#ctx.config.getPool(poolKey);\n\t\tconst baseCoin = this.#ctx.config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#ctx.config.getCoin(pool.quoteCoin);\n\n\t\ttx.add(this.#ctx.deepBook.getLevel2TicksFromMid(poolKey, ticks));\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bid_prices = res.commandResults![0].returnValues[0].bcs;\n\t\tconst bid_parsed_prices = bcs.vector(bcs.u64()).parse(new Uint8Array(bid_prices));\n\t\tconst bid_quantities = res.commandResults![0].returnValues[1].bcs;\n\t\tconst bid_parsed_quantities = bcs.vector(bcs.u64()).parse(new Uint8Array(bid_quantities));\n\n\t\tconst ask_prices = res.commandResults![0].returnValues[2].bcs;\n\t\tconst ask_parsed_prices = bcs.vector(bcs.u64()).parse(new Uint8Array(ask_prices));\n\t\tconst ask_quantities = res.commandResults![0].returnValues[3].bcs;\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\tasync getAccountOrderDetails(\n\t\tpoolKey: string,\n\t\tmanagerKey: string,\n\t): Promise<ReturnType<typeof Order.parse>[] | []> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.deepBook.getAccountOrderDetails(poolKey, managerKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\ttry {\n\t\t\tconst orderInformation = res.commandResults![0].returnValues[0].bcs;\n\t\t\treturn bcs.vector(Order).parse(new Uint8Array(orderInformation));\n\t\t} catch {\n\t\t\treturn [];\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;AAYA,IAAa,eAAb,MAA0B;CACzB;CAEA,YAAY,KAAmB;AAC9B,QAAKA,MAAO;;CAGb,MAAM,kBAAkB,SAAiB,YAAuC;EAC/E,MAAM,KAAK,IAAI,aAAa;AAC5B,KAAG,UAAU,MAAKA,IAAK,QAAQ;AAE/B,KAAG,IAAI,MAAKA,IAAK,SAAS,kBAAkB,SAAS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