const HttpKit = require('./kit/HttpKit') class Pancake {} Pancake.pairs = async function () { const url = 'https://api.pancakeswap.info/api/v2/pairs' const { data: rst } = await HttpKit.get(url) return rst } Pancake.tokenList = async function () { const url = 'https://api.pancakeswap.info/api/v2/tokens' const { data: rst } = await HttpKit.get(url) return rst } Pancake.tokenInfo = async function (symbol = 'WBNB', tokens) { if (!tokens) { tokens = await Pancake.tokenList() } const { data: priceList } = tokens for (const key in priceList) { const token = priceList[key] if (symbol === token.symbol) { return token } } } Pancake.priceByBNB = async function (symbol, list) { const token = await Pancake.tokenInfo(symbol, list) return token ? token.price_BNB : 0 } Pancake.price = async function (symbol, list) { const token = await Pancake.tokenInfo(symbol, list) return token ? token.price : 0 } module.exports = Pancake