Skip to content

Commit

Permalink
routeString skip fake v4 pool
Browse files Browse the repository at this point in the history
  • Loading branch information
jsy1218 committed Feb 7, 2025
1 parent d062c0c commit decea23
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/util/routes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Protocol } from '@uniswap/router-sdk';
import { Currency, Percent } from '@uniswap/sdk-core';
import { ChainId, Currency, Percent } from '@uniswap/sdk-core';
import { Pair } from '@uniswap/v2-sdk';
import { Pool as V3Pool } from '@uniswap/v3-sdk';
import { Pool as V4Pool } from '@uniswap/v4-sdk';
Expand All @@ -16,6 +16,7 @@ import { V3_CORE_FACTORY_ADDRESSES } from './addresses';
import { TPool } from '@uniswap/router-sdk/dist/utils/TPool';
import { CurrencyAmount } from '.';
import { CachedRoutes } from '../providers';
import { V4_ETH_WETH_FAKE_POOL } from './pool';

export const routeToTokens = (route: SupportedRoutes): Currency[] => {
switch (route.protocol) {
Expand Down Expand Up @@ -91,6 +92,12 @@ export const routeToString = (route: SupportedRoutes): string => {
V3_CORE_FACTORY_ADDRESSES[pool.chainId]
)}]`;
} else if (pool instanceof V4Pool) {
// Special case in the case of ETH/WETH fake pool
// where we do not want to return the fake pool in the route string as it is not a real pool
if (pool.tickSpacing === V4_ETH_WETH_FAKE_POOL[pool.chainId as ChainId].tickSpacing) {
return ' ';
}

return ` -- ${pool.fee / 10000}% [${V4Pool.getPoolId(
pool.token0,
pool.token1,
Expand Down

0 comments on commit decea23

Please sign in to comment.