龚成明 3 years ago
parent
commit
847ae7c572
1 changed files with 6 additions and 5 deletions
  1. 6 5
      scripts/ready/pushv2.ts

+ 6 - 5
scripts/ready/pushv2.ts

@@ -35,7 +35,7 @@ async function handlePosition(router: String, factory: String) {
 async function handleAFactory(routerObj: any, position: number, pairsLength: number, v2_410_tool: any) {
   const lpList: any = []
 
-  while (position < pairsLength) {
+  while (position + 1 < pairsLength) {
     try {
       const info = await v2_410_tool.methods.getPairIdInfo(routerObj.factory, position).call()
 
@@ -63,7 +63,7 @@ async function handleAFactory(routerObj: any, position: number, pairsLength: num
         isEthW: routerObj.type == 'ETHW'
       }
       const insertRst = await History.appendOrUpdate('0', info['0'], data)
-      logger.debug(`insert lp:${insertRst.msg}, hash: ${info['0']}, ${position} / ${pairsLength}`)
+      logger.debug(`insert lp:${insertRst.msg}, hash: ${info['0']}, ${position + 1} / ${pairsLength}`)
       lpList.push(data)
 
       // 更新一次position
@@ -87,11 +87,12 @@ async function getAllLp(v2Router: any, fromZero: boolean, v2_410_tool: any, v2_f
     // 获取当前pull状态
     const position = fromZero ? 0 : await handlePosition(v2Router.router, v2_factory_address)
 
-    if (position < pairsLength) {
+    if (position + 1 < pairsLength) {
       logger.debug(`Router address: ${v2Router.router}`)
       logger.debug(`factory: ${v2_factory_address}, ${position} / ${pairsLength}.`)
+
+      return await handleAFactory(v2Router, position, pairsLength, v2_410_tool)
     }
-    return await handleAFactory(v2Router, position, pairsLength, v2_410_tool)
   } catch (e) {
     logger.error(`New contract error, router: ${v2Router.router}`)
     logger.error(e)
@@ -151,7 +152,7 @@ async function saveToken(lpList: any) {
       logger.debug(`${token.name} ${saveRst.msg}`)
     } catch (e) {}
 
-    logger.debug(`insert token: ${lpIndex + 1} / ${lpList.length}`)
+    logger.debug(`insert token: ${parseInt(lpIndex) + 1} / ${lpList.length}`)
   }
 }