Class HopBridgeNamespace

Class representing Hop bridge. HopBridge

Hierarchy

Constructors

Properties

Accessors

Methods

_getBonderAddress _getMessengerWrapperAddress addLiquidity calcAmountOutMin calcFromHTokenAmount calcFromHTokenAmountMulticall calcSwapAmountMulticall calcToHTokenAmount calcToHTokenAmountMulticall calculateWithdrawOneToken challengePeriod checkBlocklist checkConnectedChain connect debugTimeLog estimateBondWithdrawalGasLimit estimateGas estimateOptimismL1FeeFromData estimateSendGasLimit estimateSendHTokensGasLimit execSaddleSwap fetchBonderAvailableLiquidityData fetchBonderAvailableLiquidityDataWithIpfsFallback fetchConfigFromS3 fetchCoreConfigData fetchCoreConfigDataWithIpfsFallback fetchIpfsBonderAvailableLiquidityData fetchIpfsCoreConfigData formatUnits geConfigChains getAccountLpBalance getAccountLpCanonicalBalance getAccountLpCanonicalBalanceUsd getAmbBridge getAmm getAmmData getAmmWrapper getAmountOut getArbChainAddress getAvailableLiquidity getAvailableRoutes getBaseAvailableCreditIncludingVault getBonderAddress getBonderAvailableLiquidityData getBonderFeeAbsolute getBonderFeeRelative getBridgeContract getBumpedGasPrice getCanonicalToken getChainId getChainNativeToken getChainProvider getChainProviderUrls getChainProviders getConfigAddresses getCredit getDebit getDebugTimeLogs getDestinationFeeGasPriceMultiplier getDestinationTransactionFee getDestinationTransactionFeeData getEstimatedGasLimit getEthBalance getExplorerUrl getExplorerUrlForAccount getExplorerUrlForTransactionHash getExplorerUrlForTransferId getFeeBps getFrontendAvailableLiquidity getGasEstimateFromAddress getIpfsBaseConfigUrl getIsBridgeDeprecated getL1AmbBridgeAddress getL1Bridge getL1BridgeAddress getL1CanonicalBridgeAddress getL1CanonicalTokenAddress getL1PosErc20PredicateAddress getL1PosRootChainManagerAddress getL1Token getL2AmbBridgeAddress getL2AmmWrapperAddress getL2Bridge getL2BridgeAddress getL2CanonicalBridgeAddress getL2CanonicalTokenAddress getL2HopBridgeTokenAddress getL2HopToken getL2SaddleLpTokenAddress getL2SaddleSwapAddress getLpFeeBps getLpFees getMessengerWrapperAddress getNonAmmAssets getOptimismL1Fee getPriceByTokenSymbol getPriceImpact getProviderRpcUrl getRate getRelayerFee getRequiredLiquidity getReservesTotal getS3ConfigData getSaddleLpToken getSaddleSwapReserves getSendApprovalAddress getSendData getSendDataAmountOutMins getSendEstimatedGasCost getSignerAddress getSignerOrProvider getSupportedAssets getSupportedAssetsForChain getSupportedChains getSupportedLpChains getSupportedTokens getTimeSlot getTokenBalance getTokenBalancesForAccount getTokenDecimals getTokenImage getTokenIndexes getTokenSymbol getTotalDebit getTotalFee getTransferStatus getTransferTimes getTvl getTvlUsd getUnbondedTransferRootAmount getVaultBalance getWithdrawProof isDestinationChainPaused isNativeToken isOruToL1 isSupportedAsset isValidChain isValidNetwork isValidRelayerAndRelayerFee needsApproval needsHTokenApproval parseUnits populateBondWithdrawalTx populateSendApprovalTx populateSendHTokensTx populateSendL1ToL2Tx populateSendL2ToL1Tx populateSendL2ToL2Tx populateSendTx populateWithdrawTransferTx populateWithdrawTx removeLiquidity removeLiquidityImbalance removeLiquidityOneToken resolveDnslink send sendApproval sendHToken sendTransaction setAvailableLiqudityJsonUrl setBaseConfigUrl setChainProvider setChainProviderUrls setChainProviders setConfigAddresses setConfigFileFetchEnabled setCoreConfigJsonUrl setGasPriceMultiplier setPriceFeedApiKeys shouldAttemptSwap timeSlotSize timeSlotToAmountBonded toCanonicalToken toChainModel toHopToken toTokenModel txOverrides willTransferFail withdraw withdrawTransfer

