@mysten/deepbook-v3 1.3.5 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -0
- package/dist/contracts/deepbook/account.d.mts +18 -18
- package/dist/contracts/deepbook/balances.d.mts +4 -4
- package/dist/contracts/deepbook/balances.d.mts.map +1 -1
- package/dist/transactions/balanceManager.d.mts +12 -12
- package/dist/transactions/deepbook.d.mts +20 -20
- package/dist/transactions/deepbookAdmin.d.mts +31 -2
- 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.d.mts.map +1 -1
- 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 +4 -2
- package/dist/utils/constants.mjs.map +1 -1
- package/package.json +3 -3
- 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 +5 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DepositDuringInitParams, DepositParams } from "../types/index.mjs";
|
|
2
2
|
import { DeepBookConfig } from "../utils/config.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _mysten_sui_transactions42 from "@mysten/sui/transactions";
|
|
4
4
|
import { Transaction, TransactionArgument } from "@mysten/sui/transactions";
|
|
5
5
|
|
|
6
6
|
//#region src/transactions/marginManager.d.ts
|
|
@@ -42,6 +42,21 @@ declare class MarginManagerContract {
|
|
|
42
42
|
* @returns A function that takes a Transaction object
|
|
43
43
|
*/
|
|
44
44
|
shareMarginManager: (poolKey: string, manager: TransactionArgument, initializer: TransactionArgument) => (tx: Transaction) => void;
|
|
45
|
+
/**
|
|
46
|
+
* @description Register a margin manager back to the margin registry. Lets
|
|
47
|
+
* owners restore visibility of a manager that was unregistered by another
|
|
48
|
+
* platform.
|
|
49
|
+
* @param {string} managerKey The key to identify the margin manager
|
|
50
|
+
* @returns A function that takes a Transaction object
|
|
51
|
+
*/
|
|
52
|
+
registerMarginManager: (managerKey: string) => (tx: Transaction) => void;
|
|
53
|
+
/**
|
|
54
|
+
* @description Unregister a margin manager from the margin registry. Aborts
|
|
55
|
+
* if the manager holds any outstanding debt or base/quote/DEEP balance.
|
|
56
|
+
* @param {string} managerKey The key to identify the margin manager
|
|
57
|
+
* @returns A function that takes a Transaction object
|
|
58
|
+
*/
|
|
59
|
+
unregisterMarginManager: (managerKey: string) => (tx: Transaction) => void;
|
|
45
60
|
/**
|
|
46
61
|
* @description Deposit into a margin manager during initialization (before sharing).
|
|
47
62
|
* Use this when you need to deposit funds into a newly created manager in the same transaction.
|
|
@@ -73,49 +88,49 @@ declare class MarginManagerContract {
|
|
|
73
88
|
* @param {number} amount The amount to withdraw
|
|
74
89
|
* @returns A function that takes a Transaction object
|
|
75
90
|
*/
|
|
76
|
-
withdrawBase: (managerKey: string, amount: number) => (tx: Transaction) =>
|
|
91
|
+
withdrawBase: (managerKey: string, amount: number) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
77
92
|
/**
|
|
78
93
|
* @description Withdraw quote from a margin manager
|
|
79
94
|
* @param {string} managerKey The key to identify the manager
|
|
80
95
|
* @param {number} amount The amount to withdraw
|
|
81
96
|
* @returns A function that takes a Transaction object
|
|
82
97
|
*/
|
|
83
|
-
withdrawQuote: (managerKey: string, amount: number) => (tx: Transaction) =>
|
|
98
|
+
withdrawQuote: (managerKey: string, amount: number) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
84
99
|
/**
|
|
85
100
|
* @description Withdraw deep from a margin manager
|
|
86
101
|
* @param {string} managerKey The key to identify the manager
|
|
87
102
|
* @param {number} amount The amount to withdraw
|
|
88
103
|
* @returns A function that takes a Transaction object
|
|
89
104
|
*/
|
|
90
|
-
withdrawDeep: (managerKey: string, amount: number) => (tx: Transaction) =>
|
|
105
|
+
withdrawDeep: (managerKey: string, amount: number) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
91
106
|
/**
|
|
92
107
|
* @description Borrow base from a margin manager
|
|
93
108
|
* @param {string} managerKey The key to identify the manager
|
|
94
109
|
* @param {number} amount The amount to borrow
|
|
95
110
|
* @returns A function that takes a Transaction object
|
|
96
111
|
*/
|
|
97
|
-
borrowBase: (managerKey: string, amount: number) => (tx: Transaction) =>
|
|
112
|
+
borrowBase: (managerKey: string, amount: number) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
98
113
|
/**
|
|
99
114
|
* @description Borrow quote from a margin manager
|
|
100
115
|
* @param {string} managerKey The key to identify the manager
|
|
101
116
|
* @param {number} amount The amount to borrow
|
|
102
117
|
* @returns A function that takes a Transaction object
|
|
103
118
|
*/
|
|
104
|
-
borrowQuote: (managerKey: string, amount: number) => (tx: Transaction) =>
|
|
119
|
+
borrowQuote: (managerKey: string, amount: number) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
105
120
|
/**
|
|
106
121
|
* @description Repay base from a margin manager
|
|
107
122
|
* @param {string} managerKey The key to identify the manager
|
|
108
123
|
* @param {number} amount The amount to repay
|
|
109
124
|
* @returns A function that takes a Transaction object
|
|
110
125
|
*/
|
|
111
|
-
repayBase: (managerKey: string, amount?: number) => (tx: Transaction) =>
|
|
126
|
+
repayBase: (managerKey: string, amount?: number) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
112
127
|
/**
|
|
113
128
|
* @description Repay quote from a margin manager
|
|
114
129
|
* @param {string} managerKey The key to identify the manager
|
|
115
130
|
* @param {number} amount The amount to repay
|
|
116
131
|
* @returns A function that takes a Transaction object
|
|
117
132
|
*/
|
|
118
|
-
repayQuote: (managerKey: string, amount?: number) => (tx: Transaction) =>
|
|
133
|
+
repayQuote: (managerKey: string, amount?: number) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
119
134
|
/**
|
|
120
135
|
* @description Liquidate a margin manager
|
|
121
136
|
* @param {string} managerAddress The address of the manager to liquidate
|
|
@@ -124,7 +139,7 @@ declare class MarginManagerContract {
|
|
|
124
139
|
* @param {TransactionArgument} repayCoin The coin to repay
|
|
125
140
|
* @returns A function that takes a Transaction object
|
|
126
141
|
*/
|
|
127
|
-
liquidate: (managerAddress: string, poolKey: string, debtIsBase: boolean, repayCoin: TransactionArgument) => (tx: Transaction) =>
|
|
142
|
+
liquidate: (managerAddress: string, poolKey: string, debtIsBase: boolean, repayCoin: TransactionArgument) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
128
143
|
/**
|
|
129
144
|
* @description Set the referral for a margin manager (DeepBookPoolReferral)
|
|
130
145
|
* @param {string} managerKey The key to identify the margin manager
|
|
@@ -145,63 +160,63 @@ declare class MarginManagerContract {
|
|
|
145
160
|
* @param {string} marginManagerId The ID of the margin manager
|
|
146
161
|
* @returns A function that takes a Transaction object
|
|
147
162
|
*/
|
|
148
|
-
ownerByPoolKey: (poolKey: string, marginManagerId: string) => (tx: Transaction) =>
|
|
163
|
+
ownerByPoolKey: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
149
164
|
/**
|
|
150
165
|
* @description Get the DeepBook pool ID associated with a margin manager
|
|
151
166
|
* @param {string} poolKey The key to identify the pool
|
|
152
167
|
* @param {string} marginManagerId The ID of the margin manager
|
|
153
168
|
* @returns A function that takes a Transaction object
|
|
154
169
|
*/
|
|
155
|
-
deepbookPool: (poolKey: string, marginManagerId: string) => (tx: Transaction) =>
|
|
170
|
+
deepbookPool: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
156
171
|
/**
|
|
157
172
|
* @description Get the margin pool ID (if any) associated with a margin manager
|
|
158
173
|
* @param {string} poolKey The key to identify the pool
|
|
159
174
|
* @param {string} marginManagerId The ID of the margin manager
|
|
160
175
|
* @returns A function that takes a Transaction object
|
|
161
176
|
*/
|
|
162
|
-
marginPoolId: (poolKey: string, marginManagerId: string) => (tx: Transaction) =>
|
|
177
|
+
marginPoolId: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
163
178
|
/**
|
|
164
179
|
* @description Get borrowed shares for both base and quote assets
|
|
165
180
|
* @param {string} poolKey The key to identify the pool
|
|
166
181
|
* @param {string} marginManagerId The ID of the margin manager
|
|
167
182
|
* @returns A function that takes a Transaction object
|
|
168
183
|
*/
|
|
169
|
-
borrowedShares: (poolKey: string, marginManagerId: string) => (tx: Transaction) =>
|
|
184
|
+
borrowedShares: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
170
185
|
/**
|
|
171
186
|
* @description Get borrowed base shares
|
|
172
187
|
* @param {string} poolKey The key to identify the pool
|
|
173
188
|
* @param {string} marginManagerId The ID of the margin manager
|
|
174
189
|
* @returns A function that takes a Transaction object
|
|
175
190
|
*/
|
|
176
|
-
borrowedBaseShares: (poolKey: string, marginManagerId: string) => (tx: Transaction) =>
|
|
191
|
+
borrowedBaseShares: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
177
192
|
/**
|
|
178
193
|
* @description Get borrowed quote shares
|
|
179
194
|
* @param {string} poolKey The key to identify the pool
|
|
180
195
|
* @param {string} marginManagerId The ID of the margin manager
|
|
181
196
|
* @returns A function that takes a Transaction object
|
|
182
197
|
*/
|
|
183
|
-
borrowedQuoteShares: (poolKey: string, marginManagerId: string) => (tx: Transaction) =>
|
|
198
|
+
borrowedQuoteShares: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
184
199
|
/**
|
|
185
200
|
* @description Check if margin manager has base asset debt
|
|
186
201
|
* @param {string} poolKey The key to identify the pool
|
|
187
202
|
* @param {string} marginManagerId The ID of the margin manager
|
|
188
203
|
* @returns A function that takes a Transaction object
|
|
189
204
|
*/
|
|
190
|
-
hasBaseDebt: (poolKey: string, marginManagerId: string) => (tx: Transaction) =>
|
|
205
|
+
hasBaseDebt: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
191
206
|
/**
|
|
192
207
|
* @description Get the balance manager ID for a margin manager
|
|
193
208
|
* @param {string} poolKey The key to identify the pool
|
|
194
209
|
* @param {string} marginManagerId The ID of the margin manager
|
|
195
210
|
* @returns A function that takes a Transaction object
|
|
196
211
|
*/
|
|
197
|
-
balanceManager: (poolKey: string, marginManagerId: string) => (tx: Transaction) =>
|
|
212
|
+
balanceManager: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
198
213
|
/**
|
|
199
214
|
* @description Calculate assets (base and quote) for a margin manager
|
|
200
215
|
* @param {string} poolKey The key to identify the pool
|
|
201
216
|
* @param {string} marginManagerId The ID of the margin manager
|
|
202
217
|
* @returns A function that takes a Transaction object
|
|
203
218
|
*/
|
|
204
|
-
calculateAssets: (poolKey: string, marginManagerId: string) => (tx: Transaction) =>
|
|
219
|
+
calculateAssets: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
205
220
|
/**
|
|
206
221
|
* @description Calculate debts (base and quote) for a margin manager
|
|
207
222
|
* @param {string} poolKey The key to identify the pool
|
|
@@ -209,7 +224,7 @@ declare class MarginManagerContract {
|
|
|
209
224
|
* @param {string} marginManagerId The ID of the margin manager
|
|
210
225
|
* @returns A function that takes a Transaction object
|
|
211
226
|
*/
|
|
212
|
-
calculateDebts: (poolKey: string, coinKey: string, marginManagerId: string) => (tx: Transaction) =>
|
|
227
|
+
calculateDebts: (poolKey: string, coinKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
213
228
|
/**
|
|
214
229
|
* @description Get comprehensive state information for a margin manager
|
|
215
230
|
* @param {string} poolKey The key to identify the pool
|
|
@@ -219,28 +234,106 @@ declare class MarginManagerContract {
|
|
|
219
234
|
* base_debt, quote_debt, base_pyth_price, base_pyth_decimals,
|
|
220
235
|
* quote_pyth_price, quote_pyth_decimals)
|
|
221
236
|
*/
|
|
222
|
-
managerState: (poolKey: string, marginManagerId: string) => (tx: Transaction) =>
|
|
237
|
+
managerState: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
223
238
|
/**
|
|
224
239
|
* @description Get the base asset balance of a margin manager
|
|
225
240
|
* @param {string} poolKey The key to identify the pool
|
|
226
241
|
* @param {string} marginManagerId The ID of the margin manager
|
|
227
242
|
* @returns A function that takes a Transaction object
|
|
228
243
|
*/
|
|
229
|
-
baseBalance: (poolKey: string, marginManagerId: string) => (tx: Transaction) =>
|
|
244
|
+
baseBalance: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
230
245
|
/**
|
|
231
246
|
* @description Get the quote asset balance of a margin manager
|
|
232
247
|
* @param {string} poolKey The key to identify the pool
|
|
233
248
|
* @param {string} marginManagerId The ID of the margin manager
|
|
234
249
|
* @returns A function that takes a Transaction object
|
|
235
250
|
*/
|
|
236
|
-
quoteBalance: (poolKey: string, marginManagerId: string) => (tx: Transaction) =>
|
|
251
|
+
quoteBalance: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
237
252
|
/**
|
|
238
253
|
* @description Get the DEEP token balance of a margin manager
|
|
239
254
|
* @param {string} poolKey The key to identify the pool
|
|
240
255
|
* @param {string} marginManagerId The ID of the margin manager
|
|
241
256
|
* @returns A function that takes a Transaction object
|
|
242
257
|
*/
|
|
243
|
-
deepBalance: (poolKey: string, marginManagerId: string) => (tx: Transaction) =>
|
|
258
|
+
deepBalance: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
259
|
+
/**
|
|
260
|
+
* @description Get the underlying BalanceManager ID for a margin manager.
|
|
261
|
+
* Returns an ID (not a `&BalanceManager`), so it composes in PTBs unlike
|
|
262
|
+
* `balanceManager`.
|
|
263
|
+
* @param {string} poolKey The key to identify the pool
|
|
264
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
265
|
+
* @returns A function that takes a Transaction object
|
|
266
|
+
*/
|
|
267
|
+
balanceManagerId: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
268
|
+
/**
|
|
269
|
+
* @description Get the BalanceManager referral ID for a pool (Option<ID>).
|
|
270
|
+
* @param {string} poolKey The key to identify the pool
|
|
271
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
272
|
+
* @returns A function that takes a Transaction object
|
|
273
|
+
*/
|
|
274
|
+
getBalanceManagerReferralId: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
275
|
+
/**
|
|
276
|
+
* @description Check if the margin manager's account exists in the pool.
|
|
277
|
+
* @param {string} poolKey The key to identify the pool
|
|
278
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
279
|
+
* @returns A function that takes a Transaction object
|
|
280
|
+
*/
|
|
281
|
+
accountExists: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
282
|
+
/**
|
|
283
|
+
* @description Get the pool account data for the margin manager.
|
|
284
|
+
* @param {string} poolKey The key to identify the pool
|
|
285
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
286
|
+
* @returns A function that takes a Transaction object
|
|
287
|
+
*/
|
|
288
|
+
account: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
289
|
+
/**
|
|
290
|
+
* @description Get the open order IDs for the margin manager's account in
|
|
291
|
+
* the pool.
|
|
292
|
+
* @param {string} poolKey The key to identify the pool
|
|
293
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
294
|
+
* @returns A function that takes a Transaction object
|
|
295
|
+
*/
|
|
296
|
+
accountOpenOrders: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
297
|
+
/**
|
|
298
|
+
* @description Get full order details for the margin manager's account in
|
|
299
|
+
* the pool.
|
|
300
|
+
* @param {string} poolKey The key to identify the pool
|
|
301
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
302
|
+
* @returns A function that takes a Transaction object
|
|
303
|
+
*/
|
|
304
|
+
getAccountOrderDetails: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
305
|
+
/**
|
|
306
|
+
* @description Get locked balances (base, quote, deep) for the margin
|
|
307
|
+
* manager's account in the pool.
|
|
308
|
+
* @param {string} poolKey The key to identify the pool
|
|
309
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
310
|
+
* @returns A function that takes a Transaction object
|
|
311
|
+
*/
|
|
312
|
+
lockedBalance: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
313
|
+
/**
|
|
314
|
+
* @description Check whether a limit order can be placed given the
|
|
315
|
+
* manager's current state.
|
|
316
|
+
* @param {string} poolKey The key to identify the pool
|
|
317
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
318
|
+
* @param {number | bigint} price Limit price
|
|
319
|
+
* @param {number | bigint} quantity Order quantity (base units)
|
|
320
|
+
* @param {boolean} isBid True for bid, false for ask
|
|
321
|
+
* @param {boolean} payWithDeep Whether to pay fees in DEEP
|
|
322
|
+
* @param {number | bigint} expireTimestamp Order expiration timestamp (ms)
|
|
323
|
+
* @returns A function that takes a Transaction object
|
|
324
|
+
*/
|
|
325
|
+
canPlaceLimitOrder: (poolKey: string, marginManagerId: string, price: number | bigint, quantity: number | bigint, isBid: boolean, payWithDeep: boolean, expireTimestamp: number | bigint) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
326
|
+
/**
|
|
327
|
+
* @description Check whether a market order can be placed given the
|
|
328
|
+
* manager's current state.
|
|
329
|
+
* @param {string} poolKey The key to identify the pool
|
|
330
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
331
|
+
* @param {number | bigint} quantity Order quantity (base units)
|
|
332
|
+
* @param {boolean} isBid True for bid, false for ask
|
|
333
|
+
* @param {boolean} payWithDeep Whether to pay fees in DEEP
|
|
334
|
+
* @returns A function that takes a Transaction object
|
|
335
|
+
*/
|
|
336
|
+
canPlaceMarketOrder: (poolKey: string, marginManagerId: string, quantity: number | bigint, isBid: boolean, payWithDeep: boolean) => (tx: Transaction) => _mysten_sui_transactions42.TransactionResult;
|
|
244
337
|
}
|
|
245
338
|
//#endregion
|
|
246
339
|
export { MarginManagerContract };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marginManager.d.mts","names":[],"sources":["../../src/transactions/marginManager.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"marginManager.d.mts","names":[],"sources":["../../src/transactions/marginManager.ts"],"mappings":";;;;;;;;;cAaa,qBAAA;EAAA;;;;cAMA,MAAA,EAAQ,cAAA;EAuDQ;;;;;EA9C5B,gBAAA,GAAoB,OAAA,cAAqB,EAAA,EAAI,WAAA;EAqG2B;;;;;EAhFxE,+BAAA,GAAmC,OAAA,cAAqB,EAAA,EAAI,WAAA;;;;;;;;;;EA8UD;;;;;;;EAtT3D,kBAAA,GACE,OAAA,UAAiB,OAAA,EAAS,mBAAA,EAAqB,WAAA,EAAa,mBAAA,MAC5D,EAAA,EAAI,WAAA;EAiZW;;;;;;;EA/XjB,qBAAA,GAAyB,UAAA,cAAwB,EAAA,EAAI,WAAA;EAsewB;;;;;;EApd7E,uBAAA,GAA2B,UAAA,cAAwB,EAAA,EAAI,WAAA;EAwhBU;;;;;;EAtgBjE,2BAAA,GAA+B,MAAA,EAAQ,uBAAA,MAA6B,EAAA,EAAI,WAAA;EA2jBQ;;;;;EAthBhF,WAAA,GAAe,MAAA,EAAQ,aAAA,MAAmB,EAAA,EAAI,WAAA;EAylB+B;;;;;EAzjB7E,YAAA,GAAgB,MAAA,EAAQ,aAAA,MAAmB,EAAA,EAAI,WAAA;EA8mB6C;;;;;EA9kB5F,WAAA,GAAe,MAAA,EAAQ,aAAA,MAAmB,EAAA,EAAI,WAAA;EAkoBoC;;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"../utils/conversion.mjs";
|
|
2
|
+
import { FLOAT_SCALAR } from "../utils/config.mjs";
|
|
2
3
|
import { coinWithBalance } from "@mysten/sui/transactions";
|
|
3
4
|
|
|
4
5
|
//#region src/transactions/marginManager.ts
|
|
@@ -55,6 +56,28 @@ var MarginManagerContract = class {
|
|
|
55
56
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
56
57
|
});
|
|
57
58
|
};
|
|
59
|
+
this.registerMarginManager = (managerKey) => (tx) => {
|
|
60
|
+
const manager = this.#config.getMarginManager(managerKey);
|
|
61
|
+
const pool = this.#config.getPool(manager.poolKey);
|
|
62
|
+
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
63
|
+
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
64
|
+
tx.moveCall({
|
|
65
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::register_margin_manager`,
|
|
66
|
+
arguments: [tx.object(manager.address), tx.object(this.#config.MARGIN_REGISTRY_ID)],
|
|
67
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
this.unregisterMarginManager = (managerKey) => (tx) => {
|
|
71
|
+
const manager = this.#config.getMarginManager(managerKey);
|
|
72
|
+
const pool = this.#config.getPool(manager.poolKey);
|
|
73
|
+
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
74
|
+
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
75
|
+
tx.moveCall({
|
|
76
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::unregister_margin_manager`,
|
|
77
|
+
arguments: [tx.object(manager.address), tx.object(this.#config.MARGIN_REGISTRY_ID)],
|
|
78
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
79
|
+
});
|
|
80
|
+
};
|
|
58
81
|
this.depositDuringInitialization = (params) => (tx) => {
|
|
59
82
|
const { manager, poolKey, coinType } = params;
|
|
60
83
|
const pool = this.#config.getPool(poolKey);
|
|
@@ -539,6 +562,115 @@ var MarginManagerContract = class {
|
|
|
539
562
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
540
563
|
});
|
|
541
564
|
};
|
|
565
|
+
this.balanceManagerId = (poolKey, marginManagerId) => (tx) => {
|
|
566
|
+
const pool = this.#config.getPool(poolKey);
|
|
567
|
+
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
568
|
+
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
569
|
+
return tx.moveCall({
|
|
570
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::balance_manager_id`,
|
|
571
|
+
arguments: [tx.object(marginManagerId)],
|
|
572
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
573
|
+
});
|
|
574
|
+
};
|
|
575
|
+
this.getBalanceManagerReferralId = (poolKey, marginManagerId) => (tx) => {
|
|
576
|
+
const pool = this.#config.getPool(poolKey);
|
|
577
|
+
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
578
|
+
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
579
|
+
return tx.moveCall({
|
|
580
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::get_balance_manager_referral_id`,
|
|
581
|
+
arguments: [tx.object(marginManagerId), tx.pure.id(pool.address)],
|
|
582
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
583
|
+
});
|
|
584
|
+
};
|
|
585
|
+
this.accountExists = (poolKey, marginManagerId) => (tx) => {
|
|
586
|
+
const pool = this.#config.getPool(poolKey);
|
|
587
|
+
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
588
|
+
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
589
|
+
return tx.moveCall({
|
|
590
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::account_exists`,
|
|
591
|
+
arguments: [tx.object(marginManagerId), tx.object(pool.address)],
|
|
592
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
593
|
+
});
|
|
594
|
+
};
|
|
595
|
+
this.account = (poolKey, marginManagerId) => (tx) => {
|
|
596
|
+
const pool = this.#config.getPool(poolKey);
|
|
597
|
+
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
598
|
+
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
599
|
+
return tx.moveCall({
|
|
600
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::account`,
|
|
601
|
+
arguments: [tx.object(marginManagerId), tx.object(pool.address)],
|
|
602
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
603
|
+
});
|
|
604
|
+
};
|
|
605
|
+
this.accountOpenOrders = (poolKey, marginManagerId) => (tx) => {
|
|
606
|
+
const pool = this.#config.getPool(poolKey);
|
|
607
|
+
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
608
|
+
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
609
|
+
return tx.moveCall({
|
|
610
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::account_open_orders`,
|
|
611
|
+
arguments: [tx.object(marginManagerId), tx.object(pool.address)],
|
|
612
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
613
|
+
});
|
|
614
|
+
};
|
|
615
|
+
this.getAccountOrderDetails = (poolKey, marginManagerId) => (tx) => {
|
|
616
|
+
const pool = this.#config.getPool(poolKey);
|
|
617
|
+
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
618
|
+
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
619
|
+
return tx.moveCall({
|
|
620
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::get_account_order_details`,
|
|
621
|
+
arguments: [tx.object(marginManagerId), tx.object(pool.address)],
|
|
622
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
623
|
+
});
|
|
624
|
+
};
|
|
625
|
+
this.lockedBalance = (poolKey, marginManagerId) => (tx) => {
|
|
626
|
+
const pool = this.#config.getPool(poolKey);
|
|
627
|
+
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
628
|
+
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
629
|
+
return tx.moveCall({
|
|
630
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::locked_balance`,
|
|
631
|
+
arguments: [tx.object(marginManagerId), tx.object(pool.address)],
|
|
632
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
633
|
+
});
|
|
634
|
+
};
|
|
635
|
+
this.canPlaceLimitOrder = (poolKey, marginManagerId, price, quantity, isBid, payWithDeep, expireTimestamp) => (tx) => {
|
|
636
|
+
const pool = this.#config.getPool(poolKey);
|
|
637
|
+
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
638
|
+
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
639
|
+
const inputPrice = convertPrice(price, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar);
|
|
640
|
+
const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
|
|
641
|
+
return tx.moveCall({
|
|
642
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::can_place_limit_order`,
|
|
643
|
+
arguments: [
|
|
644
|
+
tx.object(marginManagerId),
|
|
645
|
+
tx.object(pool.address),
|
|
646
|
+
tx.pure.u64(inputPrice),
|
|
647
|
+
tx.pure.u64(inputQuantity),
|
|
648
|
+
tx.pure.bool(isBid),
|
|
649
|
+
tx.pure.bool(payWithDeep),
|
|
650
|
+
tx.pure.u64(expireTimestamp),
|
|
651
|
+
tx.object.clock()
|
|
652
|
+
],
|
|
653
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
654
|
+
});
|
|
655
|
+
};
|
|
656
|
+
this.canPlaceMarketOrder = (poolKey, marginManagerId, quantity, isBid, payWithDeep) => (tx) => {
|
|
657
|
+
const pool = this.#config.getPool(poolKey);
|
|
658
|
+
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
659
|
+
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
660
|
+
const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
|
|
661
|
+
return tx.moveCall({
|
|
662
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::can_place_market_order`,
|
|
663
|
+
arguments: [
|
|
664
|
+
tx.object(marginManagerId),
|
|
665
|
+
tx.object(pool.address),
|
|
666
|
+
tx.pure.u64(inputQuantity),
|
|
667
|
+
tx.pure.bool(isBid),
|
|
668
|
+
tx.pure.bool(payWithDeep),
|
|
669
|
+
tx.object.clock()
|
|
670
|
+
],
|
|
671
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
672
|
+
});
|
|
673
|
+
};
|
|
542
674
|
this.#config = config;
|
|
543
675
|
}
|
|
544
676
|
};
|