@typus/typus-perp-sdk 1.0.52-upgrade → 1.0.53-upgrade

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/index.js CHANGED
@@ -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
- ? "0xe27969a70f93034de9ce16e6ad661b480324574e68d15a64b513fd90eb2423e5"
33
+ ? "0xeb018055af198e99a368ccda030e9aef07ffb86aa5de83e98734913064b0cff4"
34
34
  : "0x15844f80fb085bb8fd7cc688ade6282cd6991209eae78934ca001dced8b1b7de";
35
35
  exports.PERP_PKG_V1 = exports.NETWORK == "MAINNET"
36
36
  ? "0xe27969a70f93034de9ce16e6ad661b480324574e68d15a64b513fd90eb2423e5"
@@ -424,6 +424,8 @@ function getOrderMatchFromSentio(userAddress, startTimestamp, events) {
424
424
  }
425
425
  else {
426
426
  x.order_type = "Market";
427
+ var related_1 = events.findLast(function (e) { return e.position_id == x.position_id && e.market == x.market; });
428
+ x.dov_index = related_1 === null || related_1 === void 0 ? void 0 : related_1.dov_index;
427
429
  }
428
430
  return x;
429
431
  });
@@ -456,7 +458,7 @@ function getRealizeOptionFromSentio(userAddress, startTimestamp, events) {
456
458
  status: "Filled",
457
459
  size: undefined,
458
460
  base_token: base_token,
459
- collateral: Number(x.exercise_balance_value),
461
+ collateral: Number(x.user_remaining_value),
460
462
  collateral_token: x.collateral_token,
461
463
  price: undefined,
462
464
  realized_pnl: Number(x.user_remaining_in_usd),
@@ -469,7 +471,7 @@ function getRealizeOptionFromSentio(userAddress, startTimestamp, events) {
469
471
  return txHistory;
470
472
  });
