feat: vic init
This commit is contained in:
@@ -2,5 +2,8 @@
|
||||
|
||||
module.exports = {
|
||||
USDTAddr: '0xdac17f958d2ee523a2206206994597c13d831ec7',
|
||||
startBlock: 8510200
|
||||
VICAddr: '0xA5D1Eb8bBB42b7f2EBBebF174B3966510243F30c',
|
||||
startBlock: 8510200,
|
||||
VIC_DECIMAL: 1e18,
|
||||
USDT_DECIMAL: 1e6,
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
const { ERC20 } = require('../utils/erc20');
|
||||
const { USDTAddr, startBlock } = require('./constant');
|
||||
const { USDTAddr, VICAddr, startBlock, VIC_DECIMAL, USDT_DECIMAL } = require('./constant');
|
||||
|
||||
const getUSDTTxList = async address => {
|
||||
if (!address) return null;
|
||||
@@ -9,23 +9,43 @@ const getUSDTTxList = async address => {
|
||||
});
|
||||
return res.filter(tx => tx.tokenName === 'Tether USD' && tx.tokenSymbol === 'USDT' && tx.to === address && tx.from !== address); //只取转入到本地址的
|
||||
};
|
||||
const getVICTxList = async address => {
|
||||
if (!address) return null;
|
||||
const res = await ERC20.getActions(address, VICAddr, startBlock).catch(err => {
|
||||
if (err) return [];
|
||||
});
|
||||
return res.filter(tx => tx.tokenName === 'Value of Individual' && tx.tokenSymbol === 'VIC' && tx.to === address && tx.from !== address); //只取转入到本地址的
|
||||
};
|
||||
|
||||
const parseUsdtTx = txList => {
|
||||
const parseETHTx = txList => {
|
||||
if (!txList || !Array.isArray(txList)) return [];
|
||||
return txList.map(tx => {
|
||||
tx.amount = (+tx.value) / 1e6;
|
||||
tx.amount = (+tx.value) / VIC_DECIMAL;
|
||||
return tx;
|
||||
});
|
||||
};
|
||||
|
||||
const getNewDepositTx = (usdtTx = [], fundList = []) => {
|
||||
// usdt
|
||||
const getNewUSDTDepositTx = (usdtTx = [], fundList = []) => {
|
||||
if (fundList.length > usdtTx.length) return null;
|
||||
// fundList的顺序应该与usdtTx的顺序一致,所以只要截取新的
|
||||
const newUsdtTxList = usdtTx.slice(fundList.length);
|
||||
return parseUsdtTx(newUsdtTxList);
|
||||
return parseETHTx(newUsdtTxList);
|
||||
};
|
||||
// vic
|
||||
const getNewDepositTx = (vicTx = [], fundList = []) => {
|
||||
if (fundList.length >= vicTx.length) return null;
|
||||
const newList = [];
|
||||
const existedFund = fundList.map(fund => fund.txHash).filter(f => f !== null);
|
||||
for (let i = 0, len = vicTx.length; i < len; ++i) {
|
||||
if (!existedFund.includes(vicTx[i].hash)) {
|
||||
newList.push(vicTx[i]);
|
||||
}
|
||||
}
|
||||
return parseETHTx(newList);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getVICTxList,
|
||||
getUSDTTxList,
|
||||
getNewDepositTx
|
||||
};
|
||||
Reference in New Issue
Block a user