@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,1772 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';
|
|
5
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
6
|
+
import { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';
|
|
7
|
+
import * as balance_manager from './deps/deepbook/balance_manager.js';
|
|
8
|
+
import * as tpsl from './tpsl.js';
|
|
9
|
+
import * as vec_map from './deps/sui/vec_map.js';
|
|
10
|
+
import * as type_name from './deps/std/type_name.js';
|
|
11
|
+
const $moduleName = '@deepbook/margin::margin_manager';
|
|
12
|
+
export const MarginApp = new MoveStruct({
|
|
13
|
+
name: `${$moduleName}::MarginApp`,
|
|
14
|
+
fields: {
|
|
15
|
+
dummy_field: bcs.bool(),
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
export const MarginManager = new MoveStruct({
|
|
19
|
+
name: `${$moduleName}::MarginManager<phantom BaseAsset, phantom QuoteAsset>`,
|
|
20
|
+
fields: {
|
|
21
|
+
id: bcs.Address,
|
|
22
|
+
owner: bcs.Address,
|
|
23
|
+
deepbook_pool: bcs.Address,
|
|
24
|
+
margin_pool_id: bcs.option(bcs.Address),
|
|
25
|
+
balance_manager: balance_manager.BalanceManager,
|
|
26
|
+
deposit_cap: balance_manager.DepositCap,
|
|
27
|
+
withdraw_cap: balance_manager.WithdrawCap,
|
|
28
|
+
trade_cap: balance_manager.TradeCap,
|
|
29
|
+
borrowed_base_shares: bcs.u64(),
|
|
30
|
+
borrowed_quote_shares: bcs.u64(),
|
|
31
|
+
take_profit_stop_loss: tpsl.TakeProfitStopLoss,
|
|
32
|
+
extra_fields: vec_map.VecMap(bcs.string(), bcs.u64()),
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
export const ManagerInitializer = new MoveStruct({
|
|
36
|
+
name: `${$moduleName}::ManagerInitializer`,
|
|
37
|
+
fields: {
|
|
38
|
+
margin_manager_id: bcs.Address,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
export const MarginManagerCreatedEvent = new MoveStruct({
|
|
42
|
+
name: `${$moduleName}::MarginManagerCreatedEvent`,
|
|
43
|
+
fields: {
|
|
44
|
+
margin_manager_id: bcs.Address,
|
|
45
|
+
balance_manager_id: bcs.Address,
|
|
46
|
+
deepbook_pool_id: bcs.Address,
|
|
47
|
+
owner: bcs.Address,
|
|
48
|
+
timestamp: bcs.u64(),
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
export const LoanBorrowedEvent = new MoveStruct({
|
|
52
|
+
name: `${$moduleName}::LoanBorrowedEvent`,
|
|
53
|
+
fields: {
|
|
54
|
+
margin_manager_id: bcs.Address,
|
|
55
|
+
margin_pool_id: bcs.Address,
|
|
56
|
+
loan_amount: bcs.u64(),
|
|
57
|
+
loan_shares: bcs.u64(),
|
|
58
|
+
timestamp: bcs.u64(),
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
export const LoanRepaidEvent = new MoveStruct({
|
|
62
|
+
name: `${$moduleName}::LoanRepaidEvent`,
|
|
63
|
+
fields: {
|
|
64
|
+
margin_manager_id: bcs.Address,
|
|
65
|
+
margin_pool_id: bcs.Address,
|
|
66
|
+
repay_amount: bcs.u64(),
|
|
67
|
+
repay_shares: bcs.u64(),
|
|
68
|
+
timestamp: bcs.u64(),
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
export const LiquidationEvent = new MoveStruct({
|
|
72
|
+
name: `${$moduleName}::LiquidationEvent`,
|
|
73
|
+
fields: {
|
|
74
|
+
margin_manager_id: bcs.Address,
|
|
75
|
+
margin_pool_id: bcs.Address,
|
|
76
|
+
liquidation_amount: bcs.u64(),
|
|
77
|
+
pool_reward: bcs.u64(),
|
|
78
|
+
pool_default: bcs.u64(),
|
|
79
|
+
risk_ratio: bcs.u64(),
|
|
80
|
+
remaining_base_asset: bcs.u64(),
|
|
81
|
+
remaining_quote_asset: bcs.u64(),
|
|
82
|
+
remaining_base_debt: bcs.u64(),
|
|
83
|
+
remaining_quote_debt: bcs.u64(),
|
|
84
|
+
base_pyth_price: bcs.u64(),
|
|
85
|
+
base_pyth_decimals: bcs.u8(),
|
|
86
|
+
quote_pyth_price: bcs.u64(),
|
|
87
|
+
quote_pyth_decimals: bcs.u8(),
|
|
88
|
+
timestamp: bcs.u64(),
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
export const DepositCollateralEvent = new MoveStruct({
|
|
92
|
+
name: `${$moduleName}::DepositCollateralEvent`,
|
|
93
|
+
fields: {
|
|
94
|
+
margin_manager_id: bcs.Address,
|
|
95
|
+
amount: bcs.u64(),
|
|
96
|
+
asset: type_name.TypeName,
|
|
97
|
+
pyth_price: bcs.u64(),
|
|
98
|
+
pyth_decimals: bcs.u8(),
|
|
99
|
+
timestamp: bcs.u64(),
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
export const WithdrawCollateralEvent = new MoveStruct({
|
|
103
|
+
name: `${$moduleName}::WithdrawCollateralEvent`,
|
|
104
|
+
fields: {
|
|
105
|
+
margin_manager_id: bcs.Address,
|
|
106
|
+
amount: bcs.u64(),
|
|
107
|
+
asset: type_name.TypeName,
|
|
108
|
+
withdraw_base_asset: bcs.bool(),
|
|
109
|
+
remaining_base_asset: bcs.u64(),
|
|
110
|
+
remaining_quote_asset: bcs.u64(),
|
|
111
|
+
remaining_base_debt: bcs.u64(),
|
|
112
|
+
remaining_quote_debt: bcs.u64(),
|
|
113
|
+
base_pyth_price: bcs.u64(),
|
|
114
|
+
base_pyth_decimals: bcs.u8(),
|
|
115
|
+
quote_pyth_price: bcs.u64(),
|
|
116
|
+
quote_pyth_decimals: bcs.u8(),
|
|
117
|
+
timestamp: bcs.u64(),
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
export interface AddConditionalOrderArguments {
|
|
121
|
+
self: RawTransactionArgument<string>;
|
|
122
|
+
pool: RawTransactionArgument<string>;
|
|
123
|
+
basePriceInfoObject: RawTransactionArgument<string>;
|
|
124
|
+
quotePriceInfoObject: RawTransactionArgument<string>;
|
|
125
|
+
registry: RawTransactionArgument<string>;
|
|
126
|
+
conditionalOrderId: RawTransactionArgument<number | bigint>;
|
|
127
|
+
condition: TransactionArgument;
|
|
128
|
+
pendingOrder: TransactionArgument;
|
|
129
|
+
}
|
|
130
|
+
export interface AddConditionalOrderOptions {
|
|
131
|
+
package?: string;
|
|
132
|
+
arguments:
|
|
133
|
+
| AddConditionalOrderArguments
|
|
134
|
+
| [
|
|
135
|
+
self: RawTransactionArgument<string>,
|
|
136
|
+
pool: RawTransactionArgument<string>,
|
|
137
|
+
basePriceInfoObject: RawTransactionArgument<string>,
|
|
138
|
+
quotePriceInfoObject: RawTransactionArgument<string>,
|
|
139
|
+
registry: RawTransactionArgument<string>,
|
|
140
|
+
conditionalOrderId: RawTransactionArgument<number | bigint>,
|
|
141
|
+
condition: TransactionArgument,
|
|
142
|
+
pendingOrder: TransactionArgument,
|
|
143
|
+
];
|
|
144
|
+
typeArguments: [string, string];
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Add a conditional order (take-profit / stop-loss). Specifies the condition under
|
|
148
|
+
* which it triggers and the pending order to place when it does.
|
|
149
|
+
*
|
|
150
|
+
* Lifetime: the conditional order itself is never clamped — it rests in the queue
|
|
151
|
+
* until it triggers or is cancelled. A _market_ pending order
|
|
152
|
+
* (`tpsl::new_pending_market_order`) has no expiry, so it is the "until cancelled"
|
|
153
|
+
* stop: it waits indefinitely and, when triggered, fires and deleverages via
|
|
154
|
+
* `execute_conditional_orders_v3` (so it can protect even in the danger band). A
|
|
155
|
+
* _limit_ pending order is intentionally transient — when it triggers, the resting
|
|
156
|
+
* order it places is clamped to `max_order_ttl_ms` (default 3 days) by
|
|
157
|
+
* `clamp_expire_timestamp`, the same stale-price guard as any margin limit order.
|
|
158
|
+
* For a permanent stop, use a market pending order.
|
|
159
|
+
*/
|
|
160
|
+
export function addConditionalOrder(options: AddConditionalOrderOptions) {
|
|
161
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
162
|
+
const argumentsTypes = [
|
|
163
|
+
null,
|
|
164
|
+
null,
|
|
165
|
+
null,
|
|
166
|
+
null,
|
|
167
|
+
null,
|
|
168
|
+
'u64',
|
|
169
|
+
null,
|
|
170
|
+
null,
|
|
171
|
+
'0x2::clock::Clock',
|
|
172
|
+
] satisfies (string | null)[];
|
|
173
|
+
const parameterNames = [
|
|
174
|
+
'self',
|
|
175
|
+
'pool',
|
|
176
|
+
'basePriceInfoObject',
|
|
177
|
+
'quotePriceInfoObject',
|
|
178
|
+
'registry',
|
|
179
|
+
'conditionalOrderId',
|
|
180
|
+
'condition',
|
|
181
|
+
'pendingOrder',
|
|
182
|
+
];
|
|
183
|
+
return (tx: Transaction) =>
|
|
184
|
+
tx.moveCall({
|
|
185
|
+
package: packageAddress,
|
|
186
|
+
module: 'margin_manager',
|
|
187
|
+
function: 'add_conditional_order',
|
|
188
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
189
|
+
typeArguments: options.typeArguments,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
export interface CancelAllConditionalOrdersArguments {
|
|
193
|
+
self: RawTransactionArgument<string>;
|
|
194
|
+
}
|
|
195
|
+
export interface CancelAllConditionalOrdersOptions {
|
|
196
|
+
package?: string;
|
|
197
|
+
arguments: CancelAllConditionalOrdersArguments | [self: RawTransactionArgument<string>];
|
|
198
|
+
typeArguments: [string, string];
|
|
199
|
+
}
|
|
200
|
+
/** Cancel all conditional orders. */
|
|
201
|
+
export function cancelAllConditionalOrders(options: CancelAllConditionalOrdersOptions) {
|
|
202
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
203
|
+
const argumentsTypes = [null, '0x2::clock::Clock'] satisfies (string | null)[];
|
|
204
|
+
const parameterNames = ['self'];
|
|
205
|
+
return (tx: Transaction) =>
|
|
206
|
+
tx.moveCall({
|
|
207
|
+
package: packageAddress,
|
|
208
|
+
module: 'margin_manager',
|
|
209
|
+
function: 'cancel_all_conditional_orders',
|
|
210
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
211
|
+
typeArguments: options.typeArguments,
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
export interface CancelConditionalOrderArguments {
|
|
215
|
+
self: RawTransactionArgument<string>;
|
|
216
|
+
conditionalOrderId: RawTransactionArgument<number | bigint>;
|
|
217
|
+
}
|
|
218
|
+
export interface CancelConditionalOrderOptions {
|
|
219
|
+
package?: string;
|
|
220
|
+
arguments:
|
|
221
|
+
| CancelConditionalOrderArguments
|
|
222
|
+
| [
|
|
223
|
+
self: RawTransactionArgument<string>,
|
|
224
|
+
conditionalOrderId: RawTransactionArgument<number | bigint>,
|
|
225
|
+
];
|
|
226
|
+
typeArguments: [string, string];
|
|
227
|
+
}
|
|
228
|
+
/** Cancel a conditional order. */
|
|
229
|
+
export function cancelConditionalOrder(options: CancelConditionalOrderOptions) {
|
|
230
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
231
|
+
const argumentsTypes = [null, 'u64', '0x2::clock::Clock'] satisfies (string | null)[];
|
|
232
|
+
const parameterNames = ['self', 'conditionalOrderId'];
|
|
233
|
+
return (tx: Transaction) =>
|
|
234
|
+
tx.moveCall({
|
|
235
|
+
package: packageAddress,
|
|
236
|
+
module: 'margin_manager',
|
|
237
|
+
function: 'cancel_conditional_order',
|
|
238
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
239
|
+
typeArguments: options.typeArguments,
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
export interface ExecuteConditionalOrdersArguments {
|
|
243
|
+
Self: RawTransactionArgument<string>;
|
|
244
|
+
Pool: RawTransactionArgument<string>;
|
|
245
|
+
BasePriceInfoObject: RawTransactionArgument<string>;
|
|
246
|
+
QuotePriceInfoObject: RawTransactionArgument<string>;
|
|
247
|
+
Registry: RawTransactionArgument<string>;
|
|
248
|
+
MaxOrdersToExecute: RawTransactionArgument<number | bigint>;
|
|
249
|
+
}
|
|
250
|
+
export interface ExecuteConditionalOrdersOptions {
|
|
251
|
+
package?: string;
|
|
252
|
+
arguments:
|
|
253
|
+
| ExecuteConditionalOrdersArguments
|
|
254
|
+
| [
|
|
255
|
+
Self: RawTransactionArgument<string>,
|
|
256
|
+
Pool: RawTransactionArgument<string>,
|
|
257
|
+
BasePriceInfoObject: RawTransactionArgument<string>,
|
|
258
|
+
QuotePriceInfoObject: RawTransactionArgument<string>,
|
|
259
|
+
Registry: RawTransactionArgument<string>,
|
|
260
|
+
MaxOrdersToExecute: RawTransactionArgument<number | bigint>,
|
|
261
|
+
];
|
|
262
|
+
typeArguments: [string, string];
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* DEPRECATED. Use `execute_conditional_orders_v2`.
|
|
266
|
+
*
|
|
267
|
+
* The v1 entry preserves its on-chain signature so the v5 package upgrade
|
|
268
|
+
* type-checks against existing dependents, but the body is replaced with
|
|
269
|
+
* `abort EDeprecatedUseV2`. The v2 variant adds margin-pool + oracle params and
|
|
270
|
+
* enforces a post-fill `risk_ratio >= min_borrow_risk_ratio` invariant inside
|
|
271
|
+
* `process_collected_orders_v2`.
|
|
272
|
+
*/
|
|
273
|
+
export function executeConditionalOrders(options: ExecuteConditionalOrdersOptions) {
|
|
274
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
275
|
+
const argumentsTypes = [null, null, null, null, null, 'u64', '0x2::clock::Clock'] satisfies (
|
|
276
|
+
| string
|
|
277
|
+
| null
|
|
278
|
+
)[];
|
|
279
|
+
const parameterNames = [
|
|
280
|
+
'Self',
|
|
281
|
+
'Pool',
|
|
282
|
+
'BasePriceInfoObject',
|
|
283
|
+
'QuotePriceInfoObject',
|
|
284
|
+
'Registry',
|
|
285
|
+
'MaxOrdersToExecute',
|
|
286
|
+
];
|
|
287
|
+
return (tx: Transaction) =>
|
|
288
|
+
tx.moveCall({
|
|
289
|
+
package: packageAddress,
|
|
290
|
+
module: 'margin_manager',
|
|
291
|
+
function: 'execute_conditional_orders',
|
|
292
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
293
|
+
typeArguments: options.typeArguments,
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
export interface ExecuteConditionalOrdersV2Arguments {
|
|
297
|
+
self: RawTransactionArgument<string>;
|
|
298
|
+
pool: RawTransactionArgument<string>;
|
|
299
|
+
baseMarginPool: RawTransactionArgument<string>;
|
|
300
|
+
quoteMarginPool: RawTransactionArgument<string>;
|
|
301
|
+
basePriceInfoObject: RawTransactionArgument<string>;
|
|
302
|
+
quotePriceInfoObject: RawTransactionArgument<string>;
|
|
303
|
+
registry: RawTransactionArgument<string>;
|
|
304
|
+
maxOrdersToExecute: RawTransactionArgument<number | bigint>;
|
|
305
|
+
}
|
|
306
|
+
export interface ExecuteConditionalOrdersV2Options {
|
|
307
|
+
package?: string;
|
|
308
|
+
arguments:
|
|
309
|
+
| ExecuteConditionalOrdersV2Arguments
|
|
310
|
+
| [
|
|
311
|
+
self: RawTransactionArgument<string>,
|
|
312
|
+
pool: RawTransactionArgument<string>,
|
|
313
|
+
baseMarginPool: RawTransactionArgument<string>,
|
|
314
|
+
quoteMarginPool: RawTransactionArgument<string>,
|
|
315
|
+
basePriceInfoObject: RawTransactionArgument<string>,
|
|
316
|
+
quotePriceInfoObject: RawTransactionArgument<string>,
|
|
317
|
+
registry: RawTransactionArgument<string>,
|
|
318
|
+
maxOrdersToExecute: RawTransactionArgument<number | bigint>,
|
|
319
|
+
];
|
|
320
|
+
typeArguments: [string, string];
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Execute conditional orders and return the order infos. This is a permissionless
|
|
324
|
+
* function that can be called by anyone.
|
|
325
|
+
*
|
|
326
|
+
* v2 adds `base_margin_pool` + `quote_margin_pool` parameters and enforces a
|
|
327
|
+
* post-fill `risk_ratio >= min_borrow_risk_ratio` invariant inside the inner loop.
|
|
328
|
+
* If any single triggered fill would breach that floor, the entire txn aborts — no
|
|
329
|
+
* partial-state landing.
|
|
330
|
+
*/
|
|
331
|
+
export function executeConditionalOrdersV2(options: ExecuteConditionalOrdersV2Options) {
|
|
332
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
333
|
+
const argumentsTypes = [
|
|
334
|
+
null,
|
|
335
|
+
null,
|
|
336
|
+
null,
|
|
337
|
+
null,
|
|
338
|
+
null,
|
|
339
|
+
null,
|
|
340
|
+
null,
|
|
341
|
+
'u64',
|
|
342
|
+
'0x2::clock::Clock',
|
|
343
|
+
] satisfies (string | null)[];
|
|
344
|
+
const parameterNames = [
|
|
345
|
+
'self',
|
|
346
|
+
'pool',
|
|
347
|
+
'baseMarginPool',
|
|
348
|
+
'quoteMarginPool',
|
|
349
|
+
'basePriceInfoObject',
|
|
350
|
+
'quotePriceInfoObject',
|
|
351
|
+
'registry',
|
|
352
|
+
'maxOrdersToExecute',
|
|
353
|
+
];
|
|
354
|
+
return (tx: Transaction) =>
|
|
355
|
+
tx.moveCall({
|
|
356
|
+
package: packageAddress,
|
|
357
|
+
module: 'margin_manager',
|
|
358
|
+
function: 'execute_conditional_orders_v2',
|
|
359
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
360
|
+
typeArguments: options.typeArguments,
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
export interface ExecuteConditionalOrdersV3Arguments {
|
|
364
|
+
self: RawTransactionArgument<string>;
|
|
365
|
+
pool: RawTransactionArgument<string>;
|
|
366
|
+
baseMarginPool: RawTransactionArgument<string>;
|
|
367
|
+
quoteMarginPool: RawTransactionArgument<string>;
|
|
368
|
+
basePriceInfoObject: RawTransactionArgument<string>;
|
|
369
|
+
quotePriceInfoObject: RawTransactionArgument<string>;
|
|
370
|
+
registry: RawTransactionArgument<string>;
|
|
371
|
+
maxOrdersToExecute: RawTransactionArgument<number | bigint>;
|
|
372
|
+
}
|
|
373
|
+
export interface ExecuteConditionalOrdersV3Options {
|
|
374
|
+
package?: string;
|
|
375
|
+
arguments:
|
|
376
|
+
| ExecuteConditionalOrdersV3Arguments
|
|
377
|
+
| [
|
|
378
|
+
self: RawTransactionArgument<string>,
|
|
379
|
+
pool: RawTransactionArgument<string>,
|
|
380
|
+
baseMarginPool: RawTransactionArgument<string>,
|
|
381
|
+
quoteMarginPool: RawTransactionArgument<string>,
|
|
382
|
+
basePriceInfoObject: RawTransactionArgument<string>,
|
|
383
|
+
quotePriceInfoObject: RawTransactionArgument<string>,
|
|
384
|
+
registry: RawTransactionArgument<string>,
|
|
385
|
+
maxOrdersToExecute: RawTransactionArgument<number | bigint>,
|
|
386
|
+
];
|
|
387
|
+
typeArguments: [string, string];
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Execute conditional orders, deleveraging on each market-type fill.
|
|
391
|
+
* Permissionless, like `execute_conditional_orders_v2`, with the same trigger and
|
|
392
|
+
* cancellation handling — but takes the margin pools as `&mut` and repays the loan
|
|
393
|
+
* with the market proceeds before gating on the net (post-repay) `risk_ratio`
|
|
394
|
+
* being at least the pre-fill ratio.
|
|
395
|
+
*
|
|
396
|
+
* This is what lets a stop-loss fire in the `liquidation..min_borrow` danger band:
|
|
397
|
+
* a swap alone only lowers the oracle-valued ratio (so the v2 borrow-floor gate
|
|
398
|
+
* rejects it), while repaying actually improves it. If a single triggered fill
|
|
399
|
+
* would worsen net solvency the whole txn aborts — no partial-state landing.
|
|
400
|
+
*/
|
|
401
|
+
export function executeConditionalOrdersV3(options: ExecuteConditionalOrdersV3Options) {
|
|
402
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
403
|
+
const argumentsTypes = [
|
|
404
|
+
null,
|
|
405
|
+
null,
|
|
406
|
+
null,
|
|
407
|
+
null,
|
|
408
|
+
null,
|
|
409
|
+
null,
|
|
410
|
+
null,
|
|
411
|
+
'u64',
|
|
412
|
+
'0x2::clock::Clock',
|
|
413
|
+
] satisfies (string | null)[];
|
|
414
|
+
const parameterNames = [
|
|
415
|
+
'self',
|
|
416
|
+
'pool',
|
|
417
|
+
'baseMarginPool',
|
|
418
|
+
'quoteMarginPool',
|
|
419
|
+
'basePriceInfoObject',
|
|
420
|
+
'quotePriceInfoObject',
|
|
421
|
+
'registry',
|
|
422
|
+
'maxOrdersToExecute',
|
|
423
|
+
];
|
|
424
|
+
return (tx: Transaction) =>
|
|
425
|
+
tx.moveCall({
|
|
426
|
+
package: packageAddress,
|
|
427
|
+
module: 'margin_manager',
|
|
428
|
+
function: 'execute_conditional_orders_v3',
|
|
429
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
430
|
+
typeArguments: options.typeArguments,
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
export interface NewArguments {
|
|
434
|
+
pool: RawTransactionArgument<string>;
|
|
435
|
+
deepbookRegistry: RawTransactionArgument<string>;
|
|
436
|
+
marginRegistry: RawTransactionArgument<string>;
|
|
437
|
+
}
|
|
438
|
+
export interface NewOptions {
|
|
439
|
+
package?: string;
|
|
440
|
+
arguments:
|
|
441
|
+
| NewArguments
|
|
442
|
+
| [
|
|
443
|
+
pool: RawTransactionArgument<string>,
|
|
444
|
+
deepbookRegistry: RawTransactionArgument<string>,
|
|
445
|
+
marginRegistry: RawTransactionArgument<string>,
|
|
446
|
+
];
|
|
447
|
+
typeArguments: [string, string];
|
|
448
|
+
}
|
|
449
|
+
/** Creates a new margin manager and shares it. */
|
|
450
|
+
export function _new(options: NewOptions) {
|
|
451
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
452
|
+
const argumentsTypes = [null, null, null, '0x2::clock::Clock'] satisfies (string | null)[];
|
|
453
|
+
const parameterNames = ['pool', 'deepbookRegistry', 'marginRegistry'];
|
|
454
|
+
return (tx: Transaction) =>
|
|
455
|
+
tx.moveCall({
|
|
456
|
+
package: packageAddress,
|
|
457
|
+
module: 'margin_manager',
|
|
458
|
+
function: 'new',
|
|
459
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
460
|
+
typeArguments: options.typeArguments,
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
export interface NewWithInitializerArguments {
|
|
464
|
+
pool: RawTransactionArgument<string>;
|
|
465
|
+
deepbookRegistry: RawTransactionArgument<string>;
|
|
466
|
+
marginRegistry: RawTransactionArgument<string>;
|
|
467
|
+
}
|
|
468
|
+
export interface NewWithInitializerOptions {
|
|
469
|
+
package?: string;
|
|
470
|
+
arguments:
|
|
471
|
+
| NewWithInitializerArguments
|
|
472
|
+
| [
|
|
473
|
+
pool: RawTransactionArgument<string>,
|
|
474
|
+
deepbookRegistry: RawTransactionArgument<string>,
|
|
475
|
+
marginRegistry: RawTransactionArgument<string>,
|
|
476
|
+
];
|
|
477
|
+
typeArguments: [string, string];
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Creates a new margin manager and returns it along with an initializer. The
|
|
481
|
+
* initializer is used to ensure the margin manager is shared after creation.
|
|
482
|
+
*/
|
|
483
|
+
export function newWithInitializer(options: NewWithInitializerOptions) {
|
|
484
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
485
|
+
const argumentsTypes = [null, null, null, '0x2::clock::Clock'] satisfies (string | null)[];
|
|
486
|
+
const parameterNames = ['pool', 'deepbookRegistry', 'marginRegistry'];
|
|
487
|
+
return (tx: Transaction) =>
|
|
488
|
+
tx.moveCall({
|
|
489
|
+
package: packageAddress,
|
|
490
|
+
module: 'margin_manager',
|
|
491
|
+
function: 'new_with_initializer',
|
|
492
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
493
|
+
typeArguments: options.typeArguments,
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
export interface ShareArguments {
|
|
497
|
+
manager: RawTransactionArgument<string>;
|
|
498
|
+
initializer: TransactionArgument;
|
|
499
|
+
}
|
|
500
|
+
export interface ShareOptions {
|
|
501
|
+
package?: string;
|
|
502
|
+
arguments:
|
|
503
|
+
| ShareArguments
|
|
504
|
+
| [manager: RawTransactionArgument<string>, initializer: TransactionArgument];
|
|
505
|
+
typeArguments: [string, string];
|
|
506
|
+
}
|
|
507
|
+
/** Shares the margin manager. The initializer is dropped in the process. */
|
|
508
|
+
export function share(options: ShareOptions) {
|
|
509
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
510
|
+
const argumentsTypes = [null, null] satisfies (string | null)[];
|
|
511
|
+
const parameterNames = ['manager', 'initializer'];
|
|
512
|
+
return (tx: Transaction) =>
|
|
513
|
+
tx.moveCall({
|
|
514
|
+
package: packageAddress,
|
|
515
|
+
module: 'margin_manager',
|
|
516
|
+
function: 'share',
|
|
517
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
518
|
+
typeArguments: options.typeArguments,
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
export interface RegisterMarginManagerArguments {
|
|
522
|
+
self: RawTransactionArgument<string>;
|
|
523
|
+
marginRegistry: RawTransactionArgument<string>;
|
|
524
|
+
}
|
|
525
|
+
export interface RegisterMarginManagerOptions {
|
|
526
|
+
package?: string;
|
|
527
|
+
arguments:
|
|
528
|
+
| RegisterMarginManagerArguments
|
|
529
|
+
| [self: RawTransactionArgument<string>, marginRegistry: RawTransactionArgument<string>];
|
|
530
|
+
typeArguments: [string, string];
|
|
531
|
+
}
|
|
532
|
+
/** Register the margin manager back to the margin registry. */
|
|
533
|
+
export function registerMarginManager(options: RegisterMarginManagerOptions) {
|
|
534
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
535
|
+
const argumentsTypes = [null, null] satisfies (string | null)[];
|
|
536
|
+
const parameterNames = ['self', 'marginRegistry'];
|
|
537
|
+
return (tx: Transaction) =>
|
|
538
|
+
tx.moveCall({
|
|
539
|
+
package: packageAddress,
|
|
540
|
+
module: 'margin_manager',
|
|
541
|
+
function: 'register_margin_manager',
|
|
542
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
543
|
+
typeArguments: options.typeArguments,
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
export interface UnregisterMarginManagerArguments {
|
|
547
|
+
self: RawTransactionArgument<string>;
|
|
548
|
+
marginRegistry: RawTransactionArgument<string>;
|
|
549
|
+
}
|
|
550
|
+
export interface UnregisterMarginManagerOptions {
|
|
551
|
+
package?: string;
|
|
552
|
+
arguments:
|
|
553
|
+
| UnregisterMarginManagerArguments
|
|
554
|
+
| [self: RawTransactionArgument<string>, marginRegistry: RawTransactionArgument<string>];
|
|
555
|
+
typeArguments: [string, string];
|
|
556
|
+
}
|
|
557
|
+
/** Unregister the margin manager from the margin registry. */
|
|
558
|
+
export function unregisterMarginManager(options: UnregisterMarginManagerOptions) {
|
|
559
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
560
|
+
const argumentsTypes = [null, null] satisfies (string | null)[];
|
|
561
|
+
const parameterNames = ['self', 'marginRegistry'];
|
|
562
|
+
return (tx: Transaction) =>
|
|
563
|
+
tx.moveCall({
|
|
564
|
+
package: packageAddress,
|
|
565
|
+
module: 'margin_manager',
|
|
566
|
+
function: 'unregister_margin_manager',
|
|
567
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
568
|
+
typeArguments: options.typeArguments,
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
export interface SetMarginManagerReferralArguments {
|
|
572
|
+
self: RawTransactionArgument<string>;
|
|
573
|
+
referralCap: RawTransactionArgument<string>;
|
|
574
|
+
}
|
|
575
|
+
export interface SetMarginManagerReferralOptions {
|
|
576
|
+
package?: string;
|
|
577
|
+
arguments:
|
|
578
|
+
| SetMarginManagerReferralArguments
|
|
579
|
+
| [self: RawTransactionArgument<string>, referralCap: RawTransactionArgument<string>];
|
|
580
|
+
typeArguments: [string, string];
|
|
581
|
+
}
|
|
582
|
+
/** Set the referral for the margin manager. */
|
|
583
|
+
export function setMarginManagerReferral(options: SetMarginManagerReferralOptions) {
|
|
584
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
585
|
+
const argumentsTypes = [null, null] satisfies (string | null)[];
|
|
586
|
+
const parameterNames = ['self', 'referralCap'];
|
|
587
|
+
return (tx: Transaction) =>
|
|
588
|
+
tx.moveCall({
|
|
589
|
+
package: packageAddress,
|
|
590
|
+
module: 'margin_manager',
|
|
591
|
+
function: 'set_margin_manager_referral',
|
|
592
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
593
|
+
typeArguments: options.typeArguments,
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
export interface UnsetMarginManagerReferralArguments {
|
|
597
|
+
self: RawTransactionArgument<string>;
|
|
598
|
+
poolId: RawTransactionArgument<string>;
|
|
599
|
+
}
|
|
600
|
+
export interface UnsetMarginManagerReferralOptions {
|
|
601
|
+
package?: string;
|
|
602
|
+
arguments:
|
|
603
|
+
| UnsetMarginManagerReferralArguments
|
|
604
|
+
| [self: RawTransactionArgument<string>, poolId: RawTransactionArgument<string>];
|
|
605
|
+
typeArguments: [string, string];
|
|
606
|
+
}
|
|
607
|
+
/** Unset the referral for the margin manager. */
|
|
608
|
+
export function unsetMarginManagerReferral(options: UnsetMarginManagerReferralOptions) {
|
|
609
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
610
|
+
const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[];
|
|
611
|
+
const parameterNames = ['self', 'poolId'];
|
|
612
|
+
return (tx: Transaction) =>
|
|
613
|
+
tx.moveCall({
|
|
614
|
+
package: packageAddress,
|
|
615
|
+
module: 'margin_manager',
|
|
616
|
+
function: 'unset_margin_manager_referral',
|
|
617
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
618
|
+
typeArguments: options.typeArguments,
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
export interface DepositArguments {
|
|
622
|
+
self: RawTransactionArgument<string>;
|
|
623
|
+
registry: RawTransactionArgument<string>;
|
|
624
|
+
baseOracle: RawTransactionArgument<string>;
|
|
625
|
+
quoteOracle: RawTransactionArgument<string>;
|
|
626
|
+
coin: RawTransactionArgument<string>;
|
|
627
|
+
}
|
|
628
|
+
export interface DepositOptions {
|
|
629
|
+
package?: string;
|
|
630
|
+
arguments:
|
|
631
|
+
| DepositArguments
|
|
632
|
+
| [
|
|
633
|
+
self: RawTransactionArgument<string>,
|
|
634
|
+
registry: RawTransactionArgument<string>,
|
|
635
|
+
baseOracle: RawTransactionArgument<string>,
|
|
636
|
+
quoteOracle: RawTransactionArgument<string>,
|
|
637
|
+
coin: RawTransactionArgument<string>,
|
|
638
|
+
];
|
|
639
|
+
typeArguments: [string, string, string];
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Deposit a coin into the margin manager. The coin must be of the same type as
|
|
643
|
+
* either the base, quote, or DEEP.
|
|
644
|
+
*/
|
|
645
|
+
export function deposit(options: DepositOptions) {
|
|
646
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
647
|
+
const argumentsTypes = [null, null, null, null, null, '0x2::clock::Clock'] satisfies (
|
|
648
|
+
| string
|
|
649
|
+
| null
|
|
650
|
+
)[];
|
|
651
|
+
const parameterNames = ['self', 'registry', 'baseOracle', 'quoteOracle', 'coin'];
|
|
652
|
+
return (tx: Transaction) =>
|
|
653
|
+
tx.moveCall({
|
|
654
|
+
package: packageAddress,
|
|
655
|
+
module: 'margin_manager',
|
|
656
|
+
function: 'deposit',
|
|
657
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
658
|
+
typeArguments: options.typeArguments,
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
export interface WithdrawArguments {
|
|
662
|
+
self: RawTransactionArgument<string>;
|
|
663
|
+
registry: RawTransactionArgument<string>;
|
|
664
|
+
baseMarginPool: RawTransactionArgument<string>;
|
|
665
|
+
quoteMarginPool: RawTransactionArgument<string>;
|
|
666
|
+
baseOracle: RawTransactionArgument<string>;
|
|
667
|
+
quoteOracle: RawTransactionArgument<string>;
|
|
668
|
+
pool: RawTransactionArgument<string>;
|
|
669
|
+
withdrawAmount: RawTransactionArgument<number | bigint>;
|
|
670
|
+
}
|
|
671
|
+
export interface WithdrawOptions {
|
|
672
|
+
package?: string;
|
|
673
|
+
arguments:
|
|
674
|
+
| WithdrawArguments
|
|
675
|
+
| [
|
|
676
|
+
self: RawTransactionArgument<string>,
|
|
677
|
+
registry: RawTransactionArgument<string>,
|
|
678
|
+
baseMarginPool: RawTransactionArgument<string>,
|
|
679
|
+
quoteMarginPool: RawTransactionArgument<string>,
|
|
680
|
+
baseOracle: RawTransactionArgument<string>,
|
|
681
|
+
quoteOracle: RawTransactionArgument<string>,
|
|
682
|
+
pool: RawTransactionArgument<string>,
|
|
683
|
+
withdrawAmount: RawTransactionArgument<number | bigint>,
|
|
684
|
+
];
|
|
685
|
+
typeArguments: [string, string, string];
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* Withdraw a specified amount of an asset from the margin manager. The asset must
|
|
689
|
+
* be of the same type as either the base, quote, or DEEP. The withdrawal is
|
|
690
|
+
* subject to the risk ratio limit.
|
|
691
|
+
*/
|
|
692
|
+
export function withdraw(options: WithdrawOptions) {
|
|
693
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
694
|
+
const argumentsTypes = [
|
|
695
|
+
null,
|
|
696
|
+
null,
|
|
697
|
+
null,
|
|
698
|
+
null,
|
|
699
|
+
null,
|
|
700
|
+
null,
|
|
701
|
+
null,
|
|
702
|
+
'u64',
|
|
703
|
+
'0x2::clock::Clock',
|
|
704
|
+
] satisfies (string | null)[];
|
|
705
|
+
const parameterNames = [
|
|
706
|
+
'self',
|
|
707
|
+
'registry',
|
|
708
|
+
'baseMarginPool',
|
|
709
|
+
'quoteMarginPool',
|
|
710
|
+
'baseOracle',
|
|
711
|
+
'quoteOracle',
|
|
712
|
+
'pool',
|
|
713
|
+
'withdrawAmount',
|
|
714
|
+
];
|
|
715
|
+
return (tx: Transaction) =>
|
|
716
|
+
tx.moveCall({
|
|
717
|
+
package: packageAddress,
|
|
718
|
+
module: 'margin_manager',
|
|
719
|
+
function: 'withdraw',
|
|
720
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
721
|
+
typeArguments: options.typeArguments,
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
export interface BorrowBaseArguments {
|
|
725
|
+
self: RawTransactionArgument<string>;
|
|
726
|
+
registry: RawTransactionArgument<string>;
|
|
727
|
+
baseMarginPool: RawTransactionArgument<string>;
|
|
728
|
+
baseOracle: RawTransactionArgument<string>;
|
|
729
|
+
quoteOracle: RawTransactionArgument<string>;
|
|
730
|
+
pool: RawTransactionArgument<string>;
|
|
731
|
+
loanAmount: RawTransactionArgument<number | bigint>;
|
|
732
|
+
}
|
|
733
|
+
export interface BorrowBaseOptions {
|
|
734
|
+
package?: string;
|
|
735
|
+
arguments:
|
|
736
|
+
| BorrowBaseArguments
|
|
737
|
+
| [
|
|
738
|
+
self: RawTransactionArgument<string>,
|
|
739
|
+
registry: RawTransactionArgument<string>,
|
|
740
|
+
baseMarginPool: RawTransactionArgument<string>,
|
|
741
|
+
baseOracle: RawTransactionArgument<string>,
|
|
742
|
+
quoteOracle: RawTransactionArgument<string>,
|
|
743
|
+
pool: RawTransactionArgument<string>,
|
|
744
|
+
loanAmount: RawTransactionArgument<number | bigint>,
|
|
745
|
+
];
|
|
746
|
+
typeArguments: [string, string];
|
|
747
|
+
}
|
|
748
|
+
/** Borrow the base asset using the margin manager. */
|
|
749
|
+
export function borrowBase(options: BorrowBaseOptions) {
|
|
750
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
751
|
+
const argumentsTypes = [
|
|
752
|
+
null,
|
|
753
|
+
null,
|
|
754
|
+
null,
|
|
755
|
+
null,
|
|
756
|
+
null,
|
|
757
|
+
null,
|
|
758
|
+
'u64',
|
|
759
|
+
'0x2::clock::Clock',
|
|
760
|
+
] satisfies (string | null)[];
|
|
761
|
+
const parameterNames = [
|
|
762
|
+
'self',
|
|
763
|
+
'registry',
|
|
764
|
+
'baseMarginPool',
|
|
765
|
+
'baseOracle',
|
|
766
|
+
'quoteOracle',
|
|
767
|
+
'pool',
|
|
768
|
+
'loanAmount',
|
|
769
|
+
];
|
|
770
|
+
return (tx: Transaction) =>
|
|
771
|
+
tx.moveCall({
|
|
772
|
+
package: packageAddress,
|
|
773
|
+
module: 'margin_manager',
|
|
774
|
+
function: 'borrow_base',
|
|
775
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
776
|
+
typeArguments: options.typeArguments,
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
export interface BorrowQuoteArguments {
|
|
780
|
+
self: RawTransactionArgument<string>;
|
|
781
|
+
registry: RawTransactionArgument<string>;
|
|
782
|
+
quoteMarginPool: RawTransactionArgument<string>;
|
|
783
|
+
baseOracle: RawTransactionArgument<string>;
|
|
784
|
+
quoteOracle: RawTransactionArgument<string>;
|
|
785
|
+
pool: RawTransactionArgument<string>;
|
|
786
|
+
loanAmount: RawTransactionArgument<number | bigint>;
|
|
787
|
+
}
|
|
788
|
+
export interface BorrowQuoteOptions {
|
|
789
|
+
package?: string;
|
|
790
|
+
arguments:
|
|
791
|
+
| BorrowQuoteArguments
|
|
792
|
+
| [
|
|
793
|
+
self: RawTransactionArgument<string>,
|
|
794
|
+
registry: RawTransactionArgument<string>,
|
|
795
|
+
quoteMarginPool: RawTransactionArgument<string>,
|
|
796
|
+
baseOracle: RawTransactionArgument<string>,
|
|
797
|
+
quoteOracle: RawTransactionArgument<string>,
|
|
798
|
+
pool: RawTransactionArgument<string>,
|
|
799
|
+
loanAmount: RawTransactionArgument<number | bigint>,
|
|
800
|
+
];
|
|
801
|
+
typeArguments: [string, string];
|
|
802
|
+
}
|
|
803
|
+
/** Borrow the quote asset using the margin manager. */
|
|
804
|
+
export function borrowQuote(options: BorrowQuoteOptions) {
|
|
805
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
806
|
+
const argumentsTypes = [
|
|
807
|
+
null,
|
|
808
|
+
null,
|
|
809
|
+
null,
|
|
810
|
+
null,
|
|
811
|
+
null,
|
|
812
|
+
null,
|
|
813
|
+
'u64',
|
|
814
|
+
'0x2::clock::Clock',
|
|
815
|
+
] satisfies (string | null)[];
|
|
816
|
+
const parameterNames = [
|
|
817
|
+
'self',
|
|
818
|
+
'registry',
|
|
819
|
+
'quoteMarginPool',
|
|
820
|
+
'baseOracle',
|
|
821
|
+
'quoteOracle',
|
|
822
|
+
'pool',
|
|
823
|
+
'loanAmount',
|
|
824
|
+
];
|
|
825
|
+
return (tx: Transaction) =>
|
|
826
|
+
tx.moveCall({
|
|
827
|
+
package: packageAddress,
|
|
828
|
+
module: 'margin_manager',
|
|
829
|
+
function: 'borrow_quote',
|
|
830
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
831
|
+
typeArguments: options.typeArguments,
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
export interface RepayBaseArguments {
|
|
835
|
+
self: RawTransactionArgument<string>;
|
|
836
|
+
registry: RawTransactionArgument<string>;
|
|
837
|
+
marginPool: RawTransactionArgument<string>;
|
|
838
|
+
amount: RawTransactionArgument<number | bigint | null>;
|
|
839
|
+
}
|
|
840
|
+
export interface RepayBaseOptions {
|
|
841
|
+
package?: string;
|
|
842
|
+
arguments:
|
|
843
|
+
| RepayBaseArguments
|
|
844
|
+
| [
|
|
845
|
+
self: RawTransactionArgument<string>,
|
|
846
|
+
registry: RawTransactionArgument<string>,
|
|
847
|
+
marginPool: RawTransactionArgument<string>,
|
|
848
|
+
amount: RawTransactionArgument<number | bigint | null>,
|
|
849
|
+
];
|
|
850
|
+
typeArguments: [string, string];
|
|
851
|
+
}
|
|
852
|
+
/**
|
|
853
|
+
* Repay the base asset loan using the margin manager. Returns the total amount
|
|
854
|
+
* repaid
|
|
855
|
+
*/
|
|
856
|
+
export function repayBase(options: RepayBaseOptions) {
|
|
857
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
858
|
+
const argumentsTypes = [
|
|
859
|
+
null,
|
|
860
|
+
null,
|
|
861
|
+
null,
|
|
862
|
+
'0x1::option::Option<u64>',
|
|
863
|
+
'0x2::clock::Clock',
|
|
864
|
+
] satisfies (string | null)[];
|
|
865
|
+
const parameterNames = ['self', 'registry', 'marginPool', 'amount'];
|
|
866
|
+
return (tx: Transaction) =>
|
|
867
|
+
tx.moveCall({
|
|
868
|
+
package: packageAddress,
|
|
869
|
+
module: 'margin_manager',
|
|
870
|
+
function: 'repay_base',
|
|
871
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
872
|
+
typeArguments: options.typeArguments,
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
export interface RepayQuoteArguments {
|
|
876
|
+
self: RawTransactionArgument<string>;
|
|
877
|
+
registry: RawTransactionArgument<string>;
|
|
878
|
+
marginPool: RawTransactionArgument<string>;
|
|
879
|
+
amount: RawTransactionArgument<number | bigint | null>;
|
|
880
|
+
}
|
|
881
|
+
export interface RepayQuoteOptions {
|
|
882
|
+
package?: string;
|
|
883
|
+
arguments:
|
|
884
|
+
| RepayQuoteArguments
|
|
885
|
+
| [
|
|
886
|
+
self: RawTransactionArgument<string>,
|
|
887
|
+
registry: RawTransactionArgument<string>,
|
|
888
|
+
marginPool: RawTransactionArgument<string>,
|
|
889
|
+
amount: RawTransactionArgument<number | bigint | null>,
|
|
890
|
+
];
|
|
891
|
+
typeArguments: [string, string];
|
|
892
|
+
}
|
|
893
|
+
/**
|
|
894
|
+
* Repay the quote asset loan using the margin manager. Returns the total amount
|
|
895
|
+
* repaid
|
|
896
|
+
*/
|
|
897
|
+
export function repayQuote(options: RepayQuoteOptions) {
|
|
898
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
899
|
+
const argumentsTypes = [
|
|
900
|
+
null,
|
|
901
|
+
null,
|
|
902
|
+
null,
|
|
903
|
+
'0x1::option::Option<u64>',
|
|
904
|
+
'0x2::clock::Clock',
|
|
905
|
+
] satisfies (string | null)[];
|
|
906
|
+
const parameterNames = ['self', 'registry', 'marginPool', 'amount'];
|
|
907
|
+
return (tx: Transaction) =>
|
|
908
|
+
tx.moveCall({
|
|
909
|
+
package: packageAddress,
|
|
910
|
+
module: 'margin_manager',
|
|
911
|
+
function: 'repay_quote',
|
|
912
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
913
|
+
typeArguments: options.typeArguments,
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
export interface LiquidateArguments {
|
|
917
|
+
self: RawTransactionArgument<string>;
|
|
918
|
+
registry: RawTransactionArgument<string>;
|
|
919
|
+
baseOracle: RawTransactionArgument<string>;
|
|
920
|
+
quoteOracle: RawTransactionArgument<string>;
|
|
921
|
+
marginPool: RawTransactionArgument<string>;
|
|
922
|
+
pool: RawTransactionArgument<string>;
|
|
923
|
+
repayCoin: RawTransactionArgument<string>;
|
|
924
|
+
}
|
|
925
|
+
export interface LiquidateOptions {
|
|
926
|
+
package?: string;
|
|
927
|
+
arguments:
|
|
928
|
+
| LiquidateArguments
|
|
929
|
+
| [
|
|
930
|
+
self: RawTransactionArgument<string>,
|
|
931
|
+
registry: RawTransactionArgument<string>,
|
|
932
|
+
baseOracle: RawTransactionArgument<string>,
|
|
933
|
+
quoteOracle: RawTransactionArgument<string>,
|
|
934
|
+
marginPool: RawTransactionArgument<string>,
|
|
935
|
+
pool: RawTransactionArgument<string>,
|
|
936
|
+
repayCoin: RawTransactionArgument<string>,
|
|
937
|
+
];
|
|
938
|
+
typeArguments: [string, string, string];
|
|
939
|
+
}
|
|
940
|
+
export function liquidate(options: LiquidateOptions) {
|
|
941
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
942
|
+
const argumentsTypes = [null, null, null, null, null, null, null, '0x2::clock::Clock'] satisfies (
|
|
943
|
+
| string
|
|
944
|
+
| null
|
|
945
|
+
)[];
|
|
946
|
+
const parameterNames = [
|
|
947
|
+
'self',
|
|
948
|
+
'registry',
|
|
949
|
+
'baseOracle',
|
|
950
|
+
'quoteOracle',
|
|
951
|
+
'marginPool',
|
|
952
|
+
'pool',
|
|
953
|
+
'repayCoin',
|
|
954
|
+
];
|
|
955
|
+
return (tx: Transaction) =>
|
|
956
|
+
tx.moveCall({
|
|
957
|
+
package: packageAddress,
|
|
958
|
+
module: 'margin_manager',
|
|
959
|
+
function: 'liquidate',
|
|
960
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
961
|
+
typeArguments: options.typeArguments,
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
export interface RiskRatioArguments {
|
|
965
|
+
self: RawTransactionArgument<string>;
|
|
966
|
+
registry: RawTransactionArgument<string>;
|
|
967
|
+
baseOracle: RawTransactionArgument<string>;
|
|
968
|
+
quoteOracle: RawTransactionArgument<string>;
|
|
969
|
+
pool: RawTransactionArgument<string>;
|
|
970
|
+
baseMarginPool: RawTransactionArgument<string>;
|
|
971
|
+
quoteMarginPool: RawTransactionArgument<string>;
|
|
972
|
+
}
|
|
973
|
+
export interface RiskRatioOptions {
|
|
974
|
+
package?: string;
|
|
975
|
+
arguments:
|
|
976
|
+
| RiskRatioArguments
|
|
977
|
+
| [
|
|
978
|
+
self: RawTransactionArgument<string>,
|
|
979
|
+
registry: RawTransactionArgument<string>,
|
|
980
|
+
baseOracle: RawTransactionArgument<string>,
|
|
981
|
+
quoteOracle: RawTransactionArgument<string>,
|
|
982
|
+
pool: RawTransactionArgument<string>,
|
|
983
|
+
baseMarginPool: RawTransactionArgument<string>,
|
|
984
|
+
quoteMarginPool: RawTransactionArgument<string>,
|
|
985
|
+
];
|
|
986
|
+
typeArguments: [string, string];
|
|
987
|
+
}
|
|
988
|
+
export function riskRatio(options: RiskRatioOptions) {
|
|
989
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
990
|
+
const argumentsTypes = [null, null, null, null, null, null, null, '0x2::clock::Clock'] satisfies (
|
|
991
|
+
| string
|
|
992
|
+
| null
|
|
993
|
+
)[];
|
|
994
|
+
const parameterNames = [
|
|
995
|
+
'self',
|
|
996
|
+
'registry',
|
|
997
|
+
'baseOracle',
|
|
998
|
+
'quoteOracle',
|
|
999
|
+
'pool',
|
|
1000
|
+
'baseMarginPool',
|
|
1001
|
+
'quoteMarginPool',
|
|
1002
|
+
];
|
|
1003
|
+
return (tx: Transaction) =>
|
|
1004
|
+
tx.moveCall({
|
|
1005
|
+
package: packageAddress,
|
|
1006
|
+
module: 'margin_manager',
|
|
1007
|
+
function: 'risk_ratio',
|
|
1008
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1009
|
+
typeArguments: options.typeArguments,
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
export interface RiskRatioUnsafeArguments {
|
|
1013
|
+
self: RawTransactionArgument<string>;
|
|
1014
|
+
registry: RawTransactionArgument<string>;
|
|
1015
|
+
baseOracle: RawTransactionArgument<string>;
|
|
1016
|
+
quoteOracle: RawTransactionArgument<string>;
|
|
1017
|
+
pool: RawTransactionArgument<string>;
|
|
1018
|
+
baseMarginPool: RawTransactionArgument<string>;
|
|
1019
|
+
quoteMarginPool: RawTransactionArgument<string>;
|
|
1020
|
+
}
|
|
1021
|
+
export interface RiskRatioUnsafeOptions {
|
|
1022
|
+
package?: string;
|
|
1023
|
+
arguments:
|
|
1024
|
+
| RiskRatioUnsafeArguments
|
|
1025
|
+
| [
|
|
1026
|
+
self: RawTransactionArgument<string>,
|
|
1027
|
+
registry: RawTransactionArgument<string>,
|
|
1028
|
+
baseOracle: RawTransactionArgument<string>,
|
|
1029
|
+
quoteOracle: RawTransactionArgument<string>,
|
|
1030
|
+
pool: RawTransactionArgument<string>,
|
|
1031
|
+
baseMarginPool: RawTransactionArgument<string>,
|
|
1032
|
+
quoteMarginPool: RawTransactionArgument<string>,
|
|
1033
|
+
];
|
|
1034
|
+
typeArguments: [string, string];
|
|
1035
|
+
}
|
|
1036
|
+
/**
|
|
1037
|
+
* Returns the risk ratio without validating oracle price staleness or confidence.
|
|
1038
|
+
* Use for read-only queries where stale prices are acceptable.
|
|
1039
|
+
*/
|
|
1040
|
+
export function riskRatioUnsafe(options: RiskRatioUnsafeOptions) {
|
|
1041
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1042
|
+
const argumentsTypes = [null, null, null, null, null, null, null, '0x2::clock::Clock'] satisfies (
|
|
1043
|
+
| string
|
|
1044
|
+
| null
|
|
1045
|
+
)[];
|
|
1046
|
+
const parameterNames = [
|
|
1047
|
+
'self',
|
|
1048
|
+
'registry',
|
|
1049
|
+
'baseOracle',
|
|
1050
|
+
'quoteOracle',
|
|
1051
|
+
'pool',
|
|
1052
|
+
'baseMarginPool',
|
|
1053
|
+
'quoteMarginPool',
|
|
1054
|
+
];
|
|
1055
|
+
return (tx: Transaction) =>
|
|
1056
|
+
tx.moveCall({
|
|
1057
|
+
package: packageAddress,
|
|
1058
|
+
module: 'margin_manager',
|
|
1059
|
+
function: 'risk_ratio_unsafe',
|
|
1060
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1061
|
+
typeArguments: options.typeArguments,
|
|
1062
|
+
});
|
|
1063
|
+
}
|
|
1064
|
+
export interface BalanceManagerArguments {
|
|
1065
|
+
self: RawTransactionArgument<string>;
|
|
1066
|
+
}
|
|
1067
|
+
export interface BalanceManagerOptions {
|
|
1068
|
+
package?: string;
|
|
1069
|
+
arguments: BalanceManagerArguments | [self: RawTransactionArgument<string>];
|
|
1070
|
+
typeArguments: [string, string];
|
|
1071
|
+
}
|
|
1072
|
+
export function balanceManager(options: BalanceManagerOptions) {
|
|
1073
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1074
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
1075
|
+
const parameterNames = ['self'];
|
|
1076
|
+
return (tx: Transaction) =>
|
|
1077
|
+
tx.moveCall({
|
|
1078
|
+
package: packageAddress,
|
|
1079
|
+
module: 'margin_manager',
|
|
1080
|
+
function: 'balance_manager',
|
|
1081
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1082
|
+
typeArguments: options.typeArguments,
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1085
|
+
export interface BaseBalanceArguments {
|
|
1086
|
+
self: RawTransactionArgument<string>;
|
|
1087
|
+
}
|
|
1088
|
+
export interface BaseBalanceOptions {
|
|
1089
|
+
package?: string;
|
|
1090
|
+
arguments: BaseBalanceArguments | [self: RawTransactionArgument<string>];
|
|
1091
|
+
typeArguments: [string, string];
|
|
1092
|
+
}
|
|
1093
|
+
export function baseBalance(options: BaseBalanceOptions) {
|
|
1094
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1095
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
1096
|
+
const parameterNames = ['self'];
|
|
1097
|
+
return (tx: Transaction) =>
|
|
1098
|
+
tx.moveCall({
|
|
1099
|
+
package: packageAddress,
|
|
1100
|
+
module: 'margin_manager',
|
|
1101
|
+
function: 'base_balance',
|
|
1102
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1103
|
+
typeArguments: options.typeArguments,
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
export interface QuoteBalanceArguments {
|
|
1107
|
+
self: RawTransactionArgument<string>;
|
|
1108
|
+
}
|
|
1109
|
+
export interface QuoteBalanceOptions {
|
|
1110
|
+
package?: string;
|
|
1111
|
+
arguments: QuoteBalanceArguments | [self: RawTransactionArgument<string>];
|
|
1112
|
+
typeArguments: [string, string];
|
|
1113
|
+
}
|
|
1114
|
+
export function quoteBalance(options: QuoteBalanceOptions) {
|
|
1115
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1116
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
1117
|
+
const parameterNames = ['self'];
|
|
1118
|
+
return (tx: Transaction) =>
|
|
1119
|
+
tx.moveCall({
|
|
1120
|
+
package: packageAddress,
|
|
1121
|
+
module: 'margin_manager',
|
|
1122
|
+
function: 'quote_balance',
|
|
1123
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1124
|
+
typeArguments: options.typeArguments,
|
|
1125
|
+
});
|
|
1126
|
+
}
|
|
1127
|
+
export interface DeepBalanceArguments {
|
|
1128
|
+
self: RawTransactionArgument<string>;
|
|
1129
|
+
}
|
|
1130
|
+
export interface DeepBalanceOptions {
|
|
1131
|
+
package?: string;
|
|
1132
|
+
arguments: DeepBalanceArguments | [self: RawTransactionArgument<string>];
|
|
1133
|
+
typeArguments: [string, string];
|
|
1134
|
+
}
|
|
1135
|
+
export function deepBalance(options: DeepBalanceOptions) {
|
|
1136
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1137
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
1138
|
+
const parameterNames = ['self'];
|
|
1139
|
+
return (tx: Transaction) =>
|
|
1140
|
+
tx.moveCall({
|
|
1141
|
+
package: packageAddress,
|
|
1142
|
+
module: 'margin_manager',
|
|
1143
|
+
function: 'deep_balance',
|
|
1144
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1145
|
+
typeArguments: options.typeArguments,
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
export interface CalculateAssetsArguments {
|
|
1149
|
+
self: RawTransactionArgument<string>;
|
|
1150
|
+
pool: RawTransactionArgument<string>;
|
|
1151
|
+
}
|
|
1152
|
+
export interface CalculateAssetsOptions {
|
|
1153
|
+
package?: string;
|
|
1154
|
+
arguments:
|
|
1155
|
+
| CalculateAssetsArguments
|
|
1156
|
+
| [self: RawTransactionArgument<string>, pool: RawTransactionArgument<string>];
|
|
1157
|
+
typeArguments: [string, string];
|
|
1158
|
+
}
|
|
1159
|
+
/** Returns (base_asset, quote_asset) for margin manager. */
|
|
1160
|
+
export function calculateAssets(options: CalculateAssetsOptions) {
|
|
1161
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1162
|
+
const argumentsTypes = [null, null] satisfies (string | null)[];
|
|
1163
|
+
const parameterNames = ['self', 'pool'];
|
|
1164
|
+
return (tx: Transaction) =>
|
|
1165
|
+
tx.moveCall({
|
|
1166
|
+
package: packageAddress,
|
|
1167
|
+
module: 'margin_manager',
|
|
1168
|
+
function: 'calculate_assets',
|
|
1169
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1170
|
+
typeArguments: options.typeArguments,
|
|
1171
|
+
});
|
|
1172
|
+
}
|
|
1173
|
+
export interface CalculateDebtsArguments {
|
|
1174
|
+
self: RawTransactionArgument<string>;
|
|
1175
|
+
marginPool: RawTransactionArgument<string>;
|
|
1176
|
+
}
|
|
1177
|
+
export interface CalculateDebtsOptions {
|
|
1178
|
+
package?: string;
|
|
1179
|
+
arguments:
|
|
1180
|
+
| CalculateDebtsArguments
|
|
1181
|
+
| [self: RawTransactionArgument<string>, marginPool: RawTransactionArgument<string>];
|
|
1182
|
+
typeArguments: [string, string, string];
|
|
1183
|
+
}
|
|
1184
|
+
export function calculateDebts(options: CalculateDebtsOptions) {
|
|
1185
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1186
|
+
const argumentsTypes = [null, null, '0x2::clock::Clock'] satisfies (string | null)[];
|
|
1187
|
+
const parameterNames = ['self', 'marginPool'];
|
|
1188
|
+
return (tx: Transaction) =>
|
|
1189
|
+
tx.moveCall({
|
|
1190
|
+
package: packageAddress,
|
|
1191
|
+
module: 'margin_manager',
|
|
1192
|
+
function: 'calculate_debts',
|
|
1193
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1194
|
+
typeArguments: options.typeArguments,
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1197
|
+
export interface ManagerStateArguments {
|
|
1198
|
+
self: RawTransactionArgument<string>;
|
|
1199
|
+
registry: RawTransactionArgument<string>;
|
|
1200
|
+
baseOracle: RawTransactionArgument<string>;
|
|
1201
|
+
quoteOracle: RawTransactionArgument<string>;
|
|
1202
|
+
pool: RawTransactionArgument<string>;
|
|
1203
|
+
baseMarginPool: RawTransactionArgument<string>;
|
|
1204
|
+
quoteMarginPool: RawTransactionArgument<string>;
|
|
1205
|
+
}
|
|
1206
|
+
export interface ManagerStateOptions {
|
|
1207
|
+
package?: string;
|
|
1208
|
+
arguments:
|
|
1209
|
+
| ManagerStateArguments
|
|
1210
|
+
| [
|
|
1211
|
+
self: RawTransactionArgument<string>,
|
|
1212
|
+
registry: RawTransactionArgument<string>,
|
|
1213
|
+
baseOracle: RawTransactionArgument<string>,
|
|
1214
|
+
quoteOracle: RawTransactionArgument<string>,
|
|
1215
|
+
pool: RawTransactionArgument<string>,
|
|
1216
|
+
baseMarginPool: RawTransactionArgument<string>,
|
|
1217
|
+
quoteMarginPool: RawTransactionArgument<string>,
|
|
1218
|
+
];
|
|
1219
|
+
typeArguments: [string, string];
|
|
1220
|
+
}
|
|
1221
|
+
/**
|
|
1222
|
+
* Returns comprehensive state information for a margin manager. Returns
|
|
1223
|
+
* (manager_id, deepbook_pool_id, risk_ratio, base_asset, quote_asset, base_debt,
|
|
1224
|
+
* quote_debt, base_pyth_price, base_pyth_decimals, quote_pyth_price,
|
|
1225
|
+
* quote_pyth_decimals, current_price, lowest_trigger_above_price,
|
|
1226
|
+
* highest_trigger_below_price)
|
|
1227
|
+
*/
|
|
1228
|
+
export function managerState(options: ManagerStateOptions) {
|
|
1229
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1230
|
+
const argumentsTypes = [null, null, null, null, null, null, null, '0x2::clock::Clock'] satisfies (
|
|
1231
|
+
| string
|
|
1232
|
+
| null
|
|
1233
|
+
)[];
|
|
1234
|
+
const parameterNames = [
|
|
1235
|
+
'self',
|
|
1236
|
+
'registry',
|
|
1237
|
+
'baseOracle',
|
|
1238
|
+
'quoteOracle',
|
|
1239
|
+
'pool',
|
|
1240
|
+
'baseMarginPool',
|
|
1241
|
+
'quoteMarginPool',
|
|
1242
|
+
];
|
|
1243
|
+
return (tx: Transaction) =>
|
|
1244
|
+
tx.moveCall({
|
|
1245
|
+
package: packageAddress,
|
|
1246
|
+
module: 'margin_manager',
|
|
1247
|
+
function: 'manager_state',
|
|
1248
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1249
|
+
typeArguments: options.typeArguments,
|
|
1250
|
+
});
|
|
1251
|
+
}
|
|
1252
|
+
export interface IdArguments {
|
|
1253
|
+
self: RawTransactionArgument<string>;
|
|
1254
|
+
}
|
|
1255
|
+
export interface IdOptions {
|
|
1256
|
+
package?: string;
|
|
1257
|
+
arguments: IdArguments | [self: RawTransactionArgument<string>];
|
|
1258
|
+
typeArguments: [string, string];
|
|
1259
|
+
}
|
|
1260
|
+
export function id(options: IdOptions) {
|
|
1261
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1262
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
1263
|
+
const parameterNames = ['self'];
|
|
1264
|
+
return (tx: Transaction) =>
|
|
1265
|
+
tx.moveCall({
|
|
1266
|
+
package: packageAddress,
|
|
1267
|
+
module: 'margin_manager',
|
|
1268
|
+
function: 'id',
|
|
1269
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1270
|
+
typeArguments: options.typeArguments,
|
|
1271
|
+
});
|
|
1272
|
+
}
|
|
1273
|
+
export interface OwnerArguments {
|
|
1274
|
+
self: RawTransactionArgument<string>;
|
|
1275
|
+
}
|
|
1276
|
+
export interface OwnerOptions {
|
|
1277
|
+
package?: string;
|
|
1278
|
+
arguments: OwnerArguments | [self: RawTransactionArgument<string>];
|
|
1279
|
+
typeArguments: [string, string];
|
|
1280
|
+
}
|
|
1281
|
+
export function owner(options: OwnerOptions) {
|
|
1282
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1283
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
1284
|
+
const parameterNames = ['self'];
|
|
1285
|
+
return (tx: Transaction) =>
|
|
1286
|
+
tx.moveCall({
|
|
1287
|
+
package: packageAddress,
|
|
1288
|
+
module: 'margin_manager',
|
|
1289
|
+
function: 'owner',
|
|
1290
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1291
|
+
typeArguments: options.typeArguments,
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
export interface DeepbookPoolArguments {
|
|
1295
|
+
self: RawTransactionArgument<string>;
|
|
1296
|
+
}
|
|
1297
|
+
export interface DeepbookPoolOptions {
|
|
1298
|
+
package?: string;
|
|
1299
|
+
arguments: DeepbookPoolArguments | [self: RawTransactionArgument<string>];
|
|
1300
|
+
typeArguments: [string, string];
|
|
1301
|
+
}
|
|
1302
|
+
export function deepbookPool(options: DeepbookPoolOptions) {
|
|
1303
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1304
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
1305
|
+
const parameterNames = ['self'];
|
|
1306
|
+
return (tx: Transaction) =>
|
|
1307
|
+
tx.moveCall({
|
|
1308
|
+
package: packageAddress,
|
|
1309
|
+
module: 'margin_manager',
|
|
1310
|
+
function: 'deepbook_pool',
|
|
1311
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1312
|
+
typeArguments: options.typeArguments,
|
|
1313
|
+
});
|
|
1314
|
+
}
|
|
1315
|
+
export interface MarginPoolIdArguments {
|
|
1316
|
+
self: RawTransactionArgument<string>;
|
|
1317
|
+
}
|
|
1318
|
+
export interface MarginPoolIdOptions {
|
|
1319
|
+
package?: string;
|
|
1320
|
+
arguments: MarginPoolIdArguments | [self: RawTransactionArgument<string>];
|
|
1321
|
+
typeArguments: [string, string];
|
|
1322
|
+
}
|
|
1323
|
+
export function marginPoolId(options: MarginPoolIdOptions) {
|
|
1324
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1325
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
1326
|
+
const parameterNames = ['self'];
|
|
1327
|
+
return (tx: Transaction) =>
|
|
1328
|
+
tx.moveCall({
|
|
1329
|
+
package: packageAddress,
|
|
1330
|
+
module: 'margin_manager',
|
|
1331
|
+
function: 'margin_pool_id',
|
|
1332
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1333
|
+
typeArguments: options.typeArguments,
|
|
1334
|
+
});
|
|
1335
|
+
}
|
|
1336
|
+
export interface BorrowedSharesArguments {
|
|
1337
|
+
self: RawTransactionArgument<string>;
|
|
1338
|
+
}
|
|
1339
|
+
export interface BorrowedSharesOptions {
|
|
1340
|
+
package?: string;
|
|
1341
|
+
arguments: BorrowedSharesArguments | [self: RawTransactionArgument<string>];
|
|
1342
|
+
typeArguments: [string, string];
|
|
1343
|
+
}
|
|
1344
|
+
export function borrowedShares(options: BorrowedSharesOptions) {
|
|
1345
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1346
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
1347
|
+
const parameterNames = ['self'];
|
|
1348
|
+
return (tx: Transaction) =>
|
|
1349
|
+
tx.moveCall({
|
|
1350
|
+
package: packageAddress,
|
|
1351
|
+
module: 'margin_manager',
|
|
1352
|
+
function: 'borrowed_shares',
|
|
1353
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1354
|
+
typeArguments: options.typeArguments,
|
|
1355
|
+
});
|
|
1356
|
+
}
|
|
1357
|
+
export interface BorrowedBaseSharesArguments {
|
|
1358
|
+
self: RawTransactionArgument<string>;
|
|
1359
|
+
}
|
|
1360
|
+
export interface BorrowedBaseSharesOptions {
|
|
1361
|
+
package?: string;
|
|
1362
|
+
arguments: BorrowedBaseSharesArguments | [self: RawTransactionArgument<string>];
|
|
1363
|
+
typeArguments: [string, string];
|
|
1364
|
+
}
|
|
1365
|
+
export function borrowedBaseShares(options: BorrowedBaseSharesOptions) {
|
|
1366
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1367
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
1368
|
+
const parameterNames = ['self'];
|
|
1369
|
+
return (tx: Transaction) =>
|
|
1370
|
+
tx.moveCall({
|
|
1371
|
+
package: packageAddress,
|
|
1372
|
+
module: 'margin_manager',
|
|
1373
|
+
function: 'borrowed_base_shares',
|
|
1374
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1375
|
+
typeArguments: options.typeArguments,
|
|
1376
|
+
});
|
|
1377
|
+
}
|
|
1378
|
+
export interface BorrowedQuoteSharesArguments {
|
|
1379
|
+
self: RawTransactionArgument<string>;
|
|
1380
|
+
}
|
|
1381
|
+
export interface BorrowedQuoteSharesOptions {
|
|
1382
|
+
package?: string;
|
|
1383
|
+
arguments: BorrowedQuoteSharesArguments | [self: RawTransactionArgument<string>];
|
|
1384
|
+
typeArguments: [string, string];
|
|
1385
|
+
}
|
|
1386
|
+
export function borrowedQuoteShares(options: BorrowedQuoteSharesOptions) {
|
|
1387
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1388
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
1389
|
+
const parameterNames = ['self'];
|
|
1390
|
+
return (tx: Transaction) =>
|
|
1391
|
+
tx.moveCall({
|
|
1392
|
+
package: packageAddress,
|
|
1393
|
+
module: 'margin_manager',
|
|
1394
|
+
function: 'borrowed_quote_shares',
|
|
1395
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1396
|
+
typeArguments: options.typeArguments,
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
export interface HasBaseDebtArguments {
|
|
1400
|
+
self: RawTransactionArgument<string>;
|
|
1401
|
+
}
|
|
1402
|
+
export interface HasBaseDebtOptions {
|
|
1403
|
+
package?: string;
|
|
1404
|
+
arguments: HasBaseDebtArguments | [self: RawTransactionArgument<string>];
|
|
1405
|
+
typeArguments: [string, string];
|
|
1406
|
+
}
|
|
1407
|
+
export function hasBaseDebt(options: HasBaseDebtOptions) {
|
|
1408
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1409
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
1410
|
+
const parameterNames = ['self'];
|
|
1411
|
+
return (tx: Transaction) =>
|
|
1412
|
+
tx.moveCall({
|
|
1413
|
+
package: packageAddress,
|
|
1414
|
+
module: 'margin_manager',
|
|
1415
|
+
function: 'has_base_debt',
|
|
1416
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1417
|
+
typeArguments: options.typeArguments,
|
|
1418
|
+
});
|
|
1419
|
+
}
|
|
1420
|
+
export interface ConditionalOrderIdsArguments {
|
|
1421
|
+
self: RawTransactionArgument<string>;
|
|
1422
|
+
}
|
|
1423
|
+
export interface ConditionalOrderIdsOptions {
|
|
1424
|
+
package?: string;
|
|
1425
|
+
arguments: ConditionalOrderIdsArguments | [self: RawTransactionArgument<string>];
|
|
1426
|
+
typeArguments: [string, string];
|
|
1427
|
+
}
|
|
1428
|
+
export function conditionalOrderIds(options: ConditionalOrderIdsOptions) {
|
|
1429
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1430
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
1431
|
+
const parameterNames = ['self'];
|
|
1432
|
+
return (tx: Transaction) =>
|
|
1433
|
+
tx.moveCall({
|
|
1434
|
+
package: packageAddress,
|
|
1435
|
+
module: 'margin_manager',
|
|
1436
|
+
function: 'conditional_order_ids',
|
|
1437
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1438
|
+
typeArguments: options.typeArguments,
|
|
1439
|
+
});
|
|
1440
|
+
}
|
|
1441
|
+
export interface ConditionalOrderArguments {
|
|
1442
|
+
self: RawTransactionArgument<string>;
|
|
1443
|
+
conditionalOrderId: RawTransactionArgument<number | bigint>;
|
|
1444
|
+
}
|
|
1445
|
+
export interface ConditionalOrderOptions {
|
|
1446
|
+
package?: string;
|
|
1447
|
+
arguments:
|
|
1448
|
+
| ConditionalOrderArguments
|
|
1449
|
+
| [
|
|
1450
|
+
self: RawTransactionArgument<string>,
|
|
1451
|
+
conditionalOrderId: RawTransactionArgument<number | bigint>,
|
|
1452
|
+
];
|
|
1453
|
+
typeArguments: [string, string];
|
|
1454
|
+
}
|
|
1455
|
+
export function conditionalOrder(options: ConditionalOrderOptions) {
|
|
1456
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1457
|
+
const argumentsTypes = [null, 'u64'] satisfies (string | null)[];
|
|
1458
|
+
const parameterNames = ['self', 'conditionalOrderId'];
|
|
1459
|
+
return (tx: Transaction) =>
|
|
1460
|
+
tx.moveCall({
|
|
1461
|
+
package: packageAddress,
|
|
1462
|
+
module: 'margin_manager',
|
|
1463
|
+
function: 'conditional_order',
|
|
1464
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1465
|
+
typeArguments: options.typeArguments,
|
|
1466
|
+
});
|
|
1467
|
+
}
|
|
1468
|
+
export interface LowestTriggerAbovePriceArguments {
|
|
1469
|
+
self: RawTransactionArgument<string>;
|
|
1470
|
+
}
|
|
1471
|
+
export interface LowestTriggerAbovePriceOptions {
|
|
1472
|
+
package?: string;
|
|
1473
|
+
arguments: LowestTriggerAbovePriceArguments | [self: RawTransactionArgument<string>];
|
|
1474
|
+
typeArguments: [string, string];
|
|
1475
|
+
}
|
|
1476
|
+
/**
|
|
1477
|
+
* Returns the lowest trigger price for trigger_above orders Returns
|
|
1478
|
+
* constants::max_u64() if there are no trigger_above orders
|
|
1479
|
+
*/
|
|
1480
|
+
export function lowestTriggerAbovePrice(options: LowestTriggerAbovePriceOptions) {
|
|
1481
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1482
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
1483
|
+
const parameterNames = ['self'];
|
|
1484
|
+
return (tx: Transaction) =>
|
|
1485
|
+
tx.moveCall({
|
|
1486
|
+
package: packageAddress,
|
|
1487
|
+
module: 'margin_manager',
|
|
1488
|
+
function: 'lowest_trigger_above_price',
|
|
1489
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1490
|
+
typeArguments: options.typeArguments,
|
|
1491
|
+
});
|
|
1492
|
+
}
|
|
1493
|
+
export interface HighestTriggerBelowPriceArguments {
|
|
1494
|
+
self: RawTransactionArgument<string>;
|
|
1495
|
+
}
|
|
1496
|
+
export interface HighestTriggerBelowPriceOptions {
|
|
1497
|
+
package?: string;
|
|
1498
|
+
arguments: HighestTriggerBelowPriceArguments | [self: RawTransactionArgument<string>];
|
|
1499
|
+
typeArguments: [string, string];
|
|
1500
|
+
}
|
|
1501
|
+
/**
|
|
1502
|
+
* Returns the highest trigger price for trigger_below orders Returns 0 if there
|
|
1503
|
+
* are no trigger_below orders
|
|
1504
|
+
*/
|
|
1505
|
+
export function highestTriggerBelowPrice(options: HighestTriggerBelowPriceOptions) {
|
|
1506
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1507
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
1508
|
+
const parameterNames = ['self'];
|
|
1509
|
+
return (tx: Transaction) =>
|
|
1510
|
+
tx.moveCall({
|
|
1511
|
+
package: packageAddress,
|
|
1512
|
+
module: 'margin_manager',
|
|
1513
|
+
function: 'highest_trigger_below_price',
|
|
1514
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1515
|
+
typeArguments: options.typeArguments,
|
|
1516
|
+
});
|
|
1517
|
+
}
|
|
1518
|
+
export interface GetAccountOrderDetailsArguments {
|
|
1519
|
+
self: RawTransactionArgument<string>;
|
|
1520
|
+
pool: RawTransactionArgument<string>;
|
|
1521
|
+
}
|
|
1522
|
+
export interface GetAccountOrderDetailsOptions {
|
|
1523
|
+
package?: string;
|
|
1524
|
+
arguments:
|
|
1525
|
+
| GetAccountOrderDetailsArguments
|
|
1526
|
+
| [self: RawTransactionArgument<string>, pool: RawTransactionArgument<string>];
|
|
1527
|
+
typeArguments: [string, string];
|
|
1528
|
+
}
|
|
1529
|
+
export function getAccountOrderDetails(options: GetAccountOrderDetailsOptions) {
|
|
1530
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1531
|
+
const argumentsTypes = [null, null] satisfies (string | null)[];
|
|
1532
|
+
const parameterNames = ['self', 'pool'];
|
|
1533
|
+
return (tx: Transaction) =>
|
|
1534
|
+
tx.moveCall({
|
|
1535
|
+
package: packageAddress,
|
|
1536
|
+
module: 'margin_manager',
|
|
1537
|
+
function: 'get_account_order_details',
|
|
1538
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1539
|
+
typeArguments: options.typeArguments,
|
|
1540
|
+
});
|
|
1541
|
+
}
|
|
1542
|
+
export interface AccountOpenOrdersArguments {
|
|
1543
|
+
self: RawTransactionArgument<string>;
|
|
1544
|
+
pool: RawTransactionArgument<string>;
|
|
1545
|
+
}
|
|
1546
|
+
export interface AccountOpenOrdersOptions {
|
|
1547
|
+
package?: string;
|
|
1548
|
+
arguments:
|
|
1549
|
+
| AccountOpenOrdersArguments
|
|
1550
|
+
| [self: RawTransactionArgument<string>, pool: RawTransactionArgument<string>];
|
|
1551
|
+
typeArguments: [string, string];
|
|
1552
|
+
}
|
|
1553
|
+
export function accountOpenOrders(options: AccountOpenOrdersOptions) {
|
|
1554
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1555
|
+
const argumentsTypes = [null, null] satisfies (string | null)[];
|
|
1556
|
+
const parameterNames = ['self', 'pool'];
|
|
1557
|
+
return (tx: Transaction) =>
|
|
1558
|
+
tx.moveCall({
|
|
1559
|
+
package: packageAddress,
|
|
1560
|
+
module: 'margin_manager',
|
|
1561
|
+
function: 'account_open_orders',
|
|
1562
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1563
|
+
typeArguments: options.typeArguments,
|
|
1564
|
+
});
|
|
1565
|
+
}
|
|
1566
|
+
export interface LockedBalanceArguments {
|
|
1567
|
+
self: RawTransactionArgument<string>;
|
|
1568
|
+
pool: RawTransactionArgument<string>;
|
|
1569
|
+
}
|
|
1570
|
+
export interface LockedBalanceOptions {
|
|
1571
|
+
package?: string;
|
|
1572
|
+
arguments:
|
|
1573
|
+
| LockedBalanceArguments
|
|
1574
|
+
| [self: RawTransactionArgument<string>, pool: RawTransactionArgument<string>];
|
|
1575
|
+
typeArguments: [string, string];
|
|
1576
|
+
}
|
|
1577
|
+
export function lockedBalance(options: LockedBalanceOptions) {
|
|
1578
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1579
|
+
const argumentsTypes = [null, null] satisfies (string | null)[];
|
|
1580
|
+
const parameterNames = ['self', 'pool'];
|
|
1581
|
+
return (tx: Transaction) =>
|
|
1582
|
+
tx.moveCall({
|
|
1583
|
+
package: packageAddress,
|
|
1584
|
+
module: 'margin_manager',
|
|
1585
|
+
function: 'locked_balance',
|
|
1586
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1587
|
+
typeArguments: options.typeArguments,
|
|
1588
|
+
});
|
|
1589
|
+
}
|
|
1590
|
+
export interface BalanceManagerIdArguments {
|
|
1591
|
+
self: RawTransactionArgument<string>;
|
|
1592
|
+
}
|
|
1593
|
+
export interface BalanceManagerIdOptions {
|
|
1594
|
+
package?: string;
|
|
1595
|
+
arguments: BalanceManagerIdArguments | [self: RawTransactionArgument<string>];
|
|
1596
|
+
typeArguments: [string, string];
|
|
1597
|
+
}
|
|
1598
|
+
export function balanceManagerId(options: BalanceManagerIdOptions) {
|
|
1599
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1600
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
1601
|
+
const parameterNames = ['self'];
|
|
1602
|
+
return (tx: Transaction) =>
|
|
1603
|
+
tx.moveCall({
|
|
1604
|
+
package: packageAddress,
|
|
1605
|
+
module: 'margin_manager',
|
|
1606
|
+
function: 'balance_manager_id',
|
|
1607
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1608
|
+
typeArguments: options.typeArguments,
|
|
1609
|
+
});
|
|
1610
|
+
}
|
|
1611
|
+
export interface GetBalanceManagerReferralIdArguments {
|
|
1612
|
+
self: RawTransactionArgument<string>;
|
|
1613
|
+
poolId: RawTransactionArgument<string>;
|
|
1614
|
+
}
|
|
1615
|
+
export interface GetBalanceManagerReferralIdOptions {
|
|
1616
|
+
package?: string;
|
|
1617
|
+
arguments:
|
|
1618
|
+
| GetBalanceManagerReferralIdArguments
|
|
1619
|
+
| [self: RawTransactionArgument<string>, poolId: RawTransactionArgument<string>];
|
|
1620
|
+
typeArguments: [string, string];
|
|
1621
|
+
}
|
|
1622
|
+
export function getBalanceManagerReferralId(options: GetBalanceManagerReferralIdOptions) {
|
|
1623
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1624
|
+
const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[];
|
|
1625
|
+
const parameterNames = ['self', 'poolId'];
|
|
1626
|
+
return (tx: Transaction) =>
|
|
1627
|
+
tx.moveCall({
|
|
1628
|
+
package: packageAddress,
|
|
1629
|
+
module: 'margin_manager',
|
|
1630
|
+
function: 'get_balance_manager_referral_id',
|
|
1631
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1632
|
+
typeArguments: options.typeArguments,
|
|
1633
|
+
});
|
|
1634
|
+
}
|
|
1635
|
+
export interface AccountExistsArguments {
|
|
1636
|
+
self: RawTransactionArgument<string>;
|
|
1637
|
+
pool: RawTransactionArgument<string>;
|
|
1638
|
+
}
|
|
1639
|
+
export interface AccountExistsOptions {
|
|
1640
|
+
package?: string;
|
|
1641
|
+
arguments:
|
|
1642
|
+
| AccountExistsArguments
|
|
1643
|
+
| [self: RawTransactionArgument<string>, pool: RawTransactionArgument<string>];
|
|
1644
|
+
typeArguments: [string, string];
|
|
1645
|
+
}
|
|
1646
|
+
export function accountExists(options: AccountExistsOptions) {
|
|
1647
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1648
|
+
const argumentsTypes = [null, null] satisfies (string | null)[];
|
|
1649
|
+
const parameterNames = ['self', 'pool'];
|
|
1650
|
+
return (tx: Transaction) =>
|
|
1651
|
+
tx.moveCall({
|
|
1652
|
+
package: packageAddress,
|
|
1653
|
+
module: 'margin_manager',
|
|
1654
|
+
function: 'account_exists',
|
|
1655
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1656
|
+
typeArguments: options.typeArguments,
|
|
1657
|
+
});
|
|
1658
|
+
}
|
|
1659
|
+
export interface AccountArguments {
|
|
1660
|
+
self: RawTransactionArgument<string>;
|
|
1661
|
+
pool: RawTransactionArgument<string>;
|
|
1662
|
+
}
|
|
1663
|
+
export interface AccountOptions {
|
|
1664
|
+
package?: string;
|
|
1665
|
+
arguments:
|
|
1666
|
+
| AccountArguments
|
|
1667
|
+
| [self: RawTransactionArgument<string>, pool: RawTransactionArgument<string>];
|
|
1668
|
+
typeArguments: [string, string];
|
|
1669
|
+
}
|
|
1670
|
+
export function account(options: AccountOptions) {
|
|
1671
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1672
|
+
const argumentsTypes = [null, null] satisfies (string | null)[];
|
|
1673
|
+
const parameterNames = ['self', 'pool'];
|
|
1674
|
+
return (tx: Transaction) =>
|
|
1675
|
+
tx.moveCall({
|
|
1676
|
+
package: packageAddress,
|
|
1677
|
+
module: 'margin_manager',
|
|
1678
|
+
function: 'account',
|
|
1679
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1680
|
+
typeArguments: options.typeArguments,
|
|
1681
|
+
});
|
|
1682
|
+
}
|
|
1683
|
+
export interface CanPlaceLimitOrderArguments {
|
|
1684
|
+
self: RawTransactionArgument<string>;
|
|
1685
|
+
pool: RawTransactionArgument<string>;
|
|
1686
|
+
price: RawTransactionArgument<number | bigint>;
|
|
1687
|
+
quantity: RawTransactionArgument<number | bigint>;
|
|
1688
|
+
isBid: RawTransactionArgument<boolean>;
|
|
1689
|
+
payWithDeep: RawTransactionArgument<boolean>;
|
|
1690
|
+
expireTimestamp: RawTransactionArgument<number | bigint>;
|
|
1691
|
+
}
|
|
1692
|
+
export interface CanPlaceLimitOrderOptions {
|
|
1693
|
+
package?: string;
|
|
1694
|
+
arguments:
|
|
1695
|
+
| CanPlaceLimitOrderArguments
|
|
1696
|
+
| [
|
|
1697
|
+
self: RawTransactionArgument<string>,
|
|
1698
|
+
pool: RawTransactionArgument<string>,
|
|
1699
|
+
price: RawTransactionArgument<number | bigint>,
|
|
1700
|
+
quantity: RawTransactionArgument<number | bigint>,
|
|
1701
|
+
isBid: RawTransactionArgument<boolean>,
|
|
1702
|
+
payWithDeep: RawTransactionArgument<boolean>,
|
|
1703
|
+
expireTimestamp: RawTransactionArgument<number | bigint>,
|
|
1704
|
+
];
|
|
1705
|
+
typeArguments: [string, string];
|
|
1706
|
+
}
|
|
1707
|
+
export function canPlaceLimitOrder(options: CanPlaceLimitOrderOptions) {
|
|
1708
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1709
|
+
const argumentsTypes = [
|
|
1710
|
+
null,
|
|
1711
|
+
null,
|
|
1712
|
+
'u64',
|
|
1713
|
+
'u64',
|
|
1714
|
+
'bool',
|
|
1715
|
+
'bool',
|
|
1716
|
+
'u64',
|
|
1717
|
+
'0x2::clock::Clock',
|
|
1718
|
+
] satisfies (string | null)[];
|
|
1719
|
+
const parameterNames = [
|
|
1720
|
+
'self',
|
|
1721
|
+
'pool',
|
|
1722
|
+
'price',
|
|
1723
|
+
'quantity',
|
|
1724
|
+
'isBid',
|
|
1725
|
+
'payWithDeep',
|
|
1726
|
+
'expireTimestamp',
|
|
1727
|
+
];
|
|
1728
|
+
return (tx: Transaction) =>
|
|
1729
|
+
tx.moveCall({
|
|
1730
|
+
package: packageAddress,
|
|
1731
|
+
module: 'margin_manager',
|
|
1732
|
+
function: 'can_place_limit_order',
|
|
1733
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1734
|
+
typeArguments: options.typeArguments,
|
|
1735
|
+
});
|
|
1736
|
+
}
|
|
1737
|
+
export interface CanPlaceMarketOrderArguments {
|
|
1738
|
+
self: RawTransactionArgument<string>;
|
|
1739
|
+
pool: RawTransactionArgument<string>;
|
|
1740
|
+
quantity: RawTransactionArgument<number | bigint>;
|
|
1741
|
+
isBid: RawTransactionArgument<boolean>;
|
|
1742
|
+
payWithDeep: RawTransactionArgument<boolean>;
|
|
1743
|
+
}
|
|
1744
|
+
export interface CanPlaceMarketOrderOptions {
|
|
1745
|
+
package?: string;
|
|
1746
|
+
arguments:
|
|
1747
|
+
| CanPlaceMarketOrderArguments
|
|
1748
|
+
| [
|
|
1749
|
+
self: RawTransactionArgument<string>,
|
|
1750
|
+
pool: RawTransactionArgument<string>,
|
|
1751
|
+
quantity: RawTransactionArgument<number | bigint>,
|
|
1752
|
+
isBid: RawTransactionArgument<boolean>,
|
|
1753
|
+
payWithDeep: RawTransactionArgument<boolean>,
|
|
1754
|
+
];
|
|
1755
|
+
typeArguments: [string, string];
|
|
1756
|
+
}
|
|
1757
|
+
export function canPlaceMarketOrder(options: CanPlaceMarketOrderOptions) {
|
|
1758
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1759
|
+
const argumentsTypes = [null, null, 'u64', 'bool', 'bool', '0x2::clock::Clock'] satisfies (
|
|
1760
|
+
| string
|
|
1761
|
+
| null
|
|
1762
|
+
)[];
|
|
1763
|
+
const parameterNames = ['self', 'pool', 'quantity', 'isBid', 'payWithDeep'];
|
|
1764
|
+
return (tx: Transaction) =>
|
|
1765
|
+
tx.moveCall({
|
|
1766
|
+
package: packageAddress,
|
|
1767
|
+
module: 'margin_manager',
|
|
1768
|
+
function: 'can_place_market_order',
|
|
1769
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1770
|
+
typeArguments: options.typeArguments,
|
|
1771
|
+
});
|
|
1772
|
+
}
|