From 424844e26f986e599d6bbce19adc95e4203c980f Mon Sep 17 00:00:00 2001 From: Yevhen Shulha Date: Mon, 9 Oct 2023 00:00:20 +0300 Subject: [PATCH 1/5] fix: bug with cache key --- src/dex/algebra/algebra.ts | 2 +- src/dex/pancakeswap-v3/pancakeswap-v3.ts | 2 +- src/dex/uniswap-v3/uniswap-v3.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dex/algebra/algebra.ts b/src/dex/algebra/algebra.ts index 726cb669d..fc15c59fa 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}`.toLowerCase(); // consider doing it only from master pool for less calls to distant cache diff --git a/src/dex/pancakeswap-v3/pancakeswap-v3.ts b/src/dex/pancakeswap-v3/pancakeswap-v3.ts index 1e4013edd..7b48f2a56 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}`.toLowerCase(); // consider doing it only from master pool for less calls to distant cache diff --git a/src/dex/uniswap-v3/uniswap-v3.ts b/src/dex/uniswap-v3/uniswap-v3.ts index 6b7f8b1fa..4c86f3a50 100644 --- a/src/dex/uniswap-v3/uniswap-v3.ts +++ b/src/dex/uniswap-v3/uniswap-v3.ts @@ -209,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}`.toLowerCase(); // consider doing it only from master pool for less calls to distant cache From 360a0356ce89a554a2cad099e1c9d0c2fe5e8c42 Mon Sep 17 00:00:00 2001 From: Yevhen Shulha Date: Mon, 9 Oct 2023 00:01:32 +0300 Subject: [PATCH 2/5] 2.37.4-cache-invalidation-fix --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7dd1af3ba..420868f97 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paraswap/dex-lib", - "version": "2.37.3", + "version": "2.37.4-cache-invalidation-fix", "main": "build/index.js", "types": "build/index.d.ts", "repository": "https://github.com/paraswap/paraswap-dex-lib", From 15b7a88f38918a18305c72aef0b591b7128d31e2 Mon Sep 17 00:00:00 2001 From: Yevhen Shulha Date: Mon, 9 Oct 2023 21:09:22 +0300 Subject: [PATCH 3/5] fix: bug in deleting the pool from local state --- src/dex/algebra/algebra-factory.ts | 4 ++-- src/dex/algebra/algebra.ts | 2 +- src/dex/pancakeswap-v3/pancakeswap-v3-factory.ts | 4 ++-- src/dex/pancakeswap-v3/pancakeswap-v3.ts | 2 +- src/dex/uniswap-v3/uniswap-v3-factory.ts | 4 ++-- src/dex/uniswap-v3/uniswap-v3.ts | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) 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 fc15c59fa..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 7b48f2a56..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/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 4c86f3a50..2b9539f6e 100644 --- a/src/dex/uniswap-v3/uniswap-v3.ts +++ b/src/dex/uniswap-v3/uniswap-v3.ts @@ -209,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 From 2287786a0da88fe6495f0f56d1c8bf877b03190d Mon Sep 17 00:00:00 2001 From: Yevhen Shulha Date: Mon, 9 Oct 2023 21:11:55 +0300 Subject: [PATCH 4/5] 2.37.4-cache-invalidation-fix.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 420868f97..e61f38612 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paraswap/dex-lib", - "version": "2.37.4-cache-invalidation-fix", + "version": "2.37.4-cache-invalidation-fix.2", "main": "build/index.js", "types": "build/index.d.ts", "repository": "https://github.com/paraswap/paraswap-dex-lib", From ebc55da28fd69265742d4abe517073efe629926b Mon Sep 17 00:00:00 2001 From: Yevhen Shulha Date: Tue, 10 Oct 2023 21:19:11 +0300 Subject: [PATCH 5/5] 2.37.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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",