From a5a9cdcc10436e08d01e513acbbc017dc906823e Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Fri, 7 Feb 2025 08:53:59 -0800 Subject: [PATCH] add e2e test --- lib/handlers/quote/quote.ts | 2 +- package-lock.json | 26 +++++++++---------- package.json | 2 +- test/mocha/e2e/quote.test.ts | 48 ++++++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 15 deletions(-) diff --git a/lib/handlers/quote/quote.ts b/lib/handlers/quote/quote.ts index e35a2f9ed8..4b7c439bc9 100644 --- a/lib/handlers/quote/quote.ts +++ b/lib/handlers/quote/quote.ts @@ -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' @@ -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, diff --git a/package-lock.json b/package-lock.json index 4a79d20723..603e816072 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,7 +29,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", @@ -4508,23 +4508,23 @@ } }, "node_modules/@uniswap/smart-order-router": { - "version": "4.17.6", - "resolved": "https://registry.npmjs.org/@uniswap/smart-order-router/-/smart-order-router-4.17.6.tgz", - "integrity": "sha512-GLvj2Qv8tEF99LghrAFs7r5DOjAM0CNYEMAanErIIBptyoIa8QjiN5n83Jqo1VWNiYnQO7tekxvYuHIwvts1iw==", + "version": "4.17.10", + "resolved": "https://registry.npmjs.org/@uniswap/smart-order-router/-/smart-order-router-4.17.10.tgz", + "integrity": "sha512-5X6r6lFGzjFFWuCBIBHTOv+qv9XnuWy4BEKuh/LSbPFj3OZkJ//6WbbqCjXyN30pF08UiqUcjClRGCA2RUtEiA==", "dependencies": { "@eth-optimism/sdk": "^3.2.2", "@types/brotli": "^1.3.4", "@uniswap/default-token-list": "^11.13.0", "@uniswap/permit2-sdk": "^1.3.0", - "@uniswap/router-sdk": "^1.21.0", + "@uniswap/router-sdk": "^1.22.1", "@uniswap/sdk-core": "^7.5.0", "@uniswap/swap-router-contracts": "^1.3.1", "@uniswap/token-lists": "^1.0.0-beta.31", "@uniswap/universal-router": "^1.6.0", - "@uniswap/universal-router-sdk": "^4.14.0", + "@uniswap/universal-router-sdk": "^4.17.0", "@uniswap/v2-sdk": "^4.13.0", "@uniswap/v3-sdk": "^3.24.0", - "@uniswap/v4-sdk": "^1.18.0", + "@uniswap/v4-sdk": "^1.18.1", "async-retry": "^1.3.1", "await-timeout": "^1.1.1", "axios": "^0.21.1", @@ -27936,23 +27936,23 @@ } }, "@uniswap/smart-order-router": { - "version": "4.17.6", - "resolved": "https://registry.npmjs.org/@uniswap/smart-order-router/-/smart-order-router-4.17.6.tgz", - "integrity": "sha512-GLvj2Qv8tEF99LghrAFs7r5DOjAM0CNYEMAanErIIBptyoIa8QjiN5n83Jqo1VWNiYnQO7tekxvYuHIwvts1iw==", + "version": "4.17.10", + "resolved": "https://registry.npmjs.org/@uniswap/smart-order-router/-/smart-order-router-4.17.10.tgz", + "integrity": "sha512-5X6r6lFGzjFFWuCBIBHTOv+qv9XnuWy4BEKuh/LSbPFj3OZkJ//6WbbqCjXyN30pF08UiqUcjClRGCA2RUtEiA==", "requires": { "@eth-optimism/sdk": "^3.2.2", "@types/brotli": "^1.3.4", "@uniswap/default-token-list": "^11.13.0", "@uniswap/permit2-sdk": "^1.3.0", - "@uniswap/router-sdk": "^1.21.0", + "@uniswap/router-sdk": "^1.22.1", "@uniswap/sdk-core": "^7.5.0", "@uniswap/swap-router-contracts": "^1.3.1", "@uniswap/token-lists": "^1.0.0-beta.31", "@uniswap/universal-router": "^1.6.0", - "@uniswap/universal-router-sdk": "^4.14.0", + "@uniswap/universal-router-sdk": "^4.17.0", "@uniswap/v2-sdk": "^4.13.0", "@uniswap/v3-sdk": "^3.24.0", - "@uniswap/v4-sdk": "^1.18.0", + "@uniswap/v4-sdk": "^1.18.1", "async-retry": "^1.3.1", "await-timeout": "^1.1.1", "axios": "^0.21.1", diff --git a/package.json b/package.json index 682a6eb3b6..376e669d54 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/mocha/e2e/quote.test.ts b/test/mocha/e2e/quote.test.ts index a4968ff854..9e2953bf5a 100644 --- a/test/mocha/e2e/quote.test.ts +++ b/test/mocha/e2e/quote.test.ts @@ -13,6 +13,7 @@ import { parseAmount, SWAP_ROUTER_02_ADDRESSES, USDB_BLAST, + USDC_BASE, USDC_BNB, USDC_MAINNET, USDC_NATIVE_ARBITRUM, @@ -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 = await axios.get(`${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