const Config = require("../config/config"); const IERC20 = require("./web3/ierc20-token"); module.exports = class Token { exchange = {} ierc20 = {} constructor(exchangeSymbol, exchangePriceTick, exchangePair, ierc20Decimals) { this.exchange.symbol = exchangeSymbol this.exchange.priceTick = exchangePriceTick this.exchange.pair = exchangePair this.ierc20.decimals = ierc20Decimals } static async init(context, tokenHash, priceTickFilterMap) { // token初始化 const ierc20Decimals = parseInt(await IERC20.getDecimals(tokenHash)) const exchangeSymbol = Config.tokenMapping[tokenHash] const exchangePair = `${exchangeSymbol}${Config.baseIerc20Token.symbol}` const exchangePriceTick = priceTickFilterMap[exchangePair] context.tokenMap[tokenHash] = new Token(exchangeSymbol, exchangePriceTick, exchangePair, ierc20Decimals) } static async batchInit(context, ierc20TokenAddressList, priceTickFilterMap) { context.tokenMap = {} for (const tokenHash of ierc20TokenAddressList) { // 初始化token await Token.init(context, tokenHash, priceTickFilterMap) } } }