@oydual31/more-vaults-sdk 0.1.13 → 0.1.15

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.
@@ -222,21 +222,22 @@ async function preflightAsync(provider, vault, escrow) {
222
222
  }
223
223
  }
224
224
  async function preflightRedeemLiquidity(provider, vault, shares) {
225
+ const config = new ethers.Contract(vault, CONFIG_ABI, provider);
226
+ const bridge = new ethers.Contract(vault, BRIDGE_ABI, provider);
227
+ const [isHub, oraclesEnabled] = await Promise.all([
228
+ config.isHub(),
229
+ bridge.oraclesCrossChainAccounting()
230
+ ]);
231
+ if (!isHub || oraclesEnabled) return;
225
232
  const vaultContract = new ethers.Contract(vault, VAULT_ABI, provider);
226
233
  const underlying = await vaultContract.asset();
227
234
  const underlyingContract = new ethers.Contract(underlying, ERC20_ABI, provider);
228
235
  const [hubLiquid, assetsNeeded] = await Promise.all([
229
236
  underlyingContract.balanceOf(vault),
230
- vaultContract.convertToAssets(shares)
237
+ vaultContract.previewRedeem(shares)
231
238
  ]);
232
239
  if (hubLiquid < assetsNeeded) {
233
- throw new Error(
234
- `[MoreVaults] Insufficient hub liquidity for redeem.
235
- Hub liquid balance : ${hubLiquid}
236
- Estimated required : ${assetsNeeded}
237
- Submitting this redeem will waste the LayerZero fee \u2014 the request will be auto-refunded.
238
- Ask the vault curator to repatriate liquidity from spoke chains first.`
239
- );
240
+ throw new InsufficientLiquidityError(vault, hubLiquid, assetsNeeded);
240
241
  }
241
242
  }
242
243
  async function preflightSync(provider, vault) {