@shapeshiftoss/swapper 12.2.0 → 13.0.1

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
@@ -62,10 +62,6 @@ export declare type QuoteFeeData<T extends ChainId> = {
62
62
  networkFee: string;
63
63
  buyAssetTradeFeeUsd: string;
64
64
  sellAssetTradeFeeUsd?: string;
65
- /** @deprecated Use networkFee instead */
66
- fee: string;
67
- /** @deprecated Use sellAssetTradeFeeUsd instead */
68
- tradeFee: string;
69
65
  } & ChainSpecificQuoteFeeData<T>;
70
66
  export declare type ByPairInput = {
71
67
  sellAssetId: AssetId;
@@ -79,13 +79,11 @@ async function cowBuildTrade(deps, input) {
79
79
  const trade = {
80
80
  rate,
81
81
  feeData: {
82
- fee: '0',
83
82
  networkFee: '0',
84
83
  chainSpecific: {
85
84
  estimatedGas: feeData.chainSpecific.gasLimit,
86
85
  gasPrice: feeData.chainSpecific.gasPrice,
87
86
  },
88
- tradeFee: '0',
89
87
  buyAssetTradeFeeUsd: '0',
90
88
  sellAssetTradeFeeUsd,
91
89
  },
@@ -96,7 +96,6 @@ async function getCowSwapTradeQuote(deps, input) {
96
96
  minimum,
97
97
  maximum,
98
98
  feeData: {
99
- fee: '0',
100
99
  networkFee: '0',
101
100
  chainSpecific: {
102
101
  estimatedGas: feeData.chainSpecific.gasLimit,
@@ -105,7 +104,6 @@ async function getCowSwapTradeQuote(deps, input) {
105
104
  .multipliedBy((0, bignumber_1.bnOrZero)(feeData.chainSpecific.gasPrice))
106
105
  .toString(),
107
106
  },
108
- tradeFee: '0',
109
107
  buyAssetTradeFeeUsd: '0',
110
108
  sellAssetTradeFeeUsd,
111
109
  },
@@ -107,8 +107,6 @@ class OsmosisSwapper {
107
107
  buyAmount,
108
108
  buyAsset,
109
109
  feeData: {
110
- fee,
111
- tradeFee: buyAssetTradeFeeUsd,
112
110
  networkFee: fee,
113
111
  sellAssetTradeFeeUsd: '0',
114
112
  buyAssetTradeFeeUsd,
@@ -140,8 +138,6 @@ class OsmosisSwapper {
140
138
  return {
141
139
  buyAsset,
142
140
  feeData: {
143
- fee,
144
- tradeFee: buyAssetTradeFeeUsd,
145
141
  networkFee: fee,
146
142
  sellAssetTradeFeeUsd: '0',
147
143
  buyAssetTradeFeeUsd,
@@ -35,6 +35,7 @@ class ThorchainSwapper {
35
35
  [types_1.KnownChainIds.LitecoinMainnet]: true,
36
36
  [types_1.KnownChainIds.BitcoinCashMainnet]: true,
37
37
  [types_1.KnownChainIds.CosmosMainnet]: true,
38
+ [types_1.KnownChainIds.ThorchainMainnet]: true,
38
39
  };
39
40
  this.buySupportedChainIds = {
40
41
  [types_1.KnownChainIds.EthereumMainnet]: true,
@@ -43,6 +44,7 @@ class ThorchainSwapper {
43
44
  [types_1.KnownChainIds.LitecoinMainnet]: true,
44
45
  [types_1.KnownChainIds.BitcoinCashMainnet]: true,
45
46
  [types_1.KnownChainIds.CosmosMainnet]: true,
47
+ [types_1.KnownChainIds.ThorchainMainnet]: true,
46
48
  };
47
49
  this.supportedSellAssetIds = [];
48
50
  this.supportedBuyAssetIds = [];
@@ -126,9 +126,7 @@ const getThorTradeQuote = async ({ deps, input }) => {
126
126
  ...commonQuoteFields,
127
127
  allowanceContract: '0x0',
128
128
  feeData: {
129
- fee: feeData.fast.txFee,
130
129
  networkFee: feeData.fast.txFee,
131
- tradeFee: buyAssetTradeFeeUsdOrDefault,
132
130
  buyAssetTradeFeeUsd: buyAssetTradeFeeUsdOrDefault,
133
131
  sellAssetTradeFeeUsd: '0',
134
132
  chainSpecific: { estimatedGas: feeData.fast.chainSpecific.gasLimit },
@@ -40,7 +40,7 @@ const cosmosTxData = async (input) => {
40
40
  wallet,
41
41
  memo,
42
42
  gas: quote.feeData.chainSpecific.estimatedGas,
43
- fee: quote.feeData.fee,
43
+ fee: quote.feeData.networkFee,
44
44
  });
45
45
  return buildTxResponse.txToSign;
46
46
  }
@@ -58,7 +58,7 @@ const cosmosTxData = async (input) => {
58
58
  memo,
59
59
  chainSpecific: {
60
60
  gas: quote.feeData.chainSpecific.estimatedGas,
61
- fee: quote.feeData.fee,
61
+ fee: quote.feeData.networkFee,
62
62
  },
63
63
  });
64
64
  return buildTxResponse.txToSign;
@@ -39,6 +39,14 @@ const getPriceRatio = async (deps, input) => {
39
39
  throw new api_1.SwapError(`[getPriceRatio] zero sell asset balance sellAssetId ${sellAssetId} buyAssetId ${buyAssetId}`);
40
40
  return (0, bignumber_1.bn)(runeBalance).dividedBy(sellAssetBalance).toString();
41
41
  }
42
+ if ((0, isRune_1.isRune)(sellAssetId) && buyPool) {
43
+ const buyAssetBalance = (0, bignumber_1.bnOrZero)(buyPool.balance_asset);
44
+ const runeBalance = (0, bignumber_1.bnOrZero)(buyPool.balance_rune);
45
+ // guard against division by zero
46
+ if (buyAssetBalance.eq(0))
47
+ throw new api_1.SwapError(`[getPriceRatio] zero buy asset balance sellAssetId ${sellAssetId} buyAssetId ${buyAssetId}`);
48
+ return (0, bignumber_1.bn)(buyAssetBalance).dividedBy(runeBalance).toString();
49
+ }
42
50
  if (!buyPool || !sellPool) {
43
51
  throw new api_1.SwapError(`[getPriceRatio]: pools not found`, {
44
52
  code: api_1.SwapErrorTypes.RESPONSE_ERROR,
@@ -23,9 +23,7 @@ const getBtcTxFees = async ({ opReturnData, vault, sellAmount, sellAdapter, pubk
23
23
  const networkFee = feeMultiplier.times(feeData.txFee).dp(0).toString();
24
24
  const satsPerByte = feeMultiplier.times(feeData.chainSpecific.satoshiPerByte).dp(0).toString();
25
25
  return {
26
- fee: networkFee,
27
26
  networkFee,
28
- tradeFee: buyAssetTradeFeeUsd,
29
27
  buyAssetTradeFeeUsd,
30
28
  sellAssetTradeFeeUsd: '0',
31
29
  chainSpecific: {
@@ -31,7 +31,6 @@ const getEthTxFees = async ({ adapterManager, sellAssetReference, buyAssetTradeF
31
31
  };
32
32
  const feeData = feeDataOptions['fast'];
33
33
  return {
34
- fee: feeData.txFee,
35
34
  networkFee: feeData.txFee,
36
35
  chainSpecific: {
37
36
  estimatedGas: feeData.chainSpecific.gasLimit,
@@ -41,7 +40,6 @@ const getEthTxFees = async ({ adapterManager, sellAssetReference, buyAssetTradeF
41
40
  .multipliedBy((0, bignumber_1.bnOrZero)(feeData.chainSpecific.gasPrice))
42
41
  .toString(),
43
42
  },
44
- tradeFee: buyAssetTradeFeeUsd,
45
43
  buyAssetTradeFeeUsd,
46
44
  sellAssetTradeFeeUsd: '0',
47
45
  };
@@ -16,8 +16,6 @@ const setupQuote = () => {
16
16
  minimum: '0',
17
17
  maximum: '999999999999',
18
18
  feeData: {
19
- fee: '0',
20
- tradeFee: '0',
21
19
  chainSpecific: {},
22
20
  sellAssetTradeFeeUsd: '0',
23
21
  networkFee: '0',
@@ -58,13 +58,11 @@ async function getZrxTradeQuote(input) {
58
58
  minimum,
59
59
  maximum,
60
60
  feeData: {
61
- fee,
62
61
  chainSpecific: {
63
62
  estimatedGas: estimatedGas.toString(),
64
63
  gasPrice,
65
64
  approvalFee,
66
65
  },
67
- tradeFee: '0',
68
66
  networkFee: fee,
69
67
  buyAssetTradeFeeUsd: '0',
70
68
  sellAssetTradeFeeUsd: '0',
@@ -26,9 +26,7 @@ export declare const setupExecuteTrade: () => {
26
26
  depositAddress: string;
27
27
  receiveAddress: string;
28
28
  feeData: {
29
- fee: string;
30
29
  chainSpecific: {};
31
- tradeFee: string;
32
30
  buyAssetTradeFeeUsd: string;
33
31
  sellAssetTradeFeeUsd: string;
34
32
  networkFee: string;
@@ -38,9 +38,7 @@ const setupExecuteTrade = () => {
38
38
  depositAddress: '0x0',
39
39
  receiveAddress: '0x0',
40
40
  feeData: {
41
- fee: '0',
42
41
  chainSpecific: {},
43
- tradeFee: '0',
44
42
  buyAssetTradeFeeUsd: '0',
45
43
  sellAssetTradeFeeUsd: '0',
46
44
  networkFee: '0',
@@ -112,13 +112,11 @@ async function zrxBuildTrade({ adapter, web3 }, input) {
112
112
  rate: data.price,
113
113
  depositAddress: data.to,
114
114
  feeData: {
115
- fee: networkFee,
116
115
  chainSpecific: {
117
116
  estimatedGas: estimatedGas.toString(),
118
117
  gasPrice: data.gasPrice,
119
118
  approvalFee: approvalRequired ? approvalFee : undefined,
120
119
  },
121
- tradeFee: '0',
122
120
  networkFee,
123
121
  buyAssetTradeFeeUsd: '0',
124
122
  sellAssetTradeFeeUsd: '0',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshiftoss/swapper",
3
- "version": "12.2.0",
3
+ "version": "13.0.1",
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",