@typus/typus-perp-sdk 1.1.32-codegen-exp21 → 1.1.32-codegen-exp23

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.
@@ -16,8 +16,8 @@ export interface Volume {
16
16
  timestamp: string;
17
17
  value: number;
18
18
  }
19
- export declare function getTlpFeeFromSentio(fromTimestamp?: number, toTimestamp?: number): Promise<number>;
20
- export declare function getTotalVolumeFromSentio(fromTimestamp?: number, toTimestamp?: number): Promise<number>;
19
+ export declare function getTlpFeeFromSentio(fromTimestamp?: number, toTimestamp?: number): Promise<Map<string, number>>;
20
+ export declare function getTotalVolumeFromSentio(fromTimestamp?: number, toTimestamp?: number): Promise<Map<string, number>>;
21
21
  /** Returns Accumulated Users */
22
22
  export declare function getAccumulatedUser(): Promise<number>;
23
23
  /**
@@ -25,12 +25,12 @@ export declare function getAccumulatedUser(): Promise<number>;
25
25
  * fromTimestamp: number, toTimestamp?: number
26
26
  *
27
27
  * Returns
28
- * { timestamp: string, value: number }[]
28
+ * Map<string, { timestamp: string; value: number }[]>
29
29
  */
30
- export declare function getTlpPriceFromSentio(fromTimestamp?: number, toTimestamp?: number): Promise<{
30
+ export declare function getTlpPriceFromSentio(fromTimestamp?: number, toTimestamp?: number): Promise<Map<string, {
31
31
  timestamp: string;
32
32
  value: number;
33
- }[]>;
33
+ }[]>>;
34
34
  export declare function getTlpComparisonFromSentio(startTimestamp: number, endTimestamp: number): Promise<tlpComparison[]>;
35
35
  interface tlpComparison {
36
36
  hour: string;
@@ -263,13 +263,47 @@ async function getTlpFeeFromSentio(fromTimestamp, toTimestamp) {
263
263
  grouping: [],
264
264
  },
265
265
  functions: [],
266
+ color: "",
267
+ disabled: true,
268
+ },
269
+ dataSource: "METRICS",
270
+ sourceName: "",
271
+ },
272
+ {
273
+ metricsQuery: {
274
+ query: "tlp_fee_usd",
275
+ alias: "0",
276
+ id: "isolated_TYPUS",
277
+ labelSelector: {
278
+ base_token: "TYPUS",
279
+ },
280
+ aggregate: {
281
+ op: "SUM",
282
+ grouping: ["base_token"],
283
+ },
284
+ functions: [],
285
+ color: "",
266
286
  disabled: false,
267
287
  },
268
288
  dataSource: "METRICS",
269
289
  sourceName: "",
270
290
  },
271
291
  ],
272
- formulas: [],
292
+ formulas: [
293
+ {
294
+ expression: "a-isolated_TYPUS",
295
+ alias: "1",
296
+ id: "main",
297
+ disabled: false,
298
+ functions: [],
299
+ color: "",
300
+ },
301
+ ],
302
+ cachePolicy: {
303
+ noCache: false,
304
+ cacheTtlSecs: 43200,
305
+ cacheRefreshTtlSecs: 1800,
306
+ },
273
307
  };
274
308
  let jsonData = JSON.stringify(requestData);
275
309
  let response = await fetch(apiUrl, {
@@ -278,16 +312,18 @@ async function getTlpFeeFromSentio(fromTimestamp, toTimestamp) {
278
312
  body: jsonData,
279
313
  });
280
314
  let data = await response.json();
281
- // console.log(data);
315
+ // console.dir(data, { depth: null });
282
316
  // console.log(data.results[0].matrix.samples[0].values);
283
- let first = data.results[0].matrix.samples[0].values[0];
284
- let last = data.results[0].matrix.samples[0].values.at(-1);
285
- // console.log(first, last);
286
- let initial_value = fromTimestamp ? first.value : 0;
287
- // console.log(initial_value);
288
- let fee = last.value - initial_value;
289
- // console.log(fee);
290
- return fee;
317
+ let map = new Map();
318
+ data.results.forEach((result) => {
319
+ // console.dir(result, { depth: null });
320
+ let initial_value = fromTimestamp ? result.matrix.samples[0].values.at(0).value : 0;
321
+ // console.log(initial_value);
322
+ let value = result.matrix.samples[0].values.at(-1).value - initial_value;
323
+ // console.log(value);
324
+ map.set(result.alias, value);
325
+ });
326
+ return map;
291
327
  }
