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