@oydual31/more-vaults-sdk 1.1.4 → 1.1.6

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.
@@ -2148,6 +2148,9 @@ function parseContractError(err, vault, caller) {
2148
2148
  }
2149
2149
 
2150
2150
  // src/viem/crossChainFlows.ts
2151
+ function isNativeDropCapError(e) {
2152
+ return String(e).includes("0x0084ce02");
2153
+ }
2151
2154
  var LZ_ENDPOINT = "0x1a44076050125825900e736c501f859c50fe728c";
2152
2155
  var FACTORY_COMPOSER_ABI = [
2153
2156
  {
@@ -2187,9 +2190,15 @@ async function resolveComposeNativeValue(hubClient, vault, composerAddress, spok
2187
2190
  })
2188
2191
  ]);
2189
2192
  const readFee = readFeeResult.status === "fulfilled" ? readFeeResult.value : 0n;
2190
- if (shareOftResult.status === "fulfilled") {
2193
+ if (readFeeResult.status === "rejected") {
2194
+ console.warn("[more-vaults-sdk] resolveComposeNativeValue: quoteAccountingFee failed", readFeeResult.reason);
2195
+ }
2196
+ if (shareOftResult.status === "rejected") {
2197
+ console.warn("[more-vaults-sdk] resolveComposeNativeValue: SHARE_OFT() failed on composer", composerAddress, shareOftResult.reason);
2198
+ } else {
2191
2199
  try {
2192
2200
  const shareOft = shareOftResult.value;
2201
+ console.warn("[more-vaults-sdk] resolveComposeNativeValue: calling quoteSend on", shareOft, "dstEid", spokeEid);
2193
2202
  const feeQuote = await hubClient.readContract({
2194
2203
  address: shareOft,
2195
2204
  abi: OFT_ABI,
@@ -2204,11 +2213,13 @@ async function resolveComposeNativeValue(hubClient, vault, composerAddress, spok
2204
2213
  oftCmd: "0x"
2205
2214
  }, false]
2206
2215
  });
2216
+ console.warn("[more-vaults-sdk] resolveComposeNativeValue: quoteSend ok", feeQuote.nativeFee);
2207
2217
  return readFee + feeQuote.nativeFee;
2208
2218
  } catch (e) {
2209
2219
  console.warn("[more-vaults-sdk] resolveComposeNativeValue: quoteSend failed, using fallback", e);
2210
2220
  }
2211
2221
  }
2222
+ console.warn("[more-vaults-sdk] resolveComposeNativeValue: using fallback readFee*5 =", readFee * 5n);
2212
2223
  return readFee > 0n ? readFee * 5n : 500000000000000n;
2213
2224
  }
2214
2225
  function resolveOftCmd(_oft) {
@@ -2281,6 +2292,22 @@ async function depositFromSpoke(walletClient, publicClient, vault, spokeOFT, hub
2281
2292
  ],
2282
2293
  [hopSendParam, minMsgValue]
2283
2294
  );
2295
+ let needsPendingCompose = isStargate;
2296
+ if (!isStargate && resolvedExtraOptions !== "0x") {
2297
+ try {
2298
+ await publicClient.readContract({
2299
+ address: oft,
2300
+ abi: OFT_ABI,
2301
+ functionName: "quoteSend",
2302
+ args: [{ dstEid: hubEid, to: composerBytes32, amountLD: amount, minAmountLD: amount, extraOptions: resolvedExtraOptions, composeMsg: composeMsgBytes, oftCmd: resolvedOftCmd }, false]
2303
+ });
2304
+ } catch (e) {
2305
+ if (isNativeDropCapError(e)) {
2306
+ resolvedExtraOptions = "0x";
2307
+ needsPendingCompose = true;
2308
+ }
2309
+ }
2310
+ }
2284
2311
  let resolvedMinAmountLD = minAmountLD;
2285
2312
  if (resolvedMinAmountLD === void 0) {
2286
2313
  try {
@@ -2339,9 +2366,8 @@ async function depositFromSpoke(walletClient, publicClient, vault, spokeOFT, hub
2339
2366
  account,
2340
2367
  chain: walletClient.chain
2341
2368
  });
2342
- const stargate = isStargate;
2343
2369
  let composeData;
2344
- if (stargate) {
2370
+ if (needsPendingCompose) {
2345
2371
  const hubBlockStart = await hubClient.getBlockNumber();
2346
2372
  composeData = {
2347
2373
  endpoint: LZ_ENDPOINT,
@@ -2352,7 +2378,7 @@ async function depositFromSpoke(walletClient, publicClient, vault, spokeOFT, hub
2352
2378
  index: 0,
2353
2379
  message: "0x",
2354
2380
  // resolved by waitForCompose — from ComposeSent event
2355
- isStargate: true,
2381
+ isStargate,
2356
2382
  hubChainId,
2357
2383
  hubBlockStart
2358
2384
  };
@@ -2426,12 +2452,16 @@ async function quoteDepositFromSpokeFee(publicClient, vault, spokeOFT, hubEid, s
2426
2452
  composeMsg: composeMsgBytes,
2427
2453
  oftCmd: resolvedOftCmd
2428
2454
  };
2429
- const fee = await publicClient.readContract({
2430
- address: oft,
2431
- abi: OFT_ABI,
2432
- functionName: "quoteSend",
2433
- args: [sendParam, false]
2434
- });
2455
+ let fee;
2456
+ try {
2457
+ fee = await publicClient.readContract({ address: oft, abi: OFT_ABI, functionName: "quoteSend", args: [sendParam, false] });
2458
+ } catch (e) {
2459
+ if (isNativeDropCapError(e)) {
2460
+ fee = await publicClient.readContract({ address: oft, abi: OFT_ABI, functionName: "quoteSend", args: [{ ...sendParam, extraOptions: "0x" }, false] });
2461
+ } else {
2462
+ throw e;
2463
+ }
2464
+ }
2435
2465
  return fee.nativeFee;
2436
2466
  }
2437
2467
  var EMPTY_HASH = "0x0000000000000000000000000000000000000000000000000000000000000000";