From 2a6944e75d73314f624d94be61079a9f902f5484 Mon Sep 17 00:00:00 2001 From: "Siyu Jiang (See-You John)" <91580504+jsy1218@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:13:50 -0700 Subject: [PATCH] chore: bump sor to 3.42.0 - feat: implement v4 candidate pools from top tvl v4 subgraph (#814) * chore: bump sor to 3.42.0 * fix prettier * chore: bump sor to 3.42.0 --- lib/handlers/injector-sor.ts | 1 + .../router-entities/aws-subgraph-provider.ts | 3 +- lib/handlers/shared.ts | 38 +++++++++++++++++++ package-lock.json | 14 +++---- package.json | 2 +- 5 files changed, 49 insertions(+), 9 deletions(-) diff --git a/lib/handlers/injector-sor.ts b/lib/handlers/injector-sor.ts index 24fa43f5b5..1695153023 100644 --- a/lib/handlers/injector-sor.ts +++ b/lib/handlers/injector-sor.ts @@ -466,6 +466,7 @@ export abstract class InjectorSOR extends Injector< v4SubgraphProvider, v3SubgraphProvider, onChainQuoteProvider: quoteProvider, + v4PoolProvider, v3PoolProvider, v2PoolProvider, v2QuoteProvider: new V2QuoteProvider(), diff --git a/lib/handlers/router-entities/aws-subgraph-provider.ts b/lib/handlers/router-entities/aws-subgraph-provider.ts index e4b835a727..01aa69a3c2 100644 --- a/lib/handlers/router-entities/aws-subgraph-provider.ts +++ b/lib/handlers/router-entities/aws-subgraph-provider.ts @@ -7,6 +7,7 @@ import { MetricLoggerUnit, V2SubgraphPool, V3SubgraphPool, + V4SubgraphPool, } from '@uniswap/smart-order-router' import { S3 } from 'aws-sdk' import { ChainId } from '@uniswap/sdk-core' @@ -106,7 +107,7 @@ export const cachePoolsFromS3 = async ( return pools } -export class V4AWSSubgraphProvider extends AWSSubgraphProvider implements IV3SubgraphProvider { +export class V4AWSSubgraphProvider extends AWSSubgraphProvider implements IV3SubgraphProvider { constructor(chainId: ChainId, bucket: string, baseKey: string) { super(chainId, Protocol.V4, bucket, baseKey) } diff --git a/lib/handlers/shared.ts b/lib/handlers/shared.ts index 46cbaad993..6cbd4fc383 100644 --- a/lib/handlers/shared.ts +++ b/lib/handlers/shared.ts @@ -34,6 +34,14 @@ export const DEFAULT_ROUTING_CONFIG_BY_CHAIN = (chainId: ChainId): AlphaRouterCo topNWithEachBaseToken: 3, topNWithBaseToken: 3, }, + v4PoolSelection: { + topN: 2, + topNDirectSwaps: 2, + topNTokenInOut: 2, + topNSecondHop: 1, + topNWithEachBaseToken: 3, + topNWithBaseToken: 3, + }, maxSwapsPerPath: 3, minSplits: 1, maxSplits: 7, @@ -61,6 +69,14 @@ export const DEFAULT_ROUTING_CONFIG_BY_CHAIN = (chainId: ChainId): AlphaRouterCo topNWithEachBaseToken: 3, topNWithBaseToken: 2, }, + v4PoolSelection: { + topN: 2, + topNDirectSwaps: 2, + topNTokenInOut: 2, + topNSecondHop: 1, + topNWithEachBaseToken: 3, + topNWithBaseToken: 2, + }, maxSwapsPerPath: 2, minSplits: 1, maxSplits: 7, @@ -91,6 +107,17 @@ export const DEFAULT_ROUTING_CONFIG_BY_CHAIN = (chainId: ChainId): AlphaRouterCo topNWithEachBaseToken: 3, topNWithBaseToken: 5, }, + v4PoolSelection: { + topN: 2, + topNDirectSwaps: 2, + topNTokenInOut: 3, + topNSecondHop: 1, + topNSecondHopForTokenAddress: new MapWithLowerCaseKey([ + ['0x5f98805a4e8be255a32880fdec7f6728c6568ba0', 2], // LUSD + ]), + topNWithEachBaseToken: 3, + topNWithBaseToken: 5, + }, maxSwapsPerPath: 3, minSplits: 1, maxSplits: 2, @@ -121,6 +148,17 @@ export const DEFAULT_ROUTING_CONFIG_BY_CHAIN = (chainId: ChainId): AlphaRouterCo topNWithEachBaseToken: 3, topNWithBaseToken: 5, }, + v4PoolSelection: { + topN: 2, + topNDirectSwaps: 2, + topNTokenInOut: 3, + topNSecondHop: 1, + topNSecondHopForTokenAddress: new MapWithLowerCaseKey([ + ['0x5f98805a4e8be255a32880fdec7f6728c6568ba0', 2], // LUSD + ]), + topNWithEachBaseToken: 3, + topNWithBaseToken: 5, + }, maxSwapsPerPath: 3, minSplits: 1, maxSplits: 7, diff --git a/package-lock.json b/package-lock.json index ffdbfc7275..6a0882e0b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,7 +28,7 @@ "@uniswap/permit2-sdk": "^1.3.0", "@uniswap/router-sdk": "^1.10.0", "@uniswap/sdk-core": "^5.3.0", - "@uniswap/smart-order-router": "3.41.0", + "@uniswap/smart-order-router": "3.42.0", "@uniswap/token-lists": "^1.0.0-beta.33", "@uniswap/universal-router-sdk": "^2.2.4", "@uniswap/v2-sdk": "^4.3.2", @@ -4749,9 +4749,9 @@ } }, "node_modules/@uniswap/smart-order-router": { - "version": "3.41.0", - "resolved": "https://registry.npmjs.org/@uniswap/smart-order-router/-/smart-order-router-3.41.0.tgz", - "integrity": "sha512-j5FmHUaLE5kZ+3wF8gDuBfmFPlWCb9zNByJdNdiUEhnEfWXjgR1g94NPCEHWPG9OCAmlRfiUUzZpEJTnhqX2wg==", + "version": "3.42.0", + "resolved": "https://registry.npmjs.org/@uniswap/smart-order-router/-/smart-order-router-3.42.0.tgz", + "integrity": "sha512-AezeeCK3SCP9Co+ekYRBRNl6EvSlLQIAF9ITYjPD7rHwYuNr2n0OIrE8OUU+8VBWDMZuFHNcx/zNeG3EYTGaow==", "dependencies": { "@eth-optimism/sdk": "^3.2.2", "@types/brotli": "^1.3.4", @@ -28422,9 +28422,9 @@ } }, "@uniswap/smart-order-router": { - "version": "3.41.0", - "resolved": "https://registry.npmjs.org/@uniswap/smart-order-router/-/smart-order-router-3.41.0.tgz", - "integrity": "sha512-j5FmHUaLE5kZ+3wF8gDuBfmFPlWCb9zNByJdNdiUEhnEfWXjgR1g94NPCEHWPG9OCAmlRfiUUzZpEJTnhqX2wg==", + "version": "3.42.0", + "resolved": "https://registry.npmjs.org/@uniswap/smart-order-router/-/smart-order-router-3.42.0.tgz", + "integrity": "sha512-AezeeCK3SCP9Co+ekYRBRNl6EvSlLQIAF9ITYjPD7rHwYuNr2n0OIrE8OUU+8VBWDMZuFHNcx/zNeG3EYTGaow==", "requires": { "@eth-optimism/sdk": "^3.2.2", "@types/brotli": "^1.3.4", diff --git a/package.json b/package.json index bffdfc15d0..2323383475 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,7 @@ "@uniswap/router-sdk": "^1.10.0", "@uniswap/sdk-core": "^5.3.0", "@types/semver": "^7.5.8", - "@uniswap/smart-order-router": "3.41.0", + "@uniswap/smart-order-router": "3.42.0", "@uniswap/token-lists": "^1.0.0-beta.33", "@uniswap/universal-router-sdk": "^2.2.4", "@uniswap/v2-sdk": "^4.3.2",