|
@@ -11,7 +11,7 @@ const showPrices = function(context, task) {
|
|
|
const tokenMap = context.tokenMap
|
|
const tokenMap = context.tokenMap
|
|
|
|
|
|
|
|
const titles = ['pair', '1inch', 'binance', 'diff', 'percentage']
|
|
const titles = ['pair', '1inch', 'binance', 'diff', 'percentage']
|
|
|
- const colWidth = 20
|
|
|
|
|
|
|
+ const colWidth = 30
|
|
|
const padTitles = titles.map((title) => {
|
|
const padTitles = titles.map((title) => {
|
|
|
return title.padEnd(colWidth, ' ')
|
|
return title.padEnd(colWidth, ' ')
|
|
|
})
|
|
})
|
|
@@ -55,7 +55,7 @@ const showPrices = function(context, task) {
|
|
|
|
|
|
|
|
// 价格非法的就不输出了
|
|
// 价格非法的就不输出了
|
|
|
if ((() => {
|
|
if ((() => {
|
|
|
- return !OneInchPrice || !BinancePrice || !DiffPrice
|
|
|
|
|
|
|
+ return !OneInchPrice || !BinancePrice
|
|
|
})()) return
|
|
})()) return
|
|
|
// 需要输出到文件的打印逻辑
|
|
// 需要输出到文件的打印逻辑
|
|
|
if ((() => {
|
|
if ((() => {
|
|
@@ -78,15 +78,24 @@ const onTickFun = async function() {
|
|
|
// 搜集所有价格数据
|
|
// 搜集所有价格数据
|
|
|
for (const tokenHash of tokenContractAddressList) {
|
|
for (const tokenHash of tokenContractAddressList) {
|
|
|
const toToken = tokenMap[tokenHash]
|
|
const toToken = tokenMap[tokenHash]
|
|
|
|
|
+ const lotSize = toToken.exchange.lotSize
|
|
|
const fromIerc20Token = Config.baseIerc20Token
|
|
const fromIerc20Token = Config.baseIerc20Token
|
|
|
const amount = Config.baseTokenAmount
|
|
const amount = Config.baseTokenAmount
|
|
|
|
|
|
|
|
- const OneInchPrice = NumKit.getSubFloat(await OneInch.price(fromIerc20Token.contract, tokenHash, amount), 8)
|
|
|
|
|
- const BinancePrice = NumKit.getSubFloat(await BinanceSpot.realPrice(toToken.exchange.pair), 8)
|
|
|
|
|
|
|
+ const OneInchPrice = NumKit.getSubFloat(await OneInch.price(fromIerc20Token.contract, tokenHash, amount), lotSize)
|
|
|
|
|
+ const BinancePrice = NumKit.getSubFloat(await BinanceSpot.realPrice(toToken.exchange.pair), lotSize)
|
|
|
|
|
|
|
|
toToken.OneInchPrice = OneInchPrice
|
|
toToken.OneInchPrice = OneInchPrice
|
|
|
toToken.BinancePrice = BinancePrice
|
|
toToken.BinancePrice = BinancePrice
|
|
|
- toToken.DiffPrice = NumKit.getSubFloat(BinancePrice - OneInchPrice, 8)
|
|
|
|
|
|
|
+ toToken.DiffPrice = BinancePrice - OneInchPrice
|
|
|
|
|
+
|
|
|
|
|
+ if ((() => {
|
|
|
|
|
+ return Math.abs(toToken.DiffPrice) < Math.pow(10, -lotSize)
|
|
|
|
|
+ })()) {
|
|
|
|
|
+ toToken.DiffPrice = 0
|
|
|
|
|
+ } {
|
|
|
|
|
+ toToken.DiffPrice = NumKit.getSubFloat(toToken.DiffPrice, lotSize)
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 绘制帧
|
|
// 绘制帧
|