Skip to content

Commit

Permalink
feat: turn on rest of buckets for usdc / any token cache (Uniswap#220)
Browse files Browse the repository at this point in the history
* go live

* update unit test
  • Loading branch information
lynnshaoyu authored Jun 8, 2023
1 parent 4c8623a commit 87eab69
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ export const CACHED_ROUTES_CONFIGURATION: Map<string, CachedRoutesStrategy> = ne
new CachedRoutesBucket({ bucket: 500, cacheMode: CacheMode.Livemode, withLastNCachedRoutes: 10 }),
new CachedRoutesBucket({ bucket: 750, cacheMode: CacheMode.Livemode, withLastNCachedRoutes: 10 }),
new CachedRoutesBucket({ bucket: 1_000, cacheMode: CacheMode.Livemode, withLastNCachedRoutes: 10 }),
new CachedRoutesBucket({ bucket: 3_000, cacheMode: CacheMode.Tapcompare, withLastNCachedRoutes: 10 }),
new CachedRoutesBucket({ bucket: 8_000, cacheMode: CacheMode.Tapcompare, withLastNCachedRoutes: 10 }),
new CachedRoutesBucket({ bucket: 13_000, cacheMode: CacheMode.Tapcompare, withLastNCachedRoutes: 10 }),
new CachedRoutesBucket({ bucket: 3_000, cacheMode: CacheMode.Livemode, withLastNCachedRoutes: 10 }),
new CachedRoutesBucket({ bucket: 8_000, cacheMode: CacheMode.Livemode, withLastNCachedRoutes: 10 }),
new CachedRoutesBucket({ bucket: 13_000, cacheMode: CacheMode.Livemode, withLastNCachedRoutes: 10 }),
],
}),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ const TEST_WETH_USDC_POOL = new Pool(
/* tickCurrent */ -69633
)

const TEST_USDC_UNI_POOL = new Pool(
const TEST_USDC_WETH_POOL = new Pool(
USDC_MAINNET,
UNI_MAINNET,
WETH,
FeeAmount.HIGH,
/* sqrtRatio */ '2437312313659959819381354528',
/* liquidity */ '10272714736694327408',
Expand All @@ -78,7 +78,7 @@ const TEST_UNI_USDC_POOL = new Pool(
)

const TEST_WETH_USDC_V3_ROUTE = new V3Route([TEST_WETH_USDC_POOL], WETH, USDC_MAINNET)
const TEST_USDC_UNI_V3_ROUTE = new V3Route([TEST_USDC_UNI_POOL], USDC_MAINNET, UNI_MAINNET)
const TEST_USDC_WETH_V3_ROUTE = new V3Route([TEST_USDC_WETH_POOL], USDC_MAINNET, WETH)
const TEST_UNI_USDC_ROUTE = new V3Route([TEST_UNI_USDC_POOL], UNI_MAINNET, USDC_MAINNET)

const TEST_CACHED_ROUTE = new CachedRoute({ route: TEST_WETH_USDC_V3_ROUTE, percent: 100 })
Expand All @@ -94,15 +94,15 @@ const TEST_CACHED_ROUTES = new CachedRoutes({
blocksToLive: 5,
})

const TEST_CACHED_ROUTE_2 = new CachedRoute({ route: TEST_USDC_UNI_V3_ROUTE, percent: 100 })
const TEST_CACHED_ROUTE_2 = new CachedRoute({ route: TEST_USDC_WETH_V3_ROUTE, percent: 100 })
const TEST_CACHED_ROUTES_2 = new CachedRoutes({
routes: [TEST_CACHED_ROUTE_2],
chainId: TEST_CACHED_ROUTE_2.route.chainId,
tokenIn: USDC_MAINNET,
tokenOut: UNI_MAINNET,
tokenOut: WETH,
protocolsCovered: [TEST_CACHED_ROUTE_2.protocol],
blockNumber: 0,
tradeType: TradeType.EXACT_INPUT,
tradeType: TradeType.EXACT_OUTPUT,
originalAmount: '1',
blocksToLive: 5,
})
Expand Down Expand Up @@ -157,12 +157,12 @@ describe('DynamoRouteCachingProvider', async () => {
})

it('Caches routes properly for a token pair that has its cache configured to Tapcompare', async () => {
const currencyAmount = CurrencyAmount.fromRawAmount(USDC_MAINNET, JSBI.BigInt(1200 * 10 ** USDC_MAINNET.decimals))
const currencyAmount = CurrencyAmount.fromRawAmount(WETH, JSBI.BigInt(100 * 10 ** WETH.decimals))
const cacheMode = await dynamoRouteCache.getCacheMode(
ChainId.MAINNET,
currencyAmount,
UNI_MAINNET,
TradeType.EXACT_INPUT,
USDC_MAINNET,
TradeType.EXACT_OUTPUT,
[Protocol.V3]
)
expect(cacheMode).to.equal(CacheMode.Tapcompare)
Expand All @@ -180,8 +180,8 @@ describe('DynamoRouteCachingProvider', async () => {
const route = await dynamoRouteCache.getCachedRoute(
ChainId.MAINNET,
currencyAmount,
UNI_MAINNET,
TradeType.EXACT_INPUT,
USDC_MAINNET,
TradeType.EXACT_OUTPUT,
[Protocol.V3],
TEST_CACHED_ROUTES_2.blockNumber
)
Expand Down

0 comments on commit 87eab69

Please sign in to comment.