From 8514ae9f7417fa11c585be9facc3467b4041f720 Mon Sep 17 00:00:00 2001 From: Bruno C Date: Wed, 22 Feb 2023 23:48:37 -0500 Subject: [PATCH] Allow buyToken and sellToken to be the same --- src/handlers/swap_handlers.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/handlers/swap_handlers.ts b/src/handlers/swap_handlers.ts index 82a26a36af..6bee4af81c 100644 --- a/src/handlers/swap_handlers.ts +++ b/src/handlers/swap_handlers.ts @@ -397,18 +397,18 @@ const parseSwapQuoteRequestParams = (req: express.Request, endpoint: 'price' | ' ).toLowerCase(); const isWrap = isNativeSell && isNativeWrappedSymbolOrAddress(buyToken, CHAIN_ID); const isUnwrap = isNativeWrappedSymbolOrAddress(sellToken, CHAIN_ID) && isNativeBuy; - // if token addresses are the same but a unwrap or wrap operation is requested, ignore error - if (!isUnwrap && !isWrap && sellToken === buyToken) { - throw new ValidationError( - ['buyToken', 'sellToken'].map((field) => { - return { - field, - code: ValidationErrorCodes.RequiredField, - reason: 'buyToken and sellToken must be different', - }; - }), - ); - } + // // if token addresses are the same but a unwrap or wrap operation is requested, ignore error + // if (!isUnwrap && !isWrap && sellToken === buyToken) { + // throw new ValidationError( + // ['buyToken', 'sellToken'].map((field) => { + // return { + // field, + // code: ValidationErrorCodes.RequiredField, + // reason: 'buyToken and sellToken must be different', + // }; + // }), + // ); + // } if (sellToken === NULL_ADDRESS || buyToken === NULL_ADDRESS) { throw new ValidationError(