@typus/typus-perp-sdk 1.1.53 → 1.2.0

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.
Files changed (76) hide show
  1. package/dist/src/api/sentio.js +2 -2
  2. package/dist/src/client.d.ts +13 -12
  3. package/dist/src/client.js +24 -49
  4. package/dist/src/fetch.d.ts +15 -61
  5. package/dist/src/fetch.js +63 -163
  6. package/dist/src/generated/typus_perp/admin.d.ts +32 -42
  7. package/dist/src/generated/typus_perp/admin.js +41 -67
  8. package/dist/src/generated/typus_perp/competition.d.ts +22 -10
  9. package/dist/src/generated/typus_perp/competition.js +19 -54
  10. package/dist/src/generated/typus_perp/deps/std/type_name.d.ts +2 -2
  11. package/dist/src/generated/typus_perp/deps/std/type_name.js +2 -2
  12. package/dist/src/generated/typus_perp/deps/sui/balance.d.ts +3 -3
  13. package/dist/src/generated/typus_perp/deps/sui/balance.js +3 -3
  14. package/dist/src/generated/typus_perp/deps/sui/object_table.d.ts +4 -6
  15. package/dist/src/generated/typus_perp/deps/sui/object_table.js +4 -38
  16. package/dist/src/generated/typus_perp/deps/sui/table.d.ts +4 -6
  17. package/dist/src/generated/typus_perp/deps/sui/table.js +4 -38
  18. package/dist/src/generated/typus_perp/deps/sui/vec_set.d.ts +2 -2
  19. package/dist/src/generated/typus_perp/deps/sui/vec_set.js +2 -2
  20. package/dist/src/generated/typus_perp/deps/typus/keyed_big_vector.d.ts +7 -9
  21. package/dist/src/generated/typus_perp/deps/typus/keyed_big_vector.js +6 -6
  22. package/dist/src/generated/typus_perp/deps/typus/linked_object_table.d.ts +6 -10
  23. package/dist/src/generated/typus_perp/deps/typus/linked_object_table.js +5 -39
  24. package/dist/src/generated/typus_perp/deps/typus_framework/vault.d.ts +14 -8
  25. package/dist/src/generated/typus_perp/deps/typus_framework/vault.js +13 -39
  26. package/dist/src/generated/typus_perp/error.d.ts +97 -87
  27. package/dist/src/generated/typus_perp/error.js +18 -0
  28. package/dist/src/generated/typus_perp/escrow.d.ts +17 -21
  29. package/dist/src/generated/typus_perp/escrow.js +10 -22
  30. package/dist/src/generated/typus_perp/lending.d.ts +47 -0
  31. package/dist/src/generated/typus_perp/lending.js +40 -0
  32. package/dist/src/generated/typus_perp/lp_pool.d.ts +718 -397
  33. package/dist/src/generated/typus_perp/lp_pool.js +485 -365
  34. package/dist/src/generated/typus_perp/math.d.ts +18 -8
  35. package/dist/src/generated/typus_perp/math.js +24 -6
  36. package/dist/src/generated/typus_perp/position.d.ts +207 -185
  37. package/dist/src/generated/typus_perp/position.js +236 -277
  38. package/dist/src/generated/typus_perp/profit_vault.d.ts +64 -72
  39. package/dist/src/generated/typus_perp/profit_vault.js +48 -86
  40. package/dist/src/generated/typus_perp/symbol.d.ts +6 -6
  41. package/dist/src/generated/typus_perp/symbol.js +11 -13
  42. package/dist/src/generated/typus_perp/trading.d.ts +451 -558
  43. package/dist/src/generated/typus_perp/trading.js +429 -681
  44. package/dist/src/generated/typus_perp/treasury_caps.d.ts +5 -7
  45. package/dist/src/generated/typus_perp/treasury_caps.js +8 -45
  46. package/dist/src/generated/typus_stake_pool/admin.d.ts +13 -122
  47. package/dist/src/generated/typus_stake_pool/admin.js +19 -103
  48. package/dist/src/generated/typus_stake_pool/deps/std/type_name.d.ts +2 -2
  49. package/dist/src/generated/typus_stake_pool/deps/std/type_name.js +2 -2
  50. package/dist/src/generated/typus_stake_pool/deps/sui/vec_set.d.ts +2 -2
  51. package/dist/src/generated/typus_stake_pool/deps/sui/vec_set.js +2 -2
  52. package/dist/src/generated/typus_stake_pool/stake_pool.d.ts +249 -240
  53. package/dist/src/generated/typus_stake_pool/stake_pool.js +159 -246
  54. package/dist/src/generated/utils/index.d.ts +21 -2
  55. package/dist/src/generated/utils/index.js +34 -10
  56. package/dist/src/index.js +4 -4
  57. package/dist/src/user/history.js +39 -23
  58. package/dist/src/user/order.d.ts +1 -1
  59. package/dist/src/user/orderWithBidReceipt.d.ts +1 -1
  60. package/package.json +8 -14
  61. package/dist/src/generated/typus_perp/deps/sui/object.d.ts +0 -8
  62. package/dist/src/generated/typus_perp/deps/sui/object.js +0 -16
  63. package/dist/src/generated/typus_perp/user_account.d.ts +0 -146
  64. package/dist/src/generated/typus_perp/user_account.js +0 -221
  65. package/dist/src/generated/typus_stake_pool/deps/sui/object.d.ts +0 -8
  66. package/dist/src/generated/typus_stake_pool/deps/sui/object.js +0 -16
  67. package/dist/src/generated/typus_stake_pool/deps/sui/vec_map.d.ts +0 -30
  68. package/dist/src/generated/typus_stake_pool/deps/sui/vec_map.js +0 -37
  69. package/dist/src/grpc/graphql.d.ts +0 -26
  70. package/dist/src/grpc/graphql.js +0 -126
  71. package/dist/src/grpc/grpc.d.ts +0 -1
  72. package/dist/src/grpc/grpc.js +0 -38
  73. package/dist/src/grpc/ledgerService.d.ts +0 -0
  74. package/dist/src/grpc/ledgerService.js +0 -64
  75. package/dist/src/grpc/liveDataService.d.ts +0 -0
  76. package/dist/src/grpc/liveDataService.js +0 -49
