diff --git a/lib/entities/QuoteResponse.ts b/lib/entities/QuoteResponse.ts index 4ca8394b..62b986b6 100644 --- a/lib/entities/QuoteResponse.ts +++ b/lib/entities/QuoteResponse.ts @@ -2,9 +2,9 @@ import { TradeType } from '@uniswap/sdk-core'; import { BigNumber } from 'ethers'; import { v4 as uuidv4 } from 'uuid'; +import { QuoteRequestData } from '.'; import { PostQuoteResponse, RfqResponse, RfqResponseJoi } from '../handlers/quote/schema'; import { currentTimestampInMs, timestampInMstoSeconds } from '../util/time'; -import { QuoteRequestData } from '.'; export interface QuoteResponseData extends Omit { @@ -61,7 +61,10 @@ export class QuoteResponse implements QuoteResponseData { }; } - if (request.tokenIn !== data.tokenIn || request.tokenOut !== data.tokenOut) { + if ( + request.tokenIn.toLowerCase() !== data.tokenIn.toLowerCase() || + request.tokenOut.toLowerCase() !== data.tokenOut.toLowerCase() + ) { validationError = { message: `RFQ response token mismatch: request tokenIn: ${request.tokenIn} tokenOut: ${request.tokenOut} response tokenIn: ${data.tokenIn} tokenOut: ${data.tokenOut}`, value: data, diff --git a/test/entities/QuoteResponse.test.ts b/test/entities/QuoteResponse.test.ts index 46b7c03e..5567f333 100644 --- a/test/entities/QuoteResponse.test.ts +++ b/test/entities/QuoteResponse.test.ts @@ -73,6 +73,23 @@ describe('QuoteRequest', () => { expect(response.validationError).toBe(undefined); }); + it('fromRFQ with valid response - allow checksumed', async () => { + const response = QuoteResponse.fromRFQ( + quoteRequest, + { + chainId: CHAIN_ID, + requestId: REQUEST_ID, + tokenIn: TOKEN_IN.toLowerCase(), + amountIn: parseEther('1').toString(), + tokenOut: TOKEN_OUT.toLowerCase(), + amountOut: parseEther('1').toString(), + quoteId: QUOTE_ID, + }, + TradeType.EXACT_INPUT + ); + expect(response.validationError).toBe(undefined); + }); + it('fromRFQ with invalid response - wrong type amountIn', async () => { const invalidResponse = { chainId: CHAIN_ID,