@mysten/deepbook-v3 1.5.8 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +73 -0
- package/dist/client.d.mts +5 -0
- package/dist/client.d.mts.map +1 -1
- package/dist/client.mjs +7 -0
- package/dist/client.mjs.map +1 -1
- package/dist/contracts/deepbook/account.d.mts +18 -18
- package/dist/contracts/deepbook/account.d.mts.map +1 -1
- package/dist/contracts/deepbook/balance_manager.mjs +413 -0
- package/dist/contracts/deepbook/balance_manager.mjs.map +1 -0
- package/dist/contracts/deepbook/big_vector.mjs +43 -0
- package/dist/contracts/deepbook/big_vector.mjs.map +1 -0
- package/dist/contracts/deepbook/book.mjs +29 -0
- package/dist/contracts/deepbook/book.mjs.map +1 -0
- package/dist/contracts/deepbook/deep_price.d.mts +3 -3
- package/dist/contracts/deepbook/deep_price.d.mts.map +1 -1
- package/dist/contracts/deepbook/deep_price.mjs +1 -1
- package/dist/contracts/deepbook/deps/std/type_name.mjs +17 -0
- package/dist/contracts/deepbook/deps/std/type_name.mjs.map +1 -0
- package/dist/contracts/deepbook/deps/sui/bag.mjs +43 -0
- package/dist/contracts/deepbook/deps/sui/bag.mjs.map +1 -0
- package/dist/contracts/deepbook/deps/sui/balance.mjs +21 -0
- package/dist/contracts/deepbook/deps/sui/balance.mjs.map +1 -0
- package/dist/contracts/deepbook/deps/sui/table.mjs +38 -0
- package/dist/contracts/deepbook/deps/sui/table.mjs.map +1 -0
- package/dist/contracts/deepbook/deps/sui/vec_map.mjs +37 -0
- package/dist/contracts/deepbook/deps/sui/vec_map.mjs.map +1 -0
- package/dist/contracts/deepbook/deps/sui/versioned.mjs +19 -0
- package/dist/contracts/deepbook/deps/sui/versioned.mjs.map +1 -0
- package/dist/contracts/deepbook/governance.mjs +49 -0
- package/dist/contracts/deepbook/governance.mjs.map +1 -0
- package/dist/contracts/deepbook/history.mjs +56 -0
- package/dist/contracts/deepbook/history.mjs.map +1 -0
- package/dist/contracts/deepbook/order.d.mts +12 -12
- package/dist/contracts/deepbook/pool.mjs +1739 -0
- package/dist/contracts/deepbook/pool.mjs.map +1 -0
- package/dist/contracts/deepbook/registry.mjs +295 -0
- package/dist/contracts/deepbook/registry.mjs.map +1 -0
- package/dist/contracts/deepbook/state.mjs +89 -0
- package/dist/contracts/deepbook/state.mjs.map +1 -0
- package/dist/contracts/deepbook/trade_params.mjs +21 -0
- package/dist/contracts/deepbook/trade_params.mjs.map +1 -0
- package/dist/contracts/deepbook/vault.mjs +42 -0
- package/dist/contracts/deepbook/vault.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/deepbook/balance_manager.mjs +53 -0
- package/dist/contracts/deepbook_margin/deps/deepbook/balance_manager.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/std/type_name.mjs +17 -0
- package/dist/contracts/deepbook_margin/deps/std/type_name.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/bag.mjs +43 -0
- package/dist/contracts/deepbook_margin/deps/sui/bag.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/balance.mjs +21 -0
- package/dist/contracts/deepbook_margin/deps/sui/balance.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/table.mjs +38 -0
- package/dist/contracts/deepbook_margin/deps/sui/table.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/vec_map.mjs +37 -0
- package/dist/contracts/deepbook_margin/deps/sui/vec_map.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/vec_set.mjs +26 -0
- package/dist/contracts/deepbook_margin/deps/sui/vec_set.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/versioned.mjs +19 -0
- package/dist/contracts/deepbook_margin/deps/sui/versioned.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/margin_manager.mjs +989 -0
- package/dist/contracts/deepbook_margin/margin_manager.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/margin_pool.mjs +550 -0
- package/dist/contracts/deepbook_margin/margin_pool.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/margin_registry.mjs +786 -0
- package/dist/contracts/deepbook_margin/margin_registry.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/margin_state.mjs +30 -0
- package/dist/contracts/deepbook_margin/margin_state.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/oracle.mjs +82 -0
- package/dist/contracts/deepbook_margin/oracle.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/pool_proxy.mjs +644 -0
- package/dist/contracts/deepbook_margin/pool_proxy.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/position_manager.mjs +32 -0
- package/dist/contracts/deepbook_margin/position_manager.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/protocol_config.mjs +122 -0
- package/dist/contracts/deepbook_margin/protocol_config.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/protocol_fees.mjs +58 -0
- package/dist/contracts/deepbook_margin/protocol_fees.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/rate_limiter.mjs +26 -0
- package/dist/contracts/deepbook_margin/rate_limiter.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/tpsl.mjs +171 -0
- package/dist/contracts/deepbook_margin/tpsl.mjs.map +1 -0
- package/dist/contracts/margin_liquidation/deps/sui/bag.mjs +43 -0
- package/dist/contracts/margin_liquidation/deps/sui/bag.mjs.map +1 -0
- package/dist/contracts/margin_liquidation/liquidation_vault.mjs +179 -0
- package/dist/contracts/margin_liquidation/liquidation_vault.mjs.map +1 -0
- package/dist/contracts/utils/index.d.mts +1 -1
- package/dist/contracts/utils/index.mjs +92 -3
- package/dist/contracts/utils/index.mjs.map +1 -1
- package/dist/queries/registryQueries.mjs +13 -0
- package/dist/queries/registryQueries.mjs.map +1 -1
- package/dist/transactions/balanceManager.d.mts.map +1 -1
- package/dist/transactions/balanceManager.mjs +119 -100
- package/dist/transactions/balanceManager.mjs.map +1 -1
- package/dist/transactions/deepbook.d.mts.map +1 -1
- package/dist/transactions/deepbook.mjs +464 -439
- package/dist/transactions/deepbook.mjs.map +1 -1
- package/dist/transactions/deepbookAdmin.d.mts.map +1 -1
- package/dist/transactions/deepbookAdmin.mjs +151 -135
- package/dist/transactions/deepbookAdmin.mjs.map +1 -1
- package/dist/transactions/flashLoans.d.mts.map +1 -1
- package/dist/transactions/flashLoans.mjs +29 -22
- package/dist/transactions/flashLoans.mjs.map +1 -1
- package/dist/transactions/governance.d.mts.map +1 -1
- package/dist/transactions/governance.mjs +34 -33
- package/dist/transactions/governance.mjs.map +1 -1
- package/dist/transactions/marginAdmin.d.mts +17 -7
- package/dist/transactions/marginAdmin.d.mts.map +1 -1
- package/dist/transactions/marginAdmin.mjs +186 -169
- package/dist/transactions/marginAdmin.mjs.map +1 -1
- package/dist/transactions/marginLiquidations.d.mts +3 -3
- package/dist/transactions/marginLiquidations.d.mts.map +1 -1
- package/dist/transactions/marginLiquidations.mjs +53 -54
- package/dist/transactions/marginLiquidations.mjs.map +1 -1
- package/dist/transactions/marginMaintainer.d.mts +5 -5
- package/dist/transactions/marginMaintainer.d.mts.map +1 -1
- package/dist/transactions/marginMaintainer.mjs +83 -83
- package/dist/transactions/marginMaintainer.mjs.map +1 -1
- package/dist/transactions/marginManager.d.mts +32 -32
- package/dist/transactions/marginManager.d.mts.map +1 -1
- package/dist/transactions/marginManager.mjs +330 -317
- package/dist/transactions/marginManager.mjs.map +1 -1
- package/dist/transactions/marginPool.d.mts +18 -18
- package/dist/transactions/marginPool.d.mts.map +1 -1
- package/dist/transactions/marginPool.mjs +93 -89
- package/dist/transactions/marginPool.mjs.map +1 -1
- package/dist/transactions/marginRegistry.d.mts +22 -15
- package/dist/transactions/marginRegistry.d.mts.map +1 -1
- package/dist/transactions/marginRegistry.mjs +101 -68
- package/dist/transactions/marginRegistry.mjs.map +1 -1
- package/dist/transactions/marginTPSL.d.mts +27 -9
- package/dist/transactions/marginTPSL.d.mts.map +1 -1
- package/dist/transactions/marginTPSL.mjs +108 -82
- package/dist/transactions/marginTPSL.mjs.map +1 -1
- package/dist/transactions/poolProxy.d.mts +37 -5
- package/dist/transactions/poolProxy.d.mts.map +1 -1
- package/dist/transactions/poolProxy.mjs +269 -189
- package/dist/transactions/poolProxy.mjs.map +1 -1
- package/dist/utils/constants.mjs +4 -4
- package/dist/utils/constants.mjs.map +1 -1
- package/package.json +3 -3
- package/src/client.ts +8 -0
- package/src/contracts/deepbook/balance_manager.ts +46 -5
- package/src/contracts/deepbook/constants.ts +13 -0
- package/src/contracts/deepbook/pool.ts +133 -0
- package/src/contracts/deepbook/registry.ts +136 -1
- package/src/contracts/deepbook_margin/deps/deepbook/balance_manager.ts +49 -0
- package/src/contracts/deepbook_margin/deps/std/type_name.ts +24 -0
- package/src/contracts/deepbook_margin/deps/sui/bag.ts +41 -0
- package/src/contracts/deepbook_margin/deps/sui/balance.ts +19 -0
- package/src/contracts/deepbook_margin/deps/sui/table.ts +36 -0
- package/src/contracts/deepbook_margin/deps/sui/vec_map.ts +33 -0
- package/src/contracts/deepbook_margin/deps/sui/vec_set.ts +22 -0
- package/src/contracts/deepbook_margin/deps/sui/versioned.ts +13 -0
- package/src/contracts/deepbook_margin/margin_constants.ts +329 -0
- package/src/contracts/deepbook_margin/margin_manager.ts +1772 -0
- package/src/contracts/deepbook_margin/margin_pool.ts +1129 -0
- package/src/contracts/deepbook_margin/margin_registry.ts +1207 -0
- package/src/contracts/deepbook_margin/margin_state.ts +26 -0
- package/src/contracts/deepbook_margin/oracle.ts +99 -0
- package/src/contracts/deepbook_margin/pool_proxy.ts +1298 -0
- package/src/contracts/deepbook_margin/position_manager.ts +28 -0
- package/src/contracts/deepbook_margin/protocol_config.ts +163 -0
- package/src/contracts/deepbook_margin/protocol_fees.ts +153 -0
- package/src/contracts/deepbook_margin/rate_limiter.ts +80 -0
- package/src/contracts/deepbook_margin/tpsl.ts +559 -0
- package/src/contracts/margin_liquidation/deps/sui/bag.ts +41 -0
- package/src/contracts/margin_liquidation/liquidation_vault.ts +401 -0
- package/src/queries/registryQueries.ts +15 -0
- package/src/transactions/balanceManager.ts +140 -90
- package/src/transactions/deepbook.ts +586 -494
- package/src/transactions/deepbookAdmin.ts +154 -146
- package/src/transactions/flashLoans.ts +29 -20
- package/src/transactions/governance.ts +50 -37
- package/src/transactions/marginAdmin.ts +247 -188
- package/src/transactions/marginLiquidations.ts +70 -55
- package/src/transactions/marginMaintainer.ts +106 -88
- package/src/transactions/marginManager.ts +414 -348
- package/src/transactions/marginPool.ts +140 -103
- package/src/transactions/marginRegistry.ts +103 -70
- package/src/transactions/marginTPSL.ts +151 -87
- package/src/transactions/poolProxy.ts +384 -205
- package/src/utils/constants.ts +4 -4
|
@@ -5,6 +5,7 @@ import { coinWithBalance } from '@mysten/sui/transactions';
|
|
|
5
5
|
|
|
6
6
|
import type { DeepBookConfig } from '../utils/config.js';
|
|
7
7
|
import { convertQuantity } from '../utils/conversion.js';
|
|
8
|
+
import * as liquidationVaultMoveCalls from '../contracts/margin_liquidation/liquidation_vault.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* MarginLiquidationsContract class for managing LiquidationVault operations.
|
|
@@ -25,10 +26,12 @@ export class MarginLiquidationsContract {
|
|
|
25
26
|
* @returns A function that takes a Transaction object
|
|
26
27
|
*/
|
|
27
28
|
createLiquidationVault = (liquidationAdminCap: string) => (tx: Transaction) => {
|
|
28
|
-
tx.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
tx.add(
|
|
30
|
+
liquidationVaultMoveCalls.createLiquidationVault({
|
|
31
|
+
package: this.#config.LIQUIDATION_PACKAGE_ID,
|
|
32
|
+
arguments: { LiquidationCap: liquidationAdminCap },
|
|
33
|
+
}),
|
|
34
|
+
);
|
|
32
35
|
};
|
|
33
36
|
|
|
34
37
|
/**
|
|
@@ -47,11 +50,13 @@ export class MarginLiquidationsContract {
|
|
|
47
50
|
type: coin.type,
|
|
48
51
|
balance: convertQuantity(amount, coin.scalar),
|
|
49
52
|
});
|
|
50
|
-
tx.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
tx.add(
|
|
54
|
+
liquidationVaultMoveCalls.deposit({
|
|
55
|
+
package: this.#config.LIQUIDATION_PACKAGE_ID,
|
|
56
|
+
arguments: { self: vaultId, LiquidationCap: liquidationAdminCap, coin: depositCoin },
|
|
57
|
+
typeArguments: [coin.type],
|
|
58
|
+
}),
|
|
59
|
+
);
|
|
55
60
|
};
|
|
56
61
|
|
|
57
62
|
/**
|
|
@@ -66,15 +71,17 @@ export class MarginLiquidationsContract {
|
|
|
66
71
|
(vaultId: string, liquidationAdminCap: string, coinKey: string, amount: number) =>
|
|
67
72
|
(tx: Transaction) => {
|
|
68
73
|
const coin = this.#config.getCoin(coinKey);
|
|
69
|
-
return tx.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
return tx.add(
|
|
75
|
+
liquidationVaultMoveCalls.withdraw({
|
|
76
|
+
package: this.#config.LIQUIDATION_PACKAGE_ID,
|
|
77
|
+
arguments: {
|
|
78
|
+
self: vaultId,
|
|
79
|
+
LiquidationCap: liquidationAdminCap,
|
|
80
|
+
amount: convertQuantity(amount, coin.scalar),
|
|
81
|
+
},
|
|
82
|
+
typeArguments: [coin.type],
|
|
83
|
+
}),
|
|
84
|
+
);
|
|
78
85
|
};
|
|
79
86
|
|
|
80
87
|
/**
|
|
@@ -94,27 +101,30 @@ export class MarginLiquidationsContract {
|
|
|
94
101
|
const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
|
|
95
102
|
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
96
103
|
|
|
104
|
+
// Build the Option arg first so its pure input registers ahead of the
|
|
105
|
+
// object inputs (matches the original positional ordering — byte-identical).
|
|
97
106
|
const repayAmountArg =
|
|
98
107
|
repayAmount !== undefined
|
|
99
108
|
? tx.pure.option('u64', convertQuantity(repayAmount, baseCoin.scalar))
|
|
100
109
|
: tx.pure.option('u64', null);
|
|
101
110
|
|
|
102
|
-
tx.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
111
|
+
tx.add(
|
|
112
|
+
liquidationVaultMoveCalls.liquidateBase({
|
|
113
|
+
package: this.#config.LIQUIDATION_PACKAGE_ID,
|
|
114
|
+
arguments: {
|
|
115
|
+
self: vaultId,
|
|
116
|
+
marginManager: managerAddress,
|
|
117
|
+
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
118
|
+
baseOracle: baseCoin.priceInfoObjectId!,
|
|
119
|
+
quoteOracle: quoteCoin.priceInfoObjectId!,
|
|
120
|
+
baseMarginPool: baseMarginPool.address,
|
|
121
|
+
quoteMarginPool: quoteMarginPool.address,
|
|
122
|
+
pool: pool.address,
|
|
123
|
+
repayAmount: repayAmountArg,
|
|
124
|
+
},
|
|
125
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
126
|
+
}),
|
|
127
|
+
);
|
|
118
128
|
};
|
|
119
129
|
|
|
120
130
|
/**
|
|
@@ -134,27 +144,30 @@ export class MarginLiquidationsContract {
|
|
|
134
144
|
const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
|
|
135
145
|
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
136
146
|
|
|
147
|
+
// Build the Option arg first so its pure input registers ahead of the
|
|
148
|
+
// object inputs (matches the original positional ordering — byte-identical).
|
|
137
149
|
const repayAmountArg =
|
|
138
150
|
repayAmount !== undefined
|
|
139
151
|
? tx.pure.option('u64', convertQuantity(repayAmount, quoteCoin.scalar))
|
|
140
152
|
: tx.pure.option('u64', null);
|
|
141
153
|
|
|
142
|
-
tx.
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
154
|
+
tx.add(
|
|
155
|
+
liquidationVaultMoveCalls.liquidateQuote({
|
|
156
|
+
package: this.#config.LIQUIDATION_PACKAGE_ID,
|
|
157
|
+
arguments: {
|
|
158
|
+
self: vaultId,
|
|
159
|
+
marginManager: managerAddress,
|
|
160
|
+
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
161
|
+
baseOracle: baseCoin.priceInfoObjectId!,
|
|
162
|
+
quoteOracle: quoteCoin.priceInfoObjectId!,
|
|
163
|
+
baseMarginPool: baseMarginPool.address,
|
|
164
|
+
quoteMarginPool: quoteMarginPool.address,
|
|
165
|
+
pool: pool.address,
|
|
166
|
+
repayAmount: repayAmountArg,
|
|
167
|
+
},
|
|
168
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
169
|
+
}),
|
|
170
|
+
);
|
|
158
171
|
};
|
|
159
172
|
|
|
160
173
|
// === Read-Only Functions ===
|
|
@@ -167,10 +180,12 @@ export class MarginLiquidationsContract {
|
|
|
167
180
|
*/
|
|
168
181
|
balance = (vaultId: string, coinKey: string) => (tx: Transaction) => {
|
|
169
182
|
const coin = this.#config.getCoin(coinKey);
|
|
170
|
-
return tx.
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
183
|
+
return tx.add(
|
|
184
|
+
liquidationVaultMoveCalls.balance({
|
|
185
|
+
package: this.#config.LIQUIDATION_PACKAGE_ID,
|
|
186
|
+
arguments: { self: vaultId },
|
|
187
|
+
typeArguments: [coin.type],
|
|
188
|
+
}),
|
|
189
|
+
);
|
|
175
190
|
};
|
|
176
191
|
}
|
|
@@ -11,6 +11,8 @@ import type { DeepBookConfig } from '../utils/config.js';
|
|
|
11
11
|
import type { MarginPoolConfigParams, InterestConfigParams } from '../types/index.js';
|
|
12
12
|
import { FLOAT_SCALAR } from '../utils/config.js';
|
|
13
13
|
import { convertQuantity, convertRate } from '../utils/conversion.js';
|
|
14
|
+
import * as marginPoolMoveCalls from '../contracts/deepbook_margin/margin_pool.js';
|
|
15
|
+
import * as protocolConfigMoveCalls from '../contracts/deepbook_margin/protocol_config.js';
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* DeepBookMaintainerContract class for managing maintainer actions.
|
|
@@ -45,16 +47,17 @@ export class MarginMaintainerContract {
|
|
|
45
47
|
*/
|
|
46
48
|
createMarginPool = (coinKey: string, poolConfig: TransactionArgument) => (tx: Transaction) => {
|
|
47
49
|
const coin = this.#config.getCoin(coinKey);
|
|
48
|
-
tx.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
tx.add(
|
|
51
|
+
marginPoolMoveCalls.createMarginPool({
|
|
52
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
53
|
+
arguments: {
|
|
54
|
+
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
55
|
+
config: poolConfig,
|
|
56
|
+
maintainerCap: this.#marginMaintainerCap(),
|
|
57
|
+
},
|
|
58
|
+
typeArguments: [coin.type],
|
|
59
|
+
}),
|
|
60
|
+
);
|
|
58
61
|
};
|
|
59
62
|
|
|
60
63
|
/**
|
|
@@ -84,10 +87,15 @@ export class MarginMaintainerContract {
|
|
|
84
87
|
})(tx)
|
|
85
88
|
: this.newMarginPoolConfig(coinKey, marginPoolConfig)(tx);
|
|
86
89
|
const interestConfigObject = this.newInterestConfig(interestConfig)(tx);
|
|
87
|
-
return tx.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
return tx.add(
|
|
91
|
+
protocolConfigMoveCalls.newProtocolConfig({
|
|
92
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
93
|
+
arguments: {
|
|
94
|
+
marginPoolConfig: marginPoolConfigObject,
|
|
95
|
+
interestConfig: interestConfigObject,
|
|
96
|
+
},
|
|
97
|
+
}),
|
|
98
|
+
);
|
|
91
99
|
};
|
|
92
100
|
|
|
93
101
|
/**
|
|
@@ -100,15 +108,17 @@ export class MarginMaintainerContract {
|
|
|
100
108
|
(coinKey: string, marginPoolConfig: MarginPoolConfigParams) => (tx: Transaction) => {
|
|
101
109
|
const coin = this.#config.getCoin(coinKey);
|
|
102
110
|
const { supplyCap, maxUtilizationRate, protocolSpread, minBorrow } = marginPoolConfig;
|
|
103
|
-
return tx.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
111
|
+
return tx.add(
|
|
112
|
+
protocolConfigMoveCalls.newMarginPoolConfig({
|
|
113
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
114
|
+
arguments: {
|
|
115
|
+
supplyCap: convertQuantity(supplyCap, coin.scalar),
|
|
116
|
+
maxUtilizationRate: convertRate(maxUtilizationRate, FLOAT_SCALAR),
|
|
117
|
+
protocolSpread: convertRate(protocolSpread, FLOAT_SCALAR),
|
|
118
|
+
minBorrow: convertQuantity(minBorrow, coin.scalar),
|
|
119
|
+
},
|
|
120
|
+
}),
|
|
121
|
+
);
|
|
112
122
|
};
|
|
113
123
|
|
|
114
124
|
/**
|
|
@@ -139,18 +149,20 @@ export class MarginMaintainerContract {
|
|
|
139
149
|
rateLimitRefillRatePerMs,
|
|
140
150
|
rateLimitEnabled,
|
|
141
151
|
} = marginPoolConfig;
|
|
142
|
-
return tx.
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
return tx.add(
|
|
153
|
+
protocolConfigMoveCalls.newMarginPoolConfigWithRateLimit({
|
|
154
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
155
|
+
arguments: {
|
|
156
|
+
supplyCap: convertQuantity(supplyCap, coin.scalar),
|
|
157
|
+
maxUtilizationRate: convertRate(maxUtilizationRate, FLOAT_SCALAR),
|
|
158
|
+
protocolSpread: convertRate(protocolSpread, FLOAT_SCALAR),
|
|
159
|
+
minBorrow: convertQuantity(minBorrow, coin.scalar),
|
|
160
|
+
rateLimitCapacity: convertQuantity(rateLimitCapacity, coin.scalar),
|
|
161
|
+
rateLimitRefillRatePerMs: convertQuantity(rateLimitRefillRatePerMs, coin.scalar),
|
|
162
|
+
rateLimitEnabled,
|
|
163
|
+
},
|
|
164
|
+
}),
|
|
165
|
+
);
|
|
154
166
|
};
|
|
155
167
|
|
|
156
168
|
/**
|
|
@@ -160,15 +172,17 @@ export class MarginMaintainerContract {
|
|
|
160
172
|
*/
|
|
161
173
|
newInterestConfig = (interestConfig: InterestConfigParams) => (tx: Transaction) => {
|
|
162
174
|
const { baseRate, baseSlope, optimalUtilization, excessSlope } = interestConfig;
|
|
163
|
-
return tx.
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
175
|
+
return tx.add(
|
|
176
|
+
protocolConfigMoveCalls.newInterestConfig({
|
|
177
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
178
|
+
arguments: {
|
|
179
|
+
baseRate: convertRate(baseRate, FLOAT_SCALAR),
|
|
180
|
+
baseSlope: convertRate(baseSlope, FLOAT_SCALAR),
|
|
181
|
+
optimalUtilization: convertRate(optimalUtilization, FLOAT_SCALAR),
|
|
182
|
+
excessSlope: convertRate(excessSlope, FLOAT_SCALAR),
|
|
183
|
+
},
|
|
184
|
+
}),
|
|
185
|
+
);
|
|
172
186
|
};
|
|
173
187
|
|
|
174
188
|
/**
|
|
@@ -183,17 +197,18 @@ export class MarginMaintainerContract {
|
|
|
183
197
|
(tx: Transaction) => {
|
|
184
198
|
const deepbookPool = this.#config.getPool(deepbookPoolKey);
|
|
185
199
|
const marginPool = this.#config.getMarginPool(coinKey);
|
|
186
|
-
tx.
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
200
|
+
tx.add(
|
|
201
|
+
marginPoolMoveCalls.enableDeepbookPoolForLoan({
|
|
202
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
203
|
+
arguments: {
|
|
204
|
+
self: marginPool.address,
|
|
205
|
+
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
206
|
+
deepbookPoolId: deepbookPool.address,
|
|
207
|
+
marginPoolCap,
|
|
208
|
+
},
|
|
209
|
+
typeArguments: [marginPool.type],
|
|
210
|
+
}),
|
|
211
|
+
);
|
|
197
212
|
};
|
|
198
213
|
|
|
199
214
|
/**
|
|
@@ -208,17 +223,18 @@ export class MarginMaintainerContract {
|
|
|
208
223
|
(tx: Transaction) => {
|
|
209
224
|
const deepbookPool = this.#config.getPool(deepbookPoolKey);
|
|
210
225
|
const marginPool = this.#config.getMarginPool(coinKey);
|
|
211
|
-
tx.
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
226
|
+
tx.add(
|
|
227
|
+
marginPoolMoveCalls.disableDeepbookPoolForLoan({
|
|
228
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
229
|
+
arguments: {
|
|
230
|
+
self: marginPool.address,
|
|
231
|
+
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
232
|
+
deepbookPoolId: deepbookPool.address,
|
|
233
|
+
marginPoolCap,
|
|
234
|
+
},
|
|
235
|
+
typeArguments: [marginPool.type],
|
|
236
|
+
}),
|
|
237
|
+
);
|
|
222
238
|
};
|
|
223
239
|
|
|
224
240
|
/**
|
|
@@ -237,17 +253,18 @@ export class MarginMaintainerContract {
|
|
|
237
253
|
(tx: Transaction) => {
|
|
238
254
|
const marginPool = this.#config.getMarginPool(coinKey);
|
|
239
255
|
const interestConfigObject = this.newInterestConfig(interestConfig)(tx);
|
|
240
|
-
tx.
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
256
|
+
tx.add(
|
|
257
|
+
marginPoolMoveCalls.updateInterestParams({
|
|
258
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
259
|
+
arguments: {
|
|
260
|
+
self: marginPool.address,
|
|
261
|
+
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
262
|
+
interestConfig: interestConfigObject,
|
|
263
|
+
marginPoolCap,
|
|
264
|
+
},
|
|
265
|
+
typeArguments: [marginPool.type],
|
|
266
|
+
}),
|
|
267
|
+
);
|
|
251
268
|
};
|
|
252
269
|
|
|
253
270
|
/**
|
|
@@ -277,16 +294,17 @@ export class MarginMaintainerContract {
|
|
|
277
294
|
rateLimitEnabled: marginPoolConfig.rateLimitEnabled!,
|
|
278
295
|
})(tx)
|
|
279
296
|
: this.newMarginPoolConfig(coinKey, marginPoolConfig)(tx);
|
|
280
|
-
tx.
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
297
|
+
tx.add(
|
|
298
|
+
marginPoolMoveCalls.updateMarginPoolConfig({
|
|
299
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
300
|
+
arguments: {
|
|
301
|
+
self: marginPool.address,
|
|
302
|
+
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
303
|
+
marginPoolConfig: marginPoolConfigObject,
|
|
304
|
+
marginPoolCap,
|
|
305
|
+
},
|
|
306
|
+
typeArguments: [marginPool.type],
|
|
307
|
+
}),
|
|
308
|
+
);
|
|
291
309
|
};
|
|
292
310
|
}
|