@@ -29,7 +29,7 @@ async function getFromSentio(event, userAddress, startTimestamp, endTimestamp, c
29
29
  sql: `
30
30
  SELECT *
31
31
  FROM ${event}
32
- WHERE distinct_id = '${userAddress}' AND timestamp >= ${startTimestamp} ${endTimestamp ? `AND timestamp <= ${endTimestamp}` : ''} ${crankerFilter}
32
+ WHERE distinct_id = '${userAddress}' AND timestamp >= ${startTimestamp} ${endTimestamp ? `AND timestamp <= ${endTimestamp}` : ""} ${crankerFilter}
33
33
  ORDER BY timestamp DESC;
34
34
  `,
35
35
  size: 1000,
@@ -788,7 +788,7 @@ async function getLeaderboardFromSentio(startTs, endTs, type = LeaderboardType.C
788
788
  t.rk ASC
789
789
  `,
790
790
  size,
791
- }
791
+ },
792
792
  };
793
793
  }
794
794
  let jsonData = JSON.stringify(requestData);
@@ -1,28 +1,29 @@
1
1
  import { SuiGraphQLClient } from "@mysten/sui/graphql";
2
2
  import { SuiGrpcClient } from "@mysten/sui/grpc";
3
- import { DevInspectTransactionBlockParams, ExecuteTransactionBlockParams, GetCoinsParams, GetDynamicFieldsParams, GetObjectParams, GetOwnedObjectsParams, MultiGetObjectsParams, QueryEventsParams, SuiClient } from "@mysten/sui/client";
4
3
  import { PythClient, TypusConfig } from "@typus/typus-sdk/dist/src/utils";
5
4
  import type { RpcTransport } from "@protobuf-ts/runtime-rpc";
5
+ import { SuiClientTypes } from "@mysten/sui/client";
6
6
  export type Network = "MAINNET" | "TESTNET";
7
7
  export declare class TypusClient {
8
- jsonRpcClient: SuiClient;
9
8
  gRpcClient: SuiGrpcClient;
10
9
  graphQLClient: SuiGraphQLClient;
11
10
  pythClient: PythClient;
12
11
  config: TypusConfig;
13
12
  constructor(config: TypusConfig, grpcTransport?: RpcTransport);
14
- getCoins(params: GetCoinsParams): Promise<import("@mysten/sui/client").PaginatedCoins>;
15
- getObject(params: GetObjectParams): Promise<import("@mysten/sui/client").SuiObjectResponse>;
16
- getOwnedObjects(params: GetOwnedObjectsParams): Promise<import("@mysten/sui/client").PaginatedObjectsResponse>;
17
- getDynamicFields(params: GetDynamicFieldsParams): Promise<import("@mysten/sui/client").DynamicFieldPage>;
18
- multiGetObjects(params: MultiGetObjectsParams): Promise<import("@mysten/sui/client").SuiObjectResponse[]>;
19
- devInspectTransactionBlock(params: DevInspectTransactionBlockParams): Promise<import("@mysten/sui/client").DevInspectResults>;
20
- executeTransactionBlock(params: ExecuteTransactionBlockParams): Promise<import("@mysten/sui/client").SuiTransactionBlockResponse>;
21
- signAndExecuteTransaction(params: any): Promise<import("@mysten/sui/client").SuiTransactionBlockResponse>;
22
- queryEvents(params: QueryEventsParams): Promise<import("@mysten/sui/client").PaginatedEvents>;
13
+ getCoins(params: SuiClientTypes.ListCoinsOptions): Promise<SuiClientTypes.ListCoinsResponse>;
14
+ getObject(params: SuiClientTypes.GetObjectOptions): Promise<SuiClientTypes.GetObjectResponse<{}>>;
15
+ getOwnedObjects(params: SuiClientTypes.ListOwnedObjectsOptions): Promise<SuiClientTypes.ListOwnedObjectsResponse<{}>>;
16
+ getDynamicFields(params: SuiClientTypes.ListDynamicFieldsOptions): Promise<SuiClientTypes.ListDynamicFieldsResponse>;
17
+ multiGetObjects(params: SuiClientTypes.GetObjectsOptions): Promise<SuiClientTypes.GetObjectsResponse<{}>>;
18
+ /**
19
+ * For view-function and dry-run transaction.
20
+ * dry-run need `tx.setSender(user)` to work, otherwise it will fail with "Invalid sender address" error
21
+ */
22
+ devInspectTransactionBlock(params: SuiClientTypes.SimulateTransactionOptions): Promise<SuiClientTypes.SimulateTransactionResult<{}>>;
23
+ executeTransactionBlock(params: SuiClientTypes.ExecuteTransactionOptions): Promise<SuiClientTypes.TransactionResult<{}>>;
24
+ signAndExecuteTransaction(params: SuiClientTypes.SignAndExecuteTransactionOptions): Promise<SuiClientTypes.TransactionResult<{}>>;
23
25
  getObjectBcs(objectId: string): Promise<Uint8Array<ArrayBufferLike> | undefined>;
24
26
  batchGetObjectsBcs(objectIds: string[]): Promise<(Uint8Array<ArrayBufferLike> | undefined)[]>;
25
27
  getDynamicFieldsBcs(parent: string): Promise<Uint8Array<ArrayBufferLike>[]>;
26
28
  getDynamicObjectFieldsBcs(parent: string): Promise<Uint8Array<ArrayBufferLike>[]>;
27
- simulateTransaction(transactionBcs: Uint8Array<ArrayBufferLike>): Promise<import("@mysten/sui/dist/cjs/experimental").Experimental_SuiClientTypes.DryRunTransactionResponse>;
28
29
  }
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TypusClient = void 0;
4
- const latest_1 = require("@mysten/sui/graphql/schemas/latest");
4
+ const schema_1 = require("@mysten/sui/graphql/schema");
5
5
  const graphql_1 = require("@mysten/sui/graphql");
6
6
  const grpc_1 = require("@mysten/sui/grpc");
7
- const client_1 = require("@mysten/sui/client");
8
7
  const utils_1 = require("@typus/typus-sdk/dist/src/utils");
9
- const grpcweb_transport_1 = require("@protobuf-ts/grpcweb-transport");
8
+ const jsonRpc_1 = require("@mysten/sui/jsonRpc");
10
9
  class TypusClient {
11
10
  // user: string;
12
11
  // mvr?: Experimental_SuiClientTypes.MvrOptions
@@ -25,68 +24,51 @@ class TypusClient {
25
24
  // },
26
25
  },
27
26
  };
28
- this.jsonRpcClient = new client_1.SuiClient({
29
- network: network,
30
- url: config.rpcEndpoint,
31
- mvr,
32
- });
33
27
  this.gRpcClient = new grpc_1.SuiGrpcClient({
34
28
  network: network,
35
- transport: grpcTransport ??
36
- new grpcweb_transport_1.GrpcWebFetchTransport({
37
- baseUrl: `https://fullnode.${network}.sui.io:443`,
38
- // Additional transport options
39
- }),
29
+ baseUrl: config.rpcEndpoint,
30
+ mvr,
40
31
  });
