@mysten/deepbook-v3 0.24.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/cjs/client.d.ts +24 -0
- package/dist/cjs/client.js +71 -0
- package/dist/cjs/client.js.map +2 -2
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/transactions/marginLiquidations.d.ts +61 -0
- package/dist/cjs/transactions/marginLiquidations.js +173 -0
- package/dist/cjs/transactions/marginLiquidations.js.map +7 -0
- package/dist/cjs/transactions/marginTPSL.d.ts +93 -0
- package/dist/cjs/transactions/marginTPSL.js +286 -0
- package/dist/cjs/transactions/marginTPSL.js.map +7 -0
- package/dist/cjs/types/index.d.ts +24 -0
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/cjs/utils/config.d.ts +1 -0
- package/dist/cjs/utils/config.js +2 -0
- package/dist/cjs/utils/config.js.map +2 -2
- package/dist/cjs/utils/constants.d.ts +3 -0
- package/dist/cjs/utils/constants.js +6 -4
- package/dist/cjs/utils/constants.js.map +2 -2
- package/dist/esm/client.d.ts +24 -0
- package/dist/esm/client.js +71 -0
- package/dist/esm/client.js.map +2 -2
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/transactions/marginLiquidations.d.ts +61 -0
- package/dist/esm/transactions/marginLiquidations.js +153 -0
- package/dist/esm/transactions/marginLiquidations.js.map +7 -0
- package/dist/esm/transactions/marginTPSL.d.ts +93 -0
- package/dist/esm/transactions/marginTPSL.js +266 -0
- package/dist/esm/transactions/marginTPSL.js.map +7 -0
- package/dist/esm/types/index.d.ts +24 -0
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/utils/config.d.ts +1 -0
- package/dist/esm/utils/config.js +2 -0
- package/dist/esm/utils/config.js.map +2 -2
- package/dist/esm/utils/constants.d.ts +3 -0
- package/dist/esm/utils/constants.js +6 -4
- package/dist/esm/utils/constants.js.map +2 -2
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/client.ts +86 -0
- package/src/index.ts +8 -0
- package/src/transactions/marginLiquidations.ts +175 -0
- package/src/transactions/marginTPSL.ts +296 -0
- package/src/types/index.ts +27 -0
- package/src/utils/config.ts +3 -0
- package/src/utils/constants.ts +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @mysten/deepbook-v3
|
|
2
2
|
|
|
3
|
+
## 0.26.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- ef523b8: Take Profit Stop Loss support
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 396fb3f: Bump margin package for testing
|
|
12
|
+
|
|
13
|
+
## 0.25.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- 74b9509: Liquidation Logic
|
|
18
|
+
|
|
3
19
|
## 0.24.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
package/dist/cjs/client.d.ts
CHANGED
|
@@ -12,7 +12,9 @@ import { MarginMaintainerContract } from './transactions/marginMaintainer.js';
|
|
|
12
12
|
import { MarginPoolContract } from './transactions/marginPool.js';
|
|
13
13
|
import { MarginManagerContract } from './transactions/marginManager.js';
|
|
14
14
|
import { MarginRegistryContract } from './transactions/marginRegistry.js';
|
|
15
|
+
import { MarginLiquidationsContract } from './transactions/marginLiquidations.js';
|
|
15
16
|
import { PoolProxyContract } from './transactions/poolProxy.js';
|
|
17
|
+
import { MarginTPSLContract } from './transactions/marginTPSL.js';
|
|
16
18
|
/**
|
|
17
19
|
* DeepBookClient class for managing DeepBook operations.
|
|
18
20
|
*/
|
|
@@ -29,7 +31,9 @@ export declare class DeepBookClient {
|
|
|
29
31
|
marginPool: MarginPoolContract;
|
|
30
32
|
marginManager: MarginManagerContract;
|
|
31
33
|
marginRegistry: MarginRegistryContract;
|
|
34
|
+
marginLiquidations: MarginLiquidationsContract;
|
|
32
35
|
poolProxy: PoolProxyContract;
|
|
36
|
+
marginTPSL: MarginTPSLContract;
|
|
33
37
|
/**
|
|
34
38
|
* @param {SuiClient} client SuiClient instance
|
|
35
39
|
* @param {string} address Address of the client
|
|
@@ -601,6 +605,26 @@ export declare class DeepBookClient {
|
|
|
601
605
|
* @returns {Promise<string>} The DEEP token balance
|
|
602
606
|
*/
|
|
603
607
|
getMarginManagerDeepBalance(marginManagerKey: string, decimals?: number): Promise<string>;
|
|
608
|
+
/**
|
|
609
|
+
* @description Get all conditional order IDs for a margin manager
|
|
610
|
+
* @param {string} marginManagerKey The key to identify the margin manager
|
|
611
|
+
* @returns {Promise<string[]>} Array of conditional order IDs
|
|
612
|
+
*/
|
|
613
|
+
getConditionalOrderIds(marginManagerKey: string): Promise<string[]>;
|
|
614
|
+
/**
|
|
615
|
+
* @description Get the lowest trigger price for trigger_above orders
|
|
616
|
+
* Returns MAX_U64 if there are no trigger_above orders
|
|
617
|
+
* @param {string} marginManagerKey The key to identify the margin manager
|
|
618
|
+
* @returns {Promise<bigint>} The lowest trigger above price
|
|
619
|
+
*/
|
|
620
|
+
getLowestTriggerAbovePrice(marginManagerKey: string): Promise<bigint>;
|
|
621
|
+
/**
|
|
622
|
+
* @description Get the highest trigger price for trigger_below orders
|
|
623
|
+
* Returns 0 if there are no trigger_below orders
|
|
624
|
+
* @param {string} marginManagerKey The key to identify the margin manager
|
|
625
|
+
* @returns {Promise<bigint>} The highest trigger below price
|
|
626
|
+
*/
|
|
627
|
+
getHighestTriggerBelowPrice(marginManagerKey: string): Promise<bigint>;
|
|
604
628
|
/**
|
|
605
629
|
* @description Check if a deepbook pool is enabled for margin trading
|
|
606
630
|
* @param {string} poolKey The key to identify the pool
|
package/dist/cjs/client.js
CHANGED
|
@@ -44,9 +44,11 @@ var import_marginMaintainer = require("./transactions/marginMaintainer.js");
|
|
|
44
44
|
var import_marginPool = require("./transactions/marginPool.js");
|
|
45
45
|
var import_marginManager = require("./transactions/marginManager.js");
|
|
46
46
|
var import_marginRegistry = require("./transactions/marginRegistry.js");
|
|
47
|
+
var import_marginLiquidations = require("./transactions/marginLiquidations.js");
|
|
47
48
|
var import_pyth = require("./pyth/pyth.js");
|
|
48
49
|
var import_pyth2 = require("./pyth/pyth.js");
|
|
49
50
|
var import_poolProxy = require("./transactions/poolProxy.js");
|
|
51
|
+
var import_marginTPSL = require("./transactions/marginTPSL.js");
|
|
50
52
|
var _config, _address, _DeepBookClient_instances, formatTokenAmount_fn;
|
|
51
53
|
class DeepBookClient {
|
|
52
54
|
/**
|
|
@@ -99,7 +101,9 @@ class DeepBookClient {
|
|
|
99
101
|
this.marginPool = new import_marginPool.MarginPoolContract(__privateGet(this, _config));
|
|
100
102
|
this.marginManager = new import_marginManager.MarginManagerContract(__privateGet(this, _config));
|
|
101
103
|
this.marginRegistry = new import_marginRegistry.MarginRegistryContract(__privateGet(this, _config));
|
|
104
|
+
this.marginLiquidations = new import_marginLiquidations.MarginLiquidationsContract(__privateGet(this, _config));
|
|
102
105
|
this.poolProxy = new import_poolProxy.PoolProxyContract(__privateGet(this, _config));
|
|
106
|
+
this.marginTPSL = new import_marginTPSL.MarginTPSLContract(__privateGet(this, _config));
|
|
103
107
|
}
|
|
104
108
|
/**
|
|
105
109
|
* @description Check the balance of a balance manager for a specific coin
|
|
@@ -1350,6 +1354,73 @@ class DeepBookClient {
|
|
|
1350
1354
|
const deepCoin = __privateGet(this, _config).getCoin("DEEP");
|
|
1351
1355
|
return __privateMethod(this, _DeepBookClient_instances, formatTokenAmount_fn).call(this, BigInt(import_bcs.bcs.U64.parse(new Uint8Array(bytes))), deepCoin.scalar, decimals);
|
|
1352
1356
|
}
|
|
1357
|
+
// === Margin TPSL (Take Profit / Stop Loss) Read-Only Functions ===
|
|
1358
|
+
/**
|
|
1359
|
+
* @description Get all conditional order IDs for a margin manager
|
|
1360
|
+
* @param {string} marginManagerKey The key to identify the margin manager
|
|
1361
|
+
* @returns {Promise<string[]>} Array of conditional order IDs
|
|
1362
|
+
*/
|
|
1363
|
+
async getConditionalOrderIds(marginManagerKey) {
|
|
1364
|
+
const manager = __privateGet(this, _config).getMarginManager(marginManagerKey);
|
|
1365
|
+
const tx = new import_transactions.Transaction();
|
|
1366
|
+
tx.add(this.marginTPSL.conditionalOrderIds(manager.poolKey, manager.address));
|
|
1367
|
+
const res = await this.client.devInspectTransactionBlock({
|
|
1368
|
+
sender: (0, import_utils.normalizeSuiAddress)(__privateGet(this, _address)),
|
|
1369
|
+
transactionBlock: tx
|
|
1370
|
+
});
|
|
1371
|
+
if (!res.results || !res.results[0] || !res.results[0].returnValues) {
|
|
1372
|
+
throw new Error(
|
|
1373
|
+
`Failed to get conditional order IDs: ${res.effects?.status?.error || "Unknown error"}`
|
|
1374
|
+
);
|
|
1375
|
+
}
|
|
1376
|
+
const bytes = res.results[0].returnValues[0][0];
|
|
1377
|
+
const orderIds = import_bcs.bcs.vector(import_bcs.bcs.u64()).parse(new Uint8Array(bytes));
|
|
1378
|
+
return orderIds.map((id) => id.toString());
|
|
1379
|
+
}
|
|
1380
|
+
/**
|
|
1381
|
+
* @description Get the lowest trigger price for trigger_above orders
|
|
1382
|
+
* Returns MAX_U64 if there are no trigger_above orders
|
|
1383
|
+
* @param {string} marginManagerKey The key to identify the margin manager
|
|
1384
|
+
* @returns {Promise<bigint>} The lowest trigger above price
|
|
1385
|
+
*/
|
|
1386
|
+
async getLowestTriggerAbovePrice(marginManagerKey) {
|
|
1387
|
+
const manager = __privateGet(this, _config).getMarginManager(marginManagerKey);
|
|
1388
|
+
const tx = new import_transactions.Transaction();
|
|
1389
|
+
tx.add(this.marginTPSL.lowestTriggerAbovePrice(manager.poolKey, manager.address));
|
|
1390
|
+
const res = await this.client.devInspectTransactionBlock({
|
|
1391
|
+
sender: (0, import_utils.normalizeSuiAddress)(__privateGet(this, _address)),
|
|
1392
|
+
transactionBlock: tx
|
|
1393
|
+
});
|
|
1394
|
+
if (!res.results || !res.results[0] || !res.results[0].returnValues) {
|
|
1395
|
+
throw new Error(
|
|
1396
|
+
`Failed to get lowest trigger above price: ${res.effects?.status?.error || "Unknown error"}`
|
|
1397
|
+
);
|
|
1398
|
+
}
|
|
1399
|
+
const bytes = res.results[0].returnValues[0][0];
|
|
1400
|
+
return BigInt(import_bcs.bcs.U64.parse(new Uint8Array(bytes)));
|
|
1401
|
+
}
|
|
1402
|
+
/**
|
|
1403
|
+
* @description Get the highest trigger price for trigger_below orders
|
|
1404
|
+
* Returns 0 if there are no trigger_below orders
|
|
1405
|
+
* @param {string} marginManagerKey The key to identify the margin manager
|
|
1406
|
+
* @returns {Promise<bigint>} The highest trigger below price
|
|
1407
|
+
*/
|
|
1408
|
+
async getHighestTriggerBelowPrice(marginManagerKey) {
|
|
1409
|
+
const manager = __privateGet(this, _config).getMarginManager(marginManagerKey);
|
|
1410
|
+
const tx = new import_transactions.Transaction();
|
|
1411
|
+
tx.add(this.marginTPSL.highestTriggerBelowPrice(manager.poolKey, manager.address));
|
|
1412
|
+
const res = await this.client.devInspectTransactionBlock({
|
|
1413
|
+
sender: (0, import_utils.normalizeSuiAddress)(__privateGet(this, _address)),
|
|
1414
|
+
transactionBlock: tx
|
|
1415
|
+
});
|
|
1416
|
+
if (!res.results || !res.results[0] || !res.results[0].returnValues) {
|
|
1417
|
+
throw new Error(
|
|
1418
|
+
`Failed to get highest trigger below price: ${res.effects?.status?.error || "Unknown error"}`
|
|
1419
|
+
);
|
|
1420
|
+
}
|
|
1421
|
+
const bytes = res.results[0].returnValues[0][0];
|
|
1422
|
+
return BigInt(import_bcs.bcs.U64.parse(new Uint8Array(bytes)));
|
|
1423
|
+
}
|
|
1353
1424
|
// === Margin Registry Functions ===
|
|
1354
1425
|
/**
|
|
1355
1426
|
* @description Check if a deepbook pool is enabled for margin trading
|