index.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. const ChainLib = require("../lib/chain-lib");
  2. const Web3Utils = require("../../utils/web3-utils");
  3. const logger = require("../../utils/logger");
  4. const Time = require("../../utils/time");
  5. const LpLib = require("../lib/lp-lib");
  6. class LpMaintenance {
  7. constructor(web3, chain) {
  8. this.web3 = web3
  9. this.chain = chain
  10. // 初始化依赖库
  11. this.lpLib = new LpLib(this.web3, this.chain)
  12. }
  13. async tick() {
  14. }
  15. async run() {
  16. logger.debug(`${this.chain.networkName} liquidity pool maintenance is start.`)
  17. logger.debug(`web3 is connected, block number: ${await this.web3.eth.getBlockNumber()}.`)
  18. // 3. 开始处理
  19. while (true) {
  20. try {
  21. await this.tick()
  22. } catch (e) {
  23. logger.error(e)
  24. }
  25. await Time.delay(1000)
  26. }
  27. }
  28. }
  29. async function main() {
  30. const chain = await ChainLib.getChainFromCommand()
  31. const web3 = Web3Utils.autoCreate(chain)
  32. const generator = new LpMaintenance(web3, chain)
  33. await generator.run()
  34. }
  35. main().catch((error) => {
  36. console.error(error);
  37. process.exitCode = 1;
  38. })