@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,28 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Position manager is responsible for managing users' positions. It is used to
|
|
7
|
+
* track the supply and loan shares of the users.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { MoveStruct } from '../utils/index.js';
|
|
11
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
12
|
+
import * as table from './deps/sui/table.js';
|
|
13
|
+
import * as vec_map from './deps/sui/vec_map.js';
|
|
14
|
+
const $moduleName = '@deepbook/margin::position_manager';
|
|
15
|
+
export const PositionManager = new MoveStruct({
|
|
16
|
+
name: `${$moduleName}::PositionManager`,
|
|
17
|
+
fields: {
|
|
18
|
+
positions: table.Table,
|
|
19
|
+
extra_fields: vec_map.VecMap(bcs.string(), bcs.u64()),
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
export const Position = new MoveStruct({
|
|
23
|
+
name: `${$moduleName}::Position`,
|
|
24
|
+
fields: {
|
|
25
|
+
shares: bcs.u64(),
|
|
26
|
+
referral: bcs.option(bcs.Address),
|
|
27
|
+
},
|
|
28
|
+
});
|
|
@@ -0,0 +1,163 @@
|
|
|
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 vec_map from './deps/sui/vec_map.js';
|
|
8
|
+
const $moduleName = '@deepbook/margin::protocol_config';
|
|
9
|
+
export const MarginPoolConfig = new MoveStruct({
|
|
10
|
+
name: `${$moduleName}::MarginPoolConfig`,
|
|
11
|
+
fields: {
|
|
12
|
+
supply_cap: bcs.u64(),
|
|
13
|
+
max_utilization_rate: bcs.u64(),
|
|
14
|
+
protocol_spread: bcs.u64(),
|
|
15
|
+
min_borrow: bcs.u64(),
|
|
16
|
+
rate_limit_capacity: bcs.u64(),
|
|
17
|
+
rate_limit_refill_rate_per_ms: bcs.u64(),
|
|
18
|
+
rate_limit_enabled: bcs.bool(),
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
export const InterestConfig = new MoveStruct({
|
|
22
|
+
name: `${$moduleName}::InterestConfig`,
|
|
23
|
+
fields: {
|
|
24
|
+
base_rate: bcs.u64(),
|
|
25
|
+
base_slope: bcs.u64(),
|
|
26
|
+
optimal_utilization: bcs.u64(),
|
|
27
|
+
excess_slope: bcs.u64(),
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
export const ProtocolConfig = new MoveStruct({
|
|
31
|
+
name: `${$moduleName}::ProtocolConfig`,
|
|
32
|
+
fields: {
|
|
33
|
+
margin_pool_config: MarginPoolConfig,
|
|
34
|
+
interest_config: InterestConfig,
|
|
35
|
+
extra_fields: vec_map.VecMap(bcs.string(), bcs.u64()),
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
export interface NewProtocolConfigArguments {
|
|
39
|
+
marginPoolConfig: TransactionArgument;
|
|
40
|
+
interestConfig: TransactionArgument;
|
|
41
|
+
}
|
|
42
|
+
export interface NewProtocolConfigOptions {
|
|
43
|
+
package?: string;
|
|
44
|
+
arguments:
|
|
45
|
+
| NewProtocolConfigArguments
|
|
46
|
+
| [marginPoolConfig: TransactionArgument, interestConfig: TransactionArgument];
|
|
47
|
+
}
|
|
48
|
+
export function newProtocolConfig(options: NewProtocolConfigOptions) {
|
|
49
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
50
|
+
const argumentsTypes = [null, null] satisfies (string | null)[];
|
|
51
|
+
const parameterNames = ['marginPoolConfig', 'interestConfig'];
|
|
52
|
+
return (tx: Transaction) =>
|
|
53
|
+
tx.moveCall({
|
|
54
|
+
package: packageAddress,
|
|
55
|
+
module: 'protocol_config',
|
|
56
|
+
function: 'new_protocol_config',
|
|
57
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
export interface NewMarginPoolConfigArguments {
|
|
61
|
+
supplyCap: RawTransactionArgument<number | bigint>;
|
|
62
|
+
maxUtilizationRate: RawTransactionArgument<number | bigint>;
|
|
63
|
+
protocolSpread: RawTransactionArgument<number | bigint>;
|
|
64
|
+
minBorrow: RawTransactionArgument<number | bigint>;
|
|
65
|
+
}
|
|
66
|
+
export interface NewMarginPoolConfigOptions {
|
|
67
|
+
package?: string;
|
|
68
|
+
arguments:
|
|
69
|
+
| NewMarginPoolConfigArguments
|
|
70
|
+
| [
|
|
71
|
+
supplyCap: RawTransactionArgument<number | bigint>,
|
|
72
|
+
maxUtilizationRate: RawTransactionArgument<number | bigint>,
|
|
73
|
+
protocolSpread: RawTransactionArgument<number | bigint>,
|
|
74
|
+
minBorrow: RawTransactionArgument<number | bigint>,
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
export function newMarginPoolConfig(options: NewMarginPoolConfigOptions) {
|
|
78
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
79
|
+
const argumentsTypes = ['u64', 'u64', 'u64', 'u64'] satisfies (string | null)[];
|
|
80
|
+
const parameterNames = ['supplyCap', 'maxUtilizationRate', 'protocolSpread', 'minBorrow'];
|
|
81
|
+
return (tx: Transaction) =>
|
|
82
|
+
tx.moveCall({
|
|
83
|
+
package: packageAddress,
|
|
84
|
+
module: 'protocol_config',
|
|
85
|
+
function: 'new_margin_pool_config',
|
|
86
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
export interface NewMarginPoolConfigWithRateLimitArguments {
|
|
90
|
+
supplyCap: RawTransactionArgument<number | bigint>;
|
|
91
|
+
maxUtilizationRate: RawTransactionArgument<number | bigint>;
|
|
92
|
+
protocolSpread: RawTransactionArgument<number | bigint>;
|
|
93
|
+
minBorrow: RawTransactionArgument<number | bigint>;
|
|
94
|
+
rateLimitCapacity: RawTransactionArgument<number | bigint>;
|
|
95
|
+
rateLimitRefillRatePerMs: RawTransactionArgument<number | bigint>;
|
|
96
|
+
rateLimitEnabled: RawTransactionArgument<boolean>;
|
|
97
|
+
}
|
|
98
|
+
export interface NewMarginPoolConfigWithRateLimitOptions {
|
|
99
|
+
package?: string;
|
|
100
|
+
arguments:
|
|
101
|
+
| NewMarginPoolConfigWithRateLimitArguments
|
|
102
|
+
| [
|
|
103
|
+
supplyCap: RawTransactionArgument<number | bigint>,
|
|
104
|
+
maxUtilizationRate: RawTransactionArgument<number | bigint>,
|
|
105
|
+
protocolSpread: RawTransactionArgument<number | bigint>,
|
|
106
|
+
minBorrow: RawTransactionArgument<number | bigint>,
|
|
107
|
+
rateLimitCapacity: RawTransactionArgument<number | bigint>,
|
|
108
|
+
rateLimitRefillRatePerMs: RawTransactionArgument<number | bigint>,
|
|
109
|
+
rateLimitEnabled: RawTransactionArgument<boolean>,
|
|
110
|
+
];
|
|
111
|
+
}
|
|
112
|
+
export function newMarginPoolConfigWithRateLimit(options: NewMarginPoolConfigWithRateLimitOptions) {
|
|
113
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
114
|
+
const argumentsTypes = ['u64', 'u64', 'u64', 'u64', 'u64', 'u64', 'bool'] satisfies (
|
|
115
|
+
| string
|
|
116
|
+
| null
|
|
117
|
+
)[];
|
|
118
|
+
const parameterNames = [
|
|
119
|
+
'supplyCap',
|
|
120
|
+
'maxUtilizationRate',
|
|
121
|
+
'protocolSpread',
|
|
122
|
+
'minBorrow',
|
|
123
|
+
'rateLimitCapacity',
|
|
124
|
+
'rateLimitRefillRatePerMs',
|
|
125
|
+
'rateLimitEnabled',
|
|
126
|
+
];
|
|
127
|
+
return (tx: Transaction) =>
|
|
128
|
+
tx.moveCall({
|
|
129
|
+
package: packageAddress,
|
|
130
|
+
module: 'protocol_config',
|
|
131
|
+
function: 'new_margin_pool_config_with_rate_limit',
|
|
132
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
export interface NewInterestConfigArguments {
|
|
136
|
+
baseRate: RawTransactionArgument<number | bigint>;
|
|
137
|
+
baseSlope: RawTransactionArgument<number | bigint>;
|
|
138
|
+
optimalUtilization: RawTransactionArgument<number | bigint>;
|
|
139
|
+
excessSlope: RawTransactionArgument<number | bigint>;
|
|
140
|
+
}
|
|
141
|
+
export interface NewInterestConfigOptions {
|
|
142
|
+
package?: string;
|
|
143
|
+
arguments:
|
|
144
|
+
| NewInterestConfigArguments
|
|
145
|
+
| [
|
|
146
|
+
baseRate: RawTransactionArgument<number | bigint>,
|
|
147
|
+
baseSlope: RawTransactionArgument<number | bigint>,
|
|
148
|
+
optimalUtilization: RawTransactionArgument<number | bigint>,
|
|
149
|
+
excessSlope: RawTransactionArgument<number | bigint>,
|
|
150
|
+
];
|
|
151
|
+
}
|
|
152
|
+
export function newInterestConfig(options: NewInterestConfigOptions) {
|
|
153
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
154
|
+
const argumentsTypes = ['u64', 'u64', 'u64', 'u64'] satisfies (string | null)[];
|
|
155
|
+
const parameterNames = ['baseRate', 'baseSlope', 'optimalUtilization', 'excessSlope'];
|
|
156
|
+
return (tx: Transaction) =>
|
|
157
|
+
tx.moveCall({
|
|
158
|
+
package: packageAddress,
|
|
159
|
+
module: 'protocol_config',
|
|
160
|
+
function: 'new_interest_config',
|
|
161
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
162
|
+
});
|
|
163
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
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 table from './deps/sui/table.js';
|
|
8
|
+
import * as vec_map from './deps/sui/vec_map.js';
|
|
9
|
+
const $moduleName = '@deepbook/margin::protocol_fees';
|
|
10
|
+
export const ProtocolFees = new MoveStruct({
|
|
11
|
+
name: `${$moduleName}::ProtocolFees`,
|
|
12
|
+
fields: {
|
|
13
|
+
referrals: table.Table,
|
|
14
|
+
total_shares: bcs.u64(),
|
|
15
|
+
fees_per_share: bcs.u64(),
|
|
16
|
+
maintainer_fees: bcs.u64(),
|
|
17
|
+
protocol_fees: bcs.u64(),
|
|
18
|
+
extra_fields: vec_map.VecMap(bcs.string(), bcs.u64()),
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
export const ReferralTracker = new MoveStruct({
|
|
22
|
+
name: `${$moduleName}::ReferralTracker`,
|
|
23
|
+
fields: {
|
|
24
|
+
current_shares: bcs.u64(),
|
|
25
|
+
last_fees_per_share: bcs.u64(),
|
|
26
|
+
unclaimed_fees: bcs.u64(),
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
export const SupplyReferral = new MoveStruct({
|
|
30
|
+
name: `${$moduleName}::SupplyReferral`,
|
|
31
|
+
fields: {
|
|
32
|
+
id: bcs.Address,
|
|
33
|
+
owner: bcs.Address,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
export const ProtocolFeesIncreasedEvent = new MoveStruct({
|
|
37
|
+
name: `${$moduleName}::ProtocolFeesIncreasedEvent`,
|
|
38
|
+
fields: {
|
|
39
|
+
margin_pool_id: bcs.Address,
|
|
40
|
+
total_shares: bcs.u64(),
|
|
41
|
+
referral_fees: bcs.u64(),
|
|
42
|
+
maintainer_fees: bcs.u64(),
|
|
43
|
+
protocol_fees: bcs.u64(),
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
export const ReferralFeesClaimedEvent = new MoveStruct({
|
|
47
|
+
name: `${$moduleName}::ReferralFeesClaimedEvent`,
|
|
48
|
+
fields: {
|
|
49
|
+
referral_id: bcs.Address,
|
|
50
|
+
owner: bcs.Address,
|
|
51
|
+
fees: bcs.u64(),
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
export interface MaintainerFeesArguments {
|
|
55
|
+
self: TransactionArgument;
|
|
56
|
+
}
|
|
57
|
+
export interface MaintainerFeesOptions {
|
|
58
|
+
package?: string;
|
|
59
|
+
arguments: MaintainerFeesArguments | [self: TransactionArgument];
|
|
60
|
+
}
|
|
61
|
+
/** Get the maintainer fees. */
|
|
62
|
+
export function maintainerFees(options: MaintainerFeesOptions) {
|
|
63
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
64
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
65
|
+
const parameterNames = ['self'];
|
|
66
|
+
return (tx: Transaction) =>
|
|
67
|
+
tx.moveCall({
|
|
68
|
+
package: packageAddress,
|
|
69
|
+
module: 'protocol_fees',
|
|
70
|
+
function: 'maintainer_fees',
|
|
71
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
export interface ProtocolFeesArguments {
|
|
75
|
+
self: TransactionArgument;
|
|
76
|
+
}
|
|
77
|
+
export interface ProtocolFeesOptions {
|
|
78
|
+
package?: string;
|
|
79
|
+
arguments: ProtocolFeesArguments | [self: TransactionArgument];
|
|
80
|
+
}
|
|
81
|
+
/** Get the protocol fees. */
|
|
82
|
+
export function protocolFees(options: ProtocolFeesOptions) {
|
|
83
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
84
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
85
|
+
const parameterNames = ['self'];
|
|
86
|
+
return (tx: Transaction) =>
|
|
87
|
+
tx.moveCall({
|
|
88
|
+
package: packageAddress,
|
|
89
|
+
module: 'protocol_fees',
|
|
90
|
+
function: 'protocol_fees',
|
|
91
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
export interface ReferralTrackerArguments {
|
|
95
|
+
self: TransactionArgument;
|
|
96
|
+
referral: RawTransactionArgument<string>;
|
|
97
|
+
}
|
|
98
|
+
export interface ReferralTrackerOptions {
|
|
99
|
+
package?: string;
|
|
100
|
+
arguments:
|
|
101
|
+
| ReferralTrackerArguments
|
|
102
|
+
| [self: TransactionArgument, referral: RawTransactionArgument<string>];
|
|
103
|
+
}
|
|
104
|
+
export function referralTracker(options: ReferralTrackerOptions) {
|
|
105
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
106
|
+
const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[];
|
|
107
|
+
const parameterNames = ['self', 'referral'];
|
|
108
|
+
return (tx: Transaction) =>
|
|
109
|
+
tx.moveCall({
|
|
110
|
+
package: packageAddress,
|
|
111
|
+
module: 'protocol_fees',
|
|
112
|
+
function: 'referral_tracker',
|
|
113
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
export interface TotalSharesArguments {
|
|
117
|
+
self: TransactionArgument;
|
|
118
|
+
}
|
|
119
|
+
export interface TotalSharesOptions {
|
|
120
|
+
package?: string;
|
|
121
|
+
arguments: TotalSharesArguments | [self: TransactionArgument];
|
|
122
|
+
}
|
|
123
|
+
export function totalShares(options: TotalSharesOptions) {
|
|
124
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
125
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
126
|
+
const parameterNames = ['self'];
|
|
127
|
+
return (tx: Transaction) =>
|
|
128
|
+
tx.moveCall({
|
|
129
|
+
package: packageAddress,
|
|
130
|
+
module: 'protocol_fees',
|
|
131
|
+
function: 'total_shares',
|
|
132
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
export interface FeesPerShareArguments {
|
|
136
|
+
self: TransactionArgument;
|
|
137
|
+
}
|
|
138
|
+
export interface FeesPerShareOptions {
|
|
139
|
+
package?: string;
|
|
140
|
+
arguments: FeesPerShareArguments | [self: TransactionArgument];
|
|
141
|
+
}
|
|
142
|
+
export function feesPerShare(options: FeesPerShareOptions) {
|
|
143
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
144
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
145
|
+
const parameterNames = ['self'];
|
|
146
|
+
return (tx: Transaction) =>
|
|
147
|
+
tx.moveCall({
|
|
148
|
+
package: packageAddress,
|
|
149
|
+
module: 'protocol_fees',
|
|
150
|
+
function: 'fees_per_share',
|
|
151
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
152
|
+
});
|
|
153
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Token Bucket rate limiter for controlling withdrawal rates. Reference:
|
|
7
|
+
* https://github.com/code-423n4/2024-11-chainlink/blob/main/contracts/src/ccip/libraries/RateLimiter.sol
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { MoveStruct, normalizeMoveArguments } from '../utils/index.js';
|
|
11
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
12
|
+
import { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';
|
|
13
|
+
const $moduleName = '@deepbook/margin::rate_limiter';
|
|
14
|
+
export const RateLimiter = new MoveStruct({
|
|
15
|
+
name: `${$moduleName}::RateLimiter`,
|
|
16
|
+
fields: {
|
|
17
|
+
available: bcs.u64(),
|
|
18
|
+
last_updated_ms: bcs.u64(),
|
|
19
|
+
capacity: bcs.u64(),
|
|
20
|
+
refill_rate_per_ms: bcs.u64(),
|
|
21
|
+
enabled: bcs.bool(),
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
export interface IsEnabledArguments {
|
|
25
|
+
self: TransactionArgument;
|
|
26
|
+
}
|
|
27
|
+
export interface IsEnabledOptions {
|
|
28
|
+
package?: string;
|
|
29
|
+
arguments: IsEnabledArguments | [self: TransactionArgument];
|
|
30
|
+
}
|
|
31
|
+
export function isEnabled(options: IsEnabledOptions) {
|
|
32
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
33
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
34
|
+
const parameterNames = ['self'];
|
|
35
|
+
return (tx: Transaction) =>
|
|
36
|
+
tx.moveCall({
|
|
37
|
+
package: packageAddress,
|
|
38
|
+
module: 'rate_limiter',
|
|
39
|
+
function: 'is_enabled',
|
|
40
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
export interface CapacityArguments {
|
|
44
|
+
self: TransactionArgument;
|
|
45
|
+
}
|
|
46
|
+
export interface CapacityOptions {
|
|
47
|
+
package?: string;
|
|
48
|
+
arguments: CapacityArguments | [self: TransactionArgument];
|
|
49
|
+
}
|
|
50
|
+
export function capacity(options: CapacityOptions) {
|
|
51
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
52
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
53
|
+
const parameterNames = ['self'];
|
|
54
|
+
return (tx: Transaction) =>
|
|
55
|
+
tx.moveCall({
|
|
56
|
+
package: packageAddress,
|
|
57
|
+
module: 'rate_limiter',
|
|
58
|
+
function: 'capacity',
|
|
59
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
export interface RefillRatePerMsArguments {
|
|
63
|
+
self: TransactionArgument;
|
|
64
|
+
}
|
|
65
|
+
export interface RefillRatePerMsOptions {
|
|
66
|
+
package?: string;
|
|
67
|
+
arguments: RefillRatePerMsArguments | [self: TransactionArgument];
|
|
68
|
+
}
|
|
69
|
+
export function refillRatePerMs(options: RefillRatePerMsOptions) {
|
|
70
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
71
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
72
|
+
const parameterNames = ['self'];
|
|
73
|
+
return (tx: Transaction) =>
|
|
74
|
+
tx.moveCall({
|
|
75
|
+
package: packageAddress,
|
|
76
|
+
module: 'rate_limiter',
|
|
77
|
+
function: 'refill_rate_per_ms',
|
|
78
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
79
|
+
});
|
|
80
|
+
}
|