|
@@ -4,15 +4,14 @@ import contracts from "../../config/contracts";
|
|
|
import logger from "../../utils/logger";
|
|
import logger from "../../utils/logger";
|
|
|
import {BigNumber} from "ethers";
|
|
import {BigNumber} from "ethers";
|
|
|
import {replaceAll} from "hardhat/internal/util/strings";
|
|
import {replaceAll} from "hardhat/internal/util/strings";
|
|
|
-import swapPath from "../interface/swapPath";
|
|
|
|
|
import history from "../interface/history";
|
|
import history from "../interface/history";
|
|
|
-import {LpMaintenance} from "./lpMaintenance";
|
|
|
|
|
import Time from "../../utils/time";
|
|
import Time from "../../utils/time";
|
|
|
|
|
+import MemoryUtils from "../../utils/memory";
|
|
|
const ierc20abi = require('../../abi/IERC20_ABI.json')
|
|
const ierc20abi = require('../../abi/IERC20_ABI.json')
|
|
|
|
|
|
|
|
export class LpGenerate {
|
|
export class LpGenerate {
|
|
|
tokenInstance: any = {}
|
|
tokenInstance: any = {}
|
|
|
- maxMemoryOfByte: number = 0
|
|
|
|
|
|
|
+ memoryUtils: MemoryUtils = new MemoryUtils()
|
|
|
|
|
|
|
|
async handlePosition(routerObj: any) {
|
|
async handlePosition(routerObj: any) {
|
|
|
const block = routerObj.type === 'univ2' ? 'UNIV2DEX' : 'UNIV3DEX'
|
|
const block = routerObj.type === 'univ2' ? 'UNIV2DEX' : 'UNIV3DEX'
|
|
@@ -161,16 +160,6 @@ export class LpGenerate {
|
|
|
return router.positionManager
|
|
return router.positionManager
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- async checkPosition(pm: any, position: any) {
|
|
|
|
|
- try {
|
|
|
|
|
- await pm.methods.positions(position).call()
|
|
|
|
|
-
|
|
|
|
|
- return true
|
|
|
|
|
- } catch (e) {
|
|
|
|
|
- return false
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
// 二分法查length
|
|
// 二分法查length
|
|
|
async getPositionLength(pm: any, low: number) {
|
|
async getPositionLength(pm: any, low: number) {
|
|
|
let high = low + 8
|
|
let high = low + 8
|
|
@@ -207,7 +196,6 @@ export class LpGenerate {
|
|
|
return 'ok'
|
|
return 'ok'
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- let count = 0
|
|
|
|
|
while (true) {
|
|
while (true) {
|
|
|
let checkRst = await check(checkNumber)
|
|
let checkRst = await check(checkNumber)
|
|
|
// logger.debug(`[${low}, ${high}], c: ${checkNumber}, ${checkRst}. [${++count}]`)
|
|
// logger.debug(`[${low}, ${high}], c: ${checkNumber}, ${checkRst}. [${++count}]`)
|
|
@@ -276,23 +264,13 @@ export class LpGenerate {
|
|
|
await this.saveToken(lp, 'token')
|
|
await this.saveToken(lp, 'token')
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const memoryUsage = process.memoryUsage()
|
|
|
|
|
- if (this.maxMemoryOfByte < memoryUsage.rss) {
|
|
|
|
|
- this.maxMemoryOfByte = memoryUsage.rss
|
|
|
|
|
- }
|
|
|
|
|
if (lp) {
|
|
if (lp) {
|
|
|
- logger.debug(`${position + 1} / ${pairsLength}, ${lp.name}-${lp.LP}-${routerObj.chain}`
|
|
|
|
|
- + ` ${this.format(memoryUsage.rss)}/${this.format(this.maxMemoryOfByte)}`)
|
|
|
|
|
|
|
+ this.memoryUtils.logWithMemoryOnMemoryChange(`${position + 1} / ${pairsLength}, ${lp.name}-${lp.LP}-${routerObj.chain}`)
|
|
|
} else {
|
|
} else {
|
|
|
- logger.debug(`lp get filed. ${position + 1} / ${pairsLength}, ${routerObj.name}-${routerObj.router}-${routerObj.chain}`
|
|
|
|
|
- + ` ${this.format(memoryUsage.rss)}/${this.format(this.maxMemoryOfByte)}`)
|
|
|
|
|
|
|
+ this.memoryUtils.logWithMemoryOnMemoryChange(`lp get filed. ${position + 1} / ${pairsLength}, ${routerObj.name}-${routerObj.router}-${routerObj.chain}`)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- format (bytes: any) {
|
|
|
|
|
- return (bytes / 1024 / 1024).toFixed(2) + ' MB';
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
async run() {
|
|
async run() {
|
|
|
logger.debug('Pull lp start.')
|
|
logger.debug('Pull lp start.')
|
|
|
|
|
|