@mysten/deepbook-v3 1.3.6 → 1.4.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 +49 -0
- package/dist/contracts/deepbook/account.d.mts +18 -18
- package/dist/contracts/deepbook/account.d.mts.map +1 -1
- package/dist/contracts/deepbook/balances.d.mts +4 -4
- package/dist/contracts/deepbook/deep_price.d.mts +3 -3
- package/dist/contracts/deepbook/deep_price.d.mts.map +1 -1
- package/dist/contracts/deepbook/order.d.mts +12 -12
- package/dist/transactions/deepbookAdmin.d.mts +29 -0
- package/dist/transactions/deepbookAdmin.d.mts.map +1 -1
- package/dist/transactions/deepbookAdmin.mjs +34 -2
- package/dist/transactions/deepbookAdmin.mjs.map +1 -1
- package/dist/transactions/marginAdmin.d.mts +38 -7
- package/dist/transactions/marginAdmin.d.mts.map +1 -1
- package/dist/transactions/marginAdmin.mjs +48 -0
- package/dist/transactions/marginAdmin.mjs.map +1 -1
- package/dist/transactions/marginLiquidations.d.mts +3 -3
- package/dist/transactions/marginMaintainer.d.mts +5 -5
- package/dist/transactions/marginMaintainer.mjs +4 -4
- package/dist/transactions/marginMaintainer.mjs.map +1 -1
- package/dist/transactions/marginManager.d.mts +116 -23
- package/dist/transactions/marginManager.d.mts.map +1 -1
- package/dist/transactions/marginManager.mjs +133 -1
- package/dist/transactions/marginManager.mjs.map +1 -1
- package/dist/transactions/marginPool.d.mts +18 -18
- package/dist/transactions/marginRegistry.d.mts +15 -15
- package/dist/transactions/marginRegistry.d.mts.map +1 -1
- package/dist/transactions/marginTPSL.d.mts +14 -11
- package/dist/transactions/marginTPSL.d.mts.map +1 -1
- package/dist/transactions/marginTPSL.mjs +5 -1
- package/dist/transactions/marginTPSL.mjs.map +1 -1
- package/dist/transactions/poolProxy.d.mts +19 -9
- package/dist/transactions/poolProxy.d.mts.map +1 -1
- package/dist/transactions/poolProxy.mjs +31 -21
- package/dist/transactions/poolProxy.mjs.map +1 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/utils/config.d.mts +1 -0
- package/dist/utils/config.d.mts.map +1 -1
- package/dist/utils/config.mjs +3 -0
- package/dist/utils/config.mjs.map +1 -1
- package/dist/utils/constants.d.mts +3 -0
- package/dist/utils/constants.d.mts.map +1 -1
- package/dist/utils/constants.mjs +5 -3
- package/dist/utils/constants.mjs.map +1 -1
- package/package.json +2 -2
- package/src/transactions/deepbookAdmin.ts +64 -2
- package/src/transactions/marginAdmin.ts +79 -0
- package/src/transactions/marginMaintainer.ts +4 -4
- package/src/transactions/marginManager.ts +244 -1
- package/src/transactions/marginTPSL.ts +10 -3
- package/src/transactions/poolProxy.ts +45 -21
- package/src/types/index.ts +1 -1
- package/src/utils/config.ts +4 -0
- package/src/utils/constants.ts +6 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DeepBookConfig } from "../utils/config.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _mysten_sui_transactions102 from "@mysten/sui/transactions";
|
|
3
3
|
import { Transaction } from "@mysten/sui/transactions";
|
|
4
4
|
|
|
5
5
|
//#region src/transactions/marginRegistry.d.ts
|
|
@@ -17,83 +17,83 @@ declare class MarginRegistryContract {
|
|
|
17
17
|
* @param {string} poolKey The key to identify the pool
|
|
18
18
|
* @returns A function that takes a Transaction object
|
|
19
19
|
*/
|
|
20
|
-
poolEnabled: (poolKey: string) => (tx: Transaction) =>
|
|
20
|
+
poolEnabled: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions102.TransactionResult;
|
|
21
21
|
/**
|
|
22
22
|
* @description Get the margin pool ID for a given asset
|
|
23
23
|
* @param {string} coinKey The key to identify the coin
|
|
24
24
|
* @returns A function that takes a Transaction object
|
|
25
25
|
*/
|
|
26
|
-
getMarginPoolId: (coinKey: string) => (tx: Transaction) =>
|
|
26
|
+
getMarginPoolId: (coinKey: string) => (tx: Transaction) => _mysten_sui_transactions102.TransactionResult;
|
|
27
27
|
/**
|
|
28
28
|
* @description Get the margin pool IDs (base and quote) for a deepbook pool
|
|
29
29
|
* @param {string} poolKey The key to identify the pool
|
|
30
30
|
* @returns A function that takes a Transaction object
|
|
31
31
|
*/
|
|
32
|
-
getDeepbookPoolMarginPoolIds: (poolKey: string) => (tx: Transaction) =>
|
|
32
|
+
getDeepbookPoolMarginPoolIds: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions102.TransactionResult;
|
|
33
33
|
/**
|
|
34
34
|
* @description Get the margin manager IDs for a given owner
|
|
35
35
|
* @param {string} owner The owner address
|
|
36
36
|
* @returns A function that takes a Transaction object
|
|
37
37
|
*/
|
|
38
|
-
getMarginManagerIds: (owner: string) => (tx: Transaction) =>
|
|
38
|
+
getMarginManagerIds: (owner: string) => (tx: Transaction) => _mysten_sui_transactions102.TransactionResult;
|
|
39
39
|
/**
|
|
40
40
|
* @description Get the base margin pool ID for a deepbook pool
|
|
41
41
|
* @param {string} poolKey The key to identify the pool
|
|
42
42
|
* @returns A function that takes a Transaction object
|
|
43
43
|
*/
|
|
44
|
-
baseMarginPoolId: (poolKey: string) => (tx: Transaction) =>
|
|
44
|
+
baseMarginPoolId: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions102.TransactionResult;
|
|
45
45
|
/**
|
|
46
46
|
* @description Get the quote margin pool ID for a deepbook pool
|
|
47
47
|
* @param {string} poolKey The key to identify the pool
|
|
48
48
|
* @returns A function that takes a Transaction object
|
|
49
49
|
*/
|
|
50
|
-
quoteMarginPoolId: (poolKey: string) => (tx: Transaction) =>
|
|
50
|
+
quoteMarginPoolId: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions102.TransactionResult;
|
|
51
51
|
/**
|
|
52
52
|
* @description Get the minimum withdraw risk ratio for a deepbook pool
|
|
53
53
|
* @param {string} poolKey The key to identify the pool
|
|
54
54
|
* @returns A function that takes a Transaction object
|
|
55
55
|
*/
|
|
56
|
-
minWithdrawRiskRatio: (poolKey: string) => (tx: Transaction) =>
|
|
56
|
+
minWithdrawRiskRatio: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions102.TransactionResult;
|
|
57
57
|
/**
|
|
58
58
|
* @description Get the minimum borrow risk ratio for a deepbook pool
|
|
59
59
|
* @param {string} poolKey The key to identify the pool
|
|
60
60
|
* @returns A function that takes a Transaction object
|
|
61
61
|
*/
|
|
62
|
-
minBorrowRiskRatio: (poolKey: string) => (tx: Transaction) =>
|
|
62
|
+
minBorrowRiskRatio: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions102.TransactionResult;
|
|
63
63
|
/**
|
|
64
64
|
* @description Get the liquidation risk ratio for a deepbook pool
|
|
65
65
|
* @param {string} poolKey The key to identify the pool
|
|
66
66
|
* @returns A function that takes a Transaction object
|
|
67
67
|
*/
|
|
68
|
-
liquidationRiskRatio: (poolKey: string) => (tx: Transaction) =>
|
|
68
|
+
liquidationRiskRatio: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions102.TransactionResult;
|
|
69
69
|
/**
|
|
70
70
|
* @description Get the target liquidation risk ratio for a deepbook pool
|
|
71
71
|
* @param {string} poolKey The key to identify the pool
|
|
72
72
|
* @returns A function that takes a Transaction object
|
|
73
73
|
*/
|
|
74
|
-
targetLiquidationRiskRatio: (poolKey: string) => (tx: Transaction) =>
|
|
74
|
+
targetLiquidationRiskRatio: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions102.TransactionResult;
|
|
75
75
|
/**
|
|
76
76
|
* @description Get the user liquidation reward for a deepbook pool
|
|
77
77
|
* @param {string} poolKey The key to identify the pool
|
|
78
78
|
* @returns A function that takes a Transaction object
|
|
79
79
|
*/
|
|
80
|
-
userLiquidationReward: (poolKey: string) => (tx: Transaction) =>
|
|
80
|
+
userLiquidationReward: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions102.TransactionResult;
|
|
81
81
|
/**
|
|
82
82
|
* @description Get the pool liquidation reward for a deepbook pool
|
|
83
83
|
* @param {string} poolKey The key to identify the pool
|
|
84
84
|
* @returns A function that takes a Transaction object
|
|
85
85
|
*/
|
|
86
|
-
poolLiquidationReward: (poolKey: string) => (tx: Transaction) =>
|
|
86
|
+
poolLiquidationReward: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions102.TransactionResult;
|
|
87
87
|
/**
|
|
88
88
|
* @description Get all allowed maintainer cap IDs
|
|
89
89
|
* @returns A function that takes a Transaction object
|
|
90
90
|
*/
|
|
91
|
-
allowedMaintainers: () => (tx: Transaction) =>
|
|
91
|
+
allowedMaintainers: () => (tx: Transaction) => _mysten_sui_transactions102.TransactionResult;
|
|
92
92
|
/**
|
|
93
93
|
* @description Get all allowed pause cap IDs
|
|
94
94
|
* @returns A function that takes a Transaction object
|
|
95
95
|
*/
|
|
96
|
-
allowedPauseCaps: () => (tx: Transaction) =>
|
|
96
|
+
allowedPauseCaps: () => (tx: Transaction) => _mysten_sui_transactions102.TransactionResult;
|
|
97
97
|
}
|
|
98
98
|
//#endregion
|
|
99
99
|
export { MarginRegistryContract };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marginRegistry.d.mts","names":[],"sources":["../../src/transactions/marginRegistry.ts"],"mappings":";;;;;;;;cASa,sBAAA;EAAA;;;;cAMA,MAAA,EAAQ,cAAA;EAyBwB;;;;;EAhB5C,WAAA,GAAe,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,
|
|
1
|
+
{"version":3,"file":"marginRegistry.d.mts","names":[],"sources":["../../src/transactions/marginRegistry.ts"],"mappings":";;;;;;;;cASa,sBAAA;EAAA;;;;cAMA,MAAA,EAAQ,cAAA;EAyBwB;;;;;EAhB5C,WAAA,GAAe,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EAyDN;;;;;EAzC7C,eAAA,GAAmB,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EAmFR;;;;;EArE/C,4BAAA,GAAgC,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EA+GlB;;;;;EAjGlD,mBAAA,GAAuB,KAAA,cAAmB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EAwI3B;;;;;EA3H9B,gBAAA,GAAoB,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EAlEpC;;;;;EAgFpB,iBAAA,GAAqB,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EAvEN;;;;;EAqFnD,oBAAA,GAAwB,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EAvD5D;;;;;EAqEA,kBAAA,GAAsB,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EAvDnC;;;;;EAqEvB,oBAAA,GAAwB,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EAxDf;;;;;EAsE7C,0BAAA,GAA8B,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EAxDxB;;;;;EAsE1C,qBAAA,GAAyB,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EAxDD;;;;;EAsE5D,qBAAA,GAAyB,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EA1C7D;;;;EAuDA,kBAAA,SAA4B,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EAzC3C;;;;EAqDA,gBAAA,SAA0B,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;AAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AddConditionalOrderParams, PendingLimitOrderParams, PendingMarketOrderParams } from "../types/index.mjs";
|
|
2
2
|
import { DeepBookConfig } from "../utils/config.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _mysten_sui_transactions94 from "@mysten/sui/transactions";
|
|
4
4
|
import { Transaction } from "@mysten/sui/transactions";
|
|
5
5
|
|
|
6
6
|
//#region src/transactions/marginTPSL.d.ts
|
|
@@ -20,21 +20,21 @@ declare class MarginTPSLContract {
|
|
|
20
20
|
* @param {number} triggerPrice The price at which to trigger the order
|
|
21
21
|
* @returns A function that takes a Transaction object
|
|
22
22
|
*/
|
|
23
|
-
newCondition: (poolKey: string, triggerBelowPrice: boolean, triggerPrice: number | bigint) => (tx: Transaction) =>
|
|
23
|
+
newCondition: (poolKey: string, triggerBelowPrice: boolean, triggerPrice: number | bigint) => (tx: Transaction) => _mysten_sui_transactions94.TransactionResult;
|
|
24
24
|
/**
|
|
25
25
|
* @description Create a new pending limit order for use in conditional orders
|
|
26
26
|
* @param {string} poolKey The key to identify the pool
|
|
27
27
|
* @param {PendingLimitOrderParams} params Parameters for the pending limit order
|
|
28
28
|
* @returns A function that takes a Transaction object
|
|
29
29
|
*/
|
|
30
|
-
newPendingLimitOrder: (poolKey: string, params: PendingLimitOrderParams) => (tx: Transaction) =>
|
|
30
|
+
newPendingLimitOrder: (poolKey: string, params: PendingLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions94.TransactionResult;
|
|
31
31
|
/**
|
|
32
32
|
* @description Create a new pending market order for use in conditional orders
|
|
33
33
|
* @param {string} poolKey The key to identify the pool
|
|
34
34
|
* @param {PendingMarketOrderParams} params Parameters for the pending market order
|
|
35
35
|
* @returns A function that takes a Transaction object
|
|
36
36
|
*/
|
|
37
|
-
newPendingMarketOrder: (poolKey: string, params: PendingMarketOrderParams) => (tx: Transaction) =>
|
|
37
|
+
newPendingMarketOrder: (poolKey: string, params: PendingMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions94.TransactionResult;
|
|
38
38
|
/**
|
|
39
39
|
* @description Add a conditional order (take profit or stop loss)
|
|
40
40
|
* @param {AddConditionalOrderParams} params Parameters for adding the conditional order
|
|
@@ -55,21 +55,24 @@ declare class MarginTPSLContract {
|
|
|
55
55
|
*/
|
|
56
56
|
cancelConditionalOrder: (marginManagerKey: string, conditionalOrderId: string) => (tx: Transaction) => void;
|
|
57
57
|
/**
|
|
58
|
-
* @description Execute conditional orders that have been triggered
|
|
59
|
-
*
|
|
58
|
+
* @description Execute conditional orders that have been triggered.
|
|
59
|
+
* Permissionless — anyone can call this. After the inner fill loop, the
|
|
60
|
+
* manager's post-trade `risk_ratio` is checked against
|
|
61
|
+
* `min_borrow_risk_ratio`; if any triggered fill breaches that floor, the
|
|
62
|
+
* whole txn aborts (no partial-state landing).
|
|
60
63
|
* @param {string} managerAddress The address of the margin manager
|
|
61
64
|
* @param {string} poolKey The key to identify the pool (e.g., 'SUI_USDC')
|
|
62
65
|
* @param {number} maxOrdersToExecute Maximum number of orders to execute in this call
|
|
63
66
|
* @returns A function that takes a Transaction object
|
|
64
67
|
*/
|
|
65
|
-
executeConditionalOrders: (managerAddress: string, poolKey: string, maxOrdersToExecute: number) => (tx: Transaction) =>
|
|
68
|
+
executeConditionalOrders: (managerAddress: string, poolKey: string, maxOrdersToExecute: number) => (tx: Transaction) => _mysten_sui_transactions94.TransactionResult;
|
|
66
69
|
/**
|
|
67
70
|
* @description Get all conditional order IDs for a margin manager
|
|
68
71
|
* @param {string} poolKey The key to identify the pool
|
|
69
72
|
* @param {string} marginManagerId The ID of the margin manager
|
|
70
73
|
* @returns A function that takes a Transaction object
|
|
71
74
|
*/
|
|
72
|
-
conditionalOrderIds: (poolKey: string, marginManagerId: string) => (tx: Transaction) =>
|
|
75
|
+
conditionalOrderIds: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions94.TransactionResult;
|
|
73
76
|
/**
|
|
74
77
|
* @description Get a specific conditional order by ID
|
|
75
78
|
* @param {string} poolKey The key to identify the pool
|
|
@@ -77,7 +80,7 @@ declare class MarginTPSLContract {
|
|
|
77
80
|
* @param {string} conditionalOrderId The ID of the conditional order
|
|
78
81
|
* @returns A function that takes a Transaction object
|
|
79
82
|
*/
|
|
80
|
-
conditionalOrder: (poolKey: string, marginManagerId: string, conditionalOrderId: string) => (tx: Transaction) =>
|
|
83
|
+
conditionalOrder: (poolKey: string, marginManagerId: string, conditionalOrderId: string) => (tx: Transaction) => _mysten_sui_transactions94.TransactionResult;
|
|
81
84
|
/**
|
|
82
85
|
* @description Get the lowest trigger price for trigger_above orders
|
|
83
86
|
* Returns constants::max_u64() if there are no trigger_above orders
|
|
@@ -85,7 +88,7 @@ declare class MarginTPSLContract {
|
|
|
85
88
|
* @param {string} marginManagerId The ID of the margin manager
|
|
86
89
|
* @returns A function that takes a Transaction object
|
|
87
90
|
*/
|
|
88
|
-
lowestTriggerAbovePrice: (poolKey: string, marginManagerId: string) => (tx: Transaction) =>
|
|
91
|
+
lowestTriggerAbovePrice: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions94.TransactionResult;
|
|
89
92
|
/**
|
|
90
93
|
* @description Get the highest trigger price for trigger_below orders
|
|
91
94
|
* Returns 0 if there are no trigger_below orders
|
|
@@ -93,7 +96,7 @@ declare class MarginTPSLContract {
|
|
|
93
96
|
* @param {string} marginManagerId The ID of the margin manager
|
|
94
97
|
* @returns A function that takes a Transaction object
|
|
95
98
|
*/
|
|
96
|
-
highestTriggerBelowPrice: (poolKey: string, marginManagerId: string) => (tx: Transaction) =>
|
|
99
|
+
highestTriggerBelowPrice: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions94.TransactionResult;
|
|
97
100
|
}
|
|
98
101
|
//#endregion
|
|
99
102
|
export { MarginTPSLContract };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marginTPSL.d.mts","names":[],"sources":["../../src/transactions/marginTPSL.ts"],"mappings":";;;;;;;;;cAiBa,kBAAA;EAAA;;;;cAMA,MAAA,EAAQ,cAAA;EAsCO;;;;;;;EAzB3B,YAAA,GACE,OAAA,UAAiB,iBAAA,WAA4B,YAAA,uBAC7C,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA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A2B,OAAA,UAAiB,eAAA,cAA6B,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAlBrE;;;;;;;EAoCnB,wBAAA,GAA4B,OAAA,UAAiB,eAAA,cAA6B,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;AAAA"}
|
|
@@ -110,11 +110,15 @@ var MarginTPSLContract = class {
|
|
|
110
110
|
const pool = this.#config.getPool(poolKey);
|
|
111
111
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
112
112
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
113
|
+
const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
|
|
114
|
+
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
113
115
|
return tx.moveCall({
|
|
114
|
-
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::
|
|
116
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::execute_conditional_orders_v2`,
|
|
115
117
|
arguments: [
|
|
116
118
|
tx.object(managerAddress),
|
|
117
119
|
tx.object(pool.address),
|
|
120
|
+
tx.object(baseMarginPool.address),
|
|
121
|
+
tx.object(quoteMarginPool.address),
|
|
118
122
|
tx.object(baseCoin.priceInfoObjectId),
|
|
119
123
|
tx.object(quoteCoin.priceInfoObjectId),
|
|
120
124
|
tx.object(this.#config.MARGIN_REGISTRY_ID),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marginTPSL.mjs","names":["#config"],"sources":["../../src/transactions/marginTPSL.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { Transaction } from '@mysten/sui/transactions';\n\nimport type { DeepBookConfig } from '../utils/config.js';\nimport type {\n\tPendingLimitOrderParams,\n\tPendingMarketOrderParams,\n\tAddConditionalOrderParams,\n} from '../types/index.js';\nimport { OrderType, SelfMatchingOptions } from '../types/index.js';\nimport { MAX_TIMESTAMP, FLOAT_SCALAR } from '../utils/config.js';\nimport { convertQuantity, convertPrice } from '../utils/conversion.js';\n\n/**\n * MarginTPSLContract class for managing Take Profit / Stop Loss operations.\n */\nexport class MarginTPSLContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for MarginTPSLContract\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t// === Helper Functions ===\n\n\t/**\n\t * @description Create a new condition for a conditional order\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {boolean} triggerBelowPrice Whether to trigger when price is below trigger price\n\t * @param {number} triggerPrice The price at which to trigger the order\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewCondition =\n\t\t(poolKey: string, triggerBelowPrice: boolean, triggerPrice: number | bigint) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst inputPrice = convertPrice(\n\t\t\t\ttriggerPrice,\n\t\t\t\tFLOAT_SCALAR,\n\t\t\t\tquoteCoin.scalar,\n\t\t\t\tbaseCoin.scalar,\n\t\t\t);\n\t\t\treturn tx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::tpsl::new_condition`,\n\t\t\t\targuments: [tx.pure.bool(triggerBelowPrice), tx.pure.u64(inputPrice)],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Create a new pending limit order for use in conditional orders\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {PendingLimitOrderParams} params Parameters for the pending limit order\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewPendingLimitOrder =\n\t\t(poolKey: string, params: PendingLimitOrderParams) => (tx: Transaction) => {\n\t\t\tconst {\n\t\t\t\tclientOrderId,\n\t\t\t\torderType = OrderType.NO_RESTRICTION,\n\t\t\t\tselfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,\n\t\t\t\tprice,\n\t\t\t\tquantity,\n\t\t\t\tisBid,\n\t\t\t\tpayWithDeep = true,\n\t\t\t\texpireTimestamp = MAX_TIMESTAMP,\n\t\t\t} = params;\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst inputPrice = convertPrice(price, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar);\n\t\t\tconst inputQuantity = convertQuantity(quantity, baseCoin.scalar);\n\t\t\treturn tx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::tpsl::new_pending_limit_order`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.pure.u64(clientOrderId),\n\t\t\t\t\ttx.pure.u8(orderType),\n\t\t\t\t\ttx.pure.u8(selfMatchingOption),\n\t\t\t\t\ttx.pure.u64(inputPrice),\n\t\t\t\t\ttx.pure.u64(inputQuantity),\n\t\t\t\t\ttx.pure.bool(isBid),\n\t\t\t\t\ttx.pure.bool(payWithDeep),\n\t\t\t\t\ttx.pure.u64(expireTimestamp),\n\t\t\t\t],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Create a new pending market order for use in conditional orders\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {PendingMarketOrderParams} params Parameters for the pending market order\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewPendingMarketOrder =\n\t\t(poolKey: string, params: PendingMarketOrderParams) => (tx: Transaction) => {\n\t\t\tconst {\n\t\t\t\tclientOrderId,\n\t\t\t\tselfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,\n\t\t\t\tquantity,\n\t\t\t\tisBid,\n\t\t\t\tpayWithDeep = true,\n\t\t\t} = params;\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst inputQuantity = convertQuantity(quantity, baseCoin.scalar);\n\t\t\treturn tx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::tpsl::new_pending_market_order`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.pure.u64(clientOrderId),\n\t\t\t\t\ttx.pure.u8(selfMatchingOption),\n\t\t\t\t\ttx.pure.u64(inputQuantity),\n\t\t\t\t\ttx.pure.bool(isBid),\n\t\t\t\t\ttx.pure.bool(payWithDeep),\n\t\t\t\t],\n\t\t\t});\n\t\t};\n\n\t// === Public Functions ===\n\n\t/**\n\t * @description Add a conditional order (take profit or stop loss)\n\t * @param {AddConditionalOrderParams} params Parameters for adding the conditional order\n\t * @returns A function that takes a Transaction object\n\t */\n\taddConditionalOrder = (params: AddConditionalOrderParams) => (tx: Transaction) => {\n\t\tconst { marginManagerKey, conditionalOrderId, triggerBelowPrice, triggerPrice, pendingOrder } =\n\t\t\tparams;\n\t\tconst manager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\t// Create condition\n\t\tconst condition = this.newCondition(manager.poolKey, triggerBelowPrice, triggerPrice)(tx);\n\n\t\t// Create pending order based on type\n\t\tconst isLimitOrder = 'price' in pendingOrder;\n\t\tconst pending = isLimitOrder\n\t\t\t? this.newPendingLimitOrder(manager.poolKey, pendingOrder as PendingLimitOrderParams)(tx)\n\t\t\t: this.newPendingMarketOrder(manager.poolKey, pendingOrder as PendingMarketOrderParams)(tx);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::add_conditional_order`,\n\t\t\targuments: [\n\t\t\t\ttx.object(manager.address),\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.pure.u64(conditionalOrderId),\n\t\t\t\tcondition,\n\t\t\t\tpending,\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Cancel all conditional orders for a margin manager\n\t * @param {string} marginManagerKey The key to identify the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tcancelAllConditionalOrders = (marginManagerKey: string) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::cancel_all_conditional_orders`,\n\t\t\targuments: [tx.object(manager.address), tx.object.clock()],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Cancel a specific conditional order\n\t * @param {string} marginManagerKey The key to identify the margin manager\n\t * @param {string} conditionalOrderId The ID of the conditional order to cancel\n\t * @returns A function that takes a Transaction object\n\t */\n\tcancelConditionalOrder =\n\t\t(marginManagerKey: string, conditionalOrderId: string) => (tx: Transaction) => {\n\t\t\tconst manager = this.#config.getMarginManager(marginManagerKey);\n\t\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::cancel_conditional_order`,\n\t\t\t\targuments: [tx.object(manager.address), tx.pure.u64(conditionalOrderId), tx.object.clock()],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Execute conditional orders that have been triggered\n\t * This is a permissionless function that can be called by anyone\n\t * @param {string} managerAddress The address of the margin manager\n\t * @param {string} poolKey The key to identify the pool (e.g., 'SUI_USDC')\n\t * @param {number} maxOrdersToExecute Maximum number of orders to execute in this call\n\t * @returns A function that takes a Transaction object\n\t */\n\texecuteConditionalOrders =\n\t\t(managerAddress: string, poolKey: string, maxOrdersToExecute: number) => (tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\treturn tx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::execute_conditional_orders`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(managerAddress),\n\t\t\t\t\ttx.object(pool.address),\n\t\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\t\ttx.pure.u64(maxOrdersToExecute),\n\t\t\t\t\ttx.object.clock(),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\t\t};\n\n\t// === Read-Only Functions ===\n\n\t/**\n\t * @description Get all conditional order IDs for a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tconditionalOrderIds = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::conditional_order_ids`,\n\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get a specific conditional order by ID\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @param {string} conditionalOrderId The ID of the conditional order\n\t * @returns A function that takes a Transaction object\n\t */\n\tconditionalOrder =\n\t\t(poolKey: string, marginManagerId: string, conditionalOrderId: string) => (tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\treturn tx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::conditional_order`,\n\t\t\t\targuments: [tx.object(marginManagerId), tx.pure.u64(conditionalOrderId)],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Get the lowest trigger price for trigger_above orders\n\t * Returns constants::max_u64() if there are no trigger_above orders\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tlowestTriggerAbovePrice = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::lowest_trigger_above_price`,\n\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the highest trigger price for trigger_below orders\n\t * Returns 0 if there are no trigger_below orders\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\thighestTriggerBelowPrice = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::highest_trigger_below_price`,\n\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n}\n"],"mappings":";;;;;;;;AAiBA,IAAa,qBAAb,MAAgC;CAC/B;;;;CAKA,YAAY,QAAwB;uBAclC,SAAiB,mBAA4B,kBAC7C,OAAoB;GACpB,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;GAC1C,MAAM,WAAW,MAAKA,OAAQ,QAAQ,KAAK,SAAS;GAEpD,MAAM,aAAa,aAClB,cACA,cAHiB,MAAKA,OAAQ,QAAQ,KAAK,UAAU,CAI3C,QACV,SAAS,OACT;AACD,UAAO,GAAG,SAAS;IAClB,QAAQ,GAAG,MAAKA,OAAQ,kBAAkB;IAC1C,WAAW,CAAC,GAAG,KAAK,KAAK,kBAAkB,EAAE,GAAG,KAAK,IAAI,WAAW,CAAC;IACrE,CAAC;;+BAUF,SAAiB,YAAqC,OAAoB;GAC1E,MAAM,EACL,eACA,YAAY,UAAU,gBACtB,qBAAqB,oBAAoB,uBACzC,OACA,UACA,OACA,cAAc,MACd,kBAAkB,kBACf;GACJ,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;GAC1C,MAAM,WAAW,MAAKA,OAAQ,QAAQ,KAAK,SAAS;GAEpD,MAAM,aAAa,aAAa,OAAO,cADrB,MAAKA,OAAQ,QAAQ,KAAK,UAAU,CACS,QAAQ,SAAS,OAAO;GACvF,MAAM,gBAAgB,gBAAgB,UAAU,SAAS,OAAO;AAChE,UAAO,GAAG,SAAS;IAClB,QAA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kBAAkB;IAC1C,WAAW,CAAC,GAAG,OAAO,gBAAgB,EAAE,GAAG,KAAK,IAAI,mBAAmB,CAAC;IACxE,eAAe,CAAC,SAAS,MAAM,UAAU,KAAK;IAC9C,CAAC;;kCAUuB,SAAiB,qBAA6B,OAAoB;GAC5F,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;GAC1C,MAAM,WAAW,MAAKA,OAAQ,QAAQ,KAAK,SAAS;GACpD,MAAM,YAAY,MAAKA,OAAQ,QAAQ,KAAK,UAAU;AACtD,UAAO,GAAG,SAAS;IAClB,QAAQ,GAAG,MAAKA,OAAQ,kBAAkB;IAC1C,WAAW,CAAC,GAAG,OAAO,gBAAgB,CAAC;IACvC,eAAe,CAAC,SAAS,MAAM,UAAU,KAAK;IAC9C,CAAC;;mCAUyB,SAAiB,qBAA6B,OAAoB;GAC7F,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;GAC1C,MAAM,WAAW,MAAKA,OAAQ,QAAQ,KAAK,SAAS;GACpD,MAAM,YAAY,MAAKA,OAAQ,QAAQ,KAAK,UAAU;AACtD,UAAO,GAAG,SAAS;IAClB,QAAQ,GAAG,MAAKA,OAAQ,kBAAkB;IAC1C,WAAW,CAAC,GAAG,OAAO,gBAAgB,CAAC;IACvC,eAAe,CAAC,SAAS,MAAM,UAAU,KAAK;IAC9C,CAAC;;AAlRF,QAAKA,SAAU"}
|
|
1
|
+
{"version":3,"file":"marginTPSL.mjs","names":["#config"],"sources":["../../src/transactions/marginTPSL.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { Transaction } from '@mysten/sui/transactions';\n\nimport type { DeepBookConfig } from '../utils/config.js';\nimport type {\n\tPendingLimitOrderParams,\n\tPendingMarketOrderParams,\n\tAddConditionalOrderParams,\n} from '../types/index.js';\nimport { OrderType, SelfMatchingOptions } from '../types/index.js';\nimport { MAX_TIMESTAMP, FLOAT_SCALAR } from '../utils/config.js';\nimport { convertQuantity, convertPrice } from '../utils/conversion.js';\n\n/**\n * MarginTPSLContract class for managing Take Profit / Stop Loss operations.\n */\nexport class MarginTPSLContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for MarginTPSLContract\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t// === Helper Functions ===\n\n\t/**\n\t * @description Create a new condition for a conditional order\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {boolean} triggerBelowPrice Whether to trigger when price is below trigger price\n\t * @param {number} triggerPrice The price at which to trigger the order\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewCondition =\n\t\t(poolKey: string, triggerBelowPrice: boolean, triggerPrice: number | bigint) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst inputPrice = convertPrice(\n\t\t\t\ttriggerPrice,\n\t\t\t\tFLOAT_SCALAR,\n\t\t\t\tquoteCoin.scalar,\n\t\t\t\tbaseCoin.scalar,\n\t\t\t);\n\t\t\treturn tx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::tpsl::new_condition`,\n\t\t\t\targuments: [tx.pure.bool(triggerBelowPrice), tx.pure.u64(inputPrice)],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Create a new pending limit order for use in conditional orders\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {PendingLimitOrderParams} params Parameters for the pending limit order\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewPendingLimitOrder =\n\t\t(poolKey: string, params: PendingLimitOrderParams) => (tx: Transaction) => {\n\t\t\tconst {\n\t\t\t\tclientOrderId,\n\t\t\t\torderType = OrderType.NO_RESTRICTION,\n\t\t\t\tselfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,\n\t\t\t\tprice,\n\t\t\t\tquantity,\n\t\t\t\tisBid,\n\t\t\t\tpayWithDeep = true,\n\t\t\t\texpireTimestamp = MAX_TIMESTAMP,\n\t\t\t} = params;\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst inputPrice = convertPrice(price, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar);\n\t\t\tconst inputQuantity = convertQuantity(quantity, baseCoin.scalar);\n\t\t\treturn tx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::tpsl::new_pending_limit_order`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.pure.u64(clientOrderId),\n\t\t\t\t\ttx.pure.u8(orderType),\n\t\t\t\t\ttx.pure.u8(selfMatchingOption),\n\t\t\t\t\ttx.pure.u64(inputPrice),\n\t\t\t\t\ttx.pure.u64(inputQuantity),\n\t\t\t\t\ttx.pure.bool(isBid),\n\t\t\t\t\ttx.pure.bool(payWithDeep),\n\t\t\t\t\ttx.pure.u64(expireTimestamp),\n\t\t\t\t],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Create a new pending market order for use in conditional orders\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {PendingMarketOrderParams} params Parameters for the pending market order\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewPendingMarketOrder =\n\t\t(poolKey: string, params: PendingMarketOrderParams) => (tx: Transaction) => {\n\t\t\tconst {\n\t\t\t\tclientOrderId,\n\t\t\t\tselfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,\n\t\t\t\tquantity,\n\t\t\t\tisBid,\n\t\t\t\tpayWithDeep = true,\n\t\t\t} = params;\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst inputQuantity = convertQuantity(quantity, baseCoin.scalar);\n\t\t\treturn tx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::tpsl::new_pending_market_order`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.pure.u64(clientOrderId),\n\t\t\t\t\ttx.pure.u8(selfMatchingOption),\n\t\t\t\t\ttx.pure.u64(inputQuantity),\n\t\t\t\t\ttx.pure.bool(isBid),\n\t\t\t\t\ttx.pure.bool(payWithDeep),\n\t\t\t\t],\n\t\t\t});\n\t\t};\n\n\t// === Public Functions ===\n\n\t/**\n\t * @description Add a conditional order (take profit or stop loss)\n\t * @param {AddConditionalOrderParams} params Parameters for adding the conditional order\n\t * @returns A function that takes a Transaction object\n\t */\n\taddConditionalOrder = (params: AddConditionalOrderParams) => (tx: Transaction) => {\n\t\tconst { marginManagerKey, conditionalOrderId, triggerBelowPrice, triggerPrice, pendingOrder } =\n\t\t\tparams;\n\t\tconst manager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\t// Create condition\n\t\tconst condition = this.newCondition(manager.poolKey, triggerBelowPrice, triggerPrice)(tx);\n\n\t\t// Create pending order based on type\n\t\tconst isLimitOrder = 'price' in pendingOrder;\n\t\tconst pending = isLimitOrder\n\t\t\t? this.newPendingLimitOrder(manager.poolKey, pendingOrder as PendingLimitOrderParams)(tx)\n\t\t\t: this.newPendingMarketOrder(manager.poolKey, pendingOrder as PendingMarketOrderParams)(tx);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::add_conditional_order`,\n\t\t\targuments: [\n\t\t\t\ttx.object(manager.address),\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.pure.u64(conditionalOrderId),\n\t\t\t\tcondition,\n\t\t\t\tpending,\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Cancel all conditional orders for a margin manager\n\t * @param {string} marginManagerKey The key to identify the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tcancelAllConditionalOrders = (marginManagerKey: string) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::cancel_all_conditional_orders`,\n\t\t\targuments: [tx.object(manager.address), tx.object.clock()],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Cancel a specific conditional order\n\t * @param {string} marginManagerKey The key to identify the margin manager\n\t * @param {string} conditionalOrderId The ID of the conditional order to cancel\n\t * @returns A function that takes a Transaction object\n\t */\n\tcancelConditionalOrder =\n\t\t(marginManagerKey: string, conditionalOrderId: string) => (tx: Transaction) => {\n\t\t\tconst manager = this.#config.getMarginManager(marginManagerKey);\n\t\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::cancel_conditional_order`,\n\t\t\t\targuments: [tx.object(manager.address), tx.pure.u64(conditionalOrderId), tx.object.clock()],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Execute conditional orders that have been triggered.\n\t * Permissionless — anyone can call this. After the inner fill loop, the\n\t * manager's post-trade `risk_ratio` is checked against\n\t * `min_borrow_risk_ratio`; if any triggered fill breaches that floor, the\n\t * whole txn aborts (no partial-state landing).\n\t * @param {string} managerAddress The address of the margin manager\n\t * @param {string} poolKey The key to identify the pool (e.g., 'SUI_USDC')\n\t * @param {number} maxOrdersToExecute Maximum number of orders to execute in this call\n\t * @returns A function that takes a Transaction object\n\t */\n\texecuteConditionalOrders =\n\t\t(managerAddress: string, poolKey: string, maxOrdersToExecute: number) => (tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\t\treturn tx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::execute_conditional_orders_v2`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(managerAddress),\n\t\t\t\t\ttx.object(pool.address),\n\t\t\t\t\ttx.object(baseMarginPool.address),\n\t\t\t\t\ttx.object(quoteMarginPool.address),\n\t\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\t\ttx.pure.u64(maxOrdersToExecute),\n\t\t\t\t\ttx.object.clock(),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\t\t};\n\n\t// === Read-Only Functions ===\n\n\t/**\n\t * @description Get all conditional order IDs for a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tconditionalOrderIds = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::conditional_order_ids`,\n\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get a specific conditional order by ID\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @param {string} conditionalOrderId The ID of the conditional order\n\t * @returns A function that takes a Transaction object\n\t */\n\tconditionalOrder =\n\t\t(poolKey: string, marginManagerId: string, conditionalOrderId: string) => (tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\treturn tx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::conditional_order`,\n\t\t\t\targuments: [tx.object(marginManagerId), tx.pure.u64(conditionalOrderId)],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Get the lowest trigger price for trigger_above orders\n\t * Returns constants::max_u64() if there are no trigger_above orders\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tlowestTriggerAbovePrice = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::lowest_trigger_above_price`,\n\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the highest trigger price for trigger_below orders\n\t * Returns 0 if there are no trigger_below orders\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\thighestTriggerBelowPrice = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::highest_trigger_below_price`,\n\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n}\n"],"mappings":";;;;;;;;AAiBA,IAAa,qBAAb,MAAgC;CAC/B;;;;CAKA,YAAY,QAAwB;uBAclC,SAAiB,mBAA4B,kBAC7C,OAAoB;GACpB,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;GAC1C,MAAM,WAAW,MAAKA,OAAQ,QAAQ,KAAK,SAAS;GAEpD,MAAM,aAAa,aAClB,cACA,cAHiB,MAAKA,OAAQ,QAAQ,KAAK,UAAU,CAI3C,QACV,SAAS,OACT;AACD,UAAO,GAAG,SAAS;IAClB,QAAQ,GAAG,MAAKA,OAAQ,kBAAkB;IAC1C,WAAW,CAAC,GAAG,KAAK,KAAK,kBAAkB,EAAE,GAAG,KAAK,IAAI,WAAW,CAAC;IACrE,CAAC;;+BAUF,SAAiB,YAAqC,OAAoB;GAC1E,MAAM,EACL,eACA,YAAY,UAAU,gBACtB,qBAAqB,oBAAoB,uBACzC,OACA,UACA,OACA,cAAc,MACd,kBAAkB,kBACf;GACJ,MAAM,OAAO,MA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AC,SAAS,MAAM,UAAU,KAAK;IAC9C,CAAC;;AAzRF,QAAKA,SAAU"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MarginProposalParams, PlaceMarginLimitOrderParams, PlaceMarginMarketOrderParams } from "../types/index.mjs";
|
|
2
2
|
import { DeepBookConfig } from "../utils/config.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _mysten_sui_transactions90 from "@mysten/sui/transactions";
|
|
4
4
|
import { Transaction } from "@mysten/sui/transactions";
|
|
5
5
|
|
|
6
6
|
//#region src/transactions/poolProxy.d.ts
|
|
@@ -14,29 +14,39 @@ declare class PoolProxyContract {
|
|
|
14
14
|
*/
|
|
15
15
|
constructor(config: DeepBookConfig);
|
|
16
16
|
/**
|
|
17
|
-
* @description Place a limit order
|
|
17
|
+
* @description Place a limit order. Enforces a post-trade `risk_ratio >=
|
|
18
|
+
* min_borrow_risk_ratio` invariant on the manager (skipped when the manager
|
|
19
|
+
* has no debt).
|
|
18
20
|
* @param {PlaceMarginLimitOrderParams} params Parameters for placing a limit order
|
|
19
21
|
* @returns A function that takes a Transaction object
|
|
20
22
|
*/
|
|
21
|
-
placeLimitOrder: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) =>
|
|
23
|
+
placeLimitOrder: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions90.TransactionResult;
|
|
22
24
|
/**
|
|
23
|
-
* @description Place a market order
|
|
25
|
+
* @description Place a market order. Enforces a post-trade `risk_ratio >=
|
|
26
|
+
* min_borrow_risk_ratio` invariant on the manager (skipped when the manager
|
|
27
|
+
* has no debt).
|
|
24
28
|
* @param {PlaceMarginMarketOrderParams} params Parameters for placing a market order
|
|
25
29
|
* @returns A function that takes a Transaction object
|
|
26
30
|
*/
|
|
27
|
-
placeMarketOrder: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) =>
|
|
31
|
+
placeMarketOrder: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions90.TransactionResult;
|
|
28
32
|
/**
|
|
29
|
-
* @description Place a reduce only limit order
|
|
33
|
+
* @description Place a reduce only limit order. Requires the manager to have
|
|
34
|
+
* debt on the relevant side; enforces a monotonic `risk_ratio_after >=
|
|
35
|
+
* risk_ratio_before` invariant so the fill cannot leak value to the
|
|
36
|
+
* counterparty.
|
|
30
37
|
* @param {PlaceMarginLimitOrderParams} params Parameters for placing a reduce only limit order
|
|
31
38
|
* @returns A function that takes a Transaction object
|
|
32
39
|
*/
|
|
33
|
-
placeReduceOnlyLimitOrder: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) =>
|
|
40
|
+
placeReduceOnlyLimitOrder: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions90.TransactionResult;
|
|
34
41
|
/**
|
|
35
|
-
* @description Place a reduce only market order
|
|
42
|
+
* @description Place a reduce only market order. Requires the manager to
|
|
43
|
+
* have debt on the relevant side; enforces a monotonic `risk_ratio_after >=
|
|
44
|
+
* risk_ratio_before` invariant so the fill cannot leak value to the
|
|
45
|
+
* counterparty.
|
|
36
46
|
* @param {PlaceMarginMarketOrderParams} params Parameters for placing a reduce only market order
|
|
37
47
|
* @returns A function that takes a Transaction object
|
|
38
48
|
*/
|
|
39
|
-
placeReduceOnlyMarketOrder: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) =>
|
|
49
|
+
placeReduceOnlyMarketOrder: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions90.TransactionResult;
|
|
40
50
|
/**
|
|
41
51
|
* @description Modify an existing order
|
|
42
52
|
* @param {string} marginManagerKey The key to identify the MarginManager
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poolProxy.d.mts","names":[],"sources":["../../src/transactions/poolProxy.ts"],"mappings":";;;;;;;;;cAiBa,iBAAA;EAAA;;;;cAMA,MAAA,EAAQ,cAAA;
|
|
1
|
+
{"version":3,"file":"poolProxy.d.mts","names":[],"sources":["../../src/trans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;;;EAsB9D,WAAA,GAAe,gBAAA,cAA8B,EAAA,EAAI,WAAA;EAsBjD;;;;;;EAAA,4BAAA,GACE,OAAA,UAAiB,eAAA,cAA6B,EAAA,EAAI,WAAA;EAoBL;;;;;EAA/C,kBAAA,GAAsB,OAAA,cAAqB,EAAA,EAAI,WAAA;AAAA"}
|
|
@@ -18,14 +18,20 @@ var PoolProxyContract = class {
|
|
|
18
18
|
const manager = this.#config.getMarginManager(marginManagerKey);
|
|
19
19
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
20
20
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
21
|
+
const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
|
|
22
|
+
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
21
23
|
const inputPrice = convertPrice(price, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar);
|
|
22
24
|
const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
|
|
23
25
|
return tx.moveCall({
|
|
24
|
-
target: `${this.#config.MARGIN_PACKAGE_ID}::pool_proxy::
|
|
26
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::pool_proxy::place_limit_order_v2`,
|
|
25
27
|
arguments: [
|
|
26
28
|
tx.object(this.#config.MARGIN_REGISTRY_ID),
|
|
27
29
|
tx.object(manager.address),
|
|
28
30
|
tx.object(pool.address),
|
|
31
|
+
tx.object(baseMarginPool.address),
|
|
32
|
+
tx.object(quoteMarginPool.address),
|
|
33
|
+
tx.object(baseCoin.priceInfoObjectId),
|
|
34
|
+
tx.object(quoteCoin.priceInfoObjectId),
|
|
29
35
|
tx.pure.u64(clientOrderId),
|
|
30
36
|
tx.pure.u8(orderType),
|
|
31
37
|
tx.pure.u8(selfMatchingOption),
|
|
@@ -45,13 +51,19 @@ var PoolProxyContract = class {
|
|
|
45
51
|
const manager = this.#config.getMarginManager(marginManagerKey);
|
|
46
52
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
47
53
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
54
|
+
const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
|
|
55
|
+
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
48
56
|
const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
|
|
49
57
|
return tx.moveCall({
|
|
50
|
-
target: `${this.#config.MARGIN_PACKAGE_ID}::pool_proxy::
|
|
58
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::pool_proxy::place_market_order_v2`,
|
|
51
59
|
arguments: [
|
|
52
60
|
tx.object(this.#config.MARGIN_REGISTRY_ID),
|
|
53
61
|
tx.object(manager.address),
|
|
54
62
|
tx.object(pool.address),
|
|
63
|
+
tx.object(baseMarginPool.address),
|
|
64
|
+
tx.object(quoteMarginPool.address),
|
|
65
|
+
tx.object(baseCoin.priceInfoObjectId),
|
|
66
|
+
tx.object(quoteCoin.priceInfoObjectId),
|
|
55
67
|
tx.pure.u64(clientOrderId),
|
|
56
68
|
tx.pure.u8(selfMatchingOption),
|
|
57
69
|
tx.pure.u64(inputQuantity),
|
|
@@ -68,17 +80,20 @@ var PoolProxyContract = class {
|
|
|
68
80
|
const manager = this.#config.getMarginManager(marginManagerKey);
|
|
69
81
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
70
82
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
83
|
+
const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
|
|
84
|
+
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
71
85
|
const inputPrice = convertPrice(price, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar);
|
|
72
86
|
const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
|
|
73
|
-
const marginPool = isBid ? this.#config.getMarginPool(pool.baseCoin) : this.#config.getMarginPool(pool.quoteCoin);
|
|
74
|
-
const debtType = isBid ? baseCoin.type : quoteCoin.type;
|
|
75
87
|
return tx.moveCall({
|
|
76
|
-
target: `${this.#config.MARGIN_PACKAGE_ID}::pool_proxy::
|
|
88
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::pool_proxy::place_reduce_only_limit_order_v2`,
|
|
77
89
|
arguments: [
|
|
78
90
|
tx.object(this.#config.MARGIN_REGISTRY_ID),
|
|
79
91
|
tx.object(manager.address),
|
|
80
92
|
tx.object(pool.address),
|
|
81
|
-
tx.object(
|
|
93
|
+
tx.object(baseMarginPool.address),
|
|
94
|
+
tx.object(quoteMarginPool.address),
|
|
95
|
+
tx.object(baseCoin.priceInfoObjectId),
|
|
96
|
+
tx.object(quoteCoin.priceInfoObjectId),
|
|
82
97
|
tx.pure.u64(clientOrderId),
|
|
83
98
|
tx.pure.u8(orderType),
|
|
84
99
|
tx.pure.u8(selfMatchingOption),
|
|
@@ -89,11 +104,7 @@ var PoolProxyContract = class {
|
|
|
89
104
|
tx.pure.u64(expiration),
|
|
90
105
|
tx.object.clock()
|
|
91
106
|
],
|
|
92
|
-
typeArguments: [
|
|
93
|
-
baseCoin.type,
|
|
94
|
-
quoteCoin.type,
|
|
95
|
-
debtType
|
|
96
|
-
]
|
|
107
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
97
108
|
});
|
|
98
109
|
};
|
|
99
110
|
this.placeReduceOnlyMarketOrder = (params) => (tx) => {
|
|
@@ -102,16 +113,19 @@ var PoolProxyContract = class {
|
|
|
102
113
|
const manager = this.#config.getMarginManager(marginManagerKey);
|
|
103
114
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
104
115
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
116
|
+
const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
|
|
117
|
+
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
105
118
|
const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
|
|
106
|
-
const marginPool = isBid ? this.#config.getMarginPool(pool.baseCoin) : this.#config.getMarginPool(pool.quoteCoin);
|
|
107
|
-
const debtType = isBid ? baseCoin.type : quoteCoin.type;
|
|
108
119
|
return tx.moveCall({
|
|
109
|
-
target: `${this.#config.MARGIN_PACKAGE_ID}::pool_proxy::
|
|
120
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::pool_proxy::place_reduce_only_market_order_v2`,
|
|
110
121
|
arguments: [
|
|
111
122
|
tx.object(this.#config.MARGIN_REGISTRY_ID),
|
|
112
123
|
tx.object(manager.address),
|
|
113
124
|
tx.object(pool.address),
|
|
114
|
-
tx.object(
|
|
125
|
+
tx.object(baseMarginPool.address),
|
|
126
|
+
tx.object(quoteMarginPool.address),
|
|
127
|
+
tx.object(baseCoin.priceInfoObjectId),
|
|
128
|
+
tx.object(quoteCoin.priceInfoObjectId),
|
|
115
129
|
tx.pure.u64(clientOrderId),
|
|
116
130
|
tx.pure.u8(selfMatchingOption),
|
|
117
131
|
tx.pure.u64(inputQuantity),
|
|
@@ -119,11 +133,7 @@ var PoolProxyContract = class {
|
|
|
119
133
|
tx.pure.bool(payWithDeep),
|
|
120
134
|
tx.object.clock()
|
|
121
135
|
],
|
|
122
|
-
typeArguments: [
|
|
123
|
-
baseCoin.type,
|
|
124
|
-
quoteCoin.type,
|
|
125
|
-
debtType
|
|
126
|
-
]
|
|
136
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
127
137
|
});
|
|
128
138
|
};
|
|
129
139
|
this.modifyOrder = (marginManagerKey, orderId, newQuantity) => (tx) => {
|
|
@@ -286,7 +296,7 @@ var PoolProxyContract = class {
|
|
|
286
296
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
287
297
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
288
298
|
tx.moveCall({
|
|
289
|
-
target: `${this.#config.MARGIN_PACKAGE_ID}::pool_proxy::
|
|
299
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::pool_proxy::claim_rebates`,
|
|
290
300
|
arguments: [
|
|
291
301
|
tx.object(this.#config.MARGIN_REGISTRY_ID),
|
|
292
302
|
tx.object(marginManager.address),
|