Skip to content

Commit

Permalink
add e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
jsy1218 committed Feb 7, 2025
1 parent 3828b63 commit a5a9cdc
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 15 deletions.
2 changes: 1 addition & 1 deletion 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 @@ -45,7 +46,6 @@ import {
protocolVersionsToBeExcludedFromMixed,
URVersionsToProtocolVersions,
} from '../../util/supportedProtocolVersions'
import { V4_ETH_WETH_FAKE_POOL } from '@uniswap/smart-order-router/src/main/util/pool'

export class QuoteHandler extends APIGLambdaHandler<
ContainerInjected,
Expand Down
26 changes: 13 additions & 13 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"@uniswap/permit2-sdk": "^1.3.0",
"@uniswap/router-sdk": "^1.22.1",
"@uniswap/sdk-core": "^7.5.0",
"@uniswap/smart-order-router": "4.17.6",
"@uniswap/smart-order-router": "4.17.10",
"@uniswap/token-lists": "^1.0.0-beta.33",
"@uniswap/universal-router-sdk": "^4.17.0",
"@uniswap/v2-sdk": "^4.13.0",
Expand Down
48 changes: 48 additions & 0 deletions test/mocha/e2e/quote.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
parseAmount,
SWAP_ROUTER_02_ADDRESSES,
USDB_BLAST,
USDC_BASE,
USDC_BNB,
USDC_MAINNET,
USDC_NATIVE_ARBITRUM,
Expand Down Expand Up @@ -3417,6 +3418,53 @@ describe('quote', function () {
fail(JSON.stringify(err.response.data))
}
})

it(`USDC -> mockA only through mixed`, async () => {
if (chain !== ChainId.BASE) {
// Only Base has mockA
return
}

if (type !== 'exactIn') {
// mixed route only supports exact in
return
}

const tokenOut = new Token(ChainId.BASE, '0x878784f7ebf6e57d17c81d82ddf53f117a5e2988', 18, 'MOCKA')
const amount = type === 'exactIn' ? '0.00000000000001' : '0.000001'

const quoteReq: QuoteQueryParams = {
tokenInAddress: USDC_BASE.address,
tokenInChainId: chain,
tokenOutAddress: tokenOut.address,
tokenOutChainId: chain,
amount: await getAmountFromToken(type, WNATIVE_ON(chain), tokenOut, amount),
type,
enableUniversalRouter: true,
forceMixedRoutes: true,
protocols: 'mixed',
}

const headers = {
'x-universal-router-version': '2.0',
}

const queryParams = qs.stringify(quoteReq)

try {
const response: AxiosResponse<QuoteResponse> = await axios.get<QuoteResponse>(`${API}?${queryParams}`, {
headers: headers,
})
const { status, data } = response

expect(status).to.equal(200, JSON.stringify(response.data))
expect(data.route.filter((pools) => pools.filter((pool) => pool.type === 'v3-pool'))).to.not.be.undefined
expect(data.route.filter((pools) => pools.filter((pool) => pool.type === 'v4-pool'))).to.not.be.undefined
} catch (err: any) {
fail(JSON.stringify(err.response.data))
}
})

it(`has quoteGasAdjusted values`, async () => {
if (chain === ChainId.SEPOLIA && !erc1.equals(V4_SEPOLIA_TEST_A)) {
// Sepolia doesn't have sufficient liquidity on DAI pools yet
Expand Down

0 comments on commit a5a9cdc

Please sign in to comment.