import Big from 'big.js'; import { Maybe } from '@avalabs/core-utils-sdk'; import { TransactionResponse, Block, Provider, JsonRpcProvider, JsonRpcApiProvider, TransactionRequest } from 'ethers'; import { VsCurrencyType } from '@avalabs/core-coingecko-sdk'; import { Psbt } from 'bitcoinjs-lib'; import * as _avalabs_core_wallets_sdk from '@avalabs/core-wallets-sdk'; import { BitcoinInputUTXO, BitcoinOutputUTXO, BitcoinInputUTXOWithOptionalScript, BitcoinProvider } from '@avalabs/core-wallets-sdk'; import { BridgeConfig as BridgeConfig$1 } from 'types'; declare enum Blockchain { AVALANCHE = "avalanche", ETHEREUM = "ethereum", BITCOIN = "bitcoin", UNKNOWN = "" } declare enum NetworkType { MAINNET = "mainnet", TESTNET = "testnet" } declare enum Environment { DEV = "development", STAGING = "staging", TEST = "test", PROD = "prod" } interface RuntimeConfig { environment: Environment; bridgeUrl: string; tokenInfoUrl: string; configMismatchThreshold: number; wardenConfigURLs: string[]; avalancheNetworkConfig: AddEthereumChainParameter; ethereumNetworkConfig: { chainId: number; rpcUrls: string[]; }; disabledTokensOnNetwork: Partial>; } interface EthereumCriticalConfigBase extends CriticalConfigBase { networks: Partial>; walletAddresses: Partial>; addressBlocklist: string[]; } interface EthereumStaticFeeCriticalConfig extends EthereumCriticalConfigBase { assets: EthereumStaticFeeConfigAssets; useNewFeeStructure?: false; } interface EthereumDynamicFeeCriticalConfig extends EthereumCriticalConfigBase { assets: EthereumDynamicFeeConfigAssets; useNewFeeStructure: true; } interface EthereumNonCriticalConfigBase { minimumConfirmations: Partial>; currentEthPrice: string; currentAvaxPrice: string; currentGasPrices: Record; /** Timestamp */ updated: string; useChainlinkAssetPriceFeeds?: boolean; chainlinkAvaxUsdFeedAddress?: string; chainlinkEthUsdFeedAddress?: string; chainlinkBtcUsdFeedAddress?: string; /** Timestamp */ startupTime: string; } interface EthereumStaticFeeNonCriticalConfig extends EthereumNonCriticalConfigBase { unwrapFeeApproximation: Record; wrapFeeApproximation: Record; } interface EthereumDynamicFeeNonCriticalConfig extends EthereumNonCriticalConfigBase { unwrapFeeApproximation: Record; wrapFeeApproximation: Record; } interface CriticalConfigBase { disableFrontend: boolean; operationMode: string; operatorEvmAddress?: string; operatorAddress: string; targetSecretVersion?: number; useEip1559TransactionFormat?: boolean; } interface BitcoinCriticalConfigBase extends CriticalConfigBase { addressBlocklist: string[]; avalancheChainId: number; useEip1559TransactionFormat: boolean; walletAddresses: { avalanche: string; btc: string; }; offboardDelaySeconds: number; } interface BitcoinStaticFeeCriticalConfig extends BitcoinCriticalConfigBase { bitcoinAssets: BitcoinStaticFeeConfigAssets; useNewFeeStructure?: false; } interface BitcoinDynamicFeeCriticalConfig extends BitcoinCriticalConfigBase { bitcoinAssets: BitcoinDynamicFeeConfigAssets; useNewFeeStructure: true; } interface BitcoinStaticBridgeFeeEstimate { wrapFeeAmount: number; constUnwrapFeeAmount: number; unwrapFeeNumerator: number; unwrapFeeDenominator: number; dustThreshold: number; } interface BitcoinDynamicBridgeFeeEstimate { dustThreshold: number; wrapFeeEstimate: DynamicFeeEstimation; unwrapFeeEstimate: { bridgeToll: DynamicFeeEstimation; estimatedTxFee: { constAmount: number; numeratorPerSat: number; denominatorPerSat: number; }; }; } interface BitcoinNetworkInfoBase { minimumConfirmations: number; minimumOnboardSize: number; currentPrice: string; currentFeeRate: { feeRate: number; source: string; }; currentUtxoStatistics: { [hash: string]: { mean: string; count: string; }; }; reserveBalance: number; networkView: { lastIndexedBlock: number; lastSeenBlock: number; nodeVersion: string; }; } interface BitcoinStaticFeeNetworkInfo extends BitcoinNetworkInfoBase { currentBridgeFeeEstimate: BitcoinStaticBridgeFeeEstimate; } interface BitcoinDynamicFeeNetworkInfo extends BitcoinNetworkInfoBase { currentBridgeFeeEstimate: BitcoinDynamicBridgeFeeEstimate; } interface BitcoinNonCriticalConfig { networkInfo: { btc: T; }; /** Timestamp */ updated: string; } interface BitcoinStaticFeeConfig { criticalBitcoin: BitcoinStaticFeeCriticalConfig; nonCriticalBitcoin: BitcoinNonCriticalConfig; } interface BitcoinDynamicFeeConfig { criticalBitcoin: BitcoinDynamicFeeCriticalConfig; nonCriticalBitcoin: BitcoinNonCriticalConfig; } interface EthereumStaticFeeConfig { critical: EthereumStaticFeeCriticalConfig; nonCritical: EthereumStaticFeeNonCriticalConfig; } interface EthereumDynamicFeeConfig { critical: EthereumDynamicFeeCriticalConfig; nonCritical: EthereumDynamicFeeNonCriticalConfig; } interface AppConfigBase { startupTime: string; version: string; } interface AppConfigWithDynamicFeesForEthereum extends AppConfigBase, EthereumDynamicFeeConfig, BitcoinStaticFeeConfig { } interface AppConfigWithDynamicFeesForBitcoin extends AppConfigBase, EthereumStaticFeeConfig, BitcoinDynamicFeeConfig { } type AppConfigWithStaticFeesForEthereum = AppConfigWithFullStaticFees | AppConfigWithDynamicFeesForBitcoin; type AppConfigWithStaticFeesForBitcoin = AppConfigWithFullStaticFees | AppConfigWithDynamicFeesForEthereum; interface AppConfigWithFullDynamicFees extends AppConfigBase, EthereumDynamicFeeConfig, BitcoinDynamicFeeConfig { } interface AppConfigWithFullStaticFees extends AppConfigBase, EthereumStaticFeeConfig, BitcoinStaticFeeConfig { } type AppConfig = AppConfigWithFullStaticFees | AppConfigWithFullDynamicFees | AppConfigWithDynamicFeesForEthereum | AppConfigWithDynamicFeesForBitcoin; type CriticalConfig = Pick; type NonCriticalConfig = Pick; type BridgeConfig = { config?: AppConfig; error?: any; }; declare enum AssetType { NATIVE = 0, ERC20 = 1, BTC = 2 } interface Assets { [symbol: string]: Asset; } type EthereumStaticFeeConfigAssets = Record; type EthereumDynamicFeeConfigAssets = Record; type EthereumConfigAssets = EthereumStaticFeeConfigAssets | EthereumDynamicFeeConfigAssets; interface BitcoinStaticFeeConfigAsset extends BitcoinConfigAsset { offboardFeeDollars: number; onboardFeeDollars: number; } interface BitcoinDynamicFeeConfigAsset extends BitcoinConfigAsset { offboardFeeConfiguration: DynamicFeeConfiguration; onboardFeeConfiguration: DynamicFeeConfiguration; } type BitcoinStaticFeeConfigAssets = Record; type BitcoinDynamicFeeConfigAssets = Record; type BitcoinConfigAssets = BitcoinStaticFeeConfigAssets | BitcoinDynamicFeeConfigAssets; /** * Bridge assets can fall into one of these categories */ type Asset = EthereumConfigAsset | NativeAsset | BitcoinConfigAsset; /** * Must exist on every asset. * This data is added to the raw config when it is fetched. */ interface AssetBase { symbol: string; tokenName: string; assetType: AssetType; nativeNetwork: Blockchain; denomination: number; } type DynamicFeeConfiguration = { feePercentage: number; feePercentageDecimals: number; maximumFeeDollars: number; minimumFeeDollars: number; }; type DynamicFeeEstimation = { minimumFeeAmount: string; maximumFeeAmount: string; feePercentage: number; feePercentageDecimals: number; }; interface EthereumAssetConfigBase extends AssetBase { avaxPromotionDollarThreshold: number; avaxPromotionAmount: string; chainlinkFeedAddress?: string; chainlinkFeedNetwork?: string; ipfsHash?: string; transferGasLimit?: number; nativeContractAddress: string; wrappedContractAddress: string; wrappedNetwork: string; deprecatedTokenContractAddress?: string; offboardFeeProcessThreshold: string; } interface EthereumStaticFeeAssetConfig extends EthereumAssetConfigBase { maximumOnboardFee?: string; onboardFeeDollars?: number; offboardFeeDollars: number; onboardFeePercentage?: string; } interface EthereumDynamicFeeAssetConfig extends EthereumAssetConfigBase { offboardFeeConfiguration: DynamicFeeConfiguration; onboardFeeConfiguration: DynamicFeeConfiguration; } /** * For Ethereum <-> Avalanche assets */ type EthereumConfigAsset = EthereumStaticFeeAssetConfig | EthereumDynamicFeeAssetConfig; /** * For Bitcoin <-> Avalanche assets */ interface BitcoinConfigAsset extends AssetBase { additionalTxFeeAmount: number; avaxPromotionAmount: string; avaxPromotionDollarThreshold: number; bech32AddressPrefix: string; operatorAddress: string; privateKeyPrefix: string; reserveBalanceHighWaterMark: number; reserveBalanceLowWaterMark: number; targetChangeAmount: number; wrappedContractAddress: string; wrappedNetwork: string; } /** * Currently used only for native Ethereum since it is not provided in the bridge config. */ interface NativeAsset extends AssetBase { assetType: AssetType.NATIVE; wrappedAssetSymbol: string; coingeckoId: string; } interface AddEthereumChainParameter { chainId: string; chainName: string; nativeCurrency: { name: string; symbol: string; decimals: number; }; rpcUrls: string[]; blockExplorerUrls?: string[]; iconUrls?: string[]; } interface TokenInfo { logo: string; coingeckoId: string; } type TokenInfoData = Record; interface TransactionDetails { tokenSymbol: string; amount: Big; } type EthChains = Blockchain.ETHEREUM | Blockchain.AVALANCHE; interface BridgeTransaction { /** C-chain address */ addressC: string; /** C-chain derived BTC address */ addressBTC: string; /** The amount requested by the user to transfer */ amount: Big; /** Token being transferred */ symbol: string; /** * The transaction was successfully created on the target blockchain and * bridging is finished. */ complete: boolean; completedAt?: number; /** Set when there is an error with transaction tracking */ error?: any; /** The network environment */ environment: 'main' | 'test'; sourceChain: Blockchain; /** When tracking the source confirmations started */ sourceStartedAt: number; sourceTxHash: string; sourceNetworkFee?: Big; confirmationCount: number; requiredConfirmationCount: number; targetChain: Blockchain; /** When tracking the target transaction started */ targetStartedAt?: number; targetTxHash?: string; /** * The fee paid to the bridge operators * (paid from the transferred asset e.g. LINK or WETH) */ targetBridgeFee?: Big; /** * The fee paid to the blockchain * (paid in the native token e.g. ETH or AVAX) */ targetNetworkFee?: Big; /** Block number used to find the target transaction hash */ startBlockNumber?: number; } type TxHash = string; declare enum WrapStatus { INITIAL = 0, WAITING_FOR_DEPOSIT_CONFIRMATION = 1, WAITING_FOR_DEPOSIT = 2, WAITING_FOR_CONFIRMATION = 3, COMPLETE = 4, VULNERABLE_ADDRESS = 5 } type EthereumAssets = Record; type AvalancheAssets = Record; interface BridgeSDKState { ethereumAssets: EthereumAssets; ethereumWrappedAssets: EthereumConfigAssets; avalancheAssets: AvalancheAssets; sourceAssets: Assets; bitcoinAssets: BitcoinConfigAssets; bridgeConfig: BridgeConfig; setBridgeConfig: (bridgeConfig: BridgeConfig) => void; criticalConfig?: CriticalConfig; currentBlockchain: Blockchain; setCurrentBlockchain: (blockchain: Blockchain) => void; targetBlockchain: Blockchain; currentAsset?: string; currentAssetData?: Asset; setCurrentAsset: (symbol: string) => void; transactionDetails?: TransactionDetails; setTransactionDetails: (transactionDetails: TransactionDetails) => void; targetChains: Blockchain[]; } declare function useBridgeSDK(): BridgeSDKState; declare function BridgeSDKProvider({ children }: { children: JSX.Element; }): JSX.Element; declare const initalState: {}; declare const TokenInfoProvider: ({ children }: { children: any; }) => JSX.Element; declare function useTokenInfoContext(): TokenInfoData | undefined; /** * Get the bridge config from the bridge context. Use * useBridgeConfigUpdater() to ensure that the bridge config is * periodically re-fetch. * * @example * const { config, error } = useBridgeConfig(); */ declare function useBridgeConfig(): BridgeConfig; /** * Use to periodically re-fetch the bridge config. This is needed in case any of * the wardens returns disableFrontend === true which should shutdown the * frontend immediately. * * @param fetchFn use fetchConfig() by default, this param is provided so it can * be customized in the extension. * * @example * useBridgeConfigUpdater(() => fetchConfig("main")); */ declare function useBridgeConfigUpdater(fetchFn: () => Promise): void; declare function isBech32Address(btcAddress: string): boolean; /** * In addition to Bech32 validation, it makes sure that the address is from the correct network. */ declare function isBech32AddressInNetwork(btcAddress: string, isMainnet: boolean): boolean; /** * Verify if its a valid base 58 encoded address */ declare function isBase58Address(addr: string): boolean; /** * Verify if address is valid base58 and matches the network * @param addr P2PKH or P2SH address to verify * @param isMainnet If true will verify it's a valid mainnet address */ declare function isBase58AddressInNetwork(addr: string, isMainnet: boolean): boolean; type BtcBlockchains = Blockchain.AVALANCHE | Blockchain.BITCOIN; /** * Return the estimated bridge fee that will be paid to the bridge operators. */ declare function getBridgeFeeEstimateBTC({ source, config, amount, }: { source: BtcBlockchains; config: AppConfig; amount: Big; }): Big; /** * Legacy (static) fee estimation for BTC */ declare function getStaticBridgeFeeEstimateBTC(source: BtcBlockchains, config: AppConfigWithStaticFeesForBitcoin, amountInSatoshis: number): Big; /** * Get the BTC native asset on the bitcoin network. */ declare function getBtcAsset(config: CriticalConfig): BitcoinConfigAsset | undefined; /** * Bitcoin to Avalanche * @param changeAddress: The user's C-chain derived BTC address. Change UTXO will be sent to this address. * @param config: Configuration file for the bridge. * @param utxos: The available UTXOs to consume. * @param amount: The amount to wrap in satoshis. Must cover the `bridgeFee`. * @param feeRate: Fee rate given in satoshis per byte. * @throws when the transaction cannot be created */ declare function getBtcTransaction(config: AppConfig, changeAddress: string, utxos: BitcoinInputUTXO[], amount: number, feeRate: number): { /** The total fee (bridge fee + tx fee) */ fee: number; tx: Psbt; bridgeFee: number; receiveAmount: number; inputs: BitcoinInputUTXO[]; outputs: BitcoinOutputUTXO[]; }; /** * Bitcoin to Avalanche * @param config: Configuration file for the bridge. * @param changeAddress: The user's C-chain derived BTC address. Change UTXO will be sent to this address. * @param utxos: The available UTXOs to consume. * @param amount: The amount to wrap in satoshis. Must cover the `bridgeFee`. * @param feeRate: Fee rate given in satoshis per byte. * @throws when the transaction is invalid */ declare function getBtcTransactionDetails(config: AppConfig, changeAddress: string, utxos: BitcoinInputUTXOWithOptionalScript[], amount: number, feeRate: number): { /** The total fee (bridge fee + tx fee) */ fee: number; bridgeFee: number; receiveAmount: number; inputs: BitcoinInputUTXOWithOptionalScript[]; outputs: BitcoinOutputUTXO[]; }; /** * Returns the minimum amount (in satoshis) can be sent to the bridge. * @param source * @param config * @param amount */ declare function getMinimumTransferAmount(source: BtcBlockchains, config: AppConfig, amount: number): number; declare function getTxDetails(txHash: string, provider: BitcoinProvider): Promise<_avalabs_core_wallets_sdk.BitcoinTx>; /** * Get the number of confirmations for a given transaction hash. * @param txHash * @param config */ declare function getTxConfirmations(txHash: string, provider: BitcoinProvider): Promise; declare function btcToSatoshi(btc: Big): number; declare function satoshiToBtc(satoshis: number): Big; type Args = { source: EthChains; config: AppConfig; asset: EthereumConfigAsset; amount: Big; }; /** * Get Ethereum <-> Avalanche bridge fee estimate. */ declare function getBridgeFeeEstimateEVM({ source, config, asset, amount, }: Args): Big; /** * Legacy (static) fee estimation for Ethereum */ declare function getStaticBridgeFeeEstimateEVM(source: EthChains, config: AppConfigWithStaticFeesForEthereum, asset: EthereumConfigAsset): Big; interface HistoryTxData { transaction?: TransactionResponse; block?: Block | null; error?: string; } /** * EVM specific function to search for a new bridge transaction. */ declare function checkHistoryForNewTxEVM(network: Blockchain, provider: Provider, config: Maybe, account: Maybe, asset: Maybe, startBlockNumber: Maybe): Promise; /** * Get the config for working with either mainnet or testnet blockchains. */ declare function fetchConfig(env?: Environment): Promise; /** * Fetch token balances for EVM */ declare function fetchTokenBalances(tokens: Record, blockchain: Blockchain, provider: Provider, account: string, deprecated?: boolean): Promise>; /** * Return the assets available for the given chain * @param blockchain The blockchain to get asset dict for * @param config The config of the bridge */ declare function getAssets(blockchain: Blockchain.AVALANCHE, config: CriticalConfig): AvalancheAssets; declare function getAssets(blockchain: Blockchain.BITCOIN, config: CriticalConfig): BitcoinConfigAssets; declare function getAssets(blockchain: Blockchain.ETHEREUM, config: CriticalConfig): EthereumAssets; declare function getAssets(blockchain: Blockchain, config: CriticalConfig): Assets; type GetMaxTransferAmountParams = { currentBlockchain: Blockchain; currentAsset: string; balance: Big; assets: EthereumAssets | AvalancheAssets; provider: JsonRpcProvider; config: AppConfig; }; declare function getMaxTransferAmount({ currentBlockchain, balance, currentAsset, assets, provider, config, }: GetMaxTransferAmountParams): Promise; interface TrackerArgs { bridgeTransaction: BridgeTransaction; onBridgeTransactionUpdate: (bridgeTransaction: BridgeTransaction) => void; config: AppConfig; avalancheProvider: Provider; ethereumProvider: Provider; bitcoinProvider: BitcoinProvider; } interface TrackerSubscription { /** Cancel tracking */ unsubscribe(): void; /** A flag to indicate whether this has already been unsubscribed */ readonly closed: boolean; } /** * Track a bridge transaction to completion. * * The process consists of two steps: * - Ensure that the source blockchain has reached the required number of * confirmations. * - Watch for the new transaction to be created on the target blockchain. * * During the process `onBridgeTransactionUpdate` will be called when the state * of the `bridgeTransaction` changes e.g. `confirmationCount` * * When the two steps finish `onBridgeTransactionUpdate` will be called a final * time with `complete` set to true. * * @returns a subscription object that can be used to unsubscribe * (e.g. when used in a `useEffect` hook) */ declare function trackBridgeTransaction(args: TrackerArgs): TrackerSubscription; type TransferAssetEVMParams = { currentBlockchain: Blockchain.AVALANCHE | Blockchain.ETHEREUM; amount: Big; account: string; asset: Asset; avalancheProvider: JsonRpcApiProvider; ethereumProvider: JsonRpcApiProvider; config: AppConfig; onStatusChange: (status: WrapStatus) => void; onTxHashChange: (txHash: string) => void; signAndSendEVM?: (txData: TransactionRequest) => Promise; }; /** * Transfer an ERC20 asset. * When currentBlockchain is Avalanche the asset will be transferred to * Ethereum and vice versa. * * @param signAndSendEVM Required when the provider for the currentBlockchain * does not support signing transactions. */ declare function transferAssetEVM({ currentBlockchain, amount, account, asset, avalancheProvider, ethereumProvider, config, onStatusChange, onTxHashChange, signAndSendEVM, }: TransferAssetEVMParams): Promise; type BtcTransactionRequest = [ toAddress: string, amount: string, feeRate: number ]; type TransferAssetBTCParams = { amount: string; feeRate: number; config: AppConfig; onStatusChange: (status: WrapStatus) => void; onTxHashChange: (txHash: string) => void; signAndSendBTC: (txParams: BtcTransactionRequest) => Promise; }; declare const transferAssetBTC: ({ amount, feeRate, config, onStatusChange, onTxHashChange, signAndSendBTC, }: TransferAssetBTCParams) => Promise; /** * Transfer from Avalanche to Ethereum or Bitcoin. */ declare function unwrapAsset(amount: Big, account: string, asset: EthereumConfigAsset | BitcoinConfigAsset, provider: JsonRpcApiProvider, onTxHashChange: (txHash: string) => void, signAndSendEVM?: (txData: TransactionRequest) => Promise): Promise; /** * Transfer from Ethereum to Avalanche. * * @param wrappedAsset - must be provided when asset is of AssetType.NATIVE * @param signAndSendEVM - Optional, provide when NOT using Metamask. Some * providers like `InfuraProvider` don't support `getSigner` so * `signAndSendEVM` is used to manually sign and send the transaction instead of calling * `contract.transfer`. */ declare function wrapAsset(amount: Big, account: string, asset: EthereumConfigAsset | NativeAsset, avalancheProvider: JsonRpcApiProvider, ethereumProvider: JsonRpcApiProvider, config: AppConfig, onStatusChange: (status: WrapStatus) => void, onTxHashChange: (txHash: string) => void, signAndSendEVM?: (txData: TransactionRequest) => Promise): Promise; declare function useCheckHistoryForNewTxEVM(network: Blockchain, provider: Provider, account: Maybe, asset: Maybe): { checkHistoryForNewTx: () => Promise; startBlockNumber: number | undefined; }; declare function useGetAirdropAmount(sourceNetwork: Blockchain, assetPrice: Big, transactionDetails: Maybe, assetInfo: Maybe): () => number; /** * Fetch the account balance for the token on Ethereum or Avalanche. * @param blockchain network to get the balances on * @param asset the contract token (skips fetch when not defined) * @param deprecated query the deprecated token balance instead of the regular */ declare function useGetTokenBalanceEVM(blockchain: Blockchain.AVALANCHE | Blockchain.ETHEREUM, asset: Maybe, provider: Provider, active: boolean, account: Maybe, deprecated?: boolean): Big | undefined; /** * Fetch the account balances for the tokens. * @param blockchain network to get the balances on * @param tokens the list of contract tokens * @param deprected query the deprecated token balance instead of the regular */ declare function useGetTokenBalancesEVM(blockchain: Blockchain, tokens: Maybe>, provider: Provider, active: boolean, account: Maybe, deprecated?: boolean): { [key: string]: Big; } | undefined; declare function useGetTokenSymbolOnNetwork(): { getTokenSymbolOnNetwork: (symbol: string, network: Blockchain) => string; }; declare function useHasEnoughForGas(account: Maybe, provider: Maybe): boolean; declare function useIsAddressSanctioned(address: string): boolean; /** * Calculates the approximate maximum abount transfarable for a given asset. * For ERC20s it's always the user's max balance * For native assets, since gas price is payed with the native asset, * it's balance minus approximate transaction fees */ declare function useMaxTransferAmount(balance: Maybe, account: Maybe, provider: Maybe): Big | null; /** * Returns the price of the input currency (default is USD) * @param assetId id of the asset on coingecko, not matches the symbol * @param currency currency you want the result to be in, default is 'usd' */ declare function usePrice(assetId: string | undefined, currency?: VsCurrencyType): Big; declare function usePriceForChain(chain: Blockchain | undefined): Big; declare function useResetTransactionDetailsFromParams(avalancheProvider: Provider, ethereumProvider: Provider, setTransactionDetails: (details: TransactionDetails) => void, assets: Maybe): (txHash: string, network: Blockchain) => Promise; declare function useSubscribeForNewTransactionFromBridgeEVM(network: Blockchain, avalancheProvider: Provider, ethereumProvider: Provider, config: Maybe, asset: Maybe, account: Maybe): TransactionResponse | undefined; declare function useTimer(): { isActive: boolean; seconds: number; start: () => void; stop: () => void; setTimerSeconds: (startTimestamp: number, endTimestamp?: number) => void; started: number; }; /** * Get the bridge fee depending on the selected chain and asset * @param amount */ declare function useBridgeFeeEstimate(amount: Big): Big | undefined; /** * Transfer an ERC20 asset. * When currentBlockchain is Avalanche the asset will be transferred to * Ethereum and vice versa. * * @param signAndSendEVM Required when the provider for the currentBlockchain * @param avalancheProvider This can accept either a JsonRpcProvider or BrowserProvider. If a signAndSendEVM param is provided, then this can be a JsonRpcProvider (i.e. a provider without signing capabilities), otherwise this should be a BrowserProvider, or other provider with signing capabilities (via the provider.getSigner method) * @param ethereumProvider Same comment as avalancheProvider^ * does not support signing transactions. */ declare function useTransferAssetEVM(asset: Maybe, account: Maybe, avalancheProvider: JsonRpcApiProvider, ethereumProvider: JsonRpcApiProvider, signAndSendEVM?: (txData: TransactionRequest) => Promise): { transferAsset: (amount: Big) => Promise | undefined; status: WrapStatus; txHash: string; }; /** * Transfer Bitcoin asset to Avalanche. */ declare function useTransferAssetBTC(signAndSendBTC: (txParams: BtcTransactionRequest) => Promise): { transferAsset: (amount: string, feeRate: number) => Promise | undefined; status: WrapStatus; txHash: string; }; interface TrackerViewProps { sourceNetwork: Blockchain; sourceSeconds: number; sourceTxHash?: string; targetNetwork: Blockchain; targetSeconds: number; targetTxHash?: string; confirmationCount: number; requiredConfirmationCount: number; complete: boolean; gasCost?: Big; gasValue?: Big; amount?: Big; symbol?: string; } /** * @deprecated this hook is buggy, prefer trackBridgeTransaction instead. * * Track an EVM transaction * @param started Start timestamp of the source transaction. * @param isHidden Is the screen hidden e.g. document.hidden */ declare function useTxTracker(sourceNetwork: Blockchain, txId: string, started: string, avalancheProvider: Provider, ethereumProvider: Provider, setTransactionDetails: (details: TransactionDetails) => void, config: Maybe, account: Maybe, transactionDetails: Maybe, ethWrappedAssets: Maybe, isHidden?: boolean): TrackerViewProps; declare function useWaitForConfirmations(requiredConfirmationCount: number, provider: Provider, txHash: Maybe): { confirmations: number; gasCost: Big | undefined; }; /** * Get the bridge fee depending on the selected chain and asset * @param amount */ declare function useMinimumTransferAmount(amount: Big): Big; declare const ETHERSCAN_API_KEY: string | undefined; declare const INFURA_API_KEY: string | undefined; /** * Set the bridge runtime environment. */ declare function setBridgeEnvironment(environment: Environment): void; /** * Get the runtime config for the current environment. * @throws when the environment has not already been initialized by calling * `setBridgeEnvironment(env)` * @param env optional, provide to get the config for the given Environment. */ declare function getRuntimeConfig(env?: Environment): RuntimeConfig; declare const BIG_TEN: Big; declare const BIG_ZERO: Big; declare const capped: (value: Big, { max, min }: { max: Big; min: Big; }) => Big; declare function isMainnetConfig(config: AppConfig): boolean; /** * @returns the number of required confirmations before the bridge will initiate a transfer. */ declare function getMinimumConfirmations(blockchain: Blockchain, config: AppConfig): number; /** * Compares critical sections of the bridge config. */ declare function hasCriticalChanges(oldConfig: BridgeConfig, newConfig: BridgeConfig): boolean; declare function isEthUsingDynamicFees(config: AppConfig): config is AppConfigWithDynamicFeesForEthereum | AppConfigWithFullDynamicFees; declare function isBtcUsingDynamicFees(config: AppConfig): config is AppConfigWithDynamicFeesForBitcoin | AppConfigWithFullDynamicFees; declare function formatTokenAmount(amount: Big, denomination?: number): string; declare function getNativeSymbol(chain: Blockchain): string; declare const usdFormatter: Intl.NumberFormat; declare const isAddressBlocklisted: ({ addressEVM, addressBTC, bridgeConfig, }: { addressEVM?: string | undefined; addressBTC?: string | undefined; bridgeConfig: BridgeConfig$1; }) => boolean; declare const isNativeAsset: (asset: Asset) => asset is NativeAsset; declare const isBtcAsset: (asset: Asset) => asset is BitcoinConfigAsset; declare const isEthAsset: (asset: Asset) => asset is EthereumConfigAsset; declare const AVERAGE_TRANSFER_TX_GAS_USAGE = 40000n; /** * NOTE: These estimates are only supposed to be used to approximate * the network fees in the UI. * * DO NOT use them as `gasLimit` prop on the transactions! */ declare function estimateGas(amount: Big, account: string, asset: Asset, providers: { ethereum: JsonRpcApiProvider; avalanche: JsonRpcApiProvider; }, config: AppConfig, sourceBlockchain: Blockchain, withSigner?: boolean): Promise; export { AVERAGE_TRANSFER_TX_GAS_USAGE, AddEthereumChainParameter, AppConfig, AppConfigWithDynamicFeesForBitcoin, AppConfigWithDynamicFeesForEthereum, AppConfigWithFullDynamicFees, AppConfigWithFullStaticFees, AppConfigWithStaticFeesForBitcoin, AppConfigWithStaticFeesForEthereum, Asset, AssetBase, AssetType, Assets, AvalancheAssets, BIG_TEN, BIG_ZERO, BitcoinConfigAsset, BitcoinConfigAssets, BitcoinDynamicFeeConfig, BitcoinDynamicFeeConfigAsset, BitcoinDynamicFeeConfigAssets, BitcoinDynamicFeeCriticalConfig, BitcoinStaticFeeConfig, BitcoinStaticFeeConfigAsset, BitcoinStaticFeeConfigAssets, BitcoinStaticFeeCriticalConfig, Blockchain, BridgeConfig, BridgeSDKProvider, BridgeSDKState, BridgeTransaction, BtcBlockchains, BtcTransactionRequest, CriticalConfig, DynamicFeeEstimation, ETHERSCAN_API_KEY, Environment, EthChains, EthereumAssetConfigBase, EthereumAssets, EthereumConfigAsset, EthereumConfigAssets, EthereumDynamicFeeAssetConfig, EthereumDynamicFeeConfig, EthereumDynamicFeeConfigAssets, EthereumStaticFeeAssetConfig, EthereumStaticFeeConfig, EthereumStaticFeeConfigAssets, HistoryTxData, INFURA_API_KEY, NativeAsset, NetworkType, NonCriticalConfig, RuntimeConfig, TokenInfo, TokenInfoData, TokenInfoProvider, TrackerSubscription, TrackerViewProps, TransactionDetails, TransferAssetBTCParams, TransferAssetEVMParams, TxHash, WrapStatus, btcToSatoshi, capped, checkHistoryForNewTxEVM, estimateGas, fetchConfig, fetchTokenBalances, formatTokenAmount, getAssets, getBridgeFeeEstimateBTC, getBridgeFeeEstimateEVM, getBtcAsset, getBtcTransaction, getBtcTransactionDetails, getMaxTransferAmount, getMinimumConfirmations, getMinimumTransferAmount, getNativeSymbol, getRuntimeConfig, getStaticBridgeFeeEstimateBTC, getStaticBridgeFeeEstimateEVM, getTxConfirmations, getTxDetails, hasCriticalChanges, initalState, isAddressBlocklisted, isBase58Address, isBase58AddressInNetwork, isBech32Address, isBech32AddressInNetwork, isBtcAsset, isBtcUsingDynamicFees, isEthAsset, isEthUsingDynamicFees, isMainnetConfig, isNativeAsset, satoshiToBtc, setBridgeEnvironment, trackBridgeTransaction, transferAssetBTC, transferAssetEVM, unwrapAsset, usdFormatter, useBridgeConfig, useBridgeConfigUpdater, useBridgeFeeEstimate, useBridgeSDK, useCheckHistoryForNewTxEVM, useGetAirdropAmount, useGetTokenBalanceEVM, useGetTokenBalancesEVM, useGetTokenSymbolOnNetwork, useHasEnoughForGas, useIsAddressSanctioned, useMaxTransferAmount, useMinimumTransferAmount, usePrice, usePriceForChain, useResetTransactionDetailsFromParams, useSubscribeForNewTransactionFromBridgeEVM, useTimer, useTokenInfoContext, useTransferAssetBTC, useTransferAssetEVM, useTxTracker, useWaitForConfirmations, wrapAsset };