@shapeshiftoss/swapper 9.15.0 → 9.15.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/manager/SwapperManager.js +3 -3
- package/dist/swappercli.js +8 -8
- package/dist/swappers/cow/CowSwapper.js +1 -1
- package/dist/swappers/cow/cowApprovalNeeded/cowApprovalNeeded.js +4 -4
- package/dist/swappers/cow/cowApproveInfinite/cowApproveInfinite.js +3 -3
- package/dist/swappers/cow/cowBuildTrade/cowBuildTrade.js +11 -11
- package/dist/swappers/cow/cowExecuteTrade/cowExecuteTrade.js +7 -7
- package/dist/swappers/cow/cowGetTradeTxs/cowGetTradeTxs.js +4 -4
- package/dist/swappers/cow/getCowSwapMinMax/getCowSwapMinMax.js +1 -1
- package/dist/swappers/cow/getCowSwapTradeQuote/getCowSwapTradeQuote.js +12 -12
- package/dist/swappers/cow/utils/blacklist.js +1 -1
- package/dist/swappers/cow/utils/cowService.js +2 -2
- package/dist/swappers/cow/utils/helpers/helpers.js +7 -7
- package/dist/swappers/osmosis/OsmosisSwapper.js +20 -20
- package/dist/swappers/osmosis/utils/helpers.d.ts +1 -1
- package/dist/swappers/osmosis/utils/helpers.js +35 -35
- package/dist/swappers/test/TestSwapper.js +2 -2
- package/dist/swappers/thorchain/ThorchainSwapper.js +13 -13
- package/dist/swappers/thorchain/buildThorTrade/buildThorTrade.d.ts +1 -1
- package/dist/swappers/thorchain/buildThorTrade/buildThorTrade.js +14 -14
- package/dist/swappers/thorchain/getThorTradeQuote/getTradeQuote.js +14 -14
- package/dist/swappers/thorchain/thorTradeApprovalNeeded/thorTradeApprovalNeeded.d.ts +1 -1
- package/dist/swappers/thorchain/thorTradeApprovalNeeded/thorTradeApprovalNeeded.js +7 -7
- package/dist/swappers/thorchain/thorTradeApproveInfinite/thorTradeApproveInfinite.d.ts +1 -1
- package/dist/swappers/thorchain/thorTradeApproveInfinite/thorTradeApproveInfinite.js +7 -7
- package/dist/swappers/thorchain/utils/bitcoin/utils/getThorTxData.js +5 -5
- package/dist/swappers/thorchain/utils/constants.js +1 -1
- package/dist/swappers/thorchain/utils/cosmos/cosmosTxData.js +6 -6
- package/dist/swappers/thorchain/utils/estimateTradeFee/estimateTradeFee.js +6 -6
- package/dist/swappers/thorchain/utils/ethereum/makeTradeTx.d.ts +1 -1
- package/dist/swappers/thorchain/utils/ethereum/makeTradeTx.js +6 -6
- package/dist/swappers/thorchain/utils/ethereum/utils/getThorTxData.js +5 -5
- package/dist/swappers/thorchain/utils/getLimit/getLimit.d.ts +1 -1
- package/dist/swappers/thorchain/utils/getLimit/getLimit.js +2 -2
- package/dist/swappers/thorchain/utils/getPriceRatio/getPriceRatio.js +3 -3
- package/dist/swappers/thorchain/utils/getTradeRate/getTradeRate.js +5 -5
- package/dist/swappers/thorchain/utils/getUsdRate/getUsdRate.d.ts +1 -1
- package/dist/swappers/thorchain/utils/getUsdRate/getUsdRate.js +4 -4
- package/dist/swappers/thorchain/utils/makeSwapMemo/makeSwapMemo.d.ts +1 -1
- package/dist/swappers/thorchain/utils/makeSwapMemo/makeSwapMemo.js +4 -4
- package/dist/swappers/thorchain/utils/test-data/midgardResponse.js +11 -11
- package/dist/swappers/thorchain/utils/test-data/setupThorswapDeps.js +9 -9
- package/dist/swappers/thorchain/utils/thorService.js +2 -2
- package/dist/swappers/thorchain/utils/txFeeHelpers/btcTxFees/getBtcTxFees.d.ts +1 -1
- package/dist/swappers/thorchain/utils/txFeeHelpers/btcTxFees/getBtcTxFees.js +4 -4
- package/dist/swappers/thorchain/utils/txFeeHelpers/ethTxFees/getEthTxFees.d.ts +1 -1
- package/dist/swappers/thorchain/utils/txFeeHelpers/ethTxFees/getEthTxFees.js +7 -7
- package/dist/swappers/utils/abi/erc20-abi.js +54 -54
- package/dist/swappers/utils/abi/erc20Allowance-abi.js +7 -7
- package/dist/swappers/utils/helpers/helpers.d.ts +4 -4
- package/dist/swappers/utils/helpers/helpers.js +13 -13
- package/dist/swappers/utils/test-data/assets.js +8 -8
- package/dist/swappers/utils/test-data/setupDeps.js +3 -3
- package/dist/swappers/utils/test-data/setupSwapQuote.js +3 -3
- package/dist/swappers/zrx/ZrxSwapper.js +2 -2
- package/dist/swappers/zrx/getZrxMinMax/getZrxMinMax.js +1 -1
- package/dist/swappers/zrx/getZrxTradeQuote/getZrxTradeQuote.js +7 -7
- package/dist/swappers/zrx/utils/blacklist.js +1 -1
- package/dist/swappers/zrx/utils/helpers/helpers.js +6 -6
- package/dist/swappers/zrx/utils/test-data/setupZrxSwapQuote.js +2 -2
- package/dist/swappers/zrx/utils/zrxService.js +2 -2
- package/dist/swappers/zrx/zrxApprovalNeeded/zrxApprovalNeeded.js +6 -6
- package/dist/swappers/zrx/zrxApprove/zrxApprove.js +6 -6
- package/dist/swappers/zrx/zrxBuildTrade/zrxBuildTrade.js +13 -11
- package/dist/swappers/zrx/zrxExecuteTrade/zrxExecuteTrade.js +6 -6
- package/package.json +1 -1
|
@@ -9,8 +9,8 @@ const axiosConfig = {
|
|
|
9
9
|
timeout: 10000,
|
|
10
10
|
headers: {
|
|
11
11
|
Accept: 'application/json',
|
|
12
|
-
'Content-Type': 'application/json'
|
|
13
|
-
}
|
|
12
|
+
'Content-Type': 'application/json',
|
|
13
|
+
},
|
|
14
14
|
};
|
|
15
15
|
const zrxServiceFactory = (baseUrl) => axios_1.default.create({ ...axiosConfig, baseURL: baseUrl });
|
|
16
16
|
exports.zrxServiceFactory = zrxServiceFactory;
|
|
@@ -14,7 +14,7 @@ async function zrxApprovalNeeded({ adapter, web3 }, { quote, wallet }) {
|
|
|
14
14
|
if (sellAsset.chainId !== adapter.getChainId()) {
|
|
15
15
|
throw new api_1.SwapError('[zrxApprovalNeeded] - sellAsset chainId is not supported', {
|
|
16
16
|
code: api_1.SwapErrorTypes.UNSUPPORTED_CHAIN,
|
|
17
|
-
details: { chainId: sellAsset.chainId }
|
|
17
|
+
details: { chainId: sellAsset.chainId },
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
// No approval needed for selling a fee asset
|
|
@@ -27,7 +27,7 @@ async function zrxApprovalNeeded({ adapter, web3 }, { quote, wallet }) {
|
|
|
27
27
|
if (!quote.allowanceContract) {
|
|
28
28
|
throw new api_1.SwapError('[zrxApprovalNeeded] - allowanceTarget is required', {
|
|
29
29
|
code: api_1.SwapErrorTypes.VALIDATION_FAILED,
|
|
30
|
-
details: { chainId: sellAsset.chainId }
|
|
30
|
+
details: { chainId: sellAsset.chainId },
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
const allowanceResult = await (0, helpers_1.getERC20Allowance)({
|
|
@@ -35,16 +35,16 @@ async function zrxApprovalNeeded({ adapter, web3 }, { quote, wallet }) {
|
|
|
35
35
|
erc20AllowanceAbi: erc20Allowance_abi_1.erc20AllowanceAbi,
|
|
36
36
|
sellAssetErc20Address,
|
|
37
37
|
spenderAddress: quote.allowanceContract,
|
|
38
|
-
ownerAddress: receiveAddress
|
|
38
|
+
ownerAddress: receiveAddress,
|
|
39
39
|
});
|
|
40
40
|
const allowanceOnChain = (0, bignumber_1.bnOrZero)(allowanceResult);
|
|
41
41
|
if (!((_a = quote.feeData.chainSpecific) === null || _a === void 0 ? void 0 : _a.gasPrice))
|
|
42
42
|
throw new api_1.SwapError('[zrxApprovalNeeded] - no gas price with quote', {
|
|
43
43
|
code: api_1.SwapErrorTypes.RESPONSE_ERROR,
|
|
44
|
-
details: { feeData: quote.feeData }
|
|
44
|
+
details: { feeData: quote.feeData },
|
|
45
45
|
});
|
|
46
46
|
return {
|
|
47
|
-
approvalNeeded: allowanceOnChain.lte((0, bignumber_1.bnOrZero)(quote.sellAmount))
|
|
47
|
+
approvalNeeded: allowanceOnChain.lte((0, bignumber_1.bnOrZero)(quote.sellAmount)),
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
catch (e) {
|
|
@@ -52,7 +52,7 @@ async function zrxApprovalNeeded({ adapter, web3 }, { quote, wallet }) {
|
|
|
52
52
|
throw e;
|
|
53
53
|
throw new api_1.SwapError('[zrxApprovalNeeded]', {
|
|
54
54
|
cause: e,
|
|
55
|
-
code: api_1.SwapErrorTypes.CHECK_APPROVAL_FAILED
|
|
55
|
+
code: api_1.SwapErrorTypes.CHECK_APPROVAL_FAILED,
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -16,16 +16,16 @@ const grantAllowanceForAmount = async ({ adapter, web3 }, { quote, wallet }, app
|
|
|
16
16
|
...quote.feeData.chainSpecific,
|
|
17
17
|
// 0x approvals are cheaper than trades, but we don't have dynamic quote data for them.
|
|
18
18
|
// Instead, we use a hardcoded gasLimit estimate in place of the estimatedGas in the 0x quote response.
|
|
19
|
-
estimatedGas: constants_1.APPROVAL_GAS_LIMIT
|
|
20
|
-
}
|
|
21
|
-
}
|
|
19
|
+
estimatedGas: constants_1.APPROVAL_GAS_LIMIT,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
22
|
};
|
|
23
23
|
return await (0, helpers_1.grantAllowance)({
|
|
24
24
|
quote: approvalQuote,
|
|
25
25
|
wallet,
|
|
26
26
|
adapter,
|
|
27
27
|
erc20Abi: erc20_abi_1.erc20Abi,
|
|
28
|
-
web3
|
|
28
|
+
web3,
|
|
29
29
|
});
|
|
30
30
|
};
|
|
31
31
|
async function zrxApproveAmount(deps, args) {
|
|
@@ -41,7 +41,7 @@ async function zrxApproveAmount(deps, args) {
|
|
|
41
41
|
throw e;
|
|
42
42
|
throw new api_1.SwapError('[zrxApproveAmount]', {
|
|
43
43
|
cause: e,
|
|
44
|
-
code: api_1.SwapErrorTypes.APPROVE_AMOUNT_FAILED
|
|
44
|
+
code: api_1.SwapErrorTypes.APPROVE_AMOUNT_FAILED,
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -55,7 +55,7 @@ async function zrxApproveInfinite(deps, args) {
|
|
|
55
55
|
throw e;
|
|
56
56
|
throw new api_1.SwapError('[zrxApproveInfinite]', {
|
|
57
57
|
cause: e,
|
|
58
|
-
code: api_1.SwapErrorTypes.APPROVE_INFINITE_FAILED
|
|
58
|
+
code: api_1.SwapErrorTypes.APPROVE_INFINITE_FAILED,
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -47,7 +47,7 @@ async function zrxBuildTrade({ adapter, web3 }, input) {
|
|
|
47
47
|
if (buyAsset.chainId !== adapterChainId) {
|
|
48
48
|
throw new api_1.SwapError(`[zrxBuildTrade] - buyAsset must be on chainId ${adapterChainId}`, {
|
|
49
49
|
code: api_1.SwapErrorTypes.VALIDATION_FAILED,
|
|
50
|
-
details: { chainId: sellAsset.chainId }
|
|
50
|
+
details: { chainId: sellAsset.chainId },
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
const slippagePercentage = slippage ? (0, bignumber_1.bnOrZero)(slippage).div(100).toString() : constants_1.DEFAULT_SLIPPAGE;
|
|
@@ -76,7 +76,7 @@ async function zrxBuildTrade({ adapter, web3 }, input) {
|
|
|
76
76
|
return true;
|
|
77
77
|
// Handle the request based on your other config options, e.g. `statusCodesToRetry`
|
|
78
78
|
return rax.shouldRetryRequest(err);
|
|
79
|
-
}
|
|
79
|
+
},
|
|
80
80
|
});
|
|
81
81
|
const quoteResponse = await zrxRetry.get('/swap/v1/quote', {
|
|
82
82
|
params: {
|
|
@@ -86,8 +86,8 @@ async function zrxBuildTrade({ adapter, web3 }, input) {
|
|
|
86
86
|
takerAddress: receiveAddress,
|
|
87
87
|
slippagePercentage,
|
|
88
88
|
skipValidation: false,
|
|
89
|
-
affiliateAddress: constants_2.AFFILIATE_ADDRESS
|
|
90
|
-
}
|
|
89
|
+
affiliateAddress: constants_2.AFFILIATE_ADDRESS,
|
|
90
|
+
},
|
|
91
91
|
});
|
|
92
92
|
const { data } = quoteResponse;
|
|
93
93
|
const estimatedGas = (0, bignumber_1.bnOrZero)(data.gas || 0);
|
|
@@ -102,14 +102,14 @@ async function zrxBuildTrade({ adapter, web3 }, input) {
|
|
|
102
102
|
fee: (0, bignumber_1.bnOrZero)(estimatedGas).multipliedBy((0, bignumber_1.bnOrZero)(data.gasPrice)).toString(),
|
|
103
103
|
chainSpecific: {
|
|
104
104
|
estimatedGas: estimatedGas.toString(),
|
|
105
|
-
gasPrice: data.gasPrice
|
|
105
|
+
gasPrice: data.gasPrice,
|
|
106
106
|
},
|
|
107
|
-
tradeFee: '0'
|
|
107
|
+
tradeFee: '0',
|
|
108
108
|
},
|
|
109
109
|
txData: data.data,
|
|
110
110
|
sellAmount: data.sellAmount,
|
|
111
111
|
buyAmount: data.buyAmount,
|
|
112
|
-
sources: ((_a = data.sources) === null || _a === void 0 ? void 0 : _a.filter((s) => parseFloat(s.proportion) > 0)) || constants_2.DEFAULT_SOURCE
|
|
112
|
+
sources: ((_a = data.sources) === null || _a === void 0 ? void 0 : _a.filter((s) => parseFloat(s.proportion) > 0)) || constants_2.DEFAULT_SOURCE,
|
|
113
113
|
};
|
|
114
114
|
const allowanceRequired = await (0, helpers_1.getAllowanceRequired)({
|
|
115
115
|
adapter,
|
|
@@ -118,16 +118,18 @@ async function zrxBuildTrade({ adapter, web3 }, input) {
|
|
|
118
118
|
receiveAddress,
|
|
119
119
|
sellAmount: data.sellAmount,
|
|
120
120
|
web3,
|
|
121
|
-
erc20AllowanceAbi: erc20Allowance_abi_1.erc20AllowanceAbi
|
|
121
|
+
erc20AllowanceAbi: erc20Allowance_abi_1.erc20AllowanceAbi,
|
|
122
122
|
});
|
|
123
123
|
if (allowanceRequired) {
|
|
124
124
|
trade.feeData = {
|
|
125
125
|
fee: ((_b = trade.feeData) === null || _b === void 0 ? void 0 : _b.fee) || '0',
|
|
126
126
|
chainSpecific: {
|
|
127
127
|
...(_c = trade.feeData) === null || _c === void 0 ? void 0 : _c.chainSpecific,
|
|
128
|
-
approvalFee: (0, bignumber_1.bnOrZero)(constants_1.APPROVAL_GAS_LIMIT)
|
|
128
|
+
approvalFee: (0, bignumber_1.bnOrZero)(constants_1.APPROVAL_GAS_LIMIT)
|
|
129
|
+
.multipliedBy((0, bignumber_1.bnOrZero)(data.gasPrice))
|
|
130
|
+
.toString(),
|
|
129
131
|
},
|
|
130
|
-
tradeFee: '0'
|
|
132
|
+
tradeFee: '0',
|
|
131
133
|
};
|
|
132
134
|
}
|
|
133
135
|
return trade;
|
|
@@ -136,7 +138,7 @@ async function zrxBuildTrade({ adapter, web3 }, input) {
|
|
|
136
138
|
if (e instanceof api_1.SwapError)
|
|
137
139
|
throw e;
|
|
138
140
|
throw new api_1.SwapError('[zrxBuildTrade]', {
|
|
139
|
-
code: api_1.SwapErrorTypes.BUILD_TRADE_FAILED
|
|
141
|
+
code: api_1.SwapErrorTypes.BUILD_TRADE_FAILED,
|
|
140
142
|
});
|
|
141
143
|
}
|
|
142
144
|
}
|
|
@@ -11,7 +11,7 @@ async function zrxExecuteTrade({ adapter }, { trade, wallet }) {
|
|
|
11
11
|
// value is 0 for erc20s
|
|
12
12
|
const value = (0, helpers_1.isNativeEvmAsset)(sellAsset.assetId) ? trade.sellAmount : '0';
|
|
13
13
|
const bip44Params = adapter.buildBIP44Params({
|
|
14
|
-
accountNumber: trade.sellAssetAccountNumber
|
|
14
|
+
accountNumber: trade.sellAssetAccountNumber,
|
|
15
15
|
});
|
|
16
16
|
const buildTxResponse = await adapter.buildSendTransaction({
|
|
17
17
|
value,
|
|
@@ -19,9 +19,9 @@ async function zrxExecuteTrade({ adapter }, { trade, wallet }) {
|
|
|
19
19
|
to: trade.depositAddress,
|
|
20
20
|
chainSpecific: {
|
|
21
21
|
gasPrice: (0, web3_utils_1.numberToHex)(((_b = (_a = trade.feeData) === null || _a === void 0 ? void 0 : _a.chainSpecific) === null || _b === void 0 ? void 0 : _b.gasPrice) || 0),
|
|
22
|
-
gasLimit: (0, web3_utils_1.numberToHex)(((_d = (_c = trade.feeData) === null || _c === void 0 ? void 0 : _c.chainSpecific) === null || _d === void 0 ? void 0 : _d.estimatedGas) || 0)
|
|
22
|
+
gasLimit: (0, web3_utils_1.numberToHex)(((_d = (_c = trade.feeData) === null || _c === void 0 ? void 0 : _c.chainSpecific) === null || _d === void 0 ? void 0 : _d.estimatedGas) || 0),
|
|
23
23
|
},
|
|
24
|
-
bip44Params
|
|
24
|
+
bip44Params,
|
|
25
25
|
});
|
|
26
26
|
const { txToSign } = buildTxResponse;
|
|
27
27
|
const txWithQuoteData = { ...txToSign, data: (_e = trade.txData) !== null && _e !== void 0 ? _e : '' };
|
|
@@ -33,13 +33,13 @@ async function zrxExecuteTrade({ adapter }, { trade, wallet }) {
|
|
|
33
33
|
else if (wallet.supportsBroadcast() && adapter.signAndBroadcastTransaction) {
|
|
34
34
|
const txid = await ((_f = adapter.signAndBroadcastTransaction) === null || _f === void 0 ? void 0 : _f.call(adapter, {
|
|
35
35
|
txToSign: txWithQuoteData,
|
|
36
|
-
wallet
|
|
36
|
+
wallet,
|
|
37
37
|
}));
|
|
38
38
|
return { tradeId: txid };
|
|
39
39
|
}
|
|
40
40
|
else {
|
|
41
41
|
throw new api_1.SwapError('[zrxExecuteTrade]', {
|
|
42
|
-
code: api_1.SwapErrorTypes.SIGN_AND_BROADCAST_FAILED
|
|
42
|
+
code: api_1.SwapErrorTypes.SIGN_AND_BROADCAST_FAILED,
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -48,7 +48,7 @@ async function zrxExecuteTrade({ adapter }, { trade, wallet }) {
|
|
|
48
48
|
throw e;
|
|
49
49
|
throw new api_1.SwapError('[zrxExecuteTrade]', {
|
|
50
50
|
cause: e,
|
|
51
|
-
code: api_1.SwapErrorTypes.EXECUTE_TRADE_FAILED
|
|
51
|
+
code: api_1.SwapErrorTypes.EXECUTE_TRADE_FAILED,
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
}
|
package/package.json
CHANGED