@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.esm.js CHANGED
@@ -1832,9 +1832,9 @@ class ThorchainQuery {
1832
1832
  asset: assetFromStringEx(depositQuote.fees.asset),
1833
1833
  outbound: new CryptoAmount(baseAmount(depositQuote.fees.outbound), addAmount.asset),
1834
1834
  };
1835
- // define savers cap
1836
- const saverCap = 0.3 * +pool.assetDepth;
1837
- const saverCapFilledPercent = (+pool.saversDepth / saverCap) * 100;
1835
+ // define savers filled capacity
1836
+ const saverCapFilledPercent = (+pool.synthSupply / +pool.assetDepth) * 100;
1837
+ // return object
1838
1838
  const estimateAddSaver = {
1839
1839
  assetAmount: new CryptoAmount(baseAmount(depositQuote.expected_amount_out), addAmount.asset),
1840
1840
  estimatedDepositValue: new CryptoAmount(baseAmount(depositQuote.expected_amount_deposit), addAmount.asset),
@@ -1950,8 +1950,10 @@ class ThorchainQuery {
1950
1950
  errors.push(`Could not find position for ${params.address}`);
1951
1951
  if (!(blockData === null || blockData === void 0 ? void 0 : blockData.thorchain))
1952
1952
  errors.push(`Could not get thorchain block height`);
1953
- const outboundFee = yield calcOutboundFee(params.asset, inboundDetails[params.asset.chain]);
1954
- if (Number(savers === null || savers === void 0 ? void 0 : savers.asset_redeem_value) < outboundFee.baseAmount.amount().toNumber())
1953
+ const outboundFee = calcOutboundFee(params.asset, inboundDetails[params.asset.chain]);
1954
+ const convertToBaseEight = getBaseAmountWithDiffDecimals(outboundFee, 8);
1955
+ // For comparison use 1e8 since asset_redeem_value is returned in 1e8
1956
+ if (Number(savers === null || savers === void 0 ? void 0 : savers.asset_redeem_value) < convertToBaseEight.toNumber())
1955
1957
  errors.push(`Unlikely to withdraw balance as outbound fee is greater than redeemable amount`);
1956
1958
  const ownerUnits = Number(savers === null || savers === void 0 ? void 0 : savers.units);
1957
1959
  const lastAdded = Number(savers === null || savers === void 0 ? void 0 : savers.last_add_height);