Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: mixed route eth <-> weth need to remove fake pool #1017

Merged
merged 6 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/handlers/quote/quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
sortsBefore,
SwapOptions,
SwapRoute,
V4_ETH_WETH_FAKE_POOL,
} from '@uniswap/smart-order-router'
import { Pool as V3Pool } from '@uniswap/v3-sdk'
import { Pool as V4Pool } from '@uniswap/v4-sdk'
Expand Down Expand Up @@ -552,6 +553,13 @@ export class QuoteHandler extends APIGLambdaHandler<
}

if (nextPool instanceof V4Pool) {
// We want to filter the fake v4 pool here,
// because in SOR, we intentionally retain the fake pool, when it returns the valid routes
// https://github.com/Uniswap/smart-order-router/pull/819/files#diff-0eeab2733d13572382be381aa273dddcb38e797adf48c864105fbab2dcf011ffR489
if (nextPool.tickSpacing === V4_ETH_WETH_FAKE_POOL[chainId].tickSpacing) {
continue
}

curRoute.push({
type: 'v4-pool',
address: v4PoolProvider.getPoolId(
Expand Down
10 changes: 9 additions & 1 deletion test/mocha/e2e/quote.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1533,7 +1533,7 @@ describe('quote', function () {
},
})
const {
data: { quoteDecimals, quoteGasAdjustedDecimals, methodParameters, routeString },
data: { quoteDecimals, quoteGasAdjustedDecimals, methodParameters, route, routeString },
status,
} = response

Expand All @@ -1543,6 +1543,14 @@ describe('quote', function () {

/// since we only get the routeString back, we can check if there's V3 + V2
expect(routeString.includes('[V2 + V3 + V4]'))
expect(route.length).to.equal(1)
expect(route[0].length).to.equal(2)
expect(route[0][0].type).to.equal('v3-pool')
expect(route[0][0].tokenIn.address).to.equal('0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913')
expect(route[0][0].tokenOut.address).to.equal(WETH9[ChainId.BASE])
expect(route[0][1].type).to.equal('v4-pool')
expect(route[0][1].tokenIn.address).to.equal('0x0000000000000000000000000000000000000000')
expect(route[0][1].tokenOut.address).to.equal('0x878784F7eBF6e57d17C81D82DDF53F117a5E2988')
})

it('USDC -> mockA forceMixedRoutes true for mixed protocol on Base no request source', async () => {
Expand Down
Loading