@typus/typus-perp-sdk 1.1.32-codegen-exp22 → 1.1.32-codegen-exp24
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 +3 -3
- package/dist/src/api/sentio.js +94 -21
- package/dist/src/fetch.js +1 -3
- package/dist/src/index.js +12 -12
- package/dist/src/user/order.d.ts +0 -1
- package/dist/src/user/order.js +1 -2
- package/package.json +1 -1
package/dist/src/api/sentio.d.ts
CHANGED
|
@@ -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,7 +25,7 @@ export declare function getAccumulatedUser(): Promise<number>;
|
|
|
25
25
|
* fromTimestamp: number, toTimestamp?: number
|
|
26
26
|
*
|
|
27
27
|
* Returns
|
|
28
|
-
* { timestamp: string
|
|
28
|
+
* Map<string, { timestamp: string; value: number }[]>
|
|
29
29
|
*/
|
|
30
30
|
export declare function getTlpPriceFromSentio(fromTimestamp?: number, toTimestamp?: number): Promise<Map<string, {
|
|
31
31
|
timestamp: string;
|
package/dist/src/api/sentio.js
CHANGED
|
@@ -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.
|
|
315
|
+
// console.dir(data, { depth: null });
|
|
282
316
|
// console.log(data.results[0].matrix.samples[0].values);
|
|
283
|
-
let
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
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:
|
|
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.
|
|
330
|
-
let
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
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,12 +463,11 @@ async function getAccumulatedUser() {
|
|
|
389
463
|
* fromTimestamp: number, toTimestamp?: number
|
|
390
464
|
*
|
|
391
465
|
* Returns
|
|
392
|
-
* { timestamp: string
|
|
466
|
+
* Map<string, { timestamp: string; value: number }[]>
|
|
393
467
|
*/
|
|
394
468
|
async function getTlpPriceFromSentio(fromTimestamp, toTimestamp) {
|
|
395
469
|
let apiUrl = "https://api.sentio.xyz/v1/insights/typus/typus_perp/query";
|
|
396
470
|
let requestData = {
|
|
397
|
-
version: 3,
|
|
398
471
|
timeRange: {
|
|
399
472
|
start: `${fromTimestamp ?? 0}`,
|
|
400
473
|
end: `${toTimestamp ?? now()}`,
|
|
@@ -680,7 +753,7 @@ async function getLeaderboardFromSentio(startTs, endTs) {
|
|
|
680
753
|
// getAccumulatedUser().then((x) => console.log(x));
|
|
681
754
|
// getTradingVolumeFromSentio(1747008000, 1, 1747011600);
|
|
682
755
|
// getTlpPriceFromSentio(0).then((x) => console.dir(x, { depth: null }));
|
|
683
|
-
// getTotalVolumeFromSentio(
|
|
756
|
+
// getTotalVolumeFromSentio().then((x) => console.log(x));
|
|
684
757
|
// getTlpFeeFromSentio(0).then((x) => console.log(x));
|
|
685
758
|
// getUserPnlFromSentio(parseTimestamp("2025-06-24 11:00:00"), parseTimestamp("2025-07-08 11:00:00")).then((x) => console.log(x));
|
|
686
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
|
-
|
|
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
|
package/dist/src/index.js
CHANGED
|
@@ -26,42 +26,42 @@ dotenv_1.default.config();
|
|
|
26
26
|
// default MAINNET
|
|
27
27
|
exports.NETWORK = process.env.NEXT_PUBLIC_CLUSTER == "testnet" ? "TESTNET" : "MAINNET";
|
|
28
28
|
exports.PERP_PACKAGE_ID = exports.NETWORK == "MAINNET"
|
|
29
|
-
? "
|
|
29
|
+
? "0x46acca74c6bbba9d0f286e9741444485808f2be493a8baeee1bf7a6ea067c670"
|
|
30
30
|
: "0x94cd358f552e9dd5df837de85939a9d1d682e97480740a203121e6f4c0078853";
|
|
31
31
|
exports.STAKE_PACKAGE_ID = exports.NETWORK == "MAINNET"
|
|
32
|
-
? "
|
|
32
|
+
? "0x39addbf74f24fc4dcef507a229be8ba6dcbc7ffce34bc1c0b4225ba4cd1677a7"
|
|
33
33
|
: "0x02b94b340a8810f6c451bc244dc2dd8d9d50cf86d727798969ca2c287c3186aa";
|
|
34
34
|
// lp_pool::Registry
|
|
35
35
|
exports.LP_POOL = exports.NETWORK == "MAINNET"
|
|
36
|
-
? "
|
|
36
|
+
? "0x9e9855b4ac00e407a0719a6542b9be76d886b499bf1d763a79f56d139830fd3a"
|
|
37
37
|
: "0x85fa3cc6dc0fa8b47dda95ba0335fe1cec61dde4a2a8486ccd040f94d399b4c3";
|
|
38
38
|
// liquidity_pool_registry
|
|
39
39
|
exports.LIQUIDITY_POOL = exports.NETWORK == "MAINNET"
|
|
40
|
-
? "
|
|
40
|
+
? "0x32db917d2ed873a5bd8664efb220bfc7af4175638e30c8fc2b69b80888aab5d2"
|
|
41
41
|
: "0xe034d157764f273df5a1e264a3c0f78d8f922c37f942c340dabb1d66244c72ba";
|
|
42
42
|
// MarketRegistry
|
|
43
43
|
exports.MARKET = exports.NETWORK == "MAINNET"
|
|
44
|
-
? "
|
|
44
|
+
? "0xdcc27865c3668dcad62fecee867e219a2d3a8f7920bcfe2ffe5f0949442adf37"
|
|
45
45
|
: "0xd0685e3eca9530f0618625d4a617a80db09f000609285b32a85f863da6baf811";
|
|
46
46
|
exports.PERP_VERSION = exports.NETWORK == "MAINNET"
|
|
47
|
-
? "
|
|
47
|
+
? "0x70abe0418b654d6bae8f860aeebb8912c05534ededf67289a61cd48de679b450"
|
|
48
48
|
: "0xbb0615832168e64e301db2ebd6ad71b3fe170d7e217ccd0c08714de56b41676b";
|
|
49
49
|
exports.TLP_TREASURY_CAP = exports.NETWORK == "MAINNET"
|
|
50
|
-
? "
|
|
50
|
+
? "0x791498ed6eea0680052f262b388e0bea46e1dfdb976f2ca7ab9183142f5d2045"
|
|
51
51
|
: "0x1b39c2a5bc109ac520787c62f924da9244343e869bad755157e6e3e22bd7b7ae";
|
|
52
52
|
// StakePoolRegistry
|
|
53
53
|
exports.STAKE_POOL = exports.NETWORK == "MAINNET"
|
|
54
|
-
? "
|
|
54
|
+
? "0xf26906bd797b32a55c4ec479102c1b74eea5b3795d4a9af0bbb29c171c110826"
|
|
55
55
|
: "0x8e5e5435c3fcd77f07cf097c5fbd381af7c2b394420ea035685662215471e578";
|
|
56
56
|
exports.STAKE_POOL_VERSION = exports.NETWORK == "MAINNET"
|
|
57
|
-
? "
|
|
57
|
+
? "0x2f33ef6920dd63ab2089aa28f91c564cf15c008e507ceb915c286f3fc28e06a8"
|
|
58
58
|
: "0x02b94b340a8810f6c451bc244dc2dd8d9d50cf86d727798969ca2c287c3186aa";
|
|
59
59
|
exports.COMPETITION_CONFIG = exports.NETWORK == "MAINNET"
|
|
60
|
-
? "
|
|
60
|
+
? "0xd9f4468854e5e352072a9c9e023eaea096b5314e75832c49e23555c5f0a00472"
|
|
61
61
|
: "0x2b811b120177839555aabdc2c28b28078170e663e855d29aa9072013d4fc918d";
|
|
62
62
|
exports.PROFIT_VAULT = exports.NETWORK == "MAINNET"
|
|
63
|
-
? "" // TODO: Add mainnet PROFIT_VAULT address
|
|
63
|
+
? "0xc7cc07321b9b34339f65c8b7dbfa31503421c261069df907bbde265f16e74c80" // TODO: Add mainnet PROFIT_VAULT address
|
|
64
64
|
: "0xb1d603139b24db2c46f6a423c8613ce677f329a0b159ff6e57672f3b663aec47"; // TODO: Add testnet PROFIT_VAULT address
|
|
65
65
|
exports.LOCK_VAULT = exports.NETWORK == "MAINNET"
|
|
66
|
-
? "" // TODO: Add mainnet LOCK_VAULT address
|
|
66
|
+
? "0xb4a67eafb124ad2d27c464de47e47eacc1d054bf04f38ee5be92add2d3010d92" // TODO: Add mainnet LOCK_VAULT address
|
|
67
67
|
: "0x25dd9540f031b9a62b83784a727e1ef410f9aa91ecf7e3bb27a0c61f8ceecbfb"; // TODO: Add testnet LOCK_VAULT address
|
package/dist/src/user/order.d.ts
CHANGED
|
@@ -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;
|
package/dist/src/user/order.js
CHANGED
|
@@ -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
|
-
|
|
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: {
|