Sfoglia il codice sorgente

同一hash既是token又是lp的情况,以lp优先

skyfffire 3 anni fa
parent
commit
526c84a1f1
2 ha cambiato i file con 16 aggiunte e 6 eliminazioni
  1. 12 2
      scripts/lp/lpGenerate.ts
  2. 4 4
      scripts/path/level2Generate.ts

+ 12 - 2
scripts/lp/lpGenerate.ts

@@ -11,6 +11,7 @@ const ierc20abi = require('../../abi/IERC20_ABI.json')
 
 export class LpGenerate {
   tokenInstance: any = {}
+  lpInstance: any = {}
   memoryUtils: MemoryUtils = new MemoryUtils()
 
   async handlePosition(routerObj: any) {
@@ -130,17 +131,26 @@ export class LpGenerate {
     try {
       const token = await this.handleToken(lp, true)
 
-      await history.appendOrUpdate(type, token.address, token)
+      // token的hash不同时为lp的情况才更新
+      if (!this.lpInstance[token.address]) {
+        await history.appendOrUpdate(type, token.address, token)
+      }
     } catch (e) {}
 
     try {
       const token = await this.handleToken(lp, false)
 
-      await history.appendOrUpdate(type, token.address, token)
+      // token的hash不同时为lp的情况才更新
+      if (!this.lpInstance[token.address]) {
+        await history.appendOrUpdate(type, token.address, token)
+      }
     } catch (e) {}
   }
 
   async saveLp(lp: any, type='0') {
+    // 本地lp实例存档
+    this.lpInstance[lp.LP] = lp
+
     await History.appendOrUpdate(type, lp.LP, lp)
   }
 

+ 4 - 4
scripts/path/level2Generate.ts

@@ -71,10 +71,10 @@ class Level2Generate {
         const topLpPullRst = await history.findByBlock('topLp')
         if (!topLpPullRst.state) continue
         const topLpList = topLpPullRst.data
-        // const normalLpPullRst = await history.findByBlock('normalLp')
-        // if (!normalLpPullRst.state) continue
-        // const normalLpList = normalLpPullRst.data
-        const normalLpList: any = []
+        const normalLpPullRst = await history.findByBlock('normalLp')
+        if (!normalLpPullRst.state) continue
+        const normalLpList = normalLpPullRst.data
+        // const normalLpList: any = []
 
         const allTypeLpList: any = topLpList.concat(normalLpList)