diff --git a/lib/entities/QuoteResponse.ts b/lib/entities/QuoteResponse.ts index 4ca8394b..050bcf8f 100644 --- a/lib/entities/QuoteResponse.ts +++ b/lib/entities/QuoteResponse.ts @@ -54,14 +54,17 @@ export class QuoteResponse implements QuoteResponseData { stripUnknown: true, }); - if (responseValidation.error) { + if (responseValidation?.error) { validationError = { message: responseValidation.error?.message, value: data, }; } - 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,