@oydual31/more-vaults-sdk 1.1.17 → 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;
@@ -742,6 +748,12 @@ var ComposeTimeoutError = class extends MoreVaultsError {
742
748
  this.guid = guid;
743
749
  }
744
750
  };
751
+ var ComposeAlreadyExecutedError = class extends MoreVaultsError {
752
+ constructor() {
753
+ super("[MoreVaults] Compose already executed \u2014 deposit is complete, no action needed.");
754
+ this.name = "ComposeAlreadyExecutedError";
755
+ }
756
+ };
745
757
  var WithdrawalTimelockActiveError = class extends MoreVaultsError {
746
758
  timelockEndsAt;
747
759
  requestTxHash;
@@ -1186,7 +1198,11 @@ async function waitForCompose(hubProvider, composeData, receiver, pollIntervalMs
1186
1198
  logGuid,
1187
1199
  logIndex
1188
1200
  );
1189
- if (hash !== EMPTY_HASH && hash !== RECEIVED_HASH) {
1201
+ if (hash === RECEIVED_HASH) {
1202
+ console.log(`[more-vaults-sdk] waitForCompose compose already executed (RECEIVED_HASH) \u2014 signaling done`);
1203
+ throw new ComposeAlreadyExecutedError();
1204
+ }
1205
+ if (hash !== EMPTY_HASH) {
1190
1206
  console.log(`[${elapsed}s] Poll #${attempt} \u2014 compose found! (block ${log.blockNumber})`);
1191
1207
  return {
1192
1208
  ...composeData,
@@ -1198,16 +1214,19 @@ async function waitForCompose(hubProvider, composeData, receiver, pollIntervalMs
1198
1214
  };
1199
1215
  }
1200
1216
  }
1201
- } catch {
1217
+ } catch (e) {
1218
+ if (e instanceof ComposeAlreadyExecutedError) throw e;
1202
1219
  }
1203
1220
  }
1204
- } catch {
1221
+ } catch (e) {
1222
+ if (e instanceof ComposeAlreadyExecutedError) throw e;
1205
1223
  break;
1206
1224
  }
1207
1225
  from = chunkEnd + 1n;
1208
1226
  }
1209
1227
  scannedUpTo = currentBlock;
1210
- } catch {
1228
+ } catch (e) {
1229
+ if (e instanceof ComposeAlreadyExecutedError) throw e;
1211
1230
  }
1212
1231
  let guidMatchFound = false;
1213
1232
  for (const fromAddr of knownFromAddresses) {
@@ -1284,17 +1303,26 @@ async function preflightRedeemLiquidity(provider, vault, shares) {
1284
1303
  throw new InsufficientLiquidityError(vault, hubLiquid, assetsNeeded);
1285
1304
  }
1286
1305
  }
1287
- async function preflightSync(provider, vault) {
1306
+ async function preflightSync(provider, vault, user) {
1288
1307
  const config = new ethers.Contract(vault, CONFIG_ABI, provider);
1289
1308
  const [isPaused, depositCapResult] = await Promise.all([
1290
1309
  config.paused(),
1291
- config.maxDeposit(ethers.ZeroAddress).catch(() => null)
1310
+ config.maxDeposit(user).catch(() => null)
1292
1311
  ]);
1293
1312
  if (isPaused) {
1294
1313
  throw new VaultPausedError(vault);
1295
1314
  }
1296
- if (depositCapResult !== null && depositCapResult === 0n) {
1297
- 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);
1298
1326
  }
1299
1327
  }
1300
1328
  async function preflightSpokeDeposit(spokeProvider, vault, spokeOFT, hubEid, spokeEid, amount, userAddress, lzFee) {
@@ -1466,7 +1494,7 @@ async function depositSimple(signer, addresses, assets, receiver) {
1466
1494
  if (assets === 0n) throw new InvalidInputError("deposit amount must be greater than zero");
1467
1495
  const provider = signer.provider;
1468
1496
  await validateWalletChain(signer, addresses.hubChainId);
1469
- await preflightSync(provider, addresses.vault);
1497
+ await preflightSync(provider, addresses.vault, receiver);
1470
1498
  const vault = new ethers.Contract(addresses.vault, VAULT_ABI, signer);
1471
1499
  const underlying = await vault.asset();
1472
1500
  await ensureAllowance3(signer, underlying, addresses.vault, assets);
@@ -3690,6 +3718,7 @@ exports.CHAIN_ID_TO_EID = CHAIN_ID_TO_EID;
3690
3718
  exports.CONFIG_ABI = CONFIG_ABI;
3691
3719
  exports.CURATOR_CONFIG_ABI = CURATOR_CONFIG_ABI;
3692
3720
  exports.CapacityFullError = CapacityFullError;
3721
+ exports.ComposeAlreadyExecutedError = ComposeAlreadyExecutedError;
3693
3722
  exports.ComposeTimeoutError = ComposeTimeoutError;
3694
3723
  exports.ComposerNotConfiguredError = ComposerNotConfiguredError;
3695
3724
  exports.DEX_ABI = DEX_ABI;
@@ -3729,6 +3758,7 @@ exports.UnsupportedChainError = UnsupportedChainError;
3729
3758
  exports.VAULT_ABI = VAULT_ABI;
3730
3759
  exports.VAULT_ANALYSIS_ABI = VAULT_ANALYSIS_ABI;
3731
3760
  exports.VaultPausedError = VaultPausedError;
3761
+ exports.WhitelistQuotaExhaustedError = WhitelistQuotaExhaustedError;
3732
3762
  exports.WithdrawalTimelockActiveError = WithdrawalTimelockActiveError;
3733
3763
  exports.WrongChainError = WrongChainError;
3734
3764
  exports.acceptOwnership = acceptOwnership;