Constructors

  • Parameters

    • networkOrOptionsObject: string | HopBridgeConstructorOptions

      L1 network name (e.g. 'mainnet', 'goerli')

    • Optional signer: TProvider

      Ethers Signer for signing transactions.

    • Optional token: TToken

      Token symbol or model

    • Optional chainProviders: ChainProviders

    Returns HopBridge

    HopBridge SDK instance.

    Desc

    Instantiates Hop Bridge. Returns a new Hop Bridge instance.

    Example

    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)

Properties

addresses: Record<string, any>
baseConfigUrl: string = defaultBaseConfigUrl
baseExplorerUrl: string = 'https://explorer.hop.exchange'
blocklist: Record<string, boolean> = null
bonders: Record<string, any>
bridgeDeprecated: Record<string, boolean>
chainProviders: ChainProviders = {}
chains: Record<string, any>
configFileFetchEnabled: boolean = true
customAvailableLiquidityJsonUrl: string = ''
customCoreConfigJsonUrl: string = ''
debugTimeLogsCache: any[] = []
debugTimeLogsCacheEnabled: boolean = false
debugTimeLogsEnabled: boolean = false
defaultDeadlineMinutes: number = ...

Default deadline for transfers

destinationChain: Chain

Destination Chain model

destinationFeeGasPriceMultiplier: number = 1
doesUseAmm: boolean
fees: {
    [token: string]: Record<string, number>;
}

Type declaration

  • [token: string]: Record<string, number>
gasPriceMultiplier: number = 0
getContract: ((factory, address, provider) => Promise<any>) = getContract

Type declaration

    • (factory, address, provider): Promise<any>
    • Parameters

      • factory: Factory
      • address: string
      • provider: TProvider

      Returns Promise<any>

getGasPrice: ((...args) => Promise<BigNumber>) = ...

Type declaration

    • (...args): Promise<BigNumber>
    • Parameters

      Returns Promise<BigNumber>

network: string

Network name

priceFeed: PriceFeedFromS3
priceFeedApiKeys: ApiKeys = null
relayerFeeEnabled: Record<string, boolean>
relayerFeeWei: Record<string, string>
signer: TProvider

Ethers signer or provider

sourceChain: Chain

Source Chain model

tokenSymbol: string

Accessors

  • get availableLiqudityJsonUrl(): string
  • Returns string

  • get configChains(): string[]
  • Returns string[]

  • get coreConfigJsonUrl(): string
  • Returns string

  • get defaultDeadlineSeconds(): number
  • Returns number

    Deadline in seconds

    Desc

    The default deadline to use in seconds.

  • get supportedChains(): string[]
  • Returns string[]

  • get supportedNetworks(): string[]
  • Returns string[]

