@shapeshiftoss/swapper 9.2.3 → 9.3.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.
|
@@ -27,13 +27,6 @@ const getThorTradeQuote = async ({ deps, input }) => {
|
|
|
27
27
|
code: api_1.SwapErrorTypes.UNSUPPORTED_CHAIN,
|
|
28
28
|
details: { chainId }
|
|
29
29
|
});
|
|
30
|
-
const buyAssetId = buyAsset.assetId;
|
|
31
|
-
const feeAssetId = (0, caip_1.getFeeAssetIdFromAssetId)(buyAssetId);
|
|
32
|
-
if (!feeAssetId)
|
|
33
|
-
throw new api_1.SwapError(`[getThorTradeQuote] - No feeAssetId found for ${buyAssetId}.`, {
|
|
34
|
-
code: api_1.SwapErrorTypes.VALIDATION_FAILED,
|
|
35
|
-
details: { buyAssetId }
|
|
36
|
-
});
|
|
37
30
|
const tradeRate = await (0, getTradeRate_1.getTradeRate)(sellAsset, buyAsset.assetId, sellAmount, deps);
|
|
38
31
|
const rate = (0, bignumber_1.bnOrZero)(1).div(tradeRate).toString();
|
|
39
32
|
const buyAmount = (0, bignumber_1.toBaseUnit)((0, bignumber_1.bnOrZero)((0, bignumber_1.fromBaseUnit)(sellAmount, sellAsset.precision)).times(tradeRate), buyAsset.precision);
|
|
@@ -16,10 +16,6 @@ const thorTradeApprovalNeeded = async ({ deps, input }) => {
|
|
|
16
16
|
const { chainNamespace } = (0, caip_1.fromChainId)(sellAsset.chainId);
|
|
17
17
|
if (chainNamespace !== caip_1.CHAIN_NAMESPACE.Ethereum)
|
|
18
18
|
return { approvalNeeded: false };
|
|
19
|
-
// No approval needed for selling a fee asset
|
|
20
|
-
if (sellAsset.assetId === (0, caip_1.getFeeAssetIdFromAssetId)(sellAsset.assetId)) {
|
|
21
|
-
return { approvalNeeded: false };
|
|
22
|
-
}
|
|
23
19
|
const accountNumber = quote.sellAssetAccountNumber;
|
|
24
20
|
const adapter = adapterManager.get(sellAsset.chainId);
|
|
25
21
|
if (!adapter)
|
|
@@ -27,6 +23,10 @@ const thorTradeApprovalNeeded = async ({ deps, input }) => {
|
|
|
27
23
|
code: api_1.SwapErrorTypes.UNSUPPORTED_CHAIN,
|
|
28
24
|
details: { chainId: sellAsset.chainId }
|
|
29
25
|
});
|
|
26
|
+
// No approval needed for selling a fee asset
|
|
27
|
+
if (sellAsset.assetId === adapter.getFeeAssetId()) {
|
|
28
|
+
return { approvalNeeded: false };
|
|
29
|
+
}
|
|
30
30
|
const bip44Params = adapter.buildBIP44Params({ accountNumber });
|
|
31
31
|
const receiveAddress = await adapter.getAddress({ wallet, bip44Params });
|
|
32
32
|
if (!quote.allowanceContract) {
|
|
@@ -18,7 +18,7 @@ async function zrxApprovalNeeded({ adapter, web3 }, { quote, wallet }) {
|
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
// No approval needed for selling a fee asset
|
|
21
|
-
if (sellAsset.assetId ===
|
|
21
|
+
if (sellAsset.assetId === adapter.getFeeAssetId()) {
|
|
22
22
|
return { approvalNeeded: false };
|
|
23
23
|
}
|
|
24
24
|
const accountNumber = quote.sellAssetAccountNumber;
|
package/package.json
CHANGED