@typus/typus-perp-sdk 1.0.58 → 1.0.59-leaderboard-b

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.
@@ -1,10 +1,19 @@
1
1
  export declare function getFromSentio(event: string, userAddress: string, startTimestamp: string): Promise<any[]>;
2
- export declare function getVolumeFromSentio(): Promise<any[]>;
2
+ /**
3
+ * Inputs:
4
+ * day: number (at least 1)
5
+ * interval: in hour
6
+ *
7
+ * Returns Map<string, Volume[]>
8
+ * key: base_token {'APT','BTC','CETUS','DEEP','ETH','NAVX','NS','SOL','SUI','WAL'}
9
+ * value: Volume[]
10
+ */
11
+ export declare function getTradingVolumeFromSentio(fromTimestamp: number, interval: number, toTimestamp?: number): Promise<Map<string, Volume[]>>;
3
12
  export interface Volume {
4
13
  timestamp: string;
5
14
  value: number;
6
15
  }
7
16
  export declare function getTlpFeeFromSentio(): Promise<number>;
8
- export declare function getTotalVolumeFromSentio(): Promise<number>;
17
+ export declare function getTotalVolumeFromSentio(fromTimestamp: number, toTimestamp: number): Promise<number>;
9
18
  /** Returns Accumulated Users */
10
19
  export declare function getAccumulatedUser(): Promise<number>;
@@ -37,7 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.getFromSentio = getFromSentio;
40
- exports.getVolumeFromSentio = getVolumeFromSentio;
40
+ exports.getTradingVolumeFromSentio = getTradingVolumeFromSentio;
41
41
  exports.getTlpFeeFromSentio = getTlpFeeFromSentio;
42
42
  exports.getTotalVolumeFromSentio = getTotalVolumeFromSentio;
43
43
  exports.getAccumulatedUser = getAccumulatedUser;
@@ -84,9 +84,18 @@ function getFromSentio(event, userAddress, startTimestamp) {
84
84
  });
85
85
  });
86
86
  }
