xiongzhu 2 سال پیش
والد
کامیت
8f8525631c
2فایلهای تغییر یافته به همراه53 افزوده شده و 2 حذف شده
  1. 26 2
      src/accounts/entities/account.entity.ts
  2. 27 0
      src/web3/web3.service.ts

+ 26 - 2
src/accounts/entities/account.entity.ts

@@ -40,11 +40,35 @@ export class Account {
     swapNum: number
 
     @Column({ nullable: true })
-    bridgeNum: number
+    lastSwap: Date
 
     @Column({ nullable: true })
-    liuidityNum: number
+    offBridgeNum: number
+
+    @Column({ nullable: true })
+    lastOffBridge: Date
+
+    @Column({ nullable: true })
+    thirdBridgeNum: number
+
+    @Column({ nullable: true })
+    lastThirdBridge: Date
+
+    @Column({ nullable: true })
+    addLiuidityNum: number
+
+    @Column({ nullable: true })
+    lastAddLiuidity: Date
+
+    @Column({ nullable: true })
+    removeLiuidityNum: number
+
+    @Column({ nullable: true })
+    lastRemoveLiuidity: Date
 
     @Column({ nullable: true })
     mintNum: number
+
+    @Column({ nullable: true })
+    lastMint: Date
 }

+ 27 - 0
src/web3/web3.service.ts

@@ -65,6 +65,9 @@ export class Web3Service {
             amount: ethers.utils.parseEther(amount)
         })
         Logger.log('Deposit sent. Awaiting confirmation...')
+        account.offBridgeNum = (account.offBridgeNum || 0) + 1
+        account.lastOffBridge = new Date()
+        await this.accountService.save([account])
         return new Web3Result(account.address, deposit.hash, web3Config[account.network], false)
         // // Await processing of the deposit on L1
         // const ethereumTxReceipt = await deposit.waitL1Commit()
@@ -97,6 +100,9 @@ export class Web3Service {
             amount: ethers.utils.parseEther(amount)
         })
         Logger.log(`Widthdraw sent. ${web3Config[account.network].zksyncExplorer}/tx/${withdrawL2.hash}`)
+        account.offBridgeNum = (account.offBridgeNum || 0) + 1
+        account.lastOffBridge = new Date()
+        await this.accountService.save([account])
         return new Web3Result(account.address, withdrawL2.hash, web3Config[account.network], true)
         // // Await processing of the deposit on L1
         // const ethereumTxReceipt = await deposit.waitL1Commit()
@@ -128,6 +134,9 @@ export class Web3Service {
             to: web3Config[account.network].orbiterEthAddress,
             value: ethers.utils.parseEther(amount).add(web3Config[account.network].orbiterIdCodeZk)
         })
+        account.thirdBridgeNum = (account.thirdBridgeNum || 0) + 1
+        account.lastThirdBridge = new Date()
+        await this.accountService.save([account])
         return new Web3Result(account.address, tx.hash, web3Config[account.network], false)
     }
 
@@ -143,6 +152,9 @@ export class Web3Service {
             to: web3Config[account.network].orbiterZkAddress,
             value: ethers.utils.parseEther(amount).add(web3Config[account.network].orbiterIdCodeEth)
         })
+        account.thirdBridgeNum = (account.thirdBridgeNum || 0) + 1
+        account.lastThirdBridge = new Date()
+        await this.accountService.save([account])
         return new Web3Result(account.address, tx.hash, web3Config[account.network], true)
     }
 
@@ -265,6 +277,9 @@ export class Web3Service {
             gasLimit
         })
         Logger.log(`tx hash: ${tx.hash}`, 'addLiquidity')
+        account.addLiuidityNum = (account.addLiuidityNum || 0) + 1
+        account.lastAddLiuidity = new Date()
+        await this.accountService.save([account])
         return new Web3Result(account.address, tx.hash, web3Config[account.network], true)
     }
 
@@ -334,6 +349,9 @@ export class Web3Service {
             gasLimit
         })
         console.log('decLiquidityCalling tx: ', JSON.stringify(tx0, null, 4))
+        account.removeLiuidityNum = (account.removeLiuidityNum || 0) + 1
+        account.lastRemoveLiuidity = new Date()
+        await this.accountService.save([account])
         return new Web3Result(account.address, tx0.hash, web3Config[account.network], true)
     }
 
@@ -439,6 +457,9 @@ export class Web3Service {
             gasLimit
         })
         console.log(tx)
+        account.swapNum = (account.swapNum || 0) + 1
+        account.lastSwap = new Date()
+        await this.accountService.save([account])
         return new Web3Result(account.address, tx.hash, web3Config[account.network], true)
     }
 
@@ -504,6 +525,9 @@ export class Web3Service {
             gasLimit
         })
         console.log(JSON.stringify(tx, null, 4))
+        account.swapNum = (account.swapNum || 0) + 1
+        account.lastSwap = new Date()
+        await this.accountService.save([account])
         return new Web3Result(account.address, tx.hash, web3Config[account.network], true)
     }
 
@@ -555,6 +579,9 @@ export class Web3Service {
             gasLimit
         })
         console.log(tx)
+        account.mintNum = (account.mintNum || 0) + 1
+        account.lastMint = new Date()
+        await this.accountService.save([account])
         return new Web3Result(account.address, tx.hash, web3Config[account.network], true)
     }
 }