@alcorexchange/alcor-swap-sdk 1.0.21 → 1.0.23

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.
@@ -497,7 +497,7 @@ class Trade {
497
497
  const trade = yield Trade.fromRoute(new route_1.Route([...freshPools], route.input, route.output), currencyAmountIn, internalConstants_1.TradeType.EXACT_INPUT);
498
498
  // FIXME! Sorting bug multiple pools
499
499
  if (!trade.inputAmount.greaterThan(0) || !trade.priceImpact.greaterThan(0)) {
500
- console.log('continue trade', (0, utils_1.parseTrade)(trade));
500
+ //console.log('continue trade', parseTrade(trade))
501
501
  continue;
502
502
  }
503
503
  (0, utils_1.sortedInsert)(bestTrades, trade, maxNumResults, tradeComparator);
@@ -514,7 +514,7 @@ class Trade {
514
514
  const freshPools = route.pools.map(p => poolsMap.get(p.id));
515
515
  const trade = yield Trade.fromRoute(new route_1.Route([...freshPools], route.input, route.output), currencyAmountOut, internalConstants_1.TradeType.EXACT_OUTPUT);
516
516
  if (!trade.inputAmount.greaterThan(0) || !trade.priceImpact.greaterThan(0)) {
517
- console.log('continue trade', (0, utils_1.parseTrade)(trade));
517
+ //console.log('continue trade', parseTrade(trade))
518
518
  continue;
519
519
  }
520
520
  (0, utils_1.sortedInsert)(bestTrades, trade, maxNumResults, tradeComparator);
@@ -2,15 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseTrade = void 0;
4
4
  const entities_1 = require("../entities");
5
+ const internalConstants_1 = require("../internalConstants");
5
6
  function parseTrade(trade) {
6
7
  // Parse Trade into api format object
7
- // 1.0000 EOS
8
8
  const slippage = new entities_1.Percent(3, 100); // 0.3%
9
- const receiver = 'myaccount';
9
+ const receiver = '<receiver>';
10
+ const tradeType = trade.tradeType == internalConstants_1.TradeType.EXACT_INPUT ? 'swapexactin' : 'swapexactout';
10
11
  const route = trade.route.pools.map(p => p.id);
11
12
  const maxSent = trade.inputAmount;
12
13
  const minReceived = trade.minimumAmountOut(slippage);
13
- const memo = `swapexactin#${route.join(',')}#${receiver}#${minReceived.toExtendedAsset()}#0`;
14
+ const memo = `${tradeType}#${route.join(',')}#${receiver}#${minReceived.toExtendedAsset()}#0`;
14
15
  const result = {
15
16
  input: trade.inputAmount.toFixed(),
16
17
  output: trade.outputAmount.toFixed(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alcorexchange/alcor-swap-sdk",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
@@ -720,7 +720,7 @@ export class Trade<TInput extends Currency, TOutput extends Currency, TTradeType
720
720
 
721
721
  // FIXME! Sorting bug multiple pools
722
722
  if (!trade.inputAmount.greaterThan(0) || !trade.priceImpact.greaterThan(0)) {
723
- console.log('continue trade', parseTrade(trade))
723
+ //console.log('continue trade', parseTrade(trade))
724
724
  continue
725
725
  }
726
726
 
@@ -755,7 +755,7 @@ export class Trade<TInput extends Currency, TOutput extends Currency, TTradeType
755
755
  )
756
756
 
757
757
  if (!trade.inputAmount.greaterThan(0) || !trade.priceImpact.greaterThan(0)) {
758
- console.log('continue trade', parseTrade(trade))
758
+ //console.log('continue trade', parseTrade(trade))
759
759
  continue
760
760
  }
761
761
 
@@ -1,15 +1,17 @@
1
1
  import { Percent } from "../entities"
2
+ import { TradeType } from "../internalConstants"
2
3
 
3
4
  export function parseTrade(trade) {
4
5
  // Parse Trade into api format object
5
- // 1.0000 EOS
6
6
  const slippage = new Percent(3, 100) // 0.3%
7
- const receiver = 'myaccount'
7
+ const receiver = '<receiver>'
8
+
9
+ const tradeType = trade.tradeType == TradeType.EXACT_INPUT ? 'swapexactin' : 'swapexactout'
8
10
 
9
11
  const route = trade.route.pools.map(p => p.id)
10
12
  const maxSent = trade.inputAmount
11
13
  const minReceived = trade.minimumAmountOut(slippage)
12
- const memo = `swapexactin#${route.join(',')}#${receiver}#${minReceived.toExtendedAsset()}#0`
14
+ const memo = `${tradeType}#${route.join(',')}#${receiver}#${minReceived.toExtendedAsset()}#0`
13
15
 
14
16
  const result = {
15
17
  input: trade.inputAmount.toFixed(),