From fe134d53eb0fc580e5d7ca7a33c43746fbb96bfd Mon Sep 17 00:00:00 2001 From: Vasilis Xouris Date: Tue, 4 Mar 2025 16:00:48 -0800 Subject: [PATCH] fix: don't use cachedRoutes if intent.caching (100%) --- package-lock.json | 4 ++-- package.json | 2 +- src/routers/alpha-router/alpha-router.ts | 17 ++--------------- .../routers/alpha-router/alpha-router.test.ts | 8 -------- 4 files changed, 5 insertions(+), 26 deletions(-) diff --git a/package-lock.json b/package-lock.json index efb281e0a..fe0f1d075 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@uniswap/smart-order-router", - "version": "4.19.4", + "version": "4.20.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@uniswap/smart-order-router", - "version": "4.19.4", + "version": "4.20.1", "license": "GPL", "dependencies": { "@eth-optimism/sdk": "^3.2.2", diff --git a/package.json b/package.json index a4447575b..6c6dfeae9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@uniswap/smart-order-router", - "version": "4.19.4", + "version": "4.20.1", "description": "Uniswap Smart Order Router", "main": "build/main/index.js", "typings": "build/main/index.d.ts", diff --git a/src/routers/alpha-router/alpha-router.ts b/src/routers/alpha-router/alpha-router.ts index e5418d685..1a551fcaf 100644 --- a/src/routers/alpha-router/alpha-router.ts +++ b/src/routers/alpha-router/alpha-router.ts @@ -3200,22 +3200,9 @@ export class AlphaRouter ); } - // Percentage of time we want to skip cached routes for the experiment. - // Starting with 50% to gradually roll out the change. - public static readonly CACHED_ROUTES_SKIP_EXPERIMENT_FLAG_PERCENTAGE = 0.5; - // We want to skip cached routes access whenever "intent === INTENT.CACHING". - // To verify this functionality though, we want to start by using a percentage of the time. + // We keep this method as we might want to add more conditions in the future. public static isAllowedToEnterCachedRoutes(intent?: INTENT): boolean { - // Check if we should run the experiment - const shouldRunExperiment = - Math.random() < AlphaRouter.CACHED_ROUTES_SKIP_EXPERIMENT_FLAG_PERCENTAGE; - if (shouldRunExperiment) { - // For the experiment group, we want to skip the cached routes access if the intent is caching - return intent !== INTENT.CACHING; - } - - // For the control group, we always allow access to cached routes. - return true; + return intent !== INTENT.CACHING; } } diff --git a/test/unit/routers/alpha-router/alpha-router.test.ts b/test/unit/routers/alpha-router/alpha-router.test.ts index 88d58f9a1..0fa02e058 100644 --- a/test/unit/routers/alpha-router/alpha-router.test.ts +++ b/test/unit/routers/alpha-router/alpha-router.test.ts @@ -3101,14 +3101,6 @@ describe('alpha router', () => { }); test('returns correct values based on random percentage and intent', () => { - // Test when random is above experiment threshold (control group - should always return true) - randomStub.returns(AlphaRouter.CACHED_ROUTES_SKIP_EXPERIMENT_FLAG_PERCENTAGE + 0.01); - expect(AlphaRouter.isAllowedToEnterCachedRoutes(INTENT.CACHING)).toBe(true); - expect(AlphaRouter.isAllowedToEnterCachedRoutes(INTENT.QUOTE)).toBe(true); - expect(AlphaRouter.isAllowedToEnterCachedRoutes(undefined)).toBe(true); - - // Test when random is below experiment threshold (experiment group) - randomStub.returns(AlphaRouter.CACHED_ROUTES_SKIP_EXPERIMENT_FLAG_PERCENTAGE - 0.001); // Should return false only for CACHING intent expect(AlphaRouter.isAllowedToEnterCachedRoutes(INTENT.CACHING)).toBe(false); // Should return true for other intents