diff --git a/package.json b/package.json index 7e58a27be..2d306b41d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paraswap/dex-lib", - "version": "2.37.4", + "version": "2.37.5", "main": "build/index.js", "types": "build/index.d.ts", "repository": "https://github.com/paraswap/paraswap-dex-lib", diff --git a/src/dex/algebra/algebra-factory.ts b/src/dex/algebra/algebra-factory.ts index 1650878ad..41de2a014 100644 --- a/src/dex/algebra/algebra-factory.ts +++ b/src/dex/algebra/algebra-factory.ts @@ -62,8 +62,8 @@ export class AlgebraFactory extends StatefulEventSubscriber { } async handleNewPool(event: LogDescription) { - const token0 = event.args.token0; - const token1 = event.args.token1; + const token0 = event.args.token0.toLowerCase(); + const token1 = event.args.token1.toLowerCase(); await this.onPoolCreated({ token0, token1 }); } diff --git a/src/dex/algebra/algebra.ts b/src/dex/algebra/algebra.ts index 726cb669d..42ad77520 100644 --- a/src/dex/algebra/algebra.ts +++ b/src/dex/algebra/algebra.ts @@ -167,7 +167,7 @@ export class Algebra extends SimpleExchange implements IDex { }) => { const logPrefix = '[Algebra.onPoolCreatedDeleteFromNonExistingSet]'; const [_token0, _token1] = this._sortTokens(token0, token1); - const poolKey = `${token0}_${token1}`.toLowerCase(); + const poolKey = `${_token0}_${_token1}`; // consider doing it only from master pool for less calls to distant cache diff --git a/src/dex/pancakeswap-v3/pancakeswap-v3-factory.ts b/src/dex/pancakeswap-v3/pancakeswap-v3-factory.ts index 8bfc7a46b..5b60cb025 100644 --- a/src/dex/pancakeswap-v3/pancakeswap-v3-factory.ts +++ b/src/dex/pancakeswap-v3/pancakeswap-v3-factory.ts @@ -64,8 +64,8 @@ export class PancakeswapV3Factory extends StatefulEventSubscriber } async handleNewPool(event: LogDescription) { - const token0 = event.args.token0; - const token1 = event.args.token1; + const token0 = event.args.token0.toLowerCase(); + const token1 = event.args.token1.toLowerCase(); const fee = event.args.fee; await this.onPoolCreated({ token0, token1, fee }); diff --git a/src/dex/pancakeswap-v3/pancakeswap-v3.ts b/src/dex/pancakeswap-v3/pancakeswap-v3.ts index 1e4013edd..be08718f7 100644 --- a/src/dex/pancakeswap-v3/pancakeswap-v3.ts +++ b/src/dex/pancakeswap-v3/pancakeswap-v3.ts @@ -178,7 +178,7 @@ export class PancakeswapV3 }) => { const logPrefix = '[PancakeV3.onPoolCreatedDeleteFromNonExistingSet]'; const [_token0, _token1] = this._sortTokens(token0, token1); - const poolKey = `${token0}_${token1}_${fee}`.toLowerCase(); + const poolKey = `${_token0}_${_token1}_${fee}`; // consider doing it only from master pool for less calls to distant cache diff --git a/src/dex/uniswap-v3/forks/ramses-v2/ramses-v2-pool.ts b/src/dex/uniswap-v3/forks/ramses-v2/ramses-v2-pool.ts index c68b71658..5889cc06b 100644 --- a/src/dex/uniswap-v3/forks/ramses-v2/ramses-v2-pool.ts +++ b/src/dex/uniswap-v3/forks/ramses-v2/ramses-v2-pool.ts @@ -1,5 +1,9 @@ import { UniswapV3EventPool } from '../../uniswap-v3-pool'; -import { DecodedStateMultiCallResultWithRelativeBitmaps, DecodeStateMultiCallFunc, PoolState } from '../../types'; +import { + DecodedStateMultiCallResultWithRelativeBitmaps, + DecodeStateMultiCallFunc, + PoolState, +} from '../../types'; import { assert } from 'ts-essentials'; import { _reduceTickBitmap, _reduceTicks } from '../../contract-math/utils'; import { bigIntify } from '../../../../utils'; @@ -12,7 +16,6 @@ import { Contract } from 'web3-eth-contract'; import { Address, Logger } from '../../../../types'; export class RamsesV2EventPool extends UniswapV3EventPool { - public readonly poolIface = new Interface(RamsesV2PoolABI); constructor( @@ -49,10 +52,7 @@ export class RamsesV2EventPool extends UniswapV3EventPool { this.handlers['FeeAdjustment'] = this.handleFeeAdjustmentEvent.bind(this); } - handleFeeAdjustmentEvent( - event: any, - pool: PoolState, - ): PoolState { + handleFeeAdjustmentEvent(event: any, pool: PoolState): PoolState { const newFee = bigIntify(event.args.newFee); pool.fee = newFee; @@ -77,7 +77,7 @@ export class RamsesV2EventPool extends UniswapV3EventPool { const [resBalance0, resBalance1, resState, resCurrentFee] = await this.dexHelper.multiWrapper.tryAggregate< bigint | DecodedStateMultiCallResultWithRelativeBitmaps - >( + >( false, calldataWithFee, blockNumber, @@ -92,7 +92,12 @@ export class RamsesV2EventPool extends UniswapV3EventPool { resBalance1.returnData, resState.returnData, resCurrentFee.returnData, - ] as [bigint, bigint, DecodedStateMultiCallResultWithRelativeBitmaps, bigint]; + ] as [ + bigint, + bigint, + DecodedStateMultiCallResultWithRelativeBitmaps, + bigint, + ]; const tickBitmap = {}; const ticks = {}; diff --git a/src/dex/uniswap-v3/uniswap-v3-factory.ts b/src/dex/uniswap-v3/uniswap-v3-factory.ts index 0f568e7ab..372020de4 100644 --- a/src/dex/uniswap-v3/uniswap-v3-factory.ts +++ b/src/dex/uniswap-v3/uniswap-v3-factory.ts @@ -64,8 +64,8 @@ export class UniswapV3Factory extends StatefulEventSubscriber { } async handleNewPool(event: LogDescription) { - const token0 = event.args.token0; - const token1 = event.args.token1; + const token0 = event.args.token0.toLowerCase(); + const token1 = event.args.token1.toLowerCase(); const fee = event.args.fee; await this.onPoolCreated({ token0, token1, fee }); diff --git a/src/dex/uniswap-v3/uniswap-v3.ts b/src/dex/uniswap-v3/uniswap-v3.ts index 3e6ceef72..57c32f5c6 100644 --- a/src/dex/uniswap-v3/uniswap-v3.ts +++ b/src/dex/uniswap-v3/uniswap-v3.ts @@ -17,7 +17,13 @@ import { } from '../../types'; import { CACHE_PREFIX, Network, SwapSide } from '../../constants'; import * as CALLDATA_GAS_COST from '../../calldata-gas-cost'; -import { getBigIntPow, getDexKeysWithNetwork, interpolate, isTruthy, uuidToBytes16, } from '../../utils'; +import { + getBigIntPow, + getDexKeysWithNetwork, + interpolate, + isTruthy, + uuidToBytes16, +} from '../../utils'; import { IDex } from '../../dex/idex'; import { IDexHelper } from '../../dex-helper/idex-helper'; import { @@ -29,7 +35,10 @@ import { UniswapV3Param, UniswapV3SimpleSwapParams, } from './types'; -import { getLocalDeadlineAsFriendlyPlaceholder, SimpleExchange, } from '../simple-exchange'; +import { + getLocalDeadlineAsFriendlyPlaceholder, + SimpleExchange, +} from '../simple-exchange'; import { Adapters, PoolsToPreload, UniswapV3Config } from './config'; import { UniswapV3EventPool } from './uniswap-v3-pool'; import UniswapV3RouterABI from '../../abi/uniswap-v3/UniswapV3Router.abi.json'; @@ -49,7 +58,11 @@ import { uniswapV3Math } from './contract-math/uniswap-v3-math'; import { Contract } from 'web3-eth-contract'; import { AbiItem } from 'web3-utils'; import { BalanceRequest, getBalances } from '../../lib/tokens/balancer-fetcher'; -import { AssetType, DEFAULT_ID_ERC20, DEFAULT_ID_ERC20_AS_STRING, } from '../../lib/tokens/types'; +import { + AssetType, + DEFAULT_ID_ERC20, + DEFAULT_ID_ERC20_AS_STRING, +} from '../../lib/tokens/types'; import { OptimalSwapExchange } from '@paraswap/core'; import { OnPoolCreatedCallback, UniswapV3Factory } from './uniswap-v3-factory'; @@ -196,7 +209,7 @@ export class UniswapV3 }) => { const logPrefix = '[UniswapV3.onPoolCreatedDeleteFromNonExistingSet]'; const [_token0, _token1] = this._sortTokens(token0, token1); - const poolKey = `${token0}_${token1}_${fee}`.toLowerCase(); + const poolKey = `${_token0}_${_token1}_${fee}`; // consider doing it only from master pool for less calls to distant cache @@ -281,18 +294,18 @@ export class UniswapV3 pool = pool || new poolImplementation( - this.dexHelper, - this.dexKey, - this.stateMultiContract, - this.config.decodeStateMultiCallResultWithRelativeBitmaps, - this.erc20Interface, - this.config.factory, - fee, - token0, - token1, - this.logger, - this.cacheStateKey, - this.config.initHash, + this.dexHelper, + this.dexKey, + this.stateMultiContract, + this.config.decodeStateMultiCallResultWithRelativeBitmaps, + this.erc20Interface, + this.config.factory, + fee, + token0, + token1, + this.logger, + this.cacheStateKey, + this.config.initHash, ); try {