Skip to content

Commit

Permalink
fix: add pool deletion logging
Browse files Browse the repository at this point in the history
  • Loading branch information
JackieJoo committed Sep 30, 2023
1 parent de231db commit 674ef92
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/dex/algebra/algebra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,21 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
token0,
token1,
}) => {
const logPrefix = '[Algebra.onPoolCreatedDeleteFromNonExistingSet]';
const [_token0, _token1] = this._sortTokens(token0, token1);
const poolKey = `${token0}_${token1}`.toLowerCase();

// consider doing it only from master pool for less calls to distant cache

try {
this.logger.info(
`${logPrefix} delete pool from not existing set: ${poolKey}`,
);
// delete pool record from set
await this.dexHelper.cache.zrem(this.notExistingPoolSetKey, [poolKey]);
} catch (e) {}
} catch (e) {
this.logger.error(`${logPrefix} ERROR deleting pool: ${poolKey}`);
}

// delete entry locally to let local instance discover the pool
delete this.eventPools[this.getPoolIdentifier(_token0, _token1)];
Expand Down
8 changes: 7 additions & 1 deletion src/dex/pancakeswap-v3/pancakeswap-v3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,21 @@ export class PancakeswapV3
token1,
fee,
}) => {
const logPrefix = '[PancakeV3.onPoolCreatedDeleteFromNonExistingSet]';
const [_token0, _token1] = this._sortTokens(token0, token1);
const poolKey = `${token0}_${token1}_${fee}`.toLowerCase();

// consider doing it only from master pool for less calls to distant cache

try {
this.logger.info(
`${logPrefix} delete pool from not existing set: ${poolKey}`,
);
// delete pool record from set
await this.dexHelper.cache.zrem(this.notExistingPoolSetKey, [poolKey]);
} catch (e) {}
} catch (e) {
this.logger.error(`${logPrefix} ERROR deleting pool: ${poolKey}`);
}

// delete entry locally to let local instance discover the pool
delete this.eventPools[this.getPoolIdentifier(_token0, _token1, fee)];
Expand Down
8 changes: 7 additions & 1 deletion src/dex/uniswap-v3/uniswap-v3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,21 @@ export class UniswapV3
token1,
fee,
}) => {
const logPrefix = '[UniswapV3.onPoolCreatedDeleteFromNonExistingSet]';
const [_token0, _token1] = this._sortTokens(token0, token1);
const poolKey = `${token0}_${token1}_${fee}`.toLowerCase();

// consider doing it only from master pool for less calls to distant cache

try {
this.logger.info(
`${logPrefix} delete pool from not existing set: ${poolKey}`,
);
// delete pool record from set
await this.dexHelper.cache.zrem(this.notExistingPoolSetKey, [poolKey]);
} catch (e) {}
} catch (e) {
this.logger.error(`${logPrefix} ERROR deleting pool: ${poolKey}`);
}

// delete entry locally to let local instance discover the pool
delete this.eventPools[this.getPoolIdentifier(_token0, _token1, fee)];
Expand Down

0 comments on commit 674ef92

Please sign in to comment.