@shapeshiftoss/swapper 3.0.4 → 3.0.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.
@@ -112,7 +112,6 @@ async function ZrxBuildQuoteTx({ adapterManager, web3 }, { input, wallet }) {
112
112
  sellAssetAccountId,
113
113
  buyAssetAccountId,
114
114
  receiveAddress,
115
- slippage,
116
115
  success: true,
117
116
  rate: data.price,
118
117
  depositAddress: data.to,
@@ -21,7 +21,7 @@ const getZrxMinMax = async (input) => {
21
21
  const minimum = new bignumber_js_1.default(1).dividedBy(new bignumber_js_1.default(usdRate)).toString();
22
22
  return {
23
23
  minimum,
24
- maximum: constants_1.MAX_ZRX_TRADE
24
+ maximum: constants_1.MAX_ZRX_TRADE // Arbitrarily large value. 10e+28 here.
25
25
  };
26
26
  };
27
27
  exports.getZrxMinMax = getZrxMinMax;
@@ -6,13 +6,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getZrxQuote = void 0;
7
7
  const types_1 = require("@shapeshiftoss/types");
8
8
  const bignumber_js_1 = __importDefault(require("bignumber.js"));
9
+ const getZrxMinMax_1 = require("../getZrxMinMax/getZrxMinMax");
10
+ const bignumber_1 = require("../utils/bignumber");
9
11
  const constants_1 = require("../utils/constants");
10
12
  const helpers_1 = require("../utils/helpers/helpers");
11
13
  const zrxService_1 = require("../utils/zrxService");
12
14
  const ZrxSwapper_1 = require("../ZrxSwapper");
13
15
  async function getZrxQuote(input) {
14
16
  var _a, _b, _c, _d, _e, _f, _g;
15
- const { sellAsset, buyAsset, sellAmount, buyAmount, minimum: minQuoteSellAmount, slippage } = input;
17
+ const { sellAsset, buyAsset, sellAmount, buyAmount } = input;
16
18
  if (!buyAsset) {
17
19
  throw new ZrxSwapper_1.ZrxError('getQuote - Missing buyAsset');
18
20
  }
@@ -28,10 +30,8 @@ async function getZrxQuote(input) {
28
30
  const useSellAmount = !!sellAmount;
29
31
  const buyToken = buyAsset.tokenId || buyAsset.symbol;
30
32
  const sellToken = sellAsset.tokenId || sellAsset.symbol;
31
- let minQuoteSellAmountWei = null;
32
- if (minQuoteSellAmount) {
33
- minQuoteSellAmountWei = new bignumber_js_1.default(minQuoteSellAmount).times(new bignumber_js_1.default(10).exponentiatedBy(sellAsset.precision));
34
- }
33
+ const { minimum: minQuoteSellAmount, maximum: maxSellAmount } = await (0, getZrxMinMax_1.getZrxMinMax)(input);
34
+ const minQuoteSellAmountWei = (0, bignumber_1.bnOrZero)(minQuoteSellAmount).times((0, bignumber_1.bnOrZero)(10).exponentiatedBy(sellAsset.precision));
35
35
  const amount = useSellAmount ? { sellAmount } : { buyAmount };
36
36
  const amountKey = Object.keys(amount)[0];
37
37
  const amountValue = Object.values(amount)[0];
@@ -42,7 +42,6 @@ async function getZrxQuote(input) {
42
42
  if (!normalizedAmount || normalizedAmount === '0') {
43
43
  throw new ZrxSwapper_1.ZrxError('getQuote - Must have valid sellAmount, buyAmount or minimum amount');
44
44
  }
45
- const slippagePercentage = slippage ? new bignumber_js_1.default(slippage).div(100).toString() : undefined;
46
45
  try {
47
46
  /**
48
47
  * /swap/v1/price
@@ -57,7 +56,6 @@ async function getZrxQuote(input) {
57
56
  params: {
58
57
  sellToken,
59
58
  buyToken,
60
- slippagePercentage,
61
59
  [amountKey]: normalizedAmount
62
60
  }
63
61
  });
@@ -69,11 +67,10 @@ async function getZrxQuote(input) {
69
67
  return {
70
68
  sellAsset,
71
69
  buyAsset,
72
- slippage,
73
70
  success: true,
74
71
  rate,
75
72
  minimum: minQuoteSellAmount,
76
- maximum: constants_1.MAX_ZRX_TRADE,
73
+ maximum: maxSellAmount,
77
74
  feeData: {
78
75
  fee: new bignumber_js_1.default(estimatedGas || 0)
79
76
  .multipliedBy(new bignumber_js_1.default(data.gasPrice || 0))
@@ -98,8 +95,6 @@ async function getZrxQuote(input) {
98
95
  return {
99
96
  sellAsset,
100
97
  buyAsset,
101
- minimum: minQuoteSellAmount,
102
- maximum: constants_1.MAX_ZRX_TRADE,
103
98
  success: false,
104
99
  statusReason
105
100
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshiftoss/swapper",
3
- "version": "3.0.4",
3
+ "version": "3.0.5",
4
4
  "description": "TODO: description",
5
5
  "repository": "https://github.com/shapeshift/lib",
6
6
  "license": "MIT",