41
32
  this.graphQLClient = new graphql_1.SuiGraphQLClient({
42
33
  network: network,
43
34
  url: `https://graphql.${network}.sui.io/graphql`,
44
35
  mvr,
45
36
  });
46
- this.pythClient = (0, utils_1.createPythClient)(this.jsonRpcClient, this.config.network);
37
+ const jsonRpcClient = new jsonRpc_1.SuiJsonRpcClient({
38
+ network: network,
39
+ transport: new jsonRpc_1.JsonRpcHTTPTransport({ url: config.rpcEndpoint }),
40
+ });
41
+ this.pythClient = (0, utils_1.createPythClient)(jsonRpcClient, this.config.network);
47
42
  }
48
43
  getCoins(params) {
49
- return this.jsonRpcClient.getCoins(params);
44
+ return this.gRpcClient.listCoins(params);
50
45
  }
51
46
  getObject(params) {
52
- return this.jsonRpcClient.getObject(params);
47
+ return this.gRpcClient.getObject(params);
53
48
  }
54
49
  getOwnedObjects(params) {
55
- return this.jsonRpcClient.getOwnedObjects(params);
50
+ return this.gRpcClient.listOwnedObjects(params);
56
51
  }
57
52
  getDynamicFields(params) {
58
- return this.jsonRpcClient.getDynamicFields(params);
53
+ return this.gRpcClient.listDynamicFields(params);
59
54
  }
