@oydual31/more-vaults-sdk 0.2.5 → 0.2.7

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.
@@ -1459,21 +1459,9 @@ declare function waitForCompose(hubPublicClient: PublicClient, composeData: Comp
1459
1459
  * @returns ETH amount in wei to send with executeCompose
1460
1460
  */
1461
1461
  declare function quoteComposeFee(hubPublicClient: PublicClient, vault: Address, spokeEid?: number, receiver?: Address): Promise<bigint>;
1462
- /**
1463
- * Execute a pending LZ compose on the hub chain (Stargate 2-TX flow, step 2).
1464
- *
1465
- * Calls `endpoint.lzCompose{value: fee}(from, to, guid, index, message, '0x')`.
1466
- * This triggers MoreVaultsComposer.lzCompose() which deposits tokens into the vault
1467
- * and delivers shares to the user on the hub chain.
1468
- *
1469
- * @param walletClient Wallet client on the HUB chain (user signs TX2 here)
1470
- * @param hubPublicClient Public client on the HUB chain
1471
- * @param composeData Complete compose data (from waitForCompose or manual)
1472
- * @param fee ETH to send (from quoteComposeFee). Covers readFee for D7.
1473
- * @returns Transaction hash of the compose execution
1474
- */
1475
1462
  declare function executeCompose(walletClient: WalletClient, hubPublicClient: PublicClient, composeData: ComposeData, fee: bigint): Promise<{
1476
1463
  txHash: Hash;
1464
+ guid?: `0x${string}`;
1477
1465
  }>;
1478
1466
 
1479
1467
  /**
@@ -1459,21 +1459,9 @@ declare function waitForCompose(hubPublicClient: PublicClient, composeData: Comp
1459
1459
  * @returns ETH amount in wei to send with executeCompose
1460
1460
  */
1461
1461
  declare function quoteComposeFee(hubPublicClient: PublicClient, vault: Address, spokeEid?: number, receiver?: Address): Promise<bigint>;
1462
- /**
1463
- * Execute a pending LZ compose on the hub chain (Stargate 2-TX flow, step 2).
1464
- *
1465
- * Calls `endpoint.lzCompose{value: fee}(from, to, guid, index, message, '0x')`.
1466
- * This triggers MoreVaultsComposer.lzCompose() which deposits tokens into the vault
1467
- * and delivers shares to the user on the hub chain.
1468
- *
1469
- * @param walletClient Wallet client on the HUB chain (user signs TX2 here)
1470
- * @param hubPublicClient Public client on the HUB chain
1471
- * @param composeData Complete compose data (from waitForCompose or manual)
1472
- * @param fee ETH to send (from quoteComposeFee). Covers readFee for D7.
1473
- * @returns Transaction hash of the compose execution
1474
- */
1475
1462
  declare function executeCompose(walletClient: WalletClient, hubPublicClient: PublicClient, composeData: ComposeData, fee: bigint): Promise<{
1476
1463
  txHash: Hash;
1464
+ guid?: `0x${string}`;
1477
1465
  }>;
1478
1466
 
1479
1467
  /**
@@ -1962,6 +1962,7 @@ async function quoteComposeFee(hubPublicClient, vault, spokeEid, receiver) {
1962
1962
  return 500000000000000n;
1963
1963
  }
1964
1964
  }
1965
+ var ESCROW_REQUEST_TOPIC = "0x304ac8b57de34b9e6118fb049ba362689cfcfab98c30c9d78e3e2e14be7e0972";
1965
1966
  async function executeCompose(walletClient, hubPublicClient, composeData, fee) {
1966
1967
  const account = walletClient.account;
1967
1968
  const endpoint = getAddress(composeData.endpoint);
@@ -1996,7 +1997,18 @@ async function executeCompose(walletClient, hubPublicClient, composeData, fee) {
1996
1997
  gas: 5000000n
1997
1998
  // initVaultActionRequest + LZ Read is gas-heavy
1998
1999
  });
1999
- return { txHash };
2000
+ let guid;
2001
+ try {
2002
+ const receipt = await hubPublicClient.waitForTransactionReceipt({ hash: txHash, timeout: 6e4 });
2003
+ for (const log of receipt.logs) {
2004
+ if (log.topics[0] === ESCROW_REQUEST_TOPIC && log.topics[1]) {
2005
+ guid = log.topics[1];
2006
+ break;
2007
+ }
2008
+ }
2009
+ } catch {
2010
+ }
2011
+ return { txHash, guid };
2000
2012
  }
2001
2013
 
2002
2014
  // src/viem/preflight.ts
@@ -3041,12 +3053,21 @@ async function getUserPositionMultiChain(vault, user) {
3041
3053
  }
3042
3054
  const spokeClient = createChainClient(spokeChainId);
3043
3055
  if (!spokeClient) return { chainId: spokeChainId, balance: 0n };
3044
- const balance = await spokeClient.readContract({
3045
- address: spokeOft,
3046
- abi: ERC20_ABI,
3047
- functionName: "balanceOf",
3048
- args: [u]
3056
+ const [rawBalance, spokeOftDecimals] = await spokeClient.multicall({
3057
+ contracts: [
3058
+ { address: spokeOft, abi: ERC20_ABI, functionName: "balanceOf", args: [u] },
3059
+ { address: spokeOft, abi: METADATA_ABI, functionName: "decimals" }
3060
+ ],
3061
+ allowFailure: false
3049
3062
  });
3063
+ let balance;
3064
+ if (spokeOftDecimals > decimals) {
3065
+ balance = rawBalance / 10n ** BigInt(spokeOftDecimals - decimals);
3066
+ } else if (spokeOftDecimals < decimals) {
3067
+ balance = rawBalance * 10n ** BigInt(decimals - spokeOftDecimals);
3068
+ } else {
3069
+ balance = rawBalance;
3070
+ }
3050
3071
  return { chainId: spokeChainId, balance };
3051
3072
  } catch {
3052
3073
  return { chainId: spokeChainId, balance: 0n };