@typus/typus-perp-sdk 1.1.37 → 1.1.39
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.
|
@@ -25,12 +25,12 @@ export interface Event {
|
|
|
25
25
|
is_stop_order?: boolean;
|
|
26
26
|
sender: "user" | "cranker";
|
|
27
27
|
}
|
|
28
|
-
export declare function parseUserHistory(raw_events: any): Promise<Event[]>;
|
|
28
|
+
export declare function parseUserHistory(raw_events: any, matchingDatas: any): Promise<Event[]>;
|
|
29
29
|
export declare function getGraphQLEvents(module: string, sender: string | null, beforeCursor?: string | null): Promise<any>;
|
|
30
30
|
export declare function getLiquidateFromSentio(userAddress: string, startTimestamp: number, events: Event[]): Promise<Event[]>;
|
|
31
31
|
export declare function getRealizeFundingFromSentio(userAddress: string, startTimestamp: number, events: Event[]): Promise<Event[]>;
|
|
32
32
|
export declare function getRemovePositionFromSentio(userAddress: string, startTimestamp: number, events: Event[]): Promise<Event[]>;
|
|
33
33
|
export declare function getCancelOrderFromSentio(userAddress: string, startTimestamp: number, events: Event[]): Promise<Event[]>;
|
|
34
|
-
export declare function getOrderMatchFromSentio(userAddress: string, startTimestamp: number, events: Event[]): Promise<Event[]>;
|
|
34
|
+
export declare function getOrderMatchFromSentio(userAddress: string, startTimestamp: number, events: Event[], datas?: any[]): Promise<Event[]>;
|
|
35
35
|
export declare function getRealizeOptionFromSentio(userAddress: string, startTimestamp: number, events: Event[]): Promise<Event[]>;
|
|
36
36
|
export declare function toSentioToken(name: TOKEN): string;
|
package/dist/src/user/history.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.parseUserHistory = parseUserHistory;
|
|
4
7
|
exports.getGraphQLEvents = getGraphQLEvents;
|
|
@@ -9,6 +12,7 @@ exports.getCancelOrderFromSentio = getCancelOrderFromSentio;
|
|
|
9
12
|
exports.getOrderMatchFromSentio = getOrderMatchFromSentio;
|
|
10
13
|
exports.getRealizeOptionFromSentio = getRealizeOptionFromSentio;
|
|
11
14
|
exports.toSentioToken = toSentioToken;
|
|
15
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
12
16
|
const constants_1 = require("@typus/typus-sdk/dist/src/constants");
|
|
13
17
|
const position_1 = require("../generated/typus_perp/position");
|
|
14
18
|
const trading_1 = require("../generated/typus_perp/trading");
|
|
@@ -16,7 +20,7 @@ const profit_vault_1 = require("../generated/typus_perp/profit_vault");
|
|
|
16
20
|
const lp_pool_1 = require("../generated/typus_perp/lp_pool");
|
|
17
21
|
const sentio_1 = require("../../src/api/sentio");
|
|
18
22
|
const src_1 = require("../../src");
|
|
19
|
-
async function parseUserHistory(raw_events) {
|
|
23
|
+
async function parseUserHistory(raw_events, matchingDatas) {
|
|
20
24
|
const events = [];
|
|
21
25
|
raw_events.forEach((event) => {
|
|
22
26
|
const type = event.contents.type.repr;
|
|
@@ -60,6 +64,24 @@ async function parseUserHistory(raw_events) {
|
|
|
60
64
|
}
|
|
61
65
|
else if (json.reduce_only && json.is_stop_order) {
|
|
62
66
|
order_type = "Stop Loss";
|
|
67
|
+
if (json.linked_position_id != undefined) {
|
|
68
|
+
const related = matchingDatas.findLast((e) => e.position_id === json.linked_position_id &&
|
|
69
|
+
e.base_token === base_token);
|
|
70
|
+
if (related) {
|
|
71
|
+
const positionFilledPrice = related.filled_price;
|
|
72
|
+
const orderTriggerPrice = (0, bignumber_js_1.default)(json.trigger_price).div((0, bignumber_js_1.default)(10).pow(8));
|
|
73
|
+
if (related.side === "Long") {
|
|
74
|
+
if ((0, bignumber_js_1.default)(orderTriggerPrice).gt(positionFilledPrice)) {
|
|
75
|
+
order_type = 'Take Profit';
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
if ((0, bignumber_js_1.default)(orderTriggerPrice).lt(positionFilledPrice)) {
|
|
80
|
+
order_type = 'Take Profit';
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
63
85
|
}
|
|
64
86
|
var e = {
|
|
65
87
|
action: "Place Order",
|
|
@@ -568,8 +590,9 @@ async function getCancelOrderFromSentio(userAddress, startTimestamp, events) {
|
|
|
568
590
|
events = events.sort((a, b) => Number(new Date(a.timestamp)) - Number(new Date(b.timestamp)));
|
|
569
591
|
return events;
|
|
570
592
|
}
|
|
571
|
-
async function getOrderMatchFromSentio(userAddress, startTimestamp, events) {
|
|
572
|
-
|
|
593
|
+
async function getOrderMatchFromSentio(userAddress, startTimestamp, events, datas) {
|
|
594
|
+
if (!datas)
|
|
595
|
+
datas = await (0, sentio_1.getFromSentio)("OrderFilled", userAddress, startTimestamp.toString(), true);
|
|
573
596
|
let order_match = datas.map((x) => {
|
|
574
597
|
let base_token = toToken(x.base_token);
|
|
575
598
|
let txHistory = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typus/typus-perp-sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.39",
|
|
4
4
|
"repository": "https://github.com/Typus-Lab/typus-perp-sdk.git",
|
|
5
5
|
"author": "Typus",
|
|
6
6
|
"description": "typus perp sdk",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@mysten/bcs": "1.9.2",
|
|
10
10
|
"@mysten/sui": "1.44.0",
|
|
11
|
-
"@typus/typus-sdk": "1.8.
|
|
11
|
+
"@typus/typus-sdk": "1.8.36"
|
|
12
12
|
},
|
|
13
13
|
"resolutions": {
|
|
14
14
|
"@mysten/bcs": "1.9.2",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"@types/node": "^24.10.1",
|
|
24
24
|
"@types/rx": "^4.1.2",
|
|
25
25
|
"axios": "^1.13.2",
|
|
26
|
+
"bignumber.js": "9.1.2",
|
|
26
27
|
"prettier": "^3.0.0",
|
|
27
28
|
"ts-node": "^10.9.2",
|
|
28
29
|
"tsc-alias": "^1.8.10",
|
|
@@ -44,4 +45,4 @@
|
|
|
44
45
|
},
|
|
45
46
|
"homepage": "https://github.com/Typus-Lab/typus-perp-sdk#readme",
|
|
46
47
|
"packageManager": "yarn@4.10.3+sha512.c38cafb5c7bb273f3926d04e55e1d8c9dfa7d9c3ea1f36a4868fa028b9e5f72298f0b7f401ad5eb921749eb012eb1c3bb74bf7503df3ee43fd600d14a018266f"
|
|
47
|
-
}
|
|
48
|
+
}
|