@oydual31/more-vaults-sdk 0.2.4 → 0.2.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.
@@ -1,6 +1,6 @@
1
1
  import { Hash, Address, WalletClient, PublicClient } from 'viem';
2
2
  export { PublicClient as SdkPublicClient } from 'viem';
3
- export { A as AsyncRequestStatus, a as AsyncRequestStatusInfo, D as DepositBlockReason, b as DepositEligibility, I as InboundRoute, c as InboundRouteWithBalance, M as MaxWithdrawable, d as MultiChainUserPosition, N as NATIVE_SYMBOL, O as OMNI_FACTORY_ADDRESS, e as OutboundRoute, S as SpokeBalance, U as UserBalances, f as UserPosition, V as VaultDistribution, g as VaultMetadata, h as VaultMode, i as VaultStatus, j as VaultSummary, k as VaultTopology, l as canDeposit, m as discoverVaultTopology, n as ensureAllowance, o as getAllVaultChainIds, p as getAsyncRequestStatus, q as getAsyncRequestStatusLabel, r as getFullVaultTopology, s as getInboundRoutes, t as getMaxWithdrawable, u as getOutboundRoutes, v as getUserBalances, w as getUserBalancesForRoutes, x as getUserPosition, y as getUserPositionMultiChain, z as getVaultDistribution, B as getVaultDistributionWithTopology, C as getVaultMetadata, E as getVaultStatus, F as getVaultSummary, G as getVaultTopology, H as isAsyncMode, J as isOnHubChain, K as previewDeposit, L as previewRedeem, P as quoteLzFee, Q as quoteRouteDepositFee, R as waitForTx } from '../spokeRoutes-CXMG7nLp.cjs';
3
+ export { A as AsyncRequestFinalResult, a as AsyncRequestStatus, b as AsyncRequestStatusInfo, D as DepositBlockReason, c as DepositEligibility, I as InboundRoute, d as InboundRouteWithBalance, M as MaxWithdrawable, e as MultiChainUserPosition, N as NATIVE_SYMBOL, O as OMNI_FACTORY_ADDRESS, f as OutboundRoute, S as SpokeBalance, U as UserBalances, g as UserPosition, V as VaultDistribution, h as VaultMetadata, i as VaultMode, j as VaultStatus, k as VaultSummary, l as VaultTopology, m as canDeposit, n as discoverVaultTopology, o as ensureAllowance, p as getAllVaultChainIds, q as getAsyncRequestStatus, r as getAsyncRequestStatusLabel, s as getFullVaultTopology, t as getInboundRoutes, u as getMaxWithdrawable, v as getOutboundRoutes, w as getUserBalances, x as getUserBalancesForRoutes, y as getUserPosition, z as getUserPositionMultiChain, B as getVaultDistribution, C as getVaultDistributionWithTopology, E as getVaultMetadata, F as getVaultStatus, G as getVaultSummary, H as getVaultTopology, J as isAsyncMode, K as isOnHubChain, L as previewDeposit, P as previewRedeem, Q as quoteLzFee, R as quoteRouteDepositFee, T as waitForAsyncRequest, W as waitForTx } from '../spokeRoutes-z7s_5ooO.cjs';
4
4
 
5
5
  /** EVM Chain IDs for chains supported by MoreVaults */
