@shapeshiftoss/swapper 11.0.1 → 11.1.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
@@ -108,7 +108,7 @@ interface TradeBase<C extends ChainId> {
108
108
  sellAmount: string;
109
109
  feeData: QuoteFeeData<C>;
110
110
  rate: string;
111
- sources: Array<SwapSource>;
111
+ sources: SwapSource[];
112
112
  buyAsset: Asset;
113
113
  sellAsset: Asset;
114
114
  sellAssetAccountNumber: number;
@@ -22,7 +22,7 @@ export declare type CowSwapGetOrdersResponse = {
22
22
  export declare type CowSwapGetTradesElement = {
23
23
  txHash: string;
24
24
  };
25
- export declare type CowSwapGetTradesResponse = Array<CowSwapGetTradesElement>;
25
+ export declare type CowSwapGetTradesResponse = CowSwapGetTradesElement[];
26
26
  export interface CowTrade<C extends ChainId> extends Trade<C> {
27
27
  feeAmountInSellToken: string;
28
28
  sellAmountWithoutFee: string;
@@ -8,7 +8,7 @@ export declare const ORDER_TYPE_FIELDS: {
8
8
  /**
9
9
  * EIP-712 typed data type definitions.
10
10
  */
11
- export declare type TypedDataTypes = Record<string, Array<TypedDataField>>;
11
+ export declare type TypedDataTypes = Record<string, TypedDataField[]>;
12
12
  export declare type CowSwapOrder = {
13
13
  sellToken: string;
14
14
  buyToken: string;
@@ -41,7 +41,7 @@ export declare const buildTradeTx: ({ osmoAddress, adapter, buyAssetDenom, sellA
41
41
  }[];
42
42
  gas: string;
43
43
  };
44
- signatures: null;
44
+ signatures: never[];
45
45
  msg: {
46
46
  type: string;
47
47
  value: {
@@ -189,7 +189,7 @@ const performIbcTransfer = async (input, adapter, wallet, blockBaseUrl, denom, s
189
189
  ],
190
190
  gas,
191
191
  },
192
- signatures: null,
192
+ signatures: [],
193
193
  msg: [
194
194
  {
195
195
  type: 'cosmos-sdk/MsgTransfer',
@@ -247,7 +247,7 @@ const buildTradeTx = async ({ osmoAddress, adapter, buyAssetDenom, sellAssetDeno
247
247
  ],
248
248
  gas,
249
249
  },
250
- signatures: null,
250
+ signatures: [],
251
251
  msg: [
252
252
  {
253
253
  type: 'osmosis/gamm/swap-exact-amount-in',
@@ -10,8 +10,10 @@ const constants_2 = require("../utils/constants");
10
10
  const estimateTradeFee_1 = require("../utils/estimateTradeFee/estimateTradeFee");
11
11
  const getThorTxData_2 = require("../utils/ethereum/utils/getThorTxData");
12
12
  const getTradeRate_1 = require("../utils/getTradeRate/getTradeRate");
13
+ const getUsdRate_1 = require("../utils/getUsdRate/getUsdRate");
13
14
  const getBtcTxFees_1 = require("../utils/txFeeHelpers/btcTxFees/getBtcTxFees");
14
15
  const getEthTxFees_1 = require("../utils/txFeeHelpers/ethTxFees/getEthTxFees");
16
+ const MINIMUM_USD_TRADE_AMOUNT = (0, bignumber_1.bn)(1);
15
17
  const getThorTradeQuote = async ({ deps, input }) => {
16
18
  const { sellAsset, buyAsset, sellAmount, sellAssetAccountNumber, chainId, receiveAddress } = input;
17
19
  try {
@@ -24,7 +26,12 @@ const getThorTradeQuote = async ({ deps, input }) => {
24
26
  });
25
27
  const rate = await (0, getTradeRate_1.getTradeRate)(sellAsset, buyAsset.assetId, sellAmount, deps);
26
28
  const buyAmount = (0, bignumber_1.toBaseUnit)((0, bignumber_1.bnOrZero)((0, bignumber_1.fromBaseUnit)(sellAmount, sellAsset.precision)).times(rate), buyAsset.precision);
27
- const tradeFee = await (0, estimateTradeFee_1.estimateTradeFee)(deps, buyAsset);
29
+ const estimatedTradeFee = await (0, estimateTradeFee_1.estimateTradeFee)(deps, buyAsset);
30
+ const buyAssetUsdRate = await (0, getUsdRate_1.getUsdRate)({ deps, input: { assetId: buyAsset.assetId } });
31
+ const minTradeFeeAmount = MINIMUM_USD_TRADE_AMOUNT.div(buyAssetUsdRate);
32
+ const tradeFee = minTradeFeeAmount.gt(estimatedTradeFee)
33
+ ? minTradeFeeAmount.toString()
34
+ : estimatedTradeFee;
28
35
  const sellAssetTradeFee = (0, bignumber_1.bnOrZero)(tradeFee).dividedBy((0, bignumber_1.bnOrZero)(rate));
29
36
  // minimum is tradeFee padded by an amount to be sure they get something back
30
37
  // usually it will be slightly more than the amount because sellAssetTradeFee is already a high estimate
@@ -1,2 +1,2 @@
1
1
  import { AbiItem } from 'web3-utils';
2
- export declare const erc20Abi: Array<AbiItem>;
2
+ export declare const erc20Abi: AbiItem[];
@@ -7,7 +7,7 @@ export declare type ZrxCommonResponse = {
7
7
  buyAmount: string;
8
8
  sellAmount: string;
9
9
  allowanceTarget: string;
10
- sources: Array<SwapSource>;
10
+ sources: SwapSource[];
11
11
  };
12
12
  export declare type ZrxPriceResponse = ZrxCommonResponse & {
13
13
  estimatedGas: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshiftoss/swapper",
3
- "version": "11.0.1",
3
+ "version": "11.1.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",
@@ -30,23 +30,23 @@
30
30
  "web3": "1.7.4"
31
31
  },
32
32
  "peerDependencies": {
33
- "@shapeshiftoss/asset-service": "^7.1.0",
33
+ "@shapeshiftoss/asset-service": "^8.0.1",
34
34
  "@shapeshiftoss/caip": "^8.0.0",
35
- "@shapeshiftoss/chain-adapters": "^7.13.0",
35
+ "@shapeshiftoss/chain-adapters": "^9.0.1",
36
36
  "@shapeshiftoss/errors": "^1.1.2",
37
- "@shapeshiftoss/hdwallet-core": "^1.27.0",
37
+ "@shapeshiftoss/hdwallet-core": "^1.31.0",
38
38
  "@shapeshiftoss/types": "^8.1.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@shapeshiftoss/asset-service": "^7.1.0",
41
+ "@shapeshiftoss/asset-service": "^8.0.1",
42
42
  "@shapeshiftoss/caip": "^8.0.0",
43
- "@shapeshiftoss/chain-adapters": "^7.13.0",
43
+ "@shapeshiftoss/chain-adapters": "^9.0.1",
44
44
  "@shapeshiftoss/errors": "^1.1.2",
45
- "@shapeshiftoss/hdwallet-core": "^1.27.0",
45
+ "@shapeshiftoss/hdwallet-core": "^1.31.0",
46
46
  "@shapeshiftoss/types": "^8.1.0",
47
47
  "@types/readline-sync": "^1.4.4",
48
48
  "readline-sync": "^1.4.10",
49
49
  "web3-utils": "1.7.4",
50
- "@shapeshiftoss/unchained-client": "^9.5.0"
50
+ "@shapeshiftoss/unchained-client": "^10.0.1"
51
51
  }
52
52
  }