Namespace
Instantiates AMM instance. Returns a new Hop AMM SDK instance.
Hop AMM instance
import { AMM, Chain } from '@hop-protocol/sdk'
const amm = new AMM('mainnet', 'USDC', Chain.Gnosis)
Rest
...args: [fromIndex: TokenIndex, toIndex: TokenIndex, amount: BigNumberish]Chain model
Rest
...args: [signerOrProvider: TProvider]Network name
Ethers signer or provider
Token class instance
Deadline 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
Minimum amount of LP token to mint in order for transaction to be successful.
Order deadline in seconds
Ethers transaction object.
Sends transaction to add liquidity to AMM.
import { AMM } from '@hop-protocol/sdk'
const amm = new AMM(...)
const tx = await amm.addLiquidity('1000000000000000000', '1000000000000000000', '0')
console.log(tx.hash)
Private
calculateEthers Signer
for signing transactions.
Hop AMM instance with connected signer.
Returns hop AMM instance with signer connected. Used for adding or changing signer.
import { AMM } from '@hop-protocol/sdk'
const signer = new Wallet(privateKey)
let amm = new AMM(...)
// ...
amm = amm.connect(signer)
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.
Private
normalizeAmount of LP tokens to burn.
Minimum amount of token #0 to receive in order for transaction to be successful.
Minimum amount of token #1 to receive in order for transaction to be successful. transaction to be successful.
Order deadline in seconds
Ethers transaction object.
Sends transaction to remove liquidity from AMM.
import { AMM } from '@hop-protocol/sdk'
const amm = new AMM(...)
const tx = await amm.removeLiquidity('1000000000000000000', '0', '0')
console.log(tx.hash)
Token name or model.
Token model.
Returns a Token instance.
Generated using TypeDoc
Class representing AMM contract AMM