فهرست منبع

池子数据拉下来了

skyfffire 3 سال پیش
والد
کامیت
2f95c0ca93
7فایلهای تغییر یافته به همراه75 افزوده شده و 4 حذف شده
  1. 0 0
      config/v2PoolList.json
  2. 0 0
      config/v3PoolList.json
  3. 16 0
      scripts/calcLevel2Path.ts
  4. 5 2
      scripts/interface/history.ts
  5. 1 1
      scripts/pushv2.ts
  6. 1 1
      scripts/pushv3.ts
  7. 52 0
      test/PullPoolTest.ts

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
config/v2PoolList.json


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
config/v3PoolList.json


+ 16 - 0
scripts/calcLevel2Path.ts

@@ -0,0 +1,16 @@
+import { web3 } from "hardhat";
+import History from "./interface/history";
+import contracts from "../config/contracts";
+import logger from "../utils/logger";
+import v2_routers from "../config/v2_routers";
+import {BigNumber} from "ethers";
+import {replaceAll} from "hardhat/internal/util/strings";
+
+async function main() {
+
+}
+
+main().catch((error) => {
+  console.error(error);
+  process.exitCode = 1;
+})

+ 5 - 2
scripts/interface/history.ts

@@ -1,12 +1,15 @@
 import http from '../../utils/http'
 
 export default class History {
-  static async findByHashOrBlockOrDataVague(block: String, hashCode: String, dataVague: String) {
+  static async findByHashOrBlockOrDataVague(block: String, hashCode: String, dataVague: String,
+                                            limit1: Number, limit2: Number) {
     let url = '/ethmev/findByHashOrBlockOrDataVague'
     const rst = await http.post(url, {
       block: block,
       hash: hashCode,
-      dataVague: dataVague
+      dataVague: dataVague,
+      limit1: limit1,
+      limit2: limit2
     })
     return rst.data
   }

+ 1 - 1
scripts/pullv2.ts → scripts/pushv2.ts

@@ -9,7 +9,7 @@ import {replaceAll} from "hardhat/internal/util/strings";
 async function handlePosition(router: String, factory: String) {
   try {
     // 拉取当前pull状态信息
-    const pullState = await History.findByHashOrBlockOrDataVague('UNIV2DEX', factory, '')
+    const pullState = await History.findByHashOrBlockOrDataVague('UNIV2DEX', factory, '', 0, 200)
     let nowPosition = 0
 
     // 没有状态信息的情况

+ 1 - 1
scripts/pullv3.ts → scripts/pushv3.ts

@@ -9,7 +9,7 @@ import {replaceAll} from "hardhat/internal/util/strings";
 async function handlePosition(router: String, factory: String) {
   try {
     // 拉取当前pull状态信息
-    const pullState = await History.findByHashOrBlockOrDataVague('UNIV3DEX', factory, '')
+    const pullState = await History.findByHashOrBlockOrDataVague('UNIV3DEX', factory, '', 0, 200)
     let nowPosition = 0
 
     // 没有状态信息的情况

+ 52 - 0
test/PullPoolTest.ts

@@ -0,0 +1,52 @@
+import history from '../scripts/interface/history'
+import contracts from "../config/contracts";
+import logger from "../utils/logger";
+import v2_routers from "../config/v2_routers";
+import fs from 'fs'
+
+describe('Pull pool test', () => {
+  it ('pull v3', async () => {
+    logger.debug('start pull v3')
+    const rst = await history.findByHashOrBlockOrDataVague('0', '', contracts.UNIV3, 0, 3000)
+
+    logger.debug(rst.msg)
+    const v3PoolList = []
+    for (let v3Index in rst.data) {
+      let v3Lp = rst.data[v3Index].dataObj
+      v3PoolList.push(v3Lp)
+    }
+    logger.debug(v3PoolList.length)
+
+    fs.writeFile('./config/v3PoolList.json', JSON.stringify(v3PoolList), (err) => {
+      if (err) {
+        logger.error(err)
+      } else {
+        logger.debug("File written successfully\n")
+      }
+    })
+  })
+
+  it ('pull v2', async () => {
+    logger.debug('start pull v2')
+
+    const v2PoolList = []
+    for (let v2RouterIndex in v2_routers) {
+      const rst = await history.findByHashOrBlockOrDataVague('0', '', v2_routers[v2RouterIndex], 0, 110000)
+
+      logger.debug(v2_routers[v2RouterIndex])
+      for (let v2Index in rst.data) {
+        let v2Lp = rst.data[v2Index].dataObj
+        v2PoolList.push(v2Lp)
+      }
+    }
+    logger.debug(v2PoolList.length)
+
+    fs.writeFile('./config/v2PoolList.json', JSON.stringify(v2PoolList), (err) => {
+      if (err) {
+        logger.error(err);
+      } else {
+        logger.debug("File written successfully\n");
+      }
+    })
+  })
+})

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است