471
473
  filter_exercise = exercise.reduce(function (acc, x) {
472
- var _a, _b, _c, _d;
474
+ var _a, _b;
473
475
  var related_index = events.findLastIndex(function (e) { return e.position_id == x.position_id && e.market == x.market && e.tx_digest == x.tx_digest; });
474
476
  // console.log(x);
475
477
  // console.log(related_index);
@@ -480,8 +482,8 @@ function getRealizeOptionFromSentio(userAddress, startTimestamp, events) {
480
482
  x.size = related.size;
481
483
  x.dov_index = related.dov_index;
482
484
  // add to close event
483
- related.collateral = Number((_a = related.collateral) !== null && _a !== void 0 ? _a : 0) + Number((_b = x.collateral) !== null && _b !== void 0 ? _b : 0);
484
- related.realized_pnl = Number((_c = related.realized_pnl) !== null && _c !== void 0 ? _c : 0) + Number((_d = x.realized_pnl) !== null && _d !== void 0 ? _d : 0);
485
+ related.collateral = x.collateral;
486
+ related.realized_pnl = Number((_a = related.realized_pnl) !== null && _a !== void 0 ? _a : 0) + Number((_b = x.realized_pnl) !== null && _b !== void 0 ? _b : 0);
485
487
  x.collateral = undefined;
486
488
  x.realized_pnl = undefined;
487
489
  acc.push(x);
@@ -35,17 +35,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
36
  }
37
37
  };
38
- var __values = (this && this.__values) || function(o) {
39
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
40
- if (m) return m.call(o);
41
- if (o && typeof o.length === "number") return {
42
- next: function () {
43
- if (o && i >= o.length) o = void 0;
44
- return { value: o && o[i++], done: !o };
45
- }
46
- };
47
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
48
- };
49
38
  var __read = (this && this.__read) || function (o, n) {
50
39
  var m = typeof Symbol === "function" && o[Symbol.iterator];
51
40
  if (!m) return o;
@@ -62,6 +51,17 @@ var __read = (this && this.__read) || function (o, n) {
62
51
  }
63
52
  return ar;
64
53
  };
54
+ var __values = (this && this.__values) || function(o) {
55
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
56
+ if (m) return m.call(o);
57
+ if (o && typeof o.length === "number") return {
58
+ next: function () {
59
+ if (o && i >= o.length) o = void 0;
60
+ return { value: o && o[i++], done: !o };
61
+ }
62
+ };
63
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
64
+ };
65
65
  Object.defineProperty(exports, "__esModule", { value: true });
66
66
  exports.createTradingOrder = createTradingOrder;
67
67
  exports.zeroCoin = zeroCoin;
@@ -74,54 +74,54 @@ var utils_1 = require("@typus/typus-sdk/dist/src/utils");
74
74
  var constants_1 = require("@typus/typus-sdk/dist/src/constants");
75
75
  function createTradingOrder(config, tx, pythClient, input) {
76
76
  return __awaiter(this, void 0, void 0, function () {
77
- var TOKEN, BASE_TOKEN, tokens, tokens_1, tokens_1_1, token, cToken, baseToken, coin, destination;
78
- var e_1, _a, _b, _c, _d, _e;
77
+ var TOKEN, BASE_TOKEN, cToken, baseToken, coin, destination, tokens, tokens_1, tokens_1_1, token;
78
+ var _a, _b, _c, _d, e_1, _e;
79
79
  return __generator(this, function (_f) {
80
80
  switch (_f.label) {
81
81
  case 0:
82
82
  TOKEN = input.cToken;
83
83
  BASE_TOKEN = input.tradingToken;
84
- tokens = Array.from(new Set([TOKEN, BASE_TOKEN]));
85
- return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, tokens)];
86
- case 1:
87
- _f.sent();
88
- try {
89
- for (tokens_1 = __values(tokens), tokens_1_1 = tokens_1.next(); !tokens_1_1.done; tokens_1_1 = tokens_1.next()) {
90
- token = tokens_1_1.value;
91
- (0, utils_1.updateOracleWithPythUsd)(pythClient, tx, config.package.oracle, token);
92
- }
93
- }
94
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
95
- finally {
96
- try {
97
- if (tokens_1_1 && !tokens_1_1.done && (_a = tokens_1.return)) _a.call(tokens_1);
98
- }
99
- finally { if (e_1) throw e_1.error; }
100
- }
101
84
  cToken = constants_1.tokenType[__1.NETWORK][TOKEN];
102
85
  baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
103
86
  if (TOKEN == "SUI") {
104
87
  if (input.coins.length == 0) {
105
88
  // support zero coin input for closing position
106
- _b = __read(zeroCoin(tx, [cToken]), 1), coin = _b[0];
89
+ _a = __read(zeroCoin(tx, [cToken]), 1), coin = _a[0];
107
90
  }
108
91
  else {
109
- _c = __read(tx.splitCoins(tx.gas, [input.amount]), 1), coin = _c[0];
92
+ _b = __read(tx.splitCoins(tx.gas, [input.amount]), 1), coin = _b[0];
110
93
  }
111
94
  }
112
95
  else {
113
96
  if (input.coins.length == 0) {
114
97
  // support zero coin input for closing position
115
- _d = __read(zeroCoin(tx, [cToken]), 1), coin = _d[0];
98
+ _c = __read(zeroCoin(tx, [cToken]), 1), coin = _c[0];
116
99
  }
117
100
  else {
118
101
  destination = input.coins.pop();
119
102
  if (input.coins.length > 0) {
120
103
  tx.mergeCoins(destination, input.coins);
121
104
  }
122
- _e = __read(tx.splitCoins(destination, [input.amount]), 1), coin = _e[0];
105
+ _d = __read(tx.splitCoins(destination, [input.amount]), 1), coin = _d[0];
123
106
  }
124
107
  }
108
+ tokens = Array.from(new Set([TOKEN, BASE_TOKEN]));
109
+ return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, tokens)];
110
+ case 1:
111
+ _f.sent();
112
+ try {
113
+ for (tokens_1 = __values(tokens), tokens_1_1 = tokens_1.next(); !tokens_1_1.done; tokens_1_1 = tokens_1.next()) {
114
+ token = tokens_1_1.value;
115
+ (0, utils_1.updateOracleWithPythUsd)(pythClient, tx, config.package.oracle, token);
116
+ }
117
+ }
118
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
119
+ finally {
120
+ try {
121
+ if (tokens_1_1 && !tokens_1_1.done && (_e = tokens_1.return)) _e.call(tokens_1);
122
+ }
123
+ finally { if (e_1) throw e_1.error; }
124
+ }
125
125
  (0, functions_1.createTradingOrder)(tx, [cToken, baseToken], {
126
126
  version: __1.PERP_VERSION,
127
127
  registry: __1.MARKET,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typus/typus-perp-sdk",
3
- "version": "1.0.52-upgrade",
3
+ "version": "1.0.53-upgrade",
4
4
  "repository": "https://github.com/Typus-Lab/typus-perp-sdk.git",
5
5
  "author": "Typus",
6
6
  "description": "typus perp sdk",