@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
|
@@ -7,6 +7,7 @@ import type { DeepBookConfig } from '../utils/config.js';
|
|
|
7
7
|
import type { DepositParams, DepositDuringInitParams } from '../types/index.js';
|
|
8
8
|
import { FLOAT_SCALAR } from '../utils/config.js';
|
|
9
9
|
import { convertPrice, convertQuantity } from '../utils/conversion.js';
|
|
10
|
+
import * as marginManagerMoveCalls from '../contracts/deepbook_margin/margin_manager.js';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* MarginManagerContract class for managing MarginManager operations.
|
|
@@ -30,16 +31,17 @@ export class MarginManagerContract {
|
|
|
30
31
|
const pool = this.#config.getPool(poolKey);
|
|
31
32
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
32
33
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
33
|
-
tx.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
tx.add(
|
|
35
|
+
marginManagerMoveCalls._new({
|
|
36
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
37
|
+
arguments: {
|
|
38
|
+
pool: pool.address,
|
|
39
|
+
deepbookRegistry: this.#config.REGISTRY_ID,
|
|
40
|
+
marginRegistry: this.#config.MARGIN_REGISTRY_ID,
|
|
41
|
+
},
|
|
42
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
43
|
+
}),
|
|
44
|
+
);
|
|
43
45
|
};
|
|
44
46
|
|
|
45
47
|
/**
|
|
@@ -51,16 +53,17 @@ export class MarginManagerContract {
|
|
|
51
53
|
const pool = this.#config.getPool(poolKey);
|
|
52
54
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
53
55
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
54
|
-
const [manager, initializer] = tx.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
56
|
+
const [manager, initializer] = tx.add(
|
|
57
|
+
marginManagerMoveCalls.newWithInitializer({
|
|
58
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
59
|
+
arguments: {
|
|
60
|
+
pool: pool.address,
|
|
61
|
+
deepbookRegistry: this.#config.REGISTRY_ID,
|
|
62
|
+
marginRegistry: this.#config.MARGIN_REGISTRY_ID,
|
|
63
|
+
},
|
|
64
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
65
|
+
}),
|
|
66
|
+
);
|
|
64
67
|
return { manager, initializer };
|
|
65
68
|
};
|
|
66
69
|
|
|
@@ -77,11 +80,13 @@ export class MarginManagerContract {
|
|
|
77
80
|
const pool = this.#config.getPool(poolKey);
|
|
78
81
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
79
82
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
80
|
-
tx.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
tx.add(
|
|
84
|
+
marginManagerMoveCalls.share({
|
|
85
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
86
|
+
arguments: { manager, initializer },
|
|
87
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
88
|
+
}),
|
|
89
|
+
);
|
|
85
90
|
};
|
|
86
91
|
|
|
87
92
|
/**
|
|
@@ -96,11 +101,13 @@ export class MarginManagerContract {
|
|
|
96
101
|
const pool = this.#config.getPool(manager.poolKey);
|
|
97
102
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
98
103
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
99
|
-
tx.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
+
tx.add(
|
|
105
|
+
marginManagerMoveCalls.registerMarginManager({
|
|
106
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
107
|
+
arguments: { self: manager.address, marginRegistry: this.#config.MARGIN_REGISTRY_ID },
|
|
108
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
109
|
+
}),
|
|
110
|
+
);
|
|
104
111
|
};
|
|
105
112
|
|
|
106
113
|
/**
|
|
@@ -114,11 +121,13 @@ export class MarginManagerContract {
|
|
|
114
121
|
const pool = this.#config.getPool(manager.poolKey);
|
|
115
122
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
116
123
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
117
|
-
tx.
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
124
|
+
tx.add(
|
|
125
|
+
marginManagerMoveCalls.unregisterMarginManager({
|
|
126
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
127
|
+
arguments: { self: manager.address, marginRegistry: this.#config.MARGIN_REGISTRY_ID },
|
|
128
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
129
|
+
}),
|
|
130
|
+
);
|
|
122
131
|
};
|
|
123
132
|
|
|
124
133
|
/**
|
|
@@ -145,18 +154,19 @@ export class MarginManagerContract {
|
|
|
145
154
|
})
|
|
146
155
|
: params.coin;
|
|
147
156
|
|
|
148
|
-
tx.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
tx.add(
|
|
158
|
+
marginManagerMoveCalls.deposit({
|
|
159
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
160
|
+
arguments: {
|
|
161
|
+
self: manager,
|
|
162
|
+
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
163
|
+
baseOracle: baseCoin.priceInfoObjectId!,
|
|
164
|
+
quoteOracle: quoteCoin.priceInfoObjectId!,
|
|
165
|
+
coin,
|
|
166
|
+
},
|
|
167
|
+
typeArguments: [baseCoin.type, quoteCoin.type, depositCoin.type],
|
|
168
|
+
}),
|
|
169
|
+
);
|
|
160
170
|
};
|
|
161
171
|
|
|
162
172
|
/**
|
|
@@ -177,18 +187,19 @@ export class MarginManagerContract {
|
|
|
177
187
|
balance: convertQuantity(params.amount, baseCoin.scalar),
|
|
178
188
|
})
|
|
179
189
|
: params.coin;
|
|
180
|
-
tx.
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
190
|
+
tx.add(
|
|
191
|
+
marginManagerMoveCalls.deposit({
|
|
192
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
193
|
+
arguments: {
|
|
194
|
+
self: manager.address,
|
|
195
|
+
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
196
|
+
baseOracle: baseCoin.priceInfoObjectId!,
|
|
197
|
+
quoteOracle: quoteCoin.priceInfoObjectId!,
|
|
198
|
+
coin,
|
|
199
|
+
},
|
|
200
|
+
typeArguments: [baseCoin.type, quoteCoin.type, baseCoin.type],
|
|
201
|
+
}),
|
|
202
|
+
);
|
|
192
203
|
};
|
|
193
204
|
|
|
194
205
|
/**
|
|
@@ -209,18 +220,19 @@ export class MarginManagerContract {
|
|
|
209
220
|
balance: convertQuantity(params.amount, quoteCoin.scalar),
|
|
210
221
|
})
|
|
211
222
|
: params.coin;
|
|
212
|
-
tx.
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
223
|
+
tx.add(
|
|
224
|
+
marginManagerMoveCalls.deposit({
|
|
225
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
226
|
+
arguments: {
|
|
227
|
+
self: manager.address,
|
|
228
|
+
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
229
|
+
baseOracle: baseCoin.priceInfoObjectId!,
|
|
230
|
+
quoteOracle: quoteCoin.priceInfoObjectId!,
|
|
231
|
+
coin,
|
|
232
|
+
},
|
|
233
|
+
typeArguments: [baseCoin.type, quoteCoin.type, quoteCoin.type],
|
|
234
|
+
}),
|
|
235
|
+
);
|
|
224
236
|
};
|
|
225
237
|
|
|
226
238
|
/**
|
|
@@ -242,18 +254,19 @@ export class MarginManagerContract {
|
|
|
242
254
|
balance: convertQuantity(params.amount, deepCoin.scalar),
|
|
243
255
|
})
|
|
244
256
|
: params.coin;
|
|
245
|
-
tx.
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
+
tx.add(
|
|
258
|
+
marginManagerMoveCalls.deposit({
|
|
259
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
260
|
+
arguments: {
|
|
261
|
+
self: manager.address,
|
|
262
|
+
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
263
|
+
baseOracle: baseCoin.priceInfoObjectId!,
|
|
264
|
+
quoteOracle: quoteCoin.priceInfoObjectId!,
|
|
265
|
+
coin,
|
|
266
|
+
},
|
|
267
|
+
typeArguments: [baseCoin.type, quoteCoin.type, deepCoin.type],
|
|
268
|
+
}),
|
|
269
|
+
);
|
|
257
270
|
};
|
|
258
271
|
|
|
259
272
|
/**
|
|
@@ -269,21 +282,22 @@ export class MarginManagerContract {
|
|
|
269
282
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
270
283
|
const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
|
|
271
284
|
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
272
|
-
return tx.
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
285
|
+
return tx.add(
|
|
286
|
+
marginManagerMoveCalls.withdraw({
|
|
287
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
288
|
+
arguments: {
|
|
289
|
+
self: manager.address,
|
|
290
|
+
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
291
|
+
baseMarginPool: baseMarginPool.address,
|
|
292
|
+
quoteMarginPool: quoteMarginPool.address,
|
|
293
|
+
baseOracle: baseCoin.priceInfoObjectId!,
|
|
294
|
+
quoteOracle: quoteCoin.priceInfoObjectId!,
|
|
295
|
+
pool: pool.address,
|
|
296
|
+
withdrawAmount: convertQuantity(amount, baseCoin.scalar),
|
|
297
|
+
},
|
|
298
|
+
typeArguments: [baseCoin.type, quoteCoin.type, baseCoin.type],
|
|
299
|
+
}),
|
|
300
|
+
);
|
|
287
301
|
};
|
|
288
302
|
|
|
289
303
|
/**
|
|
@@ -299,21 +313,22 @@ export class MarginManagerContract {
|
|
|
299
313
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
300
314
|
const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
|
|
301
315
|
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
302
|
-
return tx.
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
316
|
+
return tx.add(
|
|
317
|
+
marginManagerMoveCalls.withdraw({
|
|
318
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
319
|
+
arguments: {
|
|
320
|
+
self: manager.address,
|
|
321
|
+
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
322
|
+
baseMarginPool: baseMarginPool.address,
|
|
323
|
+
quoteMarginPool: quoteMarginPool.address,
|
|
324
|
+
baseOracle: baseCoin.priceInfoObjectId!,
|
|
325
|
+
quoteOracle: quoteCoin.priceInfoObjectId!,
|
|
326
|
+
pool: pool.address,
|
|
327
|
+
withdrawAmount: convertQuantity(amount, quoteCoin.scalar),
|
|
328
|
+
},
|
|
329
|
+
typeArguments: [baseCoin.type, quoteCoin.type, quoteCoin.type],
|
|
330
|
+
}),
|
|
331
|
+
);
|
|
317
332
|
};
|
|
318
333
|
|
|
319
334
|
/**
|
|
@@ -330,21 +345,22 @@ export class MarginManagerContract {
|
|
|
330
345
|
const deepCoin = this.#config.getCoin('DEEP');
|
|
331
346
|
const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
|
|
332
347
|
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
333
|
-
return tx.
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
+
return tx.add(
|
|
349
|
+
marginManagerMoveCalls.withdraw({
|
|
350
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
351
|
+
arguments: {
|
|
352
|
+
self: manager.address,
|
|
353
|
+
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
354
|
+
baseMarginPool: baseMarginPool.address,
|
|
355
|
+
quoteMarginPool: quoteMarginPool.address,
|
|
356
|
+
baseOracle: baseCoin.priceInfoObjectId!,
|
|
357
|
+
quoteOracle: quoteCoin.priceInfoObjectId!,
|
|
358
|
+
pool: pool.address,
|
|
359
|
+
withdrawAmount: convertQuantity(amount, deepCoin.scalar),
|
|
360
|
+
},
|
|
361
|
+
typeArguments: [baseCoin.type, quoteCoin.type, deepCoin.type],
|
|
362
|
+
}),
|
|
363
|
+
);
|
|
348
364
|
};
|
|
349
365
|
|
|
350
366
|
/**
|
|
@@ -359,20 +375,21 @@ export class MarginManagerContract {
|
|
|
359
375
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
360
376
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
361
377
|
const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
|
|
362
|
-
return tx.
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
378
|
+
return tx.add(
|
|
379
|
+
marginManagerMoveCalls.borrowBase({
|
|
380
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
381
|
+
arguments: {
|
|
382
|
+
self: manager.address,
|
|
383
|
+
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
384
|
+
baseMarginPool: baseMarginPool.address,
|
|
385
|
+
baseOracle: baseCoin.priceInfoObjectId!,
|
|
386
|
+
quoteOracle: quoteCoin.priceInfoObjectId!,
|
|
387
|
+
pool: pool.address,
|
|
388
|
+
loanAmount: convertQuantity(amount, baseCoin.scalar),
|
|
389
|
+
},
|
|
390
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
391
|
+
}),
|
|
392
|
+
);
|
|
376
393
|
};
|
|
377
394
|
|
|
378
395
|
/**
|
|
@@ -387,20 +404,21 @@ export class MarginManagerContract {
|
|
|
387
404
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
388
405
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
389
406
|
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
390
|
-
return tx.
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
407
|
+
return tx.add(
|
|
408
|
+
marginManagerMoveCalls.borrowQuote({
|
|
409
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
410
|
+
arguments: {
|
|
411
|
+
self: manager.address,
|
|
412
|
+
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
413
|
+
quoteMarginPool: quoteMarginPool.address,
|
|
414
|
+
baseOracle: baseCoin.priceInfoObjectId!,
|
|
415
|
+
quoteOracle: quoteCoin.priceInfoObjectId!,
|
|
416
|
+
pool: pool.address,
|
|
417
|
+
loanAmount: convertQuantity(amount, quoteCoin.scalar),
|
|
418
|
+
},
|
|
419
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
420
|
+
}),
|
|
421
|
+
);
|
|
404
422
|
};
|
|
405
423
|
|
|
406
424
|
/**
|
|
@@ -415,20 +433,18 @@ export class MarginManagerContract {
|
|
|
415
433
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
416
434
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
417
435
|
const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
|
|
418
|
-
return tx.
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
431
|
-
});
|
|
436
|
+
return tx.add(
|
|
437
|
+
marginManagerMoveCalls.repayBase({
|
|
438
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
439
|
+
arguments: {
|
|
440
|
+
self: manager.address,
|
|
441
|
+
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
442
|
+
marginPool: baseMarginPool.address,
|
|
443
|
+
amount: amount !== undefined ? convertQuantity(amount, baseCoin.scalar) : null,
|
|
444
|
+
},
|
|
445
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
446
|
+
}),
|
|
447
|
+
);
|
|
432
448
|
};
|
|
433
449
|
|
|
434
450
|
/**
|
|
@@ -443,20 +459,18 @@ export class MarginManagerContract {
|
|
|
443
459
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
444
460
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
445
461
|
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
446
|
-
return tx.
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
459
|
-
});
|
|
462
|
+
return tx.add(
|
|
463
|
+
marginManagerMoveCalls.repayQuote({
|
|
464
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
465
|
+
arguments: {
|
|
466
|
+
self: manager.address,
|
|
467
|
+
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
468
|
+
marginPool: quoteMarginPool.address,
|
|
469
|
+
amount: amount !== undefined ? convertQuantity(amount, quoteCoin.scalar) : null,
|
|
470
|
+
},
|
|
471
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
472
|
+
}),
|
|
473
|
+
);
|
|
460
474
|
};
|
|
461
475
|
|
|
462
476
|
/**
|
|
@@ -481,20 +495,25 @@ export class MarginManagerContract {
|
|
|
481
495
|
const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
|
|
482
496
|
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
483
497
|
const marginPool = debtIsBase ? baseMarginPool : quoteMarginPool;
|
|
484
|
-
return tx.
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
+
return tx.add(
|
|
499
|
+
marginManagerMoveCalls.liquidate({
|
|
500
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
501
|
+
arguments: {
|
|
502
|
+
self: managerAddress,
|
|
503
|
+
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
504
|
+
baseOracle: baseCoin.priceInfoObjectId!,
|
|
505
|
+
quoteOracle: quoteCoin.priceInfoObjectId!,
|
|
506
|
+
marginPool: marginPool.address,
|
|
507
|
+
pool: pool.address,
|
|
508
|
+
repayCoin,
|
|
509
|
+
},
|
|
510
|
+
typeArguments: [
|
|
511
|
+
baseCoin.type,
|
|
512
|
+
quoteCoin.type,
|
|
513
|
+
debtIsBase ? baseCoin.type : quoteCoin.type,
|
|
514
|
+
],
|
|
515
|
+
}),
|
|
516
|
+
);
|
|
498
517
|
};
|
|
499
518
|
|
|
500
519
|
/**
|
|
@@ -509,11 +528,13 @@ export class MarginManagerContract {
|
|
|
509
528
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
510
529
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
511
530
|
|
|
512
|
-
tx.
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
531
|
+
tx.add(
|
|
532
|
+
marginManagerMoveCalls.setMarginManagerReferral({
|
|
533
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
534
|
+
arguments: { self: manager.address, referralCap: referral },
|
|
535
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
536
|
+
}),
|
|
537
|
+
);
|
|
517
538
|
};
|
|
518
539
|
|
|
519
540
|
/**
|
|
@@ -528,11 +549,13 @@ export class MarginManagerContract {
|
|
|
528
549
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
529
550
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
530
551
|
|
|
531
|
-
tx.
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
552
|
+
tx.add(
|
|
553
|
+
marginManagerMoveCalls.unsetMarginManagerReferral({
|
|
554
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
555
|
+
arguments: { self: manager.address, poolId: pool.address },
|
|
556
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
557
|
+
}),
|
|
558
|
+
);
|
|
536
559
|
};
|
|
537
560
|
|
|
538
561
|
// === Read-Only Functions ===
|
|
@@ -547,11 +570,13 @@ export class MarginManagerContract {
|
|
|
547
570
|
const pool = this.#config.getPool(poolKey);
|
|
548
571
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
549
572
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
550
|
-
return tx.
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
573
|
+
return tx.add(
|
|
574
|
+
marginManagerMoveCalls.owner({
|
|
575
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
576
|
+
arguments: { self: marginManagerId },
|
|
577
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
578
|
+
}),
|
|
579
|
+
);
|
|
555
580
|
};
|
|
556
581
|
|
|
557
582
|
/**
|
|
@@ -564,11 +589,13 @@ export class MarginManagerContract {
|
|
|
564
589
|
const pool = this.#config.getPool(poolKey);
|
|
565
590
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
566
591
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
567
|
-
return tx.
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
592
|
+
return tx.add(
|
|
593
|
+
marginManagerMoveCalls.deepbookPool({
|
|
594
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
595
|
+
arguments: { self: marginManagerId },
|
|
596
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
597
|
+
}),
|
|
598
|
+
);
|
|
572
599
|
};
|
|
573
600
|
|
|
574
601
|
/**
|
|
@@ -581,11 +608,13 @@ export class MarginManagerContract {
|
|
|
581
608
|
const pool = this.#config.getPool(poolKey);
|
|
582
609
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
583
610
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
584
|
-
return tx.
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
611
|
+
return tx.add(
|
|
612
|
+
marginManagerMoveCalls.marginPoolId({
|
|
613
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
614
|
+
arguments: { self: marginManagerId },
|
|
615
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
616
|
+
}),
|
|
617
|
+
);
|
|
589
618
|
};
|
|
590
619
|
|
|
591
620
|
/**
|
|
@@ -598,11 +627,13 @@ export class MarginManagerContract {
|
|
|
598
627
|
const pool = this.#config.getPool(poolKey);
|
|
599
628
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
600
629
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
601
|
-
return tx.
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
630
|
+
return tx.add(
|
|
631
|
+
marginManagerMoveCalls.borrowedShares({
|
|
632
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
633
|
+
arguments: { self: marginManagerId },
|
|
634
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
635
|
+
}),
|
|
636
|
+
);
|
|
606
637
|
};
|
|
607
638
|
|
|
608
639
|
/**
|
|
@@ -615,11 +646,13 @@ export class MarginManagerContract {
|
|
|
615
646
|
const pool = this.#config.getPool(poolKey);
|
|
616
647
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
617
648
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
618
|
-
return tx.
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
649
|
+
return tx.add(
|
|
650
|
+
marginManagerMoveCalls.borrowedBaseShares({
|
|
651
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
652
|
+
arguments: { self: marginManagerId },
|
|
653
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
654
|
+
}),
|
|
655
|
+
);
|
|
623
656
|
};
|
|
624
657
|
|
|
625
658
|
/**
|
|
@@ -632,11 +665,13 @@ export class MarginManagerContract {
|
|
|
632
665
|
const pool = this.#config.getPool(poolKey);
|
|
633
666
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
634
667
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
635
|
-
return tx.
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
668
|
+
return tx.add(
|
|
669
|
+
marginManagerMoveCalls.borrowedQuoteShares({
|
|
670
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
671
|
+
arguments: { self: marginManagerId },
|
|
672
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
673
|
+
}),
|
|
674
|
+
);
|
|
640
675
|
};
|
|
641
676
|
|
|
642
677
|
/**
|
|
@@ -649,11 +684,13 @@ export class MarginManagerContract {
|
|
|
649
684
|
const pool = this.#config.getPool(poolKey);
|
|
650
685
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
651
686
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
652
|
-
return tx.
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
687
|
+
return tx.add(
|
|
688
|
+
marginManagerMoveCalls.hasBaseDebt({
|
|
689
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
690
|
+
arguments: { self: marginManagerId },
|
|
691
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
692
|
+
}),
|
|
693
|
+
);
|
|
657
694
|
};
|
|
658
695
|
|
|
659
696
|
/**
|
|
@@ -666,11 +703,13 @@ export class MarginManagerContract {
|
|
|
666
703
|
const pool = this.#config.getPool(poolKey);
|
|
667
704
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
668
705
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
669
|
-
return tx.
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
706
|
+
return tx.add(
|
|
707
|
+
marginManagerMoveCalls.balanceManager({
|
|
708
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
709
|
+
arguments: { self: marginManagerId },
|
|
710
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
711
|
+
}),
|
|
712
|
+
);
|
|
674
713
|
};
|
|
675
714
|
|
|
676
715
|
/**
|
|
@@ -683,11 +722,13 @@ export class MarginManagerContract {
|
|
|
683
722
|
const pool = this.#config.getPool(poolKey);
|
|
684
723
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
685
724
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
686
|
-
return tx.
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
725
|
+
return tx.add(
|
|
726
|
+
marginManagerMoveCalls.calculateAssets({
|
|
727
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
728
|
+
arguments: { self: marginManagerId, pool: pool.address },
|
|
729
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
730
|
+
}),
|
|
731
|
+
);
|
|
691
732
|
};
|
|
692
733
|
|
|
693
734
|
/**
|
|
@@ -704,11 +745,13 @@ export class MarginManagerContract {
|
|
|
704
745
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
705
746
|
const debtCoin = this.#config.getCoin(coinKey);
|
|
706
747
|
const marginPool = this.#config.getMarginPool(coinKey);
|
|
707
|
-
return tx.
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
748
|
+
return tx.add(
|
|
749
|
+
marginManagerMoveCalls.calculateDebts({
|
|
750
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
751
|
+
arguments: { self: marginManagerId, marginPool: marginPool.address },
|
|
752
|
+
typeArguments: [baseCoin.type, quoteCoin.type, debtCoin.type],
|
|
753
|
+
}),
|
|
754
|
+
);
|
|
712
755
|
};
|
|
713
756
|
|
|
714
757
|
/**
|
|
@@ -726,20 +769,21 @@ export class MarginManagerContract {
|
|
|
726
769
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
727
770
|
const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
|
|
728
771
|
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
729
|
-
return tx.
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
772
|
+
return tx.add(
|
|
773
|
+
marginManagerMoveCalls.managerState({
|
|
774
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
775
|
+
arguments: {
|
|
776
|
+
self: marginManagerId,
|
|
777
|
+
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
778
|
+
baseOracle: baseCoin.priceInfoObjectId!,
|
|
779
|
+
quoteOracle: quoteCoin.priceInfoObjectId!,
|
|
780
|
+
pool: pool.address,
|
|
781
|
+
baseMarginPool: baseMarginPool.address,
|
|
782
|
+
quoteMarginPool: quoteMarginPool.address,
|
|
783
|
+
},
|
|
784
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
785
|
+
}),
|
|
786
|
+
);
|
|
743
787
|
};
|
|
744
788
|
|
|
745
789
|
/**
|
|
@@ -752,11 +796,13 @@ export class MarginManagerContract {
|
|
|
752
796
|
const pool = this.#config.getPool(poolKey);
|
|
753
797
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
754
798
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
755
|
-
return tx.
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
799
|
+
return tx.add(
|
|
800
|
+
marginManagerMoveCalls.baseBalance({
|
|
801
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
802
|
+
arguments: { self: marginManagerId },
|
|
803
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
804
|
+
}),
|
|
805
|
+
);
|
|
760
806
|
};
|
|
761
807
|
|
|
762
808
|
/**
|
|
@@ -769,11 +815,13 @@ export class MarginManagerContract {
|
|
|
769
815
|
const pool = this.#config.getPool(poolKey);
|
|
770
816
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
771
817
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
772
|
-
return tx.
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
818
|
+
return tx.add(
|
|
819
|
+
marginManagerMoveCalls.quoteBalance({
|
|
820
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
821
|
+
arguments: { self: marginManagerId },
|
|
822
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
823
|
+
}),
|
|
824
|
+
);
|
|
777
825
|
};
|
|
778
826
|
|
|
779
827
|
/**
|
|
@@ -786,11 +834,13 @@ export class MarginManagerContract {
|
|
|
786
834
|
const pool = this.#config.getPool(poolKey);
|
|
787
835
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
788
836
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
789
|
-
return tx.
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
837
|
+
return tx.add(
|
|
838
|
+
marginManagerMoveCalls.deepBalance({
|
|
839
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
840
|
+
arguments: { self: marginManagerId },
|
|
841
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
842
|
+
}),
|
|
843
|
+
);
|
|
794
844
|
};
|
|
795
845
|
|
|
796
846
|
/**
|
|
@@ -805,11 +855,13 @@ export class MarginManagerContract {
|
|
|
805
855
|
const pool = this.#config.getPool(poolKey);
|
|
806
856
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
807
857
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
808
|
-
return tx.
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
858
|
+
return tx.add(
|
|
859
|
+
marginManagerMoveCalls.balanceManagerId({
|
|
860
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
861
|
+
arguments: { self: marginManagerId },
|
|
862
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
863
|
+
}),
|
|
864
|
+
);
|
|
813
865
|
};
|
|
814
866
|
|
|
815
867
|
/**
|
|
@@ -822,11 +874,13 @@ export class MarginManagerContract {
|
|
|
822
874
|
const pool = this.#config.getPool(poolKey);
|
|
823
875
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
824
876
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
825
|
-
return tx.
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
877
|
+
return tx.add(
|
|
878
|
+
marginManagerMoveCalls.getBalanceManagerReferralId({
|
|
879
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
880
|
+
arguments: { self: marginManagerId, poolId: pool.address },
|
|
881
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
882
|
+
}),
|
|
883
|
+
);
|
|
830
884
|
};
|
|
831
885
|
|
|
832
886
|
/**
|
|
@@ -839,11 +893,13 @@ export class MarginManagerContract {
|
|
|
839
893
|
const pool = this.#config.getPool(poolKey);
|
|
840
894
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
841
895
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
842
|
-
return tx.
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
896
|
+
return tx.add(
|
|
897
|
+
marginManagerMoveCalls.accountExists({
|
|
898
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
899
|
+
arguments: { self: marginManagerId, pool: pool.address },
|
|
900
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
901
|
+
}),
|
|
902
|
+
);
|
|
847
903
|
};
|
|
848
904
|
|
|
849
905
|
/**
|
|
@@ -856,11 +912,13 @@ export class MarginManagerContract {
|
|
|
856
912
|
const pool = this.#config.getPool(poolKey);
|
|
857
913
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
858
914
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
859
|
-
return tx.
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
915
|
+
return tx.add(
|
|
916
|
+
marginManagerMoveCalls.account({
|
|
917
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
918
|
+
arguments: { self: marginManagerId, pool: pool.address },
|
|
919
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
920
|
+
}),
|
|
921
|
+
);
|
|
864
922
|
};
|
|
865
923
|
|
|
866
924
|
/**
|
|
@@ -874,11 +932,13 @@ export class MarginManagerContract {
|
|
|
874
932
|
const pool = this.#config.getPool(poolKey);
|
|
875
933
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
876
934
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
877
|
-
return tx.
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
935
|
+
return tx.add(
|
|
936
|
+
marginManagerMoveCalls.accountOpenOrders({
|
|
937
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
938
|
+
arguments: { self: marginManagerId, pool: pool.address },
|
|
939
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
940
|
+
}),
|
|
941
|
+
);
|
|
882
942
|
};
|
|
883
943
|
|
|
884
944
|
/**
|
|
@@ -892,11 +952,13 @@ export class MarginManagerContract {
|
|
|
892
952
|
const pool = this.#config.getPool(poolKey);
|
|
893
953
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
894
954
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
895
|
-
return tx.
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
955
|
+
return tx.add(
|
|
956
|
+
marginManagerMoveCalls.getAccountOrderDetails({
|
|
957
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
958
|
+
arguments: { self: marginManagerId, pool: pool.address },
|
|
959
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
960
|
+
}),
|
|
961
|
+
);
|
|
900
962
|
};
|
|
901
963
|
|
|
902
964
|
/**
|
|
@@ -910,11 +972,13 @@ export class MarginManagerContract {
|
|
|
910
972
|
const pool = this.#config.getPool(poolKey);
|
|
911
973
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
912
974
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
913
|
-
return tx.
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
975
|
+
return tx.add(
|
|
976
|
+
marginManagerMoveCalls.lockedBalance({
|
|
977
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
978
|
+
arguments: { self: marginManagerId, pool: pool.address },
|
|
979
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
980
|
+
}),
|
|
981
|
+
);
|
|
918
982
|
};
|
|
919
983
|
|
|
920
984
|
/**
|
|
@@ -945,20 +1009,21 @@ export class MarginManagerContract {
|
|
|
945
1009
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
946
1010
|
const inputPrice = convertPrice(price, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar);
|
|
947
1011
|
const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
|
|
948
|
-
return tx.
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
1012
|
+
return tx.add(
|
|
1013
|
+
marginManagerMoveCalls.canPlaceLimitOrder({
|
|
1014
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
1015
|
+
arguments: {
|
|
1016
|
+
self: marginManagerId,
|
|
1017
|
+
pool: pool.address,
|
|
1018
|
+
price: inputPrice,
|
|
1019
|
+
quantity: inputQuantity,
|
|
1020
|
+
isBid,
|
|
1021
|
+
payWithDeep,
|
|
1022
|
+
expireTimestamp,
|
|
1023
|
+
},
|
|
1024
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
1025
|
+
}),
|
|
1026
|
+
);
|
|
962
1027
|
};
|
|
963
1028
|
|
|
964
1029
|
/**
|
|
@@ -984,17 +1049,18 @@ export class MarginManagerContract {
|
|
|
984
1049
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
985
1050
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
986
1051
|
const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
|
|
987
|
-
return tx.
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
1052
|
+
return tx.add(
|
|
1053
|
+
marginManagerMoveCalls.canPlaceMarketOrder({
|
|
1054
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
1055
|
+
arguments: {
|
|
1056
|
+
self: marginManagerId,
|
|
1057
|
+
pool: pool.address,
|
|
1058
|
+
quantity: inputQuantity,
|
|
1059
|
+
isBid,
|
|
1060
|
+
payWithDeep,
|
|
1061
|
+
},
|
|
1062
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
1063
|
+
}),
|
|
1064
|
+
);
|
|
999
1065
|
};
|
|
1000
1066
|
}
|