Skip to content

Commit befa9da

Browse files
committed
Asset/Asset pools TVL
1 parent d9915e5 commit befa9da

File tree

2 files changed

+10
-25
lines changed

2 files changed

+10
-25
lines changed

src/jobs/UpdateLiquidityPoolTicks.ts

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,12 @@ export class UpdateLiquidityPoolTicks extends BaseJob {
6060
.limit(1)
6161
.getOne() ?? undefined;
6262
});
63-
if (this._liquidityPoolState.liquidityPool.identifier === 'f5808c2c990d86da54bfc97d89cee6efa20cd8461616359478d96b4c9b65707373c4cec488b16151a64d7102dbae16857c500652b5c513650b8d604e') {
64-
logInfo(`ddddd here 1`)
65-
}
63+
6664
if (! existingTick) {
6765
if (! this._liquidityPoolState.liquidityPool) {
6866
return Promise.reject('Liquidity Pool not found for liquidity pool state');
6967
}
70-
if (this._liquidityPoolState.liquidityPool.identifier === 'f5808c2c990d86da54bfc97d89cee6efa20cd8461616359478d96b4c9b65707373c4cec488b16151a64d7102dbae16857c500652b5c513650b8d604e') {
71-
logInfo(`ddddd here 2`)
72-
}
68+
7369
const lastTick: LiquidityPoolTick | undefined = await dbService.query((manager: EntityManager) => {
7470
return manager.createQueryBuilder(LiquidityPoolTick, 'ticks')
7571
.where('resolution = :resolution', { resolution })
@@ -82,9 +78,7 @@ logInfo(`ddddd here 2`)
8278
});
8379

8480
const open: number = lastTick ? lastTick.close : price;
85-
if (this._liquidityPoolState.liquidityPool.identifier === 'f5808c2c990d86da54bfc97d89cee6efa20cd8461616359478d96b4c9b65707373c4cec488b16151a64d7102dbae16857c500652b5c513650b8d604e') {
86-
logInfo(`ddddd here 3 ${Math.abs(lastTick ? this._liquidityPoolState.tvl - lastTick.tvl : this._liquidityPoolState.tvl)}`)
87-
}
81+
8882
return dbService.transaction((manager: EntityManager) => {
8983
return manager.save(
9084
LiquidityPoolTick.make(
@@ -100,9 +94,7 @@ logInfo(`ddddd here 3 ${Math.abs(lastTick ? this._liquidityPoolState.tvl - lastT
10094
)
10195
).then((tick: LiquidityPoolTick) => {
10296
operationWs.broadcast(tick);
103-
if (this._liquidityPoolState.liquidityPool.identifier === 'f5808c2c990d86da54bfc97d89cee6efa20cd8461616359478d96b4c9b65707373c4cec488b16151a64d7102dbae16857c500652b5c513650b8d604e') {
104-
logInfo(`ddddd here 3.5 ${tick.time}`)
105-
}
97+
10698
eventService.pushEvent({
10799
type: 'LiquidityPoolTickCreated',
108100
data: tick,
@@ -112,9 +104,7 @@ logInfo(`ddddd here 3.5 ${tick.time}`)
112104
}).catch((reason: any) => this.createOrUpdateTick(startOfTick, resolution));
113105
});
114106
}
115-
if (this._liquidityPoolState.liquidityPool.identifier === 'f5808c2c990d86da54bfc97d89cee6efa20cd8461616359478d96b4c9b65707373c4cec488b16151a64d7102dbae16857c500652b5c513650b8d604e') {
116-
logInfo(`ddddd here 4`)
117-
}
107+
118108
if (price < existingTick.low) {
119109
existingTick.low = price;
120110
}
@@ -131,9 +121,7 @@ logInfo(`ddddd here 4`)
131121
return manager.save(existingTick)
132122
.then((tick: LiquidityPoolTick) => {
133123
operationWs.broadcast(tick);
134-
if (this._liquidityPoolState.liquidityPool.identifier === 'f5808c2c990d86da54bfc97d89cee6efa20cd8461616359478d96b4c9b65707373c4cec488b16151a64d7102dbae16857c500652b5c513650b8d604e') {
135-
logInfo(`ddddd here 5`)
136-
}
124+
137125
eventService.pushEvent({
138126
type: 'LiquidityPoolTickUpdated',
139127
data: tick,

src/jobs/UpdateLiquidityPoolTvlJob.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { BaseJob } from './BaseJob';
22
import { LiquidityPoolState } from '../db/entities/LiquidityPoolState';
33
import { dbService, queue } from '../indexerServices';
4-
import { EntityManager } from 'typeorm';
4+
import { Brackets, EntityManager } from 'typeorm';
55
import { LiquidityPool } from '../db/entities/LiquidityPool';
66
import { logInfo } from '../logger';
77
import { Asset } from '../db/entities/Asset';
@@ -55,14 +55,11 @@ export class UpdateLiquidityPoolTvlJob extends BaseJob {
5555
.leftJoinAndSelect('pools.tokenA', 'tokenA')
5656
.leftJoinAndSelect('pools.tokenB', 'tokenB')
5757
.leftJoinAndSelect('pools.latestState', 'latestState')
58-
.where("pools.dex = :dex", {
59-
dex: liquidityPool.dex,
60-
})
61-
.andWhere('pools.tokenA IS NULL')
62-
.andWhere("pools.tokenB.id = :tokenBId", {
58+
.where('pools.tokenA IS NULL')
59+
.andWhere('pools.tokenB.id = :tokenBId', {
6360
tokenBId: token.id,
6461
})
65-
.orderBy('pools.createdSlot', 'DESC')
62+
.orderBy('latestState.tvl', 'DESC')
6663
.limit(1)
6764
.getOne();
6865
});

0 commit comments

Comments
 (0)