@alcorexchange/alcor-swap-sdk 1.0.21 → 1.0.22

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.
@@ -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.22",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
@@ -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(),