@shapeshiftoss/swapper 9.11.1 → 9.12.0

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.
package/dist/api.d.ts CHANGED
@@ -173,6 +173,7 @@ export declare enum SwapErrorTypes {
173
173
  RESPONSE_ERROR = "RESPONSE_ERROR",
174
174
  SIGN_AND_BROADCAST_FAILED = "SIGN_AND_BROADCAST_FAILED",
175
175
  TRADE_QUOTE_FAILED = "TRADE_QUOTE_FAILED",
176
+ TRADE_QUOTE_INPUT_LOWER_THAN_FEES = "TRADE_QUOTE_INPUT_LOWER_THAN_FEES",
176
177
  UNSUPPORTED_PAIR = "UNSUPPORTED_PAIR",
177
178
  USD_RATE_FAILED = "USD_RATE_FAILED",
178
179
  UNSUPPORTED_CHAIN = "UNSUPPORTED_CHAIN",
package/dist/api.js CHANGED
@@ -28,6 +28,7 @@ var SwapErrorTypes;
28
28
  SwapErrorTypes["RESPONSE_ERROR"] = "RESPONSE_ERROR";
29
29
  SwapErrorTypes["SIGN_AND_BROADCAST_FAILED"] = "SIGN_AND_BROADCAST_FAILED";
30
30
  SwapErrorTypes["TRADE_QUOTE_FAILED"] = "TRADE_QUOTE_FAILED";
31
+ SwapErrorTypes["TRADE_QUOTE_INPUT_LOWER_THAN_FEES"] = "TRADE_QUOTE_INPUT_LOWER_THAN_FEES";
31
32
  SwapErrorTypes["UNSUPPORTED_PAIR"] = "UNSUPPORTED_PAIR";
32
33
  SwapErrorTypes["USD_RATE_FAILED"] = "USD_RATE_FAILED";
33
34
  SwapErrorTypes["UNSUPPORTED_CHAIN"] = "UNSUPPORTED_CHAIN";
@@ -1,8 +1,12 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.getCowSwapTradeQuote = void 0;
4
7
  const caip_1 = require("@shapeshiftoss/caip");
5
8
  const types_1 = require("@shapeshiftoss/types");
9
+ const axios_1 = __importDefault(require("axios"));
6
10
  const api_1 = require("../../../api");
7
11
  const bignumber_1 = require("../../utils/bignumber");
8
12
  const helpers_1 = require("../../utils/helpers/helpers");
@@ -11,6 +15,7 @@ const constants_1 = require("../utils/constants");
11
15
  const cowService_1 = require("../utils/cowService");
12
16
  const helpers_2 = require("../utils/helpers/helpers");
13
17
  async function getCowSwapTradeQuote(deps, input) {
18
+ var _a, _b;
14
19
  try {
15
20
  const { sellAsset, buyAsset, sellAmount, sellAssetAccountNumber, wallet } = input;
16
21
  const { adapter, web3 } = deps;
@@ -113,6 +118,15 @@ async function getCowSwapTradeQuote(deps, input) {
113
118
  };
114
119
  }
115
120
  catch (e) {
121
+ if (axios_1.default.isAxiosError(e) &&
122
+ ((_a = e.response) === null || _a === void 0 ? void 0 : _a.status) === 400 &&
123
+ ((_b = e.response) === null || _b === void 0 ? void 0 : _b.data.errorType) ===
124
+ 'SellAmountDoesNotCoverFee') {
125
+ throw new api_1.SwapError('[getCowSwapTradeQuote]', {
126
+ cause: e,
127
+ code: api_1.SwapErrorTypes.TRADE_QUOTE_INPUT_LOWER_THAN_FEES
128
+ });
129
+ }
116
130
  if (e instanceof api_1.SwapError)
117
131
  throw e;
118
132
  throw new api_1.SwapError('[getCowSwapTradeQuote]', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshiftoss/swapper",
3
- "version": "9.11.1",
3
+ "version": "9.12.0",
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",