interface icon indicating copy to clipboard operation
interface copied to clipboard

Uniswap Trading API (Sepolia) - Intermittent 502/404 Errors on ERC20 Swaps

Open 5oqT opened this issue 10 months ago • 11 comments

Hi everyone,

I'm encountering persistent issues with the Uniswap Trading API (https://trading-api-labs.interface.gateway.uniswap.org/v1/swap) when attempting ERC20 token swaps (e.g., WETH -> USDC) on the Sepolia testnet. I previously posted about this in the discussions forum (https://github.com/Uniswap/interface/discussions/7862) without a resolution, so I'm hoping someone here can help me out.

Problem:

The API https://trading-api-labs.interface.gateway.uniswap.org/v1/swapis frequently returning HTTP errors. These API errors are completely blocking the swap process, preventing transactions from being completed.

  • 502 Bad Gateway image
  • 404 Not Found image

Details:

The errors occur during the SwapTransactionAsync step within a classicSwap execution. (See screenshots below) image image

I'm unable to locate the source code for this specific API service to investigate further.

The swap process becomes stuck and cannot proceed due to these API errors.

Request:

Could anyone provide guidance on:

  • The location of the Uniswap Trading API's source code?
  • Potential causes for these intermittent 502/404 errors on the Sepolia testnet?
  • Any recommended workarounds or alternative approaches for performing ERC20 swaps on Sepolia?

Thanks in advance for any help!

5oqT avatar Mar 16 '25 19:03 5oqT

404s usually mean an issue simulating the tx, can you provide the error details in the response?

plondon avatar Apr 14 '25 15:04 plondon

404s usually mean an issue simulating the tx, can you provide the error details in the response?

Thank you. Here is cURLs I saved, hope they will help:

404 Response:

