@mysten/deepbook-v3 0.25.0 → 0.26.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 +16 -0
- package/dist/cjs/client.d.ts +22 -0
- package/dist/cjs/client.js +69 -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/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/constants.js +6 -1
- package/dist/cjs/utils/constants.js.map +2 -2
- package/dist/esm/client.d.ts +22 -0
- package/dist/esm/client.js +69 -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/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/constants.js +6 -1
- 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 +3 -3
- package/src/client.ts +83 -0
- package/src/index.ts +8 -0
- package/src/transactions/marginTPSL.ts +296 -0
- package/src/types/index.ts +27 -0
- package/src/utils/constants.ts +6 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @mysten/deepbook-v3
|
|
2
2
|
|
|
3
|
+
## 0.26.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6b8f03d: LZWBTC coin
|
|
8
|
+
|
|
9
|
+
## 0.26.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- ef523b8: Take Profit Stop Loss support
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 396fb3f: Bump margin package for testing
|
|
18
|
+
|
|
3
19
|
## 0.25.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
package/dist/cjs/client.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { MarginManagerContract } from './transactions/marginManager.js';
|
|
|
14
14
|
import { MarginRegistryContract } from './transactions/marginRegistry.js';
|
|
15
15
|
import { MarginLiquidationsContract } from './transactions/marginLiquidations.js';
|
|
16
16
|
import { PoolProxyContract } from './transactions/poolProxy.js';
|
|
17
|
+
import { MarginTPSLContract } from './transactions/marginTPSL.js';
|
|
17
18
|
/**
|
|
18
19
|
* DeepBookClient class for managing DeepBook operations.
|
|
19
20
|
*/
|
|
@@ -32,6 +33,7 @@ export declare class DeepBookClient {
|
|
|
32
33
|
marginRegistry: MarginRegistryContract;
|
|
33
34
|
marginLiquidations: MarginLiquidationsContract;
|
|
34
35
|
poolProxy: PoolProxyContract;
|
|
36
|
+
marginTPSL: MarginTPSLContract;
|
|
35
37
|
/**
|
|
36
38
|
* @param {SuiClient} client SuiClient instance
|
|
37
39
|
* @param {string} address Address of the client
|
|
@@ -603,6 +605,26 @@ export declare class DeepBookClient {
|
|
|
603
605
|
* @returns {Promise<string>} The DEEP token balance
|
|
604
606
|
*/
|
|
605
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>;
|
|
606
628
|
/**
|
|
607
629
|
* @description Check if a deepbook pool is enabled for margin trading
|
|
608
630
|
* @param {string} poolKey The key to identify the pool
|
package/dist/cjs/client.js
CHANGED
|
@@ -48,6 +48,7 @@ var import_marginLiquidations = require("./transactions/marginLiquidations.js");
|
|
|
48
48
|
var import_pyth = require("./pyth/pyth.js");
|
|
49
49
|
var import_pyth2 = require("./pyth/pyth.js");
|
|
50
50
|
var import_poolProxy = require("./transactions/poolProxy.js");
|
|
51
|
+
var import_marginTPSL = require("./transactions/marginTPSL.js");
|
|
51
52
|
var _config, _address, _DeepBookClient_instances, formatTokenAmount_fn;
|
|
52
53
|
class DeepBookClient {
|
|
53
54
|
/**
|
|
@@ -102,6 +103,7 @@ class DeepBookClient {
|
|
|
102
103
|
this.marginRegistry = new import_marginRegistry.MarginRegistryContract(__privateGet(this, _config));
|
|
103
104
|
this.marginLiquidations = new import_marginLiquidations.MarginLiquidationsContract(__privateGet(this, _config));
|
|
104
105
|
this.poolProxy = new import_poolProxy.PoolProxyContract(__privateGet(this, _config));
|
|
106
|
+
this.marginTPSL = new import_marginTPSL.MarginTPSLContract(__privateGet(this, _config));
|
|
105
107
|
}
|
|
106
108
|
/**
|
|
107
109
|
* @description Check the balance of a balance manager for a specific coin
|
|
@@ -1352,6 +1354,73 @@ class DeepBookClient {
|
|
|
1352
1354
|
const deepCoin = __privateGet(this, _config).getCoin("DEEP");
|
|
1353
1355
|
return __privateMethod(this, _DeepBookClient_instances, formatTokenAmount_fn).call(this, BigInt(import_bcs.bcs.U64.parse(new Uint8Array(bytes))), deepCoin.scalar, decimals);
|
|
1354
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
|
+
}
|
|
1355
1424
|
// === Margin Registry Functions ===
|
|
1356
1425
|
/**
|
|
1357
1426
|
* @description Check if a deepbook pool is enabled for margin trading
|