@shapeshiftoss/swapper 11.5.3 → 11.5.4

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.
@@ -28,6 +28,17 @@ const getPriceRatio = async (deps, input) => {
28
28
  const { data: responseData } = await thorService_1.thorService.get(`${deps.daemonUrl}/lcd/thorchain/pools`);
29
29
  const buyPool = responseData.find((response) => response.asset === buyPoolId);
30
30
  const sellPool = responseData.find((response) => response.asset === sellPoolId);
31
+ /**
32
+ * there is no rune pool, rune *is* the pool, special logic case buying RUNE
33
+ */
34
+ if ((0, isRune_1.isRune)(buyAssetId) && sellPool) {
35
+ const sellAssetBalance = (0, bignumber_1.bnOrZero)(sellPool.balance_asset);
36
+ const runeBalance = (0, bignumber_1.bnOrZero)(sellPool.balance_rune);
37
+ // guard against division by zero
38
+ if (sellAssetBalance.eq(0))
39
+ throw new api_1.SwapError(`[getPriceRatio] zero sell asset balance sellAssetId ${sellAssetId} buyAssetId ${buyAssetId}`);
40
+ return (0, bignumber_1.bn)(runeBalance).dividedBy(sellAssetBalance).toString();
41
+ }
31
42
  if (!buyPool || !sellPool) {
32
43
  throw new api_1.SwapError(`[getPriceRatio]: pools not found`, {
33
44
  code: api_1.SwapErrorTypes.RESPONSE_ERROR,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshiftoss/swapper",
3
- "version": "11.5.3",
3
+ "version": "11.5.4",
4
4
  "description": "An interface and implementations to trade coins via various protocols",
5
5
  "repository": "https://github.com/shapeshift/lib",
6
6
  "license": "MIT",