Namespace
HopBridge SDK instance.
Instantiates Hop Bridge. Returns a new Hop Bridge instance.
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)
Default deadline for transfers
Destination Chain model
Rest
...args: [signerOrProvider: TProvider]Network name
Ethers signer or provider
Source Chain model
Private
tokenDeadline in seconds
The default deadline to use in seconds.
Protected
_getProtected
_getAmount of token #0 in smallest unit
Amount of token #1 in smallest unit
Optional
chain: TChainChain model of desired chain to add liquidity to.
Method options.
Ethers transaction object.
Sends transaction to add liquidity to AMM.
Private
calcPrivate
calcPrivate
calcOptional
chain: TChainReadonly
challengePrivate
checkEthers Signer
for signing transactions.
New HopBridge SDK instance with connected signer.
Returns hop bridge instance with signer connected. Used for adding or changing signer.
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)
Source chain model.
Converts to Hop token only if set to true.
Amount of token to swap.
Minimum amount of tokens to receive in order for transaction to be successful.
Transaction deadline in seconds.
Ethers transaction object.
Sends transaction to execute swap on Saddle contract.
Optional
account: stringOptional
account: stringOptional
account: stringAmount as BigNumber.
Estimate token amount out.
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)
Private
getPrivate
getchain model.
Ethers contract instance.
Returns bridge contract instance for specified chain.
Ether's Signer
Percentage to bump by.
Bumped as price as BigNumber
Calculates current gas price plus increased percentage amount.
import { Hop } from '@hop-protocol/sdk'
const hop = new Hop()
const bumpedGasPrice = await hop.getBumpedGasPrice(signer, 1.20)
console.log(bumpedGasPrice.toNumber())
Chain model.
Returns Chain ID for specified Chain model.
Chain model.
Ethers provider.
Returns Ethers provider for specified Chain model.
Chain model.
Total credit as BigNumber.
Returns total credit that bonder holds on Hop bridge at specified chain.
Chain model.
Total debit as BigNumber.
Returns total debit that bonder holds on Hop bridge at specified chain.
Private
getOptional
address: stringPrivate
getEthers signer
Ethers contract instance.
Returns Hop L1 Bridge Ethers contract instance.
Private
getPrivate
getPrivate
getToken amount input.
Source chain model.
Amount as BigNumber.
Estimate the bonder liquidity needed at the destination.
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)
Chain model.
Array containing reserve amounts for canonical token and hTokens.
Returns Hop Bridge Saddle reserve amounts.
Readonly
getOptional
address: stringPrivate
getChain model.
Total debit as BigNumber.
Returns total debit, including sliding window debit, that bonder holds on Hop bridge at specified chain.
Optional
chain: TChainPrivate
isPrivate
isPrivate
populatePrivate
populatePrivate
populateAmount of LP tokens to burn.
Optional
chain: TChainChain model of desired chain to add liquidity to.
Method options.
Ethers transaction object.
Sends transaction to remove liquidity from AMM.
Optional
chain: TChainOptional
chain: TChainEthers Transaction object.
Send tokens to another chain.
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)
Readonly
timeReadonly
timeReadonly
Time slot to get.
Address of the bonder to check.
Amount bonded for the bonder for the given time slot as BigNumber.
The amount bonded for a time slot for a bonder.
Token name or model.
Token model.
Returns a Token instance.
Generated using TypeDoc
Class representing Hop bridge. HopBridge