@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,1207 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
/** Registry holds all margin pools. */
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
MoveStruct,
|
|
9
|
+
MoveTuple,
|
|
10
|
+
normalizeMoveArguments,
|
|
11
|
+
type RawTransactionArgument,
|
|
12
|
+
} from '../utils/index.js';
|
|
13
|
+
import { bcs, type BcsType } from '@mysten/sui/bcs';
|
|
14
|
+
import { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';
|
|
15
|
+
import * as versioned from './deps/sui/versioned.js';
|
|
16
|
+
import * as vec_set from './deps/sui/vec_set.js';
|
|
17
|
+
import * as table from './deps/sui/table.js';
|
|
18
|
+
import * as vec_map from './deps/sui/vec_map.js';
|
|
19
|
+
const $moduleName = '@deepbook/margin::margin_registry';
|
|
20
|
+
export const MARGIN_REGISTRY = new MoveStruct({
|
|
21
|
+
name: `${$moduleName}::MARGIN_REGISTRY`,
|
|
22
|
+
fields: {
|
|
23
|
+
dummy_field: bcs.bool(),
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
export const MarginRegistry = new MoveStruct({
|
|
27
|
+
name: `${$moduleName}::MarginRegistry`,
|
|
28
|
+
fields: {
|
|
29
|
+
id: bcs.Address,
|
|
30
|
+
inner: versioned.Versioned,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
export const MarginRegistryInner = new MoveStruct({
|
|
34
|
+
name: `${$moduleName}::MarginRegistryInner`,
|
|
35
|
+
fields: {
|
|
36
|
+
registry_id: bcs.Address,
|
|
37
|
+
allowed_versions: vec_set.VecSet(bcs.u64()),
|
|
38
|
+
pool_registry: table.Table,
|
|
39
|
+
margin_pools: table.Table,
|
|
40
|
+
margin_managers: table.Table,
|
|
41
|
+
allowed_maintainers: vec_set.VecSet(bcs.Address),
|
|
42
|
+
allowed_pause_caps: vec_set.VecSet(bcs.Address),
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
export const RiskRatios = new MoveStruct({
|
|
46
|
+
name: `${$moduleName}::RiskRatios`,
|
|
47
|
+
fields: {
|
|
48
|
+
min_withdraw_risk_ratio: bcs.u64(),
|
|
49
|
+
min_borrow_risk_ratio: bcs.u64(),
|
|
50
|
+
liquidation_risk_ratio: bcs.u64(),
|
|
51
|
+
target_liquidation_risk_ratio: bcs.u64(),
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
export const PoolConfig = new MoveStruct({
|
|
55
|
+
name: `${$moduleName}::PoolConfig`,
|
|
56
|
+
fields: {
|
|
57
|
+
base_margin_pool_id: bcs.Address,
|
|
58
|
+
quote_margin_pool_id: bcs.Address,
|
|
59
|
+
risk_ratios: RiskRatios,
|
|
60
|
+
user_liquidation_reward: bcs.u64(),
|
|
61
|
+
pool_liquidation_reward: bcs.u64(),
|
|
62
|
+
enabled: bcs.bool(),
|
|
63
|
+
extra_fields: vec_map.VecMap(bcs.string(), bcs.u64()),
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
export const ConfigKey = new MoveStruct({
|
|
67
|
+
name: `${$moduleName}::ConfigKey<phantom Config>`,
|
|
68
|
+
fields: {
|
|
69
|
+
dummy_field: bcs.bool(),
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
export const CurrentPriceKey = new MoveStruct({
|
|
73
|
+
name: `${$moduleName}::CurrentPriceKey`,
|
|
74
|
+
fields: {
|
|
75
|
+
pool_id: bcs.Address,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
export const CurrentPriceData = new MoveStruct({
|
|
79
|
+
name: `${$moduleName}::CurrentPriceData`,
|
|
80
|
+
fields: {
|
|
81
|
+
price: bcs.u64(),
|
|
82
|
+
last_price_update_ms: bcs.u64(),
|
|
83
|
+
tolerance: bcs.u64(),
|
|
84
|
+
max_price_age_ms: bcs.u64(),
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
export const MaxOrderTtlKey = new MoveTuple({
|
|
88
|
+
name: `${$moduleName}::MaxOrderTtlKey`,
|
|
89
|
+
fields: [bcs.Address],
|
|
90
|
+
});
|
|
91
|
+
export const MinOpenRiskRatioKey = new MoveTuple({
|
|
92
|
+
name: `${$moduleName}::MinOpenRiskRatioKey`,
|
|
93
|
+
fields: [bcs.Address],
|
|
94
|
+
});
|
|
95
|
+
export const MarginAdminCap = new MoveStruct({
|
|
96
|
+
name: `${$moduleName}::MarginAdminCap`,
|
|
97
|
+
fields: {
|
|
98
|
+
id: bcs.Address,
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
export const MarginPauseCap = new MoveStruct({
|
|
102
|
+
name: `${$moduleName}::MarginPauseCap`,
|
|
103
|
+
fields: {
|
|
104
|
+
id: bcs.Address,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
export const MaintainerCap = new MoveStruct({
|
|
108
|
+
name: `${$moduleName}::MaintainerCap`,
|
|
109
|
+
fields: {
|
|
110
|
+
id: bcs.Address,
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
export const MarginPoolCap = new MoveStruct({
|
|
114
|
+
name: `${$moduleName}::MarginPoolCap`,
|
|
115
|
+
fields: {
|
|
116
|
+
id: bcs.Address,
|
|
117
|
+
margin_pool_id: bcs.Address,
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
export const MaintainerCapUpdated = new MoveStruct({
|
|
121
|
+
name: `${$moduleName}::MaintainerCapUpdated`,
|
|
122
|
+
fields: {
|
|
123
|
+
maintainer_cap_id: bcs.Address,
|
|
124
|
+
allowed: bcs.bool(),
|
|
125
|
+
timestamp: bcs.u64(),
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
export const PauseCapUpdated = new MoveStruct({
|
|
129
|
+
name: `${$moduleName}::PauseCapUpdated`,
|
|
130
|
+
fields: {
|
|
131
|
+
pause_cap_id: bcs.Address,
|
|
132
|
+
allowed: bcs.bool(),
|
|
133
|
+
timestamp: bcs.u64(),
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
export const DeepbookPoolRegistered = new MoveStruct({
|
|
137
|
+
name: `${$moduleName}::DeepbookPoolRegistered`,
|
|
138
|
+
fields: {
|
|
139
|
+
pool_id: bcs.Address,
|
|
140
|
+
config: PoolConfig,
|
|
141
|
+
timestamp: bcs.u64(),
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
export const DeepbookPoolUpdated = new MoveStruct({
|
|
145
|
+
name: `${$moduleName}::DeepbookPoolUpdated`,
|
|
146
|
+
fields: {
|
|
147
|
+
pool_id: bcs.Address,
|
|
148
|
+
enabled: bcs.bool(),
|
|
149
|
+
timestamp: bcs.u64(),
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
export const DeepbookPoolConfigUpdated = new MoveStruct({
|
|
153
|
+
name: `${$moduleName}::DeepbookPoolConfigUpdated`,
|
|
154
|
+
fields: {
|
|
155
|
+
pool_id: bcs.Address,
|
|
156
|
+
config: PoolConfig,
|
|
157
|
+
timestamp: bcs.u64(),
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
export const CurrentPriceUpdated = new MoveStruct({
|
|
161
|
+
name: `${$moduleName}::CurrentPriceUpdated`,
|
|
162
|
+
fields: {
|
|
163
|
+
pool_id: bcs.Address,
|
|
164
|
+
price: bcs.u64(),
|
|
165
|
+
timestamp: bcs.u64(),
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
export const PriceToleranceUpdated = new MoveStruct({
|
|
169
|
+
name: `${$moduleName}::PriceToleranceUpdated`,
|
|
170
|
+
fields: {
|
|
171
|
+
pool_id: bcs.Address,
|
|
172
|
+
tolerance: bcs.u64(),
|
|
173
|
+
timestamp: bcs.u64(),
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
export const MaxPriceAgeUpdated = new MoveStruct({
|
|
177
|
+
name: `${$moduleName}::MaxPriceAgeUpdated`,
|
|
178
|
+
fields: {
|
|
179
|
+
pool_id: bcs.Address,
|
|
180
|
+
max_age_ms: bcs.u64(),
|
|
181
|
+
timestamp: bcs.u64(),
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
export const MaxOrderTtlUpdated = new MoveStruct({
|
|
185
|
+
name: `${$moduleName}::MaxOrderTtlUpdated`,
|
|
186
|
+
fields: {
|
|
187
|
+
pool_id: bcs.Address,
|
|
188
|
+
max_order_ttl_ms: bcs.u64(),
|
|
189
|
+
timestamp: bcs.u64(),
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
export const MinOpenRiskRatioUpdated = new MoveStruct({
|
|
193
|
+
name: `${$moduleName}::MinOpenRiskRatioUpdated`,
|
|
194
|
+
fields: {
|
|
195
|
+
pool_id: bcs.Address,
|
|
196
|
+
min_open_risk_ratio: bcs.u64(),
|
|
197
|
+
timestamp: bcs.u64(),
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
export interface MintMaintainerCapArguments {
|
|
201
|
+
self: RawTransactionArgument<string>;
|
|
202
|
+
AdminCap: RawTransactionArgument<string>;
|
|
203
|
+
}
|
|
204
|
+
export interface MintMaintainerCapOptions {
|
|
205
|
+
package?: string;
|
|
206
|
+
arguments:
|
|
207
|
+
| MintMaintainerCapArguments
|
|
208
|
+
| [self: RawTransactionArgument<string>, AdminCap: RawTransactionArgument<string>];
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Mint a `MaintainerCap`, only admin can mint a `MaintainerCap`. This function
|
|
212
|
+
* does not have version restrictions
|
|
213
|
+
*/
|
|
214
|
+
export function mintMaintainerCap(options: MintMaintainerCapOptions) {
|
|
215
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
216
|
+
const argumentsTypes = [null, null, '0x2::clock::Clock'] satisfies (string | null)[];
|
|
217
|
+
const parameterNames = ['self', 'AdminCap'];
|
|
218
|
+
return (tx: Transaction) =>
|
|
219
|
+
tx.moveCall({
|
|
220
|
+
package: packageAddress,
|
|
221
|
+
module: 'margin_registry',
|
|
222
|
+
function: 'mint_maintainer_cap',
|
|
223
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
export interface RevokeMaintainerCapArguments {
|
|
227
|
+
self: RawTransactionArgument<string>;
|
|
228
|
+
AdminCap: RawTransactionArgument<string>;
|
|
229
|
+
maintainerCapId: RawTransactionArgument<string>;
|
|
230
|
+
}
|
|
231
|
+
export interface RevokeMaintainerCapOptions {
|
|
232
|
+
package?: string;
|
|
233
|
+
arguments:
|
|
234
|
+
| RevokeMaintainerCapArguments
|
|
235
|
+
| [
|
|
236
|
+
self: RawTransactionArgument<string>,
|
|
237
|
+
AdminCap: RawTransactionArgument<string>,
|
|
238
|
+
maintainerCapId: RawTransactionArgument<string>,
|
|
239
|
+
];
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Revoke a `MaintainerCap`. Only the admin can revoke a `MaintainerCap`. This
|
|
243
|
+
* function does not have version restrictions
|
|
244
|
+
*/
|
|
245
|
+
export function revokeMaintainerCap(options: RevokeMaintainerCapOptions) {
|
|
246
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
247
|
+
const argumentsTypes = [null, null, '0x2::object::ID', '0x2::clock::Clock'] satisfies (
|
|
248
|
+
| string
|
|
249
|
+
| null
|
|
250
|
+
)[];
|
|
251
|
+
const parameterNames = ['self', 'AdminCap', 'maintainerCapId'];
|
|
252
|
+
return (tx: Transaction) =>
|
|
253
|
+
tx.moveCall({
|
|
254
|
+
package: packageAddress,
|
|
255
|
+
module: 'margin_registry',
|
|
256
|
+
function: 'revoke_maintainer_cap',
|
|
257
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
export interface RegisterDeepbookPoolArguments {
|
|
261
|
+
self: RawTransactionArgument<string>;
|
|
262
|
+
AdminCap: RawTransactionArgument<string>;
|
|
263
|
+
pool: RawTransactionArgument<string>;
|
|
264
|
+
poolConfig: TransactionArgument;
|
|
265
|
+
}
|
|
266
|
+
export interface RegisterDeepbookPoolOptions {
|
|
267
|
+
package?: string;
|
|
268
|
+
arguments:
|
|
269
|
+
| RegisterDeepbookPoolArguments
|
|
270
|
+
| [
|
|
271
|
+
self: RawTransactionArgument<string>,
|
|
272
|
+
AdminCap: RawTransactionArgument<string>,
|
|
273
|
+
pool: RawTransactionArgument<string>,
|
|
274
|
+
poolConfig: TransactionArgument,
|
|
275
|
+
];
|
|
276
|
+
typeArguments: [string, string];
|
|
277
|
+
}
|
|
278
|
+
/** Register a margin pool for margin trading with existing margin pools */
|
|
279
|
+
export function registerDeepbookPool(options: RegisterDeepbookPoolOptions) {
|
|
280
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
281
|
+
const argumentsTypes = [null, null, null, null, '0x2::clock::Clock'] satisfies (string | null)[];
|
|
282
|
+
const parameterNames = ['self', 'AdminCap', 'pool', 'poolConfig'];
|
|
283
|
+
return (tx: Transaction) =>
|
|
284
|
+
tx.moveCall({
|
|
285
|
+
package: packageAddress,
|
|
286
|
+
module: 'margin_registry',
|
|
287
|
+
function: 'register_deepbook_pool',
|
|
288
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
289
|
+
typeArguments: options.typeArguments,
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
export interface EnableDeepbookPoolArguments {
|
|
293
|
+
self: RawTransactionArgument<string>;
|
|
294
|
+
AdminCap: RawTransactionArgument<string>;
|
|
295
|
+
pool: RawTransactionArgument<string>;
|
|
296
|
+
}
|
|
297
|
+
export interface EnableDeepbookPoolOptions {
|
|
298
|
+
package?: string;
|
|
299
|
+
arguments:
|
|
300
|
+
| EnableDeepbookPoolArguments
|
|
301
|
+
| [
|
|
302
|
+
self: RawTransactionArgument<string>,
|
|
303
|
+
AdminCap: RawTransactionArgument<string>,
|
|
304
|
+
pool: RawTransactionArgument<string>,
|
|
305
|
+
];
|
|
306
|
+
typeArguments: [string, string];
|
|
307
|
+
}
|
|
308
|
+
/** Enables a deepbook pool for margin trading. */
|
|
309
|
+
export function enableDeepbookPool(options: EnableDeepbookPoolOptions) {
|
|
310
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
311
|
+
const argumentsTypes = [null, null, null, '0x2::clock::Clock'] satisfies (string | null)[];
|
|
312
|
+
const parameterNames = ['self', 'AdminCap', 'pool'];
|
|
313
|
+
return (tx: Transaction) =>
|
|
314
|
+
tx.moveCall({
|
|
315
|
+
package: packageAddress,
|
|
316
|
+
module: 'margin_registry',
|
|
317
|
+
function: 'enable_deepbook_pool',
|
|
318
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
319
|
+
typeArguments: options.typeArguments,
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
export interface DisableDeepbookPoolArguments {
|
|
323
|
+
self: RawTransactionArgument<string>;
|
|
324
|
+
AdminCap: RawTransactionArgument<string>;
|
|
325
|
+
pool: RawTransactionArgument<string>;
|
|
326
|
+
}
|
|
327
|
+
export interface DisableDeepbookPoolOptions {
|
|
328
|
+
package?: string;
|
|
329
|
+
arguments:
|
|
330
|
+
| DisableDeepbookPoolArguments
|
|
331
|
+
| [
|
|
332
|
+
self: RawTransactionArgument<string>,
|
|
333
|
+
AdminCap: RawTransactionArgument<string>,
|
|
334
|
+
pool: RawTransactionArgument<string>,
|
|
335
|
+
];
|
|
336
|
+
typeArguments: [string, string];
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Disables a deepbook pool from margin trading. Only reduce only orders, cancels,
|
|
340
|
+
* and withdraw settled amounts are allowed.
|
|
341
|
+
*/
|
|
342
|
+
export function disableDeepbookPool(options: DisableDeepbookPoolOptions) {
|
|
343
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
344
|
+
const argumentsTypes = [null, null, null, '0x2::clock::Clock'] satisfies (string | null)[];
|
|
345
|
+
const parameterNames = ['self', 'AdminCap', 'pool'];
|
|
346
|
+
return (tx: Transaction) =>
|
|
347
|
+
tx.moveCall({
|
|
348
|
+
package: packageAddress,
|
|
349
|
+
module: 'margin_registry',
|
|
350
|
+
function: 'disable_deepbook_pool',
|
|
351
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
352
|
+
typeArguments: options.typeArguments,
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
export interface UpdateRiskParamsArguments {
|
|
356
|
+
self: RawTransactionArgument<string>;
|
|
357
|
+
AdminCap: RawTransactionArgument<string>;
|
|
358
|
+
pool: RawTransactionArgument<string>;
|
|
359
|
+
poolConfig: TransactionArgument;
|
|
360
|
+
}
|
|
361
|
+
export interface UpdateRiskParamsOptions {
|
|
362
|
+
package?: string;
|
|
363
|
+
arguments:
|
|
364
|
+
| UpdateRiskParamsArguments
|
|
365
|
+
| [
|
|
366
|
+
self: RawTransactionArgument<string>,
|
|
367
|
+
AdminCap: RawTransactionArgument<string>,
|
|
368
|
+
pool: RawTransactionArgument<string>,
|
|
369
|
+
poolConfig: TransactionArgument,
|
|
370
|
+
];
|
|
371
|
+
typeArguments: [string, string];
|
|
372
|
+
}
|
|
373
|
+
/** Updates risk params for a deepbook pool as the admin. */
|
|
374
|
+
export function updateRiskParams(options: UpdateRiskParamsOptions) {
|
|
375
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
376
|
+
const argumentsTypes = [null, null, null, null, '0x2::clock::Clock'] satisfies (string | null)[];
|
|
377
|
+
const parameterNames = ['self', 'AdminCap', 'pool', 'poolConfig'];
|
|
378
|
+
return (tx: Transaction) =>
|
|
379
|
+
tx.moveCall({
|
|
380
|
+
package: packageAddress,
|
|
381
|
+
module: 'margin_registry',
|
|
382
|
+
function: 'update_risk_params',
|
|
383
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
384
|
+
typeArguments: options.typeArguments,
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
export interface AddConfigArguments<Config extends BcsType<any>> {
|
|
388
|
+
self: RawTransactionArgument<string>;
|
|
389
|
+
AdminCap: RawTransactionArgument<string>;
|
|
390
|
+
config: RawTransactionArgument<Config>;
|
|
391
|
+
}
|
|
392
|
+
export interface AddConfigOptions<Config extends BcsType<any>> {
|
|
393
|
+
package?: string;
|
|
394
|
+
arguments:
|
|
395
|
+
| AddConfigArguments<Config>
|
|
396
|
+
| [
|
|
397
|
+
self: RawTransactionArgument<string>,
|
|
398
|
+
AdminCap: RawTransactionArgument<string>,
|
|
399
|
+
config: RawTransactionArgument<Config>,
|
|
400
|
+
];
|
|
401
|
+
typeArguments: [string];
|
|
402
|
+
}
|
|
403
|
+
/** Add Pyth Config to the MarginRegistry. */
|
|
404
|
+
export function addConfig<Config extends BcsType<any>>(options: AddConfigOptions<Config>) {
|
|
405
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
406
|
+
const argumentsTypes = [null, null, `${options.typeArguments[0]}`] satisfies (string | null)[];
|
|
407
|
+
const parameterNames = ['self', 'AdminCap', 'config'];
|
|
408
|
+
return (tx: Transaction) =>
|
|
409
|
+
tx.moveCall({
|
|
410
|
+
package: packageAddress,
|
|
411
|
+
module: 'margin_registry',
|
|
412
|
+
function: 'add_config',
|
|
413
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
414
|
+
typeArguments: options.typeArguments,
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
export interface RemoveConfigArguments {
|
|
418
|
+
self: RawTransactionArgument<string>;
|
|
419
|
+
AdminCap: RawTransactionArgument<string>;
|
|
420
|
+
}
|
|
421
|
+
export interface RemoveConfigOptions {
|
|
422
|
+
package?: string;
|
|
423
|
+
arguments:
|
|
424
|
+
| RemoveConfigArguments
|
|
425
|
+
| [self: RawTransactionArgument<string>, AdminCap: RawTransactionArgument<string>];
|
|
426
|
+
typeArguments: [string];
|
|
427
|
+
}
|
|
428
|
+
/** Remove Pyth Config from the MarginRegistry. */
|
|
429
|
+
export function removeConfig(options: RemoveConfigOptions) {
|
|
430
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
431
|
+
const argumentsTypes = [null, null] satisfies (string | null)[];
|
|
432
|
+
const parameterNames = ['self', 'AdminCap'];
|
|
433
|
+
return (tx: Transaction) =>
|
|
434
|
+
tx.moveCall({
|
|
435
|
+
package: packageAddress,
|
|
436
|
+
module: 'margin_registry',
|
|
437
|
+
function: 'remove_config',
|
|
438
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
439
|
+
typeArguments: options.typeArguments,
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
export interface EnableVersionArguments {
|
|
443
|
+
self: RawTransactionArgument<string>;
|
|
444
|
+
version: RawTransactionArgument<number | bigint>;
|
|
445
|
+
AdminCap: RawTransactionArgument<string>;
|
|
446
|
+
}
|
|
447
|
+
export interface EnableVersionOptions {
|
|
448
|
+
package?: string;
|
|
449
|
+
arguments:
|
|
450
|
+
| EnableVersionArguments
|
|
451
|
+
| [
|
|
452
|
+
self: RawTransactionArgument<string>,
|
|
453
|
+
version: RawTransactionArgument<number | bigint>,
|
|
454
|
+
AdminCap: RawTransactionArgument<string>,
|
|
455
|
+
];
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Enables a package version Only Admin can enable a package version This function
|
|
459
|
+
* does not have version restrictions
|
|
460
|
+
*/
|
|
461
|
+
export function enableVersion(options: EnableVersionOptions) {
|
|
462
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
463
|
+
const argumentsTypes = [null, 'u64', null] satisfies (string | null)[];
|
|
464
|
+
const parameterNames = ['self', 'version', 'AdminCap'];
|
|
465
|
+
return (tx: Transaction) =>
|
|
466
|
+
tx.moveCall({
|
|
467
|
+
package: packageAddress,
|
|
468
|
+
module: 'margin_registry',
|
|
469
|
+
function: 'enable_version',
|
|
470
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
export interface DisableVersionArguments {
|
|
474
|
+
self: RawTransactionArgument<string>;
|
|
475
|
+
version: RawTransactionArgument<number | bigint>;
|
|
476
|
+
AdminCap: RawTransactionArgument<string>;
|
|
477
|
+
}
|
|
478
|
+
export interface DisableVersionOptions {
|
|
479
|
+
package?: string;
|
|
480
|
+
arguments:
|
|
481
|
+
| DisableVersionArguments
|
|
482
|
+
| [
|
|
483
|
+
self: RawTransactionArgument<string>,
|
|
484
|
+
version: RawTransactionArgument<number | bigint>,
|
|
485
|
+
AdminCap: RawTransactionArgument<string>,
|
|
486
|
+
];
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* Disables a package version Only Admin can disable a package version This
|
|
490
|
+
* function does not have version restrictions
|
|
491
|
+
*/
|
|
492
|
+
export function disableVersion(options: DisableVersionOptions) {
|
|
493
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
494
|
+
const argumentsTypes = [null, 'u64', null] satisfies (string | null)[];
|
|
495
|
+
const parameterNames = ['self', 'version', 'AdminCap'];
|
|
496
|
+
return (tx: Transaction) =>
|
|
497
|
+
tx.moveCall({
|
|
498
|
+
package: packageAddress,
|
|
499
|
+
module: 'margin_registry',
|
|
500
|
+
function: 'disable_version',
|
|
501
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
export interface DisableVersionPauseCapArguments {
|
|
505
|
+
self: RawTransactionArgument<string>;
|
|
506
|
+
version: RawTransactionArgument<number | bigint>;
|
|
507
|
+
pauseCap: RawTransactionArgument<string>;
|
|
508
|
+
}
|
|
509
|
+
export interface DisableVersionPauseCapOptions {
|
|
510
|
+
package?: string;
|
|
511
|
+
arguments:
|
|
512
|
+
| DisableVersionPauseCapArguments
|
|
513
|
+
| [
|
|
514
|
+
self: RawTransactionArgument<string>,
|
|
515
|
+
version: RawTransactionArgument<number | bigint>,
|
|
516
|
+
pauseCap: RawTransactionArgument<string>,
|
|
517
|
+
];
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Disables a package version Pause Cap must be valid and can disable the version
|
|
521
|
+
* This function does not have version restrictions
|
|
522
|
+
*/
|
|
523
|
+
export function disableVersionPauseCap(options: DisableVersionPauseCapOptions) {
|
|
524
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
525
|
+
const argumentsTypes = [null, 'u64', null] satisfies (string | null)[];
|
|
526
|
+
const parameterNames = ['self', 'version', 'pauseCap'];
|
|
527
|
+
return (tx: Transaction) =>
|
|
528
|
+
tx.moveCall({
|
|
529
|
+
package: packageAddress,
|
|
530
|
+
module: 'margin_registry',
|
|
531
|
+
function: 'disable_version_pause_cap',
|
|
532
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
export interface MintPauseCapArguments {
|
|
536
|
+
self: RawTransactionArgument<string>;
|
|
537
|
+
AdminCap: RawTransactionArgument<string>;
|
|
538
|
+
}
|
|
539
|
+
export interface MintPauseCapOptions {
|
|
540
|
+
package?: string;
|
|
541
|
+
arguments:
|
|
542
|
+
| MintPauseCapArguments
|
|
543
|
+
| [self: RawTransactionArgument<string>, AdminCap: RawTransactionArgument<string>];
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Mint a pause cap Only Admin can mint a pause cap This function does not have
|
|
547
|
+
* version restrictions
|
|
548
|
+
*/
|
|
549
|
+
export function mintPauseCap(options: MintPauseCapOptions) {
|
|
550
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
551
|
+
const argumentsTypes = [null, null, '0x2::clock::Clock'] satisfies (string | null)[];
|
|
552
|
+
const parameterNames = ['self', 'AdminCap'];
|
|
553
|
+
return (tx: Transaction) =>
|
|
554
|
+
tx.moveCall({
|
|
555
|
+
package: packageAddress,
|
|
556
|
+
module: 'margin_registry',
|
|
557
|
+
function: 'mint_pause_cap',
|
|
558
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
export interface RevokePauseCapArguments {
|
|
562
|
+
self: RawTransactionArgument<string>;
|
|
563
|
+
AdminCap: RawTransactionArgument<string>;
|
|
564
|
+
pauseCapId: RawTransactionArgument<string>;
|
|
565
|
+
}
|
|
566
|
+
export interface RevokePauseCapOptions {
|
|
567
|
+
package?: string;
|
|
568
|
+
arguments:
|
|
569
|
+
| RevokePauseCapArguments
|
|
570
|
+
| [
|
|
571
|
+
self: RawTransactionArgument<string>,
|
|
572
|
+
AdminCap: RawTransactionArgument<string>,
|
|
573
|
+
pauseCapId: RawTransactionArgument<string>,
|
|
574
|
+
];
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Revoke a pause cap Only Admin can revoke a pause cap This function does not have
|
|
578
|
+
* version restrictions
|
|
579
|
+
*/
|
|
580
|
+
export function revokePauseCap(options: RevokePauseCapOptions) {
|
|
581
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
582
|
+
const argumentsTypes = [null, null, '0x2::clock::Clock', '0x2::object::ID'] satisfies (
|
|
583
|
+
| string
|
|
584
|
+
| null
|
|
585
|
+
)[];
|
|
586
|
+
const parameterNames = ['self', 'AdminCap', 'pauseCapId'];
|
|
587
|
+
return (tx: Transaction) =>
|
|
588
|
+
tx.moveCall({
|
|
589
|
+
package: packageAddress,
|
|
590
|
+
module: 'margin_registry',
|
|
591
|
+
function: 'revoke_pause_cap',
|
|
592
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
export interface SetPriceToleranceArguments {
|
|
596
|
+
self: RawTransactionArgument<string>;
|
|
597
|
+
AdminCap: RawTransactionArgument<string>;
|
|
598
|
+
pool: RawTransactionArgument<string>;
|
|
599
|
+
tolerance: RawTransactionArgument<number | bigint>;
|
|
600
|
+
}
|
|
601
|
+
export interface SetPriceToleranceOptions {
|
|
602
|
+
package?: string;
|
|
603
|
+
arguments:
|
|
604
|
+
| SetPriceToleranceArguments
|
|
605
|
+
| [
|
|
606
|
+
self: RawTransactionArgument<string>,
|
|
607
|
+
AdminCap: RawTransactionArgument<string>,
|
|
608
|
+
pool: RawTransactionArgument<string>,
|
|
609
|
+
tolerance: RawTransactionArgument<number | bigint>,
|
|
610
|
+
];
|
|
611
|
+
typeArguments: [string, string];
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Set price deviation tolerance for a pool tolerance is in 9 decimals where 1.0 =
|
|
615
|
+
* 1_000_000_000 (e.g., 100_000_000 = 0.1 = 10%) Only Admin can set tolerance
|
|
616
|
+
* Requires price to be initialized first via update_current_price
|
|
617
|
+
*/
|
|
618
|
+
export function setPriceTolerance(options: SetPriceToleranceOptions) {
|
|
619
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
620
|
+
const argumentsTypes = [null, null, null, 'u64', '0x2::clock::Clock'] satisfies (string | null)[];
|
|
621
|
+
const parameterNames = ['self', 'AdminCap', 'pool', 'tolerance'];
|
|
622
|
+
return (tx: Transaction) =>
|
|
623
|
+
tx.moveCall({
|
|
624
|
+
package: packageAddress,
|
|
625
|
+
module: 'margin_registry',
|
|
626
|
+
function: 'set_price_tolerance',
|
|
627
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
628
|
+
typeArguments: options.typeArguments,
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
export interface SetMaxPriceAgeArguments {
|
|
632
|
+
self: RawTransactionArgument<string>;
|
|
633
|
+
AdminCap: RawTransactionArgument<string>;
|
|
634
|
+
pool: RawTransactionArgument<string>;
|
|
635
|
+
maxAgeMs: RawTransactionArgument<number | bigint>;
|
|
636
|
+
}
|
|
637
|
+
export interface SetMaxPriceAgeOptions {
|
|
638
|
+
package?: string;
|
|
639
|
+
arguments:
|
|
640
|
+
| SetMaxPriceAgeArguments
|
|
641
|
+
| [
|
|
642
|
+
self: RawTransactionArgument<string>,
|
|
643
|
+
AdminCap: RawTransactionArgument<string>,
|
|
644
|
+
pool: RawTransactionArgument<string>,
|
|
645
|
+
maxAgeMs: RawTransactionArgument<number | bigint>,
|
|
646
|
+
];
|
|
647
|
+
typeArguments: [string, string];
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* Set maximum price age in milliseconds for a pool Only Admin can set max price
|
|
651
|
+
* age Requires price to be initialized first via update_current_price
|
|
652
|
+
*/
|
|
653
|
+
export function setMaxPriceAge(options: SetMaxPriceAgeOptions) {
|
|
654
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
655
|
+
const argumentsTypes = [null, null, null, 'u64', '0x2::clock::Clock'] satisfies (string | null)[];
|
|
656
|
+
const parameterNames = ['self', 'AdminCap', 'pool', 'maxAgeMs'];
|
|
657
|
+
return (tx: Transaction) =>
|
|
658
|
+
tx.moveCall({
|
|
659
|
+
package: packageAddress,
|
|
660
|
+
module: 'margin_registry',
|
|
661
|
+
function: 'set_max_price_age',
|
|
662
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
663
|
+
typeArguments: options.typeArguments,
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
export interface SetMaxOrderTtlArguments {
|
|
667
|
+
self: RawTransactionArgument<string>;
|
|
668
|
+
AdminCap: RawTransactionArgument<string>;
|
|
669
|
+
pool: RawTransactionArgument<string>;
|
|
670
|
+
maxOrderTtlMs: RawTransactionArgument<number | bigint>;
|
|
671
|
+
}
|
|
672
|
+
export interface SetMaxOrderTtlOptions {
|
|
673
|
+
package?: string;
|
|
674
|
+
arguments:
|
|
675
|
+
| SetMaxOrderTtlArguments
|
|
676
|
+
| [
|
|
677
|
+
self: RawTransactionArgument<string>,
|
|
678
|
+
AdminCap: RawTransactionArgument<string>,
|
|
679
|
+
pool: RawTransactionArgument<string>,
|
|
680
|
+
maxOrderTtlMs: RawTransactionArgument<number | bigint>,
|
|
681
|
+
];
|
|
682
|
+
typeArguments: [string, string];
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Set the maximum lifetime (in ms) of margin limit orders for a pool.
|
|
686
|
+
* User-supplied `expire_timestamp` on margin limit-order placements is clamped to
|
|
687
|
+
* at most `now + max_order_ttl_ms`. Bounds margin orders' exposure to stale-price
|
|
688
|
+
* exploitation if liquidity disappears after placement. Only Admin can set max
|
|
689
|
+
* order TTL.
|
|
690
|
+
*/
|
|
691
|
+
export function setMaxOrderTtl(options: SetMaxOrderTtlOptions) {
|
|
692
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
693
|
+
const argumentsTypes = [null, null, null, 'u64', '0x2::clock::Clock'] satisfies (string | null)[];
|
|
694
|
+
const parameterNames = ['self', 'AdminCap', 'pool', 'maxOrderTtlMs'];
|
|
695
|
+
return (tx: Transaction) =>
|
|
696
|
+
tx.moveCall({
|
|
697
|
+
package: packageAddress,
|
|
698
|
+
module: 'margin_registry',
|
|
699
|
+
function: 'set_max_order_ttl',
|
|
700
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
701
|
+
typeArguments: options.typeArguments,
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
export interface SetMinOpenRiskRatioArguments {
|
|
705
|
+
self: RawTransactionArgument<string>;
|
|
706
|
+
AdminCap: RawTransactionArgument<string>;
|
|
707
|
+
pool: RawTransactionArgument<string>;
|
|
708
|
+
minOpenRiskRatio: RawTransactionArgument<number | bigint>;
|
|
709
|
+
}
|
|
710
|
+
export interface SetMinOpenRiskRatioOptions {
|
|
711
|
+
package?: string;
|
|
712
|
+
arguments:
|
|
713
|
+
| SetMinOpenRiskRatioArguments
|
|
714
|
+
| [
|
|
715
|
+
self: RawTransactionArgument<string>,
|
|
716
|
+
AdminCap: RawTransactionArgument<string>,
|
|
717
|
+
pool: RawTransactionArgument<string>,
|
|
718
|
+
minOpenRiskRatio: RawTransactionArgument<number | bigint>,
|
|
719
|
+
];
|
|
720
|
+
typeArguments: [string, string];
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* Set the per-pool `min_open_risk_ratio` override — the post-trade solvency floor
|
|
724
|
+
* enforced on opening (risk-increasing) orders. Must sit in
|
|
725
|
+
* `(liquidation_risk_ratio, min_borrow_risk_ratio]`: above liquidation so an open
|
|
726
|
+
* can't land in the liquidatable zone, at or below the borrow floor. Absent an
|
|
727
|
+
* override the floor defaults to the midpoint of liquidation and min_borrow. Only
|
|
728
|
+
* Admin can set it.
|
|
729
|
+
*/
|
|
730
|
+
export function setMinOpenRiskRatio(options: SetMinOpenRiskRatioOptions) {
|
|
731
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
732
|
+
const argumentsTypes = [null, null, null, 'u64', '0x2::clock::Clock'] satisfies (string | null)[];
|
|
733
|
+
const parameterNames = ['self', 'AdminCap', 'pool', 'minOpenRiskRatio'];
|
|
734
|
+
return (tx: Transaction) =>
|
|
735
|
+
tx.moveCall({
|
|
736
|
+
package: packageAddress,
|
|
737
|
+
module: 'margin_registry',
|
|
738
|
+
function: 'set_min_open_risk_ratio',
|
|
739
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
740
|
+
typeArguments: options.typeArguments,
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
export interface NewPoolConfigArguments {
|
|
744
|
+
self: RawTransactionArgument<string>;
|
|
745
|
+
minWithdrawRiskRatio: RawTransactionArgument<number | bigint>;
|
|
746
|
+
minBorrowRiskRatio: RawTransactionArgument<number | bigint>;
|
|
747
|
+
liquidationRiskRatio: RawTransactionArgument<number | bigint>;
|
|
748
|
+
targetLiquidationRiskRatio: RawTransactionArgument<number | bigint>;
|
|
749
|
+
userLiquidationReward: RawTransactionArgument<number | bigint>;
|
|
750
|
+
poolLiquidationReward: RawTransactionArgument<number | bigint>;
|
|
751
|
+
}
|
|
752
|
+
export interface NewPoolConfigOptions {
|
|
753
|
+
package?: string;
|
|
754
|
+
arguments:
|
|
755
|
+
| NewPoolConfigArguments
|
|
756
|
+
| [
|
|
757
|
+
self: RawTransactionArgument<string>,
|
|
758
|
+
minWithdrawRiskRatio: RawTransactionArgument<number | bigint>,
|
|
759
|
+
minBorrowRiskRatio: RawTransactionArgument<number | bigint>,
|
|
760
|
+
liquidationRiskRatio: RawTransactionArgument<number | bigint>,
|
|
761
|
+
targetLiquidationRiskRatio: RawTransactionArgument<number | bigint>,
|
|
762
|
+
userLiquidationReward: RawTransactionArgument<number | bigint>,
|
|
763
|
+
poolLiquidationReward: RawTransactionArgument<number | bigint>,
|
|
764
|
+
];
|
|
765
|
+
typeArguments: [string, string];
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* Create a PoolConfig with margin pool IDs and risk parameters Enable is false by
|
|
769
|
+
* default, must be enabled after registration
|
|
770
|
+
*/
|
|
771
|
+
export function newPoolConfig(options: NewPoolConfigOptions) {
|
|
772
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
773
|
+
const argumentsTypes = [null, 'u64', 'u64', 'u64', 'u64', 'u64', 'u64'] satisfies (
|
|
774
|
+
| string
|
|
775
|
+
| null
|
|
776
|
+
)[];
|
|
777
|
+
const parameterNames = [
|
|
778
|
+
'self',
|
|
779
|
+
'minWithdrawRiskRatio',
|
|
780
|
+
'minBorrowRiskRatio',
|
|
781
|
+
'liquidationRiskRatio',
|
|
782
|
+
'targetLiquidationRiskRatio',
|
|
783
|
+
'userLiquidationReward',
|
|
784
|
+
'poolLiquidationReward',
|
|
785
|
+
];
|
|
786
|
+
return (tx: Transaction) =>
|
|
787
|
+
tx.moveCall({
|
|
788
|
+
package: packageAddress,
|
|
789
|
+
module: 'margin_registry',
|
|
790
|
+
function: 'new_pool_config',
|
|
791
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
792
|
+
typeArguments: options.typeArguments,
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
export interface NewPoolConfigWithLeverageArguments {
|
|
796
|
+
self: RawTransactionArgument<string>;
|
|
797
|
+
leverage: RawTransactionArgument<number | bigint>;
|
|
798
|
+
}
|
|
799
|
+
export interface NewPoolConfigWithLeverageOptions {
|
|
800
|
+
package?: string;
|
|
801
|
+
arguments:
|
|
802
|
+
| NewPoolConfigWithLeverageArguments
|
|
803
|
+
| [self: RawTransactionArgument<string>, leverage: RawTransactionArgument<number | bigint>];
|
|
804
|
+
typeArguments: [string, string];
|
|
805
|
+
}
|
|
806
|
+
/** Create a PoolConfig with default risk parameters based on leverage */
|
|
807
|
+
export function newPoolConfigWithLeverage(options: NewPoolConfigWithLeverageOptions) {
|
|
808
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
809
|
+
const argumentsTypes = [null, 'u64'] satisfies (string | null)[];
|
|
810
|
+
const parameterNames = ['self', 'leverage'];
|
|
811
|
+
return (tx: Transaction) =>
|
|
812
|
+
tx.moveCall({
|
|
813
|
+
package: packageAddress,
|
|
814
|
+
module: 'margin_registry',
|
|
815
|
+
function: 'new_pool_config_with_leverage',
|
|
816
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
817
|
+
typeArguments: options.typeArguments,
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
export interface PoolEnabledArguments {
|
|
821
|
+
self: RawTransactionArgument<string>;
|
|
822
|
+
pool: RawTransactionArgument<string>;
|
|
823
|
+
}
|
|
824
|
+
export interface PoolEnabledOptions {
|
|
825
|
+
package?: string;
|
|
826
|
+
arguments:
|
|
827
|
+
| PoolEnabledArguments
|
|
828
|
+
| [self: RawTransactionArgument<string>, pool: RawTransactionArgument<string>];
|
|
829
|
+
typeArguments: [string, string];
|
|
830
|
+
}
|
|
831
|
+
/** Check if a deepbook pool is registered for margin trading */
|
|
832
|
+
export function poolEnabled(options: PoolEnabledOptions) {
|
|
833
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
834
|
+
const argumentsTypes = [null, null] satisfies (string | null)[];
|
|
835
|
+
const parameterNames = ['self', 'pool'];
|
|
836
|
+
return (tx: Transaction) =>
|
|
837
|
+
tx.moveCall({
|
|
838
|
+
package: packageAddress,
|
|
839
|
+
module: 'margin_registry',
|
|
840
|
+
function: 'pool_enabled',
|
|
841
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
842
|
+
typeArguments: options.typeArguments,
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
export interface GetMarginPoolIdArguments {
|
|
846
|
+
self: RawTransactionArgument<string>;
|
|
847
|
+
}
|
|
848
|
+
export interface GetMarginPoolIdOptions {
|
|
849
|
+
package?: string;
|
|
850
|
+
arguments: GetMarginPoolIdArguments | [self: RawTransactionArgument<string>];
|
|
851
|
+
typeArguments: [string];
|
|
852
|
+
}
|
|
853
|
+
/** Get the margin pool id for the given asset. */
|
|
854
|
+
export function getMarginPoolId(options: GetMarginPoolIdOptions) {
|
|
855
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
856
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
857
|
+
const parameterNames = ['self'];
|
|
858
|
+
return (tx: Transaction) =>
|
|
859
|
+
tx.moveCall({
|
|
860
|
+
package: packageAddress,
|
|
861
|
+
module: 'margin_registry',
|
|
862
|
+
function: 'get_margin_pool_id',
|
|
863
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
864
|
+
typeArguments: options.typeArguments,
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
export interface GetDeepbookPoolMarginPoolIdsArguments {
|
|
868
|
+
self: RawTransactionArgument<string>;
|
|
869
|
+
deepbookPoolId: RawTransactionArgument<string>;
|
|
870
|
+
}
|
|
871
|
+
export interface GetDeepbookPoolMarginPoolIdsOptions {
|
|
872
|
+
package?: string;
|
|
873
|
+
arguments:
|
|
874
|
+
| GetDeepbookPoolMarginPoolIdsArguments
|
|
875
|
+
| [self: RawTransactionArgument<string>, deepbookPoolId: RawTransactionArgument<string>];
|
|
876
|
+
}
|
|
877
|
+
/** Get the margin pool IDs for a deepbook pool */
|
|
878
|
+
export function getDeepbookPoolMarginPoolIds(options: GetDeepbookPoolMarginPoolIdsOptions) {
|
|
879
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
880
|
+
const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[];
|
|
881
|
+
const parameterNames = ['self', 'deepbookPoolId'];
|
|
882
|
+
return (tx: Transaction) =>
|
|
883
|
+
tx.moveCall({
|
|
884
|
+
package: packageAddress,
|
|
885
|
+
module: 'margin_registry',
|
|
886
|
+
function: 'get_deepbook_pool_margin_pool_ids',
|
|
887
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
export interface GetMarginManagerIdsArguments {
|
|
891
|
+
self: RawTransactionArgument<string>;
|
|
892
|
+
owner: RawTransactionArgument<string>;
|
|
893
|
+
}
|
|
894
|
+
export interface GetMarginManagerIdsOptions {
|
|
895
|
+
package?: string;
|
|
896
|
+
arguments:
|
|
897
|
+
| GetMarginManagerIdsArguments
|
|
898
|
+
| [self: RawTransactionArgument<string>, owner: RawTransactionArgument<string>];
|
|
899
|
+
}
|
|
900
|
+
/** Get the margin manager IDs for a given owner */
|
|
901
|
+
export function getMarginManagerIds(options: GetMarginManagerIdsOptions) {
|
|
902
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
903
|
+
const argumentsTypes = [null, 'address'] satisfies (string | null)[];
|
|
904
|
+
const parameterNames = ['self', 'owner'];
|
|
905
|
+
return (tx: Transaction) =>
|
|
906
|
+
tx.moveCall({
|
|
907
|
+
package: packageAddress,
|
|
908
|
+
module: 'margin_registry',
|
|
909
|
+
function: 'get_margin_manager_ids',
|
|
910
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
export interface CanLiquidateArguments {
|
|
914
|
+
self: RawTransactionArgument<string>;
|
|
915
|
+
deepbookPoolId: RawTransactionArgument<string>;
|
|
916
|
+
riskRatio: RawTransactionArgument<number | bigint>;
|
|
917
|
+
}
|
|
918
|
+
export interface CanLiquidateOptions {
|
|
919
|
+
package?: string;
|
|
920
|
+
arguments:
|
|
921
|
+
| CanLiquidateArguments
|
|
922
|
+
| [
|
|
923
|
+
self: RawTransactionArgument<string>,
|
|
924
|
+
deepbookPoolId: RawTransactionArgument<string>,
|
|
925
|
+
riskRatio: RawTransactionArgument<number | bigint>,
|
|
926
|
+
];
|
|
927
|
+
}
|
|
928
|
+
export function canLiquidate(options: CanLiquidateOptions) {
|
|
929
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
930
|
+
const argumentsTypes = [null, '0x2::object::ID', 'u64'] satisfies (string | null)[];
|
|
931
|
+
const parameterNames = ['self', 'deepbookPoolId', 'riskRatio'];
|
|
932
|
+
return (tx: Transaction) =>
|
|
933
|
+
tx.moveCall({
|
|
934
|
+
package: packageAddress,
|
|
935
|
+
module: 'margin_registry',
|
|
936
|
+
function: 'can_liquidate',
|
|
937
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
export interface BaseMarginPoolIdArguments {
|
|
941
|
+
self: RawTransactionArgument<string>;
|
|
942
|
+
deepbookPoolId: RawTransactionArgument<string>;
|
|
943
|
+
}
|
|
944
|
+
export interface BaseMarginPoolIdOptions {
|
|
945
|
+
package?: string;
|
|
946
|
+
arguments:
|
|
947
|
+
| BaseMarginPoolIdArguments
|
|
948
|
+
| [self: RawTransactionArgument<string>, deepbookPoolId: RawTransactionArgument<string>];
|
|
949
|
+
}
|
|
950
|
+
export function baseMarginPoolId(options: BaseMarginPoolIdOptions) {
|
|
951
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
952
|
+
const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[];
|
|
953
|
+
const parameterNames = ['self', 'deepbookPoolId'];
|
|
954
|
+
return (tx: Transaction) =>
|
|
955
|
+
tx.moveCall({
|
|
956
|
+
package: packageAddress,
|
|
957
|
+
module: 'margin_registry',
|
|
958
|
+
function: 'base_margin_pool_id',
|
|
959
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
export interface QuoteMarginPoolIdArguments {
|
|
963
|
+
self: RawTransactionArgument<string>;
|
|
964
|
+
deepbookPoolId: RawTransactionArgument<string>;
|
|
965
|
+
}
|
|
966
|
+
export interface QuoteMarginPoolIdOptions {
|
|
967
|
+
package?: string;
|
|
968
|
+
arguments:
|
|
969
|
+
| QuoteMarginPoolIdArguments
|
|
970
|
+
| [self: RawTransactionArgument<string>, deepbookPoolId: RawTransactionArgument<string>];
|
|
971
|
+
}
|
|
972
|
+
export function quoteMarginPoolId(options: QuoteMarginPoolIdOptions) {
|
|
973
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
974
|
+
const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[];
|
|
975
|
+
const parameterNames = ['self', 'deepbookPoolId'];
|
|
976
|
+
return (tx: Transaction) =>
|
|
977
|
+
tx.moveCall({
|
|
978
|
+
package: packageAddress,
|
|
979
|
+
module: 'margin_registry',
|
|
980
|
+
function: 'quote_margin_pool_id',
|
|
981
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
982
|
+
});
|
|
983
|
+
}
|
|
984
|
+
export interface MinWithdrawRiskRatioArguments {
|
|
985
|
+
self: RawTransactionArgument<string>;
|
|
986
|
+
deepbookPoolId: RawTransactionArgument<string>;
|
|
987
|
+
}
|
|
988
|
+
export interface MinWithdrawRiskRatioOptions {
|
|
989
|
+
package?: string;
|
|
990
|
+
arguments:
|
|
991
|
+
| MinWithdrawRiskRatioArguments
|
|
992
|
+
| [self: RawTransactionArgument<string>, deepbookPoolId: RawTransactionArgument<string>];
|
|
993
|
+
}
|
|
994
|
+
export function minWithdrawRiskRatio(options: MinWithdrawRiskRatioOptions) {
|
|
995
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
996
|
+
const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[];
|
|
997
|
+
const parameterNames = ['self', 'deepbookPoolId'];
|
|
998
|
+
return (tx: Transaction) =>
|
|
999
|
+
tx.moveCall({
|
|
1000
|
+
package: packageAddress,
|
|
1001
|
+
module: 'margin_registry',
|
|
1002
|
+
function: 'min_withdraw_risk_ratio',
|
|
1003
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
1006
|
+
export interface MinBorrowRiskRatioArguments {
|
|
1007
|
+
self: RawTransactionArgument<string>;
|
|
1008
|
+
deepbookPoolId: RawTransactionArgument<string>;
|
|
1009
|
+
}
|
|
1010
|
+
export interface MinBorrowRiskRatioOptions {
|
|
1011
|
+
package?: string;
|
|
1012
|
+
arguments:
|
|
1013
|
+
| MinBorrowRiskRatioArguments
|
|
1014
|
+
| [self: RawTransactionArgument<string>, deepbookPoolId: RawTransactionArgument<string>];
|
|
1015
|
+
}
|
|
1016
|
+
export function minBorrowRiskRatio(options: MinBorrowRiskRatioOptions) {
|
|
1017
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1018
|
+
const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[];
|
|
1019
|
+
const parameterNames = ['self', 'deepbookPoolId'];
|
|
1020
|
+
return (tx: Transaction) =>
|
|
1021
|
+
tx.moveCall({
|
|
1022
|
+
package: packageAddress,
|
|
1023
|
+
module: 'margin_registry',
|
|
1024
|
+
function: 'min_borrow_risk_ratio',
|
|
1025
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
export interface LiquidationRiskRatioArguments {
|
|
1029
|
+
self: RawTransactionArgument<string>;
|
|
1030
|
+
deepbookPoolId: RawTransactionArgument<string>;
|
|
1031
|
+
}
|
|
1032
|
+
export interface LiquidationRiskRatioOptions {
|
|
1033
|
+
package?: string;
|
|
1034
|
+
arguments:
|
|
1035
|
+
| LiquidationRiskRatioArguments
|
|
1036
|
+
| [self: RawTransactionArgument<string>, deepbookPoolId: RawTransactionArgument<string>];
|
|
1037
|
+
}
|
|
1038
|
+
export function liquidationRiskRatio(options: LiquidationRiskRatioOptions) {
|
|
1039
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1040
|
+
const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[];
|
|
1041
|
+
const parameterNames = ['self', 'deepbookPoolId'];
|
|
1042
|
+
return (tx: Transaction) =>
|
|
1043
|
+
tx.moveCall({
|
|
1044
|
+
package: packageAddress,
|
|
1045
|
+
module: 'margin_registry',
|
|
1046
|
+
function: 'liquidation_risk_ratio',
|
|
1047
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
export interface TargetLiquidationRiskRatioArguments {
|
|
1051
|
+
self: RawTransactionArgument<string>;
|
|
1052
|
+
deepbookPoolId: RawTransactionArgument<string>;
|
|
1053
|
+
}
|
|
1054
|
+
export interface TargetLiquidationRiskRatioOptions {
|
|
1055
|
+
package?: string;
|
|
1056
|
+
arguments:
|
|
1057
|
+
| TargetLiquidationRiskRatioArguments
|
|
1058
|
+
| [self: RawTransactionArgument<string>, deepbookPoolId: RawTransactionArgument<string>];
|
|
1059
|
+
}
|
|
1060
|
+
export function targetLiquidationRiskRatio(options: TargetLiquidationRiskRatioOptions) {
|
|
1061
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1062
|
+
const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[];
|
|
1063
|
+
const parameterNames = ['self', 'deepbookPoolId'];
|
|
1064
|
+
return (tx: Transaction) =>
|
|
1065
|
+
tx.moveCall({
|
|
1066
|
+
package: packageAddress,
|
|
1067
|
+
module: 'margin_registry',
|
|
1068
|
+
function: 'target_liquidation_risk_ratio',
|
|
1069
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
export interface MinOpenRiskRatioArguments {
|
|
1073
|
+
self: RawTransactionArgument<string>;
|
|
1074
|
+
deepbookPoolId: RawTransactionArgument<string>;
|
|
1075
|
+
}
|
|
1076
|
+
export interface MinOpenRiskRatioOptions {
|
|
1077
|
+
package?: string;
|
|
1078
|
+
arguments:
|
|
1079
|
+
| MinOpenRiskRatioArguments
|
|
1080
|
+
| [self: RawTransactionArgument<string>, deepbookPoolId: RawTransactionArgument<string>];
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Post-trade solvency floor for _opening_ (risk-increasing) orders, sitting in
|
|
1084
|
+
* `(liquidation_risk_ratio, min_borrow_risk_ratio]`. Lets a max-leverage open
|
|
1085
|
+
* absorb the opening trade's spread — which lands the post-trade ratio just under
|
|
1086
|
+
* the borrow floor — without aborting, while staying above the liquidatable zone.
|
|
1087
|
+
* Defaults to the midpoint of liquidation and min_borrow; an admin override
|
|
1088
|
+
* (`set_min_open_risk_ratio`) is honored only while it stays in the valid band, so
|
|
1089
|
+
* a later risk-param change can't strand it below liquidation.
|
|
1090
|
+
*/
|
|
1091
|
+
export function minOpenRiskRatio(options: MinOpenRiskRatioOptions) {
|
|
1092
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1093
|
+
const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[];
|
|
1094
|
+
const parameterNames = ['self', 'deepbookPoolId'];
|
|
1095
|
+
return (tx: Transaction) =>
|
|
1096
|
+
tx.moveCall({
|
|
1097
|
+
package: packageAddress,
|
|
1098
|
+
module: 'margin_registry',
|
|
1099
|
+
function: 'min_open_risk_ratio',
|
|
1100
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1101
|
+
});
|
|
1102
|
+
}
|
|
1103
|
+
export interface UserLiquidationRewardArguments {
|
|
1104
|
+
self: RawTransactionArgument<string>;
|
|
1105
|
+
deepbookPoolId: RawTransactionArgument<string>;
|
|
1106
|
+
}
|
|
1107
|
+
export interface UserLiquidationRewardOptions {
|
|
1108
|
+
package?: string;
|
|
1109
|
+
arguments:
|
|
1110
|
+
| UserLiquidationRewardArguments
|
|
1111
|
+
| [self: RawTransactionArgument<string>, deepbookPoolId: RawTransactionArgument<string>];
|
|
1112
|
+
}
|
|
1113
|
+
export function userLiquidationReward(options: UserLiquidationRewardOptions) {
|
|
1114
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1115
|
+
const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[];
|
|
1116
|
+
const parameterNames = ['self', 'deepbookPoolId'];
|
|
1117
|
+
return (tx: Transaction) =>
|
|
1118
|
+
tx.moveCall({
|
|
1119
|
+
package: packageAddress,
|
|
1120
|
+
module: 'margin_registry',
|
|
1121
|
+
function: 'user_liquidation_reward',
|
|
1122
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1123
|
+
});
|
|
1124
|
+
}
|
|
1125
|
+
export interface PoolLiquidationRewardArguments {
|
|
1126
|
+
self: RawTransactionArgument<string>;
|
|
1127
|
+
deepbookPoolId: RawTransactionArgument<string>;
|
|
1128
|
+
}
|
|
1129
|
+
export interface PoolLiquidationRewardOptions {
|
|
1130
|
+
package?: string;
|
|
1131
|
+
arguments:
|
|
1132
|
+
| PoolLiquidationRewardArguments
|
|
1133
|
+
| [self: RawTransactionArgument<string>, deepbookPoolId: RawTransactionArgument<string>];
|
|
1134
|
+
}
|
|
1135
|
+
export function poolLiquidationReward(options: PoolLiquidationRewardOptions) {
|
|
1136
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1137
|
+
const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[];
|
|
1138
|
+
const parameterNames = ['self', 'deepbookPoolId'];
|
|
1139
|
+
return (tx: Transaction) =>
|
|
1140
|
+
tx.moveCall({
|
|
1141
|
+
package: packageAddress,
|
|
1142
|
+
module: 'margin_registry',
|
|
1143
|
+
function: 'pool_liquidation_reward',
|
|
1144
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1145
|
+
});
|
|
1146
|
+
}
|
|
1147
|
+
export interface AllowedMaintainersArguments {
|
|
1148
|
+
self: RawTransactionArgument<string>;
|
|
1149
|
+
}
|
|
1150
|
+
export interface AllowedMaintainersOptions {
|
|
1151
|
+
package?: string;
|
|
1152
|
+
arguments: AllowedMaintainersArguments | [self: RawTransactionArgument<string>];
|
|
1153
|
+
}
|
|
1154
|
+
export function allowedMaintainers(options: AllowedMaintainersOptions) {
|
|
1155
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1156
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
1157
|
+
const parameterNames = ['self'];
|
|
1158
|
+
return (tx: Transaction) =>
|
|
1159
|
+
tx.moveCall({
|
|
1160
|
+
package: packageAddress,
|
|
1161
|
+
module: 'margin_registry',
|
|
1162
|
+
function: 'allowed_maintainers',
|
|
1163
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1164
|
+
});
|
|
1165
|
+
}
|
|
1166
|
+
export interface AllowedPauseCapsArguments {
|
|
1167
|
+
self: RawTransactionArgument<string>;
|
|
1168
|
+
}
|
|
1169
|
+
export interface AllowedPauseCapsOptions {
|
|
1170
|
+
package?: string;
|
|
1171
|
+
arguments: AllowedPauseCapsArguments | [self: RawTransactionArgument<string>];
|
|
1172
|
+
}
|
|
1173
|
+
export function allowedPauseCaps(options: AllowedPauseCapsOptions) {
|
|
1174
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1175
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
1176
|
+
const parameterNames = ['self'];
|
|
1177
|
+
return (tx: Transaction) =>
|
|
1178
|
+
tx.moveCall({
|
|
1179
|
+
package: packageAddress,
|
|
1180
|
+
module: 'margin_registry',
|
|
1181
|
+
function: 'allowed_pause_caps',
|
|
1182
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1185
|
+
export interface GetPoolConfigArguments {
|
|
1186
|
+
self: RawTransactionArgument<string>;
|
|
1187
|
+
deepbookPoolId: RawTransactionArgument<string>;
|
|
1188
|
+
}
|
|
1189
|
+
export interface GetPoolConfigOptions {
|
|
1190
|
+
package?: string;
|
|
1191
|
+
arguments:
|
|
1192
|
+
| GetPoolConfigArguments
|
|
1193
|
+
| [self: RawTransactionArgument<string>, deepbookPoolId: RawTransactionArgument<string>];
|
|
1194
|
+
}
|
|
1195
|
+
/** Get the pool configuration for a deepbook pool */
|
|
1196
|
+
export function getPoolConfig(options: GetPoolConfigOptions) {
|
|
1197
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1198
|
+
const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[];
|
|
1199
|
+
const parameterNames = ['self', 'deepbookPoolId'];
|
|
1200
|
+
return (tx: Transaction) =>
|
|
1201
|
+
tx.moveCall({
|
|
1202
|
+
package: packageAddress,
|
|
1203
|
+
module: 'margin_registry',
|
|
1204
|
+
function: 'get_pool_config',
|
|
1205
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1206
|
+
});
|
|
1207
|
+
}
|