60
55
  multiGetObjects(params) {
61
- return this.jsonRpcClient.multiGetObjects(params);
56
+ return this.gRpcClient.getObjects(params);
62
57
  }
58
+ /**
59
+ * For view-function and dry-run transaction.
60
+ * dry-run need `tx.setSender(user)` to work, otherwise it will fail with "Invalid sender address" error
61
+ */
63
62
  devInspectTransactionBlock(params) {
64
- // this.gRpcClient.transactionExecutionService.simulateTransaction({ transaction: { bcs: { value: params.transactionBlock } } });
65
- return this.jsonRpcClient.devInspectTransactionBlock(params);
63
+ params.checksEnabled = false;
64
+ params.include = { commandResults: true, events: true };
65
+ return this.gRpcClient.simulateTransaction(params);
66
66
  }
67
67
  executeTransactionBlock(params) {
68
- // this.gRpcClient.transactionExecutionService.executeTransaction({
69
- // transaction: { bcs: { value: params.transactionBlock } },
70
- // signatures,
71
- // });
72
- // this.gRpcClient.transactionExecutionService.executeTransaction({
73
- // transaction: {
74
- // bcs: {
75
- // value: transactionBytes,
76
- // },
77
- // },
78
- // signatures: signatures.map((sig) => ({
79
- // bcs: { value: fromBase64(sig) },
80
- // signature: { oneofKind: undefined },
81
- // })),
82
- // });
83
- return this.jsonRpcClient.executeTransactionBlock(params);
68
+ return this.gRpcClient.executeTransaction(params);
84
69
  }
