|
|
@@ -32,7 +32,7 @@ async function handlePosition(router: String, factory: String) {
|
|
|
async function handleAFactory(router: String, factory: String, position: number, pairsLength: number, v2_410_tool: any) {
|
|
|
let errorCount = 0
|
|
|
|
|
|
- while (true) {
|
|
|
+ while (position <= pairsLength) {
|
|
|
try {
|
|
|
const info = await v2_410_tool.methods.getPairIdInfo(factory, position++).call()
|
|
|
|
|
|
@@ -48,6 +48,11 @@ async function handleAFactory(router: String, factory: String, position: number,
|
|
|
// 8 pairInfo.r1
|
|
|
// );
|
|
|
|
|
|
+ const symbol0 = info['2'].replace(/[^A-Za-z0-9 ]+/g, '').substring(0, 10)
|
|
|
+ const symbol1 = info['6'].replace(/[^A-Za-z0-9 ]+/g, '').substring(0, 10)
|
|
|
+ const name = `${router.slice(2, 4) + router.slice(-2)}_${symbol0}_${symbol1}`
|
|
|
+ const sum2 = replaceAll(BigNumber.from(info['1']).add(BigNumber.from(info['5']))._hex, '0x0', '0x')
|
|
|
+
|
|
|
const data = {
|
|
|
LP: info['0'],
|
|
|
decimals0: info['3'],
|
|
|
@@ -55,13 +60,13 @@ async function handleAFactory(router: String, factory: String, position: number,
|
|
|
factory: factory,
|
|
|
feei: 30,
|
|
|
id: position,
|
|
|
- name: `${router.slice(2, 4) + router.slice(-2)}_${info['2']}_${info['6']}`,
|
|
|
+ name: name,
|
|
|
r0: info['4'],
|
|
|
r1: info['8'],
|
|
|
router: router,
|
|
|
- sum2: replaceAll(BigNumber.from(info['1']).add(BigNumber.from(info['5']))._hex, '0x0', '0x'),
|
|
|
- symbol0: info['2'],
|
|
|
- symbol1: info['6'],
|
|
|
+ sum2: sum2,
|
|
|
+ symbol0: symbol0,
|
|
|
+ symbol1: symbol1,
|
|
|
token0: info['1'],
|
|
|
token1: info['5']
|
|
|
}
|
|
|
@@ -88,6 +93,8 @@ async function handleAFactory(router: String, factory: String, position: number,
|
|
|
}
|
|
|
|
|
|
async function main() {
|
|
|
+ const fromZero: boolean = true
|
|
|
+
|
|
|
logger.debug('Pull v2 start.')
|
|
|
|
|
|
const v2_router_abi = require('../abi/UNIV2_ROUTER_ABI.json')
|
|
|
@@ -111,7 +118,7 @@ async function main() {
|
|
|
// 获取当前pairsLength
|
|
|
const pairsLength = await v2_factory.methods.allPairsLength().call()
|
|
|
// 获取当前pull状态
|
|
|
- const position = await handlePosition(v2_router_address, v2_factory_address)
|
|
|
+ const position = fromZero ? 0 : await handlePosition(v2_router_address, v2_factory_address)
|
|
|
|
|
|
logger.debug(`factory: ${v2_factory_address}, ${position} / ${pairsLength}.`)
|
|
|
await handleAFactory(v2_router_address, v2_factory_address, position, pairsLength, v2_410_tool)
|