@typus/typus-perp-sdk 1.0.59 → 1.0.60

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.
@@ -8,12 +8,12 @@ export declare function getFromSentio(event: string, userAddress: string, startT
8
8
  * key: base_token {'APT','BTC','CETUS','DEEP','ETH','NAVX','NS','SOL','SUI','WAL'}
9
9
  * value: Volume[]
10
10
  */
11
- export declare function getTradingVolumeFromSentio(fromTimestamp: number, interval: number): Promise<Map<string, Volume[]>>;
11
+ export declare function getTradingVolumeFromSentio(fromTimestamp: number, interval: number, toTimestamp?: number): Promise<Map<string, Volume[]>>;
12
12
  export interface Volume {
13
13
  timestamp: string;
14
14
  value: number;
15
15
  }
16
16
  export declare function getTlpFeeFromSentio(): Promise<number>;
17
- export declare function getTotalVolumeFromSentio(): Promise<number>;
17
+ export declare function getTotalVolumeFromSentio(fromTimestamp: number, toTimestamp: number): Promise<number>;
18
18
  /** Returns Accumulated Users */
19
19
  export declare function getAccumulatedUser(): Promise<number>;
@@ -93,7 +93,7 @@ function getFromSentio(event, userAddress, startTimestamp) {
93
93
  * key: base_token {'APT','BTC','CETUS','DEEP','ETH','NAVX','NS','SOL','SUI','WAL'}
94
94
  * value: Volume[]
95
95
  */
96
- function getTradingVolumeFromSentio(fromTimestamp, interval) {
96
+ function getTradingVolumeFromSentio(fromTimestamp, interval, toTimestamp) {
97
97
  return __awaiter(this, void 0, void 0, function () {
98
98
  var apiUrl, requestData, jsonData, response, data, samples, map;
99
99
  return __generator(this, function (_a) {
@@ -105,7 +105,7 @@ function getTradingVolumeFromSentio(fromTimestamp, interval) {
105
105
  requestData = {
106
106
  timeRange: {
107
107
  start: "".concat(fromTimestamp),
108
- end: "now",
108
+ end: "".concat(toTimestamp !== null && toTimestamp !== void 0 ? toTimestamp : "now"),
109
109
  step: 3600 * interval,
110
110
  },
111
111
  limit: 30 * 24,
@@ -227,7 +227,7 @@ function getTlpFeeFromSentio() {
227
227
  });
228
228
  });
229
229
  }
230
- function getTotalVolumeFromSentio() {
230
+ function getTotalVolumeFromSentio(fromTimestamp, toTimestamp) {
231
231
  return __awaiter(this, void 0, void 0, function () {
232
232
  var apiUrl, requestData, jsonData, response, data, result;
233
233
  return __generator(this, function (_a) {
@@ -238,8 +238,8 @@ function getTotalVolumeFromSentio() {
238
238
  : "https://app.sentio.xyz/api/v1/insights/typus/typus_perp/query";
239
239
  requestData = {
240
240
  timeRange: {
241
- start: "now-1h",
242
- end: "now",
241
+ start: "".concat(fromTimestamp),
242
+ end: "".concat(toTimestamp),
243
243
  step: 3600,
244
244
  },
245
245
  limit: 1,
@@ -275,7 +275,7 @@ function getTotalVolumeFromSentio() {
275
275
  return [4 /*yield*/, response.json()];
276
276
  case 2:
277
277
  data = _a.sent();
278
- 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;
279
279
  // console.log(result);
280
280
  return [2 /*return*/, result];
281
281
  }
@@ -349,5 +349,5 @@ function getAccumulatedUser() {
349
349
  // getVolumeFromSentio();
350
350
  // getTlpFeeFromSentio();
351
351
  // getAccumulatedUser();
352
- // getTotalVolumeFromSentio();
353
- // getTradingVolumeFromSentio(1745712000, 1);
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
+ }
@@ -0,0 +1,288 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || (function () {
30
+ var ownKeys = function(o) {
31
+ ownKeys = Object.getOwnPropertyNames || function (o) {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ };
36
+ return ownKeys(o);
37
+ };
38
+ return function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ })();
46
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
47
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
48
+ return new (P || (P = Promise))(function (resolve, reject) {
49
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
50
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
51
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
52
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
53
+ });
54
+ };
55
+ var __generator = (this && this.__generator) || function (thisArg, body) {
56
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
57
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
58
+ function verb(n) { return function (v) { return step([n, v]); }; }
59
+ function step(op) {
60
+ if (f) throw new TypeError("Generator is already executing.");
61
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
62
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
63
+ if (y = 0, t) op = [op[0] & 2, t.value];
64
+ switch (op[0]) {
65
+ case 0: case 1: t = op; break;
66
+ case 4: _.label++; return { value: op[1], done: false };
67
+ case 5: _.label++; y = op[1]; op = [0]; continue;
68
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
69
+ default:
70
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
71
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
72
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
73
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
74
+ if (t[2]) _.ops.pop();
75
+ _.trys.pop(); continue;
76
+ }
77
+ op = body.call(thisArg, _);
78
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
79
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
80
+ }
81
+ };
82
+ var __read = (this && this.__read) || function (o, n) {
83
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
84
+ if (!m) return o;
85
+ var i = m.call(o), r, ar = [], e;
86
+ try {
87
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
88
+ }
89
+ catch (error) { e = { error: error }; }
90
+ finally {
91
+ try {
92
+ if (r && !r.done && (m = i["return"])) m.call(i);
93
+ }
94
+ finally { if (e) throw e.error; }
95
+ }
96
+ return ar;
97
+ };
98
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
99
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
100
+ if (ar || !(i in from)) {
101
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
102
+ ar[i] = from[i];
103
+ }
104
+ }
105
+ return to.concat(ar || Array.prototype.slice.call(from));
106
+ };
107
+ Object.defineProperty(exports, "__esModule", { value: true });
108
+ exports.CompetitionConfig = void 0;
109
+ exports.isCompetitionConfig = isCompetitionConfig;
110
+ var reified = __importStar(require("../../_framework/reified"));
111
+ var structs_1 = require("../../_dependencies/source/0x1/ascii/structs");
112
+ var structs_2 = require("../../_dependencies/source/0x2/object/structs");
113
+ var reified_1 = require("../../_framework/reified");
114
+ var util_1 = require("../../_framework/util");
115
+ var index_1 = require("../index");
116
+ var bcs_1 = require("@mysten/sui/bcs");
117
+ var utils_1 = require("@mysten/sui/utils");
118
+ /* ============================== CompetitionConfig =============================== */
119
+ function isCompetitionConfig(type) {
120
+ type = (0, util_1.compressSuiType)(type);
121
+ return type === "".concat(index_1.PKG_V1, "::competition::CompetitionConfig");
122
+ }
123
+ var CompetitionConfig = /** @class */ (function () {
124
+ function CompetitionConfig(typeArgs, fields) {
125
+ this.__StructClass = true;
126
+ this.$typeName = CompetitionConfig.$typeName;
127
+ this.$isPhantom = CompetitionConfig.$isPhantom;
128
+ this.$fullTypeName = util_1.composeSuiType.apply(void 0, __spreadArray([CompetitionConfig.$typeName], __read(typeArgs), false));
129
+ this.$typeArgs = typeArgs;
130
+ this.id = fields.id;
131
+ this.boostBp = fields.boostBp;
132
+ this.isActive = fields.isActive;
133
+ this.programName = fields.programName;
134
+ this.u64Padding = fields.u64Padding;
135
+ }
136
+ CompetitionConfig.reified = function () {
137
+ var _this = this;
138
+ return {
139
+ typeName: CompetitionConfig.$typeName,
140
+ fullTypeName: util_1.composeSuiType.apply(void 0, __spreadArray([CompetitionConfig.$typeName], [], false)),
141
+ typeArgs: [],
142
+ isPhantom: CompetitionConfig.$isPhantom,
143
+ reifiedTypeArgs: [],
144
+ fromFields: function (fields) { return CompetitionConfig.fromFields(fields); },
145
+ fromFieldsWithTypes: function (item) { return CompetitionConfig.fromFieldsWithTypes(item); },
146
+ fromBcs: function (data) { return CompetitionConfig.fromBcs(data); },
147
+ bcs: CompetitionConfig.bcs,
148
+ fromJSONField: function (field) { return CompetitionConfig.fromJSONField(field); },
149
+ fromJSON: function (json) { return CompetitionConfig.fromJSON(json); },
150
+ fromSuiParsedData: function (content) { return CompetitionConfig.fromSuiParsedData(content); },
151
+ fromSuiObjectData: function (content) { return CompetitionConfig.fromSuiObjectData(content); },
152
+ fetch: function (client, id) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
153
+ return [2 /*return*/, CompetitionConfig.fetch(client, id)];
154
+ }); }); },
155
+ new: function (fields) {
156
+ return new CompetitionConfig([], fields);
157
+ },
158
+ kind: "StructClassReified",
159
+ };
160
+ };
161
+ Object.defineProperty(CompetitionConfig, "r", {
162
+ get: function () {
163
+ return CompetitionConfig.reified();
164
+ },
165
+ enumerable: false,
166
+ configurable: true
167
+ });
168
+ CompetitionConfig.phantom = function () {
169
+ return (0, reified_1.phantom)(CompetitionConfig.reified());
170
+ };
171
+ Object.defineProperty(CompetitionConfig, "p", {
172
+ get: function () {
173
+ return CompetitionConfig.phantom();
174
+ },
175
+ enumerable: false,
176
+ configurable: true
177
+ });
178
+ Object.defineProperty(CompetitionConfig, "bcs", {
179
+ get: function () {
180
+ return bcs_1.bcs.struct("CompetitionConfig", {
181
+ id: structs_2.UID.bcs,
182
+ boost_bp: bcs_1.bcs.vector(bcs_1.bcs.u64()),
183
+ is_active: bcs_1.bcs.bool(),
184
+ program_name: structs_1.String.bcs,
185
+ u64_padding: bcs_1.bcs.vector(bcs_1.bcs.u64()),
186
+ });
187
+ },
188
+ enumerable: false,
189
+ configurable: true
190
+ });
191
+ CompetitionConfig.fromFields = function (fields) {
192
+ return CompetitionConfig.reified().new({
193
+ id: (0, reified_1.decodeFromFields)(structs_2.UID.reified(), fields.id),
194
+ boostBp: (0, reified_1.decodeFromFields)(reified.vector("u64"), fields.boost_bp),
195
+ isActive: (0, reified_1.decodeFromFields)("bool", fields.is_active),
196
+ programName: (0, reified_1.decodeFromFields)(structs_1.String.reified(), fields.program_name),
197
+ u64Padding: (0, reified_1.decodeFromFields)(reified.vector("u64"), fields.u64_padding),
198
+ });
199
+ };
200
+ CompetitionConfig.fromFieldsWithTypes = function (item) {
201
+ if (!isCompetitionConfig(item.type)) {
202
+ throw new Error("not a CompetitionConfig type");
203
+ }
204
+ return CompetitionConfig.reified().new({
205
+ id: (0, reified_1.decodeFromFieldsWithTypes)(structs_2.UID.reified(), item.fields.id),
206
+ boostBp: (0, reified_1.decodeFromFieldsWithTypes)(reified.vector("u64"), item.fields.boost_bp),
207
+ isActive: (0, reified_1.decodeFromFieldsWithTypes)("bool", item.fields.is_active),
208
+ programName: (0, reified_1.decodeFromFieldsWithTypes)(structs_1.String.reified(), item.fields.program_name),
209
+ u64Padding: (0, reified_1.decodeFromFieldsWithTypes)(reified.vector("u64"), item.fields.u64_padding),
210
+ });
211
+ };
212
+ CompetitionConfig.fromBcs = function (data) {
213
+ return CompetitionConfig.fromFields(CompetitionConfig.bcs.parse(data));
214
+ };
215
+ CompetitionConfig.prototype.toJSONField = function () {
216
+ return {
217
+ id: this.id,
218
+ boostBp: (0, reified_1.fieldToJSON)("vector<u64>", this.boostBp),
219
+ isActive: this.isActive,
220
+ programName: this.programName,
221
+ u64Padding: (0, reified_1.fieldToJSON)("vector<u64>", this.u64Padding),
222
+ };
223
+ };
224
+ CompetitionConfig.prototype.toJSON = function () {
225
+ return __assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
226
+ };
227
+ CompetitionConfig.fromJSONField = function (field) {
228
+ return CompetitionConfig.reified().new({
229
+ id: (0, reified_1.decodeFromJSONField)(structs_2.UID.reified(), field.id),
230
+ boostBp: (0, reified_1.decodeFromJSONField)(reified.vector("u64"), field.boostBp),
231
+ isActive: (0, reified_1.decodeFromJSONField)("bool", field.isActive),
232
+ programName: (0, reified_1.decodeFromJSONField)(structs_1.String.reified(), field.programName),
233
+ u64Padding: (0, reified_1.decodeFromJSONField)(reified.vector("u64"), field.u64Padding),
234
+ });
235
+ };
236
+ CompetitionConfig.fromJSON = function (json) {
237
+ if (json.$typeName !== CompetitionConfig.$typeName) {
238
+ throw new Error("not a WithTwoGenerics json object");
239
+ }
240
+ return CompetitionConfig.fromJSONField(json);
241
+ };
242
+ CompetitionConfig.fromSuiParsedData = function (content) {
243
+ if (content.dataType !== "moveObject") {
244
+ throw new Error("not an object");
245
+ }
246
+ if (!isCompetitionConfig(content.type)) {
247
+ throw new Error("object at ".concat(content.fields.id, " is not a CompetitionConfig object"));
248
+ }
249
+ return CompetitionConfig.fromFieldsWithTypes(content);
250
+ };
251
+ CompetitionConfig.fromSuiObjectData = function (data) {
252
+ if (data.bcs) {
253
+ if (data.bcs.dataType !== "moveObject" || !isCompetitionConfig(data.bcs.type)) {
254
+ throw new Error("object at is not a CompetitionConfig object");
255
+ }
256
+ return CompetitionConfig.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
257
+ }
258
+ if (data.content) {
259
+ return CompetitionConfig.fromSuiParsedData(data.content);
260
+ }
261
+ throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
262
+ };
263
+ CompetitionConfig.fetch = function (client, id) {
264
+ return __awaiter(this, void 0, void 0, function () {
265
+ var res;
266
+ var _a, _b;
267
+ return __generator(this, function (_c) {
268
+ switch (_c.label) {
269
+ case 0: return [4 /*yield*/, client.getObject({ id: id, options: { showBcs: true } })];
270
+ case 1:
271
+ res = _c.sent();
272
+ if (res.error) {
273
+ throw new Error("error fetching CompetitionConfig object at id ".concat(id, ": ").concat(res.error.code));
274
+ }
275
+ if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" || !isCompetitionConfig(res.data.bcs.type)) {
276
+ throw new Error("object at id ".concat(id, " is not a CompetitionConfig object"));
277
+ }
278
+ return [2 /*return*/, CompetitionConfig.fromSuiObjectData(res.data)];
279
+ }
280
+ });
281
+ });
282
+ };
283
+ CompetitionConfig.$typeName = "".concat(index_1.PKG_V1, "::competition::CompetitionConfig");
284
+ CompetitionConfig.$numTypeParams = 0;
285
+ CompetitionConfig.$isPhantom = [];
286
+ return CompetitionConfig;
287
+ }());
288
+ exports.CompetitionConfig = CompetitionConfig;
@@ -15,11 +15,14 @@ export declare function collateralTokenTypeMismatched(tx: Transaction, published
15
15
  export declare function depositAmountInsufficient(tx: Transaction, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
16
16
  export declare function depositTokenMismatched(tx: Transaction, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
17
17
  export declare function exceedMaxLeverage(tx: Transaction, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
18
+ export declare function exceedMaxOpenInterest(tx: Transaction, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
18
19
  export declare function frictionTooLarge(tx: Transaction, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
19
20
  export declare function insufficientAmountForMintFee(tx: Transaction, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
20
21
  export declare function invalidBidReceiptsInput(tx: Transaction, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
22
+ export declare function invalidBoostBpArrayLength(tx: Transaction, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
21
23
  export declare function invalidOrderSide(tx: Transaction, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
22
24
  export declare function invalidOrderSize(tx: Transaction, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
25
+ export declare function invalidTokenType(tx: Transaction, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
23
26
  export declare function invalidTradingFeeConfig(tx: Transaction, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
24
27
  export declare function invalidVersion(tx: Transaction, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
25
28
  export declare function linkedOrderIdNotExisted(tx: Transaction, published_at?: string): import("@mysten/sui/transactions").TransactionResult;