@shapeshiftoss/swapper 9.16.0 → 9.17.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 +1 -2
- package/dist/swappercli.js +0 -1
- package/dist/swappers/cow/cowApprovalNeeded/cowApprovalNeeded.js +1 -1
- package/dist/swappers/cow/getCowSwapTradeQuote/getCowSwapTradeQuote.js +1 -2
- package/dist/swappers/thorchain/buildThorTrade/buildThorTrade.js +1 -3
- package/dist/swappers/thorchain/getThorTradeQuote/getTradeQuote.js +2 -8
- package/dist/swappers/thorchain/thorTradeApprovalNeeded/thorTradeApprovalNeeded.js +1 -1
- package/dist/swappers/thorchain/utils/bitcoin/utils/getThorTxData.d.ts +1 -5
- package/dist/swappers/thorchain/utils/bitcoin/utils/getThorTxData.js +2 -4
- package/dist/swappers/utils/test-data/setupSwapQuote.d.ts +0 -1
- package/dist/swappers/utils/test-data/setupSwapQuote.js +0 -1
- package/dist/swappers/zrx/zrxApprovalNeeded/zrxApprovalNeeded.js +1 -1
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -79,7 +79,6 @@ declare type CommonTradeInput = {
|
|
|
79
79
|
sellAmount: string;
|
|
80
80
|
sendMax: boolean;
|
|
81
81
|
sellAssetAccountNumber: number;
|
|
82
|
-
wallet: HDWallet;
|
|
83
82
|
receiveAddress: string;
|
|
84
83
|
};
|
|
85
84
|
export declare type EvmSupportedChainIds = KnownChainIds.EthereumMainnet | KnownChainIds.AvalancheMainnet;
|
|
@@ -97,7 +96,7 @@ export declare type GetUtxoTradeQuoteInput = CommonTradeInput & {
|
|
|
97
96
|
chainId: UtxoSupportedChainIds;
|
|
98
97
|
accountType: UtxoAccountType;
|
|
99
98
|
bip44Params: BIP44Params;
|
|
100
|
-
|
|
99
|
+
xpub: string;
|
|
101
100
|
};
|
|
102
101
|
export declare type GetTradeQuoteInput = GetUtxoTradeQuoteInput | GetEvmTradeQuoteInput | GetCosmosSdkTradeQuoteInput;
|
|
103
102
|
export declare type BuildTradeInput = GetTradeQuoteInput & {
|
package/dist/swappercli.js
CHANGED
|
@@ -27,7 +27,7 @@ async function cowApprovalNeeded({ adapter, web3 }, { quote, wallet }) {
|
|
|
27
27
|
});
|
|
28
28
|
const allowanceOnChain = (0, bignumber_1.bnOrZero)(allowanceResult);
|
|
29
29
|
return {
|
|
30
|
-
approvalNeeded: allowanceOnChain.
|
|
30
|
+
approvalNeeded: allowanceOnChain.lt((0, bignumber_1.bnOrZero)(quote.sellAmount)),
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
catch (e) {
|
|
@@ -17,7 +17,7 @@ const helpers_2 = require("../utils/helpers/helpers");
|
|
|
17
17
|
async function getCowSwapTradeQuote(deps, input) {
|
|
18
18
|
var _a, _b;
|
|
19
19
|
try {
|
|
20
|
-
const { sellAsset, buyAsset, sellAmount, sellAssetAccountNumber,
|
|
20
|
+
const { sellAsset, buyAsset, sellAmount, sellAssetAccountNumber, receiveAddress } = input;
|
|
21
21
|
const { adapter, web3 } = deps;
|
|
22
22
|
const { assetReference: sellAssetErc20Address, assetNamespace: sellAssetNamespace } = (0, caip_1.fromAssetId)(sellAsset.assetId);
|
|
23
23
|
const { assetReference: buyAssetErc20Address, chainId: buyAssetChainId } = (0, caip_1.fromAssetId)(buyAsset.assetId);
|
|
@@ -68,7 +68,6 @@ async function getCowSwapTradeQuote(deps, input) {
|
|
|
68
68
|
const buyCryptoAmount = (0, bignumber_1.bn)(quote.buyAmount).div((0, bignumber_1.bn)(10).exponentiatedBy(buyAsset.precision));
|
|
69
69
|
const sellCryptoAmount = (0, bignumber_1.bn)(quote.sellAmount).div((0, bignumber_1.bn)(10).exponentiatedBy(sellAsset.precision));
|
|
70
70
|
const rate = buyCryptoAmount.div(sellCryptoAmount).toString();
|
|
71
|
-
const receiveAddress = wallet ? await adapter.getAddress({ wallet }) : constants_1.DEFAULT_ADDRESS;
|
|
72
71
|
const data = (0, helpers_1.getApproveContractData)({
|
|
73
72
|
web3,
|
|
74
73
|
spenderAddress: constants_1.COW_SWAP_VAULT_RELAYER_ADDRESS,
|
|
@@ -55,9 +55,7 @@ const buildTrade = async ({ deps, input, }) => {
|
|
|
55
55
|
sellAmount,
|
|
56
56
|
slippageTolerance,
|
|
57
57
|
destinationAddress,
|
|
58
|
-
|
|
59
|
-
bip44Params: input.bip44Params,
|
|
60
|
-
accountType: input.accountType,
|
|
58
|
+
xpub: input.xpub,
|
|
61
59
|
tradeFee: quote.feeData.tradeFee,
|
|
62
60
|
});
|
|
63
61
|
const buildTxResponse = await sellAdapter.buildSendTransaction({
|
|
@@ -13,11 +13,7 @@ const getTradeRate_1 = require("../utils/getTradeRate/getTradeRate");
|
|
|
13
13
|
const getBtcTxFees_1 = require("../utils/txFeeHelpers/btcTxFees/getBtcTxFees");
|
|
14
14
|
const getEthTxFees_1 = require("../utils/txFeeHelpers/ethTxFees/getEthTxFees");
|
|
15
15
|
const getThorTradeQuote = async ({ deps, input }) => {
|
|
16
|
-
const { sellAsset, buyAsset, sellAmount, sellAssetAccountNumber,
|
|
17
|
-
if (!wallet)
|
|
18
|
-
throw new api_1.SwapError('[getThorTradeQuote] - wallet is required', {
|
|
19
|
-
code: api_1.SwapErrorTypes.VALIDATION_FAILED,
|
|
20
|
-
});
|
|
16
|
+
const { sellAsset, buyAsset, sellAmount, sellAssetAccountNumber, chainId, receiveAddress } = input;
|
|
21
17
|
try {
|
|
22
18
|
const { assetReference: sellAssetErc20Address } = (0, caip_1.fromAssetId)(sellAsset.assetId);
|
|
23
19
|
const sellAdapter = deps.adapterManager.get(chainId);
|
|
@@ -77,9 +73,7 @@ const getThorTradeQuote = async ({ deps, input }) => {
|
|
|
77
73
|
sellAmount,
|
|
78
74
|
slippageTolerance: constants_1.DEFAULT_SLIPPAGE,
|
|
79
75
|
destinationAddress: receiveAddress,
|
|
80
|
-
|
|
81
|
-
bip44Params: input.bip44Params,
|
|
82
|
-
accountType: input.accountType,
|
|
76
|
+
xpub: input.xpub,
|
|
83
77
|
tradeFee,
|
|
84
78
|
});
|
|
85
79
|
const feeData = await (0, getBtcTxFees_1.getBtcTxFees)({
|
|
@@ -49,7 +49,7 @@ const thorTradeApprovalNeeded = async ({ deps, input, }) => {
|
|
|
49
49
|
details: { feeData: quote.feeData },
|
|
50
50
|
});
|
|
51
51
|
return {
|
|
52
|
-
approvalNeeded: allowanceOnChain.
|
|
52
|
+
approvalNeeded: allowanceOnChain.lt((0, bignumber_1.bnOrZero)(quote.sellAmount)),
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
catch (e) {
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { Asset } from '@shapeshiftoss/asset-service';
|
|
2
|
-
import { HDWallet } from '@shapeshiftoss/hdwallet-core';
|
|
3
|
-
import { BIP44Params, UtxoAccountType } from '@shapeshiftoss/types';
|
|
4
2
|
import { ThorchainSwapperDeps } from '../../../types';
|
|
5
3
|
declare type GetBtcThorTxInfoArgs = {
|
|
6
4
|
deps: ThorchainSwapperDeps;
|
|
@@ -9,9 +7,7 @@ declare type GetBtcThorTxInfoArgs = {
|
|
|
9
7
|
sellAmount: string;
|
|
10
8
|
slippageTolerance: string;
|
|
11
9
|
destinationAddress: string;
|
|
12
|
-
|
|
13
|
-
bip44Params: BIP44Params;
|
|
14
|
-
accountType: UtxoAccountType;
|
|
10
|
+
xpub: string;
|
|
15
11
|
tradeFee: string;
|
|
16
12
|
};
|
|
17
13
|
declare type GetBtcThorTxInfoReturn = Promise<{
|
|
@@ -5,7 +5,7 @@ const api_1 = require("../../../../../api");
|
|
|
5
5
|
const getLimit_1 = require("../../getLimit/getLimit");
|
|
6
6
|
const makeSwapMemo_1 = require("../../makeSwapMemo/makeSwapMemo");
|
|
7
7
|
const thorService_1 = require("../../thorService");
|
|
8
|
-
const getThorTxInfo = async ({ deps, sellAsset, buyAsset, sellAmount, slippageTolerance, destinationAddress,
|
|
8
|
+
const getThorTxInfo = async ({ deps, sellAsset, buyAsset, sellAmount, slippageTolerance, destinationAddress, xpub, tradeFee, }) => {
|
|
9
9
|
try {
|
|
10
10
|
const { data: inboundAddresses } = await thorService_1.thorService.get(`${deps.midgardUrl}/thorchain/inbound_addresses`);
|
|
11
11
|
const sellAssetInboundAddresses = inboundAddresses.find((inbound) => inbound.chain === sellAsset.symbol.toUpperCase());
|
|
@@ -30,12 +30,10 @@ const getThorTxInfo = async ({ deps, sellAsset, buyAsset, sellAmount, slippageTo
|
|
|
30
30
|
destinationAddress,
|
|
31
31
|
limit,
|
|
32
32
|
});
|
|
33
|
-
const adapter = deps.adapterManager.get(sellAsset.chainId);
|
|
34
|
-
const pubkey = await adapter.getPublicKey(wallet, bip44Params, accountType);
|
|
35
33
|
return {
|
|
36
34
|
opReturnData: memo,
|
|
37
35
|
vault,
|
|
38
|
-
pubkey:
|
|
36
|
+
pubkey: xpub,
|
|
39
37
|
};
|
|
40
38
|
}
|
|
41
39
|
catch (e) {
|
|
@@ -44,7 +44,7 @@ async function zrxApprovalNeeded({ adapter, web3 }, { quote, wallet }) {
|
|
|
44
44
|
details: { feeData: quote.feeData },
|
|
45
45
|
});
|
|
46
46
|
return {
|
|
47
|
-
approvalNeeded: allowanceOnChain.
|
|
47
|
+
approvalNeeded: allowanceOnChain.lt((0, bignumber_1.bnOrZero)(quote.sellAmount)),
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
catch (e) {
|
package/package.json
CHANGED