87
- function getVolumeFromSentio() {
87
+ /**
88
+ * Inputs:
89
+ * day: number (at least 1)
90
+ * interval: in hour
91
+ *
92
+ * Returns Map<string, Volume[]>
93
+ * key: base_token {'APT','BTC','CETUS','DEEP','ETH','NAVX','NS','SOL','SUI','WAL'}
94
+ * value: Volume[]
95
+ */
96
+ function getTradingVolumeFromSentio(fromTimestamp, interval, toTimestamp) {
88
97
  return __awaiter(this, void 0, void 0, function () {
89
- var apiUrl, requestData, jsonData, response, data, symbols, volume;
98
+ var apiUrl, requestData, jsonData, response, data, samples, map;
90
99
  return __generator(this, function (_a) {
91
100
  switch (_a.label) {
92
101
  case 0:
@@ -95,30 +104,39 @@ function getVolumeFromSentio() {
95
104
  : "https://app.sentio.xyz/api/v1/insights/typus/typus_perp/query";
96
105
  requestData = {
97
106
  timeRange: {
98
- start: "now-3d",
99
- end: "now",
100
- step: 3600,
107
+ start: "".concat(fromTimestamp),
108
+ end: "".concat(toTimestamp !== null && toTimestamp !== void 0 ? toTimestamp : "now"),
109
+ step: 3600 * interval,
101
110
  },
102
- limit: 20,
111
+ limit: 30 * 24,
103
112
  queries: [
104
113
  {
105
- eventsQuery: {
106
- resource: {
107
- name: "OrderFilled",
108
- type: "EVENTS",
109
- },
114
+ metricsQuery: {
115
+ query: "trading_volume_usd",
110
116
  alias: "",
111
117
  id: "a",
112
- aggregation: {
113
- total: {},
118
+ labelSelector: {},
119
+ aggregate: {
120
+ op: "SUM",
121
+ grouping: ["base_token"],
114
122
  },
115
- groupBy: ["base_token"],
116
- limit: 0,
117
- functions: [],
123
+ functions: [
124
+ {
125
+ name: "rollup_delta",
126
+ arguments: [
127
+ {
128
+ durationValue: {
129
+ value: interval,
130
+ unit: "h",
131
+ },
132
+ },
133
+ ],
134
+ },
135
+ ],
118
136
  color: "",
119
137
  disabled: false,
120
138
  },
121
- dataSource: "EVENTS",
139
+ dataSource: "METRICS",
122
140
  sourceName: "",
123
141
  },
124
142
  ],
@@ -135,11 +153,20 @@ function getVolumeFromSentio() {
135
153
  return [4 /*yield*/, response.json()];
136
154
  case 2:
137
155
  data = _a.sent();
138
- symbols = data.results[0].matrix.samples.map(function (s) { return s.metric.labels.base_token; });
139
- console.log(symbols);
140
- volume = data.results[0].matrix.samples.map(function (s) { return s.values; });
141
- console.log(volume);
142
- return [2 /*return*/, data.results];
156
+ samples = data.results[0].matrix.samples;
157
+ map = new Map();
158
+ samples.forEach(function (sample) {
159
+ // console.log(samples);
160
+ var base_token = sample.metric.labels.base_token;
161
+ var values = sample.values;
162
+ // console.log(base_token);
163
+ // console.log(values);
164
+ map.set(base_token, values);
165
+ });
166
+ // console.log(map);
167
+ // console.log(map.keys());
168
+ // console.log(map.get("SUI")?.length);
169
+ return [2 /*return*/, map];
143
170
  }
144
171
  });
145
172
  });
@@ -200,7 +227,7 @@ function getTlpFeeFromSentio() {
200
227
  });
201
228
  });
202
229
  }
203
- function getTotalVolumeFromSentio() {
230
+ function getTotalVolumeFromSentio(fromTimestamp, toTimestamp) {
204
231
  return __awaiter(this, void 0, void 0, function () {
205
232
  var apiUrl, requestData, jsonData, response, data, result;
206
233
  return __generator(this, function (_a) {
@@ -211,8 +238,8 @@ function getTotalVolumeFromSentio() {
211
238
  : "https://app.sentio.xyz/api/v1/insights/typus/typus_perp/query";
212
239
  requestData = {
213
240
  timeRange: {
214
- start: "now-1h",
215
- end: "now",
241
+ start: "".concat(fromTimestamp),
242
+ end: "".concat(toTimestamp),
216
243
  step: 3600,
217
244
  },
218
245
  limit: 1,
@@ -248,7 +275,7 @@ function getTotalVolumeFromSentio() {
248
275
  return [4 /*yield*/, response.json()];
249
276
  case 2:
250
277
  data = _a.sent();
251
- result = data.results[0].matrix.samples[0].values.at(-1).value;
278
+ result = data.results[0].matrix.samples[0].values.at(-1).value - data.results[0].matrix.samples[0].values.at(0).value;
252
279
  // console.log(result);
253
280
  return [2 /*return*/, result];
254
281
  }
@@ -322,4 +349,5 @@ function getAccumulatedUser() {
322
349
  // getVolumeFromSentio();
323
350
  // getTlpFeeFromSentio();
324
351
  // getAccumulatedUser();
325
- // getTotalVolumeFromSentio();
352
+ // getTradingVolumeFromSentio(1747008000, 1, 1747011600);
353
+ // getTotalVolumeFromSentio(1747008000, 1747011600);
@@ -18,3 +18,4 @@ export declare const TLP_TREASURY_CAP: string;
18
18
  export declare const STAKE_POOL: string;
19
19
  export declare const STAKE_POOL_0: string;
20
20
  export declare const STAKE_POOL_VERSION: string;
21
+ export declare const COMPETITION_CONFIG: string;
package/dist/src/index.js CHANGED
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.STAKE_POOL_VERSION = exports.STAKE_POOL_0 = exports.STAKE_POOL = exports.TLP_TREASURY_CAP = exports.TLP_TOKEN = exports.TLP = exports.PERP_VERSION = exports.MARKET = exports.LIQUIDITY_POOL_0 = exports.LIQUIDITY_POOL = exports.LP_POOL = exports.STAKE_PKG_V1 = exports.STAKE_PUBLISHED_AT = exports.STAKE_PACKAGE_ID = exports.PERP_PKG_V1 = exports.PERP_PUBLISHED_AT = exports.PERP_PACKAGE_ID = exports.NETWORK = void 0;
20
+ exports.COMPETITION_CONFIG = exports.STAKE_POOL_VERSION = exports.STAKE_POOL_0 = exports.STAKE_POOL = exports.TLP_TREASURY_CAP = exports.TLP_TOKEN = exports.TLP = exports.PERP_VERSION = exports.MARKET = exports.LIQUIDITY_POOL_0 = exports.LIQUIDITY_POOL = exports.LP_POOL = exports.STAKE_PKG_V1 = exports.STAKE_PUBLISHED_AT = exports.STAKE_PACKAGE_ID = exports.PERP_PKG_V1 = exports.PERP_PUBLISHED_AT = exports.PERP_PACKAGE_ID = exports.NETWORK = void 0;
21
21
  __exportStar(require("./fetch"), exports);
22
22
  __exportStar(require("./user"), exports);
23
23
  var dotenv_1 = __importDefault(require("dotenv"));
@@ -30,7 +30,7 @@ exports.PERP_PACKAGE_ID = exports.NETWORK == "MAINNET"
30
30
  ? "0xe27969a70f93034de9ce16e6ad661b480324574e68d15a64b513fd90eb2423e5"
31
31
  : "0x585924f160f83ef16f8927ec117e4d740abb6f4e571ecfa89ff3e973042cb1b9";
32
32
  exports.PERP_PUBLISHED_AT = exports.NETWORK == "MAINNET"
33
- ? "0xeb018055af198e99a368ccda030e9aef07ffb86aa5de83e98734913064b0cff4"
33
+ ? "0x347b833859a487218737de4a5e6b0fb861d37e653a10f44d420279c984badf9c"
34
34
  : "0x15844f80fb085bb8fd7cc688ade6282cd6991209eae78934ca001dced8b1b7de";
35
35
  exports.PERP_PKG_V1 = exports.NETWORK == "MAINNET"
36
36
  ? "0xe27969a70f93034de9ce16e6ad661b480324574e68d15a64b513fd90eb2423e5"
@@ -81,3 +81,4 @@ exports.STAKE_POOL_0 = exports.NETWORK == "MAINNET"
81
81
  exports.STAKE_POOL_VERSION = exports.NETWORK == "MAINNET"
82
82
  ? "0xdf3ed1599218b2415b2cd7fa06296f7f647676019b2873ec18e55a626c584f1b"
83
83
  : "0xafb81680b9ac3d627eb733154c43d34e3ec758cf8e00a55c384df2c8150f7881";
84
+ exports.COMPETITION_CONFIG = exports.NETWORK == "MAINNET" ? "0x36056abf9adde86f81667dad680a8ac98868c9fc1cb4d519fd2222d5d4522906" : "";
@@ -4,6 +4,16 @@ export interface AddAuthorizedUserArgs {
4
4
  userAddress: string | TransactionArgument;
5
5
  }
6
6
  export declare function addAuthorizedUser(tx: Transaction, args: AddAuthorizedUserArgs, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
7
+ export interface AddCompetitionLeaderboardArgs {
8
+ version: TransactionObjectInput;
9
+ typusEcosystemVersion: TransactionObjectInput;
10
+ typusLeaderboardRegistry: TransactionObjectInput;
11
+ leaderboardKey: string | TransactionArgument;
12
+ user: string | TransactionArgument;
13
+ score: bigint | TransactionArgument;
14
+ clock: TransactionObjectInput;
15
+ }
16
+ export declare function addCompetitionLeaderboard(tx: Transaction, args: AddCompetitionLeaderboardArgs, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
7
17
  export interface AddExpLeaderboardArgs {
8
18
  version: TransactionObjectInput;
9
19
  typusEcosystemVersion: TransactionObjectInput;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addAuthorizedUser = addAuthorizedUser;
4
+ exports.addCompetitionLeaderboard = addCompetitionLeaderboard;
4
5
  exports.addExpLeaderboard = addExpLeaderboard;
5
6
  exports.addTailsExpAmount = addTailsExpAmount;
6
7
  exports.chargeFee = chargeFee;
@@ -14,6 +15,7 @@ exports.upgrade = upgrade;
14
15
  exports.verify = verify;
15
16
  exports.versionCheck = versionCheck;
16
17
  var __1 = require("..");
18
+ var structs_1 = require("../../_dependencies/source/0x1/ascii/structs");
17
19
  var util_1 = require("../../_framework/util");
18
20
  function addAuthorizedUser(tx, args, published_at) {
19
21
  if (published_at === void 0) { published_at = __1.PUBLISHED_AT; }
@@ -22,6 +24,21 @@ function addAuthorizedUser(tx, args, published_at) {
22
24
  arguments: [(0, util_1.obj)(tx, args.version), (0, util_1.pure)(tx, args.userAddress, "address")],
23
25
  });
24
26
  }
27
+ function addCompetitionLeaderboard(tx, args, published_at) {
28
+ if (published_at === void 0) { published_at = __1.PUBLISHED_AT; }
29
+ return tx.moveCall({
30
+ target: "".concat(published_at, "::admin::add_competition_leaderboard"),
31
+ arguments: [
32
+ (0, util_1.obj)(tx, args.version),
33
+ (0, util_1.obj)(tx, args.typusEcosystemVersion),
34
+ (0, util_1.obj)(tx, args.typusLeaderboardRegistry),
35
+ (0, util_1.pure)(tx, args.leaderboardKey, "".concat(structs_1.String.$typeName)),
36
+ (0, util_1.pure)(tx, args.user, "address"),
37
+ (0, util_1.pure)(tx, args.score, "u64"),
38
+ (0, util_1.obj)(tx, args.clock),
39
+ ],
40
+ });
41
+ }
25
42
  function addExpLeaderboard(tx, args, published_at) {
26
43
  if (published_at === void 0) { published_at = __1.PUBLISHED_AT; }
27
44
  return tx.moveCall({
@@ -0,0 +1,24 @@
1
+ import { Transaction, TransactionArgument, TransactionObjectInput } from "@mysten/sui/transactions";
2
+ export interface AddScoreArgs {
3
+ version: TransactionObjectInput;
4
+ ecosystemVersion: TransactionObjectInput;
5
+ typusLeaderboardRegistry: TransactionObjectInput;
6
+ tailsStakingRegistry: TransactionObjectInput;
7
+ competitionConfig: TransactionObjectInput;
8
+ volumeUsd: bigint | TransactionArgument;
9
+ user: string | TransactionArgument;
10
+ clock: TransactionObjectInput;
11
+ }
12
+ export declare function addScore(tx: Transaction, args: AddScoreArgs, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
13
+ export interface NewCompetitionConfigArgs {
14
+ version: TransactionObjectInput;
15
+ boostBp: Array<bigint | TransactionArgument> | TransactionArgument;
16
+ programName: string | TransactionArgument;
17
+ }
18
+ export declare function newCompetitionConfig(tx: Transaction, args: NewCompetitionConfigArgs, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
19
+ export interface SetBoostBpArgs {
20
+ version: TransactionObjectInput;
21
+ competitionConfig: TransactionObjectInput;
22
+ boostBp: Array<bigint | TransactionArgument> | TransactionArgument;
23
+ }
24
+ export declare function setBoostBp(tx: Transaction, args: SetBoostBpArgs, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addScore = addScore;
4
+ exports.newCompetitionConfig = newCompetitionConfig;
5
+ exports.setBoostBp = setBoostBp;
6
+ var __1 = require("..");
7
+ var structs_1 = require("../../_dependencies/source/0x1/ascii/structs");
8
+ var util_1 = require("../../_framework/util");
9
+ function addScore(tx, args, published_at) {
10
+ if (published_at === void 0) { published_at = __1.PUBLISHED_AT; }
11
+ return tx.moveCall({
12
+ target: "".concat(published_at, "::competition::add_score"),
13
+ arguments: [
14
+ (0, util_1.obj)(tx, args.version),
15
+ (0, util_1.obj)(tx, args.ecosystemVersion),
16
+ (0, util_1.obj)(tx, args.typusLeaderboardRegistry),
17
+ (0, util_1.obj)(tx, args.tailsStakingRegistry),
18
+ (0, util_1.obj)(tx, args.competitionConfig),
19
+ (0, util_1.pure)(tx, args.volumeUsd, "u64"),
20
+ (0, util_1.pure)(tx, args.user, "address"),
21
+ (0, util_1.obj)(tx, args.clock),
22
+ ],
23
+ });
24
+ }
25
+ function newCompetitionConfig(tx, args, published_at) {
26
+ if (published_at === void 0) { published_at = __1.PUBLISHED_AT; }
27
+ return tx.moveCall({
28
+ target: "".concat(published_at, "::competition::new_competition_config"),
29
+ arguments: [(0, util_1.obj)(tx, args.version), (0, util_1.pure)(tx, args.boostBp, "vector<u64>"), (0, util_1.pure)(tx, args.programName, "".concat(structs_1.String.$typeName))],
30
+ });
31
+ }
32
+ function setBoostBp(tx, args, published_at) {
33
+ if (published_at === void 0) { published_at = __1.PUBLISHED_AT; }
34
+ return tx.moveCall({
35
+ target: "".concat(published_at, "::competition::set_boost_bp"),
36
+ arguments: [(0, util_1.obj)(tx, args.version), (0, util_1.obj)(tx, args.competitionConfig), (0, util_1.pure)(tx, args.boostBp, "vector<u64>")],
37
+ });
38
+ }
@@ -0,0 +1,92 @@
1
+ import * as reified from "../../_framework/reified";
2
+ import { String } from "../../_dependencies/source/0x1/ascii/structs";
3
+ import { UID } from "../../_dependencies/source/0x2/object/structs";
4
+ import { PhantomReified, Reified, StructClass, ToField, ToTypeStr } from "../../_framework/reified";
5
+ import { FieldsWithTypes } from "../../_framework/util";
6
+ import { Vector } from "../../_framework/vector";
7
+ import { PKG_V1 } from "../index";
8
+ import { SuiClient, SuiObjectData, SuiParsedData } from "@mysten/sui/client";
9
+ export declare function isCompetitionConfig(type: string): boolean;
10
+ export interface CompetitionConfigFields {
11
+ id: ToField<UID>;
12
+ boostBp: ToField<Vector<"u64">>;
13
+ isActive: ToField<"bool">;
14
+ programName: ToField<String>;
15
+ u64Padding: ToField<Vector<"u64">>;
16
+ }
17
+ export type CompetitionConfigReified = Reified<CompetitionConfig, CompetitionConfigFields>;
18
+ export declare class CompetitionConfig implements StructClass {
19
+ __StructClass: true;
20
+ static readonly $typeName: string;
21
+ static readonly $numTypeParams = 0;
22
+ static readonly $isPhantom: readonly [];
23
+ readonly $typeName: string;
24
+ readonly $fullTypeName: `${typeof PKG_V1}::competition::CompetitionConfig`;
25
+ readonly $typeArgs: [];
26
+ readonly $isPhantom: readonly [];
27
+ readonly id: ToField<UID>;
28
+ readonly boostBp: ToField<Vector<"u64">>;
29
+ readonly isActive: ToField<"bool">;
30
+ readonly programName: ToField<String>;
31
+ readonly u64Padding: ToField<Vector<"u64">>;
32
+ private constructor();
33
+ static reified(): CompetitionConfigReified;
34
+ static get r(): reified.StructClassReified<CompetitionConfig, CompetitionConfigFields>;
35
+ static phantom(): PhantomReified<ToTypeStr<CompetitionConfig>>;
36
+ static get p(): reified.PhantomReified<"0xe27969a70f93034de9ce16e6ad661b480324574e68d15a64b513fd90eb2423e5::competition::CompetitionConfig" | "0x585924f160f83ef16f8927ec117e4d740abb6f4e571ecfa89ff3e973042cb1b9::competition::CompetitionConfig">;
37
+ static get bcs(): import("@mysten/sui/bcs").BcsType<{
38
+ id: {
39
+ id: {
40
+ bytes: string;
41
+ };
42
+ };
43
+ boost_bp: string[];
44
+ is_active: boolean;
45
+ program_name: {
46
+ bytes: number[];
47
+ };
48
+ u64_padding: string[];
49
+ }, {
50
+ id: {
51
+ id: {
52
+ bytes: string;
53
+ };
54
+ };
55
+ boost_bp: Iterable<string | number | bigint> & {
56
+ length: number;
57
+ };
58
+ is_active: boolean;
59
+ program_name: {
60
+ bytes: Iterable<number> & {
61
+ length: number;
62
+ };
63
+ };
64
+ u64_padding: Iterable<string | number | bigint> & {
65
+ length: number;
66
+ };
67
+ }>;
68
+ static fromFields(fields: Record<string, any>): CompetitionConfig;
69
+ static fromFieldsWithTypes(item: FieldsWithTypes): CompetitionConfig;
70
+ static fromBcs(data: Uint8Array): CompetitionConfig;
71
+ toJSONField(): {
72
+ id: string;
73
+ boostBp: string[];
74
+ isActive: boolean;
75
+ programName: string;
76
+ u64Padding: string[];
77
+ };
78
+ toJSON(): {
79
+ id: string;
80
+ boostBp: string[];
81
+ isActive: boolean;
82
+ programName: string;
83
+ u64Padding: string[];
84
+ $typeName: string;
85
+ $typeArgs: [];
86
+ };
87
+ static fromJSONField(field: any): CompetitionConfig;
88
+ static fromJSON(json: Record<string, any>): CompetitionConfig;
89
+ static fromSuiParsedData(content: SuiParsedData): CompetitionConfig;
90
+ static fromSuiObjectData(data: SuiObjectData): CompetitionConfig;
91
+ static fetch(client: SuiClient, id: string): Promise<CompetitionConfig>;
92
+ }