@@ -130,6 +130,17 @@ export const POLYMARKET_API_DOWN = async (mockServer: Mockttp) => {
130130 } ,
131131 } ) ;
132132
133+ await setupMockRequest ( mockServer , {
134+ requestMethod : 'GET' ,
135+ url : / ^ h t t p s : \/ \/ g a m m a - a p i \. p o l y m a r k e t \. c o m \/ e v e n t s \/ k e y s e t / ,
136+ responseCode : 500 ,
137+ response : {
138+ error : 'Internal Server Error' ,
139+ message : 'Service temporarily unavailable' ,
140+ statusCode : 500 ,
141+ } ,
142+ } ) ;
143+
133144 await setupMockRequest ( mockServer , {
134145 requestMethod : 'GET' ,
135146 url : / ^ h t t p s : \/ \/ g a m m a - a p i \. p o l y m a r k e t \. c o m \/ e v e n t s \/ \d + / ,
@@ -1376,7 +1387,7 @@ export const POLYMARKET_USDC_BALANCE_MOCKS = async (
13761387 * Mock for all Polymarket endpoints (positions, redeemable positions, activity, UpNL, order book, and value)
13771388 * Mock for Polymarket market feeds API
13781389 * Returns market feed data using the proxy pattern (consistent with other mocks)
1379- * Intercepts proxy calls to gamma-api.polymarket.com/events/pagination
1390+ * Intercepts proxy calls to gamma-api.polymarket.com/events/pagination and /events/keyset
13801391 */
13811392export const POLYMARKET_MARKET_FEEDS_MOCKS = async ( mockServer : Mockttp ) => {
13821393 // Mock proxy calls to gamma-api.polymarket.com (consistent with other mocks)
@@ -1385,7 +1396,8 @@ export const POLYMARKET_MARKET_FEEDS_MOCKS = async (mockServer: Mockttp) => {
13851396 . matching ( ( request ) => {
13861397 const url = new URL ( request . url ) . searchParams . get ( 'url' ) ;
13871398 return Boolean (
1388- url ?. includes ( 'gamma-api.polymarket.com/events/pagination' ) ,
1399+ url ?. includes ( 'gamma-api.polymarket.com/events/pagination' ) ||
1400+ url ?. includes ( 'gamma-api.polymarket.com/events/keyset' ) ,
13891401 ) ;
13901402 } )
13911403 . asPriority ( PRIORITY . BASE )
@@ -1427,13 +1439,20 @@ export const POLYMARKET_MARKET_FEEDS_MOCKS = async (mockServer: Mockttp) => {
14271439 selectedFeed = POLYMARKET_TRENDING_FEED ;
14281440 }
14291441
1430- // Return the feed data in the correct API structure
1442+ const isKeysetRequest = polymarketUrl . pathname . endsWith ( '/events/keyset' ) ;
1443+
1444+ // Return the feed data in the correct API structure for the requested endpoint.
14311445 return {
14321446 statusCode : 200 ,
1433- json : {
1434- data : selectedFeed . data ,
1435- pagination : selectedFeed . pagination ,
1436- } ,
1447+ json : isKeysetRequest
1448+ ? {
1449+ events : selectedFeed . data ,
1450+ next_cursor : null ,
1451+ }
1452+ : {
1453+ data : selectedFeed . data ,
1454+ pagination : selectedFeed . pagination ,
1455+ } ,
14371456 } ;
14381457 } ) ;
14391458
0 commit comments