Ver código fonte

基础过滤

龚成明 3 anos atrás
pai
commit
69f0c8c2fa
1 arquivos alterados com 23 adições e 4 exclusões
  1. 23 4
      scripts/ready/pushv2FromHead.ts

+ 23 - 4
scripts/ready/pushv2FromHead.ts

@@ -156,6 +156,24 @@ async function saveToken(lpList: any) {
   }
 }
 
+async function filterLp(lpList: any) {
+  const filteredLpList: any = []
+
+  for (let lpIndex in lpList) {
+    const lp = lpList[lpIndex]
+
+    if (lp.token0.toLowerCase() === '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2') {
+      if (parseInt(lp.r0) > 20 * 1e18) filteredLpList.push(filteredLpList)
+    } else if (lp.token1.toLowerCase() === '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2') {
+      if (parseInt(lp.r1) > 20 * 1e18) filteredLpList.push(filteredLpList)
+    } else {
+      filteredLpList.push(lp)
+    }
+  }
+
+  return filteredLpList
+}
+
 async function main() {
   logger.debug('Pull v2 start.')
 
@@ -170,12 +188,13 @@ async function main() {
   while (true) {
     for (let router_index = 0; router_index < v2RouterInfo.length; router_index++) {
       // 1. 获取Lp
-      const lpList = await getAllLp(v2RouterInfo[router_index], fromZero, v2_410_tool, v2_factory_abi)
-      // 2. 将Lp保存到二阶表
+      let lpList = await getAllLp(v2RouterInfo[router_index], fromZero, v2_410_tool, v2_factory_abi)
+      // 2. 过滤Lp
+      lpList = await filterLp(lpList)
+      // 3. 将Lp保存到二阶表
       await saveLpToSwapPath(lpList)
-      // 3. 保存Lp的Token到Token表
+      // 4. 保存Lp的Token到Token表
       await saveToken(lpList)
-      // 4. 过滤Lp
       // 5. 保存Lp的Token到TopToken表
 
       if (lpList.length > 0) {