/** * Cross-Chain Vault Methods * * Implements LayerZero OVault cross-chain deposit and redemption operations. * These functions are generic — callers provide their own ICrossChainVaultConfig * rather than relying on hardcoded vault addresses. * * @module evm/methods/crossChainVault */ import type { IAddress } from '../../types'; import type { ICrossChainVaultConfig, ICrossChainBuildRequest, ICrossChainBuildResult, ICrossChainDepositRequest, ICrossChainDepositResult, ICrossChainRedeemRequest, ICrossChainRedeemResult, IQuoteCrossChainDepositRequest, IQuoteCrossChainRedeemRequest, IQuoteCrossChainResult, CrossChainErrorType } from '../types/crossChain'; /** * Build LayerZero OVault transaction inputs for cross-chain deposits and * redemptions. Does NOT execute the transaction. * * Overridable defaults on `props`: `slippageBps` = 100 (range 1–10000), * `feeBufferPercent` = 50% (added to LZ `nativeFee`), * `hubLzComposeGasLimit` = 2_000_000n (multi-asset composed messages). * * @returns Transaction inputs or `{ success: false, error }`. */ export declare function buildCrossChainVaultTx(props: ICrossChainBuildRequest): Promise; /** * Estimate fees and expected shares for a cross-chain deposit. The returned * quote carries `quotedAt`/`expiresAt`; re-quote via {@link isQuoteStale} * before submitting. */ export declare function quoteCrossChainDeposit(props: IQuoteCrossChainDepositRequest): Promise; /** * Estimate fees and expected assets for a cross-chain redeem. The returned * quote carries `quotedAt`/`expiresAt`; re-quote via {@link isQuoteStale} * before submitting. */ export declare function quoteCrossChainRedeem(props: IQuoteCrossChainRedeemRequest): Promise; /** * Returns `true` when the wallet's ERC-20 allowance is insufficient for the * cross-chain operation. On RPC failure also returns `true` (defensive * default — better a redundant approval than a downstream revert). */ export declare function needsCrossChainApproval(tokenAddress: IAddress, spenderAddress: IAddress, walletAddress: IAddress, amount: bigint, publicClient: { readContract: (args: unknown) => Promise; }): Promise; /** * Execute a token approval for a cross-chain operation. * * @param chainId Chain the approval is sent on, used to gate ERC-8021 * attribution. Omitted means unattributed under a `chains` restriction — * the suffix would lengthen `approve` calldata past its ABI encoding and * break Ledger clear-signing. * @returns Transaction hash of the approval */ export declare function approveCrossChain(tokenAddress: IAddress, spenderAddress: IAddress, amount: bigint, walletClient: { account: { address: string; } | undefined; writeContract: (args: unknown) => Promise; }, publicClient: { waitForTransactionReceipt: (args: { hash: string; }) => Promise<{ status: string; }>; }, chainId?: number): Promise; /** * Execute a cross-chain deposit via LayerZero OVault. Validates the source * chain, ensures approval, estimates gas with a buffer, and waits for the * on-chain receipt. Defaults: `slippageBps` 100, `feeBufferPercent` 50, * `gasBufferPercent` 150 — all overridable on the request. * * @throws Error on unsupported chain, approval revert, gas-estimation * failure, or on-chain revert. */ export declare function crossChainVaultDeposit(props: ICrossChainDepositRequest): Promise; /** * Execute a cross-chain redemption via LayerZero OVault. User must be on the * hub chain. Defaults: `slippageBps` 100, `feeBufferPercent` 50, * `gasBufferPercent` 200 (compose calls under-estimate on mainnet), * `minGasLimit` 5_000_000n — all overridable on the request. */ export declare function crossChainVaultRedeem(props: ICrossChainRedeemRequest): Promise; /** * Check if an error indicates a missing LayerZero peer configuration. */ export declare function isNoPeerError(errStr: string): boolean; /** * Classify a cross-chain contract error into a known error type. */ export declare function classifyCrossChainError(error: unknown): CrossChainErrorType; /** * Check if a user can deposit from their current chain. */ export declare function canDepositFromChain(config: ICrossChainVaultConfig, userChainId: number): boolean; /** * Check if a user can redeem from their current chain (must be hub). */ export declare function canRedeemFromChain(config: ICrossChainVaultConfig, userChainId: number): boolean; /** * Check if an operation is cross-chain (needs LayerZero). * * An operation is cross-chain when: * - The user's chain differs from the hub chain, OR * - The destination chain differs from the hub chain * (e.g. deposit from hub but receive shares on a spoke) */ export declare function isCrossChainOperation(config: ICrossChainVaultConfig, userChainId: number, destinationChainId?: number): boolean; /** * Get all chain IDs that a vault supports (hub + all spokes). */ export declare function getAvailableChains(config: ICrossChainVaultConfig): number[]; /** * Format a cross-chain error into a user-friendly message. * * Mirrors the `classifyCrossChainDepositError` from upshift-app but is * generic enough for any SDK consumer. */ export declare function formatCrossChainError(errMsg: string): string; /** * Get the LayerZero Scan URL for tracking a cross-chain message. */ export declare function getLayerZeroScanUrl(txHash: string, testnet?: boolean): string; /** * Well-known LayerZero Endpoint IDs for common chains. * SDK consumers can use these when building their ICrossChainVaultConfig. */ export declare const LAYERZERO_ENDPOINT_IDS: { readonly ETHEREUM: 30101; readonly ARBITRUM: 30110; readonly AVALANCHE: 30106; readonly BASE: 30184; readonly SONIC: 30332; readonly MONAD: 30390; };