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