diff --git a/src/dex/algebra/algebra.ts b/src/dex/algebra/algebra.ts index 559d31092..daa4bc17d 100644 --- a/src/dex/algebra/algebra.ts +++ b/src/dex/algebra/algebra.ts @@ -69,10 +69,6 @@ const ALGEBRA_TICK_BASE_OVERHEAD = 75_000; const ALGEBRA_POOL_SEARCH_OVERHEAD = 10_000; const ALGEBRA_QUOTE_GASLIMIT = 2_000_000; -const MAX_STALE_STATE_BLOCK_AGE = { - [Network.ZKEVM]: 150, // approximately 3min -}; - type IAlgebraEventPool = | AlgebraEventPoolV1_1 | AlgebraEventPoolV1_9 @@ -240,20 +236,6 @@ export class Algebra extends SimpleExchange implements IDex { if (pool) { if (!pool.initFailed) { - if (this.network !== Network.ZKEVM) return pool; - - if ( - pool.getStaleState() === null || - (pool.getState(blockNumber) === null && - blockNumber - pool.getStateBlockNumber() > - MAX_STALE_STATE_BLOCK_AGE[this.network]) - ) { - /* reload state, on zkEVM this would most likely timeout during request life - * but would allow to rely on staleState for couple of min for next requests - */ - await pool.initialize(blockNumber, { forceRegenerate: true }); - } - return pool; } else { // if init failed then prefer to early return pool with empty state to fallback to rpc call @@ -615,37 +597,16 @@ export class Algebra extends SimpleExchange implements IDex { let state = pool.getState(blockNumber); if (state === null) { - if (this.network === Network.ZKEVM) { - if (pool.initFailed) return null; - - if ( - blockNumber - pool.getStateBlockNumber() <= - MAX_STALE_STATE_BLOCK_AGE[this.network] - ) { - this.logger.warn( - `${_srcAddress}_${_destAddress}_${pool.name}_${ - pool.poolAddress - } state fallback to latest early enough state. Current blockNumber=${blockNumber}, stateBlockNumber=${pool.getStateBlockNumber()}`, - ); - state = pool.getStaleState(); - } else { - this.logger.warn( - `${_srcAddress}_${_destAddress}_${pool.name}_${pool.poolAddress} state is unhealthy, cannot compute price (no fallback on this chain)`, - ); - return null; // never fallback as takes more time - } - } else { - const rpcPrice = await this.getPricingFromRpc( - _srcToken, - _destToken, - amounts, - side, - pool, - transferFees, - ); + const rpcPrice = await this.getPricingFromRpc( + _srcToken, + _destToken, + amounts, + side, + pool, + transferFees, + ); - return rpcPrice; - } + return rpcPrice; } if (!state) return null;