@typus/typus-perp-sdk 1.0.10 → 1.0.11

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.
@@ -64,31 +64,37 @@ var constants_1 = require("@typus/typus-sdk/dist/src/constants");
64
64
  function createTradingOrder(config, tx, pythClient, input) {
65
65
  return __awaiter(this, void 0, void 0, function () {
66
66
  var TOKEN, BASE_TOKEN, cToken, baseToken, coin, destination;
67
- var _a, _b, _c;
68
- return __generator(this, function (_d) {
69
- switch (_d.label) {
67
+ var _a, _b, _c, _d;
68
+ return __generator(this, function (_e) {
69
+ switch (_e.label) {
70
70
  case 0:
71
71
  TOKEN = input.cToken;
72
72
  BASE_TOKEN = input.tradingToken;
73
73
  return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, [TOKEN, BASE_TOKEN])];
74
74
  case 1:
75
- _d.sent();
75
+ _e.sent();
76
76
  cToken = constants_1.tokenType[__1.NETWORK][TOKEN];
77
77
  baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
78
78
  if (TOKEN == "SUI") {
79
- _a = __read(tx.splitCoins(tx.gas, [input.amount]), 1), coin = _a[0];
79
+ if (input.coins.length == 0) {
80
+ // support zero coin input for closing position
81
+ _a = __read(zeroCoin(tx, [cToken]), 1), coin = _a[0];
82
+ }
83
+ else {
84
+ _b = __read(tx.splitCoins(tx.gas, [input.amount]), 1), coin = _b[0];
85
+ }
80
86
  }
81
87
  else {
82
88
  if (input.coins.length == 0) {
83
89
  // support zero coin input for closing position
84
- _b = __read(zeroCoin(tx, [cToken]), 1), coin = _b[0];
90
+ _c = __read(zeroCoin(tx, [cToken]), 1), coin = _c[0];
85
91
  }
86
92
  else {
87
93
  destination = input.coins.pop();
88
94
  if (input.coins.length > 0) {
89
95
  tx.mergeCoins(destination, input.coins);
90
96
  }
91
- _c = __read(tx.splitCoins(destination, [input.amount]), 1), coin = _c[0];
97
+ _d = __read(tx.splitCoins(destination, [input.amount]), 1), coin = _d[0];
92
98
  }
93
99
  }
94
100
  (0, functions_1.createTradingOrder)(tx, [cToken, baseToken], {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typus/typus-perp-sdk",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "repository": "https://github.com/Typus-Lab/typus-perp-sdk.git",
5
5
  "author": "Typus",
6
6
  "description": "typus perp sdk",