Methods

  • Parameters

    • amount0Desired: BigNumberish

      Amount of token #0 in smallest unit

    • amount1Desired: BigNumberish

      Amount of token #1 in smallest unit

    • Optional chain: TChain

      Chain model of desired chain to add liquidity to.

    • options: Partial<AddLiquidityOptions> = {}

      Method options.

    Returns Promise<any>

    Ethers transaction object.

    Desc

    Sends transaction to add liquidity to AMM.

  • Parameters

    • amountOut: BigNumberish
    • slippageTolerance: number

    Returns BigNumber

  • Parameters

    • amount: BigNumberish
    • chain: Chain

    Returns Promise<BigNumber>

  • Parameters

    • chain: TChain
    • amountIns: BigNumberish[]

    Returns Promise<BigNumber[]>

  • Parameters

    • chain: TChain
    • tokenIndexes: number[]
    • amountIns: BigNumberish[]

    Returns Promise<BigNumber[]>

  • Parameters

    • amount: BigNumberish
    • chain: Chain
    • isHTokenSend: boolean = false

    Returns Promise<BigNumber>

  • Parameters

    • chain: TChain
    • amountIns: BigNumberish[]

    Returns Promise<BigNumber[]>

  • Parameters

    • tokenAmount: BigNumberish
    • tokenIndex: number
    • Optional chain: TChain

    Returns Promise<any>

  • Readonly

    Returns Promise<BigNumber>

    The challenge period for the bridge as BigNumber.

    Desc

    The challenge period.

  • Parameters

    • signer: Signer

      Ethers Signer for signing transactions.

    Returns HopBridge

    New HopBridge SDK instance with connected signer.

    Desc

    Returns hop bridge instance with signer connected. Used for adding or changing signer.

    Example

    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)
  • Parameters

    Returns Promise<any>

  • Parameters

    • gasLimit: BigNumberish
    • data: string = '0x'
    • to: string = constants.AddressZero
    • destChain: string | Chain = Chain.Optimism

    Returns Promise<any>

  • Parameters

    • tokenAmount: BigNumberish
    • sourceChain: TChain
    • destinationChain: TChain
    • options: Partial<SendOptions> = {}

    Returns Promise<BigNumber>

  • Parameters

    • tokenAmount: BigNumberish
    • sourceChain: TChain
    • destinationChain: TChain
    • options: Partial<SendOptions> = {}

    Returns Promise<BigNumber>

  • Parameters

    • sourceChain: TChain

      Source chain model.

    • toHop: boolean

      Converts to Hop token only if set to true.

    • amount: BigNumberish

      Amount of token to swap.

    • minAmountOut: BigNumberish

      Minimum amount of tokens to receive in order for transaction to be successful.

    • deadline: BigNumberish

      Transaction deadline in seconds.

    Returns Promise<any>

    Ethers transaction object.

    Desc

    Sends transaction to execute swap on Saddle contract.

  • Parameters

    • value: BigNumberish
    • Optional decimals: number

    Returns number

  • Parameters

    • chain: TChain
    • Optional account: string

    Returns Promise<BigNumber>

  • Parameters

    • chain: TChain
    • Optional account: string

    Returns Promise<BigNumber>

  • Parameters

    • chain: TChain
    • Optional account: string

    Returns Promise<number>

  • Parameters

    • chain: TChain
    • amountIn: BigNumberish
    • isToHToken: boolean
    • slippageTolerance: number

    Returns Promise<any>

  • Parameters

    Returns Promise<any>

    Ethers contract instance.

    Desc

    Returns Hop Bridge AMM wrapper Ethers contract instance.

  • Parameters

    • tokenAmountIn: BigNumberish

      Token amount input.

    • Optional sourceChain: TChain

      Source chain model.

    • Optional destinationChain: TChain

      Destination chain model.

    Returns Promise<BigNumber>

    Amount as BigNumber.

    Desc

    Estimate token amount out.

    Example

    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)
  • Parameters

    • destinationChain: TChain
    • bonder: string

    Returns Promise<BigNumber>

  • Parameters

    Returns Promise<BigNumber>

  • Parameters

    Returns Promise<string>

  • Parameters

    Returns Promise<BigNumber>

  • Parameters

    • amountIn: BigNumberish
    • sourceChain: TChain
    • destinationChain: TChain
    • isHTokenSend: boolean = false

    Returns Promise<BigNumber>

  • Parameters

    Returns Promise<Contract>

    Ethers contract instance.

    Desc

    Returns bridge contract instance for specified chain.

  • Parameters

    • signer: TProvider

      Ether's Signer

    • percent: number

      Percentage to bump by.

    Returns Promise<BigNumber>

    Bumped as price as BigNumber

    Desc

    Calculates current gas price plus increased percentage amount.

    Example

    import { Hop } from '@hop-protocol/sdk'

    const hop = new Hop()
    const bumpedGasPrice = await hop.getBumpedGasPrice(signer, 1.20)
    console.log(bumpedGasPrice.toNumber())
  • Parameters

    • chain: Chain

      Chain model.

    Returns number

    • Chain ID.

    Desc

    Returns Chain ID for specified Chain model.

  • Parameters

    • chain: string | Chain

      Chain model.

    Returns any

    Ethers provider.

    Desc

    Returns Ethers provider for specified Chain model.

  • Parameters

    • sourceChain: TChain

      Chain model.

    • bonder: string

    Returns Promise<BigNumber>

    Total credit as BigNumber.

    Desc

    Returns total credit that bonder holds on Hop bridge at specified chain.

  • Parameters

    • sourceChain: TChain

      Chain model.

    • bonder: string

    Returns Promise<BigNumber>

    Total debit as BigNumber.

    Desc

    Returns total debit that bonder holds on Hop bridge at specified chain.

  • Parameters

    Returns Promise<BigNumber>

  • Parameters

    Returns Promise<any>

  • Parameters

    • sourceChain: TChain
    • destinationChain: TChain
    • populatedTx: any

    Returns Promise<BigNumber>

  • Parameters

    • chain: TChain = ...
    • Optional address: string

    Returns Promise<BigNumber>

  • Parameters

    • sourceChain: TChain

      Source chain model.

    • destinationChain: TChain

      Destination chain model.

    Returns Promise<BigNumber>

    Available liquidity as BigNumber.

    Desc

    Returns available liquidity for Hop bridge at specified chain.

  • Parameters

    Returns Promise<any>

  • Parameters

    Returns Promise<any>

    Ethers contract instance.

    Desc

    Returns Hop L1 Bridge Ethers contract instance.

  • Parameters

    Returns Promise<any>

    Ethers contract instance.

    Desc

    Returns Hop L2 Bridge Ethers contract instance.

  • Parameters

    • amountIn: BigNumberish
    • sourceChain: TChain
    • destinationChain: TChain

    Returns BigNumber

  • Parameters

    Returns Promise<string>

  • Parameters

    Returns Promise<BigNumber>

  • Parameters

    • tokenSymbol: string

    Returns Promise<any>

  • Parameters

    • rate: number
    • marketRate: number

    Returns number

  • Parameters

    • amountIn: BigNumber
    • amountOut: BigNumber
    • sourceToken: Token
    • destToken: Token

    Returns number

  • Parameters

    • destinationChain: TChain
    • tokenSymbol: string

    Returns Promise<BigNumber>

  • Parameters

    • tokenAmountIn: BigNumberish

      Token amount input.

    • sourceChain: TChain

      Source chain model.

    Returns Promise<BigNumber>

    Amount as BigNumber.

    Desc

    Estimate the bonder liquidity needed at the destination.

    Example

    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)
  • Parameters

    Returns Promise<BigNumber>

  • Parameters

    Returns Token

    Ethers contract instance.

    Desc

    Returns Hop Bridge Saddle Swap LP Token Ethers contract instance.

  • Parameters

    • chain: TChain = ...

      Chain model.

    Returns Promise<BigNumber[]>

    Array containing reserve amounts for canonical token and hTokens.

    Desc

    Returns Hop Bridge Saddle reserve amounts.

  • Parameters

    • sourceChain: TChain
    • isHTokenTransfer: boolean = false
    • Optional destinationChain: TChain

    Returns string

  • Parameters

    • amountIn: BigNumberish
    • sourceChain: TChain
    • destinationChain: TChain
    • isHTokenSend: boolean = false

    Returns Promise<any>

  • Parameters

    • getSendDataResponse: any
    • slippageTolerance: number

    Returns any

  • Parameters

    • tokenAmount: BigNumberish
    • sourceChain: TChain
    • destinationChain: TChain
    • options: Partial<SendOptions> = {}

    Returns Promise<BigNumber>

  • Returns Promise<string>

    Ethers signer address.

    Desc

    Returns the connected signer address.

    Example

    import { Hop } from '@hop-protocol/sdk'

    const hop = new Hop()
    const address = await hop.getSignerAddress()
    console.log(address)
  • Parameters

    • chain: TChain

      Chain name or model

    • signer: TProvider = ...

      Ethers signer or provider

    Returns Promise<Provider | Signer>

    Ethers signer or provider

    Desc

    Returns the connected signer if it's connected to the specified chain id, otherwise it returns a regular provider for the specified chain.

  • Readonly

    Parameters

    • time: BigNumberish

      Unix timestamp (in seconds) to get the time slot.

    Returns Promise<BigNumber>

    Time slot for the given time as BigNumber.

    Desc

    The time slot for the current time.

  • Parameters

    • chain: TChain
    • Optional address: string

    Returns Promise<BigNumber>

  • Parameters

    Returns Promise<number[]>

  • Parameters

    • sourceChain: TChain

      Chain model.

    • bonder: string

    Returns Promise<BigNumber>

    Total debit as BigNumber.

    Desc

    Returns total debit, including sliding window debit, that bonder holds on Hop bridge at specified chain.

  • Parameters

    • amountIn: BigNumberish
    • sourceChain: TChain
    • destinationChain: TChain

    Returns Promise<BigNumber>

  • Parameters

    • sourceChainSlug: string
    • destinationChainSlug: string

    Returns Promise<any>

  • Parameters

    Returns Promise<BigNumber>

  • Parameters

    • destinationChain: TChain
    • bonder: string

    Returns Promise<BigNumber>

  • Parameters

    • sourceChain: TChain
    • destinationChain: TChain
    • transferIdOrTransactionHash: string

    Returns Promise<any>

  • Parameters

    Returns Promise<boolean>

  • Parameters

    • relayer: string
    • relayerFee: BigNumber

    Returns Promise<boolean>

  • Parameters

    • amount: BigNumberish
    • sourceChain: TChain
    • Optional address: string
    • Optional destinationChain: TChain

    Returns Promise<boolean>

  • Parameters

    • amount: BigNumberish
    • sourceChain: TChain
    • Optional address: string
    • Optional destinationChain: TChain

    Returns Promise<boolean>

  • Parameters

    • value: BigNumberish
    • Optional decimals: number

    Returns BigNumber

  • Parameters

    • sourceChain: TChain
    • destinationChain: TChain
    • Optional recipient: string

    Returns Promise<any>

  • Parameters

    • tokenAmount: BigNumberish
    • sourceChain: TChain
    • isHTokenTransfer: boolean = false
    • Optional destinationChain: TChain

    Returns Promise<any>

  • Parameters

    • tokenAmount: BigNumberish
    • sourceChain: TChain
    • destinationChain: TChain
    • options: Partial<SendOptions> = {}

    Returns Promise<any>

  • Parameters

    • input: SendL1ToL2Input

    Returns Promise<any>

  • Parameters

    • input: SendL2ToL1Input

    Returns Promise<any>

  • Parameters

    • input: SendL2ToL2Input

    Returns Promise<any>

  • Parameters

    • tokenAmount: BigNumberish
    • Optional sourceChain: TChain
    • Optional destinationChain: TChain
    • options: Partial<SendOptions> = {}

    Returns Promise<any>

  • Parameters

    • sourceChain: TChain
    • destinationChain: TChain
    • transferIdOrTransactionHash: string

    Returns Promise<any>

  • Parameters

    • chain: TChain
    • recipient: string
    • amount: BigNumberish
    • transferNonce: string
    • bonderFee: BigNumberish
    • amountOutMin: BigNumberish
    • deadline: number
    • transferRootHash: string
    • rootTotalAmount: BigNumberish
    • transferIdTreeIndex: number
    • siblings: string[]
    • totalLeaves: number

    Returns Promise<PopulatedTransaction>

  • Parameters

    • liquidityTokenAmount: BigNumberish

      Amount of LP tokens to burn.

    • Optional chain: TChain

      Chain model of desired chain to add liquidity to.

    • options: Partial<RemoveLiquidityOptions> = {}

      Method options.

    Returns Promise<any>

    Ethers transaction object.

    Desc

    Sends transaction to remove liquidity from AMM.

  • Parameters

    • token0Amount: BigNumberish
    • token1Amount: BigNumberish
    • Optional chain: TChain
    • options: Partial<RemoveLiquidityImbalanceOptions> = {}

    Returns Promise<any>

  • Parameters

    • lpTokenAmount: BigNumberish
    • tokenIndex: number
    • Optional chain: TChain
    • options: Partial<RemoveLiquidityOneTokenOptions> = {}

    Returns Promise<any>

  • Parameters

    • tokenAmount: BigNumberish

      Token amount to send denominated in smallest unit.

    • Optional sourceChain: TChain

      Source chain model.

    • Optional destinationChain: TChain

      Destination chain model.

    • options: Partial<SendOptions> = {}

    Returns Promise<any>

    Ethers Transaction object.

    Desc

    Send tokens to another chain.

    Example

    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)
  • Parameters

    • tokenAmount: BigNumberish
    • sourceChain: TChain
    • destinationChain: TChain
    • isHTokenTransfer: boolean = false

    Returns Promise<any>

  • Parameters

    • tokenAmount: BigNumberish
    • sourceChain: TChain
    • destinationChain: TChain
    • options: Partial<SendOptions> = {}

    Returns Promise<any>

  • Parameters

    • transactionRequest: TransactionRequest
    • chain: TChain

    Returns Promise<any>

  • Parameters

    • apiKeys: ApiKeys = {}

    Returns void

  • Parameters

    • amountOutMin: BigNumber
    • deadline: BigNumberish

    Returns boolean

  • Readonly

    Returns Promise<BigNumber>

    The size of the time slots for the bridge as BigNumber.

    Desc

    The size of the time slots.

  • Readonly

    Parameters

    • timeSlot: BigNumberish

      Time slot to get.

    • bonder: string

      Address of the bonder to check.

    Returns Promise<BigNumber>

    Amount bonded for the bonder for the given time slot as BigNumber.

    Desc

    The amount bonded for a time slot for a bonder.

  • Parameters

    • chain: TChain

      Chain name or model.

    Returns Chain

    Chain model with connected provider.

    Desc

    Returns a Chain model instance with connected provider.

  • Parameters

    • sourceChain: TChain
    • destinationChain: TChain
    • recipient: string

    Returns Promise<any>

  • Parameters

    • chain: TChain
    • recipient: string
    • amount: BigNumberish
    • transferNonce: string
    • bonderFee: BigNumberish
    • amountOutMin: BigNumberish
    • deadline: number
    • transferRootHash: string
    • rootTotalAmount: BigNumberish
    • transferIdTreeIndex: number
    • siblings: string[]
    • totalLeaves: number

    Returns Promise<any>

  • Parameters

    • sourceChain: TChain
    • destinationChain: TChain
    • transferIdOrTransactionHash: string

    Returns Promise<any>

Generated using TypeDoc