292
328
  async function getTotalVolumeFromSentio(fromTimestamp, toTimestamp) {
293
329
  let apiUrl = "https://app.sentio.xyz/api/v1/insights/typus/typus_perp/query";
@@ -297,7 +333,7 @@ async function getTotalVolumeFromSentio(fromTimestamp, toTimestamp) {
297
333
  end: `${toTimestamp ?? now()}`,
298
334
  step: 3600,
299
335
  },
300
- limit: 1,
336
+ limit: 20,
301
337
  queries: [
302
338
  {
303
339
  metricsQuery: {
@@ -311,13 +347,46 @@ async function getTotalVolumeFromSentio(fromTimestamp, toTimestamp) {
311
347
  },
312
348
  functions: [],
313
349
  color: "",
350
+ disabled: true,
351
+ },
352
+ dataSource: "METRICS",
353
+ sourceName: "",
354
+ },
355
+ {
356
+ metricsQuery: {
357
+ query: "trading_volume_usd",
358
+ alias: "0",
359
+ id: "isolated_TYPUS",
360
+ labelSelector: {
361
+ base_token: "TYPUS",
362
+ },
363
+ aggregate: {
364
+ op: "SUM",
365
+ grouping: ["base_token"],
366
+ },
367
+ functions: [],
368
+ color: "",
314
369
  disabled: false,
315
370
  },
316
371
  dataSource: "METRICS",
317
372
  sourceName: "",
318
373
  },
319
374
  ],
320
- formulas: [],
375
+ formulas: [
376
+ {
377
+ expression: "a-isolated_TYPUS",
378
+ alias: "1",
379
+ id: "main",
380
+ disabled: false,
381
+ functions: [],
382
+ color: "",
383
+ },
384
+ ],
385
+ cachePolicy: {
386
+ noCache: false,
387
+ cacheTtlSecs: 43200,
388
+ cacheRefreshTtlSecs: 1800,
389
+ },
321
390
  };
322
391
  let jsonData = JSON.stringify(requestData);
323
392
  let response = await fetch(apiUrl, {
@@ -326,12 +395,17 @@ async function getTotalVolumeFromSentio(fromTimestamp, toTimestamp) {
326
395
  body: jsonData,
327
396
  });
328
397
  let data = await response.json();
329
- // console.log(data.results[0].matrix.samples[0].values);
330
- let initial_value = fromTimestamp ? data.results[0].matrix.samples[0].values.at(0).value : 0;
331
- // console.log(initial_value);
332
- let result = data.results[0].matrix.samples[0].values.at(-1).value - initial_value;
333
- // console.log(result);
334
- return result;
398
+ // console.dir(data.results, { depth: null });
399
+ let map = new Map();
400
+ data.results.forEach((result) => {
401
+ // console.dir(result, { depth: null });
402
+ let initial_value = fromTimestamp ? result.matrix.samples[0].values.at(0).value : 0;
403
+ // console.log(initial_value);
404
+ let value = result.matrix.samples[0].values.at(-1).value - initial_value;
405
+ // console.log(value);
406
+ map.set(result.alias, value);
407
+ });
408
+ return map;
335
409
  }
336
410
  /** Returns Accumulated Users */
