import { AMM } from './AMM.js'; import { Base, BaseConstructorOptions, ChainProviders } from './Base.js'; import { BigNumber, BigNumberish, Signer, ethers } from 'ethers'; import { ChainSlug } from './constants/index.js'; import { TAmount, TChain, TProvider, TTime, TTimeSlot, TToken } from './types.js'; import { Token } from './Token.js'; import { Chain } from '#chains/index.js'; import { PriceFeedApiKeys, PriceFeedFromS3 } from '#priceFeed/index.js'; export type HopBridgeConstructorOptions = { token: TToken; } & BaseConstructorOptions; type SendOptions = { deadline: BigNumberish; relayer: string; relayerFee: TAmount; recipient: string; amountOutMin: TAmount; bonderFee: TAmount; destinationAmountOutMin: TAmount; destinationDeadline: BigNumberish; checkAllowance?: boolean; isHTokenSend?: boolean; slippageTolerance?: number; }; type AddLiquidityOptions = { minToMint: TAmount; deadline: BigNumberish; }; type RemoveLiquidityOptions = { amount0Min: TAmount; amount1Min: TAmount; deadline: BigNumberish; }; type RemoveLiquidityOneTokenOptions = { amountMin: TAmount; deadline: BigNumberish; }; type RemoveLiquidityImbalanceOptions = { maxBurnAmount: TAmount; deadline: BigNumberish; }; type SendDataAmountOutMins = { amount: BigNumberish; amountOutMin: BigNumber; destinationAmountOutMin: BigNumber | null; deadline: number; destinationDeadline: number | null; }; type FeeAndAmountOutMinData = { totalFee: BigNumber; amountOutMin: BigNumber; destinationAmountOutMin: BigNumber | null; }; /** * Class representing Hop bridge. * @namespace HopBridge */ export declare class HopBridge extends Base { #private; private tokenSymbol; /** Source Chain model */ sourceChain: Chain; /** Destination Chain model */ destinationChain: Chain; /** Default deadline for transfers */ defaultDeadlineMinutes: number; priceFeed: PriceFeedFromS3; priceFeedApiKeys: PriceFeedApiKeys | null; doesUseAmm: boolean; defaultSlippageTolerance: number; /** * @desc Instantiates Hop Bridge. * Returns a new Hop Bridge instance. * @param networkOrOptionsObject - L1 network name (e.g. 'mainnet', 'goerli') * @param signer - Ethers `Signer` for signing transactions. * @param token - Token symbol or model * @returns HopBridge SDK instance. * @example *```js *import { HopBridge, Chain, Token } from '@hop-protocol/sdk' *import { Wallet } from 'ethers' * *const signer = new Wallet(privateKey) *const bridge = new HopBridge('mainnet', signer, Token.USDC, Chain.Optimism, Chain.Gnosis) *``` */ constructor(networkOrOptionsObject: string | HopBridgeConstructorOptions, signer?: TProvider, token?: TToken, chainProviders?: ChainProviders); /** * @desc Returns hop bridge instance with signer connected. Used for adding or changing signer. * @param signer - Ethers `Signer` for signing transactions. * @returns New HopBridge SDK instance with connected signer. * @example *```js *import { Hop, Token } from '@hop-protocol/sdk' *import { Wallet } from 'ethers' * *const signer = new Wallet(privateKey) *let hop = new Hop() * // ... *const bridge = hop.bridge(Token.USDC).connect(signer) *``` */ connect(signer: Signer): HopBridge; getL1Token(): any; getCanonicalToken(chain: TChain): any; getL2HopToken(chain: TChain): any; toCanonicalToken(token: TToken, network: string, chain: TChain): Token; toHopToken(token: TToken, network: string, chain: TChain): Token; /** * @desc Send tokens to another chain. * @param tokenAmount - Token amount to send denominated in smallest unit. * @param sourceChain - Source chain model. * @param destinationChain - Destination chain model. * @returns Ethers Transaction object. * @example *```js *import { Hop, Chain, Token } from '@hop-protocol/sdk' * *const hop = new Hop() *const bridge = hop.connect(signer).bridge(Token.USDC) *\// send 1 USDC token from Optimism -> Gnosis *const tx = await bridge.send('1000000000000000000', Chain.Optimism, Chain.Gnosis) *console.log(tx.hash) *``` */ send(tokenAmount: TAmount, sourceChain?: TChain, destinationChain?: TChain, options?: Partial): Promise; populateSendTx(tokenAmount: TAmount, sourceChain?: TChain, destinationChain?: TChain, options?: Partial): Promise; estimateSendGasLimit(tokenAmount: TAmount, sourceChain: TChain, destinationChain: TChain, options?: Partial): Promise; private getEstimatedGasLimit; getSendEstimatedGasCost(tokenAmount: TAmount, sourceChain: TChain, destinationChain: TChain, options?: Partial): Promise; getSendApprovalAddress(sourceChain: TChain, isHTokenSend?: boolean, destinationChain?: TChain): string; populateSendApprovalTx(tokenAmount: TAmount, sourceChain: TChain, isHTokenSend?: boolean, destinationChain?: TChain): Promise; sendApproval(tokenAmount: TAmount, sourceChain: TChain, destinationChain: TChain, isHTokenSend?: boolean): Promise; sendHToken(tokenAmount: TAmount, sourceChain: TChain, destinationChain: TChain, options?: Partial): Promise; estimateSendHTokensGasLimit(tokenAmount: TAmount, sourceChain: TChain, destinationChain: TChain, options?: Partial): Promise; populateSendHTokensTx(tokenAmount: TAmount, sourceChain: TChain, destinationChain: TChain, options?: Partial): Promise; commitTransfers(sourceChain: TChain, destinationChain: TChain): Promise; getTokenSymbol(): string; getTokenImage(): string; getTokenDecimals(): number; getTokenBalance(chain: TChain, address?: string): Promise; getShouldUseCctpBridge(options?: { isHTokenSend: boolean; }): boolean; getSendData(amountIn: BigNumberish, sourceChain: TChain, destinationChain: TChain, isHTokenSend?: boolean, slippageTolerance?: number): Promise; getSendDataAmountOutMins(getSendDataResponse: any, slippageTolerance: number): SendDataAmountOutMins; getFeeAndAmountOutMinData(amountIn: BigNumberish, sourceChain: TChain, destinationChain: TChain, slippageTolerance: number): Promise; getAmmData(chain: TChain, amountIn: BigNumberish, isToHToken: boolean, slippageTolerance: number): Promise; getTotalFee(amountIn: BigNumberish, sourceChain: TChain, destinationChain: TChain, isHTokenSend?: boolean): Promise; getLpFees(amountIn: BigNumberish, sourceChain: TChain, destinationChain: TChain): BigNumber; getDestinationTransactionFee(sourceChain: TChain, destinationChain: TChain, isHTokenSend?: boolean): Promise; getDestinationTransactionFeeData(sourceChain: TChain, destinationChain: TChain, isHTokenSend?: boolean): Promise; getOptimismL1Fee(sourceChain: TChain, destinationChain: TChain): Promise; willTransferFail(sourceChain: TChain, destinationChain: TChain, recipient: string): Promise; estimateBondWithdrawalGasLimit(sourceChain: TChain, destinationChain: TChain): Promise; populateBondWithdrawalTx(sourceChain: TChain, destinationChain: TChain, recipient?: string): Promise; /** * @desc Estimate token amount out. * @param tokenAmountIn - Token amount input. * @param sourceChain - Source chain model. * @param destinationChain - Destination chain model. * @returns Amount as BigNumber. * @example *```js *import { Hop, Chain } from '@hop-protocol/sdk' * *const hop = new Hop() *const bridge = hop.connect(signer).bridge('USDC') *const amountOut = await bridge.getAmountOut('1000000000000000000', Chain.Optimism, Chain.Gnosis) *console.log(amountOut) *``` */ getAmountOut(tokenAmountIn: TAmount, sourceChain?: TChain, destinationChain?: TChain): Promise; /** * @desc Estimate the bonder liquidity needed at the destination. * @param tokenAmountIn - Token amount input. * @param sourceChain - Source chain model. * @returns Amount as BigNumber. * @example *```js *import { Hop, Chain } from '@hop-protocol/sdk' * *const hop = new Hop() *const bridge = hop.connect(signer).bridge('USDC') *const requiredLiquidity = await bridge.getRequiredLiquidity('1000000000000000000', Chain.Optimism, Chain.Gnosis) *console.log(requiredLiquidity) *``` */ getRequiredLiquidity(tokenAmountIn: TAmount, sourceChain: TChain): Promise; getAvailableLiquidity(destinationChain: TChain, bonder: string): Promise; /** * @desc Returns available liquidity for Hop bridge at specified chain. * @param sourceChain - Source chain model. * @param destinationChain - Destination chain model. * @returns Available liquidity as BigNumber. */ getFrontendAvailableLiquidity(sourceChain: TChain, destinationChain: TChain, isHTokenSend?: boolean): Promise; private isOruToL1; getBonderAvailableLiquidityData(): Promise; getUnbondedTransferRootAmount(sourceChain: TChain, destinationChain: TChain): Promise; private getBaseAvailableCredit; private getPendingAmount; /** * @desc Returns bridge contract instance for specified chain. * @param chain - chain model. * @returns Ethers contract instance. */ getBridgeContract(chain: TChain): Promise; getCctpBridge(chain: TChain): Promise; /** * @desc Returns total credit that bonder holds on Hop bridge at specified chain. * @param sourceChain - Chain model. * @returns Total credit as BigNumber. */ getCredit(sourceChain: TChain, bonder: string): Promise; /** * @desc Returns total debit, including sliding window debit, that bonder holds on Hop bridge at specified chain. * @param sourceChain - Chain model. * @returns Total debit as BigNumber. */ getTotalDebit(sourceChain: TChain, bonder: string): Promise; /** * @desc Returns total debit that bonder holds on Hop bridge at specified chain. * @param sourceChain - Chain model. * @returns Total debit as BigNumber. */ getDebit(sourceChain: TChain, bonder: string): Promise; /** * @desc Sends transaction to execute swap on Saddle contract. * @param sourceChain - Source chain model. * @param toHop - Converts to Hop token only if set to true. * @param amount - Amount of token to swap. * @param minAmountOut - Minimum amount of tokens to receive in order * for transaction to be successful. * @param deadline - Transaction deadline in seconds. * @returns Ethers transaction object. */ execSaddleSwap(sourceChain: TChain, toHop: boolean, amount: TAmount, minAmountOut: TAmount, deadline: BigNumberish): Promise; /** * @desc Returns Hop L1 Bridge Ethers contract instance. * @param signer - Ethers signer * @returns Ethers contract instance. */ getL1Bridge(signer?: TProvider): Promise; getCctpL1Bridge(signer?: TProvider): Promise; /** * @desc Returns Hop L2 Bridge Ethers contract instance. * @param chain - Chain model. * @param signer - Ethers signer * @returns Ethers contract instance. */ getL2Bridge(chain: TChain, signer?: TProvider): Promise; getCctpL2Bridge(chain: TChain, signer?: TProvider): Promise; getAmm(chain: TChain): AMM; /** * @desc Returns Hop Bridge AMM wrapper Ethers contract instance. * @param chain - Chain model. * @param signer - Ethers signer * @returns Ethers contract instance. */ getAmmWrapper(chain: TChain, signer?: TProvider): Promise; /** * @desc Returns Hop Bridge Saddle reserve amounts. * @param chain - Chain model. * @returns Array containing reserve amounts for canonical token * and hTokens. */ getSaddleSwapReserves(chain?: TChain): Promise; getReservesTotal(chain?: TChain): Promise; getTvl(chain?: TChain): Promise; getTvlUsd(chain?: TChain): Promise; /** * @desc Returns Hop Bridge Saddle Swap LP Token Ethers contract instance. * @param chain - Chain model. * @param signer - Ethers signer * @returns Ethers contract instance. */ getSaddleLpToken(chain: TChain, signer?: TProvider): Token; /** * @desc Sends transaction to add liquidity to AMM. * @param amount0Desired - Amount of token #0 in smallest unit * @param amount1Desired - Amount of token #1 in smallest unit * @param chain - Chain model of desired chain to add liquidity to. * @param options - Method options. * @returns Ethers transaction object. */ addLiquidity(amount0Desired: TAmount, amount1Desired: TAmount, chain?: TChain, options?: Partial): Promise; /** * @desc Sends transaction to remove liquidity from AMM. * @param liquidityTokenAmount - Amount of LP tokens to burn. * @param chain - Chain model of desired chain to add liquidity to. * @param options - Method options. * @returns Ethers transaction object. */ removeLiquidity(liquidityTokenAmount: TAmount, chain?: TChain, options?: Partial): Promise; removeLiquidityOneToken(lpTokenAmount: TAmount, tokenIndex: number, chain?: TChain, options?: Partial): Promise; removeLiquidityImbalance(token0Amount: TAmount, token1Amount: TAmount, chain?: TChain, options?: Partial): Promise; calculateWithdrawOneToken(tokenAmount: TAmount, tokenIndex: number, chain?: TChain): Promise; /** * @readonly * @desc The default deadline to use in seconds. * @returns Deadline in seconds */ get defaultDeadlineSeconds(): number; /** * @readonly * @desc The time slot for the current time. * @param {Object} time - Unix timestamp (in seconds) to get the time slot. * @returns {Object} Time slot for the given time as BigNumber. */ getTimeSlot(time: TTime): Promise; /** * @readonly * @desc The challenge period. * @returns {Object} The challenge period for the bridge as BigNumber. */ challengePeriod(): Promise; /** * @readonly * @desc The size of the time slots. * @returns {Object} The size of the time slots for the bridge as BigNumber. */ timeSlotSize(): Promise; /** * @readonly * @desc The amount bonded for a time slot for a bonder. * @param timeSlot - Time slot to get. * @param bonder - Address of the bonder to check. * @returns Amount bonded for the bonder for the given time slot as BigNumber. */ timeSlotToAmountBonded(timeSlot: TTimeSlot, bonder: string): Promise; private getTokenIndexes; private populateSendL1ToL2Tx; private populateSendL2ToL1Tx; private populateSendL2ToL2Tx; private calcToHTokenAmount; private calcFromHTokenAmount; private calcSwapAmountMulticall; calcToHTokenAmountMulticall(chain: TChain, amountIns: BigNumberish[]): Promise; calcFromHTokenAmountMulticall(chain: TChain, amountIns: BigNumberish[]): Promise; getBonderFeeRelative(amountIn: TAmount, sourceChain: TChain, destinationChain: TChain, isHTokenSend?: boolean): Promise; getBonderFeeAbsolute(sourceChain: TChain, destinationChain?: TChain): Promise; private getRate; private getPriceImpact; private checkConnectedChain; getAmbBridge(chain: TChain): Promise; getChainNativeToken(chain: TChain): any; isNativeToken(chain?: TChain): boolean; getEthBalance(chain?: TChain, address?: string): Promise; isSupportedAsset(chain: TChain): boolean; getBonderAddress(sourceChain: TChain, destinationChain: TChain): Promise; getMessengerWrapperAddress(destinationChain: TChain): Promise; shouldAttemptSwap(amountOutMin: BigNumber, deadline: BigNumberish): boolean; private getGasEstimateFromAddress; withdraw(chain: TChain, recipient: string, amount: BigNumberish, transferNonce: string, bonderFee: BigNumberish, amountOutMin: BigNumberish, deadline: number, transferRootHash: string, rootTotalAmount: BigNumberish, transferIdTreeIndex: number, siblings: string[], totalLeaves: number): Promise; populateWithdrawTx(chain: TChain, recipient: string, amount: BigNumberish, transferNonce: string, bonderFee: BigNumberish, amountOutMin: BigNumberish, deadline: number, transferRootHash: string, rootTotalAmount: BigNumberish, transferIdTreeIndex: number, siblings: string[], totalLeaves: number): Promise; populateWithdrawTransferTx(sourceChain: TChain, destinationChain: TChain, transferIdOrTransactionHash: string): Promise; withdrawTransfer(sourceChain: TChain, destinationChain: TChain, transferIdOrTransactionHash: string): Promise; getWithdrawProof(sourceChain: TChain, destinationChain: TChain, transferIdOrTransactionHash: string): Promise; setPriceFeedApiKeys(apiKeys?: PriceFeedApiKeys): void; needsApproval(amount: TAmount, sourceChain: TChain, address?: string, destinationChain?: TChain): Promise; needsHTokenApproval(amount: TAmount, sourceChain: TChain, address?: string, destinationChain?: TChain): Promise; parseUnits(value: TAmount, decimals?: number): BigNumber; formatUnits(value: TAmount, decimals?: number): number; calcAmountOutMin(amountOut: TAmount, slippageTolerance: number): BigNumber; isDestinationChainPaused(destinationChain: TChain): Promise; get supportedChains(): string[]; get supportedLpChains(): string[]; getSupportedLpChains(): string[]; getNonAmmAssets(): Set; getIsSupportedCctpRoute(fromChain: TChain, toChain: TChain): boolean; getAccountLpBalance(chain: TChain, account?: string): Promise; getAccountLpCanonicalBalance(chain: TChain, account?: string): Promise; getAccountLpCanonicalBalanceUsd(chain: TChain, account?: string): Promise; getPriceByTokenSymbol(tokenSymbol: string): Promise; private isValidRelayerAndRelayerFee; private getLpFeeBps; getCctpDecodedMessageBody(message: string): string; getCctpMessageHash(message: string): string; getCctpReceiveMessageEstimateGasLimit(fromChain: TChain, toChain: TChain): Promise; getCctpMessageAttestation(messageHash: string, toChain: TChain): Promise; getCctpReceiveMessagePopulatedTx(message: string, attestation: string, toChain: TChain): Promise; getCctpWithdrawData(transactionHash: string): Promise<{ fromChain: string; fromChainId: string; toChain: ChainSlug; toChainId: any; nonce: string; nonceUsed: boolean; transactionHash: string; }>; getCctpWithdrawPopulatedTx(fromChain: TChain, toChain: TChain, transactionHash: string): Promise; cctpWithdraw(fromChain: TChain, toChain: TChain, transactionHash: string): Promise; calcUniswapSwapAmountOut(sourceChain: TChain, amountIn: BigNumber): Promise; getIsCctpEnabled(): Promise; getCctpRecipientHash(recipientAddress: string): string; getIsCctpNonceUsed(nonce: string, fromChain: TChain, toChain: TChain): Promise; getTransactionStatusSocket(hash: string, isRequestHash?: boolean): Promise<{ status: 'PENDING' | 'COMPLETED'; txHash: string | null; destTxHash: string | null; originalSocketResponse: any; }>; getTransactionStatusLifi(hash: string): Promise<{ status: 'PENDING' | 'COMPLETED' | 'FAILED'; txHash: string | null; destTxHash: string | null; originalLifiResponse: any; }>; getTransactionStatusCctp(transactionHash: string, fromChain: TChain, toChain: TChain): Promise<{ status: 'PENDING' | 'COMPLETED' | 'FAILED'; txHash: string | null; destTxHash: string | null; originalCctpResponse: any; }>; } export {}; //# sourceMappingURL=HopBridge.d.ts.map