@mysten/deepbook-v3 1.5.8 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +73 -0
- package/dist/client.d.mts +5 -0
- package/dist/client.d.mts.map +1 -1
- package/dist/client.mjs +7 -0
- package/dist/client.mjs.map +1 -1
- package/dist/contracts/deepbook/account.d.mts +18 -18
- package/dist/contracts/deepbook/account.d.mts.map +1 -1
- package/dist/contracts/deepbook/balance_manager.mjs +413 -0
- package/dist/contracts/deepbook/balance_manager.mjs.map +1 -0
- package/dist/contracts/deepbook/big_vector.mjs +43 -0
- package/dist/contracts/deepbook/big_vector.mjs.map +1 -0
- package/dist/contracts/deepbook/book.mjs +29 -0
- package/dist/contracts/deepbook/book.mjs.map +1 -0
- package/dist/contracts/deepbook/deep_price.d.mts +3 -3
- package/dist/contracts/deepbook/deep_price.d.mts.map +1 -1
- package/dist/contracts/deepbook/deep_price.mjs +1 -1
- package/dist/contracts/deepbook/deps/std/type_name.mjs +17 -0
- package/dist/contracts/deepbook/deps/std/type_name.mjs.map +1 -0
- package/dist/contracts/deepbook/deps/sui/bag.mjs +43 -0
- package/dist/contracts/deepbook/deps/sui/bag.mjs.map +1 -0
- package/dist/contracts/deepbook/deps/sui/balance.mjs +21 -0
- package/dist/contracts/deepbook/deps/sui/balance.mjs.map +1 -0
- package/dist/contracts/deepbook/deps/sui/table.mjs +38 -0
- package/dist/contracts/deepbook/deps/sui/table.mjs.map +1 -0
- package/dist/contracts/deepbook/deps/sui/vec_map.mjs +37 -0
- package/dist/contracts/deepbook/deps/sui/vec_map.mjs.map +1 -0
- package/dist/contracts/deepbook/deps/sui/versioned.mjs +19 -0
- package/dist/contracts/deepbook/deps/sui/versioned.mjs.map +1 -0
- package/dist/contracts/deepbook/governance.mjs +49 -0
- package/dist/contracts/deepbook/governance.mjs.map +1 -0
- package/dist/contracts/deepbook/history.mjs +56 -0
- package/dist/contracts/deepbook/history.mjs.map +1 -0
- package/dist/contracts/deepbook/order.d.mts +12 -12
- package/dist/contracts/deepbook/pool.mjs +1739 -0
- package/dist/contracts/deepbook/pool.mjs.map +1 -0
- package/dist/contracts/deepbook/registry.mjs +295 -0
- package/dist/contracts/deepbook/registry.mjs.map +1 -0
- package/dist/contracts/deepbook/state.mjs +89 -0
- package/dist/contracts/deepbook/state.mjs.map +1 -0
- package/dist/contracts/deepbook/trade_params.mjs +21 -0
- package/dist/contracts/deepbook/trade_params.mjs.map +1 -0
- package/dist/contracts/deepbook/vault.mjs +42 -0
- package/dist/contracts/deepbook/vault.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/deepbook/balance_manager.mjs +53 -0
- package/dist/contracts/deepbook_margin/deps/deepbook/balance_manager.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/std/type_name.mjs +17 -0
- package/dist/contracts/deepbook_margin/deps/std/type_name.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/bag.mjs +43 -0
- package/dist/contracts/deepbook_margin/deps/sui/bag.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/balance.mjs +21 -0
- package/dist/contracts/deepbook_margin/deps/sui/balance.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/table.mjs +38 -0
- package/dist/contracts/deepbook_margin/deps/sui/table.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/vec_map.mjs +37 -0
- package/dist/contracts/deepbook_margin/deps/sui/vec_map.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/vec_set.mjs +26 -0
- package/dist/contracts/deepbook_margin/deps/sui/vec_set.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/versioned.mjs +19 -0
- package/dist/contracts/deepbook_margin/deps/sui/versioned.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/margin_manager.mjs +989 -0
- package/dist/contracts/deepbook_margin/margin_manager.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/margin_pool.mjs +550 -0
- package/dist/contracts/deepbook_margin/margin_pool.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/margin_registry.mjs +786 -0
- package/dist/contracts/deepbook_margin/margin_registry.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/margin_state.mjs +30 -0
- package/dist/contracts/deepbook_margin/margin_state.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/oracle.mjs +82 -0
- package/dist/contracts/deepbook_margin/oracle.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/pool_proxy.mjs +644 -0
- package/dist/contracts/deepbook_margin/pool_proxy.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/position_manager.mjs +32 -0
- package/dist/contracts/deepbook_margin/position_manager.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/protocol_config.mjs +122 -0
- package/dist/contracts/deepbook_margin/protocol_config.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/protocol_fees.mjs +58 -0
- package/dist/contracts/deepbook_margin/protocol_fees.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/rate_limiter.mjs +26 -0
- package/dist/contracts/deepbook_margin/rate_limiter.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/tpsl.mjs +171 -0
- package/dist/contracts/deepbook_margin/tpsl.mjs.map +1 -0
- package/dist/contracts/margin_liquidation/deps/sui/bag.mjs +43 -0
- package/dist/contracts/margin_liquidation/deps/sui/bag.mjs.map +1 -0
- package/dist/contracts/margin_liquidation/liquidation_vault.mjs +179 -0
- package/dist/contracts/margin_liquidation/liquidation_vault.mjs.map +1 -0
- package/dist/contracts/utils/index.d.mts +1 -1
- package/dist/contracts/utils/index.mjs +92 -3
- package/dist/contracts/utils/index.mjs.map +1 -1
- package/dist/queries/registryQueries.mjs +13 -0
- package/dist/queries/registryQueries.mjs.map +1 -1
- package/dist/transactions/balanceManager.d.mts.map +1 -1
- package/dist/transactions/balanceManager.mjs +119 -100
- package/dist/transactions/balanceManager.mjs.map +1 -1
- package/dist/transactions/deepbook.d.mts.map +1 -1
- package/dist/transactions/deepbook.mjs +464 -439
- package/dist/transactions/deepbook.mjs.map +1 -1
- package/dist/transactions/deepbookAdmin.d.mts.map +1 -1
- package/dist/transactions/deepbookAdmin.mjs +151 -135
- package/dist/transactions/deepbookAdmin.mjs.map +1 -1
- package/dist/transactions/flashLoans.d.mts.map +1 -1
- package/dist/transactions/flashLoans.mjs +29 -22
- package/dist/transactions/flashLoans.mjs.map +1 -1
- package/dist/transactions/governance.d.mts.map +1 -1
- package/dist/transactions/governance.mjs +34 -33
- package/dist/transactions/governance.mjs.map +1 -1
- package/dist/transactions/marginAdmin.d.mts +17 -7
- package/dist/transactions/marginAdmin.d.mts.map +1 -1
- package/dist/transactions/marginAdmin.mjs +186 -169
- package/dist/transactions/marginAdmin.mjs.map +1 -1
- package/dist/transactions/marginLiquidations.d.mts +3 -3
- package/dist/transactions/marginLiquidations.d.mts.map +1 -1
- package/dist/transactions/marginLiquidations.mjs +53 -54
- package/dist/transactions/marginLiquidations.mjs.map +1 -1
- package/dist/transactions/marginMaintainer.d.mts +5 -5
- package/dist/transactions/marginMaintainer.d.mts.map +1 -1
- package/dist/transactions/marginMaintainer.mjs +83 -83
- package/dist/transactions/marginMaintainer.mjs.map +1 -1
- package/dist/transactions/marginManager.d.mts +32 -32
- package/dist/transactions/marginManager.d.mts.map +1 -1
- package/dist/transactions/marginManager.mjs +330 -317
- package/dist/transactions/marginManager.mjs.map +1 -1
- package/dist/transactions/marginPool.d.mts +18 -18
- package/dist/transactions/marginPool.d.mts.map +1 -1
- package/dist/transactions/marginPool.mjs +93 -89
- package/dist/transactions/marginPool.mjs.map +1 -1
- package/dist/transactions/marginRegistry.d.mts +22 -15
- package/dist/transactions/marginRegistry.d.mts.map +1 -1
- package/dist/transactions/marginRegistry.mjs +101 -68
- package/dist/transactions/marginRegistry.mjs.map +1 -1
- package/dist/transactions/marginTPSL.d.mts +27 -9
- package/dist/transactions/marginTPSL.d.mts.map +1 -1
- package/dist/transactions/marginTPSL.mjs +108 -82
- package/dist/transactions/marginTPSL.mjs.map +1 -1
- package/dist/transactions/poolProxy.d.mts +37 -5
- package/dist/transactions/poolProxy.d.mts.map +1 -1
- package/dist/transactions/poolProxy.mjs +269 -189
- package/dist/transactions/poolProxy.mjs.map +1 -1
- package/dist/utils/constants.mjs +4 -4
- package/dist/utils/constants.mjs.map +1 -1
- package/package.json +3 -3
- package/src/client.ts +8 -0
- package/src/contracts/deepbook/balance_manager.ts +46 -5
- package/src/contracts/deepbook/constants.ts +13 -0
- package/src/contracts/deepbook/pool.ts +133 -0
- package/src/contracts/deepbook/registry.ts +136 -1
- package/src/contracts/deepbook_margin/deps/deepbook/balance_manager.ts +49 -0
- package/src/contracts/deepbook_margin/deps/std/type_name.ts +24 -0
- package/src/contracts/deepbook_margin/deps/sui/bag.ts +41 -0
- package/src/contracts/deepbook_margin/deps/sui/balance.ts +19 -0
- package/src/contracts/deepbook_margin/deps/sui/table.ts +36 -0
- package/src/contracts/deepbook_margin/deps/sui/vec_map.ts +33 -0
- package/src/contracts/deepbook_margin/deps/sui/vec_set.ts +22 -0
- package/src/contracts/deepbook_margin/deps/sui/versioned.ts +13 -0
- package/src/contracts/deepbook_margin/margin_constants.ts +329 -0
- package/src/contracts/deepbook_margin/margin_manager.ts +1772 -0
- package/src/contracts/deepbook_margin/margin_pool.ts +1129 -0
- package/src/contracts/deepbook_margin/margin_registry.ts +1207 -0
- package/src/contracts/deepbook_margin/margin_state.ts +26 -0
- package/src/contracts/deepbook_margin/oracle.ts +99 -0
- package/src/contracts/deepbook_margin/pool_proxy.ts +1298 -0
- package/src/contracts/deepbook_margin/position_manager.ts +28 -0
- package/src/contracts/deepbook_margin/protocol_config.ts +163 -0
- package/src/contracts/deepbook_margin/protocol_fees.ts +153 -0
- package/src/contracts/deepbook_margin/rate_limiter.ts +80 -0
- package/src/contracts/deepbook_margin/tpsl.ts +559 -0
- package/src/contracts/margin_liquidation/deps/sui/bag.ts +41 -0
- package/src/contracts/margin_liquidation/liquidation_vault.ts +401 -0
- package/src/queries/registryQueries.ts +15 -0
- package/src/transactions/balanceManager.ts +140 -90
- package/src/transactions/deepbook.ts +586 -494
- package/src/transactions/deepbookAdmin.ts +154 -146
- package/src/transactions/flashLoans.ts +29 -20
- package/src/transactions/governance.ts +50 -37
- package/src/transactions/marginAdmin.ts +247 -188
- package/src/transactions/marginLiquidations.ts +70 -55
- package/src/transactions/marginMaintainer.ts +106 -88
- package/src/transactions/marginManager.ts +414 -348
- package/src/transactions/marginPool.ts +140 -103
- package/src/transactions/marginRegistry.ts +103 -70
- package/src/transactions/marginTPSL.ts +151 -87
- package/src/transactions/poolProxy.ts +384 -205
- package/src/utils/constants.ts +4 -4
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { convertPrice, convertQuantity, convertRate } from "../utils/conversion.mjs";
|
|
2
2
|
import { DEEP_SCALAR, FLOAT_SCALAR, GAS_BUDGET, MAX_TIMESTAMP, POOL_CREATION_FEE_DEEP } from "../utils/config.mjs";
|
|
3
3
|
import { OrderType, SelfMatchingOptions } from "../types/index.mjs";
|
|
4
|
+
import { account, accountExists, accountOpenOrders, addDeepPricePoint, burnDeep, canPlaceLimitOrder, canPlaceMarketOrder, cancelAllOrders, cancelLiveOrder, cancelLiveOrders, cancelOrder, cancelOrders, checkLimitOrderParams, checkMarketOrderParams, claimPoolReferralRewards, claimRebates, createPermissionlessPool, getAccountOrderDetails, getBaseQuantityIn, getBaseQuantityOut, getBaseQuantityOutInputFee, getLevel2Range, getLevel2TicksFromMid, getOrder, getOrderDeepPrice, getOrderDeepRequired, getOrders, getPoolIdByAsset, getPoolReferralBalances, getQuantityOut, getQuantityOutInputFee, getQuoteQuantityIn, getQuoteQuantityOut, getQuoteQuantityOutInputFee, id, lockedBalance, midPrice, mintReferral, modifyOrder, placeLimitOrder, placeMarketOrder, poolBookParams, poolReferralMultiplier, poolTradeParams, poolTradeParamsNext, quorum, registeredPool, stablePool, swapExactBaseForQuote, swapExactBaseForQuoteWithManager, swapExactQuantity, swapExactQuantityWithManager, swapExactQuoteForBase, swapExactQuoteForBaseWithManager, updatePoolAllowedVersions, updatePoolReferralMultiplier, vaultBalances, whitelisted, withdrawSettledAmounts, withdrawSettledAmountsPermissionless } from "../contracts/deepbook/pool.mjs";
|
|
5
|
+
import { getBalanceManagerIds } from "../contracts/deepbook/registry.mjs";
|
|
4
6
|
import { coinWithBalance } from "@mysten/sui/transactions";
|
|
5
7
|
|
|
6
8
|
//#region src/transactions/deepbook.ts
|
|
@@ -23,24 +25,23 @@ var DeepBookContract = class {
|
|
|
23
25
|
const inputPrice = convertPrice(price, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar);
|
|
24
26
|
const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
|
|
25
27
|
const tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));
|
|
26
|
-
tx.
|
|
27
|
-
|
|
28
|
-
arguments:
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
tx.add(placeLimitOrder({
|
|
29
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
30
|
+
arguments: {
|
|
31
|
+
self: pool.address,
|
|
32
|
+
balanceManager: balanceManager.address,
|
|
31
33
|
tradeProof,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
],
|
|
34
|
+
clientOrderId: BigInt(clientOrderId),
|
|
35
|
+
orderType,
|
|
36
|
+
selfMatchingOption,
|
|
37
|
+
price: inputPrice,
|
|
38
|
+
quantity: inputQuantity,
|
|
39
|
+
isBid,
|
|
40
|
+
payWithDeep,
|
|
41
|
+
expireTimestamp: expiration
|
|
42
|
+
},
|
|
42
43
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
43
|
-
});
|
|
44
|
+
}));
|
|
44
45
|
};
|
|
45
46
|
this.placeMarketOrder = (params) => (tx) => {
|
|
46
47
|
const { poolKey, balanceManagerKey, clientOrderId, quantity, isBid, selfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED, payWithDeep = true } = params;
|
|
@@ -51,21 +52,20 @@ var DeepBookContract = class {
|
|
|
51
52
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
52
53
|
const tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));
|
|
53
54
|
const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
|
|
54
|
-
tx.
|
|
55
|
-
|
|
56
|
-
arguments:
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
tx.add(placeMarketOrder({
|
|
56
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
57
|
+
arguments: {
|
|
58
|
+
self: pool.address,
|
|
59
|
+
balanceManager: balanceManager.address,
|
|
59
60
|
tradeProof,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
],
|
|
61
|
+
clientOrderId: BigInt(clientOrderId),
|
|
62
|
+
selfMatchingOption,
|
|
63
|
+
quantity: inputQuantity,
|
|
64
|
+
isBid,
|
|
65
|
+
payWithDeep
|
|
66
|
+
},
|
|
67
67
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
68
|
-
});
|
|
68
|
+
}));
|
|
69
69
|
};
|
|
70
70
|
this.modifyOrder = (poolKey, balanceManagerKey, orderId, newQuantity) => (tx) => {
|
|
71
71
|
const pool = this.#config.getPool(poolKey);
|
|
@@ -74,18 +74,17 @@ var DeepBookContract = class {
|
|
|
74
74
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
75
75
|
const tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));
|
|
76
76
|
const inputQuantity = convertQuantity(newQuantity, baseCoin.scalar);
|
|
77
|
-
tx.
|
|
78
|
-
|
|
79
|
-
arguments:
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
tx.add(modifyOrder({
|
|
78
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
79
|
+
arguments: {
|
|
80
|
+
self: pool.address,
|
|
81
|
+
balanceManager: balanceManager.address,
|
|
82
82
|
tradeProof,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
],
|
|
83
|
+
orderId: BigInt(orderId),
|
|
84
|
+
newQuantity: inputQuantity
|
|
85
|
+
},
|
|
87
86
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
88
|
-
});
|
|
87
|
+
}));
|
|
89
88
|
};
|
|
90
89
|
this.cancelOrder = (poolKey, balanceManagerKey, orderId) => (tx) => {
|
|
91
90
|
tx.setGasBudgetIfNotSet(GAS_BUDGET);
|
|
@@ -94,17 +93,16 @@ var DeepBookContract = class {
|
|
|
94
93
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
95
94
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
96
95
|
const tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));
|
|
97
|
-
tx.
|
|
98
|
-
|
|
99
|
-
arguments:
|
|
100
|
-
|
|
101
|
-
|
|
96
|
+
tx.add(cancelOrder({
|
|
97
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
98
|
+
arguments: {
|
|
99
|
+
self: pool.address,
|
|
100
|
+
balanceManager: balanceManager.address,
|
|
102
101
|
tradeProof,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
],
|
|
102
|
+
orderId: BigInt(orderId)
|
|
103
|
+
},
|
|
106
104
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
107
|
-
});
|
|
105
|
+
}));
|
|
108
106
|
};
|
|
109
107
|
this.cancelOrders = (poolKey, balanceManagerKey, orderIds) => (tx) => {
|
|
110
108
|
tx.setGasBudgetIfNotSet(GAS_BUDGET);
|
|
@@ -113,17 +111,16 @@ var DeepBookContract = class {
|
|
|
113
111
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
114
112
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
115
113
|
const tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));
|
|
116
|
-
tx.
|
|
117
|
-
|
|
118
|
-
arguments:
|
|
119
|
-
|
|
120
|
-
|
|
114
|
+
tx.add(cancelOrders({
|
|
115
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
116
|
+
arguments: {
|
|
117
|
+
self: pool.address,
|
|
118
|
+
balanceManager: balanceManager.address,
|
|
121
119
|
tradeProof,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
],
|
|
120
|
+
orderIds: orderIds.map(BigInt)
|
|
121
|
+
},
|
|
125
122
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
126
|
-
});
|
|
123
|
+
}));
|
|
127
124
|
};
|
|
128
125
|
this.cancelLiveOrder = (poolKey, balanceManagerKey, orderId) => (tx) => {
|
|
129
126
|
tx.setGasBudgetIfNotSet(GAS_BUDGET);
|
|
@@ -132,17 +129,16 @@ var DeepBookContract = class {
|
|
|
132
129
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
133
130
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
134
131
|
const tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));
|
|
135
|
-
tx.
|
|
136
|
-
|
|
137
|
-
arguments:
|
|
138
|
-
|
|
139
|
-
|
|
132
|
+
tx.add(cancelLiveOrder({
|
|
133
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
134
|
+
arguments: {
|
|
135
|
+
self: pool.address,
|
|
136
|
+
balanceManager: balanceManager.address,
|
|
140
137
|
tradeProof,
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
],
|
|
138
|
+
orderId: BigInt(orderId)
|
|
139
|
+
},
|
|
144
140
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
145
|
-
});
|
|
141
|
+
}));
|
|
146
142
|
};
|
|
147
143
|
this.cancelLiveOrders = (poolKey, balanceManagerKey, orderIds) => (tx) => {
|
|
148
144
|
tx.setGasBudgetIfNotSet(GAS_BUDGET);
|
|
@@ -151,17 +147,16 @@ var DeepBookContract = class {
|
|
|
151
147
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
152
148
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
153
149
|
const tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));
|
|
154
|
-
tx.
|
|
155
|
-
|
|
156
|
-
arguments:
|
|
157
|
-
|
|
158
|
-
|
|
150
|
+
tx.add(cancelLiveOrders({
|
|
151
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
152
|
+
arguments: {
|
|
153
|
+
self: pool.address,
|
|
154
|
+
balanceManager: balanceManager.address,
|
|
159
155
|
tradeProof,
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
],
|
|
156
|
+
orderIds: orderIds.map(BigInt)
|
|
157
|
+
},
|
|
163
158
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
164
|
-
});
|
|
159
|
+
}));
|
|
165
160
|
};
|
|
166
161
|
this.cancelAllOrders = (poolKey, balanceManagerKey) => (tx) => {
|
|
167
162
|
tx.setGasBudgetIfNotSet(GAS_BUDGET);
|
|
@@ -170,16 +165,15 @@ var DeepBookContract = class {
|
|
|
170
165
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
171
166
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
172
167
|
const tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));
|
|
173
|
-
tx.
|
|
174
|
-
|
|
175
|
-
arguments:
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
tradeProof
|
|
179
|
-
|
|
180
|
-
],
|
|
168
|
+
tx.add(cancelAllOrders({
|
|
169
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
170
|
+
arguments: {
|
|
171
|
+
self: pool.address,
|
|
172
|
+
balanceManager: balanceManager.address,
|
|
173
|
+
tradeProof
|
|
174
|
+
},
|
|
181
175
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
182
|
-
});
|
|
176
|
+
}));
|
|
183
177
|
};
|
|
184
178
|
this.withdrawSettledAmounts = (poolKey, balanceManagerKey) => (tx) => {
|
|
185
179
|
const pool = this.#config.getPool(poolKey);
|
|
@@ -187,36 +181,42 @@ var DeepBookContract = class {
|
|
|
187
181
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
188
182
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
189
183
|
const tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));
|
|
190
|
-
tx.
|
|
191
|
-
|
|
192
|
-
arguments:
|
|
193
|
-
|
|
194
|
-
|
|
184
|
+
tx.add(withdrawSettledAmounts({
|
|
185
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
186
|
+
arguments: {
|
|
187
|
+
self: pool.address,
|
|
188
|
+
balanceManager: balanceManager.address,
|
|
195
189
|
tradeProof
|
|
196
|
-
|
|
190
|
+
},
|
|
197
191
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
198
|
-
});
|
|
192
|
+
}));
|
|
199
193
|
};
|
|
200
194
|
this.withdrawSettledAmountsPermissionless = (poolKey, balanceManagerKey) => (tx) => {
|
|
201
195
|
const pool = this.#config.getPool(poolKey);
|
|
202
196
|
const balanceManager = this.#config.getBalanceManager(balanceManagerKey);
|
|
203
197
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
204
198
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
205
|
-
tx.
|
|
206
|
-
|
|
207
|
-
arguments:
|
|
199
|
+
tx.add(withdrawSettledAmountsPermissionless({
|
|
200
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
201
|
+
arguments: {
|
|
202
|
+
self: pool.address,
|
|
203
|
+
balanceManager: balanceManager.address
|
|
204
|
+
},
|
|
208
205
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
209
|
-
});
|
|
206
|
+
}));
|
|
210
207
|
};
|
|
211
208
|
this.withdrawSettledAmountsManagerID = (poolKey, balanceManagerId) => (tx) => {
|
|
212
209
|
const pool = this.#config.getPool(poolKey);
|
|
213
210
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
214
211
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
215
|
-
tx.
|
|
216
|
-
|
|
217
|
-
arguments:
|
|
212
|
+
tx.add(withdrawSettledAmountsPermissionless({
|
|
213
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
214
|
+
arguments: {
|
|
215
|
+
self: pool.address,
|
|
216
|
+
balanceManager: balanceManagerId
|
|
217
|
+
},
|
|
218
218
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
219
|
-
});
|
|
219
|
+
}));
|
|
220
220
|
};
|
|
221
221
|
this.addDeepPricePoint = (targetPoolKey, referencePoolKey) => (tx) => {
|
|
222
222
|
const targetPool = this.#config.getPool(targetPoolKey);
|
|
@@ -225,20 +225,19 @@ var DeepBookContract = class {
|
|
|
225
225
|
const targetQuoteCoin = this.#config.getCoin(targetPool.quoteCoin);
|
|
226
226
|
const referenceBaseCoin = this.#config.getCoin(referencePool.baseCoin);
|
|
227
227
|
const referenceQuoteCoin = this.#config.getCoin(referencePool.quoteCoin);
|
|
228
|
-
tx.
|
|
229
|
-
|
|
230
|
-
arguments:
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
],
|
|
228
|
+
tx.add(addDeepPricePoint({
|
|
229
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
230
|
+
arguments: {
|
|
231
|
+
targetPool: targetPool.address,
|
|
232
|
+
referencePool: referencePool.address
|
|
233
|
+
},
|
|
235
234
|
typeArguments: [
|
|
236
235
|
targetBaseCoin.type,
|
|
237
236
|
targetQuoteCoin.type,
|
|
238
237
|
referenceBaseCoin.type,
|
|
239
238
|
referenceQuoteCoin.type
|
|
240
239
|
]
|
|
241
|
-
});
|
|
240
|
+
}));
|
|
242
241
|
};
|
|
243
242
|
this.claimRebates = (poolKey, balanceManagerKey) => (tx) => {
|
|
244
243
|
const pool = this.#config.getPool(poolKey);
|
|
@@ -246,51 +245,57 @@ var DeepBookContract = class {
|
|
|
246
245
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
247
246
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
248
247
|
const tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));
|
|
249
|
-
tx.
|
|
250
|
-
|
|
251
|
-
arguments:
|
|
252
|
-
|
|
253
|
-
|
|
248
|
+
tx.add(claimRebates({
|
|
249
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
250
|
+
arguments: {
|
|
251
|
+
self: pool.address,
|
|
252
|
+
balanceManager: balanceManager.address,
|
|
254
253
|
tradeProof
|
|
255
|
-
|
|
254
|
+
},
|
|
256
255
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
257
|
-
});
|
|
256
|
+
}));
|
|
258
257
|
};
|
|
259
258
|
this.mintReferral = (poolKey, multiplier) => (tx) => {
|
|
260
259
|
const pool = this.#config.getPool(poolKey);
|
|
261
260
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
262
261
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
263
262
|
const adjustedNumber = convertRate(multiplier, FLOAT_SCALAR);
|
|
264
|
-
tx.
|
|
265
|
-
|
|
266
|
-
arguments:
|
|
263
|
+
tx.add(mintReferral({
|
|
264
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
265
|
+
arguments: {
|
|
266
|
+
self: pool.address,
|
|
267
|
+
multiplier: adjustedNumber
|
|
268
|
+
},
|
|
267
269
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
268
|
-
});
|
|
270
|
+
}));
|
|
269
271
|
};
|
|
270
272
|
this.updatePoolReferralMultiplier = (poolKey, referral, multiplier) => (tx) => {
|
|
271
273
|
const pool = this.#config.getPool(poolKey);
|
|
272
274
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
273
275
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
274
276
|
const adjustedNumber = convertRate(multiplier, FLOAT_SCALAR);
|
|
275
|
-
tx.
|
|
276
|
-
|
|
277
|
-
arguments:
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
277
|
+
tx.add(updatePoolReferralMultiplier({
|
|
278
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
279
|
+
arguments: {
|
|
280
|
+
self: pool.address,
|
|
281
|
+
referral,
|
|
282
|
+
multiplier: adjustedNumber
|
|
283
|
+
},
|
|
282
284
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
283
|
-
});
|
|
285
|
+
}));
|
|
284
286
|
};
|
|
285
287
|
this.claimPoolReferralRewards = (poolKey, referral) => (tx) => {
|
|
286
288
|
const pool = this.#config.getPool(poolKey);
|
|
287
289
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
288
290
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
289
|
-
const [baseRewards, quoteRewards, deepRewards] = tx.
|
|
290
|
-
|
|
291
|
-
arguments:
|
|
291
|
+
const [baseRewards, quoteRewards, deepRewards] = tx.add(claimPoolReferralRewards({
|
|
292
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
293
|
+
arguments: {
|
|
294
|
+
self: pool.address,
|
|
295
|
+
referral
|
|
296
|
+
},
|
|
292
297
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
293
|
-
});
|
|
298
|
+
}));
|
|
294
299
|
return {
|
|
295
300
|
baseRewards,
|
|
296
301
|
quoteRewards,
|
|
@@ -301,164 +306,174 @@ var DeepBookContract = class {
|
|
|
301
306
|
const pool = this.#config.getPool(poolKey);
|
|
302
307
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
303
308
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
304
|
-
tx.
|
|
305
|
-
|
|
306
|
-
arguments:
|
|
309
|
+
tx.add(updatePoolAllowedVersions({
|
|
310
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
311
|
+
arguments: {
|
|
312
|
+
self: pool.address,
|
|
313
|
+
registry: this.#config.REGISTRY_ID
|
|
314
|
+
},
|
|
307
315
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
308
|
-
});
|
|
316
|
+
}));
|
|
309
317
|
};
|
|
310
318
|
this.getOrder = (poolKey, orderId) => (tx) => {
|
|
311
319
|
const pool = this.#config.getPool(poolKey);
|
|
312
320
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
313
321
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
314
|
-
tx.
|
|
315
|
-
|
|
316
|
-
arguments:
|
|
322
|
+
tx.add(getOrder({
|
|
323
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
324
|
+
arguments: {
|
|
325
|
+
self: pool.address,
|
|
326
|
+
orderId: BigInt(orderId)
|
|
327
|
+
},
|
|
317
328
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
318
|
-
});
|
|
329
|
+
}));
|
|
319
330
|
};
|
|
320
331
|
this.getOrders = (poolKey, orderIds) => (tx) => {
|
|
321
332
|
const pool = this.#config.getPool(poolKey);
|
|
322
333
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
323
334
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
324
|
-
tx.
|
|
325
|
-
|
|
326
|
-
arguments:
|
|
335
|
+
tx.add(getOrders({
|
|
336
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
337
|
+
arguments: {
|
|
338
|
+
self: pool.address,
|
|
339
|
+
orderIds: orderIds.map(BigInt)
|
|
340
|
+
},
|
|
327
341
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
328
|
-
});
|
|
342
|
+
}));
|
|
329
343
|
};
|
|
330
344
|
this.burnDeep = (poolKey) => (tx) => {
|
|
331
345
|
const pool = this.#config.getPool(poolKey);
|
|
332
346
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
333
347
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
334
|
-
tx.
|
|
335
|
-
|
|
336
|
-
arguments:
|
|
348
|
+
tx.add(burnDeep({
|
|
349
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
350
|
+
arguments: {
|
|
351
|
+
self: pool.address,
|
|
352
|
+
treasuryCap: this.#config.DEEP_TREASURY_ID
|
|
353
|
+
},
|
|
337
354
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
338
|
-
});
|
|
355
|
+
}));
|
|
339
356
|
};
|
|
340
357
|
this.midPrice = (poolKey) => (tx) => {
|
|
341
358
|
const pool = this.#config.getPool(poolKey);
|
|
342
359
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
343
360
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
344
|
-
tx.
|
|
345
|
-
|
|
346
|
-
arguments:
|
|
361
|
+
tx.add(midPrice({
|
|
362
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
363
|
+
arguments: { self: pool.address },
|
|
347
364
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
348
|
-
});
|
|
365
|
+
}));
|
|
349
366
|
};
|
|
350
367
|
this.whitelisted = (poolKey) => (tx) => {
|
|
351
368
|
const pool = this.#config.getPool(poolKey);
|
|
352
369
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
353
370
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
354
|
-
tx.
|
|
355
|
-
|
|
356
|
-
arguments:
|
|
371
|
+
tx.add(whitelisted({
|
|
372
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
373
|
+
arguments: { self: pool.address },
|
|
357
374
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
358
|
-
});
|
|
375
|
+
}));
|
|
359
376
|
};
|
|
360
377
|
this.getQuoteQuantityOut = (poolKey, baseQuantity) => (tx) => {
|
|
361
378
|
const pool = this.#config.getPool(poolKey);
|
|
362
379
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
363
380
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
364
|
-
tx.
|
|
365
|
-
|
|
366
|
-
arguments:
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
],
|
|
381
|
+
tx.add(getQuoteQuantityOut({
|
|
382
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
383
|
+
arguments: {
|
|
384
|
+
self: pool.address,
|
|
385
|
+
baseQuantity: convertQuantity(baseQuantity, baseCoin.scalar)
|
|
386
|
+
},
|
|
371
387
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
372
|
-
});
|
|
388
|
+
}));
|
|
373
389
|
};
|
|
374
390
|
this.getBaseQuantityOut = (poolKey, quoteQuantity) => (tx) => {
|
|
375
391
|
const pool = this.#config.getPool(poolKey);
|
|
376
392
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
377
393
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
378
394
|
const quoteScalar = quoteCoin.scalar;
|
|
379
|
-
tx.
|
|
380
|
-
|
|
381
|
-
arguments:
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
],
|
|
395
|
+
tx.add(getBaseQuantityOut({
|
|
396
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
397
|
+
arguments: {
|
|
398
|
+
self: pool.address,
|
|
399
|
+
quoteQuantity: convertQuantity(quoteQuantity, quoteScalar)
|
|
400
|
+
},
|
|
386
401
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
387
|
-
});
|
|
402
|
+
}));
|
|
388
403
|
};
|
|
389
404
|
this.getQuantityOut = (poolKey, baseQuantity, quoteQuantity) => (tx) => {
|
|
390
405
|
const pool = this.#config.getPool(poolKey);
|
|
391
406
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
392
407
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
393
408
|
const quoteScalar = quoteCoin.scalar;
|
|
394
|
-
tx.
|
|
395
|
-
|
|
396
|
-
arguments:
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
],
|
|
409
|
+
tx.add(getQuantityOut({
|
|
410
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
411
|
+
arguments: {
|
|
412
|
+
self: pool.address,
|
|
413
|
+
baseQuantity: convertQuantity(baseQuantity, baseCoin.scalar),
|
|
414
|
+
quoteQuantity: convertQuantity(quoteQuantity, quoteScalar)
|
|
415
|
+
},
|
|
402
416
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
403
|
-
});
|
|
417
|
+
}));
|
|
404
418
|
};
|
|
405
419
|
this.accountOpenOrders = (poolKey, managerKey) => (tx) => {
|
|
406
420
|
const pool = this.#config.getPool(poolKey);
|
|
407
421
|
const manager = this.#config.getBalanceManager(managerKey);
|
|
408
422
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
409
423
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
410
|
-
tx.
|
|
411
|
-
|
|
412
|
-
arguments:
|
|
424
|
+
tx.add(accountOpenOrders({
|
|
425
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
426
|
+
arguments: {
|
|
427
|
+
self: pool.address,
|
|
428
|
+
balanceManager: manager.address
|
|
429
|
+
},
|
|
413
430
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
414
|
-
});
|
|
431
|
+
}));
|
|
415
432
|
};
|
|
416
433
|
this.getLevel2Range = (poolKey, priceLow, priceHigh, isBid) => (tx) => {
|
|
417
434
|
const pool = this.#config.getPool(poolKey);
|
|
418
435
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
419
436
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
420
|
-
tx.
|
|
421
|
-
|
|
422
|
-
arguments:
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
],
|
|
437
|
+
tx.add(getLevel2Range({
|
|
438
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
439
|
+
arguments: {
|
|
440
|
+
self: pool.address,
|
|
441
|
+
priceLow: convertPrice(priceLow, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar),
|
|
442
|
+
priceHigh: convertPrice(priceHigh, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar),
|
|
443
|
+
isBid
|
|
444
|
+
},
|
|
429
445
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
430
|
-
});
|
|
446
|
+
}));
|
|
431
447
|
};
|
|
432
448
|
this.getLevel2TicksFromMid = (poolKey, tickFromMid) => (tx) => {
|
|
433
449
|
const pool = this.#config.getPool(poolKey);
|
|
434
450
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
435
451
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
436
|
-
tx.
|
|
437
|
-
|
|
438
|
-
arguments:
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
],
|
|
452
|
+
tx.add(getLevel2TicksFromMid({
|
|
453
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
454
|
+
arguments: {
|
|
455
|
+
self: pool.address,
|
|
456
|
+
ticks: tickFromMid
|
|
457
|
+
},
|
|
443
458
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
444
|
-
});
|
|
459
|
+
}));
|
|
445
460
|
};
|
|
446
461
|
this.vaultBalances = (poolKey) => (tx) => {
|
|
447
462
|
const pool = this.#config.getPool(poolKey);
|
|
448
463
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
449
464
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
450
|
-
tx.
|
|
451
|
-
|
|
452
|
-
arguments:
|
|
465
|
+
tx.add(vaultBalances({
|
|
466
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
467
|
+
arguments: { self: pool.address },
|
|
453
468
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
454
|
-
});
|
|
469
|
+
}));
|
|
455
470
|
};
|
|
456
471
|
this.getPoolIdByAssets = (baseType, quoteType) => (tx) => {
|
|
457
|
-
tx.
|
|
458
|
-
|
|
459
|
-
arguments:
|
|
472
|
+
tx.add(getPoolIdByAsset({
|
|
473
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
474
|
+
arguments: { registry: this.#config.REGISTRY_ID },
|
|
460
475
|
typeArguments: [baseType, quoteType]
|
|
461
|
-
});
|
|
476
|
+
}));
|
|
462
477
|
};
|
|
463
478
|
this.swapExactBaseForQuote = (params) => (tx) => {
|
|
464
479
|
tx.setGasBudgetIfNotSet(GAS_BUDGET);
|
|
@@ -478,17 +493,16 @@ var DeepBookContract = class {
|
|
|
478
493
|
balance: convertQuantity(deepAmount, DEEP_SCALAR)
|
|
479
494
|
});
|
|
480
495
|
const minQuoteInput = convertQuantity(minQuote, quoteCoin.scalar);
|
|
481
|
-
const [baseCoinResult, quoteCoinResult, deepCoinResult] = tx.
|
|
482
|
-
|
|
483
|
-
arguments:
|
|
484
|
-
|
|
485
|
-
baseCoinInput,
|
|
486
|
-
deepCoin,
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
],
|
|
496
|
+
const [baseCoinResult, quoteCoinResult, deepCoinResult] = tx.add(swapExactBaseForQuote({
|
|
497
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
498
|
+
arguments: {
|
|
499
|
+
self: pool.address,
|
|
500
|
+
baseIn: baseCoinInput,
|
|
501
|
+
deepIn: deepCoin,
|
|
502
|
+
minQuoteOut: minQuoteInput
|
|
503
|
+
},
|
|
490
504
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
491
|
-
});
|
|
505
|
+
}));
|
|
492
506
|
return [
|
|
493
507
|
baseCoinResult,
|
|
494
508
|
quoteCoinResult,
|
|
@@ -513,17 +527,16 @@ var DeepBookContract = class {
|
|
|
513
527
|
balance: convertQuantity(deepAmount, DEEP_SCALAR)
|
|
514
528
|
});
|
|
515
529
|
const minBaseInput = convertQuantity(minBase, baseCoin.scalar);
|
|
516
|
-
const [baseCoinResult, quoteCoinResult, deepCoinResult] = tx.
|
|
517
|
-
|
|
518
|
-
arguments:
|
|
519
|
-
|
|
520
|
-
quoteCoinInput,
|
|
521
|
-
deepCoin,
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
],
|
|
530
|
+
const [baseCoinResult, quoteCoinResult, deepCoinResult] = tx.add(swapExactQuoteForBase({
|
|
531
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
532
|
+
arguments: {
|
|
533
|
+
self: pool.address,
|
|
534
|
+
quoteIn: quoteCoinInput,
|
|
535
|
+
deepIn: deepCoin,
|
|
536
|
+
minBaseOut: minBaseInput
|
|
537
|
+
},
|
|
525
538
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
526
|
-
});
|
|
539
|
+
}));
|
|
527
540
|
return [
|
|
528
541
|
baseCoinResult,
|
|
529
542
|
quoteCoinResult,
|
|
@@ -557,18 +570,17 @@ var DeepBookContract = class {
|
|
|
557
570
|
balance: convertQuantity(deepAmount, DEEP_SCALAR)
|
|
558
571
|
});
|
|
559
572
|
const minOutInput = convertQuantity(minOut, isBaseToCoin ? quoteCoinType.scalar : baseCoinType.scalar);
|
|
560
|
-
const [baseCoinResult, quoteCoinResult, deepCoinResult] = tx.
|
|
561
|
-
|
|
562
|
-
arguments:
|
|
563
|
-
|
|
564
|
-
baseCoinInput,
|
|
565
|
-
quoteCoinInput,
|
|
566
|
-
deepCoinInput,
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
],
|
|
573
|
+
const [baseCoinResult, quoteCoinResult, deepCoinResult] = tx.add(swapExactQuantity({
|
|
574
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
575
|
+
arguments: {
|
|
576
|
+
self: pool.address,
|
|
577
|
+
baseIn: baseCoinInput,
|
|
578
|
+
quoteIn: quoteCoinInput,
|
|
579
|
+
deepIn: deepCoinInput,
|
|
580
|
+
minOut: minOutInput
|
|
581
|
+
},
|
|
570
582
|
typeArguments: [baseCoinType.type, quoteCoinType.type]
|
|
571
|
-
});
|
|
583
|
+
}));
|
|
572
584
|
return [
|
|
573
585
|
baseCoinResult,
|
|
574
586
|
quoteCoinResult,
|
|
@@ -587,20 +599,19 @@ var DeepBookContract = class {
|
|
|
587
599
|
balance: convertQuantity(baseAmount, baseCoinType.scalar)
|
|
588
600
|
});
|
|
589
601
|
const minQuoteInput = convertQuantity(minQuote, quoteCoinType.scalar);
|
|
590
|
-
const [baseCoinResult, quoteCoinResult] = tx.
|
|
591
|
-
|
|
592
|
-
arguments:
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
baseCoinInput,
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
],
|
|
602
|
+
const [baseCoinResult, quoteCoinResult] = tx.add(swapExactBaseForQuoteWithManager({
|
|
603
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
604
|
+
arguments: {
|
|
605
|
+
self: pool.address,
|
|
606
|
+
balanceManager: balanceManager.address,
|
|
607
|
+
tradeCap,
|
|
608
|
+
depositCap,
|
|
609
|
+
withdrawCap,
|
|
610
|
+
baseIn: baseCoinInput,
|
|
611
|
+
minQuoteOut: minQuoteInput
|
|
612
|
+
},
|
|
602
613
|
typeArguments: [baseCoinType.type, quoteCoinType.type]
|
|
603
|
-
});
|
|
614
|
+
}));
|
|
604
615
|
return [baseCoinResult, quoteCoinResult];
|
|
605
616
|
};
|
|
606
617
|
this.swapExactQuoteForBaseWithManager = (params) => (tx) => {
|
|
@@ -615,20 +626,19 @@ var DeepBookContract = class {
|
|
|
615
626
|
balance: convertQuantity(quoteAmount, quoteCoinType.scalar)
|
|
616
627
|
});
|
|
617
628
|
const minBaseInput = convertQuantity(minBase, baseCoinType.scalar);
|
|
618
|
-
const [baseCoinResult, quoteCoinResult] = tx.
|
|
619
|
-
|
|
620
|
-
arguments:
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
quoteCoinInput,
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
],
|
|
629
|
+
const [baseCoinResult, quoteCoinResult] = tx.add(swapExactQuoteForBaseWithManager({
|
|
630
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
631
|
+
arguments: {
|
|
632
|
+
self: pool.address,
|
|
633
|
+
balanceManager: balanceManager.address,
|
|
634
|
+
tradeCap,
|
|
635
|
+
depositCap,
|
|
636
|
+
withdrawCap,
|
|
637
|
+
quoteIn: quoteCoinInput,
|
|
638
|
+
minBaseOut: minBaseInput
|
|
639
|
+
},
|
|
630
640
|
typeArguments: [baseCoinType.type, quoteCoinType.type]
|
|
631
|
-
});
|
|
641
|
+
}));
|
|
632
642
|
return [baseCoinResult, quoteCoinResult];
|
|
633
643
|
};
|
|
634
644
|
this.swapExactQuantityWithManager = (params) => (tx) => {
|
|
@@ -653,21 +663,20 @@ var DeepBookContract = class {
|
|
|
653
663
|
balance: convertQuantity(amount, quoteCoinType.scalar)
|
|
654
664
|
});
|
|
655
665
|
const minOutInput = convertQuantity(minOut, isBaseToCoin ? quoteCoinType.scalar : baseCoinType.scalar);
|
|
656
|
-
const [baseCoinResult, quoteCoinResult] = tx.
|
|
657
|
-
|
|
658
|
-
arguments:
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
baseCoinInput,
|
|
665
|
-
quoteCoinInput,
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
],
|
|
666
|
+
const [baseCoinResult, quoteCoinResult] = tx.add(swapExactQuantityWithManager({
|
|
667
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
668
|
+
arguments: {
|
|
669
|
+
self: pool.address,
|
|
670
|
+
balanceManager: balanceManager.address,
|
|
671
|
+
tradeCap,
|
|
672
|
+
depositCap,
|
|
673
|
+
withdrawCap,
|
|
674
|
+
baseIn: baseCoinInput,
|
|
675
|
+
quoteIn: quoteCoinInput,
|
|
676
|
+
minOut: minOutInput
|
|
677
|
+
},
|
|
669
678
|
typeArguments: [baseCoinType.type, quoteCoinType.type]
|
|
670
|
-
});
|
|
679
|
+
}));
|
|
671
680
|
return [baseCoinResult, quoteCoinResult];
|
|
672
681
|
};
|
|
673
682
|
this.createPermissionlessPool = (params) => (tx) => {
|
|
@@ -685,199 +694,212 @@ var DeepBookContract = class {
|
|
|
685
694
|
type: deepCoinType,
|
|
686
695
|
balance: POOL_CREATION_FEE_DEEP
|
|
687
696
|
});
|
|
688
|
-
tx.
|
|
689
|
-
|
|
690
|
-
arguments:
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
deepCoinInput
|
|
696
|
-
|
|
697
|
+
tx.add(createPermissionlessPool({
|
|
698
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
699
|
+
arguments: {
|
|
700
|
+
registry: this.#config.REGISTRY_ID,
|
|
701
|
+
tickSize: adjustedTickSize,
|
|
702
|
+
lotSize: adjustedLotSize,
|
|
703
|
+
minSize: adjustedMinSize,
|
|
704
|
+
creationFee: deepCoinInput
|
|
705
|
+
},
|
|
697
706
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
698
|
-
});
|
|
707
|
+
}));
|
|
699
708
|
};
|
|
700
709
|
this.poolTradeParams = (poolKey) => (tx) => {
|
|
701
710
|
const pool = this.#config.getPool(poolKey);
|
|
702
711
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
703
712
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
704
|
-
tx.
|
|
705
|
-
|
|
706
|
-
arguments:
|
|
713
|
+
tx.add(poolTradeParams({
|
|
714
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
715
|
+
arguments: { self: pool.address },
|
|
707
716
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
708
|
-
});
|
|
717
|
+
}));
|
|
709
718
|
};
|
|
710
719
|
this.poolBookParams = (poolKey) => (tx) => {
|
|
711
720
|
const pool = this.#config.getPool(poolKey);
|
|
712
721
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
713
722
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
714
|
-
tx.
|
|
715
|
-
|
|
716
|
-
arguments:
|
|
723
|
+
tx.add(poolBookParams({
|
|
724
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
725
|
+
arguments: { self: pool.address },
|
|
717
726
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
718
|
-
});
|
|
727
|
+
}));
|
|
719
728
|
};
|
|
720
729
|
this.account = (poolKey, managerKey) => (tx) => {
|
|
721
730
|
const pool = this.#config.getPool(poolKey);
|
|
722
731
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
723
732
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
724
733
|
const managerId = this.#config.getBalanceManager(managerKey).address;
|
|
725
|
-
tx.
|
|
726
|
-
|
|
727
|
-
arguments:
|
|
734
|
+
tx.add(account({
|
|
735
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
736
|
+
arguments: {
|
|
737
|
+
self: pool.address,
|
|
738
|
+
balanceManager: managerId
|
|
739
|
+
},
|
|
728
740
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
729
|
-
});
|
|
741
|
+
}));
|
|
730
742
|
};
|
|
731
743
|
this.lockedBalance = (poolKey, managerKey) => (tx) => {
|
|
732
744
|
const pool = this.#config.getPool(poolKey);
|
|
733
745
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
734
746
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
735
747
|
const managerId = this.#config.getBalanceManager(managerKey).address;
|
|
736
|
-
tx.
|
|
737
|
-
|
|
738
|
-
arguments:
|
|
748
|
+
tx.add(lockedBalance({
|
|
749
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
750
|
+
arguments: {
|
|
751
|
+
self: pool.address,
|
|
752
|
+
balanceManager: managerId
|
|
753
|
+
},
|
|
739
754
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
740
|
-
});
|
|
755
|
+
}));
|
|
741
756
|
};
|
|
742
757
|
this.getPoolDeepPrice = (poolKey) => (tx) => {
|
|
743
758
|
const pool = this.#config.getPool(poolKey);
|
|
744
759
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
745
760
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
746
|
-
tx.
|
|
747
|
-
|
|
748
|
-
arguments:
|
|
761
|
+
tx.add(getOrderDeepPrice({
|
|
762
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
763
|
+
arguments: { self: pool.address },
|
|
749
764
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
750
|
-
});
|
|
765
|
+
}));
|
|
751
766
|
};
|
|
752
767
|
this.getBalanceManagerIds = (owner) => (tx) => {
|
|
753
|
-
tx.
|
|
754
|
-
|
|
755
|
-
arguments:
|
|
756
|
-
|
|
768
|
+
tx.add(getBalanceManagerIds({
|
|
769
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
770
|
+
arguments: {
|
|
771
|
+
self: this.#config.REGISTRY_ID,
|
|
772
|
+
owner
|
|
773
|
+
}
|
|
774
|
+
}));
|
|
757
775
|
};
|
|
758
776
|
this.getPoolReferralBalances = (poolKey, referral) => (tx) => {
|
|
759
777
|
const pool = this.#config.getPool(poolKey);
|
|
760
778
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
761
779
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
762
|
-
return tx.
|
|
763
|
-
|
|
764
|
-
arguments:
|
|
780
|
+
return tx.add(getPoolReferralBalances({
|
|
781
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
782
|
+
arguments: {
|
|
783
|
+
self: pool.address,
|
|
784
|
+
referral
|
|
785
|
+
},
|
|
765
786
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
766
|
-
});
|
|
787
|
+
}));
|
|
767
788
|
};
|
|
768
789
|
this.poolReferralMultiplier = (poolKey, referral) => (tx) => {
|
|
769
790
|
const pool = this.#config.getPool(poolKey);
|
|
770
791
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
771
792
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
772
|
-
return tx.
|
|
773
|
-
|
|
774
|
-
arguments:
|
|
793
|
+
return tx.add(poolReferralMultiplier({
|
|
794
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
795
|
+
arguments: {
|
|
796
|
+
self: pool.address,
|
|
797
|
+
referral
|
|
798
|
+
},
|
|
775
799
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
776
|
-
});
|
|
800
|
+
}));
|
|
777
801
|
};
|
|
778
802
|
this.stablePool = (poolKey) => (tx) => {
|
|
779
803
|
const pool = this.#config.getPool(poolKey);
|
|
780
804
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
781
805
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
782
|
-
return tx.
|
|
783
|
-
|
|
784
|
-
arguments:
|
|
806
|
+
return tx.add(stablePool({
|
|
807
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
808
|
+
arguments: { self: pool.address },
|
|
785
809
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
786
|
-
});
|
|
810
|
+
}));
|
|
787
811
|
};
|
|
788
812
|
this.registeredPool = (poolKey) => (tx) => {
|
|
789
813
|
const pool = this.#config.getPool(poolKey);
|
|
790
814
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
791
815
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
792
|
-
return tx.
|
|
793
|
-
|
|
794
|
-
arguments:
|
|
816
|
+
return tx.add(registeredPool({
|
|
817
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
818
|
+
arguments: { self: pool.address },
|
|
795
819
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
796
|
-
});
|
|
820
|
+
}));
|
|
797
821
|
};
|
|
798
822
|
this.getQuoteQuantityOutInputFee = (poolKey, baseQuantity) => (tx) => {
|
|
799
823
|
const pool = this.#config.getPool(poolKey);
|
|
800
824
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
801
825
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
802
|
-
return tx.
|
|
803
|
-
|
|
804
|
-
arguments:
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
],
|
|
826
|
+
return tx.add(getQuoteQuantityOutInputFee({
|
|
827
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
828
|
+
arguments: {
|
|
829
|
+
self: pool.address,
|
|
830
|
+
baseQuantity: convertQuantity(baseQuantity, baseCoin.scalar)
|
|
831
|
+
},
|
|
809
832
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
810
|
-
});
|
|
833
|
+
}));
|
|
811
834
|
};
|
|
812
835
|
this.getBaseQuantityOutInputFee = (poolKey, quoteQuantity) => (tx) => {
|
|
813
836
|
const pool = this.#config.getPool(poolKey);
|
|
814
837
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
815
838
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
816
|
-
return tx.
|
|
817
|
-
|
|
818
|
-
arguments:
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
],
|
|
839
|
+
return tx.add(getBaseQuantityOutInputFee({
|
|
840
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
841
|
+
arguments: {
|
|
842
|
+
self: pool.address,
|
|
843
|
+
quoteQuantity: convertQuantity(quoteQuantity, quoteCoin.scalar)
|
|
844
|
+
},
|
|
823
845
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
824
|
-
});
|
|
846
|
+
}));
|
|
825
847
|
};
|
|
826
848
|
this.getQuantityOutInputFee = (poolKey, baseQuantity, quoteQuantity) => (tx) => {
|
|
827
849
|
const pool = this.#config.getPool(poolKey);
|
|
828
850
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
829
851
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
830
|
-
return tx.
|
|
831
|
-
|
|
832
|
-
arguments:
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
],
|
|
852
|
+
return tx.add(getQuantityOutInputFee({
|
|
853
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
854
|
+
arguments: {
|
|
855
|
+
self: pool.address,
|
|
856
|
+
baseQuantity: convertQuantity(baseQuantity, baseCoin.scalar),
|
|
857
|
+
quoteQuantity: convertQuantity(quoteQuantity, quoteCoin.scalar)
|
|
858
|
+
},
|
|
838
859
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
839
|
-
});
|
|
860
|
+
}));
|
|
840
861
|
};
|
|
841
862
|
this.getBaseQuantityIn = (poolKey, targetQuoteQuantity, payWithDeep) => (tx) => {
|
|
842
863
|
const pool = this.#config.getPool(poolKey);
|
|
843
864
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
844
865
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
845
|
-
return tx.
|
|
846
|
-
|
|
847
|
-
arguments:
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
],
|
|
866
|
+
return tx.add(getBaseQuantityIn({
|
|
867
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
868
|
+
arguments: {
|
|
869
|
+
self: pool.address,
|
|
870
|
+
targetQuoteQuantity: convertQuantity(targetQuoteQuantity, quoteCoin.scalar),
|
|
871
|
+
payWithDeep
|
|
872
|
+
},
|
|
853
873
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
854
|
-
});
|
|
874
|
+
}));
|
|
855
875
|
};
|
|
856
876
|
this.getQuoteQuantityIn = (poolKey, targetBaseQuantity, payWithDeep) => (tx) => {
|
|
857
877
|
const pool = this.#config.getPool(poolKey);
|
|
858
878
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
859
879
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
860
|
-
return tx.
|
|
861
|
-
|
|
862
|
-
arguments:
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
],
|
|
880
|
+
return tx.add(getQuoteQuantityIn({
|
|
881
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
882
|
+
arguments: {
|
|
883
|
+
self: pool.address,
|
|
884
|
+
targetBaseQuantity: convertQuantity(targetBaseQuantity, baseCoin.scalar),
|
|
885
|
+
payWithDeep
|
|
886
|
+
},
|
|
868
887
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
869
|
-
});
|
|
888
|
+
}));
|
|
870
889
|
};
|
|
871
890
|
this.getAccountOrderDetails = (poolKey, managerKey) => (tx) => {
|
|
872
891
|
const pool = this.#config.getPool(poolKey);
|
|
873
892
|
const manager = this.#config.getBalanceManager(managerKey);
|
|
874
893
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
875
894
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
876
|
-
return tx.
|
|
877
|
-
|
|
878
|
-
arguments:
|
|
895
|
+
return tx.add(getAccountOrderDetails({
|
|
896
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
897
|
+
arguments: {
|
|
898
|
+
self: pool.address,
|
|
899
|
+
balanceManager: manager.address
|
|
900
|
+
},
|
|
879
901
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
880
|
-
});
|
|
902
|
+
}));
|
|
881
903
|
};
|
|
882
904
|
this.getOrderDeepRequired = (poolKey, baseQuantity, price) => (tx) => {
|
|
883
905
|
const pool = this.#config.getPool(poolKey);
|
|
@@ -885,56 +907,59 @@ var DeepBookContract = class {
|
|
|
885
907
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
886
908
|
const inputPrice = convertPrice(price, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar);
|
|
887
909
|
const inputQuantity = convertQuantity(baseQuantity, baseCoin.scalar);
|
|
888
|
-
return tx.
|
|
889
|
-
|
|
890
|
-
arguments:
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
910
|
+
return tx.add(getOrderDeepRequired({
|
|
911
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
912
|
+
arguments: {
|
|
913
|
+
self: pool.address,
|
|
914
|
+
baseQuantity: inputQuantity,
|
|
915
|
+
price: inputPrice
|
|
916
|
+
},
|
|
895
917
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
896
|
-
});
|
|
918
|
+
}));
|
|
897
919
|
};
|
|
898
920
|
this.accountExists = (poolKey, managerKey) => (tx) => {
|
|
899
921
|
const pool = this.#config.getPool(poolKey);
|
|
900
922
|
const manager = this.#config.getBalanceManager(managerKey);
|
|
901
923
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
902
924
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
903
|
-
return tx.
|
|
904
|
-
|
|
905
|
-
arguments:
|
|
925
|
+
return tx.add(accountExists({
|
|
926
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
927
|
+
arguments: {
|
|
928
|
+
self: pool.address,
|
|
929
|
+
balanceManager: manager.address
|
|
930
|
+
},
|
|
906
931
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
907
|
-
});
|
|
932
|
+
}));
|
|
908
933
|
};
|
|
909
934
|
this.poolTradeParamsNext = (poolKey) => (tx) => {
|
|
910
935
|
const pool = this.#config.getPool(poolKey);
|
|
911
936
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
912
937
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
913
|
-
return tx.
|
|
914
|
-
|
|
915
|
-
arguments:
|
|
938
|
+
return tx.add(poolTradeParamsNext({
|
|
939
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
940
|
+
arguments: { self: pool.address },
|
|
916
941
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
917
|
-
});
|
|
942
|
+
}));
|
|
918
943
|
};
|
|
919
944
|
this.quorum = (poolKey) => (tx) => {
|
|
920
945
|
const pool = this.#config.getPool(poolKey);
|
|
921
946
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
922
947
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
923
|
-
return tx.
|
|
924
|
-
|
|
925
|
-
arguments:
|
|
948
|
+
return tx.add(quorum({
|
|
949
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
950
|
+
arguments: { self: pool.address },
|
|
926
951
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
927
|
-
});
|
|
952
|
+
}));
|
|
928
953
|
};
|
|
929
954
|
this.poolId = (poolKey) => (tx) => {
|
|
930
955
|
const pool = this.#config.getPool(poolKey);
|
|
931
956
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
932
957
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
933
|
-
return tx.
|
|
934
|
-
|
|
935
|
-
arguments:
|
|
958
|
+
return tx.add(id({
|
|
959
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
960
|
+
arguments: { self: pool.address },
|
|
936
961
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
937
|
-
});
|
|
962
|
+
}));
|
|
938
963
|
};
|
|
939
964
|
this.canPlaceLimitOrder = (params) => (tx) => {
|
|
940
965
|
const { poolKey, balanceManagerKey, price, quantity, isBid, payWithDeep, expireTimestamp } = params;
|
|
@@ -944,20 +969,19 @@ var DeepBookContract = class {
|
|
|
944
969
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
945
970
|
const inputPrice = convertPrice(price, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar);
|
|
946
971
|
const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
|
|
947
|
-
return tx.
|
|
948
|
-
|
|
949
|
-
arguments:
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
],
|
|
972
|
+
return tx.add(canPlaceLimitOrder({
|
|
973
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
974
|
+
arguments: {
|
|
975
|
+
self: pool.address,
|
|
976
|
+
balanceManager: manager.address,
|
|
977
|
+
price: inputPrice,
|
|
978
|
+
quantity: inputQuantity,
|
|
979
|
+
isBid,
|
|
980
|
+
payWithDeep,
|
|
981
|
+
expireTimestamp
|
|
982
|
+
},
|
|
959
983
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
960
|
-
});
|
|
984
|
+
}));
|
|
961
985
|
};
|
|
962
986
|
this.canPlaceMarketOrder = (params) => (tx) => {
|
|
963
987
|
const { poolKey, balanceManagerKey, quantity, isBid, payWithDeep } = params;
|
|
@@ -966,29 +990,31 @@ var DeepBookContract = class {
|
|
|
966
990
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
967
991
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
968
992
|
const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
|
|
969
|
-
return tx.
|
|
970
|
-
|
|
971
|
-
arguments:
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
],
|
|
993
|
+
return tx.add(canPlaceMarketOrder({
|
|
994
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
995
|
+
arguments: {
|
|
996
|
+
self: pool.address,
|
|
997
|
+
balanceManager: manager.address,
|
|
998
|
+
quantity: inputQuantity,
|
|
999
|
+
isBid,
|
|
1000
|
+
payWithDeep
|
|
1001
|
+
},
|
|
979
1002
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
980
|
-
});
|
|
1003
|
+
}));
|
|
981
1004
|
};
|
|
982
1005
|
this.checkMarketOrderParams = (poolKey, quantity) => (tx) => {
|
|
983
1006
|
const pool = this.#config.getPool(poolKey);
|
|
984
1007
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
985
1008
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
986
1009
|
const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
|
|
987
|
-
return tx.
|
|
988
|
-
|
|
989
|
-
arguments:
|
|
1010
|
+
return tx.add(checkMarketOrderParams({
|
|
1011
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
1012
|
+
arguments: {
|
|
1013
|
+
self: pool.address,
|
|
1014
|
+
quantity: inputQuantity
|
|
1015
|
+
},
|
|
990
1016
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
991
|
-
});
|
|
1017
|
+
}));
|
|
992
1018
|
};
|
|
993
1019
|
this.checkLimitOrderParams = (poolKey, price, quantity, expireTimestamp) => (tx) => {
|
|
994
1020
|
const pool = this.#config.getPool(poolKey);
|
|
@@ -996,17 +1022,16 @@ var DeepBookContract = class {
|
|
|
996
1022
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
997
1023
|
const inputPrice = convertPrice(price, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar);
|
|
998
1024
|
const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
|
|
999
|
-
return tx.
|
|
1000
|
-
|
|
1001
|
-
arguments:
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
],
|
|
1025
|
+
return tx.add(checkLimitOrderParams({
|
|
1026
|
+
package: this.#config.DEEPBOOK_PACKAGE_ID,
|
|
1027
|
+
arguments: {
|
|
1028
|
+
self: pool.address,
|
|
1029
|
+
price: inputPrice,
|
|
1030
|
+
quantity: inputQuantity,
|
|
1031
|
+
expireTimestamp
|
|
1032
|
+
},
|
|
1008
1033
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
1009
|
-
});
|
|
1034
|
+
}));
|
|
1010
1035
|
};
|
|
1011
1036
|
this.#config = config;
|
|
1012
1037
|
}
|