85
70
  signAndExecuteTransaction(params) {
86
- return this.jsonRpcClient.signAndExecuteTransaction(params);
87
- }
88
- queryEvents(params) {
89
- return this.jsonRpcClient.queryEvents(params);
71
+ return this.gRpcClient.signAndExecuteTransaction(params);
90
72
  }
91
73
  // gRPC
92
74
  async getObjectBcs(objectId) {
@@ -129,16 +111,9 @@ class TypusClient {
129
111
  return x_1.childObject?.contents?.value;
130
112
  });
131
113
  }
132
- simulateTransaction(transactionBcs) {
133
- return this.gRpcClient.core.dryRunTransaction({ transaction: transactionBcs });
134
- // return this.gRpcClient.transactionExecutionService.simulateTransaction({
135
- // transaction: { bcs: { value: transactionBcs } },
136
- // // checks: 1,
137
- // });
138
- }
139
114
  }
140
115
  exports.TypusClient = TypusClient;
141
- const dynamicFieldsQuery = (0, latest_1.graphql)(`
116
+ const dynamicFieldsQuery = (0, schema_1.graphql)(`
142
117
  query ($id: SuiAddress!) {
143
118
  address(address: $id) {
144
119
  dynamicFields {
@@ -2,9 +2,7 @@ import { TOKEN } from "@typus/typus-sdk/dist/src/constants";
2
2
  import { TradingOrder, Position } from "./generated/typus_perp/position";
3
3
  import { TypusClient } from "../src/client";
4
4
  export declare function getLpPools(client: TypusClient): Promise<{
5
- id: {
6
- id: string;
7
- };
5
+ id: string;
8
6
  index: string;
9
7
  lp_token_type: {
10
8
  name: string;
@@ -66,9 +64,7 @@ export declare function getLpPools(client: TypusClient): Promise<{
66
64
  };
67
65
  liquidated_unsettled_receipts: {
68
66
  receipt: {
69
- id: {
70
- id: string;
71
- };
67
+ id: string;
72
68
  vid: string;
73
69
  index: string;
74
70
  metadata: string;
@@ -91,9 +87,7 @@ export declare function getLpPools(client: TypusClient): Promise<{
91
87
  bcs_padding: number[];
92
88
  }[]>;
93
89
  export declare function getLpPool(client: TypusClient, objectId: string): Promise<{
94
- id: {
95
- id: string;
96
- };
90
+ id: string;
97
91
  index: string;
98
92
  lp_token_type: {
99
93
  name: string;
@@ -155,9 +149,7 @@ export declare function getLpPool(client: TypusClient, objectId: string): Promis
155
149
  };
156
150
  liquidated_unsettled_receipts: {
157
151
  receipt: {
158
- id: {
159
- id: string;
160
- };
152
+ id: string;
161
153
  vid: string;
162
154
  index: string;
163
155
  metadata: string;
@@ -180,9 +172,7 @@ export declare function getLpPool(client: TypusClient, objectId: string): Promis
180
172
  bcs_padding: number[];
181
173
  }>;
182
174
  export declare function getStakePools(client: TypusClient): Promise<{
183
- id: {
184
- id: string;
185
- };
175
+ id: string;
186
176
  pool_info: {
187
177
  stake_token: {
188
178
  name: string;
@@ -220,9 +210,7 @@ export declare function getStakePools(client: TypusClient): Promise<{
220
210
  u64_padding: string[];
221
211
  }[]>;
222
212
  export declare function getStakePool(client: TypusClient, objectId: string): Promise<{
223
- id: {
224
- id: string;
225
- };
213
+ id: string;
226
214
  pool_info: {
227
215
  stake_token: {
228
216
  name: string;
@@ -265,9 +253,7 @@ export declare function getStakePool(client: TypusClient, objectId: string): Pro
265
253
  export declare function getMarkets(client: TypusClient, input: {
266
254
  indexes: string[];
267
255
  }): Promise<[{
268
- id: {
269
- id: string;
270
- };
256
+ id: string;
271
257
  index: string;
272
258
  lp_token_type: {
273
259
  name: string;
@@ -281,20 +267,14 @@ export declare function getMarkets(client: TypusClient, input: {
281
267
  name: string;
282
268
  }[];
283
269
  symbol_markets: {
284
- id: {
285
- id: string;
286
- };
270
+ id: string;
287
271
  size: string;
288
272
  };
289
273
  u64_padding: string[];
290
274
  }, {
291
- id: {
292
- id: string;
293
- };
275
+ id: string;
294
276
  user_positions: {
295
- id: {
296
- id: string;
297
- };
277
+ id: string;
298
278
  key_type: {
299
279
  name: string;
300
280
  };
@@ -305,12 +285,8 @@ export declare function getMarkets(client: TypusClient, input: {
305
285
  slice_size: number;
306
286
  length: string;
307
287
  };
308
- token_collateral_orders: {
309
- id: string;
310
- };
311
- option_collateral_orders: {
312
- id: string;
313
- };
288
+ token_collateral_orders: string;
289
+ option_collateral_orders: string;
314
290
  market_info: {
315
291
  is_active: boolean;
316
292
  size_decimal: string;
@@ -359,9 +335,7 @@ export declare function getUserPositions(client: TypusClient, input: {
359
335
  indexes: string[];
360
336
  }): Promise<PositionWithMarketIndex[]>;
361
337
  export declare function parseOptionBidReceipts(positions: (typeof Position.$inferType)[]): ({
362
- id: {
363
- id: string;
364
- };
338
+ id: string;
365
339
  vid: string;
366
340
  index: string;
367
341
  metadata: string;
@@ -428,9 +402,7 @@ export declare function getAllPositions(client: TypusClient, input: {
428
402
  marketIndex: string;
429
403
  }): Promise<{
430
404
  positions: {
431
- id: {
432
- id: string;
433
- };
405
+ id: string;
434
406
  create_ts_ms: string;
435
407
  update_ts_ms: string;
436
408
  position_id: string;
@@ -479,9 +451,7 @@ export declare function getAllPositionsWithTradingSymbol(client: TypusClient, in
479
451
  baseToken: TOKEN;
480
452
  marketIndex: string;
481
453
  }): Promise<{
482
- id: {
483
- id: string;
484
- };
454
+ id: string;
485
455
  create_ts_ms: string;
486
456
  update_ts_ms: string;
487
457
  position_id: string;
@@ -541,25 +511,9 @@ export type LockedUserProfit = {
541
511
  create_ts_ms: string;
542
512
  };
543
513
  export declare function fetchUserProfits(client: TypusClient, input: {
544
- profitVault: string;
545
- version: string;
546
514
  user: string;
547
515
  }): Promise<UserProfit[]>;
548
516
  export declare function fetchLockedUserProfits(client: TypusClient, input: {
549
- lockVault: string;
550
- version: string;
551
517
  user: string;
552
518
  }): Promise<LockedUserProfit[]>;
553
- export declare function fetchAllUserProfits(client: TypusClient, input?: {
554
- profitVault?: string;
555
- }): Promise<{
556
- user: string;
557
- profits: UserProfit[];
558
- }[]>;
559
- export declare function fetchAllLockedUserProfits(client: TypusClient, input?: {
560
- lockVault?: string;
561
- }): Promise<{
562
- user: string;
563
- lockedUserProfits: LockedUserProfit[];
564
- }[]>;
565
519
  export {};