@mysten/deepbook-v3 1.5.8 → 1.6.2
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 +73 -0
- package/dist/client.d.mts +5 -0
- package/dist/client.d.mts.map +1 -1
- package/dist/client.mjs +7 -0
- package/dist/client.mjs.map +1 -1
- package/dist/contracts/deepbook/account.d.mts +18 -18
- package/dist/contracts/deepbook/account.d.mts.map +1 -1
- package/dist/contracts/deepbook/balance_manager.mjs +413 -0
- package/dist/contracts/deepbook/balance_manager.mjs.map +1 -0
- package/dist/contracts/deepbook/big_vector.mjs +43 -0
- package/dist/contracts/deepbook/big_vector.mjs.map +1 -0
- package/dist/contracts/deepbook/book.mjs +29 -0
- package/dist/contracts/deepbook/book.mjs.map +1 -0
- 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/deep_price.mjs +1 -1
- package/dist/contracts/deepbook/deps/std/type_name.mjs +17 -0
- package/dist/contracts/deepbook/deps/std/type_name.mjs.map +1 -0
- package/dist/contracts/deepbook/deps/sui/bag.mjs +43 -0
- package/dist/contracts/deepbook/deps/sui/bag.mjs.map +1 -0
- package/dist/contracts/deepbook/deps/sui/balance.mjs +21 -0
- package/dist/contracts/deepbook/deps/sui/balance.mjs.map +1 -0
- package/dist/contracts/deepbook/deps/sui/table.mjs +38 -0
- package/dist/contracts/deepbook/deps/sui/table.mjs.map +1 -0
- package/dist/contracts/deepbook/deps/sui/vec_map.mjs +37 -0
- package/dist/contracts/deepbook/deps/sui/vec_map.mjs.map +1 -0
- package/dist/contracts/deepbook/deps/sui/versioned.mjs +19 -0
- package/dist/contracts/deepbook/deps/sui/versioned.mjs.map +1 -0
- package/dist/contracts/deepbook/governance.mjs +49 -0
- package/dist/contracts/deepbook/governance.mjs.map +1 -0
- package/dist/contracts/deepbook/history.mjs +56 -0
- package/dist/contracts/deepbook/history.mjs.map +1 -0
- package/dist/contracts/deepbook/order.d.mts +12 -12
- package/dist/contracts/deepbook/pool.mjs +1739 -0
- package/dist/contracts/deepbook/pool.mjs.map +1 -0
- package/dist/contracts/deepbook/registry.mjs +295 -0
- package/dist/contracts/deepbook/registry.mjs.map +1 -0
- package/dist/contracts/deepbook/state.mjs +89 -0
- package/dist/contracts/deepbook/state.mjs.map +1 -0
- package/dist/contracts/deepbook/trade_params.mjs +21 -0
- package/dist/contracts/deepbook/trade_params.mjs.map +1 -0
- package/dist/contracts/deepbook/vault.mjs +42 -0
- package/dist/contracts/deepbook/vault.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/deepbook/balance_manager.mjs +53 -0
- package/dist/contracts/deepbook_margin/deps/deepbook/balance_manager.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/std/type_name.mjs +17 -0
- package/dist/contracts/deepbook_margin/deps/std/type_name.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/bag.mjs +43 -0
- package/dist/contracts/deepbook_margin/deps/sui/bag.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/balance.mjs +21 -0
- package/dist/contracts/deepbook_margin/deps/sui/balance.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/table.mjs +38 -0
- package/dist/contracts/deepbook_margin/deps/sui/table.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/vec_map.mjs +37 -0
- package/dist/contracts/deepbook_margin/deps/sui/vec_map.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/vec_set.mjs +26 -0
- package/dist/contracts/deepbook_margin/deps/sui/vec_set.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/versioned.mjs +19 -0
- package/dist/contracts/deepbook_margin/deps/sui/versioned.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/margin_manager.mjs +989 -0
- package/dist/contracts/deepbook_margin/margin_manager.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/margin_pool.mjs +550 -0
- package/dist/contracts/deepbook_margin/margin_pool.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/margin_registry.mjs +786 -0
- package/dist/contracts/deepbook_margin/margin_registry.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/margin_state.mjs +30 -0
- package/dist/contracts/deepbook_margin/margin_state.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/oracle.mjs +82 -0
- package/dist/contracts/deepbook_margin/oracle.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/pool_proxy.mjs +644 -0
- package/dist/contracts/deepbook_margin/pool_proxy.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/position_manager.mjs +32 -0
- package/dist/contracts/deepbook_margin/position_manager.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/protocol_config.mjs +122 -0
- package/dist/contracts/deepbook_margin/protocol_config.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/protocol_fees.mjs +58 -0
- package/dist/contracts/deepbook_margin/protocol_fees.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/rate_limiter.mjs +26 -0
- package/dist/contracts/deepbook_margin/rate_limiter.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/tpsl.mjs +171 -0
- package/dist/contracts/deepbook_margin/tpsl.mjs.map +1 -0
- package/dist/contracts/margin_liquidation/deps/sui/bag.mjs +43 -0
- package/dist/contracts/margin_liquidation/deps/sui/bag.mjs.map +1 -0
- package/dist/contracts/margin_liquidation/liquidation_vault.mjs +179 -0
- package/dist/contracts/margin_liquidation/liquidation_vault.mjs.map +1 -0
- package/dist/contracts/utils/index.d.mts +1 -1
- package/dist/contracts/utils/index.mjs +92 -3
- package/dist/contracts/utils/index.mjs.map +1 -1
- package/dist/queries/registryQueries.mjs +13 -0
- package/dist/queries/registryQueries.mjs.map +1 -1
- package/dist/transactions/balanceManager.d.mts.map +1 -1
- package/dist/transactions/balanceManager.mjs +119 -100
- package/dist/transactions/balanceManager.mjs.map +1 -1
- package/dist/transactions/deepbook.d.mts.map +1 -1
- package/dist/transactions/deepbook.mjs +464 -439
- package/dist/transactions/deepbook.mjs.map +1 -1
- package/dist/transactions/deepbookAdmin.d.mts.map +1 -1
- package/dist/transactions/deepbookAdmin.mjs +151 -135
- package/dist/transactions/deepbookAdmin.mjs.map +1 -1
- package/dist/transactions/flashLoans.d.mts.map +1 -1
- package/dist/transactions/flashLoans.mjs +29 -22
- package/dist/transactions/flashLoans.mjs.map +1 -1
- package/dist/transactions/governance.d.mts.map +1 -1
- package/dist/transactions/governance.mjs +34 -33
- package/dist/transactions/governance.mjs.map +1 -1
- package/dist/transactions/marginAdmin.d.mts +17 -7
- package/dist/transactions/marginAdmin.d.mts.map +1 -1
- package/dist/transactions/marginAdmin.mjs +186 -169
- package/dist/transactions/marginAdmin.mjs.map +1 -1
- package/dist/transactions/marginLiquidations.d.mts +3 -3
- package/dist/transactions/marginLiquidations.d.mts.map +1 -1
- package/dist/transactions/marginLiquidations.mjs +53 -54
- package/dist/transactions/marginLiquidations.mjs.map +1 -1
- package/dist/transactions/marginMaintainer.d.mts +5 -5
- package/dist/transactions/marginMaintainer.d.mts.map +1 -1
- package/dist/transactions/marginMaintainer.mjs +83 -83
- package/dist/transactions/marginMaintainer.mjs.map +1 -1
- package/dist/transactions/marginManager.d.mts +32 -32
- package/dist/transactions/marginManager.d.mts.map +1 -1
- package/dist/transactions/marginManager.mjs +330 -317
- package/dist/transactions/marginManager.mjs.map +1 -1
- package/dist/transactions/marginPool.d.mts +18 -18
- package/dist/transactions/marginPool.d.mts.map +1 -1
- package/dist/transactions/marginPool.mjs +93 -89
- package/dist/transactions/marginPool.mjs.map +1 -1
- package/dist/transactions/marginRegistry.d.mts +22 -15
- package/dist/transactions/marginRegistry.d.mts.map +1 -1
- package/dist/transactions/marginRegistry.mjs +101 -68
- package/dist/transactions/marginRegistry.mjs.map +1 -1
- package/dist/transactions/marginTPSL.d.mts +27 -9
- package/dist/transactions/marginTPSL.d.mts.map +1 -1
- package/dist/transactions/marginTPSL.mjs +108 -82
- package/dist/transactions/marginTPSL.mjs.map +1 -1
- package/dist/transactions/poolProxy.d.mts +37 -5
- package/dist/transactions/poolProxy.d.mts.map +1 -1
- package/dist/transactions/poolProxy.mjs +269 -189
- package/dist/transactions/poolProxy.mjs.map +1 -1
- package/dist/utils/constants.mjs +4 -4
- package/dist/utils/constants.mjs.map +1 -1
- package/package.json +3 -3
- package/src/client.ts +8 -0
- package/src/contracts/deepbook/balance_manager.ts +46 -5
- package/src/contracts/deepbook/constants.ts +13 -0
- package/src/contracts/deepbook/pool.ts +133 -0
- package/src/contracts/deepbook/registry.ts +136 -1
- package/src/contracts/deepbook_margin/deps/deepbook/balance_manager.ts +49 -0
- package/src/contracts/deepbook_margin/deps/std/type_name.ts +24 -0
- package/src/contracts/deepbook_margin/deps/sui/bag.ts +41 -0
- package/src/contracts/deepbook_margin/deps/sui/balance.ts +19 -0
- package/src/contracts/deepbook_margin/deps/sui/table.ts +36 -0
- package/src/contracts/deepbook_margin/deps/sui/vec_map.ts +33 -0
- package/src/contracts/deepbook_margin/deps/sui/vec_set.ts +22 -0
- package/src/contracts/deepbook_margin/deps/sui/versioned.ts +13 -0
- package/src/contracts/deepbook_margin/margin_constants.ts +329 -0
- package/src/contracts/deepbook_margin/margin_manager.ts +1772 -0
- package/src/contracts/deepbook_margin/margin_pool.ts +1129 -0
- package/src/contracts/deepbook_margin/margin_registry.ts +1207 -0
- package/src/contracts/deepbook_margin/margin_state.ts +26 -0
- package/src/contracts/deepbook_margin/oracle.ts +99 -0
- package/src/contracts/deepbook_margin/pool_proxy.ts +1298 -0
- package/src/contracts/deepbook_margin/position_manager.ts +28 -0
- package/src/contracts/deepbook_margin/protocol_config.ts +163 -0
- package/src/contracts/deepbook_margin/protocol_fees.ts +153 -0
- package/src/contracts/deepbook_margin/rate_limiter.ts +80 -0
- package/src/contracts/deepbook_margin/tpsl.ts +559 -0
- package/src/contracts/margin_liquidation/deps/sui/bag.ts +41 -0
- package/src/contracts/margin_liquidation/liquidation_vault.ts +401 -0
- package/src/queries/registryQueries.ts +15 -0
- package/src/transactions/balanceManager.ts +140 -90
- package/src/transactions/deepbook.ts +586 -494
- package/src/transactions/deepbookAdmin.ts +154 -146
- package/src/transactions/flashLoans.ts +29 -20
- package/src/transactions/governance.ts +50 -37
- package/src/transactions/marginAdmin.ts +247 -188
- package/src/transactions/marginLiquidations.ts +70 -55
- package/src/transactions/marginMaintainer.ts +106 -88
- package/src/transactions/marginManager.ts +414 -348
- package/src/transactions/marginPool.ts +140 -103
- package/src/transactions/marginRegistry.ts +103 -70
- package/src/transactions/marginTPSL.ts +151 -87
- package/src/transactions/poolProxy.ts +384 -205
- package/src/utils/constants.ts +4 -4
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { convertPrice, convertQuantity } from "../utils/conversion.mjs";
|
|
2
2
|
import { FLOAT_SCALAR, MAX_TIMESTAMP } from "../utils/config.mjs";
|
|
3
3
|
import { OrderType, SelfMatchingOptions } from "../types/index.mjs";
|
|
4
|
+
import { newCondition, newPendingLimitOrder, newPendingMarketOrder } from "../contracts/deepbook_margin/tpsl.mjs";
|
|
5
|
+
import { addConditionalOrder, cancelAllConditionalOrders, cancelConditionalOrder, conditionalOrder, conditionalOrderIds, executeConditionalOrdersV2, executeConditionalOrdersV3, highestTriggerBelowPrice, lowestTriggerAbovePrice } from "../contracts/deepbook_margin/margin_manager.mjs";
|
|
4
6
|
|
|
5
7
|
//#region src/transactions/marginTPSL.ts
|
|
6
8
|
/**
|
|
@@ -16,10 +18,13 @@ var MarginTPSLContract = class {
|
|
|
16
18
|
const pool = this.#config.getPool(poolKey);
|
|
17
19
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
18
20
|
const inputPrice = convertPrice(triggerPrice, FLOAT_SCALAR, this.#config.getCoin(pool.quoteCoin).scalar, baseCoin.scalar);
|
|
19
|
-
return tx.
|
|
20
|
-
|
|
21
|
-
arguments:
|
|
22
|
-
|
|
21
|
+
return tx.add(newCondition({
|
|
22
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
23
|
+
arguments: {
|
|
24
|
+
triggerBelowPrice,
|
|
25
|
+
triggerPrice: inputPrice
|
|
26
|
+
}
|
|
27
|
+
}));
|
|
23
28
|
};
|
|
24
29
|
this.newPendingLimitOrder = (poolKey, params) => (tx) => {
|
|
25
30
|
const { clientOrderId, orderType = OrderType.NO_RESTRICTION, selfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED, price, quantity, isBid, payWithDeep = true, expireTimestamp = MAX_TIMESTAMP } = params;
|
|
@@ -27,34 +32,34 @@ var MarginTPSLContract = class {
|
|
|
27
32
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
28
33
|
const inputPrice = convertPrice(price, FLOAT_SCALAR, this.#config.getCoin(pool.quoteCoin).scalar, baseCoin.scalar);
|
|
29
34
|
const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
|
|
30
|
-
return tx.
|
|
31
|
-
|
|
32
|
-
arguments:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
35
|
+
return tx.add(newPendingLimitOrder({
|
|
36
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
37
|
+
arguments: {
|
|
38
|
+
clientOrderId: BigInt(clientOrderId),
|
|
39
|
+
orderType,
|
|
40
|
+
selfMatchingOption,
|
|
41
|
+
price: inputPrice,
|
|
42
|
+
quantity: inputQuantity,
|
|
43
|
+
isBid,
|
|
44
|
+
payWithDeep,
|
|
45
|
+
expireTimestamp
|
|
46
|
+
}
|
|
47
|
+
}));
|
|
43
48
|
};
|
|
44
49
|
this.newPendingMarketOrder = (poolKey, params) => (tx) => {
|
|
45
50
|
const { clientOrderId, selfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED, quantity, isBid, payWithDeep = true } = params;
|
|
46
51
|
const pool = this.#config.getPool(poolKey);
|
|
47
52
|
const inputQuantity = convertQuantity(quantity, this.#config.getCoin(pool.baseCoin).scalar);
|
|
48
|
-
return tx.
|
|
49
|
-
|
|
50
|
-
arguments:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
});
|
|
53
|
+
return tx.add(newPendingMarketOrder({
|
|
54
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
55
|
+
arguments: {
|
|
56
|
+
clientOrderId: BigInt(clientOrderId),
|
|
57
|
+
selfMatchingOption,
|
|
58
|
+
quantity: inputQuantity,
|
|
59
|
+
isBid,
|
|
60
|
+
payWithDeep
|
|
61
|
+
}
|
|
62
|
+
}));
|
|
58
63
|
};
|
|
59
64
|
this.addConditionalOrder = (params) => (tx) => {
|
|
60
65
|
const { marginManagerKey, conditionalOrderId, triggerBelowPrice, triggerPrice, pendingOrder } = params;
|
|
@@ -64,47 +69,45 @@ var MarginTPSLContract = class {
|
|
|
64
69
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
65
70
|
const condition = this.newCondition(manager.poolKey, triggerBelowPrice, triggerPrice)(tx);
|
|
66
71
|
const pending = "price" in pendingOrder ? this.newPendingLimitOrder(manager.poolKey, pendingOrder)(tx) : this.newPendingMarketOrder(manager.poolKey, pendingOrder)(tx);
|
|
67
|
-
tx.
|
|
68
|
-
|
|
69
|
-
arguments:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
tx.add(addConditionalOrder({
|
|
73
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
74
|
+
arguments: {
|
|
75
|
+
self: manager.address,
|
|
76
|
+
pool: pool.address,
|
|
77
|
+
basePriceInfoObject: baseCoin.priceInfoObjectId,
|
|
78
|
+
quotePriceInfoObject: quoteCoin.priceInfoObjectId,
|
|
79
|
+
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
80
|
+
conditionalOrderId: BigInt(conditionalOrderId),
|
|
76
81
|
condition,
|
|
77
|
-
pending
|
|
78
|
-
|
|
79
|
-
],
|
|
82
|
+
pendingOrder: pending
|
|
83
|
+
},
|
|
80
84
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
81
|
-
});
|
|
85
|
+
}));
|
|
82
86
|
};
|
|
83
87
|
this.cancelAllConditionalOrders = (marginManagerKey) => (tx) => {
|
|
84
88
|
const manager = this.#config.getMarginManager(marginManagerKey);
|
|
85
89
|
const pool = this.#config.getPool(manager.poolKey);
|
|
86
90
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
87
91
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
88
|
-
tx.
|
|
89
|
-
|
|
90
|
-
arguments:
|
|
92
|
+
tx.add(cancelAllConditionalOrders({
|
|
93
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
94
|
+
arguments: { self: manager.address },
|
|
91
95
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
92
|
-
});
|
|
96
|
+
}));
|
|
93
97
|
};
|
|
94
98
|
this.cancelConditionalOrder = (marginManagerKey, conditionalOrderId) => (tx) => {
|
|
95
99
|
const manager = this.#config.getMarginManager(marginManagerKey);
|
|
96
100
|
const pool = this.#config.getPool(manager.poolKey);
|
|
97
101
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
98
102
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
99
|
-
tx.
|
|
100
|
-
|
|
101
|
-
arguments:
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
],
|
|
103
|
+
tx.add(cancelConditionalOrder({
|
|
104
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
105
|
+
arguments: {
|
|
106
|
+
self: manager.address,
|
|
107
|
+
conditionalOrderId: BigInt(conditionalOrderId)
|
|
108
|
+
},
|
|
106
109
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
107
|
-
});
|
|
110
|
+
}));
|
|
108
111
|
};
|
|
109
112
|
this.executeConditionalOrders = (managerAddress, poolKey, maxOrdersToExecute) => (tx) => {
|
|
110
113
|
const pool = this.#config.getPool(poolKey);
|
|
@@ -112,61 +115,84 @@ var MarginTPSLContract = class {
|
|
|
112
115
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
113
116
|
const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
|
|
114
117
|
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
115
|
-
return tx.
|
|
116
|
-
|
|
117
|
-
arguments:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
],
|
|
118
|
+
return tx.add(executeConditionalOrdersV2({
|
|
119
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
120
|
+
arguments: {
|
|
121
|
+
self: managerAddress,
|
|
122
|
+
pool: pool.address,
|
|
123
|
+
baseMarginPool: baseMarginPool.address,
|
|
124
|
+
quoteMarginPool: quoteMarginPool.address,
|
|
125
|
+
basePriceInfoObject: baseCoin.priceInfoObjectId,
|
|
126
|
+
quotePriceInfoObject: quoteCoin.priceInfoObjectId,
|
|
127
|
+
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
128
|
+
maxOrdersToExecute
|
|
129
|
+
},
|
|
128
130
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
129
|
-
});
|
|
131
|
+
}));
|
|
132
|
+
};
|
|
133
|
+
this.executeConditionalOrdersV3 = (managerAddress, poolKey, maxOrdersToExecute) => (tx) => {
|
|
134
|
+
const pool = this.#config.getPool(poolKey);
|
|
135
|
+
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
136
|
+
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
137
|
+
const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
|
|
138
|
+
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
139
|
+
return tx.add(executeConditionalOrdersV3({
|
|
140
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
141
|
+
arguments: {
|
|
142
|
+
self: managerAddress,
|
|
143
|
+
pool: pool.address,
|
|
144
|
+
baseMarginPool: baseMarginPool.address,
|
|
145
|
+
quoteMarginPool: quoteMarginPool.address,
|
|
146
|
+
basePriceInfoObject: baseCoin.priceInfoObjectId,
|
|
147
|
+
quotePriceInfoObject: quoteCoin.priceInfoObjectId,
|
|
148
|
+
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
149
|
+
maxOrdersToExecute
|
|
150
|
+
},
|
|
151
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
152
|
+
}));
|
|
130
153
|
};
|
|
131
154
|
this.conditionalOrderIds = (poolKey, marginManagerId) => (tx) => {
|
|
132
155
|
const pool = this.#config.getPool(poolKey);
|
|
133
156
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
134
157
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
135
|
-
return tx.
|
|
136
|
-
|
|
137
|
-
arguments:
|
|
158
|
+
return tx.add(conditionalOrderIds({
|
|
159
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
160
|
+
arguments: { self: marginManagerId },
|
|
138
161
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
139
|
-
});
|
|
162
|
+
}));
|
|
140
163
|
};
|
|
141
164
|
this.conditionalOrder = (poolKey, marginManagerId, conditionalOrderId) => (tx) => {
|
|
142
165
|
const pool = this.#config.getPool(poolKey);
|
|
143
166
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
144
167
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
145
|
-
return tx.
|
|
146
|
-
|
|
147
|
-
arguments:
|
|
168
|
+
return tx.add(conditionalOrder({
|
|
169
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
170
|
+
arguments: {
|
|
171
|
+
self: marginManagerId,
|
|
172
|
+
conditionalOrderId: BigInt(conditionalOrderId)
|
|
173
|
+
},
|
|
148
174
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
149
|
-
});
|
|
175
|
+
}));
|
|
150
176
|
};
|
|
151
177
|
this.lowestTriggerAbovePrice = (poolKey, marginManagerId) => (tx) => {
|
|
152
178
|
const pool = this.#config.getPool(poolKey);
|
|
153
179
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
154
180
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
155
|
-
return tx.
|
|
156
|
-
|
|
157
|
-
arguments:
|
|
181
|
+
return tx.add(lowestTriggerAbovePrice({
|
|
182
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
183
|
+
arguments: { self: marginManagerId },
|
|
158
184
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
159
|
-
});
|
|
185
|
+
}));
|
|
160
186
|
};
|
|
161
187
|
this.highestTriggerBelowPrice = (poolKey, marginManagerId) => (tx) => {
|
|
162
188
|
const pool = this.#config.getPool(poolKey);
|
|
163
189
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
164
190
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
165
|
-
return tx.
|
|
166
|
-
|
|
167
|
-
arguments:
|
|
191
|
+
return tx.add(highestTriggerBelowPrice({
|
|
192
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
193
|
+
arguments: { self: marginManagerId },
|
|
168
194
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
169
|
-
});
|
|
195
|
+
}));
|
|
170
196
|
};
|
|
171
197
|
this.#config = config;
|
|
172
198
|
}
|
|
@@ -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 * 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,K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,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;;AAzRF,QAAKA,SAAU"}
|
|
1
|
+
{"version":3,"file":"marginTPSL.mjs","names":["#config","tpslMoveCalls.newCondition","tpslMoveCalls.newPendingLimitOrder","tpslMoveCalls.newPendingMarketOrder","marginManagerMoveCalls.addConditionalOrder","marginManagerMoveCalls.cancelAllConditionalOrders","marginManagerMoveCalls.cancelConditionalOrder","marginManagerMoveCalls.executeConditionalOrdersV2","marginManagerMoveCalls.executeConditionalOrdersV3","marginManagerMoveCalls.conditionalOrderIds","marginManagerMoveCalls.conditionalOrder","marginManagerMoveCalls.lowestTriggerAbovePrice","marginManagerMoveCalls.highestTriggerBelowPrice"],"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';\nimport * as marginManagerMoveCalls from '../contracts/deepbook_margin/margin_manager.js';\nimport * as tpslMoveCalls from '../contracts/deepbook_margin/tpsl.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.add(\n\t\t\t\ttpslMoveCalls.newCondition({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: { triggerBelowPrice, triggerPrice: inputPrice },\n\t\t\t\t}),\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.add(\n\t\t\t\ttpslMoveCalls.newPendingLimitOrder({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tclientOrderId: BigInt(clientOrderId),\n\t\t\t\t\t\torderType,\n\t\t\t\t\t\tselfMatchingOption,\n\t\t\t\t\t\tprice: inputPrice,\n\t\t\t\t\t\tquantity: inputQuantity,\n\t\t\t\t\t\tisBid,\n\t\t\t\t\t\tpayWithDeep,\n\t\t\t\t\t\texpireTimestamp,\n\t\t\t\t\t},\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.add(\n\t\t\t\ttpslMoveCalls.newPendingMarketOrder({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tclientOrderId: BigInt(clientOrderId),\n\t\t\t\t\t\tselfMatchingOption,\n\t\t\t\t\t\tquantity: inputQuantity,\n\t\t\t\t\t\tisBid,\n\t\t\t\t\t\tpayWithDeep,\n\t\t\t\t\t},\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.add(\n\t\t\tmarginManagerMoveCalls.addConditionalOrder({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: manager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tbasePriceInfoObject: baseCoin.priceInfoObjectId!,\n\t\t\t\t\tquotePriceInfoObject: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tconditionalOrderId: BigInt(conditionalOrderId),\n\t\t\t\t\tcondition,\n\t\t\t\t\tpendingOrder: pending,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\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.add(\n\t\t\tmarginManagerMoveCalls.cancelAllConditionalOrders({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: manager.address },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\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.add(\n\t\t\t\tmarginManagerMoveCalls.cancelConditionalOrder({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: { self: manager.address, conditionalOrderId: BigInt(conditionalOrderId) },\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\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.add(\n\t\t\t\tmarginManagerMoveCalls.executeConditionalOrdersV2({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tself: managerAddress,\n\t\t\t\t\t\tpool: pool.address,\n\t\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t\t\tbasePriceInfoObject: baseCoin.priceInfoObjectId!,\n\t\t\t\t\t\tquotePriceInfoObject: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\t\tmaxOrdersToExecute,\n\t\t\t\t\t},\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Execute conditional orders, deleveraging on each market-type\n\t * fill. Permissionless, with the same trigger and cancellation handling as\n\t * {@link executeConditionalOrders}, but the market proceeds are repaid into\n\t * the loan before the risk check, and the gate is the *net* post-repay\n\t * `risk_ratio` being at least the pre-fill ratio.\n\t *\n\t * This is what lets a stop-loss fire in the `liquidation..min_borrow` danger\n\t * band: a swap alone only lowers the oracle-valued ratio (so the v2\n\t * borrow-floor gate rejects it), while repaying actually improves it. If a\n\t * single triggered fill would worsen net solvency the whole txn aborts — no\n\t * 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\texecuteConditionalOrdersV3 =\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.add(\n\t\t\t\tmarginManagerMoveCalls.executeConditionalOrdersV3({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tself: managerAddress,\n\t\t\t\t\t\tpool: pool.address,\n\t\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t\t\tbasePriceInfoObject: baseCoin.priceInfoObjectId!,\n\t\t\t\t\t\tquotePriceInfoObject: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\t\tmaxOrdersToExecute,\n\t\t\t\t\t},\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\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.add(\n\t\t\tmarginManagerMoveCalls.conditionalOrderIds({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\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.add(\n\t\t\t\tmarginManagerMoveCalls.conditionalOrder({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: { self: marginManagerId, conditionalOrderId: BigInt(conditionalOrderId) },\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\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.add(\n\t\t\tmarginManagerMoveCalls.lowestTriggerAbovePrice({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\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.add(\n\t\t\tmarginManagerMoveCalls.highestTriggerBelowPrice({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n}\n"],"mappings":";;;;;;;;;;AAmBA,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,IACTC,aAA2B;IAC1B,SAAS,MAAKD,OAAQ;IACtB,WAAW;KAAE;KAAmB,cAAc;KAAY;IAC1D,CAAC,CACF;;+BAUD,SAAiB,YAAqC,OAAoB;GAC1E,MAAM,EACL,eACA,Y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,CAAC,SAAS,MAAM,UAAU,KAAK;IAC9C,CAAC,CACF;;AAvVD,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
|
|
@@ -20,7 +20,7 @@ declare class PoolProxyContract {
|
|
|
20
20
|
* @param {PlaceMarginLimitOrderParams} params Parameters for placing a limit order
|
|
21
21
|
* @returns A function that takes a Transaction object
|
|
22
22
|
*/
|
|
23
|
-
placeLimitOrder: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) =>
|
|
23
|
+
placeLimitOrder: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions90.TransactionResult;
|
|
24
24
|
/**
|
|
25
25
|
* @description Place a market order. Enforces a post-trade `risk_ratio >=
|
|
26
26
|
* min_borrow_risk_ratio` invariant on the manager (skipped when the manager
|
|
@@ -28,7 +28,7 @@ declare class PoolProxyContract {
|
|
|
28
28
|
* @param {PlaceMarginMarketOrderParams} params Parameters for placing a market order
|
|
29
29
|
* @returns A function that takes a Transaction object
|
|
30
30
|
*/
|
|
31
|
-
placeMarketOrder: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) =>
|
|
31
|
+
placeMarketOrder: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions90.TransactionResult;
|
|
32
32
|
/**
|
|
33
33
|
* @description Place a reduce only limit order. Requires the manager to have
|
|
34
34
|
* debt on the relevant side; enforces a monotonic `risk_ratio_after >=
|
|
@@ -37,7 +37,7 @@ declare class PoolProxyContract {
|
|
|
37
37
|
* @param {PlaceMarginLimitOrderParams} params Parameters for placing a reduce only limit order
|
|
38
38
|
* @returns A function that takes a Transaction object
|
|
39
39
|
*/
|
|
40
|
-
placeReduceOnlyLimitOrder: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) =>
|
|
40
|
+
placeReduceOnlyLimitOrder: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions90.TransactionResult;
|
|
41
41
|
/**
|
|
42
42
|
* @description Place a reduce only market order. Requires the manager to
|
|
43
43
|
* have debt on the relevant side; enforces a monotonic `risk_ratio_after >=
|
|
@@ -46,7 +46,39 @@ declare class PoolProxyContract {
|
|
|
46
46
|
* @param {PlaceMarginMarketOrderParams} params Parameters for placing a reduce only market order
|
|
47
47
|
* @returns A function that takes a Transaction object
|
|
48
48
|
*/
|
|
49
|
-
placeReduceOnlyMarketOrder: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) =>
|
|
49
|
+
placeReduceOnlyMarketOrder: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions90.TransactionResult;
|
|
50
|
+
/**
|
|
51
|
+
* @description Place a market order and repay the loan from the fill proceeds.
|
|
52
|
+
* The taker fill settles into the manager's balance, so the proceeds (plus any
|
|
53
|
+
* idle balance) are repaid into the debt side before the risk check; the gate
|
|
54
|
+
* is then the *net* post-repay `risk_ratio` being at least the pre-fill ratio.
|
|
55
|
+
* Unlike {@link placeMarketOrder}, which checks the post-trade ratio against
|
|
56
|
+
* `min_borrow_risk_ratio`, this lets a deleveraging fill go through in the
|
|
57
|
+
* `liquidation..min_borrow` band, where a swap alone would be rejected.
|
|
58
|
+
* @param {PlaceMarginMarketOrderParams} params Parameters for placing a market order
|
|
59
|
+
* @returns A function that takes a Transaction object
|
|
60
|
+
*/
|
|
61
|
+
placeMarketOrderAndRepayLoan: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions90.TransactionResult;
|
|
62
|
+
/**
|
|
63
|
+
* @description Place a reduce only limit order and repay the loan from the
|
|
64
|
+
* fill proceeds. Requires debt on the relevant side (a bid needs base debt; an
|
|
65
|
+
* ask needs quote debt and sells at most the gross base held); the repay
|
|
66
|
+
* happens before the monotonic `risk_ratio` gate, so the check is on the net
|
|
67
|
+
* post-repay ratio.
|
|
68
|
+
* @param {PlaceMarginLimitOrderParams} params Parameters for placing a reduce only limit order
|
|
69
|
+
* @returns A function that takes a Transaction object
|
|
70
|
+
*/
|
|
71
|
+
placeReduceOnlyLimitOrderAndRepayLoan: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions90.TransactionResult;
|
|
72
|
+
/**
|
|
73
|
+
* @description Place a reduce only market order and repay the loan from the
|
|
74
|
+
* fill proceeds. Same reduce-only direction guard as
|
|
75
|
+
* {@link placeReduceOnlyMarketOrder}, but the settled proceeds are repaid into
|
|
76
|
+
* the debt side before the monotonic `risk_ratio` gate, so the check is on the
|
|
77
|
+
* net post-repay ratio.
|
|
78
|
+
* @param {PlaceMarginMarketOrderParams} params Parameters for placing a reduce only market order
|
|
79
|
+
* @returns A function that takes a Transaction object
|
|
80
|
+
*/
|
|
81
|
+
placeReduceOnlyMarketOrderAndRepayLoan: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions90.TransactionResult;
|
|
50
82
|
/**
|
|
51
83
|
* @description Modify an existing order
|
|
52
84
|
* @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":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"poolProxy.d.mts","names":[],"sources":["../../src/transactions/poolProxy.ts"],"mappings":";;;;;;;;;cAkBa,iBAAA;EAAA;;;;cAMA,MAAA,EAAQ,cAAA;EAWuD;;;;;;;EAA3E,eAAA,GAAmB,MAAA,EAAQ,2BAAA,MAAiC,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EA0JC;;;;;;;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