337
411
  async function getAccumulatedUser() {
@@ -389,10 +463,10 @@ async function getAccumulatedUser() {
389
463
  * fromTimestamp: number, toTimestamp?: number
390
464
  *
391
465
  * Returns
392
- * { timestamp: string, value: number }[]
466
+ * Map<string, { timestamp: string; value: number }[]>
393
467
  */
394
468
  async function getTlpPriceFromSentio(fromTimestamp, toTimestamp) {
395
- let apiUrl = "https://app.sentio.xyz/api/v1/insights/typus/typus_perp/query";
469
+ let apiUrl = "https://api.sentio.xyz/v1/insights/typus/typus_perp/query";
396
470
  let requestData = {
397
471
  timeRange: {
398
472
  start: `${fromTimestamp ?? 0}`,
@@ -417,6 +491,11 @@ async function getTlpPriceFromSentio(fromTimestamp, toTimestamp) {
417
491
  },
418
492
  ],
419
493
  formulas: [],
494
+ cachePolicy: {
495
+ noCache: false,
496
+ cacheTtlSecs: 43200,
497
+ cacheRefreshTtlSecs: 1800,
498
+ },
420
499
  };
421
500
  let jsonData = JSON.stringify(requestData);
422
501
  let response = await fetch(apiUrl, {
@@ -425,10 +504,14 @@ async function getTlpPriceFromSentio(fromTimestamp, toTimestamp) {
425
504
  body: jsonData,
426
505
  });
427
506
  let data = await response.json();
428
- // console.log(data);
507
+ // console.dir(data, { depth: null });
429
508
  let samples = data.results[0].matrix.samples;
430
509
  // console.log(samples[0].values);
431
- return samples[0].values;
510
+ let map = new Map();
511
+ samples.forEach((sample) => {
512
+ map.set(sample.metric.labels.index, sample.values);
513
+ });
514
+ return map;
432
515
  }
433
516
  async function getTlpComparisonFromSentio(startTimestamp, endTimestamp) {
434
517
  let apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_perp/sql/execute";
@@ -670,7 +753,7 @@ async function getLeaderboardFromSentio(startTs, endTs) {
670
753
  // getAccumulatedUser().then((x) => console.log(x));
671
754
  // getTradingVolumeFromSentio(1747008000, 1, 1747011600);
672
755
  // getTlpPriceFromSentio(0).then((x) => console.dir(x, { depth: null }));
673
- // getTotalVolumeFromSentio(0).then((x) => console.log(x));
756
+ // getTotalVolumeFromSentio().then((x) => console.log(x));
674
757
  // getTlpFeeFromSentio(0).then((x) => console.log(x));
675
758
  // getUserPnlFromSentio(parseTimestamp("2025-06-24 11:00:00"), parseTimestamp("2025-07-08 11:00:00")).then((x) => console.log(x));
676
759
  // getMinuteTradingVolumeFromSentio("SUI", 30, 10).then((x) => console.log(x));
package/dist/src/fetch.js CHANGED
@@ -306,9 +306,7 @@ async function getLiquidationPriceAndPnl(client, input) {
306
306
  (0, utils_1.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, token);
307
307
  }
308
308
  if (tokens.includes("TYPUS")) {
309
- // TODO: update oracle contract
310
- const oracleContract = input.oracle ?? "0x51fc5517f5ba4e3ba8862cd74c345e7294193c693ab41376694d1c516033e2e8";
311
- tx = await (0, utils_2.updateOracleWithSignatureTx)(_1.NETWORK, tx, oracleContract, constants_1.tokenType[_1.NETWORK]["TYPUS"]);
309
+ tx = await (0, utils_2.updateOracleWithSignatureTx)(_1.NETWORK, tx, client.config.package.oracle, constants_1.tokenType[_1.NETWORK]["TYPUS"]);
312
310
  }
313
311
  for (let position of input.positions) {
314
312
  // parse from Position
@@ -20,7 +20,6 @@ export declare function createTradingOrder(client: TypusClient, tx: Transaction,
20
20
  isStopOrder: boolean;
21
21
  reduceOnly: boolean;
22
22
  linkedPositionId: string | null;
23
- oracleContract?: string;
24
23
  suiCoins?: string[];
25
24
  }): Promise<Transaction>;
26
25
  export declare function zeroCoin(tx: Transaction, typeArgs: [string]): import("@mysten/sui/transactions").TransactionResult;
@@ -50,8 +50,7 @@ async function createTradingOrder(client, tx, input) {
50
50
  (0, utils_2.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, token);
51
51
  }
52
52
  if (tokens.includes("TYPUS")) {
53
- const oracleContract = input.oracleContract ?? "0x51fc5517f5ba4e3ba8862cd74c345e7294193c693ab41376694d1c516033e2e8";
54
- tx = await (0, utils_1.updateOracleWithSignatureTx)(__1.NETWORK, tx, oracleContract, constants_1.tokenType[__1.NETWORK]["TYPUS"]);
53
+ tx = await (0, utils_1.updateOracleWithSignatureTx)(__1.NETWORK, tx, client.config.package.oracle, constants_1.tokenType[__1.NETWORK]["TYPUS"]);
55
54
  }
56
55
  tx.add((0, trading_1.createTradingOrder)({
57
56
  arguments: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typus/typus-perp-sdk",
3
- "version": "1.1.32-codegen-exp21",
3
+ "version": "1.1.32-codegen-exp23",
4
4
  "repository": "https://github.com/Typus-Lab/typus-perp-sdk.git",
5
5
  "author": "Typus",
6
6
  "description": "typus perp sdk",
@@ -44,4 +44,4 @@
44
44
  },
45
45
  "homepage": "https://github.com/Typus-Lab/typus-perp-sdk#readme",
46
46
  "packageManager": "yarn@4.10.3+sha512.c38cafb5c7bb273f3926d04e55e1d8c9dfa7d9c3ea1f36a4868fa028b9e5f72298f0b7f401ad5eb921749eb012eb1c3bb74bf7503df3ee43fd600d14a018266f"
47
- }
47
+ }