@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
|
@@ -0,0 +1,786 @@
|
|
|
1
|
+
import { MoveStruct, MoveTuple, normalizeMoveArguments } from "../utils/index.mjs";
|
|
2
|
+
import { Versioned } from "./deps/sui/versioned.mjs";
|
|
3
|
+
import { VecSet } from "./deps/sui/vec_set.mjs";
|
|
4
|
+
import { Table } from "./deps/sui/table.mjs";
|
|
5
|
+
import { VecMap } from "./deps/sui/vec_map.mjs";
|
|
6
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
7
|
+
|
|
8
|
+
//#region src/contracts/deepbook_margin/margin_registry.ts
|
|
9
|
+
/**************************************************************
|
|
10
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
11
|
+
**************************************************************/
|
|
12
|
+
/** Registry holds all margin pools. */
|
|
13
|
+
const $moduleName = "@deepbook/margin::margin_registry";
|
|
14
|
+
const MARGIN_REGISTRY = new MoveStruct({
|
|
15
|
+
name: `${$moduleName}::MARGIN_REGISTRY`,
|
|
16
|
+
fields: { dummy_field: bcs.bool() }
|
|
17
|
+
});
|
|
18
|
+
const MarginRegistry = new MoveStruct({
|
|
19
|
+
name: `${$moduleName}::MarginRegistry`,
|
|
20
|
+
fields: {
|
|
21
|
+
id: bcs.Address,
|
|
22
|
+
inner: Versioned
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const MarginRegistryInner = new MoveStruct({
|
|
26
|
+
name: `${$moduleName}::MarginRegistryInner`,
|
|
27
|
+
fields: {
|
|
28
|
+
registry_id: bcs.Address,
|
|
29
|
+
allowed_versions: VecSet(bcs.u64()),
|
|
30
|
+
pool_registry: Table,
|
|
31
|
+
margin_pools: Table,
|
|
32
|
+
margin_managers: Table,
|
|
33
|
+
allowed_maintainers: VecSet(bcs.Address),
|
|
34
|
+
allowed_pause_caps: VecSet(bcs.Address)
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
const RiskRatios = new MoveStruct({
|
|
38
|
+
name: `${$moduleName}::RiskRatios`,
|
|
39
|
+
fields: {
|
|
40
|
+
min_withdraw_risk_ratio: bcs.u64(),
|
|
41
|
+
min_borrow_risk_ratio: bcs.u64(),
|
|
42
|
+
liquidation_risk_ratio: bcs.u64(),
|
|
43
|
+
target_liquidation_risk_ratio: bcs.u64()
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const PoolConfig = new MoveStruct({
|
|
47
|
+
name: `${$moduleName}::PoolConfig`,
|
|
48
|
+
fields: {
|
|
49
|
+
base_margin_pool_id: bcs.Address,
|
|
50
|
+
quote_margin_pool_id: bcs.Address,
|
|
51
|
+
risk_ratios: RiskRatios,
|
|
52
|
+
user_liquidation_reward: bcs.u64(),
|
|
53
|
+
pool_liquidation_reward: bcs.u64(),
|
|
54
|
+
enabled: bcs.bool(),
|
|
55
|
+
extra_fields: VecMap(bcs.string(), bcs.u64())
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const ConfigKey = new MoveStruct({
|
|
59
|
+
name: `${$moduleName}::ConfigKey<phantom Config>`,
|
|
60
|
+
fields: { dummy_field: bcs.bool() }
|
|
61
|
+
});
|
|
62
|
+
const CurrentPriceKey = new MoveStruct({
|
|
63
|
+
name: `${$moduleName}::CurrentPriceKey`,
|
|
64
|
+
fields: { pool_id: bcs.Address }
|
|
65
|
+
});
|
|
66
|
+
const CurrentPriceData = new MoveStruct({
|
|
67
|
+
name: `${$moduleName}::CurrentPriceData`,
|
|
68
|
+
fields: {
|
|
69
|
+
price: bcs.u64(),
|
|
70
|
+
last_price_update_ms: bcs.u64(),
|
|
71
|
+
tolerance: bcs.u64(),
|
|
72
|
+
max_price_age_ms: bcs.u64()
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
const MaxOrderTtlKey = new MoveTuple({
|
|
76
|
+
name: `${$moduleName}::MaxOrderTtlKey`,
|
|
77
|
+
fields: [bcs.Address]
|
|
78
|
+
});
|
|
79
|
+
const MinOpenRiskRatioKey = new MoveTuple({
|
|
80
|
+
name: `${$moduleName}::MinOpenRiskRatioKey`,
|
|
81
|
+
fields: [bcs.Address]
|
|
82
|
+
});
|
|
83
|
+
const MarginAdminCap = new MoveStruct({
|
|
84
|
+
name: `${$moduleName}::MarginAdminCap`,
|
|
85
|
+
fields: { id: bcs.Address }
|
|
86
|
+
});
|
|
87
|
+
const MarginPauseCap = new MoveStruct({
|
|
88
|
+
name: `${$moduleName}::MarginPauseCap`,
|
|
89
|
+
fields: { id: bcs.Address }
|
|
90
|
+
});
|
|
91
|
+
const MaintainerCap = new MoveStruct({
|
|
92
|
+
name: `${$moduleName}::MaintainerCap`,
|
|
93
|
+
fields: { id: bcs.Address }
|
|
94
|
+
});
|
|
95
|
+
const MarginPoolCap = new MoveStruct({
|
|
96
|
+
name: `${$moduleName}::MarginPoolCap`,
|
|
97
|
+
fields: {
|
|
98
|
+
id: bcs.Address,
|
|
99
|
+
margin_pool_id: bcs.Address
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
const MaintainerCapUpdated = new MoveStruct({
|
|
103
|
+
name: `${$moduleName}::MaintainerCapUpdated`,
|
|
104
|
+
fields: {
|
|
105
|
+
maintainer_cap_id: bcs.Address,
|
|
106
|
+
allowed: bcs.bool(),
|
|
107
|
+
timestamp: bcs.u64()
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
const PauseCapUpdated = new MoveStruct({
|
|
111
|
+
name: `${$moduleName}::PauseCapUpdated`,
|
|
112
|
+
fields: {
|
|
113
|
+
pause_cap_id: bcs.Address,
|
|
114
|
+
allowed: bcs.bool(),
|
|
115
|
+
timestamp: bcs.u64()
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
const DeepbookPoolRegistered = new MoveStruct({
|
|
119
|
+
name: `${$moduleName}::DeepbookPoolRegistered`,
|
|
120
|
+
fields: {
|
|
121
|
+
pool_id: bcs.Address,
|
|
122
|
+
config: PoolConfig,
|
|
123
|
+
timestamp: bcs.u64()
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
const DeepbookPoolUpdated = new MoveStruct({
|
|
127
|
+
name: `${$moduleName}::DeepbookPoolUpdated`,
|
|
128
|
+
fields: {
|
|
129
|
+
pool_id: bcs.Address,
|
|
130
|
+
enabled: bcs.bool(),
|
|
131
|
+
timestamp: bcs.u64()
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
const DeepbookPoolConfigUpdated = new MoveStruct({
|
|
135
|
+
name: `${$moduleName}::DeepbookPoolConfigUpdated`,
|
|
136
|
+
fields: {
|
|
137
|
+
pool_id: bcs.Address,
|
|
138
|
+
config: PoolConfig,
|
|
139
|
+
timestamp: bcs.u64()
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
const CurrentPriceUpdated = new MoveStruct({
|
|
143
|
+
name: `${$moduleName}::CurrentPriceUpdated`,
|
|
144
|
+
fields: {
|
|
145
|
+
pool_id: bcs.Address,
|
|
146
|
+
price: bcs.u64(),
|
|
147
|
+
timestamp: bcs.u64()
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
const PriceToleranceUpdated = new MoveStruct({
|
|
151
|
+
name: `${$moduleName}::PriceToleranceUpdated`,
|
|
152
|
+
fields: {
|
|
153
|
+
pool_id: bcs.Address,
|
|
154
|
+
tolerance: bcs.u64(),
|
|
155
|
+
timestamp: bcs.u64()
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
const MaxPriceAgeUpdated = new MoveStruct({
|
|
159
|
+
name: `${$moduleName}::MaxPriceAgeUpdated`,
|
|
160
|
+
fields: {
|
|
161
|
+
pool_id: bcs.Address,
|
|
162
|
+
max_age_ms: bcs.u64(),
|
|
163
|
+
timestamp: bcs.u64()
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
const MaxOrderTtlUpdated = new MoveStruct({
|
|
167
|
+
name: `${$moduleName}::MaxOrderTtlUpdated`,
|
|
168
|
+
fields: {
|
|
169
|
+
pool_id: bcs.Address,
|
|
170
|
+
max_order_ttl_ms: bcs.u64(),
|
|
171
|
+
timestamp: bcs.u64()
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
const MinOpenRiskRatioUpdated = new MoveStruct({
|
|
175
|
+
name: `${$moduleName}::MinOpenRiskRatioUpdated`,
|
|
176
|
+
fields: {
|
|
177
|
+
pool_id: bcs.Address,
|
|
178
|
+
min_open_risk_ratio: bcs.u64(),
|
|
179
|
+
timestamp: bcs.u64()
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
/**
|
|
183
|
+
* Mint a `MaintainerCap`, only admin can mint a `MaintainerCap`. This function
|
|
184
|
+
* does not have version restrictions
|
|
185
|
+
*/
|
|
186
|
+
function mintMaintainerCap(options) {
|
|
187
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
188
|
+
const argumentsTypes = [
|
|
189
|
+
null,
|
|
190
|
+
null,
|
|
191
|
+
"0x2::clock::Clock"
|
|
192
|
+
];
|
|
193
|
+
const parameterNames = ["self", "AdminCap"];
|
|
194
|
+
return (tx) => tx.moveCall({
|
|
195
|
+
package: packageAddress,
|
|
196
|
+
module: "margin_registry",
|
|
197
|
+
function: "mint_maintainer_cap",
|
|
198
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
/** Register a margin pool for margin trading with existing margin pools */
|
|
202
|
+
function registerDeepbookPool(options) {
|
|
203
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
204
|
+
const argumentsTypes = [
|
|
205
|
+
null,
|
|
206
|
+
null,
|
|
207
|
+
null,
|
|
208
|
+
null,
|
|
209
|
+
"0x2::clock::Clock"
|
|
210
|
+
];
|
|
211
|
+
const parameterNames = [
|
|
212
|
+
"self",
|
|
213
|
+
"AdminCap",
|
|
214
|
+
"pool",
|
|
215
|
+
"poolConfig"
|
|
216
|
+
];
|
|
217
|
+
return (tx) => tx.moveCall({
|
|
218
|
+
package: packageAddress,
|
|
219
|
+
module: "margin_registry",
|
|
220
|
+
function: "register_deepbook_pool",
|
|
221
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
222
|
+
typeArguments: options.typeArguments
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
/** Enables a deepbook pool for margin trading. */
|
|
226
|
+
function enableDeepbookPool(options) {
|
|
227
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
228
|
+
const argumentsTypes = [
|
|
229
|
+
null,
|
|
230
|
+
null,
|
|
231
|
+
null,
|
|
232
|
+
"0x2::clock::Clock"
|
|
233
|
+
];
|
|
234
|
+
const parameterNames = [
|
|
235
|
+
"self",
|
|
236
|
+
"AdminCap",
|
|
237
|
+
"pool"
|
|
238
|
+
];
|
|
239
|
+
return (tx) => tx.moveCall({
|
|
240
|
+
package: packageAddress,
|
|
241
|
+
module: "margin_registry",
|
|
242
|
+
function: "enable_deepbook_pool",
|
|
243
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
244
|
+
typeArguments: options.typeArguments
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Disables a deepbook pool from margin trading. Only reduce only orders, cancels,
|
|
249
|
+
* and withdraw settled amounts are allowed.
|
|
250
|
+
*/
|
|
251
|
+
function disableDeepbookPool(options) {
|
|
252
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
253
|
+
const argumentsTypes = [
|
|
254
|
+
null,
|
|
255
|
+
null,
|
|
256
|
+
null,
|
|
257
|
+
"0x2::clock::Clock"
|
|
258
|
+
];
|
|
259
|
+
const parameterNames = [
|
|
260
|
+
"self",
|
|
261
|
+
"AdminCap",
|
|
262
|
+
"pool"
|
|
263
|
+
];
|
|
264
|
+
return (tx) => tx.moveCall({
|
|
265
|
+
package: packageAddress,
|
|
266
|
+
module: "margin_registry",
|
|
267
|
+
function: "disable_deepbook_pool",
|
|
268
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
269
|
+
typeArguments: options.typeArguments
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
/** Updates risk params for a deepbook pool as the admin. */
|
|
273
|
+
function updateRiskParams(options) {
|
|
274
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
275
|
+
const argumentsTypes = [
|
|
276
|
+
null,
|
|
277
|
+
null,
|
|
278
|
+
null,
|
|
279
|
+
null,
|
|
280
|
+
"0x2::clock::Clock"
|
|
281
|
+
];
|
|
282
|
+
const parameterNames = [
|
|
283
|
+
"self",
|
|
284
|
+
"AdminCap",
|
|
285
|
+
"pool",
|
|
286
|
+
"poolConfig"
|
|
287
|
+
];
|
|
288
|
+
return (tx) => tx.moveCall({
|
|
289
|
+
package: packageAddress,
|
|
290
|
+
module: "margin_registry",
|
|
291
|
+
function: "update_risk_params",
|
|
292
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
293
|
+
typeArguments: options.typeArguments
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
/** Add Pyth Config to the MarginRegistry. */
|
|
297
|
+
function addConfig(options) {
|
|
298
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
299
|
+
const argumentsTypes = [
|
|
300
|
+
null,
|
|
301
|
+
null,
|
|
302
|
+
`${options.typeArguments[0]}`
|
|
303
|
+
];
|
|
304
|
+
const parameterNames = [
|
|
305
|
+
"self",
|
|
306
|
+
"AdminCap",
|
|
307
|
+
"config"
|
|
308
|
+
];
|
|
309
|
+
return (tx) => tx.moveCall({
|
|
310
|
+
package: packageAddress,
|
|
311
|
+
module: "margin_registry",
|
|
312
|
+
function: "add_config",
|
|
313
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
314
|
+
typeArguments: options.typeArguments
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
/** Remove Pyth Config from the MarginRegistry. */
|
|
318
|
+
function removeConfig(options) {
|
|
319
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
320
|
+
const argumentsTypes = [null, null];
|
|
321
|
+
const parameterNames = ["self", "AdminCap"];
|
|
322
|
+
return (tx) => tx.moveCall({
|
|
323
|
+
package: packageAddress,
|
|
324
|
+
module: "margin_registry",
|
|
325
|
+
function: "remove_config",
|
|
326
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
327
|
+
typeArguments: options.typeArguments
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Enables a package version Only Admin can enable a package version This function
|
|
332
|
+
* does not have version restrictions
|
|
333
|
+
*/
|
|
334
|
+
function enableVersion(options) {
|
|
335
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
336
|
+
const argumentsTypes = [
|
|
337
|
+
null,
|
|
338
|
+
"u64",
|
|
339
|
+
null
|
|
340
|
+
];
|
|
341
|
+
const parameterNames = [
|
|
342
|
+
"self",
|
|
343
|
+
"version",
|
|
344
|
+
"AdminCap"
|
|
345
|
+
];
|
|
346
|
+
return (tx) => tx.moveCall({
|
|
347
|
+
package: packageAddress,
|
|
348
|
+
module: "margin_registry",
|
|
349
|
+
function: "enable_version",
|
|
350
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Disables a package version Only Admin can disable a package version This
|
|
355
|
+
* function does not have version restrictions
|
|
356
|
+
*/
|
|
357
|
+
function disableVersion(options) {
|
|
358
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
359
|
+
const argumentsTypes = [
|
|
360
|
+
null,
|
|
361
|
+
"u64",
|
|
362
|
+
null
|
|
363
|
+
];
|
|
364
|
+
const parameterNames = [
|
|
365
|
+
"self",
|
|
366
|
+
"version",
|
|
367
|
+
"AdminCap"
|
|
368
|
+
];
|
|
369
|
+
return (tx) => tx.moveCall({
|
|
370
|
+
package: packageAddress,
|
|
371
|
+
module: "margin_registry",
|
|
372
|
+
function: "disable_version",
|
|
373
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Disables a package version Pause Cap must be valid and can disable the version
|
|
378
|
+
* This function does not have version restrictions
|
|
379
|
+
*/
|
|
380
|
+
function disableVersionPauseCap(options) {
|
|
381
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
382
|
+
const argumentsTypes = [
|
|
383
|
+
null,
|
|
384
|
+
"u64",
|
|
385
|
+
null
|
|
386
|
+
];
|
|
387
|
+
const parameterNames = [
|
|
388
|
+
"self",
|
|
389
|
+
"version",
|
|
390
|
+
"pauseCap"
|
|
391
|
+
];
|
|
392
|
+
return (tx) => tx.moveCall({
|
|
393
|
+
package: packageAddress,
|
|
394
|
+
module: "margin_registry",
|
|
395
|
+
function: "disable_version_pause_cap",
|
|
396
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Mint a pause cap Only Admin can mint a pause cap This function does not have
|
|
401
|
+
* version restrictions
|
|
402
|
+
*/
|
|
403
|
+
function mintPauseCap(options) {
|
|
404
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
405
|
+
const argumentsTypes = [
|
|
406
|
+
null,
|
|
407
|
+
null,
|
|
408
|
+
"0x2::clock::Clock"
|
|
409
|
+
];
|
|
410
|
+
const parameterNames = ["self", "AdminCap"];
|
|
411
|
+
return (tx) => tx.moveCall({
|
|
412
|
+
package: packageAddress,
|
|
413
|
+
module: "margin_registry",
|
|
414
|
+
function: "mint_pause_cap",
|
|
415
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Revoke a pause cap Only Admin can revoke a pause cap This function does not have
|
|
420
|
+
* version restrictions
|
|
421
|
+
*/
|
|
422
|
+
function revokePauseCap(options) {
|
|
423
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
424
|
+
const argumentsTypes = [
|
|
425
|
+
null,
|
|
426
|
+
null,
|
|
427
|
+
"0x2::clock::Clock",
|
|
428
|
+
"0x2::object::ID"
|
|
429
|
+
];
|
|
430
|
+
const parameterNames = [
|
|
431
|
+
"self",
|
|
432
|
+
"AdminCap",
|
|
433
|
+
"pauseCapId"
|
|
434
|
+
];
|
|
435
|
+
return (tx) => tx.moveCall({
|
|
436
|
+
package: packageAddress,
|
|
437
|
+
module: "margin_registry",
|
|
438
|
+
function: "revoke_pause_cap",
|
|
439
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Set price deviation tolerance for a pool tolerance is in 9 decimals where 1.0 =
|
|
444
|
+
* 1_000_000_000 (e.g., 100_000_000 = 0.1 = 10%) Only Admin can set tolerance
|
|
445
|
+
* Requires price to be initialized first via update_current_price
|
|
446
|
+
*/
|
|
447
|
+
function setPriceTolerance(options) {
|
|
448
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
449
|
+
const argumentsTypes = [
|
|
450
|
+
null,
|
|
451
|
+
null,
|
|
452
|
+
null,
|
|
453
|
+
"u64",
|
|
454
|
+
"0x2::clock::Clock"
|
|
455
|
+
];
|
|
456
|
+
const parameterNames = [
|
|
457
|
+
"self",
|
|
458
|
+
"AdminCap",
|
|
459
|
+
"pool",
|
|
460
|
+
"tolerance"
|
|
461
|
+
];
|
|
462
|
+
return (tx) => tx.moveCall({
|
|
463
|
+
package: packageAddress,
|
|
464
|
+
module: "margin_registry",
|
|
465
|
+
function: "set_price_tolerance",
|
|
466
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
467
|
+
typeArguments: options.typeArguments
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Set maximum price age in milliseconds for a pool Only Admin can set max price
|
|
472
|
+
* age Requires price to be initialized first via update_current_price
|
|
473
|
+
*/
|
|
474
|
+
function setMaxPriceAge(options) {
|
|
475
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
476
|
+
const argumentsTypes = [
|
|
477
|
+
null,
|
|
478
|
+
null,
|
|
479
|
+
null,
|
|
480
|
+
"u64",
|
|
481
|
+
"0x2::clock::Clock"
|
|
482
|
+
];
|
|
483
|
+
const parameterNames = [
|
|
484
|
+
"self",
|
|
485
|
+
"AdminCap",
|
|
486
|
+
"pool",
|
|
487
|
+
"maxAgeMs"
|
|
488
|
+
];
|
|
489
|
+
return (tx) => tx.moveCall({
|
|
490
|
+
package: packageAddress,
|
|
491
|
+
module: "margin_registry",
|
|
492
|
+
function: "set_max_price_age",
|
|
493
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
494
|
+
typeArguments: options.typeArguments
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Set the maximum lifetime (in ms) of margin limit orders for a pool.
|
|
499
|
+
* User-supplied `expire_timestamp` on margin limit-order placements is clamped to
|
|
500
|
+
* at most `now + max_order_ttl_ms`. Bounds margin orders' exposure to stale-price
|
|
501
|
+
* exploitation if liquidity disappears after placement. Only Admin can set max
|
|
502
|
+
* order TTL.
|
|
503
|
+
*/
|
|
504
|
+
function setMaxOrderTtl(options) {
|
|
505
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
506
|
+
const argumentsTypes = [
|
|
507
|
+
null,
|
|
508
|
+
null,
|
|
509
|
+
null,
|
|
510
|
+
"u64",
|
|
511
|
+
"0x2::clock::Clock"
|
|
512
|
+
];
|
|
513
|
+
const parameterNames = [
|
|
514
|
+
"self",
|
|
515
|
+
"AdminCap",
|
|
516
|
+
"pool",
|
|
517
|
+
"maxOrderTtlMs"
|
|
518
|
+
];
|
|
519
|
+
return (tx) => tx.moveCall({
|
|
520
|
+
package: packageAddress,
|
|
521
|
+
module: "margin_registry",
|
|
522
|
+
function: "set_max_order_ttl",
|
|
523
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
524
|
+
typeArguments: options.typeArguments
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Set the per-pool `min_open_risk_ratio` override — the post-trade solvency floor
|
|
529
|
+
* enforced on opening (risk-increasing) orders. Must sit in
|
|
530
|
+
* `(liquidation_risk_ratio, min_borrow_risk_ratio]`: above liquidation so an open
|
|
531
|
+
* can't land in the liquidatable zone, at or below the borrow floor. Absent an
|
|
532
|
+
* override the floor defaults to the midpoint of liquidation and min_borrow. Only
|
|
533
|
+
* Admin can set it.
|
|
534
|
+
*/
|
|
535
|
+
function setMinOpenRiskRatio(options) {
|
|
536
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
537
|
+
const argumentsTypes = [
|
|
538
|
+
null,
|
|
539
|
+
null,
|
|
540
|
+
null,
|
|
541
|
+
"u64",
|
|
542
|
+
"0x2::clock::Clock"
|
|
543
|
+
];
|
|
544
|
+
const parameterNames = [
|
|
545
|
+
"self",
|
|
546
|
+
"AdminCap",
|
|
547
|
+
"pool",
|
|
548
|
+
"minOpenRiskRatio"
|
|
549
|
+
];
|
|
550
|
+
return (tx) => tx.moveCall({
|
|
551
|
+
package: packageAddress,
|
|
552
|
+
module: "margin_registry",
|
|
553
|
+
function: "set_min_open_risk_ratio",
|
|
554
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
555
|
+
typeArguments: options.typeArguments
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* Create a PoolConfig with margin pool IDs and risk parameters Enable is false by
|
|
560
|
+
* default, must be enabled after registration
|
|
561
|
+
*/
|
|
562
|
+
function newPoolConfig(options) {
|
|
563
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
564
|
+
const argumentsTypes = [
|
|
565
|
+
null,
|
|
566
|
+
"u64",
|
|
567
|
+
"u64",
|
|
568
|
+
"u64",
|
|
569
|
+
"u64",
|
|
570
|
+
"u64",
|
|
571
|
+
"u64"
|
|
572
|
+
];
|
|
573
|
+
const parameterNames = [
|
|
574
|
+
"self",
|
|
575
|
+
"minWithdrawRiskRatio",
|
|
576
|
+
"minBorrowRiskRatio",
|
|
577
|
+
"liquidationRiskRatio",
|
|
578
|
+
"targetLiquidationRiskRatio",
|
|
579
|
+
"userLiquidationReward",
|
|
580
|
+
"poolLiquidationReward"
|
|
581
|
+
];
|
|
582
|
+
return (tx) => tx.moveCall({
|
|
583
|
+
package: packageAddress,
|
|
584
|
+
module: "margin_registry",
|
|
585
|
+
function: "new_pool_config",
|
|
586
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
587
|
+
typeArguments: options.typeArguments
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
/** Create a PoolConfig with default risk parameters based on leverage */
|
|
591
|
+
function newPoolConfigWithLeverage(options) {
|
|
592
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
593
|
+
const argumentsTypes = [null, "u64"];
|
|
594
|
+
const parameterNames = ["self", "leverage"];
|
|
595
|
+
return (tx) => tx.moveCall({
|
|
596
|
+
package: packageAddress,
|
|
597
|
+
module: "margin_registry",
|
|
598
|
+
function: "new_pool_config_with_leverage",
|
|
599
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
600
|
+
typeArguments: options.typeArguments
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
/** Check if a deepbook pool is registered for margin trading */
|
|
604
|
+
function poolEnabled(options) {
|
|
605
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
606
|
+
const argumentsTypes = [null, null];
|
|
607
|
+
const parameterNames = ["self", "pool"];
|
|
608
|
+
return (tx) => tx.moveCall({
|
|
609
|
+
package: packageAddress,
|
|
610
|
+
module: "margin_registry",
|
|
611
|
+
function: "pool_enabled",
|
|
612
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
613
|
+
typeArguments: options.typeArguments
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
/** Get the margin pool id for the given asset. */
|
|
617
|
+
function getMarginPoolId(options) {
|
|
618
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
619
|
+
const argumentsTypes = [null];
|
|
620
|
+
const parameterNames = ["self"];
|
|
621
|
+
return (tx) => tx.moveCall({
|
|
622
|
+
package: packageAddress,
|
|
623
|
+
module: "margin_registry",
|
|
624
|
+
function: "get_margin_pool_id",
|
|
625
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
626
|
+
typeArguments: options.typeArguments
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
/** Get the margin pool IDs for a deepbook pool */
|
|
630
|
+
function getDeepbookPoolMarginPoolIds(options) {
|
|
631
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
632
|
+
const argumentsTypes = [null, "0x2::object::ID"];
|
|
633
|
+
const parameterNames = ["self", "deepbookPoolId"];
|
|
634
|
+
return (tx) => tx.moveCall({
|
|
635
|
+
package: packageAddress,
|
|
636
|
+
module: "margin_registry",
|
|
637
|
+
function: "get_deepbook_pool_margin_pool_ids",
|
|
638
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
/** Get the margin manager IDs for a given owner */
|
|
642
|
+
function getMarginManagerIds(options) {
|
|
643
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
644
|
+
const argumentsTypes = [null, "address"];
|
|
645
|
+
const parameterNames = ["self", "owner"];
|
|
646
|
+
return (tx) => tx.moveCall({
|
|
647
|
+
package: packageAddress,
|
|
648
|
+
module: "margin_registry",
|
|
649
|
+
function: "get_margin_manager_ids",
|
|
650
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
function baseMarginPoolId(options) {
|
|
654
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
655
|
+
const argumentsTypes = [null, "0x2::object::ID"];
|
|
656
|
+
const parameterNames = ["self", "deepbookPoolId"];
|
|
657
|
+
return (tx) => tx.moveCall({
|
|
658
|
+
package: packageAddress,
|
|
659
|
+
module: "margin_registry",
|
|
660
|
+
function: "base_margin_pool_id",
|
|
661
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
function quoteMarginPoolId(options) {
|
|
665
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
666
|
+
const argumentsTypes = [null, "0x2::object::ID"];
|
|
667
|
+
const parameterNames = ["self", "deepbookPoolId"];
|
|
668
|
+
return (tx) => tx.moveCall({
|
|
669
|
+
package: packageAddress,
|
|
670
|
+
module: "margin_registry",
|
|
671
|
+
function: "quote_margin_pool_id",
|
|
672
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
function minWithdrawRiskRatio(options) {
|
|
676
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
677
|
+
const argumentsTypes = [null, "0x2::object::ID"];
|
|
678
|
+
const parameterNames = ["self", "deepbookPoolId"];
|
|
679
|
+
return (tx) => tx.moveCall({
|
|
680
|
+
package: packageAddress,
|
|
681
|
+
module: "margin_registry",
|
|
682
|
+
function: "min_withdraw_risk_ratio",
|
|
683
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
function minBorrowRiskRatio(options) {
|
|
687
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
688
|
+
const argumentsTypes = [null, "0x2::object::ID"];
|
|
689
|
+
const parameterNames = ["self", "deepbookPoolId"];
|
|
690
|
+
return (tx) => tx.moveCall({
|
|
691
|
+
package: packageAddress,
|
|
692
|
+
module: "margin_registry",
|
|
693
|
+
function: "min_borrow_risk_ratio",
|
|
694
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
function liquidationRiskRatio(options) {
|
|
698
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
699
|
+
const argumentsTypes = [null, "0x2::object::ID"];
|
|
700
|
+
const parameterNames = ["self", "deepbookPoolId"];
|
|
701
|
+
return (tx) => tx.moveCall({
|
|
702
|
+
package: packageAddress,
|
|
703
|
+
module: "margin_registry",
|
|
704
|
+
function: "liquidation_risk_ratio",
|
|
705
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
function targetLiquidationRiskRatio(options) {
|
|
709
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
710
|
+
const argumentsTypes = [null, "0x2::object::ID"];
|
|
711
|
+
const parameterNames = ["self", "deepbookPoolId"];
|
|
712
|
+
return (tx) => tx.moveCall({
|
|
713
|
+
package: packageAddress,
|
|
714
|
+
module: "margin_registry",
|
|
715
|
+
function: "target_liquidation_risk_ratio",
|
|
716
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
/**
|
|
720
|
+
* Post-trade solvency floor for _opening_ (risk-increasing) orders, sitting in
|
|
721
|
+
* `(liquidation_risk_ratio, min_borrow_risk_ratio]`. Lets a max-leverage open
|
|
722
|
+
* absorb the opening trade's spread — which lands the post-trade ratio just under
|
|
723
|
+
* the borrow floor — without aborting, while staying above the liquidatable zone.
|
|
724
|
+
* Defaults to the midpoint of liquidation and min_borrow; an admin override
|
|
725
|
+
* (`set_min_open_risk_ratio`) is honored only while it stays in the valid band, so
|
|
726
|
+
* a later risk-param change can't strand it below liquidation.
|
|
727
|
+
*/
|
|
728
|
+
function minOpenRiskRatio(options) {
|
|
729
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
730
|
+
const argumentsTypes = [null, "0x2::object::ID"];
|
|
731
|
+
const parameterNames = ["self", "deepbookPoolId"];
|
|
732
|
+
return (tx) => tx.moveCall({
|
|
733
|
+
package: packageAddress,
|
|
734
|
+
module: "margin_registry",
|
|
735
|
+
function: "min_open_risk_ratio",
|
|
736
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
function userLiquidationReward(options) {
|
|
740
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
741
|
+
const argumentsTypes = [null, "0x2::object::ID"];
|
|
742
|
+
const parameterNames = ["self", "deepbookPoolId"];
|
|
743
|
+
return (tx) => tx.moveCall({
|
|
744
|
+
package: packageAddress,
|
|
745
|
+
module: "margin_registry",
|
|
746
|
+
function: "user_liquidation_reward",
|
|
747
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
function poolLiquidationReward(options) {
|
|
751
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
752
|
+
const argumentsTypes = [null, "0x2::object::ID"];
|
|
753
|
+
const parameterNames = ["self", "deepbookPoolId"];
|
|
754
|
+
return (tx) => tx.moveCall({
|
|
755
|
+
package: packageAddress,
|
|
756
|
+
module: "margin_registry",
|
|
757
|
+
function: "pool_liquidation_reward",
|
|
758
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
function allowedMaintainers(options) {
|
|
762
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
763
|
+
const argumentsTypes = [null];
|
|
764
|
+
const parameterNames = ["self"];
|
|
765
|
+
return (tx) => tx.moveCall({
|
|
766
|
+
package: packageAddress,
|
|
767
|
+
module: "margin_registry",
|
|
768
|
+
function: "allowed_maintainers",
|
|
769
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
function allowedPauseCaps(options) {
|
|
773
|
+
const packageAddress = options.package ?? "@deepbook/margin";
|
|
774
|
+
const argumentsTypes = [null];
|
|
775
|
+
const parameterNames = ["self"];
|
|
776
|
+
return (tx) => tx.moveCall({
|
|
777
|
+
package: packageAddress,
|
|
778
|
+
module: "margin_registry",
|
|
779
|
+
function: "allowed_pause_caps",
|
|
780
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
//#endregion
|
|
785
|
+
export { addConfig, allowedMaintainers, allowedPauseCaps, baseMarginPoolId, disableDeepbookPool, disableVersion, disableVersionPauseCap, enableDeepbookPool, enableVersion, getDeepbookPoolMarginPoolIds, getMarginManagerIds, getMarginPoolId, liquidationRiskRatio, minBorrowRiskRatio, minOpenRiskRatio, minWithdrawRiskRatio, mintMaintainerCap, mintPauseCap, newPoolConfig, newPoolConfigWithLeverage, poolEnabled, poolLiquidationReward, quoteMarginPoolId, registerDeepbookPool, removeConfig, revokePauseCap, setMaxOrderTtl, setMaxPriceAge, setMinOpenRiskRatio, setPriceTolerance, targetLiquidationRiskRatio, updateRiskParams, userLiquidationReward };
|
|
786
|
+
//# sourceMappingURL=margin_registry.mjs.map
|