@mysten/deepbook-v3 1.5.9 → 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 +60 -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/balance_manager.mjs +413 -0
- package/dist/contracts/deepbook/balance_manager.mjs.map +1 -0
- package/dist/contracts/deepbook/balances.d.mts +4 -4
- 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.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 +10 -0
- 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.map +1 -1
- package/dist/transactions/marginMaintainer.mjs +83 -83
- package/dist/transactions/marginMaintainer.mjs.map +1 -1
- package/dist/transactions/marginManager.d.mts.map +1 -1
- package/dist/transactions/marginManager.mjs +330 -311
- package/dist/transactions/marginManager.mjs.map +1 -1
- 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 +32 -0
- 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 +2 -2
- 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
|
@@ -7,6 +7,8 @@ import type { CreatePoolAdminParams, SetEwmaParams } from '../types/index.js';
|
|
|
7
7
|
import type { DeepBookConfig } from '../utils/config.js';
|
|
8
8
|
import { FLOAT_SCALAR } from '../utils/config.js';
|
|
9
9
|
import { convertQuantity, convertPrice, convertRate } from '../utils/conversion.js';
|
|
10
|
+
import * as poolMoveCalls from '../contracts/deepbook/pool.js';
|
|
11
|
+
import * as registryMoveCalls from '../contracts/deepbook/registry.js';
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* DeepBookAdminContract class for managing admin actions.
|
|
@@ -52,19 +54,21 @@ export class DeepBookAdminContract {
|
|
|
52
54
|
const adjustedLotSize = convertQuantity(lotSize, baseScalar);
|
|
53
55
|
const adjustedMinSize = convertQuantity(minSize, baseScalar);
|
|
54
56
|
|
|
55
|
-
tx.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
57
|
+
tx.add(
|
|
58
|
+
poolMoveCalls.createPoolAdmin({
|
|
59
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
60
|
+
arguments: {
|
|
61
|
+
registry: this.#config.REGISTRY_ID,
|
|
62
|
+
tickSize: adjustedTickSize,
|
|
63
|
+
lotSize: adjustedLotSize,
|
|
64
|
+
minSize: adjustedMinSize,
|
|
65
|
+
whitelistedPool: whitelisted,
|
|
66
|
+
stablePool,
|
|
67
|
+
Cap: this.#adminCap(),
|
|
68
|
+
},
|
|
69
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
70
|
+
}),
|
|
71
|
+
);
|
|
68
72
|
};
|
|
69
73
|
|
|
70
74
|
/**
|
|
@@ -76,15 +80,17 @@ export class DeepBookAdminContract {
|
|
|
76
80
|
const pool = this.#config.getPool(poolKey);
|
|
77
81
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
78
82
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
79
|
-
tx.
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
83
|
+
tx.add(
|
|
84
|
+
poolMoveCalls.unregisterPoolAdmin({
|
|
85
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
86
|
+
arguments: {
|
|
87
|
+
self: pool.address,
|
|
88
|
+
registry: this.#config.REGISTRY_ID,
|
|
89
|
+
Cap: this.#adminCap(),
|
|
90
|
+
},
|
|
91
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
92
|
+
}),
|
|
93
|
+
);
|
|
88
94
|
};
|
|
89
95
|
|
|
90
96
|
/**
|
|
@@ -96,15 +102,17 @@ export class DeepBookAdminContract {
|
|
|
96
102
|
const pool = this.#config.getPool(poolKey);
|
|
97
103
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
98
104
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
99
|
-
tx.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
tx.add(
|
|
106
|
+
poolMoveCalls.updateAllowedVersions({
|
|
107
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
108
|
+
arguments: {
|
|
109
|
+
self: pool.address,
|
|
110
|
+
registry: this.#config.REGISTRY_ID,
|
|
111
|
+
Cap: this.#adminCap(),
|
|
112
|
+
},
|
|
113
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
114
|
+
}),
|
|
115
|
+
);
|
|
108
116
|
};
|
|
109
117
|
|
|
110
118
|
/**
|
|
@@ -113,14 +121,12 @@ export class DeepBookAdminContract {
|
|
|
113
121
|
* @returns A function that takes a Transaction object
|
|
114
122
|
*/
|
|
115
123
|
enableVersion = (version: number) => (tx: Transaction) => {
|
|
116
|
-
tx.
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
],
|
|
123
|
-
});
|
|
124
|
+
tx.add(
|
|
125
|
+
registryMoveCalls.enableVersion({
|
|
126
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
127
|
+
arguments: { self: this.#config.REGISTRY_ID, version, Cap: this.#adminCap() },
|
|
128
|
+
}),
|
|
129
|
+
);
|
|
124
130
|
};
|
|
125
131
|
|
|
126
132
|
/**
|
|
@@ -129,14 +135,12 @@ export class DeepBookAdminContract {
|
|
|
129
135
|
* @returns A function that takes a Transaction object
|
|
130
136
|
*/
|
|
131
137
|
disableVersion = (version: number) => (tx: Transaction) => {
|
|
132
|
-
tx.
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
],
|
|
139
|
-
});
|
|
138
|
+
tx.add(
|
|
139
|
+
registryMoveCalls.disableVersion({
|
|
140
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
141
|
+
arguments: { self: this.#config.REGISTRY_ID, version, Cap: this.#adminCap() },
|
|
142
|
+
}),
|
|
143
|
+
);
|
|
140
144
|
};
|
|
141
145
|
|
|
142
146
|
/**
|
|
@@ -145,14 +149,12 @@ export class DeepBookAdminContract {
|
|
|
145
149
|
* @returns A function that takes a Transaction object
|
|
146
150
|
*/
|
|
147
151
|
setTreasuryAddress = (treasuryAddress: string) => (tx: Transaction) => {
|
|
148
|
-
tx.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
],
|
|
155
|
-
});
|
|
152
|
+
tx.add(
|
|
153
|
+
registryMoveCalls.setTreasuryAddress({
|
|
154
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
155
|
+
arguments: { self: this.#config.REGISTRY_ID, treasuryAddress, Cap: this.#adminCap() },
|
|
156
|
+
}),
|
|
157
|
+
);
|
|
156
158
|
};
|
|
157
159
|
|
|
158
160
|
/**
|
|
@@ -162,11 +164,13 @@ export class DeepBookAdminContract {
|
|
|
162
164
|
*/
|
|
163
165
|
addStableCoin = (stableCoinKey: string) => (tx: Transaction) => {
|
|
164
166
|
const stableCoinType = this.#config.getCoin(stableCoinKey).type;
|
|
165
|
-
tx.
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
167
|
+
tx.add(
|
|
168
|
+
registryMoveCalls.addStablecoin({
|
|
169
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
170
|
+
arguments: { self: this.#config.REGISTRY_ID, Cap: this.#adminCap() },
|
|
171
|
+
typeArguments: [stableCoinType],
|
|
172
|
+
}),
|
|
173
|
+
);
|
|
170
174
|
};
|
|
171
175
|
|
|
172
176
|
/**
|
|
@@ -176,11 +180,13 @@ export class DeepBookAdminContract {
|
|
|
176
180
|
*/
|
|
177
181
|
removeStableCoin = (stableCoinKey: string) => (tx: Transaction) => {
|
|
178
182
|
const stableCoinType = this.#config.getCoin(stableCoinKey).type;
|
|
179
|
-
tx.
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
183
|
+
tx.add(
|
|
184
|
+
registryMoveCalls.removeStablecoin({
|
|
185
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
186
|
+
arguments: { self: this.#config.REGISTRY_ID, Cap: this.#adminCap() },
|
|
187
|
+
typeArguments: [stableCoinType],
|
|
188
|
+
}),
|
|
189
|
+
);
|
|
184
190
|
};
|
|
185
191
|
|
|
186
192
|
/**
|
|
@@ -200,16 +206,13 @@ export class DeepBookAdminContract {
|
|
|
200
206
|
|
|
201
207
|
const adjustedTickSize = convertPrice(newTickSize, FLOAT_SCALAR, quoteScalar, baseScalar);
|
|
202
208
|
|
|
203
|
-
tx.
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
],
|
|
211
|
-
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
212
|
-
});
|
|
209
|
+
tx.add(
|
|
210
|
+
poolMoveCalls.adjustTickSizeAdmin({
|
|
211
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
212
|
+
arguments: { self: pool.address, newTickSize: adjustedTickSize, Cap: this.#adminCap() },
|
|
213
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
214
|
+
}),
|
|
215
|
+
);
|
|
213
216
|
};
|
|
214
217
|
|
|
215
218
|
/**
|
|
@@ -231,17 +234,18 @@ export class DeepBookAdminContract {
|
|
|
231
234
|
const adjustedLotSize = convertQuantity(newLotSize, baseScalar);
|
|
232
235
|
const adjustedMinSize = convertQuantity(newMinSize, baseScalar);
|
|
233
236
|
|
|
234
|
-
tx.
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
237
|
+
tx.add(
|
|
238
|
+
poolMoveCalls.adjustMinLotSizeAdmin({
|
|
239
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
240
|
+
arguments: {
|
|
241
|
+
self: pool.address,
|
|
242
|
+
newLotSize: adjustedLotSize,
|
|
243
|
+
newMinSize: adjustedMinSize,
|
|
244
|
+
Cap: this.#adminCap(),
|
|
245
|
+
},
|
|
246
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
247
|
+
}),
|
|
248
|
+
);
|
|
245
249
|
};
|
|
246
250
|
|
|
247
251
|
/**
|
|
@@ -249,10 +253,12 @@ export class DeepBookAdminContract {
|
|
|
249
253
|
* @returns A function that takes a Transaction object
|
|
250
254
|
*/
|
|
251
255
|
initBalanceManagerMap = () => (tx: Transaction) => {
|
|
252
|
-
tx.
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
+
tx.add(
|
|
257
|
+
registryMoveCalls.initBalanceManagerMap({
|
|
258
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
259
|
+
arguments: { self: this.#config.REGISTRY_ID, Cap: this.#adminCap() },
|
|
260
|
+
}),
|
|
261
|
+
);
|
|
256
262
|
};
|
|
257
263
|
|
|
258
264
|
/**
|
|
@@ -270,18 +276,19 @@ export class DeepBookAdminContract {
|
|
|
270
276
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
271
277
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
272
278
|
|
|
273
|
-
tx.
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
279
|
+
tx.add(
|
|
280
|
+
poolMoveCalls.setEwmaParams({
|
|
281
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
282
|
+
arguments: {
|
|
283
|
+
self: pool.address,
|
|
284
|
+
Cap: this.#adminCap(),
|
|
285
|
+
alpha: adjustedAlpha,
|
|
286
|
+
zScoreThreshold: adjustedZScoreThreshold,
|
|
287
|
+
additionalTakerFee: adjustedAdditionalTakerFee,
|
|
288
|
+
},
|
|
289
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
290
|
+
}),
|
|
291
|
+
);
|
|
285
292
|
};
|
|
286
293
|
|
|
287
294
|
/**
|
|
@@ -295,16 +302,13 @@ export class DeepBookAdminContract {
|
|
|
295
302
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
296
303
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
297
304
|
|
|
298
|
-
tx.
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
],
|
|
306
|
-
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
307
|
-
});
|
|
305
|
+
tx.add(
|
|
306
|
+
poolMoveCalls.enableEwmaState({
|
|
307
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
308
|
+
arguments: { self: pool.address, Cap: this.#adminCap(), enable },
|
|
309
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
310
|
+
}),
|
|
311
|
+
);
|
|
308
312
|
};
|
|
309
313
|
|
|
310
314
|
/**
|
|
@@ -312,11 +316,13 @@ export class DeepBookAdminContract {
|
|
|
312
316
|
* @returns A function that takes a Transaction object
|
|
313
317
|
*/
|
|
314
318
|
authorizeMarginApp = () => (tx: Transaction) => {
|
|
315
|
-
tx.
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
319
|
+
tx.add(
|
|
320
|
+
registryMoveCalls.authorizeApp({
|
|
321
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
322
|
+
arguments: { self: this.#config.REGISTRY_ID, AdminCap: this.#adminCap() },
|
|
323
|
+
typeArguments: [`${this.#config.MARGIN_V1}::margin_manager::MarginApp`],
|
|
324
|
+
}),
|
|
325
|
+
);
|
|
320
326
|
};
|
|
321
327
|
|
|
322
328
|
/**
|
|
@@ -324,11 +330,13 @@ export class DeepBookAdminContract {
|
|
|
324
330
|
* @returns A function that takes a Transaction object and returns a bool
|
|
325
331
|
*/
|
|
326
332
|
deauthorizeMarginApp = () => (tx: Transaction) => {
|
|
327
|
-
return tx.
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
333
|
+
return tx.add(
|
|
334
|
+
registryMoveCalls.deauthorizeApp({
|
|
335
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
336
|
+
arguments: { self: this.#config.REGISTRY_ID, AdminCap: this.#adminCap() },
|
|
337
|
+
typeArguments: [`${this.#config.MARGIN_V1}::margin_manager::MarginApp`],
|
|
338
|
+
}),
|
|
339
|
+
);
|
|
332
340
|
};
|
|
333
341
|
|
|
334
342
|
/**
|
|
@@ -339,10 +347,12 @@ export class DeepBookAdminContract {
|
|
|
339
347
|
* @returns A function that takes a Transaction object and returns the new pause cap
|
|
340
348
|
*/
|
|
341
349
|
mintCorePauseCap = () => (tx: Transaction) => {
|
|
342
|
-
return tx.
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
350
|
+
return tx.add(
|
|
351
|
+
registryMoveCalls.mintPauseCap({
|
|
352
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
353
|
+
arguments: { self: this.#config.REGISTRY_ID, Cap: this.#adminCap() },
|
|
354
|
+
}),
|
|
355
|
+
);
|
|
346
356
|
};
|
|
347
357
|
|
|
348
358
|
/**
|
|
@@ -351,14 +361,12 @@ export class DeepBookAdminContract {
|
|
|
351
361
|
* @returns A function that takes a Transaction object
|
|
352
362
|
*/
|
|
353
363
|
revokeCorePauseCap = (pauseCapId: string) => (tx: Transaction) => {
|
|
354
|
-
tx.
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
],
|
|
361
|
-
});
|
|
364
|
+
tx.add(
|
|
365
|
+
registryMoveCalls.revokePauseCap({
|
|
366
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
367
|
+
arguments: { self: this.#config.REGISTRY_ID, Cap: this.#adminCap(), pauseCapId },
|
|
368
|
+
}),
|
|
369
|
+
);
|
|
362
370
|
};
|
|
363
371
|
|
|
364
372
|
/**
|
|
@@ -371,14 +379,12 @@ export class DeepBookAdminContract {
|
|
|
371
379
|
*/
|
|
372
380
|
disableVersionWithCorePauseCap =
|
|
373
381
|
(version: number | bigint, pauseCapId: string) => (tx: Transaction) => {
|
|
374
|
-
tx.
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
],
|
|
381
|
-
});
|
|
382
|
+
tx.add(
|
|
383
|
+
registryMoveCalls.disableVersionPauseCap({
|
|
384
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
385
|
+
arguments: { self: this.#config.REGISTRY_ID, version, pauseCap: pauseCapId },
|
|
386
|
+
}),
|
|
387
|
+
);
|
|
382
388
|
};
|
|
383
389
|
|
|
384
390
|
/**
|
|
@@ -387,9 +393,11 @@ export class DeepBookAdminContract {
|
|
|
387
393
|
* @returns A function that takes a Transaction object and returns a `VecSet<ID>`
|
|
388
394
|
*/
|
|
389
395
|
corePauseCaps = () => (tx: Transaction) => {
|
|
390
|
-
return tx.
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
396
|
+
return tx.add(
|
|
397
|
+
registryMoveCalls.allowedPauseCaps({
|
|
398
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
399
|
+
arguments: { self: this.#config.REGISTRY_ID },
|
|
400
|
+
}),
|
|
401
|
+
);
|
|
394
402
|
};
|
|
395
403
|
}
|
|
@@ -4,6 +4,7 @@ import type { Transaction, TransactionObjectArgument } from '@mysten/sui/transac
|
|
|
4
4
|
|
|
5
5
|
import type { DeepBookConfig } from '../utils/config.js';
|
|
6
6
|
import { convertQuantity } from '../utils/conversion.js';
|
|
7
|
+
import * as poolMoveCalls from '../contracts/deepbook/pool.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* FlashLoanContract class for managing flash loans.
|
|
@@ -29,11 +30,13 @@ export class FlashLoanContract {
|
|
|
29
30
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
30
31
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
31
32
|
const inputQuantity = convertQuantity(borrowAmount, baseCoin.scalar);
|
|
32
|
-
const [baseCoinResult, flashLoan] = tx.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
const [baseCoinResult, flashLoan] = tx.add(
|
|
34
|
+
poolMoveCalls.borrowFlashloanBase({
|
|
35
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
36
|
+
arguments: { self: pool.address, baseAmount: inputQuantity },
|
|
37
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
38
|
+
}),
|
|
39
|
+
);
|
|
37
40
|
return [baseCoinResult, flashLoan] as const;
|
|
38
41
|
};
|
|
39
42
|
|
|
@@ -61,11 +64,13 @@ export class FlashLoanContract {
|
|
|
61
64
|
const [baseCoinReturn] = tx.splitCoins(baseCoinInput, [
|
|
62
65
|
tx.pure.u64(convertQuantity(borrowAmount, borrowScalar)),
|
|
63
66
|
]);
|
|
64
|
-
tx.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
tx.add(
|
|
68
|
+
poolMoveCalls.returnFlashloanBase({
|
|
69
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
70
|
+
arguments: { self: pool.address, coin: baseCoinReturn, flashLoan },
|
|
71
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
72
|
+
}),
|
|
73
|
+
);
|
|
69
74
|
|
|
70
75
|
return baseCoinInput;
|
|
71
76
|
};
|
|
@@ -81,11 +86,13 @@ export class FlashLoanContract {
|
|
|
81
86
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
82
87
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
83
88
|
const inputQuantity = convertQuantity(borrowAmount, quoteCoin.scalar);
|
|
84
|
-
const [quoteCoinResult, flashLoan] = tx.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
const [quoteCoinResult, flashLoan] = tx.add(
|
|
90
|
+
poolMoveCalls.borrowFlashloanQuote({
|
|
91
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
92
|
+
arguments: { self: pool.address, quoteAmount: inputQuantity },
|
|
93
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
94
|
+
}),
|
|
95
|
+
);
|
|
89
96
|
return [quoteCoinResult, flashLoan] as const;
|
|
90
97
|
};
|
|
91
98
|
|
|
@@ -113,11 +120,13 @@ export class FlashLoanContract {
|
|
|
113
120
|
const [quoteCoinReturn] = tx.splitCoins(quoteCoinInput, [
|
|
114
121
|
tx.pure.u64(convertQuantity(borrowAmount, borrowScalar)),
|
|
115
122
|
]);
|
|
116
|
-
tx.
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
123
|
+
tx.add(
|
|
124
|
+
poolMoveCalls.returnFlashloanQuote({
|
|
125
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
126
|
+
arguments: { self: pool.address, coin: quoteCoinReturn, flashLoan },
|
|
127
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
128
|
+
}),
|
|
129
|
+
);
|
|
121
130
|
|
|
122
131
|
return quoteCoinInput;
|
|
123
132
|
};
|
|
@@ -6,6 +6,7 @@ import type { ProposalParams } from '../types/index.js';
|
|
|
6
6
|
import type { DeepBookConfig } from '../utils/config.js';
|
|
7
7
|
import { DEEP_SCALAR, FLOAT_SCALAR } from '../utils/config.js';
|
|
8
8
|
import { convertQuantity, convertRate } from '../utils/conversion.js';
|
|
9
|
+
import * as poolMoveCalls from '../contracts/deepbook/pool.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* GovernanceContract class for managing governance operations in DeepBook.
|
|
@@ -36,16 +37,18 @@ export class GovernanceContract {
|
|
|
36
37
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
37
38
|
const stakeInput = convertQuantity(stakeAmount, DEEP_SCALAR);
|
|
38
39
|
|
|
39
|
-
tx.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
tx.add(
|
|
41
|
+
poolMoveCalls.stake({
|
|
42
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
43
|
+
arguments: {
|
|
44
|
+
self: pool.address,
|
|
45
|
+
balanceManager: balanceManager.address,
|
|
46
|
+
tradeProof,
|
|
47
|
+
amount: stakeInput,
|
|
48
|
+
},
|
|
49
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
50
|
+
}),
|
|
51
|
+
);
|
|
49
52
|
};
|
|
50
53
|
|
|
51
54
|
/**
|
|
@@ -61,11 +64,17 @@ export class GovernanceContract {
|
|
|
61
64
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
62
65
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
63
66
|
|
|
64
|
-
tx.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
tx.add(
|
|
68
|
+
poolMoveCalls.unstake({
|
|
69
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
70
|
+
arguments: {
|
|
71
|
+
self: pool.address,
|
|
72
|
+
balanceManager: balanceManager.address,
|
|
73
|
+
tradeProof,
|
|
74
|
+
},
|
|
75
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
76
|
+
}),
|
|
77
|
+
);
|
|
69
78
|
};
|
|
70
79
|
|
|
71
80
|
/**
|
|
@@ -82,18 +91,20 @@ export class GovernanceContract {
|
|
|
82
91
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
83
92
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
84
93
|
|
|
85
|
-
tx.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
tx.add(
|
|
95
|
+
poolMoveCalls.submitProposal({
|
|
96
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
97
|
+
arguments: {
|
|
98
|
+
self: pool.address,
|
|
99
|
+
balanceManager: balanceManager.address,
|
|
100
|
+
tradeProof,
|
|
101
|
+
takerFee: convertRate(takerFee, FLOAT_SCALAR),
|
|
102
|
+
makerFee: convertRate(makerFee, FLOAT_SCALAR),
|
|
103
|
+
stakeRequired: convertQuantity(stakeRequired, DEEP_SCALAR),
|
|
104
|
+
},
|
|
105
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
106
|
+
}),
|
|
107
|
+
);
|
|
97
108
|
};
|
|
98
109
|
|
|
99
110
|
/**
|
|
@@ -110,15 +121,17 @@ export class GovernanceContract {
|
|
|
110
121
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
111
122
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
112
123
|
|
|
113
|
-
tx.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
124
|
+
tx.add(
|
|
125
|
+
poolMoveCalls.vote({
|
|
126
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
127
|
+
arguments: {
|
|
128
|
+
self: pool.address,
|
|
129
|
+
balanceManager: balanceManager.address,
|
|
130
|
+
tradeProof,
|
|
131
|
+
proposalId: proposal_id,
|
|
132
|
+
},
|
|
133
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
134
|
+
}),
|
|
135
|
+
);
|
|
123
136
|
};
|
|
124
137
|
}
|