@typus/typus-perp-sdk 1.1.32-codegen → 1.1.32-codegen-exp2
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/dist/src/fetch.d.ts +390 -43
- package/dist/src/fetch.js +25 -12
- package/dist/src/generated/utils/index.d.ts +0 -1
- package/package.json +45 -45
package/dist/src/fetch.d.ts
CHANGED
|
@@ -1,56 +1,344 @@
|
|
|
1
1
|
import { TOKEN } from "@typus/typus-sdk/dist/src/constants";
|
|
2
|
-
import { Markets, SymbolMarket } from "./generated/typus_perp/trading";
|
|
3
|
-
import { DeactivatingShares } from "./generated/typus_perp/lp_pool";
|
|
4
2
|
import { Position } from "./generated/typus_perp/position";
|
|
5
|
-
import { LiquidityPool } from "./generated/typus_perp/lp_pool";
|
|
6
|
-
import { LpUserShare, StakePool } from "./generated/typus_stake_pool/stake_pool";
|
|
7
|
-
import { TypusBidReceipt } from "./generated/typus_perp/deps/typus_framework/vault";
|
|
8
3
|
import { TypusClient } from "../src/client";
|
|
9
|
-
|
|
10
|
-
export declare function getLpPools(client: TypusClient): Promise<InferType<typeof LiquidityPool>[]>;
|
|
11
|
-
export declare function getLpPool(client: TypusClient, objectId: string): Promise<InferType<typeof LiquidityPool>>;
|
|
12
|
-
export declare function getStakePools(client: TypusClient): Promise<InferType<typeof StakePool>[]>;
|
|
13
|
-
export declare function getStakePool(client: TypusClient, objectId: string): Promise<InferType<typeof StakePool>>;
|
|
14
|
-
export interface MarketsData {
|
|
15
|
-
markets: InferType<typeof Markets>;
|
|
16
|
-
symbolMarkets: InferType<typeof SymbolMarket>[];
|
|
17
|
-
}
|
|
18
|
-
export declare function getMarkets(client: TypusClient, input: {
|
|
19
|
-
indexes: string[];
|
|
20
|
-
}): Promise<MarketsData[]>;
|
|
21
|
-
export declare function getUserOrders(client: TypusClient, input: {
|
|
22
|
-
user: string;
|
|
23
|
-
indexes: string[];
|
|
24
|
-
}): Promise<{
|
|
4
|
+
export declare function getLpPools(client: TypusClient): Promise<{
|
|
25
5
|
id: {
|
|
26
6
|
id: string;
|
|
27
7
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
linked_position_id: string | null;
|
|
31
|
-
user: string;
|
|
32
|
-
collateral_token: {
|
|
8
|
+
index: string;
|
|
9
|
+
lp_token_type: {
|
|
33
10
|
name: string;
|
|
34
11
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
12
|
+
liquidity_tokens: {
|
|
13
|
+
name: string;
|
|
14
|
+
}[];
|
|
15
|
+
token_pools: {
|
|
16
|
+
token_type: {
|
|
38
17
|
name: string;
|
|
39
18
|
};
|
|
40
|
-
|
|
19
|
+
config: {
|
|
20
|
+
oracle_id: string;
|
|
21
|
+
liquidity_token_decimal: string;
|
|
22
|
+
spot_config: {
|
|
23
|
+
min_deposit: string;
|
|
24
|
+
max_capacity: string;
|
|
25
|
+
target_weight_bp: string;
|
|
26
|
+
basic_mint_fee_bp: string;
|
|
27
|
+
additional_mint_fee_bp: string;
|
|
28
|
+
basic_burn_fee_bp: string;
|
|
29
|
+
additional_burn_fee_bp: string;
|
|
30
|
+
swap_fee_bp: string;
|
|
31
|
+
swap_fee_protocol_share_bp: string;
|
|
32
|
+
lending_protocol_share_bp: string;
|
|
33
|
+
u64_padding: string[];
|
|
34
|
+
};
|
|
35
|
+
margin_config: {
|
|
36
|
+
basic_borrow_rate_0: string;
|
|
37
|
+
basic_borrow_rate_1: string;
|
|
38
|
+
basic_borrow_rate_2: string;
|
|
39
|
+
utilization_threshold_bp_0: string;
|
|
40
|
+
utilization_threshold_bp_1: string;
|
|
41
|
+
borrow_interval_ts_ms: string;
|
|
42
|
+
max_order_reserve_ratio_bp: string;
|
|
43
|
+
u64_padding: string[];
|
|
44
|
+
};
|
|
45
|
+
u64_padding: string[];
|
|
46
|
+
};
|
|
47
|
+
state: {
|
|
48
|
+
liquidity_amount: string;
|
|
49
|
+
value_in_usd: string;
|
|
50
|
+
reserved_amount: string;
|
|
51
|
+
update_ts_ms: string;
|
|
52
|
+
is_active: boolean;
|
|
53
|
+
last_borrow_rate_ts_ms: string;
|
|
54
|
+
cumulative_borrow_rate: string;
|
|
55
|
+
previous_last_borrow_rate_ts_ms: string;
|
|
56
|
+
previous_cumulative_borrow_rate: string;
|
|
57
|
+
current_lending_amount: string[];
|
|
58
|
+
u64_padding: string[];
|
|
59
|
+
};
|
|
60
|
+
}[];
|
|
61
|
+
pool_info: {
|
|
62
|
+
lp_token_decimal: string;
|
|
63
|
+
total_share_supply: string;
|
|
64
|
+
tvl_usd: string;
|
|
65
|
+
is_active: boolean;
|
|
66
|
+
};
|
|
67
|
+
liquidated_unsettled_receipts: {
|
|
68
|
+
receipt: {
|
|
69
|
+
id: {
|
|
70
|
+
id: string;
|
|
71
|
+
};
|
|
72
|
+
vid: string;
|
|
73
|
+
index: string;
|
|
74
|
+
metadata: string;
|
|
75
|
+
u64_padding: string[];
|
|
76
|
+
}[];
|
|
77
|
+
position_id: string;
|
|
78
|
+
user: string;
|
|
79
|
+
token_types: {
|
|
80
|
+
name: string;
|
|
81
|
+
}[];
|
|
82
|
+
unrealized_pnl_sign: boolean;
|
|
83
|
+
unrealized_pnl: string;
|
|
84
|
+
unrealized_trading_fee: string;
|
|
85
|
+
unrealized_borrow_fee: string;
|
|
86
|
+
unrealized_funding_fee_sign: boolean;
|
|
87
|
+
unrealized_funding_fee: string;
|
|
88
|
+
unrealized_liquidator_fee: string;
|
|
89
|
+
}[];
|
|
90
|
+
u64_padding: string[];
|
|
91
|
+
bcs_padding: number[];
|
|
92
|
+
}[]>;
|
|
93
|
+
export declare function getLpPool(client: TypusClient, objectId: string): Promise<{
|
|
94
|
+
id: {
|
|
95
|
+
id: string;
|
|
96
|
+
};
|
|
97
|
+
index: string;
|
|
98
|
+
lp_token_type: {
|
|
99
|
+
name: string;
|
|
100
|
+
};
|
|
101
|
+
liquidity_tokens: {
|
|
102
|
+
name: string;
|
|
103
|
+
}[];
|
|
104
|
+
token_pools: {
|
|
105
|
+
token_type: {
|
|
41
106
|
name: string;
|
|
42
107
|
};
|
|
108
|
+
config: {
|
|
109
|
+
oracle_id: string;
|
|
110
|
+
liquidity_token_decimal: string;
|
|
111
|
+
spot_config: {
|
|
112
|
+
min_deposit: string;
|
|
113
|
+
max_capacity: string;
|
|
114
|
+
target_weight_bp: string;
|
|
115
|
+
basic_mint_fee_bp: string;
|
|
116
|
+
additional_mint_fee_bp: string;
|
|
117
|
+
basic_burn_fee_bp: string;
|
|
118
|
+
additional_burn_fee_bp: string;
|
|
119
|
+
swap_fee_bp: string;
|
|
120
|
+
swap_fee_protocol_share_bp: string;
|
|
121
|
+
lending_protocol_share_bp: string;
|
|
122
|
+
u64_padding: string[];
|
|
123
|
+
};
|
|
124
|
+
margin_config: {
|
|
125
|
+
basic_borrow_rate_0: string;
|
|
126
|
+
basic_borrow_rate_1: string;
|
|
127
|
+
basic_borrow_rate_2: string;
|
|
128
|
+
utilization_threshold_bp_0: string;
|
|
129
|
+
utilization_threshold_bp_1: string;
|
|
130
|
+
borrow_interval_ts_ms: string;
|
|
131
|
+
max_order_reserve_ratio_bp: string;
|
|
132
|
+
u64_padding: string[];
|
|
133
|
+
};
|
|
134
|
+
u64_padding: string[];
|
|
135
|
+
};
|
|
136
|
+
state: {
|
|
137
|
+
liquidity_amount: string;
|
|
138
|
+
value_in_usd: string;
|
|
139
|
+
reserved_amount: string;
|
|
140
|
+
update_ts_ms: string;
|
|
141
|
+
is_active: boolean;
|
|
142
|
+
last_borrow_rate_ts_ms: string;
|
|
143
|
+
cumulative_borrow_rate: string;
|
|
144
|
+
previous_last_borrow_rate_ts_ms: string;
|
|
145
|
+
previous_cumulative_borrow_rate: string;
|
|
146
|
+
current_lending_amount: string[];
|
|
147
|
+
u64_padding: string[];
|
|
148
|
+
};
|
|
149
|
+
}[];
|
|
150
|
+
pool_info: {
|
|
151
|
+
lp_token_decimal: string;
|
|
152
|
+
total_share_supply: string;
|
|
153
|
+
tvl_usd: string;
|
|
154
|
+
is_active: boolean;
|
|
43
155
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
156
|
+
liquidated_unsettled_receipts: {
|
|
157
|
+
receipt: {
|
|
158
|
+
id: {
|
|
159
|
+
id: string;
|
|
160
|
+
};
|
|
161
|
+
vid: string;
|
|
162
|
+
index: string;
|
|
163
|
+
metadata: string;
|
|
164
|
+
u64_padding: string[];
|
|
165
|
+
}[];
|
|
166
|
+
position_id: string;
|
|
167
|
+
user: string;
|
|
168
|
+
token_types: {
|
|
169
|
+
name: string;
|
|
170
|
+
}[];
|
|
171
|
+
unrealized_pnl_sign: boolean;
|
|
172
|
+
unrealized_pnl: string;
|
|
173
|
+
unrealized_trading_fee: string;
|
|
174
|
+
unrealized_borrow_fee: string;
|
|
175
|
+
unrealized_funding_fee_sign: boolean;
|
|
176
|
+
unrealized_funding_fee: string;
|
|
177
|
+
unrealized_liquidator_fee: string;
|
|
178
|
+
}[];
|
|
179
|
+
u64_padding: string[];
|
|
180
|
+
bcs_padding: number[];
|
|
181
|
+
}>;
|
|
182
|
+
export declare function getStakePools(client: TypusClient): Promise<{
|
|
183
|
+
id: {
|
|
184
|
+
id: string;
|
|
185
|
+
};
|
|
186
|
+
pool_info: {
|
|
187
|
+
stake_token: {
|
|
188
|
+
name: string;
|
|
189
|
+
};
|
|
190
|
+
index: string;
|
|
191
|
+
next_user_share_id: string;
|
|
192
|
+
total_share: string;
|
|
193
|
+
active: boolean;
|
|
194
|
+
u64_padding: string[];
|
|
195
|
+
};
|
|
196
|
+
config: {
|
|
197
|
+
unlock_countdown_ts_ms: string;
|
|
198
|
+
u64_padding: string[];
|
|
199
|
+
};
|
|
200
|
+
incentives: {
|
|
201
|
+
token_type: {
|
|
202
|
+
name: string;
|
|
203
|
+
};
|
|
204
|
+
config: {
|
|
205
|
+
period_incentive_amount: string;
|
|
206
|
+
incentive_interval_ts_ms: string;
|
|
207
|
+
u64_padding: string[];
|
|
208
|
+
};
|
|
209
|
+
info: {
|
|
210
|
+
active: boolean;
|
|
211
|
+
last_allocate_ts_ms: string;
|
|
212
|
+
incentive_price_index: string;
|
|
213
|
+
unallocated_amount: string;
|
|
214
|
+
u64_padding: string[];
|
|
215
|
+
};
|
|
216
|
+
}[];
|
|
52
217
|
u64_padding: string[];
|
|
53
218
|
}[]>;
|
|
219
|
+
export declare function getStakePool(client: TypusClient, objectId: string): Promise<{
|
|
220
|
+
id: {
|
|
221
|
+
id: string;
|
|
222
|
+
};
|
|
223
|
+
pool_info: {
|
|
224
|
+
stake_token: {
|
|
225
|
+
name: string;
|
|
226
|
+
};
|
|
227
|
+
index: string;
|
|
228
|
+
next_user_share_id: string;
|
|
229
|
+
total_share: string;
|
|
230
|
+
active: boolean;
|
|
231
|
+
u64_padding: string[];
|
|
232
|
+
};
|
|
233
|
+
config: {
|
|
234
|
+
unlock_countdown_ts_ms: string;
|
|
235
|
+
u64_padding: string[];
|
|
236
|
+
};
|
|
237
|
+
incentives: {
|
|
238
|
+
token_type: {
|
|
239
|
+
name: string;
|
|
240
|
+
};
|
|
241
|
+
config: {
|
|
242
|
+
period_incentive_amount: string;
|
|
243
|
+
incentive_interval_ts_ms: string;
|
|
244
|
+
u64_padding: string[];
|
|
245
|
+
};
|
|
246
|
+
info: {
|
|
247
|
+
active: boolean;
|
|
248
|
+
last_allocate_ts_ms: string;
|
|
249
|
+
incentive_price_index: string;
|
|
250
|
+
unallocated_amount: string;
|
|
251
|
+
u64_padding: string[];
|
|
252
|
+
};
|
|
253
|
+
}[];
|
|
254
|
+
u64_padding: string[];
|
|
255
|
+
}>;
|
|
256
|
+
/**
|
|
257
|
+
* @returns [Markets, SymbolMarket[]][]
|
|
258
|
+
*/
|
|
259
|
+
export declare function getMarkets(client: TypusClient, input: {
|
|
260
|
+
indexes: string[];
|
|
261
|
+
}): Promise<[{
|
|
262
|
+
id: {
|
|
263
|
+
id: string;
|
|
264
|
+
};
|
|
265
|
+
index: string;
|
|
266
|
+
lp_token_type: {
|
|
267
|
+
name: string;
|
|
268
|
+
};
|
|
269
|
+
quote_token_type: {
|
|
270
|
+
name: string;
|
|
271
|
+
};
|
|
272
|
+
is_active: boolean;
|
|
273
|
+
protocol_fee_share_bp: string;
|
|
274
|
+
symbols: {
|
|
275
|
+
name: string;
|
|
276
|
+
}[];
|
|
277
|
+
symbol_markets: {
|
|
278
|
+
id: {
|
|
279
|
+
id: string;
|
|
280
|
+
};
|
|
281
|
+
size: string;
|
|
282
|
+
};
|
|
283
|
+
u64_padding: string[];
|
|
284
|
+
}, {
|
|
285
|
+
id: {
|
|
286
|
+
id: string;
|
|
287
|
+
};
|
|
288
|
+
user_positions: {
|
|
289
|
+
id: {
|
|
290
|
+
id: string;
|
|
291
|
+
};
|
|
292
|
+
key_type: {
|
|
293
|
+
name: string;
|
|
294
|
+
};
|
|
295
|
+
value_type: {
|
|
296
|
+
name: string;
|
|
297
|
+
};
|
|
298
|
+
slice_idx: number;
|
|
299
|
+
slice_size: number;
|
|
300
|
+
length: string;
|
|
301
|
+
};
|
|
302
|
+
token_collateral_orders: {
|
|
303
|
+
id: string;
|
|
304
|
+
};
|
|
305
|
+
option_collateral_orders: {
|
|
306
|
+
id: string;
|
|
307
|
+
};
|
|
308
|
+
market_info: {
|
|
309
|
+
is_active: boolean;
|
|
310
|
+
size_decimal: string;
|
|
311
|
+
user_long_position_size: string;
|
|
312
|
+
user_short_position_size: string;
|
|
313
|
+
next_position_id: string;
|
|
314
|
+
user_long_order_size: string;
|
|
315
|
+
user_short_order_size: string;
|
|
316
|
+
next_order_id: string;
|
|
317
|
+
last_funding_ts_ms: string;
|
|
318
|
+
cumulative_funding_rate_index_sign: boolean;
|
|
319
|
+
cumulative_funding_rate_index: string;
|
|
320
|
+
previous_last_funding_ts_ms: string;
|
|
321
|
+
previous_cumulative_funding_rate_index_sign: boolean;
|
|
322
|
+
previous_cumulative_funding_rate_index: string;
|
|
323
|
+
u64_padding: string[];
|
|
324
|
+
};
|
|
325
|
+
market_config: {
|
|
326
|
+
oracle_id: string;
|
|
327
|
+
max_leverage_mbp: string;
|
|
328
|
+
option_collateral_max_leverage_mbp: string;
|
|
329
|
+
min_size: string;
|
|
330
|
+
lot_size: string;
|
|
331
|
+
trading_fee_config: string[];
|
|
332
|
+
basic_funding_rate: string;
|
|
333
|
+
funding_interval_ts_ms: string;
|
|
334
|
+
exp_multiplier: string;
|
|
335
|
+
u64_padding: string[];
|
|
336
|
+
};
|
|
337
|
+
}[]][]>;
|
|
338
|
+
export declare function getUserOrders(client: TypusClient, input: {
|
|
339
|
+
user: string;
|
|
340
|
+
indexes: string[];
|
|
341
|
+
}): Promise<void>;
|
|
54
342
|
export declare function getUserPositions(client: TypusClient, input: {
|
|
55
343
|
user: string;
|
|
56
344
|
indexes: string[];
|
|
@@ -99,26 +387,41 @@ export declare function getUserPositions(client: TypusClient, input: {
|
|
|
99
387
|
} | null;
|
|
100
388
|
u64_padding: string[];
|
|
101
389
|
}[]>;
|
|
102
|
-
export declare function parseOptionBidReceipts(positions:
|
|
390
|
+
export declare function parseOptionBidReceipts(positions: (typeof Position.$inferType)[]): ({
|
|
391
|
+
id: {
|
|
392
|
+
id: string;
|
|
393
|
+
};
|
|
394
|
+
vid: string;
|
|
395
|
+
index: string;
|
|
396
|
+
metadata: string;
|
|
397
|
+
u64_padding: string[];
|
|
398
|
+
} | null)[];
|
|
103
399
|
/**
|
|
104
400
|
* @returns [lpShare, incentives][]
|
|
105
401
|
*/
|
|
106
402
|
export declare function getUserStake(client: TypusClient, input: {
|
|
107
403
|
user: string;
|
|
108
404
|
indexes: string[];
|
|
109
|
-
}): Promise<[
|
|
405
|
+
}): Promise<any[]>;
|
|
110
406
|
/**
|
|
111
407
|
* @returns deactivatingShares[]
|
|
112
408
|
*/
|
|
113
409
|
export declare function getDeactivatingShares(client: TypusClient, input: {
|
|
114
410
|
user: string;
|
|
115
411
|
indexes: string[];
|
|
116
|
-
}): Promise<
|
|
412
|
+
}): Promise<{
|
|
413
|
+
balance: {
|
|
414
|
+
value: string;
|
|
415
|
+
};
|
|
416
|
+
redeem_ts_ms: string;
|
|
417
|
+
unlock_ts_ms: string;
|
|
418
|
+
u64_padding: string[];
|
|
419
|
+
}[]>;
|
|
117
420
|
/**
|
|
118
421
|
* @returns [liquidationPrice, pnl(in USD)]
|
|
119
422
|
*/
|
|
120
423
|
export declare function getLiquidationPriceAndPnl(client: TypusClient, input: {
|
|
121
|
-
positions:
|
|
424
|
+
positions: (typeof Position.$inferType)[];
|
|
122
425
|
}): Promise<PositionInfo[]>;
|
|
123
426
|
interface PositionInfo {
|
|
124
427
|
liquidationPrice: number;
|
|
@@ -184,5 +487,49 @@ export declare function getAllPositions(client: TypusClient, input: {
|
|
|
184
487
|
export declare function getAllPositionsWithTradingSymbol(client: TypusClient, input: {
|
|
185
488
|
baseToken: TOKEN;
|
|
186
489
|
marketIndex: string;
|
|
187
|
-
}): Promise<
|
|
490
|
+
}): Promise<{
|
|
491
|
+
id: {
|
|
492
|
+
id: string;
|
|
493
|
+
};
|
|
494
|
+
create_ts_ms: string;
|
|
495
|
+
position_id: string;
|
|
496
|
+
linked_order_ids: string[];
|
|
497
|
+
linked_order_prices: string[];
|
|
498
|
+
user: string;
|
|
499
|
+
is_long: boolean;
|
|
500
|
+
size: string;
|
|
501
|
+
size_decimal: string;
|
|
502
|
+
collateral_token: {
|
|
503
|
+
name: string;
|
|
504
|
+
};
|
|
505
|
+
collateral_token_decimal: string;
|
|
506
|
+
symbol: {
|
|
507
|
+
base_token: {
|
|
508
|
+
name: string;
|
|
509
|
+
};
|
|
510
|
+
quote_token: {
|
|
511
|
+
name: string;
|
|
512
|
+
};
|
|
513
|
+
};
|
|
514
|
+
collateral_amount: string;
|
|
515
|
+
reserve_amount: string;
|
|
516
|
+
average_price: string;
|
|
517
|
+
entry_borrow_index: string;
|
|
518
|
+
entry_funding_rate_index_sign: boolean;
|
|
519
|
+
entry_funding_rate_index: string;
|
|
520
|
+
unrealized_loss: string;
|
|
521
|
+
unrealized_funding_sign: boolean;
|
|
522
|
+
unrealized_funding_fee: string;
|
|
523
|
+
unrealized_trading_fee: string;
|
|
524
|
+
unrealized_borrow_fee: string;
|
|
525
|
+
unrealized_rebate: string;
|
|
526
|
+
option_collateral_info: {
|
|
527
|
+
index: string;
|
|
528
|
+
bid_token: {
|
|
529
|
+
name: string;
|
|
530
|
+
};
|
|
531
|
+
bid_receipts_bcs: number[][];
|
|
532
|
+
} | null;
|
|
533
|
+
u64_padding: string[];
|
|
534
|
+
}[]>;
|
|
188
535
|
export {};
|
package/dist/src/fetch.js
CHANGED
|
@@ -59,7 +59,7 @@ async function getStakePools(client) {
|
|
|
59
59
|
// let dynamicFields = await client.getDynamicFields({
|
|
60
60
|
// parentId: STAKE_POOL,
|
|
61
61
|
// });
|
|
62
|
-
// let stakePools: (
|
|
62
|
+
// let stakePools: (typeof StakePool.$inferType)[] = [];
|
|
63
63
|
// for (const field of dynamicFields.data) {
|
|
64
64
|
// let stakePool = await getStakePool(client, field.objectId);
|
|
65
65
|
// // console.log(stakePool);
|
|
@@ -84,6 +84,9 @@ async function getStakePool(client, objectId) {
|
|
|
84
84
|
const bcs = await client.getObjectBcs(objectId);
|
|
85
85
|
return stake_pool_1.StakePool.parse(bcs);
|
|
86
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* @returns [Markets, SymbolMarket[]][]
|
|
89
|
+
*/
|
|
87
90
|
async function getMarkets(client, input) {
|
|
88
91
|
let tx = new transactions_1.Transaction();
|
|
89
92
|
tx.add((0, trading_1.getMarketsBcs)({ arguments: { registry: _1.MARKET, indexes: input.indexes.map((x) => BigInt(x)) } }));
|
|
@@ -98,14 +101,14 @@ async function getMarkets(client, input) {
|
|
|
98
101
|
let length = reader.readULEB();
|
|
99
102
|
let bytes = reader.readBytes(length);
|
|
100
103
|
let markets = trading_1.Markets.parse(bytes);
|
|
101
|
-
results.push(
|
|
104
|
+
results.push([markets, []]);
|
|
102
105
|
marketIndex = i + markets.symbols.length + 1;
|
|
103
106
|
}
|
|
104
107
|
else {
|
|
105
108
|
let length = reader.readULEB();
|
|
106
109
|
let bytes = reader.readBytes(length);
|
|
107
110
|
let symbolMarket = trading_1.SymbolMarket.parse(bytes);
|
|
108
|
-
results[results.length - 1].
|
|
111
|
+
results[results.length - 1][1].push(symbolMarket);
|
|
109
112
|
}
|
|
110
113
|
});
|
|
111
114
|
return results;
|
|
@@ -124,20 +127,31 @@ async function getUserOrders(client, input) {
|
|
|
124
127
|
}
|
|
125
128
|
let res = await client.devInspectTransactionBlock({ sender: input.user, transactionBlock: tx });
|
|
126
129
|
// console.log(res);
|
|
127
|
-
|
|
128
|
-
for (var x = 0; x < input.indexes.length; x++) {
|
|
130
|
+
res.results?.map((x) => {
|
|
129
131
|
// @ts-ignore
|
|
130
|
-
let returnValues =
|
|
132
|
+
let returnValues = x.returnValues[0][0];
|
|
131
133
|
// console.log(returnValues);
|
|
132
134
|
let reader = new bcs_1.BcsReader(new Uint8Array(returnValues));
|
|
133
|
-
reader.readVec((reader) => {
|
|
135
|
+
let yy = reader.readVec((reader) => {
|
|
134
136
|
let length = reader.readULEB();
|
|
135
137
|
let bytes = reader.readBytes(length);
|
|
136
138
|
let order = position_1.TradingOrder.parse(bytes);
|
|
137
|
-
|
|
139
|
+
return order;
|
|
138
140
|
});
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
+
});
|
|
142
|
+
// for (var x = 0; x < input.indexes.length; x++) {
|
|
143
|
+
// // @ts-ignore
|
|
144
|
+
// let returnValues = res.results[x].returnValues[0][0];
|
|
145
|
+
// // console.log(returnValues);
|
|
146
|
+
// let reader = new BcsReader(new Uint8Array(returnValues));
|
|
147
|
+
// reader.readVec((reader) => {
|
|
148
|
+
// let length = reader.readULEB();
|
|
149
|
+
// let bytes = reader.readBytes(length);
|
|
150
|
+
// let order = TradingOrder.parse(bytes);
|
|
151
|
+
// orders.push(order);
|
|
152
|
+
// });
|
|
153
|
+
// }
|
|
154
|
+
// return orders;
|
|
141
155
|
}
|
|
142
156
|
async function getUserPositions(client, input) {
|
|
143
157
|
let tx = new transactions_1.Transaction();
|
|
@@ -393,7 +407,6 @@ async function getAllPositions(client, input) {
|
|
|
393
407
|
}
|
|
394
408
|
const SLICE = 100;
|
|
395
409
|
async function getAllPositionsWithTradingSymbol(client, input) {
|
|
396
|
-
var positions = [];
|
|
397
410
|
var { positions: pos, maxPage } = await getAllPositions(client, {
|
|
398
411
|
baseToken: input.baseToken,
|
|
399
412
|
slice: SLICE.toString(),
|
|
@@ -401,7 +414,7 @@ async function getAllPositionsWithTradingSymbol(client, input) {
|
|
|
401
414
|
marketIndex: input.marketIndex,
|
|
402
415
|
});
|
|
403
416
|
// console.log(maxPage);
|
|
404
|
-
positions =
|
|
417
|
+
var positions = pos;
|
|
405
418
|
for (let page = 2; page <= maxPage; page++) {
|
|
406
419
|
console.log(page);
|
|
407
420
|
var { positions: pos, maxPage } = await getAllPositions(client, {
|
|
@@ -9,4 +9,3 @@ export declare class MoveEnum<T extends Record<string, BcsType<any> | null>, con
|
|
|
9
9
|
}
|
|
10
10
|
export declare class MoveTuple<T extends readonly BcsType<any>[], const Name extends string> extends BcsTuple<T, Name> {
|
|
11
11
|
}
|
|
12
|
-
export type InferType<T extends BcsType<any, any>> = T["$inferType"];
|
package/package.json
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
2
|
+
"name": "@typus/typus-perp-sdk",
|
|
3
|
+
"version": "1.1.32-codegen-exp2",
|
|
4
|
+
"repository": "https://github.com/Typus-Lab/typus-perp-sdk.git",
|
|
5
|
+
"author": "Typus",
|
|
6
|
+
"description": "typus perp sdk",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@mysten/bcs": "1.9.2",
|
|
10
|
+
"@mysten/sui": "1.44.0",
|
|
11
|
+
"@typus/typus-sdk": "1.8.21"
|
|
12
|
+
},
|
|
13
|
+
"resolutions": {
|
|
14
|
+
"@mysten/bcs": "1.9.2",
|
|
15
|
+
"@mysten/sui": "1.44.0"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/bs58": "^4.0.1",
|
|
19
|
+
"@types/camelcase-keys-deep": "^0.1.2",
|
|
20
|
+
"@types/expect": "^24.3.0",
|
|
21
|
+
"@types/mocha": "^10.0.1",
|
|
22
|
+
"@types/node": "^24.10.1",
|
|
23
|
+
"@types/rx": "^4.1.2",
|
|
24
|
+
"axios": "^1.13.2",
|
|
25
|
+
"prettier": "^3.0.0",
|
|
26
|
+
"ts-node": "^10.9.2",
|
|
27
|
+
"tsc-alias": "^1.8.10",
|
|
28
|
+
"tsconfig-paths": "^4.2.0",
|
|
29
|
+
"tslint": "^6.1.3",
|
|
30
|
+
"tslint-config-prettier": "^1.18.0",
|
|
31
|
+
"typescript": "^5.1.6"
|
|
32
|
+
},
|
|
33
|
+
"main": "dist/src/index.js",
|
|
34
|
+
"types": "dist/src/index.d.ts",
|
|
35
|
+
"files": [
|
|
36
|
+
"dist"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json && tsc-alias"
|
|
40
|
+
},
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/Typus-Lab/typus-perp-sdk/issues"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/Typus-Lab/typus-perp-sdk#readme",
|
|
45
|
+
"packageManager": "yarn@4.10.3+sha512.c38cafb5c7bb273f3926d04e55e1d8c9dfa7d9c3ea1f36a4868fa028b9e5f72298f0b7f401ad5eb921749eb012eb1c3bb74bf7503df3ee43fd600d14a018266f"
|
|
46
|
+
}
|