From e9e4a592730f96d3df8d2bd2eaaa3846f3deadaa Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Fri, 18 Oct 2024 08:42:16 -0700 Subject: [PATCH] INTENT enum --- .../route-caching/dynamo-route-caching-provider.ts | 3 ++- lib/handlers/shared.ts | 6 ++++++ package-lock.json | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/handlers/router-entities/route-caching/dynamo-route-caching-provider.ts b/lib/handlers/router-entities/route-caching/dynamo-route-caching-provider.ts index 38fd29380..9ffb3d137 100644 --- a/lib/handlers/router-entities/route-caching/dynamo-route-caching-provider.ts +++ b/lib/handlers/router-entities/route-caching/dynamo-route-caching-provider.ts @@ -3,6 +3,7 @@ import { CachedRoutes, CacheMode, ID_TO_NETWORK_NAME, + INTENT, IRouteCachingProvider, log, metric, @@ -306,7 +307,7 @@ export class DynamoRouteCachingProvider extends IRouteCachingProvider { amount: amount.quotient.toString(), type: partitionKey.tradeType === 0 ? 'exactIn' : 'exactOut', protocols: protocols.map((protocol) => protocol.toLowerCase()).join(','), - intent: 'caching', + intent: INTENT.CACHING, requestSource: 'routing-api', }, } diff --git a/lib/handlers/shared.ts b/lib/handlers/shared.ts index e1f016f3a..a2821f446 100644 --- a/lib/handlers/shared.ts +++ b/lib/handlers/shared.ts @@ -2,6 +2,7 @@ import { ChainId, Currency, CurrencyAmount, Percent } from '@uniswap/sdk-core' import { AlphaRouterConfig, CacheMode, + INTENT, LowerCaseStringArray, MapWithLowerCaseKey, ProtocolPoolSelection, @@ -238,6 +239,7 @@ export const QUOTE_SPEED_CONFIG: { [key: string]: QuoteSpeedConfig } = { } export type IntentSpecificConfig = { + intent?: INTENT useCachedRoutes?: boolean overwriteCacheMode?: CacheMode optimisticCachedRoutes?: boolean @@ -246,6 +248,7 @@ export type IntentSpecificConfig = { export const INTENT_SPECIFIC_CONFIG: { [key: string]: IntentSpecificConfig } = { caching: { // When the intent is to create a cache entry, we will use cachedRoutes with Tapcompare to track accuracy + intent: INTENT.CACHING, useCachedRoutes: true, overwriteCacheMode: CacheMode.Tapcompare, // This optimistic=false is *super* important to avoid an infinite loop of caching quotes calling themselves @@ -253,16 +256,19 @@ export const INTENT_SPECIFIC_CONFIG: { [key: string]: IntentSpecificConfig } = { }, quote: { // When the intent is to get a quote, we should use the cache and optimistic cached routes + intent: INTENT.QUOTE, useCachedRoutes: true, optimisticCachedRoutes: true, }, swap: { // When the intent is to prepare the swap, we can use cache, but it should not be optimistic + intent: INTENT.SWAP, useCachedRoutes: true, optimisticCachedRoutes: false, }, pricing: { // When the intent is to get pricing, we should use the cache and optimistic cached routes + intent: INTENT.PRICING, useCachedRoutes: true, optimisticCachedRoutes: true, }, diff --git a/package-lock.json b/package-lock.json index f29a38677..4fadfde6f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4751,8 +4751,14 @@ }, "node_modules/@uniswap/smart-order-router": { "version": "4.7.3", +<<<<<<< HEAD "resolved": "https://registry.npmjs.org/@uniswap/smart-order-router/-/smart-order-router-4.7.3.tgz", "integrity": "sha512-ehUvGt9Htn2qaHIfFcEFSPQxp29RAgBqV5ODMeqMebJGGeaw0uPS/ovR1gnzBNFC8FHKDCoiRFSHZ0M6U2nPaQ==", +======= + "resolved": "file:../../../../tmp/uniswap-smart-order-router-4.7.3.tgz", + "integrity": "sha512-qIMzAiC5UChR3xfXTFQUcuouVQkTV5MOMVbL1dnL68jVypCT6TD/lZYxBdj+ie5pL5llNs2WCYy2HGzd0Qa6gw==", + "license": "GPL", +>>>>>>> 5904820 (INTENT enum) "dependencies": { "@eth-optimism/sdk": "^3.2.2", "@types/brotli": "^1.3.4",