@pioneer-platform/thorchain-client 0.18.3 → 0.18.5

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.
@@ -1,5 +1,5 @@
1
1
 
2
2
  
3
- > @pioneer-platform/thorchain-client@0.18.3 build /Users/highlander/WebstormProjects/keepkey-stack/projects/pioneer/modules/intergrations/thorchain
3
+ > @pioneer-platform/thorchain-client@0.18.5 build /Users/highlander/WebstormProjects/keepkey-stack/projects/pioneer/modules/intergrations/thorchain
4
4
  > tsc -p .
5
5
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @pioneer-platform/thorchain-client
2
2
 
3
+ ## 0.18.5
4
+
5
+ ### Patch Changes
6
+
7
+ - chore: fix(pioneer-server): use package exports for @pioneer-platform/nodes
8
+
9
+ ## 0.18.4
10
+
11
+ ### Patch Changes
12
+
13
+ - fix(pioneer-server): use package exports for @pioneer-platform/nodes
14
+
3
15
  ## 0.18.3
4
16
 
5
17
  ### Patch Changes
package/lib/index.js CHANGED
@@ -233,6 +233,36 @@ module.exports = {
233
233
  });
234
234
  });
235
235
  },
236
+ getMarkets: function () {
237
+ return __awaiter(this, void 0, void 0, function () {
238
+ var tag, response, errorText, error_3;
239
+ return __generator(this, function (_a) {
240
+ switch (_a.label) {
241
+ case 0:
242
+ tag = TAG + " | getMarkets | ";
243
+ _a.label = 1;
244
+ case 1:
245
+ _a.trys.push([1, 5, , 6]);
246
+ log.info(tag, "Fetching THORChain markets (pools)");
247
+ return [4 /*yield*/, fetch('https://thornode.ninerealms.com/thorchain/pools')];
248
+ case 2:
249
+ response = _a.sent();
250
+ if (!!response.ok) return [3 /*break*/, 4];
251
+ return [4 /*yield*/, response.text()];
252
+ case 3:
253
+ errorText = _a.sent();
254
+ log.error(tag, "THORNode pools request failed: ".concat(response.status, " - ").concat(errorText));
255
+ throw new Error("THORNode pools request failed: ".concat(response.status));
256
+ case 4: return [2 /*return*/, response];
257
+ case 5:
258
+ error_3 = _a.sent();
259
+ log.error(tag, "Failed to fetch THORChain markets: ".concat(error_3.message));
260
+ throw error_3;
261
+ case 6: return [2 /*return*/];
262
+ }
263
+ });
264
+ });
265
+ },
236
266
  };
237
267
  function getPools() {
238
268
  return __awaiter(this, void 0, void 0, function () {
@@ -263,7 +293,7 @@ function getPools() {
263
293
  }
264
294
  var get_quote = function (quote) {
265
295
  return __awaiter(this, void 0, void 0, function () {
266
- var tag, output, pools, poolIn, poolOut, sellAssetChain, sellAssetParts, sellAssetToken, THORCHAIN_DECIMALS, BASE_UNIT, amountNum, sellAmountInBaseUnits, URL_1, quoteFromNode, expectedOut, nodeMinOut, slippagePercentage, slippageTolerance, slippageAdjustedMin, finalAmountOutMin, amountOutEstimated, memoInput, memo, isEvmChain, txType, e_2, errorMessage;
296
+ var tag, output, pools, poolIn, poolOut, sellAssetChain, sellAssetParts, sellAssetToken, THORCHAIN_DECIMALS, BASE_UNIT, amountNum, sellAmountInBaseUnits, URL_1, quoteFromNode, expectedOut, nodeMinOut, slippagePercentage, slippageTolerance, slippageAdjustedMin, finalAmountOutMin, amountOutEstimated, amountOutMinFormatted, memoInput, memo, isEvmChain, txType, e_2, errorMessage;
267
297
  return __generator(this, function (_a) {
268
298
  switch (_a.label) {
269
299
  case 0:
@@ -336,11 +366,11 @@ var get_quote = function (quote) {
336
366
  throw new Error(quoteFromNode.error);
337
367
  log.info(tag, "quoteFromNode: ", quoteFromNode);
338
368
  expectedOut = parseInt(quoteFromNode.expected_amount_out);
339
- nodeMinOut = parseInt(quoteFromNode.amount_out_min);
369
+ nodeMinOut = quoteFromNode.amount_out_min ? parseInt(quoteFromNode.amount_out_min) : 0;
340
370
  slippagePercentage = quote.slippage || 20;
341
371
  slippageTolerance = slippagePercentage / 100;
342
372
  slippageAdjustedMin = Math.floor(expectedOut * (1 - slippageTolerance));
343
- finalAmountOutMin = Math.max(nodeMinOut, slippageAdjustedMin);
373
+ finalAmountOutMin = nodeMinOut > 0 ? Math.max(nodeMinOut, slippageAdjustedMin) : slippageAdjustedMin;
344
374
  log.info(tag, "Slippage calculation:", {
345
375
  expectedOut: expectedOut,
346
376
  nodeMinOut: nodeMinOut,
@@ -350,7 +380,10 @@ var get_quote = function (quote) {
350
380
  usingNodeMin: finalAmountOutMin === nodeMinOut
351
381
  });
352
382
  amountOutEstimated = (expectedOut / BASE_UNIT).toFixed(THORCHAIN_DECIMALS);
383
+ amountOutMinFormatted = (finalAmountOutMin / BASE_UNIT).toFixed(THORCHAIN_DECIMALS);
353
384
  output.amountOut = amountOutEstimated;
385
+ output.amountOutMin = amountOutMinFormatted;
386
+ output.buyAmount = amountOutEstimated; // Alias for consistency with quote API
354
387
  memoInput = {
355
388
  type: 'SWAP',
356
389
  asset: quote.buyAsset,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pioneer-platform/thorchain-client",
3
- "version": "0.18.3",
3
+ "version": "0.18.5",
4
4
  "main": "./lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "dependencies": {
@@ -8,9 +8,9 @@
8
8
  "dotenv": "^17.2.3",
9
9
  "rango-sdk": "^0.1.45",
10
10
  "uuidv4": "^6.2.13",
11
- "@pioneer-platform/loggerdog": "8.11.0",
12
11
  "@pioneer-platform/pioneer-caip": "9.19.3",
13
- "@pioneer-platform/pioneer-coins": "9.18.3"
12
+ "@pioneer-platform/pioneer-coins": "9.18.3",
13
+ "@pioneer-platform/loggerdog": "8.11.0"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@types/jest": "^25.2.3",