@@ -5,7 +5,7 @@ import { EntityManager } from 'typeorm';
55import { dbService , eventService , operationWs } from '../indexerServices' ;
66import { LiquidityPoolTick } from '../db/entities/LiquidityPoolTick' ;
77import { TickInterval } from '../constants' ;
8- import { logInfo } from '../logger' ;
8+ import { logError , logInfo } from '../logger' ;
99
1010export class UpdateLiquidityPoolTicks extends BaseJob {
1111
@@ -22,15 +22,17 @@ export class UpdateLiquidityPoolTicks extends BaseJob {
2222
2323 const slotDate : Date = new Date ( lucidUtils . slotToUnixTime ( this . _liquidityPoolState . slot ) ) ;
2424
25- const startOfMinute : number = new Date ( slotDate . getUTCFullYear ( ) , slotDate . getUTCMonth ( ) , slotDate . getUTCDate ( ) , slotDate . getUTCHours ( ) , slotDate . getUTCMinutes ( ) , 0 , 0 ) . getTime ( ) / 1000 ;
26- const startOfHour : number = new Date ( slotDate . getUTCFullYear ( ) , slotDate . getUTCMonth ( ) , slotDate . getUTCDate ( ) , slotDate . getUTCHours ( ) , 0 , 0 , 0 ) . getTime ( ) / 1000 ;
27- const startOfDay : number = new Date ( slotDate . getUTCFullYear ( ) , slotDate . getUTCMonth ( ) , slotDate . getUTCDate ( ) , 0 , 0 , 0 , 0 ) . getTime ( ) / 1000 ;
25+ const startOfMinute : number = new Date ( slotDate . getFullYear ( ) , slotDate . getMonth ( ) , slotDate . getDate ( ) , slotDate . getHours ( ) , slotDate . getMinutes ( ) , 0 , 0 ) . getTime ( ) / 1000 ;
26+ const startOfHour : number = new Date ( slotDate . getFullYear ( ) , slotDate . getMonth ( ) , slotDate . getDate ( ) , slotDate . getHours ( ) , 0 , 0 , 0 ) . getTime ( ) / 1000 ;
27+ const startOfDay : number = new Date ( slotDate . getFullYear ( ) , slotDate . getMonth ( ) , slotDate . getDate ( ) , 0 , 0 , 0 , 0 ) . getTime ( ) / 1000 ;
2828
2929 return Promise . all ( [
3030 this . createOrUpdateTick ( startOfMinute , TickInterval . Minute ) ,
3131 this . createOrUpdateTick ( startOfHour , TickInterval . Hour ) ,
3232 this . createOrUpdateTick ( startOfDay , TickInterval . Day )
33- ] ) ;
33+ ] ) . catch ( ( reason ) => {
34+ logError ( `[Queue] \t UpdateLiquidityPoolTicks failed ${ reason } ` ) ;
35+ } ) ;
3436 }
3537
3638 private async createOrUpdateTick ( startOfTick : number , resolution : TickInterval ) : Promise < any > {
@@ -58,12 +60,16 @@ export class UpdateLiquidityPoolTicks extends BaseJob {
5860 . limit ( 1 )
5961 . getOne ( ) ?? undefined ;
6062 } ) ;
61-
63+ if ( this . _liquidityPoolState . liquidityPool . identifier === 'f5808c2c990d86da54bfc97d89cee6efa20cd8461616359478d96b4c9b65707373c4cec488b16151a64d7102dbae16857c500652b5c513650b8d604e' ) {
64+ logInfo ( `ddddd here 1` )
65+ }
6266 if ( ! existingTick ) {
6367 if ( ! this . _liquidityPoolState . liquidityPool ) {
6468 return Promise . reject ( 'Liquidity Pool not found for liquidity pool state' ) ;
6569 }
66-
70+ if ( this . _liquidityPoolState . liquidityPool . identifier === 'f5808c2c990d86da54bfc97d89cee6efa20cd8461616359478d96b4c9b65707373c4cec488b16151a64d7102dbae16857c500652b5c513650b8d604e' ) {
71+ logInfo ( `ddddd here 2` )
72+ }
6773 const lastTick : LiquidityPoolTick | undefined = await dbService . query ( ( manager : EntityManager ) => {
6874 return manager . createQueryBuilder ( LiquidityPoolTick , 'ticks' )
6975 . where ( 'resolution = :resolution' , { resolution } )
@@ -76,7 +82,9 @@ export class UpdateLiquidityPoolTicks extends BaseJob {
7682 } ) ;
7783
7884 const open : number = lastTick ? lastTick . close : price ;
79-
85+ if ( this . _liquidityPoolState . liquidityPool . identifier === 'f5808c2c990d86da54bfc97d89cee6efa20cd8461616359478d96b4c9b65707373c4cec488b16151a64d7102dbae16857c500652b5c513650b8d604e' ) {
86+ logInfo ( `ddddd here 3 ${ Math . abs ( lastTick ? this . _liquidityPoolState . tvl - lastTick . tvl : this . _liquidityPoolState . tvl ) } ` )
87+ }
8088 return dbService . transaction ( ( manager : EntityManager ) => {
8189 return manager . save (
8290 LiquidityPoolTick . make (
@@ -92,17 +100,21 @@ export class UpdateLiquidityPoolTicks extends BaseJob {
92100 )
93101 ) . then ( ( tick : LiquidityPoolTick ) => {
94102 operationWs . broadcast ( tick ) ;
95-
103+ if ( this . _liquidityPoolState . liquidityPool . identifier === 'f5808c2c990d86da54bfc97d89cee6efa20cd8461616359478d96b4c9b65707373c4cec488b16151a64d7102dbae16857c500652b5c513650b8d604e' ) {
104+ logInfo ( `ddddd here 3.5 ${ tick . time } ` )
105+ }
96106 eventService . pushEvent ( {
97107 type : 'LiquidityPoolTickCreated' ,
98108 data : tick ,
99109 } ) ;
100110
101111 return Promise . resolve ( ) ;
102- } ) . catch ( ( ) => this . createOrUpdateTick ( startOfTick , resolution ) ) ;
112+ } ) . catch ( ( reason : any ) => this . createOrUpdateTick ( startOfTick , resolution ) ) ;
103113 } ) ;
104114 }
105-
115+ if ( this . _liquidityPoolState . liquidityPool . identifier === 'f5808c2c990d86da54bfc97d89cee6efa20cd8461616359478d96b4c9b65707373c4cec488b16151a64d7102dbae16857c500652b5c513650b8d604e' ) {
116+ logInfo ( `ddddd here 4` )
117+ }
106118 if ( price < existingTick . low ) {
107119 existingTick . low = price ;
108120 }
@@ -119,7 +131,9 @@ export class UpdateLiquidityPoolTicks extends BaseJob {
119131 return manager . save ( existingTick )
120132 . then ( ( tick : LiquidityPoolTick ) => {
121133 operationWs . broadcast ( tick ) ;
122-
134+ if ( this . _liquidityPoolState . liquidityPool . identifier === 'f5808c2c990d86da54bfc97d89cee6efa20cd8461616359478d96b4c9b65707373c4cec488b16151a64d7102dbae16857c500652b5c513650b8d604e' ) {
135+ logInfo ( `ddddd here 5` )
136+ }
123137 eventService . pushEvent ( {
124138 type : 'LiquidityPoolTickUpdated' ,
125139 data : tick ,
0 commit comments