6
6
  declare const CHAIN_IDS: {
@@ -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
  /**
@@ -1,6 +1,6 @@
1
1
  import { Hash, Address, WalletClient, PublicClient } from 'viem';
2
2
  export { PublicClient as SdkPublicClient } from 'viem';
3
- export { A as AsyncRequestStatus, a as AsyncRequestStatusInfo, D as DepositBlockReason, b as DepositEligibility, I as InboundRoute, c as InboundRouteWithBalance, M as MaxWithdrawable, d as MultiChainUserPosition, N as NATIVE_SYMBOL, O as OMNI_FACTORY_ADDRESS, e as OutboundRoute, S as SpokeBalance, U as UserBalances, f as UserPosition, V as VaultDistribution, g as VaultMetadata, h as VaultMode, i as VaultStatus, j as VaultSummary, k as VaultTopology, l as canDeposit, m as discoverVaultTopology, n as ensureAllowance, o as getAllVaultChainIds, p as getAsyncRequestStatus, q as getAsyncRequestStatusLabel, r as getFullVaultTopology, s as getInboundRoutes, t as getMaxWithdrawable, u as getOutboundRoutes, v as getUserBalances, w as getUserBalancesForRoutes, x as getUserPosition, y as getUserPositionMultiChain, z as getVaultDistribution, B as getVaultDistributionWithTopology, C as getVaultMetadata, E as getVaultStatus, F as getVaultSummary, G as getVaultTopology, H as isAsyncMode, J as isOnHubChain, K as previewDeposit, L as previewRedeem, P as quoteLzFee, Q as quoteRouteDepositFee, R as waitForTx } from '../spokeRoutes-CXMG7nLp.js';
3
+ export { A as AsyncRequestFinalResult, a as AsyncRequestStatus, b as AsyncRequestStatusInfo, D as DepositBlockReason, c as DepositEligibility, I as InboundRoute, d as InboundRouteWithBalance, M as MaxWithdrawable, e as MultiChainUserPosition, N as NATIVE_SYMBOL, O as OMNI_FACTORY_ADDRESS, f as OutboundRoute, S as SpokeBalance, U as UserBalances, g as UserPosition, V as VaultDistribution, h as VaultMetadata, i as VaultMode, j as VaultStatus, k as VaultSummary, l as VaultTopology, m as canDeposit, n as discoverVaultTopology, o as ensureAllowance, p as getAllVaultChainIds, q as getAsyncRequestStatus, r as getAsyncRequestStatusLabel, s as getFullVaultTopology, t as getInboundRoutes, u as getMaxWithdrawable, v as getOutboundRoutes, w as getUserBalances, x as getUserBalancesForRoutes, y as getUserPosition, z as getUserPositionMultiChain, B as getVaultDistribution, C as getVaultDistributionWithTopology, E as getVaultMetadata, F as getVaultStatus, G as getVaultSummary, H as getVaultTopology, J as isAsyncMode, K as isOnHubChain, L as previewDeposit, P as previewRedeem, Q as quoteLzFee, R as quoteRouteDepositFee, T as waitForAsyncRequest, W as waitForTx } from '../spokeRoutes-z7s_5ooO.js';
4
4
 
5
5
  /** EVM Chain IDs for chains supported by MoreVaults */
6
6
  declare const CHAIN_IDS: {
@@ -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
  /**
@@ -1129,9 +1129,27 @@ async function getAsyncRequestStatus(publicClient, vault, guid) {
1129
1129
  return {
1130
1130
  fulfilled: info.fulfilled,
1131
1131
  finalized: info.finalized,
1132
+ refunded: info.refunded,
1132
1133
  result: finalizationResult
1133
1134
  };
1134
1135
  }
1136
+ async function waitForAsyncRequest(publicClient, vault, guid, pollInterval = 3e4, timeout = 9e5, onPoll) {
1137
+ const deadline = Date.now() + timeout;
1138
+ while (Date.now() < deadline) {
1139
+ const status = await getAsyncRequestStatus(publicClient, vault, guid);
1140
+ if (onPoll) onPoll(status);
1141
+ if (status.finalized) {
1142
+ return { status: "completed", result: status.result };
1143
+ }
1144
+ if (status.refunded) {
1145
+ return { status: "refunded", result: 0n };
1146
+ }
1147
+ await new Promise((r) => setTimeout(r, pollInterval));
1148
+ }
1149
+ throw new Error(
1150
+ `[MoreVaults] Async request ${guid} did not finalize within ${timeout / 1e3}s. The request may still complete \u2014 check https://layerzeroscan.com/tx/${guid}`
1151
+ );
1152
+ }
1135
1153
  var PUBLIC_RPCS = {
1136
1154
  1: [
1137
1155
  "https://ethereum-rpc.publicnode.com",
@@ -1944,6 +1962,7 @@ async function quoteComposeFee(hubPublicClient, vault, spokeEid, receiver) {
1944
1962
  return 500000000000000n;
1945
1963
  }
1946
1964
  }
1965
+ var ESCROW_REQUEST_TOPIC = "0x304ac8b57de34b9e6118fb049ba362689cfcfab98c30c9d78e3e2e14be7e0972";
1947
1966
  async function executeCompose(walletClient, hubPublicClient, composeData, fee) {
1948
1967
  const account = walletClient.account;
1949
1968
  const endpoint = getAddress(composeData.endpoint);
@@ -1978,7 +1997,18 @@ async function executeCompose(walletClient, hubPublicClient, composeData, fee) {
1978
1997
  gas: 5000000n
1979
1998
  // initVaultActionRequest + LZ Read is gas-heavy
1980
1999
  });
1981
- 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 };
1982
2012
  }
1983
2013
 
1984
2014
  // src/viem/preflight.ts
@@ -3127,6 +3157,6 @@ function asSdkClient(client) {
3127
3157
  return client;
3128
3158
  }
3129
3159
 
3130
- export { ActionType, BRIDGE_ABI, CCManagerNotConfiguredError, CHAIN_IDS, CHAIN_ID_TO_EID, CONFIG_ABI, CapacityFullError, EID_TO_CHAIN_ID, ERC20_ABI, EscrowNotConfiguredError, InsufficientLiquidityError, LZ_EIDS, LZ_ENDPOINT_ABI, LZ_TIMEOUTS, METADATA_ABI, MissingEscrowAddressError, MoreVaultsError, NATIVE_SYMBOL, NotHubVaultError, NotWhitelistedError, OFT_ABI, OFT_ROUTES, OMNI_FACTORY_ADDRESS, STARGATE_TAXI_CMD, USDC_STARGATE_OFT, USDC_TOKEN, VAULT_ABI, VaultPausedError, WrongChainError, asSdkClient, bridgeAssetsToSpoke, bridgeSharesToHub, canDeposit, depositAsync, depositSimple as depositCrossChainOracleOn, depositFromSpoke, depositFromSpoke as depositFromSpokeAsync, depositMultiAsset, depositSimple, discoverVaultTopology, ensureAllowance, executeCompose, getAllVaultChainIds, getAsyncRequestStatus, getAsyncRequestStatusLabel, getFullVaultTopology, getInboundRoutes, getMaxWithdrawable, getOutboundRoutes, getUserBalances, getUserBalancesForRoutes, getUserPosition, getUserPositionMultiChain, getVaultDistribution, getVaultDistributionWithTopology, getVaultMetadata, getVaultStatus, getVaultSummary, getVaultTopology, getWithdrawalRequest, isAsyncMode, isOnHubChain, mintAsync, preflightAsync, preflightRedeemLiquidity, preflightSpokeDeposit, preflightSpokeRedeem, preflightSync, previewDeposit, previewRedeem, quoteComposeFee, quoteDepositFromSpokeFee, quoteLzFee, quoteRouteDepositFee, redeemAsync, redeemShares, requestRedeem, resolveRedeemAddresses, smartDeposit, smartRedeem, waitForCompose, waitForTx, withdrawAssets };
3160
+ export { ActionType, BRIDGE_ABI, CCManagerNotConfiguredError, CHAIN_IDS, CHAIN_ID_TO_EID, CONFIG_ABI, CapacityFullError, EID_TO_CHAIN_ID, ERC20_ABI, EscrowNotConfiguredError, InsufficientLiquidityError, LZ_EIDS, LZ_ENDPOINT_ABI, LZ_TIMEOUTS, METADATA_ABI, MissingEscrowAddressError, MoreVaultsError, NATIVE_SYMBOL, NotHubVaultError, NotWhitelistedError, OFT_ABI, OFT_ROUTES, OMNI_FACTORY_ADDRESS, STARGATE_TAXI_CMD, USDC_STARGATE_OFT, USDC_TOKEN, VAULT_ABI, VaultPausedError, WrongChainError, asSdkClient, bridgeAssetsToSpoke, bridgeSharesToHub, canDeposit, depositAsync, depositSimple as depositCrossChainOracleOn, depositFromSpoke, depositFromSpoke as depositFromSpokeAsync, depositMultiAsset, depositSimple, discoverVaultTopology, ensureAllowance, executeCompose, getAllVaultChainIds, getAsyncRequestStatus, getAsyncRequestStatusLabel, getFullVaultTopology, getInboundRoutes, getMaxWithdrawable, getOutboundRoutes, getUserBalances, getUserBalancesForRoutes, getUserPosition, getUserPositionMultiChain, getVaultDistribution, getVaultDistributionWithTopology, getVaultMetadata, getVaultStatus, getVaultSummary, getVaultTopology, getWithdrawalRequest, isAsyncMode, isOnHubChain, mintAsync, preflightAsync, preflightRedeemLiquidity, preflightSpokeDeposit, preflightSpokeRedeem, preflightSync, previewDeposit, previewRedeem, quoteComposeFee, quoteDepositFromSpokeFee, quoteLzFee, quoteRouteDepositFee, redeemAsync, redeemShares, requestRedeem, resolveRedeemAddresses, smartDeposit, smartRedeem, waitForAsyncRequest, waitForCompose, waitForTx, withdrawAssets };
3131
3161
  //# sourceMappingURL=index.js.map
3132
3162
  //# sourceMappingURL=index.js.map