curl 'https://trading-api-labs.interface.gateway.uniswap.org/v1/swap' \
  -H 'accept: */*' \
  -H 'accept-language: en-US,en;q=0.9' \
  -H 'content-type: application/json' \
  -H 'origin: https://app.uniswap.org/' \
  -H 'priority: u=1, i' \
  -H 'referer: https://app.uniswap.org/' \
  -H 'sec-ch-ua: "Not(A:Brand";v="99", "Google Chrome";v="133", "Chromium";v="133"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: same-site' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/[133.0.0.0](http://133.0.0.0/) Safari/537.36' \
  -H 'x-api-key: JoyCGj29tT4pymvhaGciK4r1aIPvqW6W53xT1fwo' \
  -H 'x-app-version;' \
  -H 'x-request-source: uniswap-web' \
  -H 'x-universal-router-version: 2.0' \
  --data-raw '{"quote":{"chainId":11155111,"input":{"amount":"1000000000000000","token":"0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14"},"output":{"amount":"24714401","token":"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238","recipient":"0x6De6069281868f89b6A32A0003ce1da859AcB421"},"swapper":"0x6De6069281868f89b6A32A0003ce1da859AcB421","route":[[{"type":"v3-pool","address":"0x6418EEC70f50913ff0d756B48d32Ce7C02b47C47","tokenIn":{"chainId":11155111,"decimals":"18","address":"0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14","symbol":"WETH"},"tokenOut":{"chainId":11155111,"decimals":"6","address":"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238","symbol":"USDC"},"fee":"10000","liquidity":"26612353443116297","sqrtRatioX96":"501442176176779195057858884147814","tickCurrent":"175066","amountIn":"1000000000000000","amountOut":"24652614"}]],"slippage":0.5,"tradeType":"EXACT_INPUT","quoteId":"8b3098e5-d37b-46c3-8ce2-862dfe3b551a","gasFeeUSD":"0.000202359956409039","gasFeeQuote":"25743","gasUseEstimate":"240370","priceImpact":1,"txFailureReasons":[],"maxPriorityFeePerGas":"2000000000","maxFeePerGas":"2003725178","gasFee":"481635421035860","gasEstimates":[{"type":"eip1559","strategy":{"limitInflationFactor":1.15,"priceInflationFactor":1.5,"percentileThresholdFor1559Fee":75,"minPriorityFeeGwei":2,"maxPriorityFeeGwei":9},"gasLimit":"276425","gasFee":"553879732328650","maxFeePerGas":"2003725178","maxPriorityFeePerGas":"2000000000"}],"routeString":"[V3] 100.00% = WETH -- 1% [0x6418EEC70f50913ff0d756B48d32Ce7C02b47C47]USDC","blockNumber":"7904995","aggregatedOutputs":[{"amount":"24652615","token":"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238","recipient":"0x6De6069281868f89b6A32A0003ce1da859AcB421","bps":9975,"minAmount":"24652615"},{"amount":"61786","token":"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238","recipient":"0xE49ACc3B16c097ec88Dc9352CE4Cd57aB7e35B95","bps":25,"minAmount":"61786"}],"portionAmount":"61786","portionBips":25,"portionRecipient":"0xE49ACc3B16c097ec88Dc9352CE4Cd57aB7e35B95"},"permitData":{"domain":{"name":"Permit2","chainId":11155111,"verifyingContract":"0x000000000022D473030F116dDEE9F6B43aC78BA3"},"types":{"PermitSingle":[{"name":"details","type":"PermitDetails"},{"name":"spender","type":"address"},{"name":"sigDeadline","type":"uint256"}],"PermitDetails":[{"name":"token","type":"address"},{"name":"amount","type":"uint160"},{"name":"expiration","type":"uint48"},{"name":"nonce","type":"uint48"}]},"values":{"details":{"token":"0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14","amount":"1461501637330902918203684832716283019655932542975","expiration":"1744603892","nonce":"0"},"spender":"0x3a9d48ab9751398bbfa63ad67599bb04e4bdf98b","sigDeadline":"1742013692"}},"signature":"0x162485941ba1faf21013656dab1e60e9d7226dc00000004200937eb426e63d36b6f90eed12e1e51221c0dfdaff45157529f2c21e16ed4edfc147d5d2542832f0a7ffb982af88adb737f1e22e9d12ec5101ee268df130d36d2a1b","simulateTransaction":true,"refreshGasPrice":true,"gasStrategies":[{"limitInflationFactor":1.15,"displayLimitInflationFactor":1.15,"priceInflationFactor":1.5,"percentileThresholdFor1559Fee":75,"minPriorityFeeGwei":2,"maxPriorityFeeGwei":9}],"urgency":"normal"}'

502 Response:

curl 'https://trading-api-labs.interface.gateway.uniswap.org/v1/swap' \
  -H 'accept: */*' \
  -H 'accept-language: en-US,en;q=0.9' \
  -H 'content-type: application/json' \
  -H 'origin: https://app.uniswap.org/' \
  -H 'priority: u=1, i' \
  -H 'referer: https://app.uniswap.org/' \
  -H 'sec-ch-ua: "Not(A:Brand";v="99", "Google Chrome";v="133", "Chromium";v="133"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: same-site' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/[133.0.0.0](http://133.0.0.0/) Safari/537.36' \
  -H 'x-api-key: JoyCGj29tT4pymvhaGciK4r1aIPvqW6W53xT1fwo' \
  -H 'x-app-version;' \
  -H 'x-request-source: uniswap-web' \
  -H 'x-universal-router-version: 2.0' \
  --data-raw '{"quote":{"chainId":11155111,"input":{"amount":"1000000000000000","token":"0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14"},"output":{"amount":"24714401","token":"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238","recipient":"0x6De6069281868f89b6A32A0003ce1da859AcB421"},"swapper":"0x6De6069281868f89b6A32A0003ce1da859AcB421","route":[[{"type":"v3-pool","address":"0x6418EEC70f50913ff0d756B48d32Ce7C02b47C47","tokenIn":{"chainId":11155111,"decimals":"18","address":"0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14","symbol":"WETH"},"tokenOut":{"chainId":11155111,"decimals":"6","address":"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238","symbol":"USDC"},"fee":"10000","liquidity":"26612353443116297","sqrtRatioX96":"501442176176779195057858884147814","tickCurrent":"175066","amountIn":"1000000000000000","amountOut":"24652614"}]],"slippage":0.5,"tradeType":"EXACT_INPUT","quoteId":"41e4869f-2c52-4551-b311-f667db82fc40","gasFeeUSD":"0.00027005851867116","gasFeeQuote":"34356","gasUseEstimate":"240370","priceImpact":1,"txFailureReasons":[],"maxPriorityFeePerGas":"2000000000","maxFeePerGas":"2005547905","gasFee":"482073549924850","gasEstimates":[{"type":"eip1559","strategy":{"limitInflationFactor":1.15,"priceInflationFactor":1.5,"percentileThresholdFor1559Fee":75,"minPriorityFeeGwei":2,"maxPriorityFeeGwei":9},"gasLimit":"276425","gasFee":"554383579639625","maxFeePerGas":"2005547905","maxPriorityFeePerGas":"2000000000"}],"routeString":"[V3] 100.00% = WETH -- 1% [0x6418EEC70f50913ff0d756B48d32Ce7C02b47C47]USDC","blockNumber":"7905047","aggregatedOutputs":[{"amount":"24652615","token":"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238","recipient":"0x6De6069281868f89b6A32A0003ce1da859AcB421","bps":9975,"minAmount":"24652615"},{"amount":"61786","token":"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238","recipient":"0xE49ACc3B16c097ec88Dc9352CE4Cd57aB7e35B95","bps":25,"minAmount":"61786"}],"portionAmount":"61786","portionBips":25,"portionRecipient":"0xE49ACc3B16c097ec88Dc9352CE4Cd57aB7e35B95"},"permitData":{"domain":{"name":"Permit2","chainId":11155111,"verifyingContract":"0x000000000022D473030F116dDEE9F6B43aC78BA3"},"types":{"PermitSingle":[{"name":"details","type":"PermitDetails"},{"name":"spender","type":"address"},{"name":"sigDeadline","type":"uint256"}],"PermitDetails":[{"name":"token","type":"address"},{"name":"amount","type":"uint160"},{"name":"expiration","type":"uint48"},{"name":"nonce","type":"uint48"}]},"values":{"details":{"token":"0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14","amount":"1461501637330902918203684832716283019655932542975","expiration":"1744604570","nonce":"0"},"spender":"0x3a9d48ab9751398bbfa63ad67599bb04e4bdf98b","sigDeadline":"1742014370"}},"signature":"0x162485941ba1faf21013656dab1e60e9d7226dc00000004200199e296ce7bc7e14b975e80af9ad99af8d052b3682734d9fce70b1507759acd425358d62cfbd4fd1a4bc288ee9d599772473dc933f517fb95be91194e44142dd1c","simulateTransaction":true,"refreshGasPrice":true,"gasStrategies":[{"limitInflationFactor":1.15,"displayLimitInflationFactor":1.15,"priceInflationFactor":1.5,"percentileThresholdFor1559Fee":75,"minPriorityFeeGwei":2,"maxPriorityFeeGwei":9}],"urgency":"normal"}' 

5oqT avatar Apr 16 '25 18:04 5oqT

How can I get a x-api-key?

GoldstoneFund avatar Apr 24 '25 10:04 GoldstoneFund

@am9p here is a request for the same amounts that seems to succeed for me very consistently

curl 'https://trading-api-labs.interface.gateway.uniswap.org/v1/swap' \
  -H 'accept: */*' \
  -H 'accept-language: en-US,en;q=0.9,es-ES;q=0.8,es;q=0.7' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -H 'origin: https://app.uniswap.org' \
  -H 'pragma: no-cache' \
  -H 'priority: u=1, i' \
  -H 'referer: https://app.uniswap.org/' \
  -H 'sec-ch-ua: "Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: same-site' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36' \
  -H 'x-api-key: JoyCGj29tT4pymvhaGciK4r1aIPvqW6W53xT1fwo' \
  -H 'x-app-version;' \
  -H 'x-request-source: uniswap-web' \
  -H 'x-universal-router-version: 2.0' \
  --data-raw '{"quote":{"chainId":11155111,"input":{"amount":"1000000000000000","token":"0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14"},"output":{"amount":"8692295","token":"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238","recipient":"0x18d058a7E0486E632f7DfC473BC76D72CD201cAd"},"swapper":"0x18d058a7E0486E632f7DfC473BC76D72CD201cAd","route":[[{"type":"v3-pool","address":"0xFeEd501c2B21D315F04946F85fC6416B640240b5","tokenIn":{"chainId":11155111,"decimals":"18","address":"0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14","symbol":"WETH"},"tokenOut":{"chainId":11155111,"decimals":"6","address":"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238","symbol":"USDC"},"fee":"100","liquidity":"926395929266523","sqrtRatioX96":"849706168017666159733819429771856","tickCurrent":"185615","amountIn":"1000000000000000","amountOut":"8670564"}]],"slippage":0.5,"tradeType":"EXACT_INPUT","quoteId":"59eb554a-d851-4088-a880-90f319930237","gasFeeUSD":"2.580518475697497423","gasFeeQuote":"28459533","gasUseEstimate":"220041","priceImpact":0.02,"txFailureReasons":[],"maxPriorityFeePerGas":"2000000000","maxFeePerGas":"19484260166","gasFee":"4287336091186806","gasEstimates":[{"type":"eip1559","strategy":{"limitInflationFactor":1.15,"priceInflationFactor":1.5,"percentileThresholdFor1559Fee":75,"thresholdToInflateLastBlockBaseFee":0,"baseFeeMultiplier":1.05,"baseFeeHistoryWindow":100,"minPriorityFeeGwei":2,"maxPriorityFeeGwei":9},"gasLimit":"253047","gasFee":"4930433582225802","maxFeePerGas":"19484260166","maxPriorityFeePerGas":"2000000000"}],"routeString":"[V3] 100.00% = WETH -- 0.01% [0xFeEd501c2B21D315F04946F85fC6416B640240b5]USDC","blockNumber":"8185758","aggregatedOutputs":[{"amount":"8670565","token":"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238","recipient":"0x18d058a7E0486E632f7DfC473BC76D72CD201cAd","bps":9975,"minAmount":"8670565"},{"amount":"21730","token":"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238","recipient":"0xE49ACc3B16c097ec88Dc9352CE4Cd57aB7e35B95","bps":25,"minAmount":"21730"}],"portionAmount":"21730","portionBips":25,"portionRecipient":"0xE49ACc3B16c097ec88Dc9352CE4Cd57aB7e35B95"},"simulateTransaction":true,"refreshGasPrice":true,"gasStrategies":[{"limitInflationFactor":1.15,"displayLimitInflationFactor":1,"priceInflationFactor":1.5,"percentileThresholdFor1559Fee":75,"thresholdToInflateLastBlockBaseFee":0,"baseFeeMultiplier":1.05,"baseFeeHistoryWindow":100,"minPriorityFeeGwei":2,"maxPriorityFeeGwei":9}],"urgency":"normal"}'

plondon avatar Apr 24 '25 12:04 plondon

I took the curl directly from the interface in testnet mode

plondon avatar Apr 24 '25 12:04 plondon

I took the curl directly from the interface in testnet mode

Hi Philip, thank you for looking into this issue, really appreciate it.

It seems our request data is quite different (see the diff here: https://www.diffchecker.com/wX4SaCBz/; mine is on the left and includes extra permitData). Also, I still encountered this error, but fortunately, the error message is much clearer now.

Image

hope this cURL helps:

curl 'https://trading-api-labs.interface.gateway.uniswap.org/v1/swap' \
  -H 'accept: */*' \
  -H 'accept-language: en-US,en;q=0.9' \
  -H 'content-type: application/json' \
  -H 'origin: https://app.uniswap.org' \
  -H 'priority: u=1, i' \
  -H 'referer: https://app.uniswap.org/' \
  -H 'sec-ch-ua: "Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: same-site' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36' \
  -H 'x-api-key: JoyCGj29tT4pymvhaGciK4r1aIPvqW6W53xT1fwo' \
  -H 'x-app-version;' \
  -H 'x-request-source: uniswap-web' \
  -H 'x-universal-router-version: 2.0' \
  --data-raw '{"quote":{"chainId":11155111,"input":{"amount":"85898038740436789","token":"0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14"},"output":{"amount":"701985454","token":"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238","recipient":"0xe197F4cA9E97508405eCadDE9c48c50D119c6434"},"swapper":"0xe197F4cA9E97508405eCadDE9c48c50D119c6434","route":[[{"type":"v3-pool","address":"0x3289680dD4d6C10bb19b899729cda5eEF58AEfF1","tokenIn":{"chainId":11155111,"decimals":"18","address":"0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14","symbol":"WETH"},"tokenOut":{"chainId":11155111,"decimals":"6","address":"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238","symbol":"USDC"},"fee":"500","liquidity":"10463983729640419","sqrtRatioX96":"875898987568489912731024560988781","tickCurrent":"186222","amountIn":"77308234866393110","amountOut":"630206086"}],[{"type":"v3-pool","address":"0x6Ce0896eAE6D4BD668fDe41BB784548fb8F59b50","tokenIn":{"chainId":11155111,"decimals":"18","address":"0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14","symbol":"WETH"},"tokenOut":{"chainId":11155111,"decimals":"6","address":"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238","symbol":"USDC"},"fee":"3000","liquidity":"1211268865739628","sqrtRatioX96":"874805539471681605101546037242150","tickCurrent":"186197","amountIn":"8589803874043678","amountOut":"70024404"}]],"slippage":0.5,"tradeType":"EXACT_INPUT","quoteId":"d186ae72-a189-4750-8e1f-56b700d748c2","gasFeeUSD":"0.000289777054952657","gasFeeQuote":"3118","gasUseEstimate":"335344","priceImpact":0.14,"txFailureReasons":[],"maxPriorityFeePerGas":"2000000000","maxFeePerGas":"2000169107","gasFee":"670744709017808","gasEstimates":[{"type":"eip1559","strategy":{"limitInflationFactor":1.15,"priceInflationFactor":1.5,"percentileThresholdFor1559Fee":75,"thresholdToInflateLastBlockBaseFee":0,"baseFeeMultiplier":1.05,"baseFeeHistoryWindow":100,"minPriorityFeeGwei":2,"maxPriorityFeeGwei":9},"gasLimit":"385645","gasFee":"771355215269015","maxFeePerGas":"2000169107","maxPriorityFeePerGas":"2000000000"}],"routeString":"[V3] 90.00% = WETH -- 0.05% [0x3289680dD4d6C10bb19b899729cda5eEF58AEfF1]USDC, [V3] 10.00% = WETH -- 0.3% [0x6Ce0896eAE6D4BD668fDe41BB784548fb8F59b50]USDC","blockNumber":"8196367","aggregatedOutputs":[{"amount":"700230491","token":"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238","recipient":"0xe197F4cA9E97508405eCadDE9c48c50D119c6434","bps":9975,"minAmount":"700230491"},{"amount":"1754963","token":"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238","recipient":"0xE49ACc3B16c097ec88Dc9352CE4Cd57aB7e35B95","bps":25,"minAmount":"1754963"}],"portionAmount":"1754963","portionBips":25,"portionRecipient":"0xE49ACc3B16c097ec88Dc9352CE4Cd57aB7e35B95"},"permitData":{"domain":{"name":"Permit2","chainId":11155111,"verifyingContract":"0x000000000022D473030F116dDEE9F6B43aC78BA3"},"types":{"PermitSingle":[{"name":"details","type":"PermitDetails"},{"name":"spender","type":"address"},{"name":"sigDeadline","type":"uint256"}],"PermitDetails":[{"name":"token","type":"address"},{"name":"amount","type":"uint160"},{"name":"expiration","type":"uint48"},{"name":"nonce","type":"uint48"}]},"values":{"details":{"token":"0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14","amount":"1461501637330902918203684832716283019655932542975","expiration":"1748223384","nonce":"0"},"spender":"0x3a9d48ab9751398bbfa63ad67599bb04e4bdf98b","sigDeadline":"1745633184"}},"signature":"0x162485941ba1faf21013656dab1e60e9d7226dc00000004200886fd8cf24ffed1a22621e054fb841e4c19d99d089a0b4120195926830b8a7a003d4b59d32e768b25ea1d21d7d7db2be4ce77ed1779fde18803663bd0d6f048a1b","simulateTransaction":true,"refreshGasPrice":true,"gasStrategies":[{"limitInflationFactor":1.15,"displayLimitInflationFactor":1,"priceInflationFactor":1.5,"percentileThresholdFor1559Fee":75,"thresholdToInflateLastBlockBaseFee":0,"baseFeeMultiplier":1.05,"baseFeeHistoryWindow":100,"minPriorityFeeGwei":2,"maxPriorityFeeGwei":9}],"urgency":"normal"}'

I have a hunch that the problem might be related to the signature field. As far as I know, most dApps verify signatures based on EOA, but in my case, it’s an Smart Account signature. However, the API error doesn’t make much sense to me because it returns a 404 error without any more specific information.

Thanks again for your help!

5oqT avatar Apr 26 '25 01:04 5oqT

Updated: It’s very likely a signature-related issue.

If you use an EOA (Externally Owned Account) to Sign & Swap, the /v1/swap endpoint works fine. Here is the cURL for reference:

curl 'https://trading-api-labs.interface.gateway.uniswap.org/v1/swap' \
  -H 'accept: */*' \
  -H 'accept-language: en-US,en;q=0.9' \
  -H 'content-type: application/json' \
  -H 'origin: https://app.uniswap.org' \
  -H 'priority: u=1, i' \
  -H 'referer: https://app.uniswap.org/' \
  -H 'sec-ch-ua: "Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: same-site' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36' \
  -H 'x-api-key: JoyCGj29tT4pymvhaGciK4r1aIPvqW6W53xT1fwo' \
  -H 'x-app-version;' \
  -H 'x-request-source: uniswap-web' \
  -H 'x-universal-router-version: 2.0' \
  --data-raw '{"quote":{"chainId":11155111,"input":{"amount":"1000000000000000","token":"0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14"},"output":{"amount":"8050594","token":"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238","recipient":"0xb9d3eF27DDBAD4D361A412dc419EBB3A7Ee586c5"},"swapper":"0xb9d3eF27DDBAD4D361A412dc419EBB3A7Ee586c5","route":[[{"type":"v3-pool","address":"0xFeEd501c2B21D315F04946F85fC6416B640240b5","tokenIn":{"chainId":11155111,"decimals":"18","address":"0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14","symbol":"WETH"},"tokenOut":{"chainId":11155111,"decimals":"6","address":"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238","symbol":"USDC"},"fee":"100","liquidity":"7102808607801409","sqrtRatioX96":"882960225495994989742186033702048","tickCurrent":"186383","amountIn":"1000000000000000","amountOut":"8030467"}]],"slippage":0.5,"tradeType":"EXACT_INPUT","quoteId":"5474f72b-3e00-4443-ba31-ded5ac853ee2","gasFeeUSD":"0.015017176372092176","gasFeeQuote":"165234","gasUseEstimate":"208729","priceImpact":0.01,"txFailureReasons":[],"maxPriorityFeePerGas":"2000000000","maxFeePerGas":"2112393056","gasFee":"440917690185824","gasEstimates":[{"type":"eip1559","strategy":{"limitInflationFactor":1.15,"priceInflationFactor":1.5,"percentileThresholdFor1559Fee":75,"thresholdToInflateLastBlockBaseFee":0,"baseFeeMultiplier":1.05,"baseFeeHistoryWindow":100,"minPriorityFeeGwei":2,"maxPriorityFeeGwei":9},"gasLimit":"240038","gasFee":"507054604376128","maxFeePerGas":"2112393056","maxPriorityFeePerGas":"2000000000"}],"routeString":"[V3] 100.00% = WETH -- 0.01% [0xFeEd501c2B21D315F04946F85fC6416B640240b5]USDC","blockNumber":"8197074","aggregatedOutputs":[{"amount":"8030468","token":"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238","recipient":"0xb9d3eF27DDBAD4D361A412dc419EBB3A7Ee586c5","bps":9975,"minAmount":"8030468"},{"amount":"20126","token":"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238","recipient":"0xE49ACc3B16c097ec88Dc9352CE4Cd57aB7e35B95","bps":25,"minAmount":"20126"}],"portionAmount":"20126","portionBips":25,"portionRecipient":"0xE49ACc3B16c097ec88Dc9352CE4Cd57aB7e35B95"},"permitData":{"domain":{"name":"Permit2","chainId":11155111,"verifyingContract":"0x000000000022D473030F116dDEE9F6B43aC78BA3"},"types":{"PermitSingle":[{"name":"details","type":"PermitDetails"},{"name":"spender","type":"address"},{"name":"sigDeadline","type":"uint256"}],"PermitDetails":[{"name":"token","type":"address"},{"name":"amount","type":"uint160"},{"name":"expiration","type":"uint48"},{"name":"nonce","type":"uint48"}]},"values":{"details":{"token":"0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14","amount":"1461501637330902918203684832716283019655932542975","expiration":"1748232583","nonce":"2"},"spender":"0x3a9d48ab9751398bbfa63ad67599bb04e4bdf98b","sigDeadline":"1745642383"}},"signature":"0xb0b2a663b016a0ab492220ac9cf7895df753a2700b9a52ba18eb1f63c4f7190c3c712553912a8ed73aa1912543f128ab7e778fc0a65790f8f9a07f82911e1e821c","simulateTransaction":true,"refreshGasPrice":true,"gasStrategies":[{"limitInflationFactor":1.15,"displayLimitInflationFactor":1,"priceInflationFactor":1.5,"percentileThresholdFor1559Fee":75,"thresholdToInflateLastBlockBaseFee":0,"baseFeeMultiplier":1.05,"baseFeeHistoryWindow":100,"minPriorityFeeGwei":2,"maxPriorityFeeGwei":9}],"urgency":"normal"}'

However, when using a Smart Contract Account, /v1/swap throws an error.

The request data for both cases looks very similar, and the only suspicious difference I can spot (see: https://www.diffchecker.com/X0JqnoOa/) is in the signature field.

From what I understand, EOAs sign transactions directly with a private key, while Smart Contract Accounts use contract logic for authorization (EIP-1271), which may result in a different signature format or validation process. This might be why the API is failing when handling signatures from Smart Contract Accounts.

@plondon Do you think it’s possible that the issue is related to the signature?

5oqT avatar Apr 26 '25 04:04 5oqT

btw, to reproduce Sign & Swap, if you have signed before, you have to revoke it (I recommend https://revoke.cash/).

5oqT avatar Apr 26 '25 04:04 5oqT

Hey @am9p what smart contract account are you using? Have you delegated your wallet to a smart contract wallet?

plondon avatar May 01 '25 15:05 plondon

@am9p Your example is very useful. but i have question about uniswap x api request. in classic swap we can use end point 'https://trading-api-labs.interface.gateway.uniswap.org/v1/swap'

but if route include uniswap x path. i cant use that endpoint. i added qoute path to header but api response make wrong header.... how to make api request with uniswap x path

nanahos avatar May 02 '25 12:05 nanahos

Hey @am9p what smart contract account are you using? Have you delegated your wallet to a smart contract wallet?

Elytro. It's still in beta. The wallet I connected to Uniswap is a smart contract wallet, so I guess there's no need to delegate-it is already a smart contract wallet.

5oqT avatar May 02 '25 15:05 5oqT