@shapeshiftoss/swapper 14.2.1 → 14.2.3

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.
@@ -210,7 +210,7 @@ const performIbcTransfer = async (input, adapter, wallet, blockBaseUrl, denom, s
210
210
  txToSign: {
211
211
  tx,
212
212
  addressNList: (0, chain_adapters_1.toAddressNList)(adapter.buildBIP44Params({ accountNumber: 0 })),
213
- chain_id: caip_1.CHAIN_REFERENCE.OsmosisMainnet,
213
+ chain_id: (0, caip_1.fromChainId)(adapter.getChainId()).chainReference,
214
214
  account_number: accountNumber,
215
215
  sequence,
216
216
  },
@@ -56,13 +56,19 @@ const getLimit = async ({ sellAsset, buyAssetId, sellAmountCryptoPrecision, deps
56
56
  }
57
57
  })();
58
58
  const highestPossibleFeeCryptoPrecision8 = (0, max_1.default)([
59
- buyAssetTradeFeeCryptoPrecision8,
60
- refundFeeBuyAssetCryptoPrecision8,
59
+ // both fees are denominated in buy asset crypto precision 8
60
+ (0, bignumber_1.bnOrZero)(buyAssetTradeFeeCryptoPrecision8).toNumber(),
61
+ (0, bignumber_1.bnOrZero)(refundFeeBuyAssetCryptoPrecision8).toNumber(),
61
62
  ]);
62
- return (0, bignumber_1.bnOrZero)(expectedBuyAmountCryptoPrecision8)
63
+ const expectedBuyAmountAfterHighestFeeCryptoPrecision8 = (0, bignumber_1.bnOrZero)(expectedBuyAmountCryptoPrecision8)
63
64
  .times((0, bignumber_1.bn)(1).minus(slippageTolerance))
64
- .minus((0, bignumber_1.bnOrZero)(highestPossibleFeeCryptoPrecision8))
65
- .decimalPlaces(0)
66
- .toString();
65
+ .minus(highestPossibleFeeCryptoPrecision8 !== null && highestPossibleFeeCryptoPrecision8 !== void 0 ? highestPossibleFeeCryptoPrecision8 : 0)
66
+ .decimalPlaces(0);
67
+ // expectedBuyAmountAfterHighestFeeCryptoPrecision8 can be negative if the sell asset has a higher inbound_fee
68
+ // (a refund) than the buy asset's inbound_fee + buy amount.
69
+ // I.e. we've come this far - we don't have enough to refund, so the limit can slide all the way to 0.
70
+ return expectedBuyAmountAfterHighestFeeCryptoPrecision8.isPositive()
71
+ ? expectedBuyAmountAfterHighestFeeCryptoPrecision8.toString()
72
+ : '0';
67
73
  };
68
74
  exports.getLimit = getLimit;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshiftoss/swapper",
3
- "version": "14.2.1",
3
+ "version": "14.2.3",
4
4
  "description": "An interface and implementations to trade coins via various protocols",
5
5
  "repository": "https://github.com/shapeshift/lib",
6
6
  "license": "MIT",