@xchainjs/xchain-thorchain-query 0.4.0 → 0.4.2

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/lib/index.js CHANGED
@@ -1841,9 +1841,9 @@ class ThorchainQuery {
1841
1841
  asset: xchainUtil.assetFromStringEx(depositQuote.fees.asset),
1842
1842
  outbound: new CryptoAmount(xchainUtil.baseAmount(depositQuote.fees.outbound), addAmount.asset),
1843
1843
  };
1844
- // define savers cap
1845
- const saverCap = 0.3 * +pool.assetDepth;
1846
- const saverCapFilledPercent = (+pool.saversDepth / saverCap) * 100;
1844
+ // define savers filled capacity
1845
+ const saverCapFilledPercent = (+pool.synthSupply / +pool.assetDepth) * 100;
1846
+ // return object
1847
1847
  const estimateAddSaver = {
1848
1848
  assetAmount: new CryptoAmount(xchainUtil.baseAmount(depositQuote.expected_amount_out), addAmount.asset),
1849
1849
  estimatedDepositValue: new CryptoAmount(xchainUtil.baseAmount(depositQuote.expected_amount_deposit), addAmount.asset),
@@ -1959,8 +1959,10 @@ class ThorchainQuery {
1959
1959
  errors.push(`Could not find position for ${params.address}`);
1960
1960
  if (!(blockData === null || blockData === void 0 ? void 0 : blockData.thorchain))
1961
1961
  errors.push(`Could not get thorchain block height`);
1962
- const outboundFee = yield calcOutboundFee(params.asset, inboundDetails[params.asset.chain]);
1963
- if (Number(savers === null || savers === void 0 ? void 0 : savers.asset_redeem_value) < outboundFee.baseAmount.amount().toNumber())
1962
+ const outboundFee = calcOutboundFee(params.asset, inboundDetails[params.asset.chain]);
1963
+ const convertToBaseEight = getBaseAmountWithDiffDecimals(outboundFee, 8);
1964
+ // For comparison use 1e8 since asset_redeem_value is returned in 1e8
1965
+ if (Number(savers === null || savers === void 0 ? void 0 : savers.asset_redeem_value) < convertToBaseEight.toNumber())
1964
1966
  errors.push(`Unlikely to withdraw balance as outbound fee is greater than redeemable amount`);
1965
1967
  const ownerUnits = Number(savers === null || savers === void 0 ? void 0 : savers.units);
1966
1968
  const lastAdded = Number(savers === null || savers === void 0 ? void 0 : savers.last_add_height);