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

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.
@@ -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",
4
4
  "repository": "https://github.com/Typus-Lab/typus-perp-sdk.git",
5
5
  "author": "Typus",
6
6
  "description": "typus perp sdk",