@shapeshiftoss/swapper 9.12.0 → 9.12.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.
|
@@ -26,11 +26,10 @@ const getThorTradeQuote = async ({ deps, input }) => {
|
|
|
26
26
|
code: api_1.SwapErrorTypes.UNSUPPORTED_CHAIN,
|
|
27
27
|
details: { chainId }
|
|
28
28
|
});
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const buyAmount = (0, bignumber_1.toBaseUnit)((0, bignumber_1.bnOrZero)((0, bignumber_1.fromBaseUnit)(sellAmount, sellAsset.precision)).times(tradeRate), buyAsset.precision);
|
|
29
|
+
const rate = await (0, getTradeRate_1.getTradeRate)(sellAsset, buyAsset.assetId, sellAmount, deps);
|
|
30
|
+
const buyAmount = (0, bignumber_1.toBaseUnit)((0, bignumber_1.bnOrZero)((0, bignumber_1.fromBaseUnit)(sellAmount, sellAsset.precision)).times(rate), buyAsset.precision);
|
|
32
31
|
const tradeFee = await (0, estimateTradeFee_1.estimateTradeFee)(deps, buyAsset);
|
|
33
|
-
const sellAssetTradeFee = (0, bignumber_1.bnOrZero)(tradeFee).
|
|
32
|
+
const sellAssetTradeFee = (0, bignumber_1.bnOrZero)(tradeFee).dividedBy((0, bignumber_1.bnOrZero)(rate));
|
|
34
33
|
// minimum is tradeFee padded by an amount to be sure they get something back
|
|
35
34
|
// usually it will be slightly more than the amount because sellAssetTradeFee is already a high estimate
|
|
36
35
|
const minimum = (0, bignumber_1.bnOrZero)(sellAssetTradeFee).times(constants_2.THOR_MINIMUM_PADDING).toString();
|
|
@@ -24,7 +24,7 @@ const getPriceRatio = async (deps, input) => {
|
|
|
24
24
|
code: api_1.SwapErrorTypes.RESPONSE_ERROR,
|
|
25
25
|
details: { buyPoolId, sellPoolId }
|
|
26
26
|
});
|
|
27
|
-
return (0, bignumber_1.bnOrZero)(
|
|
27
|
+
return (0, bignumber_1.bnOrZero)(sellUsdPrice).dividedBy(buyUsdPrice).toString();
|
|
28
28
|
}
|
|
29
29
|
catch (e) {
|
|
30
30
|
if (e instanceof api_1.SwapError)
|
package/package.json
CHANGED