# Market

# getMarketPrice

To get market prices for specific tokens

# Parameters:

Name Type Default
tokenAddresses string[]
currency 'USD' | 'CNY' 'USD'

# Code sample:

const market = new Market(chainId)
const tokenAddresses = ['0x0000000000000000000000000000000000000000']
const tokenPrices = await market.getMarketPrice(tokenAddresses, 'CNY')

# Response:

[
  {
    chainType: 'ETHEREUM',
    address: '0x0000000000000000000000000000000000000000',
    currency: 'CNY',
    price: 26335.159107681542,
    source: 'coinmarketcap'
  }
]

# getMarketRateAndPrice

To get exchange rate for specific token pair

# Parameters:

Name Type Default
base string
quote string
side 'BUY' | 'SELL'
currency string 'USD'

# Code sample:

const market = new Market(chainId)
const marketResult = await market.getMarketRateAndPrice({
  base: 'ETH',
  quote: 'LON',
  side: 'SELL',
})

# Response:

{
  rate: '6602.32778604',
  marketPrice: null,
  marketSnapshot: null,
  currency: 'USD'
}

# getTradableTokens

To get all tradable tokens collected by Tokenlon protocols

# Parameters:

Name Type
protocols Protocol[]

# Code sample:

const market = new Market(chainId)
const tokens = await market.getTradableTokens([Protocol.AMMV1])

# Response:

{
  ...
  ETH: {
    contractAddress: '0x0000000000000000000000000000000000000000',
    decimal: 18,
    logo: 'https://v2-cdn.token.im/app-mainnet-production/tokens/icons/eth%403x.png',
    maxTradeAmount: '888',
    minTradeAmount: '0.025',
    opposites: [
      'KEEP', 'USDT',  'DAI',  'USDC',
      'WBTC', '1INCH', 'LON',  'BOND',
      'FEI',  'BANK',  'TORN', 'ALCX',
      'WOO',  'LUNA',  'BAL',  'ILV',
      'MCB',  'MIR',   'POOL', 'GTC',
      'DYDX', 'CEL',   'ERN',  'NU',
      'SLP',  'AXS',   'SHIB', 'INJ',
      'GNO',  'FLOAT', 'AMP',  'LPT',
      'QNT',  'LIT',   'POLS'
    ],
    precision: 4,
    recommend: true,
    symbol: 'ETH'
  }
}