UNPKG

@molecularlabs/nucleus-frontend

Version:
79 lines (75 loc) 3.56 kB
import { Address } from 'viem'; import { ChainId } from '../api/vault-config.js'; import { CrossChainTellerBaseAbi } from '../contracts/cross-chain-teller-base-abi.js'; import { VaultKey } from './config.js'; import 'viem/chains'; /** * @file Bridge functionality for cross-chain operations * @module vaults/bridge */ /** * Arguments required by the bridge contract for cross-chain transfers * @interface BridgeContractArg * @property {number} chainSelector - Unique identifier for the destination chain * @property {Address} destinationChainReceiver - Address that will receive the bridged tokens * @property {Address} bridgeFeeToken - Token used to pay the bridge fee * @property {bigint} messageGas - Amount of gas allocated for the cross-chain message * @property {`0x${string}`} data - Additional data required for the bridge operation (hex encoded) */ interface BridgeContractArg { chainSelector: number; destinationChainReceiver: Address; bridgeFeeToken: Address; messageGas: bigint; data: `0x${string}`; } /** * Parameters for preparing bridge contract arguments * @interface PrepareBridgeContractArgParams * @property {number} bridgeChainIdentifier - Chain identifier for the bridge protocol * @property {Address} userAddress - Ethereum address of the user initiating the bridge * @property {Address} [nativeTokenForBridgeFee] - Optional address of the native token used for bridge fees */ interface PrepareBridgeContractArgParams { bridgeChainIdentifier: number; userAddress: Address; nativeTokenForBridgeFee?: Address; } declare const prepareBridgeContractArg: ({ bridgeChainIdentifier, userAddress, nativeTokenForBridgeFee, }: PrepareBridgeContractArgParams) => BridgeContractArg; /** * Parameters for preparing a cross-chain bridge transaction * @interface PrepareBridgeTransactionParams * @property {VaultKey} vaultKey - Unique identifier for the vault * @property {bigint} bridgeAmount - Amount of shares to bridge (in base units) * @property {ChainId} sourceChainId - Chain ID where shares currently exist * @property {ChainId} destinationChainId - Chain ID where shares will be bridged to * @property {Address} userAddress - Ethereum address of the user initiating the bridge */ interface PrepareBridgeTransactionParams { vaultKey: VaultKey; bridgeAmount: bigint; sourceChainId: ChainId; destinationChainId: ChainId; userAddress: Address; } /** * Transaction data for executing a cross-chain bridge operation * @interface BridgeTransactionData * @property {typeof CrossChainTellerBaseAbi} abi - ABI for the CrossChainTeller contract * @property {Address} address - Address of the CrossChainTeller contract * @property {string} functionName - Name of the function to call on the contract * @property {[bigint, BridgeContractArg]} args - Arguments for the bridge function: * [amount, bridgeArgs] * @property {number} chainId - ID of the chain where the transaction should be executed * @property {bigint} value - Amount of native token to send with the transaction */ interface BridgeTransactionData { abi: typeof CrossChainTellerBaseAbi; address: Address; functionName: string; args: [bigint, BridgeContractArg]; chainId: number; value: bigint; } declare const prepareBridgeTransactionData: ({ vaultKey, bridgeAmount, sourceChainId, destinationChainId, userAddress, }: PrepareBridgeTransactionParams) => Promise<BridgeTransactionData>; export { type BridgeTransactionData, prepareBridgeContractArg, prepareBridgeTransactionData };