Skip to content

Commit

Permalink
Allow buyToken and sellToken to be the same
Browse files Browse the repository at this point in the history
  • Loading branch information
capezzbr committed Mar 2, 2023
1 parent b20c76e commit 8514ae9
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/handlers/swap_handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 8514ae9

Please sign in to comment.