@oydual31/more-vaults-sdk 1.1.18 → 1.1.19

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.
@@ -600,6 +600,12 @@ var NotWhitelistedError = class extends MoreVaultsError {
600
600
  this.name = "NotWhitelistedError";
601
601
  }
602
602
  };
603
+ var WhitelistQuotaExhaustedError = class extends MoreVaultsError {
604
+ constructor(vault, user) {
605
+ super(`[MoreVaults] Address ${user} has no remaining whitelist deposit quota on vault ${vault}. Ask the vault owner to increase your deposit cap.`);
606
+ this.name = "WhitelistQuotaExhaustedError";
607
+ }
608
+ };
603
609
  var InsufficientLiquidityError = class extends MoreVaultsError {
604
610
  hubLiquid;
605
611
  required;
@@ -1297,17 +1303,26 @@ async function preflightRedeemLiquidity(provider, vault, shares) {
1297
1303
  throw new InsufficientLiquidityError(vault, hubLiquid, assetsNeeded);
1298
1304
  }
1299
1305
  }
1300
- async function preflightSync(provider, vault) {
1306
+ async function preflightSync(provider, vault, user) {
1301
1307
  const config = new ethers.Contract(vault, CONFIG_ABI, provider);
1302
1308
  const [isPaused, depositCapResult] = await Promise.all([
1303
1309
  config.paused(),
1304
- config.maxDeposit(ethers.ZeroAddress).catch(() => null)
1310
+ config.maxDeposit(user).catch(() => null)
1305
1311
  ]);
1306
1312
  if (isPaused) {
1307
1313
  throw new VaultPausedError(vault);
1308
1314
  }
1309
- if (depositCapResult !== null && depositCapResult === 0n) {
1310
- throw new CapacityFullError(vault);
1315
+ if (depositCapResult === null) return;
1316
+ if (depositCapResult === 0n) {
1317
+ const vaultContract = new ethers.Contract(vault, VAULT_ABI, provider);
1318
+ const [capacity, assets] = await Promise.all([
1319
+ config.depositCapacity(),
1320
+ vaultContract.totalAssets()
1321
+ ]);
1322
+ if (capacity > 0n && assets >= capacity) {
1323
+ throw new CapacityFullError(vault);
1324
+ }
1325
+ throw new WhitelistQuotaExhaustedError(vault, user);
1311
1326
  }
1312
1327
  }
1313
1328
  async function preflightSpokeDeposit(spokeProvider, vault, spokeOFT, hubEid, spokeEid, amount, userAddress, lzFee) {
@@ -1479,7 +1494,7 @@ async function depositSimple(signer, addresses, assets, receiver) {
1479
1494
  if (assets === 0n) throw new InvalidInputError("deposit amount must be greater than zero");
1480
1495
  const provider = signer.provider;
1481
1496
  await validateWalletChain(signer, addresses.hubChainId);
1482
- await preflightSync(provider, addresses.vault);
1497
+ await preflightSync(provider, addresses.vault, receiver);
1483
1498
  const vault = new ethers.Contract(addresses.vault, VAULT_ABI, signer);
1484
1499
  const underlying = await vault.asset();
1485
1500
  await ensureAllowance3(signer, underlying, addresses.vault, assets);
@@ -3743,6 +3758,7 @@ exports.UnsupportedChainError = UnsupportedChainError;
3743
3758
  exports.VAULT_ABI = VAULT_ABI;
3744
3759
  exports.VAULT_ANALYSIS_ABI = VAULT_ANALYSIS_ABI;
3745
3760
  exports.VaultPausedError = VaultPausedError;
3761
+ exports.WhitelistQuotaExhaustedError = WhitelistQuotaExhaustedError;
3746
3762
  exports.WithdrawalTimelockActiveError = WithdrawalTimelockActiveError;
3747
3763
  exports.WrongChainError = WrongChainError;
3748
3764
  exports.acceptOwnership = acceptOwnership;