Skip to content

Commit

Permalink
INTENT enum
Browse files Browse the repository at this point in the history
  • Loading branch information
jsy1218 committed Oct 23, 2024
1 parent fd6fdb5 commit e9e4a59
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
CachedRoutes,
CacheMode,
ID_TO_NETWORK_NAME,
INTENT,
IRouteCachingProvider,
log,
metric,
Expand Down Expand Up @@ -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',
},
}
Expand Down
6 changes: 6 additions & 0 deletions lib/handlers/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ChainId, Currency, CurrencyAmount, Percent } from '@uniswap/sdk-core'
import {
AlphaRouterConfig,
CacheMode,
INTENT,
LowerCaseStringArray,
MapWithLowerCaseKey,
ProtocolPoolSelection,
Expand Down Expand Up @@ -238,6 +239,7 @@ export const QUOTE_SPEED_CONFIG: { [key: string]: QuoteSpeedConfig } = {
}

export type IntentSpecificConfig = {
intent?: INTENT
useCachedRoutes?: boolean
overwriteCacheMode?: CacheMode
optimisticCachedRoutes?: boolean
Expand All @@ -246,23 +248,27 @@ 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
optimisticCachedRoutes: false,
},
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,
},
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e9e4a59

Please sign in to comment.