@shapeshiftoss/swapper 11.5.6 → 12.0.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/swappers/cow/cowApprovalNeeded/cowApprovalNeeded.js +1 -1
- package/dist/swappers/cow/cowBuildTrade/cowBuildTrade.js +1 -1
- package/dist/swappers/thorchain/constants.d.ts +1 -0
- package/dist/swappers/thorchain/constants.js +2 -1
- package/dist/swappers/thorchain/getThorTradeQuote/getTradeQuote.js +14 -10
- package/package.json +1 -1
|
@@ -17,7 +17,7 @@ async function cowApprovalNeeded({ adapter, web3 }, { quote, wallet }) {
|
|
|
17
17
|
details: { assetNamespace },
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
const receiveAddress = await adapter.getAddress({ wallet });
|
|
20
|
+
const receiveAddress = await adapter.getAddress({ wallet, bip44Params: quote.bip44Params });
|
|
21
21
|
const allowanceResult = await (0, helpers_1.getERC20Allowance)({
|
|
22
22
|
web3,
|
|
23
23
|
erc20AllowanceAbi: erc20Allowance_abi_1.erc20AllowanceAbi,
|
|
@@ -29,7 +29,7 @@ async function cowBuildTrade(deps, input) {
|
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
const buyToken = buyAsset.assetId !== caip_1.ethAssetId ? buyAssetErc20Address : constants_1.COW_SWAP_ETH_MARKER_ADDRESS;
|
|
32
|
-
const receiveAddress = await adapter.getAddress({ wallet });
|
|
32
|
+
const receiveAddress = await adapter.getAddress({ wallet, bip44Params });
|
|
33
33
|
const normalizedSellAmount = (0, helpers_1.normalizeAmount)(sellAmount);
|
|
34
34
|
/**
|
|
35
35
|
* /v1/quote
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MINIMUM_USD_TRADE_AMOUNT = exports.RUNE_OUTBOUND_TRANSACTION_FEE_CRYPTO_HUMAN = void 0;
|
|
3
|
+
exports.MINIMUM_USD_TRADE_AMOUNT_ETHEREUM_NETWORK = exports.MINIMUM_USD_TRADE_AMOUNT = exports.RUNE_OUTBOUND_TRANSACTION_FEE_CRYPTO_HUMAN = void 0;
|
|
4
4
|
const bignumber_1 = require("../utils/bignumber");
|
|
5
5
|
// TODO: read from https://daemon.thorchain.shapeshift.com/lcd/thorchain/constants
|
|
6
6
|
exports.RUNE_OUTBOUND_TRANSACTION_FEE_CRYPTO_HUMAN = (0, bignumber_1.bn)('0.02');
|
|
7
7
|
exports.MINIMUM_USD_TRADE_AMOUNT = (0, bignumber_1.bn)(1);
|
|
8
|
+
exports.MINIMUM_USD_TRADE_AMOUNT_ETHEREUM_NETWORK = (0, bignumber_1.bn)(42);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getThorTradeQuote = void 0;
|
|
4
4
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
5
|
+
const types_1 = require("@shapeshiftoss/types");
|
|
5
6
|
const api_1 = require("../../../api");
|
|
6
7
|
const bignumber_1 = require("../../utils/bignumber");
|
|
7
8
|
const constants_1 = require("../../utils/constants");
|
|
@@ -36,10 +37,13 @@ const getThorTradeQuote = async ({ deps, input }) => {
|
|
|
36
37
|
const estimatedBuyAssetTradeFeeUsd = (0, bignumber_1.bn)(buyAssetUsdRate)
|
|
37
38
|
.times(estimatedBuyAssetTradeFeeCryptoHuman)
|
|
38
39
|
.toString();
|
|
39
|
-
const
|
|
40
|
-
? constants_2.
|
|
40
|
+
const minimumUsdAmount = buyAsset.chainId === types_1.KnownChainIds.EthereumMainnet
|
|
41
|
+
? constants_2.MINIMUM_USD_TRADE_AMOUNT_ETHEREUM_NETWORK
|
|
42
|
+
: constants_2.MINIMUM_USD_TRADE_AMOUNT;
|
|
43
|
+
const buyAssetTradeFeeUsdOrMinimum = minimumUsdAmount.gt(estimatedBuyAssetTradeFeeUsd)
|
|
44
|
+
? minimumUsdAmount.toString()
|
|
41
45
|
: estimatedBuyAssetTradeFeeUsd;
|
|
42
|
-
const
|
|
46
|
+
const minimumSellAssetAmountCryptoHuman = (() => {
|
|
43
47
|
// The 1$ minimum doesn't apply for swaps to RUNE, use OutboundTransactionFee in human value instead
|
|
44
48
|
if ((0, isRune_1.isRune)(buyAsset === null || buyAsset === void 0 ? void 0 : buyAsset.assetId))
|
|
45
49
|
return constants_2.RUNE_OUTBOUND_TRANSACTION_FEE_CRYPTO_HUMAN;
|
|
@@ -47,12 +51,12 @@ const getThorTradeQuote = async ({ deps, input }) => {
|
|
|
47
51
|
})();
|
|
48
52
|
// minimum is tradeFee padded by an amount to be sure they get something back
|
|
49
53
|
// usually it will be slightly more than the amount because sellAssetTradeFee is already a high estimate
|
|
50
|
-
const
|
|
54
|
+
const minimumSellAssetAmountPaddedCryptoHuman = (0, bignumber_1.bnOrZero)(minimumSellAssetAmountCryptoHuman)
|
|
51
55
|
.times(constants_3.THOR_MINIMUM_PADDING)
|
|
52
56
|
.toString();
|
|
53
57
|
const buyAssetTradeFeeUsdOrDefault = (0, isRune_1.isRune)(buyAsset === null || buyAsset === void 0 ? void 0 : buyAsset.assetId)
|
|
54
58
|
? (0, bignumber_1.bn)(buyAssetUsdRate).times(constants_2.RUNE_OUTBOUND_TRANSACTION_FEE_CRYPTO_HUMAN).toString()
|
|
55
|
-
:
|
|
59
|
+
: estimatedBuyAssetTradeFeeUsd;
|
|
56
60
|
const commonQuoteFields = {
|
|
57
61
|
rate,
|
|
58
62
|
maximum: constants_3.MAX_THORCHAIN_TRADE,
|
|
@@ -62,7 +66,7 @@ const getThorTradeQuote = async ({ deps, input }) => {
|
|
|
62
66
|
buyAsset,
|
|
63
67
|
sellAsset,
|
|
64
68
|
bip44Params,
|
|
65
|
-
minimum:
|
|
69
|
+
minimum: minimumSellAssetAmountPaddedCryptoHuman,
|
|
66
70
|
};
|
|
67
71
|
const { chainNamespace } = (0, caip_1.fromAssetId)(sellAsset.assetId);
|
|
68
72
|
switch (chainNamespace) {
|
|
@@ -75,12 +79,12 @@ const getThorTradeQuote = async ({ deps, input }) => {
|
|
|
75
79
|
sellAmount: sellAmountCryptoPrecision,
|
|
76
80
|
slippageTolerance: constants_1.DEFAULT_SLIPPAGE,
|
|
77
81
|
destinationAddress: receiveAddress,
|
|
78
|
-
buyAssetTradeFeeUsd:
|
|
82
|
+
buyAssetTradeFeeUsd: estimatedBuyAssetTradeFeeUsd,
|
|
79
83
|
});
|
|
80
84
|
const feeData = await (0, getEthTxFees_1.getEthTxFees)({
|
|
81
85
|
adapterManager: deps.adapterManager,
|
|
82
86
|
sellAssetReference,
|
|
83
|
-
buyAssetTradeFeeUsd:
|
|
87
|
+
buyAssetTradeFeeUsd: estimatedBuyAssetTradeFeeUsd,
|
|
84
88
|
});
|
|
85
89
|
return {
|
|
86
90
|
...commonQuoteFields,
|
|
@@ -98,7 +102,7 @@ const getThorTradeQuote = async ({ deps, input }) => {
|
|
|
98
102
|
slippageTolerance: constants_1.DEFAULT_SLIPPAGE,
|
|
99
103
|
destinationAddress: receiveAddress,
|
|
100
104
|
xpub: input.xpub,
|
|
101
|
-
buyAssetTradeFeeUsd:
|
|
105
|
+
buyAssetTradeFeeUsd: estimatedBuyAssetTradeFeeUsd,
|
|
102
106
|
});
|
|
103
107
|
const feeData = await (0, getBtcTxFees_1.getBtcTxFees)({
|
|
104
108
|
sellAmount: sellAmountCryptoPrecision,
|
|
@@ -106,7 +110,7 @@ const getThorTradeQuote = async ({ deps, input }) => {
|
|
|
106
110
|
opReturnData,
|
|
107
111
|
pubkey,
|
|
108
112
|
sellAdapter: sellAdapter,
|
|
109
|
-
buyAssetTradeFeeUsd:
|
|
113
|
+
buyAssetTradeFeeUsd: estimatedBuyAssetTradeFeeUsd,
|
|
110
114
|
sendMax,
|
|
111
115
|
});
|
|
112
116
|
return {
|
package/package.json
CHANGED