@typus/typus-perp-sdk 1.0.59 → 1.0.61-ui-upgrade-e
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/api/sentio.d.ts +2 -2
- package/dist/src/api/sentio.js +8 -8
- package/dist/src/fetch.d.ts +16 -3
- package/dist/src/fetch.js +139 -8
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +8 -4
- package/dist/src/typus_perp/admin/functions.d.ts +10 -0
- package/dist/src/typus_perp/admin/functions.js +17 -0
- package/dist/src/typus_perp/competition/functions.d.ts +24 -0
- package/dist/src/typus_perp/competition/functions.js +38 -0
- package/dist/src/typus_perp/competition/structs.d.ts +92 -0
- package/dist/src/typus_perp/competition/structs.js +288 -0
- package/dist/src/typus_perp/error/functions.d.ts +5 -0
- package/dist/src/typus_perp/error/functions.js +25 -0
- package/dist/src/typus_perp/lp-pool/functions.d.ts +60 -27
- package/dist/src/typus_perp/lp-pool/functions.js +92 -52
- package/dist/src/typus_perp/lp-pool/structs.d.ts +161 -210
- package/dist/src/typus_perp/lp-pool/structs.js +384 -284
- package/dist/src/typus_perp/position/functions.d.ts +8 -0
- package/dist/src/typus_perp/position/functions.js +8 -0
- package/dist/src/typus_perp/trading/functions.d.ts +186 -0
- package/dist/src/typus_perp/trading/functions.js +263 -0
- package/dist/src/typus_perp/trading/structs.d.ts +127 -0
- package/dist/src/typus_perp/trading/structs.js +395 -204
- package/dist/src/typus_stake_pool/stake-pool/functions.d.ts +9 -0
- package/dist/src/typus_stake_pool/stake-pool/functions.js +20 -0
- package/dist/src/user/order.js +3 -1
- package/dist/src/user/orderWithBidReceipt.js +6 -2
- package/dist/src/user/tlp.d.ts +23 -9
- package/dist/src/user/tlp.js +148 -61
- package/package.json +2 -2
package/dist/src/api/sentio.d.ts
CHANGED
|
@@ -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>;
|
package/dist/src/api/sentio.js
CHANGED
|
@@ -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: "
|
|
242
|
-
end: "
|
|
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
|
-
//
|
|
353
|
-
//
|
|
352
|
+
// getTradingVolumeFromSentio(1747008000, 1, 1747011600);
|
|
353
|
+
// getTotalVolumeFromSentio(1747008000, 1747011600);
|
package/dist/src/fetch.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Markets, SymbolMarket } from "./typus_perp/trading/structs";
|
|
2
|
-
import { LiquidityPool } from "./typus_perp/lp-pool/structs";
|
|
2
|
+
import { DeactivatingShares, LiquidityPool } from "./typus_perp/lp-pool/structs";
|
|
3
3
|
import { TradingOrder, Position } from "./typus_perp/position/structs";
|
|
4
4
|
import { LpUserShare, StakePool } from "./typus_stake_pool/stake-pool/structs";
|
|
5
|
+
import { TOKEN } from "@typus/typus-sdk/dist/src/constants";
|
|
5
6
|
import { PythClient, TypusConfig } from "@typus/typus-sdk/dist/src/utils";
|
|
7
|
+
import { TLP_TOKEN } from ".";
|
|
6
8
|
import { TypusBidReceipt } from "./_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/vault/structs";
|
|
7
9
|
export declare function getLpPools(config: TypusConfig): Promise<LiquidityPool[]>;
|
|
8
10
|
export declare function getLpPool(config: TypusConfig, objectId?: string): Promise<LiquidityPool>;
|
|
@@ -19,9 +21,9 @@ export declare function getUserOrders(config: TypusConfig, user: string): Promis
|
|
|
19
21
|
export declare function getUserPositions(config: TypusConfig, user: string): Promise<Position[]>;
|
|
20
22
|
export declare function parseOptionBidReceipts(positions: Position[]): (TypusBidReceipt | null)[];
|
|
21
23
|
/**
|
|
22
|
-
* @returns [lpShare, incentives]
|
|
24
|
+
* @returns [[lpShare, incentives][], deactivatingShares[]]
|
|
23
25
|
*/
|
|
24
|
-
export declare function getUserStake(config: TypusConfig, user: string): Promise<[LpUserShare, string[]][]>;
|
|
26
|
+
export declare function getUserStake(config: TypusConfig, user: string): Promise<[[LpUserShare, string[]][], DeactivatingShares<typeof TLP_TOKEN>[]]>;
|
|
25
27
|
/**
|
|
26
28
|
* @returns [liquidationPrice, pnl(in USD)]
|
|
27
29
|
*/
|
|
@@ -29,3 +31,14 @@ export declare function getLiquidationPriceAndPnl(config: TypusConfig, pythClien
|
|
|
29
31
|
positions: Position[];
|
|
30
32
|
user: string;
|
|
31
33
|
}): Promise<(string | number)[][] | undefined>;
|
|
34
|
+
export declare function getPositionCount(config: TypusConfig, input: {
|
|
35
|
+
baseToken: TOKEN;
|
|
36
|
+
}): Promise<number>;
|
|
37
|
+
export declare function getAllPositions(config: TypusConfig, input: {
|
|
38
|
+
baseToken: TOKEN;
|
|
39
|
+
slice: string;
|
|
40
|
+
page: string;
|
|
41
|
+
}): Promise<Position[]>;
|
|
42
|
+
export declare function getAllPositionsWithTradingSymbol(config: TypusConfig, input: {
|
|
43
|
+
baseToken: TOKEN;
|
|
44
|
+
}): Promise<Position[]>;
|
package/dist/src/fetch.js
CHANGED
|
@@ -57,6 +57,9 @@ exports.getUserPositions = getUserPositions;
|
|
|
57
57
|
exports.parseOptionBidReceipts = parseOptionBidReceipts;
|
|
58
58
|
exports.getUserStake = getUserStake;
|
|
59
59
|
exports.getLiquidationPriceAndPnl = getLiquidationPriceAndPnl;
|
|
60
|
+
exports.getPositionCount = getPositionCount;
|
|
61
|
+
exports.getAllPositions = getAllPositions;
|
|
62
|
+
exports.getAllPositionsWithTradingSymbol = getAllPositionsWithTradingSymbol;
|
|
60
63
|
var client_1 = require("@mysten/sui/client");
|
|
61
64
|
var transactions_1 = require("@mysten/sui/transactions");
|
|
62
65
|
var bcs_1 = require("@mysten/bcs");
|
|
@@ -71,6 +74,7 @@ var utils_1 = require("@typus/typus-sdk/dist/src/utils");
|
|
|
71
74
|
var _1 = require(".");
|
|
72
75
|
var structs_5 = require("./_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/vault/structs");
|
|
73
76
|
var typus_perp_1 = require("./typus_perp");
|
|
77
|
+
var functions_3 = require("./typus_perp/lp-pool/functions");
|
|
74
78
|
function getLpPools(config) {
|
|
75
79
|
return __awaiter(this, void 0, void 0, function () {
|
|
76
80
|
var provider, dynamicFields, lpPools, _a, _b, field, lpPool, e_1_1;
|
|
@@ -346,11 +350,11 @@ function parseOptionBidReceipts(positions) {
|
|
|
346
350
|
});
|
|
347
351
|
}
|
|
348
352
|
/**
|
|
349
|
-
* @returns [lpShare, incentives]
|
|
353
|
+
* @returns [[lpShare, incentives][], deactivatingShares[]]
|
|
350
354
|
*/
|
|
351
355
|
function getUserStake(config, user) {
|
|
352
356
|
return __awaiter(this, void 0, void 0, function () {
|
|
353
|
-
var provider, tx, res, returnValues, reader, lpShares_1;
|
|
357
|
+
var provider, tx, res, returnValues, reader, lpShares_1, returnValues, reader, deactivatingShares_1;
|
|
354
358
|
return __generator(this, function (_a) {
|
|
355
359
|
switch (_a.label) {
|
|
356
360
|
case 0:
|
|
@@ -367,6 +371,11 @@ function getUserStake(config, user) {
|
|
|
367
371
|
index: BigInt(0),
|
|
368
372
|
user: user,
|
|
369
373
|
});
|
|
374
|
+
(0, functions_3.getUserDeactivatingShares)(tx, _1.TLP_TOKEN, {
|
|
375
|
+
registry: _1.LP_POOL,
|
|
376
|
+
index: BigInt(0),
|
|
377
|
+
user: user,
|
|
378
|
+
});
|
|
370
379
|
return [4 /*yield*/, provider.devInspectTransactionBlock({ sender: user, transactionBlock: tx })];
|
|
371
380
|
case 1:
|
|
372
381
|
res = _a.sent();
|
|
@@ -387,14 +396,20 @@ function getUserStake(config, user) {
|
|
|
387
396
|
});
|
|
388
397
|
lpShares_1.push([lpShare, incentives]);
|
|
389
398
|
});
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
399
|
+
returnValues = res.results[2].returnValues[0][0];
|
|
400
|
+
reader = new bcs_1.BcsReader(new Uint8Array(returnValues));
|
|
401
|
+
deactivatingShares_1 = [];
|
|
402
|
+
reader.readVec(function (reader) {
|
|
403
|
+
var length = reader.readULEB();
|
|
404
|
+
var lpShare = structs_2.DeactivatingShares.bcs.read(reader);
|
|
405
|
+
// @ts-ignore
|
|
406
|
+
deactivatingShares_1.push(lpShare);
|
|
407
|
+
});
|
|
408
|
+
// console.log(deactivatingShares);
|
|
409
|
+
return [2 /*return*/, [lpShares_1, deactivatingShares_1]];
|
|
395
410
|
}
|
|
396
411
|
else {
|
|
397
|
-
return [2 /*return*/, []];
|
|
412
|
+
return [2 /*return*/, [[], []]];
|
|
398
413
|
}
|
|
399
414
|
return [2 /*return*/];
|
|
400
415
|
}
|
|
@@ -493,3 +508,119 @@ function getLiquidationPriceAndPnl(config, pythClient, input) {
|
|
|
493
508
|
});
|
|
494
509
|
});
|
|
495
510
|
}
|
|
511
|
+
function getPositionCount(config, input) {
|
|
512
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
513
|
+
var provider, tx, res, raw, maxPageBytes, view, maxPage;
|
|
514
|
+
var _a, _b, _c, _d;
|
|
515
|
+
return __generator(this, function (_e) {
|
|
516
|
+
switch (_e.label) {
|
|
517
|
+
case 0:
|
|
518
|
+
provider = new client_1.SuiClient({ url: config.rpcEndpoint });
|
|
519
|
+
tx = new transactions_1.Transaction();
|
|
520
|
+
// Rust 實作是呼叫 get_all_positions(slice = 1, page = 1) 然後取最後 8 bytes。
|
|
521
|
+
// 這裡直接複用相同邏輯,只需要 max_page。
|
|
522
|
+
(0, functions_1.getAllPositions)(tx, constants_1.tokenType[_1.NETWORK][input.baseToken], {
|
|
523
|
+
version: _1.PERP_VERSION,
|
|
524
|
+
registry: _1.MARKET,
|
|
525
|
+
marketIndex: BigInt(0),
|
|
526
|
+
slice: BigInt(1),
|
|
527
|
+
page: BigInt(1),
|
|
528
|
+
});
|
|
529
|
+
return [4 /*yield*/, provider.devInspectTransactionBlock({
|
|
530
|
+
sender: "0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
531
|
+
transactionBlock: tx,
|
|
532
|
+
})];
|
|
533
|
+
case 1:
|
|
534
|
+
res = _e.sent();
|
|
535
|
+
// 沒有資料時,回傳 0
|
|
536
|
+
if (!((_d = (_c = (_b = (_a = res.results) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.returnValues) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d[0])) {
|
|
537
|
+
return [2 /*return*/, 0];
|
|
538
|
+
}
|
|
539
|
+
raw = new Uint8Array(res.results[0].returnValues[0][0]);
|
|
540
|
+
// 至少要含 8 bytes 的 max_page;不足代表無 Position
|
|
541
|
+
if (raw.length < 8)
|
|
542
|
+
return [2 /*return*/, 0];
|
|
543
|
+
maxPageBytes = raw.slice(raw.length - 8);
|
|
544
|
+
view = new DataView(maxPageBytes.buffer, maxPageBytes.byteOffset, 8);
|
|
545
|
+
maxPage = Number(view.getBigUint64(0, true));
|
|
546
|
+
return [2 /*return*/, maxPage];
|
|
547
|
+
}
|
|
548
|
+
});
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
function getAllPositions(config, input) {
|
|
552
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
553
|
+
var provider, tx, res, raw, withoutMaxPage, reader, userPositionsLen, positions, i, fields, pos;
|
|
554
|
+
var _a, _b, _c, _d;
|
|
555
|
+
return __generator(this, function (_e) {
|
|
556
|
+
switch (_e.label) {
|
|
557
|
+
case 0:
|
|
558
|
+
provider = new client_1.SuiClient({ url: config.rpcEndpoint });
|
|
559
|
+
tx = new transactions_1.Transaction();
|
|
560
|
+
(0, functions_1.getAllPositions)(tx, constants_1.tokenType[_1.NETWORK][input.baseToken], {
|
|
561
|
+
version: _1.PERP_VERSION,
|
|
562
|
+
registry: _1.MARKET,
|
|
563
|
+
marketIndex: BigInt(0),
|
|
564
|
+
slice: BigInt(input.slice),
|
|
565
|
+
page: BigInt(input.page),
|
|
566
|
+
});
|
|
567
|
+
return [4 /*yield*/, provider.devInspectTransactionBlock({
|
|
568
|
+
sender: "0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
569
|
+
transactionBlock: tx,
|
|
570
|
+
})];
|
|
571
|
+
case 1:
|
|
572
|
+
res = _e.sent();
|
|
573
|
+
console.log(res);
|
|
574
|
+
if (!((_d = (_c = (_b = (_a = res.results) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.returnValues) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d[0])) {
|
|
575
|
+
return [2 /*return*/, []];
|
|
576
|
+
}
|
|
577
|
+
raw = new Uint8Array(res.results[0].returnValues[0][0]);
|
|
578
|
+
// 1) 至少要有 8 bytes 的 max_page
|
|
579
|
+
if (raw.length < 8)
|
|
580
|
+
return [2 /*return*/, []];
|
|
581
|
+
withoutMaxPage = raw.slice(0, raw.length - 8);
|
|
582
|
+
reader = new bcs_1.BcsReader(withoutMaxPage);
|
|
583
|
+
userPositionsLen = reader.read8() - 1;
|
|
584
|
+
positions = [];
|
|
585
|
+
for (i = 0; i < userPositionsLen; i++) {
|
|
586
|
+
reader.read16();
|
|
587
|
+
fields = structs_3.Position.bcs.read(reader);
|
|
588
|
+
pos = structs_3.Position.fromFields(fields);
|
|
589
|
+
positions.push(pos);
|
|
590
|
+
}
|
|
591
|
+
return [2 /*return*/, positions];
|
|
592
|
+
}
|
|
593
|
+
});
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
function getAllPositionsWithTradingSymbol(config, input) {
|
|
597
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
598
|
+
var total, slice, pages, pagePromises, page, results;
|
|
599
|
+
return __generator(this, function (_a) {
|
|
600
|
+
switch (_a.label) {
|
|
601
|
+
case 0: return [4 /*yield*/, getPositionCount(config, { baseToken: input.baseToken })];
|
|
602
|
+
case 1:
|
|
603
|
+
total = _a.sent();
|
|
604
|
+
// 2) 若無倉位直接回傳 []
|
|
605
|
+
if (total === 0) {
|
|
606
|
+
return [2 /*return*/, []];
|
|
607
|
+
}
|
|
608
|
+
slice = Math.min(total, 100);
|
|
609
|
+
pages = Math.ceil(total / slice);
|
|
610
|
+
pagePromises = [];
|
|
611
|
+
for (page = 1; page <= pages; page++) {
|
|
612
|
+
pagePromises.push(getAllPositions(config, {
|
|
613
|
+
baseToken: input.baseToken,
|
|
614
|
+
slice: slice.toString(),
|
|
615
|
+
page: page.toString(),
|
|
616
|
+
}));
|
|
617
|
+
}
|
|
618
|
+
return [4 /*yield*/, Promise.all(pagePromises)];
|
|
619
|
+
case 2:
|
|
620
|
+
results = _a.sent();
|
|
621
|
+
// 5) 扁平化後回傳
|
|
622
|
+
return [2 /*return*/, results.flat()];
|
|
623
|
+
}
|
|
624
|
+
});
|
|
625
|
+
});
|
|
626
|
+
}
|
package/dist/src/index.d.ts
CHANGED
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,8 +30,8 @@ exports.PERP_PACKAGE_ID = exports.NETWORK == "MAINNET"
|
|
|
30
30
|
? "0xe27969a70f93034de9ce16e6ad661b480324574e68d15a64b513fd90eb2423e5"
|
|
31
31
|
: "0x585924f160f83ef16f8927ec117e4d740abb6f4e571ecfa89ff3e973042cb1b9";
|
|
32
32
|
exports.PERP_PUBLISHED_AT = exports.NETWORK == "MAINNET"
|
|
33
|
-
? "
|
|
34
|
-
: "
|
|
33
|
+
? "0xb7e4416296bb3629547b5a0ab24dec17851760eca393c58fb62edbab71c76fa2"
|
|
34
|
+
: "0x910c7a8acc7e91be7a1e3952ce4ee2d443d8ef30236b08fbebcb6cf1ce9f3737";
|
|
35
35
|
exports.PERP_PKG_V1 = exports.NETWORK == "MAINNET"
|
|
36
36
|
? "0xe27969a70f93034de9ce16e6ad661b480324574e68d15a64b513fd90eb2423e5"
|
|
37
37
|
: "0x585924f160f83ef16f8927ec117e4d740abb6f4e571ecfa89ff3e973042cb1b9";
|
|
@@ -40,7 +40,7 @@ exports.STAKE_PACKAGE_ID = exports.NETWORK == "MAINNET"
|
|
|
40
40
|
: "0x220e7ba8923c0c30b57c0baab3bc15d781a39bb294cf7af318c0fc816b5cf7e6";
|
|
41
41
|
exports.STAKE_PUBLISHED_AT = exports.NETWORK == "MAINNET"
|
|
42
42
|
? "0xd9965c09d5ad7d69306b7c550b3b135d94b34f98c3adc379a7333fff2f05808b"
|
|
43
|
-
: "
|
|
43
|
+
: "0xf8fa4a303118328de2fb53f49a043fa5bf58b84f372db0d1e7cf7b1f1a47d10e";
|
|
44
44
|
exports.STAKE_PKG_V1 = exports.NETWORK == "MAINNET"
|
|
45
45
|
? "0xc427209145715a00a93d7e674a95c556a7147d79fda1bbaeb1a1cac5f9923966"
|
|
46
46
|
: "0x220e7ba8923c0c30b57c0baab3bc15d781a39bb294cf7af318c0fc816b5cf7e6";
|
|
@@ -58,6 +58,7 @@ exports.LIQUIDITY_POOL_0 = exports.NETWORK == "MAINNET"
|
|
|
58
58
|
exports.MARKET = exports.NETWORK == "MAINNET"
|
|
59
59
|
? "0xc969d946a2b6b917a83b5fb71765793c4a52149e50d2c8cf5c01d7421fc7cd73"
|
|
60
60
|
: "0xed48f046dc88c49eb01d59669e29eb3006173b66445facb88de277bec2913687";
|
|
61
|
+
// MARKET_0 = 0x442cc2c27cadaf287a5f4413967b4dacc6532bc9063875efbc7b178e5add3e4e
|
|
61
62
|
exports.PERP_VERSION = exports.NETWORK == "MAINNET"
|
|
62
63
|
? "0xa12c282a068328833ec4a9109fc77803ec1f523f8da1bb0f82bac8450335f0c9"
|
|
63
64
|
: "0x80f739d013b365055540346d3b081b19369d6ba83d1ed6291be7a066e0a3c25f";
|
|
@@ -81,3 +82,6 @@ exports.STAKE_POOL_0 = exports.NETWORK == "MAINNET"
|
|
|
81
82
|
exports.STAKE_POOL_VERSION = exports.NETWORK == "MAINNET"
|
|
82
83
|
? "0xdf3ed1599218b2415b2cd7fa06296f7f647676019b2873ec18e55a626c584f1b"
|
|
83
84
|
: "0xafb81680b9ac3d627eb733154c43d34e3ec758cf8e00a55c384df2c8150f7881";
|
|
85
|
+
exports.COMPETITION_CONFIG = exports.NETWORK == "MAINNET"
|
|
86
|
+
? "0x36056abf9adde86f81667dad680a8ac98868c9fc1cb4d519fd2222d5d4522906"
|
|
87
|
+
: "0xbc3914cd777d009afc05e81cd6d006428ce742569c795b0bac493c1b0ef58559";
|
|
@@ -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
|
+
}
|