@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
|
@@ -5,6 +5,7 @@ import type { Transaction, TransactionObjectArgument } from '@mysten/sui/transac
|
|
|
5
5
|
|
|
6
6
|
import type { DeepBookConfig } from '../utils/config.js';
|
|
7
7
|
import { convertQuantity } from '../utils/conversion.js';
|
|
8
|
+
import * as marginPoolMoveCalls from '../contracts/deepbook_margin/margin_pool.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* MarginPoolContract class for managing MarginPool operations.
|
|
@@ -24,10 +25,12 @@ export class MarginPoolContract {
|
|
|
24
25
|
* @returns A function that takes a Transaction object
|
|
25
26
|
*/
|
|
26
27
|
mintSupplierCap = () => (tx: Transaction) => {
|
|
27
|
-
return tx.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
return tx.add(
|
|
29
|
+
marginPoolMoveCalls.mintSupplierCap({
|
|
30
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
31
|
+
arguments: { registry: this.#config.MARGIN_REGISTRY_ID },
|
|
32
|
+
}),
|
|
33
|
+
);
|
|
31
34
|
};
|
|
32
35
|
|
|
33
36
|
/**
|
|
@@ -55,6 +58,11 @@ export class MarginPoolContract {
|
|
|
55
58
|
balance: depositInput,
|
|
56
59
|
});
|
|
57
60
|
|
|
61
|
+
// NOTE: left as a positional moveCall (not codegen). This builder's
|
|
62
|
+
// coinWithBalance + `tx.object.option` (an on-chain option::none MoveCall
|
|
63
|
+
// for the Option<ID> referral) interleave commands in a way that a
|
|
64
|
+
// generated named-arg call reorders — so migrating it would change the
|
|
65
|
+
// emitted PTB. Kept verbatim to stay byte-identical.
|
|
58
66
|
tx.moveCall({
|
|
59
67
|
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::supply`,
|
|
60
68
|
arguments: [
|
|
@@ -86,17 +94,18 @@ export class MarginPoolContract {
|
|
|
86
94
|
const coin = this.#config.getCoin(coinKey);
|
|
87
95
|
const withdrawInput =
|
|
88
96
|
amountToWithdraw !== undefined ? convertQuantity(amountToWithdraw, coin.scalar) : null;
|
|
89
|
-
return tx.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
return tx.add(
|
|
98
|
+
marginPoolMoveCalls.withdraw({
|
|
99
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
100
|
+
arguments: {
|
|
101
|
+
self: marginPool.address,
|
|
102
|
+
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
103
|
+
supplierCap,
|
|
104
|
+
amount: withdrawInput,
|
|
105
|
+
},
|
|
106
|
+
typeArguments: [marginPool.type],
|
|
107
|
+
}),
|
|
108
|
+
);
|
|
100
109
|
};
|
|
101
110
|
|
|
102
111
|
/**
|
|
@@ -106,15 +115,13 @@ export class MarginPoolContract {
|
|
|
106
115
|
*/
|
|
107
116
|
mintSupplyReferral = (coinKey: string) => (tx: Transaction) => {
|
|
108
117
|
const marginPool = this.#config.getMarginPool(coinKey);
|
|
109
|
-
tx.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
typeArguments: [marginPool.type],
|
|
117
|
-
});
|
|
118
|
+
tx.add(
|
|
119
|
+
marginPoolMoveCalls.mintSupplyReferral({
|
|
120
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
121
|
+
arguments: { self: marginPool.address, registry: this.#config.MARGIN_REGISTRY_ID },
|
|
122
|
+
typeArguments: [marginPool.type],
|
|
123
|
+
}),
|
|
124
|
+
);
|
|
118
125
|
};
|
|
119
126
|
|
|
120
127
|
/**
|
|
@@ -125,15 +132,17 @@ export class MarginPoolContract {
|
|
|
125
132
|
*/
|
|
126
133
|
withdrawReferralFees = (coinKey: string, referralId: string) => (tx: Transaction) => {
|
|
127
134
|
const marginPool = this.#config.getMarginPool(coinKey);
|
|
128
|
-
return tx.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
return tx.add(
|
|
136
|
+
marginPoolMoveCalls.withdrawReferralFees({
|
|
137
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
138
|
+
arguments: {
|
|
139
|
+
self: marginPool.address,
|
|
140
|
+
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
141
|
+
referral: referralId,
|
|
142
|
+
},
|
|
143
|
+
typeArguments: [marginPool.type],
|
|
144
|
+
}),
|
|
145
|
+
);
|
|
137
146
|
};
|
|
138
147
|
|
|
139
148
|
// === Read-only/View Functions ===
|
|
@@ -145,11 +154,13 @@ export class MarginPoolContract {
|
|
|
145
154
|
*/
|
|
146
155
|
getId = (coinKey: string) => (tx: Transaction) => {
|
|
147
156
|
const marginPool = this.#config.getMarginPool(coinKey);
|
|
148
|
-
return tx.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
157
|
+
return tx.add(
|
|
158
|
+
marginPoolMoveCalls.id({
|
|
159
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
160
|
+
arguments: { self: marginPool.address },
|
|
161
|
+
typeArguments: [marginPool.type],
|
|
162
|
+
}),
|
|
163
|
+
);
|
|
153
164
|
};
|
|
154
165
|
|
|
155
166
|
/**
|
|
@@ -160,11 +171,13 @@ export class MarginPoolContract {
|
|
|
160
171
|
*/
|
|
161
172
|
deepbookPoolAllowed = (coinKey: string, deepbookPoolId: string) => (tx: Transaction) => {
|
|
162
173
|
const marginPool = this.#config.getMarginPool(coinKey);
|
|
163
|
-
return tx.
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
174
|
+
return tx.add(
|
|
175
|
+
marginPoolMoveCalls.deepbookPoolAllowed({
|
|
176
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
177
|
+
arguments: { self: marginPool.address, deepbookPoolId },
|
|
178
|
+
typeArguments: [marginPool.type],
|
|
179
|
+
}),
|
|
180
|
+
);
|
|
168
181
|
};
|
|
169
182
|
|
|
170
183
|
/**
|
|
@@ -174,11 +187,13 @@ export class MarginPoolContract {
|
|
|
174
187
|
*/
|
|
175
188
|
totalSupply = (coinKey: string) => (tx: Transaction) => {
|
|
176
189
|
const marginPool = this.#config.getMarginPool(coinKey);
|
|
177
|
-
return tx.
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
190
|
+
return tx.add(
|
|
191
|
+
marginPoolMoveCalls.totalSupply({
|
|
192
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
193
|
+
arguments: { self: marginPool.address },
|
|
194
|
+
typeArguments: [marginPool.type],
|
|
195
|
+
}),
|
|
196
|
+
);
|
|
182
197
|
};
|
|
183
198
|
|
|
184
199
|
/**
|
|
@@ -188,11 +203,13 @@ export class MarginPoolContract {
|
|
|
188
203
|
*/
|
|
189
204
|
supplyShares = (coinKey: string) => (tx: Transaction) => {
|
|
190
205
|
const marginPool = this.#config.getMarginPool(coinKey);
|
|
191
|
-
return tx.
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
206
|
+
return tx.add(
|
|
207
|
+
marginPoolMoveCalls.supplyShares({
|
|
208
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
209
|
+
arguments: { self: marginPool.address },
|
|
210
|
+
typeArguments: [marginPool.type],
|
|
211
|
+
}),
|
|
212
|
+
);
|
|
196
213
|
};
|
|
197
214
|
|
|
198
215
|
/**
|
|
@@ -202,11 +219,13 @@ export class MarginPoolContract {
|
|
|
202
219
|
*/
|
|
203
220
|
totalBorrow = (coinKey: string) => (tx: Transaction) => {
|
|
204
221
|
const marginPool = this.#config.getMarginPool(coinKey);
|
|
205
|
-
return tx.
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
222
|
+
return tx.add(
|
|
223
|
+
marginPoolMoveCalls.totalBorrow({
|
|
224
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
225
|
+
arguments: { self: marginPool.address },
|
|
226
|
+
typeArguments: [marginPool.type],
|
|
227
|
+
}),
|
|
228
|
+
);
|
|
210
229
|
};
|
|
211
230
|
|
|
212
231
|
/**
|
|
@@ -216,11 +235,13 @@ export class MarginPoolContract {
|
|
|
216
235
|
*/
|
|
217
236
|
borrowShares = (coinKey: string) => (tx: Transaction) => {
|
|
218
237
|
const marginPool = this.#config.getMarginPool(coinKey);
|
|
219
|
-
return tx.
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
238
|
+
return tx.add(
|
|
239
|
+
marginPoolMoveCalls.borrowShares({
|
|
240
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
241
|
+
arguments: { self: marginPool.address },
|
|
242
|
+
typeArguments: [marginPool.type],
|
|
243
|
+
}),
|
|
244
|
+
);
|
|
224
245
|
};
|
|
225
246
|
|
|
226
247
|
/**
|
|
@@ -230,11 +251,13 @@ export class MarginPoolContract {
|
|
|
230
251
|
*/
|
|
231
252
|
lastUpdateTimestamp = (coinKey: string) => (tx: Transaction) => {
|
|
232
253
|
const marginPool = this.#config.getMarginPool(coinKey);
|
|
233
|
-
return tx.
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
254
|
+
return tx.add(
|
|
255
|
+
marginPoolMoveCalls.lastUpdateTimestamp({
|
|
256
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
257
|
+
arguments: { self: marginPool.address },
|
|
258
|
+
typeArguments: [marginPool.type],
|
|
259
|
+
}),
|
|
260
|
+
);
|
|
238
261
|
};
|
|
239
262
|
|
|
240
263
|
/**
|
|
@@ -244,11 +267,13 @@ export class MarginPoolContract {
|
|
|
244
267
|
*/
|
|
245
268
|
supplyCap = (coinKey: string) => (tx: Transaction) => {
|
|
246
269
|
const marginPool = this.#config.getMarginPool(coinKey);
|
|
247
|
-
return tx.
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
270
|
+
return tx.add(
|
|
271
|
+
marginPoolMoveCalls.supplyCap({
|
|
272
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
273
|
+
arguments: { self: marginPool.address },
|
|
274
|
+
typeArguments: [marginPool.type],
|
|
275
|
+
}),
|
|
276
|
+
);
|
|
252
277
|
};
|
|
253
278
|
|
|
254
279
|
/**
|
|
@@ -258,11 +283,13 @@ export class MarginPoolContract {
|
|
|
258
283
|
*/
|
|
259
284
|
maxUtilizationRate = (coinKey: string) => (tx: Transaction) => {
|
|
260
285
|
const marginPool = this.#config.getMarginPool(coinKey);
|
|
261
|
-
return tx.
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
286
|
+
return tx.add(
|
|
287
|
+
marginPoolMoveCalls.maxUtilizationRate({
|
|
288
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
289
|
+
arguments: { self: marginPool.address },
|
|
290
|
+
typeArguments: [marginPool.type],
|
|
291
|
+
}),
|
|
292
|
+
);
|
|
266
293
|
};
|
|
267
294
|
|
|
268
295
|
/**
|
|
@@ -272,11 +299,13 @@ export class MarginPoolContract {
|
|
|
272
299
|
*/
|
|
273
300
|
protocolSpread = (coinKey: string) => (tx: Transaction) => {
|
|
274
301
|
const marginPool = this.#config.getMarginPool(coinKey);
|
|
275
|
-
return tx.
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
302
|
+
return tx.add(
|
|
303
|
+
marginPoolMoveCalls.protocolSpread({
|
|
304
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
305
|
+
arguments: { self: marginPool.address },
|
|
306
|
+
typeArguments: [marginPool.type],
|
|
307
|
+
}),
|
|
308
|
+
);
|
|
280
309
|
};
|
|
281
310
|
|
|
282
311
|
/**
|
|
@@ -286,11 +315,13 @@ export class MarginPoolContract {
|
|
|
286
315
|
*/
|
|
287
316
|
minBorrow = (coinKey: string) => (tx: Transaction) => {
|
|
288
317
|
const marginPool = this.#config.getMarginPool(coinKey);
|
|
289
|
-
return tx.
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
318
|
+
return tx.add(
|
|
319
|
+
marginPoolMoveCalls.minBorrow({
|
|
320
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
321
|
+
arguments: { self: marginPool.address },
|
|
322
|
+
typeArguments: [marginPool.type],
|
|
323
|
+
}),
|
|
324
|
+
);
|
|
294
325
|
};
|
|
295
326
|
|
|
296
327
|
/**
|
|
@@ -300,11 +331,13 @@ export class MarginPoolContract {
|
|
|
300
331
|
*/
|
|
301
332
|
interestRate = (coinKey: string) => (tx: Transaction) => {
|
|
302
333
|
const marginPool = this.#config.getMarginPool(coinKey);
|
|
303
|
-
return tx.
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
334
|
+
return tx.add(
|
|
335
|
+
marginPoolMoveCalls.interestRate({
|
|
336
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
337
|
+
arguments: { self: marginPool.address },
|
|
338
|
+
typeArguments: [marginPool.type],
|
|
339
|
+
}),
|
|
340
|
+
);
|
|
308
341
|
};
|
|
309
342
|
|
|
310
343
|
/**
|
|
@@ -315,11 +348,13 @@ export class MarginPoolContract {
|
|
|
315
348
|
*/
|
|
316
349
|
userSupplyShares = (coinKey: string, supplierCapId: string) => (tx: Transaction) => {
|
|
317
350
|
const marginPool = this.#config.getMarginPool(coinKey);
|
|
318
|
-
return tx.
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
351
|
+
return tx.add(
|
|
352
|
+
marginPoolMoveCalls.userSupplyShares({
|
|
353
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
354
|
+
arguments: { self: marginPool.address, supplierCapId },
|
|
355
|
+
typeArguments: [marginPool.type],
|
|
356
|
+
}),
|
|
357
|
+
);
|
|
323
358
|
};
|
|
324
359
|
|
|
325
360
|
/**
|
|
@@ -330,10 +365,12 @@ export class MarginPoolContract {
|
|
|
330
365
|
*/
|
|
331
366
|
userSupplyAmount = (coinKey: string, supplierCapId: string) => (tx: Transaction) => {
|
|
332
367
|
const marginPool = this.#config.getMarginPool(coinKey);
|
|
333
|
-
return tx.
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
368
|
+
return tx.add(
|
|
369
|
+
marginPoolMoveCalls.userSupplyAmount({
|
|
370
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
371
|
+
arguments: { self: marginPool.address, supplierCapId },
|
|
372
|
+
typeArguments: [marginPool.type],
|
|
373
|
+
}),
|
|
374
|
+
);
|
|
338
375
|
};
|
|
339
376
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import type { Transaction } from '@mysten/sui/transactions';
|
|
4
4
|
|
|
5
5
|
import type { DeepBookConfig } from '../utils/config.js';
|
|
6
|
+
import * as marginRegistryMoveCalls from '../contracts/deepbook_margin/margin_registry.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* MarginRegistryContract class for managing MarginRegistry read-only operations.
|
|
@@ -26,11 +27,13 @@ export class MarginRegistryContract {
|
|
|
26
27
|
const pool = this.#config.getPool(poolKey);
|
|
27
28
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
28
29
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
29
|
-
return tx.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
return tx.add(
|
|
31
|
+
marginRegistryMoveCalls.poolEnabled({
|
|
32
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
33
|
+
arguments: { self: this.#config.MARGIN_REGISTRY_ID, pool: pool.address },
|
|
34
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
34
37
|
};
|
|
35
38
|
|
|
36
39
|
/**
|
|
@@ -40,11 +43,13 @@ export class MarginRegistryContract {
|
|
|
40
43
|
*/
|
|
41
44
|
getMarginPoolId = (coinKey: string) => (tx: Transaction) => {
|
|
42
45
|
const coin = this.#config.getCoin(coinKey);
|
|
43
|
-
return tx.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
return tx.add(
|
|
47
|
+
marginRegistryMoveCalls.getMarginPoolId({
|
|
48
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
49
|
+
arguments: { self: this.#config.MARGIN_REGISTRY_ID },
|
|
50
|
+
typeArguments: [coin.type],
|
|
51
|
+
}),
|
|
52
|
+
);
|
|
48
53
|
};
|
|
49
54
|
|
|
50
55
|
/**
|
|
@@ -54,11 +59,12 @@ export class MarginRegistryContract {
|
|
|
54
59
|
*/
|
|
55
60
|
getDeepbookPoolMarginPoolIds = (poolKey: string) => (tx: Transaction) => {
|
|
56
61
|
const pool = this.#config.getPool(poolKey);
|
|
57
|
-
return tx.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
return tx.add(
|
|
63
|
+
marginRegistryMoveCalls.getDeepbookPoolMarginPoolIds({
|
|
64
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
65
|
+
arguments: { self: this.#config.MARGIN_REGISTRY_ID, deepbookPoolId: pool.address },
|
|
66
|
+
}),
|
|
67
|
+
);
|
|
62
68
|
};
|
|
63
69
|
|
|
64
70
|
/**
|
|
@@ -67,11 +73,12 @@ export class MarginRegistryContract {
|
|
|
67
73
|
* @returns A function that takes a Transaction object
|
|
68
74
|
*/
|
|
69
75
|
getMarginManagerIds = (owner: string) => (tx: Transaction) => {
|
|
70
|
-
return tx.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
76
|
+
return tx.add(
|
|
77
|
+
marginRegistryMoveCalls.getMarginManagerIds({
|
|
78
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
79
|
+
arguments: { self: this.#config.MARGIN_REGISTRY_ID, owner },
|
|
80
|
+
}),
|
|
81
|
+
);
|
|
75
82
|
};
|
|
76
83
|
|
|
77
84
|
/**
|
|
@@ -81,11 +88,12 @@ export class MarginRegistryContract {
|
|
|
81
88
|
*/
|
|
82
89
|
baseMarginPoolId = (poolKey: string) => (tx: Transaction) => {
|
|
83
90
|
const pool = this.#config.getPool(poolKey);
|
|
84
|
-
return tx.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
91
|
+
return tx.add(
|
|
92
|
+
marginRegistryMoveCalls.baseMarginPoolId({
|
|
93
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
94
|
+
arguments: { self: this.#config.MARGIN_REGISTRY_ID, deepbookPoolId: pool.address },
|
|
95
|
+
}),
|
|
96
|
+
);
|
|
89
97
|
};
|
|
90
98
|
|
|
91
99
|
/**
|
|
@@ -95,11 +103,12 @@ export class MarginRegistryContract {
|
|
|
95
103
|
*/
|
|
96
104
|
quoteMarginPoolId = (poolKey: string) => (tx: Transaction) => {
|
|
97
105
|
const pool = this.#config.getPool(poolKey);
|
|
98
|
-
return tx.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
106
|
+
return tx.add(
|
|
107
|
+
marginRegistryMoveCalls.quoteMarginPoolId({
|
|
108
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
109
|
+
arguments: { self: this.#config.MARGIN_REGISTRY_ID, deepbookPoolId: pool.address },
|
|
110
|
+
}),
|
|
111
|
+
);
|
|
103
112
|
};
|
|
104
113
|
|
|
105
114
|
/**
|
|
@@ -109,11 +118,12 @@ export class MarginRegistryContract {
|
|
|
109
118
|
*/
|
|
110
119
|
minWithdrawRiskRatio = (poolKey: string) => (tx: Transaction) => {
|
|
111
120
|
const pool = this.#config.getPool(poolKey);
|
|
112
|
-
return tx.
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
121
|
+
return tx.add(
|
|
122
|
+
marginRegistryMoveCalls.minWithdrawRiskRatio({
|
|
123
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
124
|
+
arguments: { self: this.#config.MARGIN_REGISTRY_ID, deepbookPoolId: pool.address },
|
|
125
|
+
}),
|
|
126
|
+
);
|
|
117
127
|
};
|
|
118
128
|
|
|
119
129
|
/**
|
|
@@ -123,11 +133,28 @@ export class MarginRegistryContract {
|
|
|
123
133
|
*/
|
|
124
134
|
minBorrowRiskRatio = (poolKey: string) => (tx: Transaction) => {
|
|
125
135
|
const pool = this.#config.getPool(poolKey);
|
|
126
|
-
return tx.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
136
|
+
return tx.add(
|
|
137
|
+
marginRegistryMoveCalls.minBorrowRiskRatio({
|
|
138
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
139
|
+
arguments: { self: this.#config.MARGIN_REGISTRY_ID, deepbookPoolId: pool.address },
|
|
140
|
+
}),
|
|
141
|
+
);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @description Get the minimum risk ratio required to open a new position on
|
|
146
|
+
* a deepbook pool. Distinct from `minBorrowRiskRatio`, which gates borrowing.
|
|
147
|
+
* @param {string} poolKey The key to identify the pool
|
|
148
|
+
* @returns A function that takes a Transaction object
|
|
149
|
+
*/
|
|
150
|
+
minOpenRiskRatio = (poolKey: string) => (tx: Transaction) => {
|
|
151
|
+
const pool = this.#config.getPool(poolKey);
|
|
152
|
+
return tx.add(
|
|
153
|
+
marginRegistryMoveCalls.minOpenRiskRatio({
|
|
154
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
155
|
+
arguments: { self: this.#config.MARGIN_REGISTRY_ID, deepbookPoolId: pool.address },
|
|
156
|
+
}),
|
|
157
|
+
);
|
|
131
158
|
};
|
|
132
159
|
|
|
133
160
|
/**
|
|
@@ -137,11 +164,12 @@ export class MarginRegistryContract {
|
|
|
137
164
|
*/
|
|
138
165
|
liquidationRiskRatio = (poolKey: string) => (tx: Transaction) => {
|
|
139
166
|
const pool = this.#config.getPool(poolKey);
|
|
140
|
-
return tx.
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
167
|
+
return tx.add(
|
|
168
|
+
marginRegistryMoveCalls.liquidationRiskRatio({
|
|
169
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
170
|
+
arguments: { self: this.#config.MARGIN_REGISTRY_ID, deepbookPoolId: pool.address },
|
|
171
|
+
}),
|
|
172
|
+
);
|
|
145
173
|
};
|
|
146
174
|
|
|
147
175
|
/**
|
|
@@ -151,11 +179,12 @@ export class MarginRegistryContract {
|
|
|
151
179
|
*/
|
|
152
180
|
targetLiquidationRiskRatio = (poolKey: string) => (tx: Transaction) => {
|
|
153
181
|
const pool = this.#config.getPool(poolKey);
|
|
154
|
-
return tx.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
182
|
+
return tx.add(
|
|
183
|
+
marginRegistryMoveCalls.targetLiquidationRiskRatio({
|
|
184
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
185
|
+
arguments: { self: this.#config.MARGIN_REGISTRY_ID, deepbookPoolId: pool.address },
|
|
186
|
+
}),
|
|
187
|
+
);
|
|
159
188
|
};
|
|
160
189
|
|
|
161
190
|
/**
|
|
@@ -165,11 +194,12 @@ export class MarginRegistryContract {
|
|
|
165
194
|
*/
|
|
166
195
|
userLiquidationReward = (poolKey: string) => (tx: Transaction) => {
|
|
167
196
|
const pool = this.#config.getPool(poolKey);
|
|
168
|
-
return tx.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
197
|
+
return tx.add(
|
|
198
|
+
marginRegistryMoveCalls.userLiquidationReward({
|
|
199
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
200
|
+
arguments: { self: this.#config.MARGIN_REGISTRY_ID, deepbookPoolId: pool.address },
|
|
201
|
+
}),
|
|
202
|
+
);
|
|
173
203
|
};
|
|
174
204
|
|
|
175
205
|
/**
|
|
@@ -179,11 +209,12 @@ export class MarginRegistryContract {
|
|
|
179
209
|
*/
|
|
180
210
|
poolLiquidationReward = (poolKey: string) => (tx: Transaction) => {
|
|
181
211
|
const pool = this.#config.getPool(poolKey);
|
|
182
|
-
return tx.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
212
|
+
return tx.add(
|
|
213
|
+
marginRegistryMoveCalls.poolLiquidationReward({
|
|
214
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
215
|
+
arguments: { self: this.#config.MARGIN_REGISTRY_ID, deepbookPoolId: pool.address },
|
|
216
|
+
}),
|
|
217
|
+
);
|
|
187
218
|
};
|
|
188
219
|
|
|
189
220
|
/**
|
|
@@ -191,11 +222,12 @@ export class MarginRegistryContract {
|
|
|
191
222
|
* @returns A function that takes a Transaction object
|
|
192
223
|
*/
|
|
193
224
|
allowedMaintainers = () => (tx: Transaction) => {
|
|
194
|
-
return tx.
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
225
|
+
return tx.add(
|
|
226
|
+
marginRegistryMoveCalls.allowedMaintainers({
|
|
227
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
228
|
+
arguments: { self: this.#config.MARGIN_REGISTRY_ID },
|
|
229
|
+
}),
|
|
230
|
+
);
|
|
199
231
|
};
|
|
200
232
|
|
|
201
233
|
/**
|
|
@@ -203,10 +235,11 @@ export class MarginRegistryContract {
|
|
|
203
235
|
* @returns A function that takes a Transaction object
|
|
204
236
|
*/
|
|
205
237
|
allowedPauseCaps = () => (tx: Transaction) => {
|
|
206
|
-
return tx.
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
238
|
+
return tx.add(
|
|
239
|
+
marginRegistryMoveCalls.allowedPauseCaps({
|
|
240
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
241
|
+
arguments: { self: this.#config.MARGIN_REGISTRY_ID },
|
|
242
|
+
}),
|
|
243
|
+
);
|
|
211
244
|
};
|
|
212
245
|
}
|