From 674ef92f65d97430c6742a1a28fc71f8a42b0ec3 Mon Sep 17 00:00:00 2001 From: Yevhen Shulha Date: Sat, 30 Sep 2023 23:46:49 +0300 Subject: [PATCH] fix: add pool deletion logging --- src/dex/algebra/algebra.ts | 8 +++++++- src/dex/pancakeswap-v3/pancakeswap-v3.ts | 8 +++++++- src/dex/uniswap-v3/uniswap-v3.ts | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/dex/algebra/algebra.ts b/src/dex/algebra/algebra.ts index 32efc8326..5bb393f83 100644 --- a/src/dex/algebra/algebra.ts +++ b/src/dex/algebra/algebra.ts @@ -165,15 +165,21 @@ export class Algebra extends SimpleExchange implements IDex { 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)]; diff --git a/src/dex/pancakeswap-v3/pancakeswap-v3.ts b/src/dex/pancakeswap-v3/pancakeswap-v3.ts index 5ec7d2183..62903a292 100644 --- a/src/dex/pancakeswap-v3/pancakeswap-v3.ts +++ b/src/dex/pancakeswap-v3/pancakeswap-v3.ts @@ -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)]; diff --git a/src/dex/uniswap-v3/uniswap-v3.ts b/src/dex/uniswap-v3/uniswap-v3.ts index 1f2a6b613..d4db7efaf 100644 --- a/src/dex/uniswap-v3/uniswap-v3.ts +++ b/src/dex/uniswap-v3/uniswap-v3.ts @@ -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)];