@@ -242,7 +242,85 @@ export class ReservoirService {
242
242
marketplace : string ;
243
243
} >
244
244
> {
245
- return Promise . resolve ( [ ] ) ;
245
+ const endOperation = this . performanceMonitor . startOperation (
246
+ "getFloorListings" ,
247
+ { options }
248
+ ) ;
249
+
250
+ try {
251
+ // Validate required parameters
252
+ if ( ! options . collection ) {
253
+ throw new Error ( "Collection address is required" ) ;
254
+ }
255
+
256
+ // Default values
257
+ const limit = options . limit || 10 ;
258
+ const sortBy = options . sortBy || "price" ;
259
+
260
+ // Construct query parameters
261
+ const queryParams = {
262
+ collection : options . collection ,
263
+ limit : limit . toString ( ) ,
264
+ sortBy : sortBy === "price" ? "floorAskPrice" : "rarity" , // Reservoir API specific sorting
265
+ includeAttributes : sortBy === "rarity" ? "true" : "false" ,
266
+ } ;
267
+
268
+ const response = await this . makeRequest < {
269
+ asks : Array < {
270
+ token : {
271
+ tokenId : string ;
272
+ collection : {
273
+ id : string ;
274
+ } ;
275
+ } ;
276
+ price : {
277
+ amount : {
278
+ native : number ;
279
+ usd ?: number ;
280
+ } ;
281
+ } ;
282
+ maker : string ;
283
+ source : {
284
+ name : string ;
285
+ } ;
286
+ } > ;
287
+ } > ( "/collections/floor/v2" , queryParams , 1 , { } as IAgentRuntime ) ;
288
+
289
+ // Transform Reservoir API response to our expected format
290
+ const floorListings = response . asks . map ( ( ask ) => ( {
291
+ tokenId : ask . token . tokenId ,
292
+ price : ask . price . amount . native ,
293
+ seller : ask . maker ,
294
+ marketplace : ask . source ?. name || "Reservoir" ,
295
+ } ) ) ;
296
+
297
+ endOperation ( ) ;
298
+ return floorListings ;
299
+ } catch ( error ) {
300
+ this . performanceMonitor . recordMetric ( {
301
+ operation : "getFloorListings" ,
302
+ duration : 0 ,
303
+ success : false ,
304
+ metadata : {
305
+ error : error . message ,
306
+ collection : options . collection ,
307
+ } ,
308
+ } ) ;
309
+
310
+ const nftError = NFTErrorFactory . create (
311
+ ErrorType . API ,
312
+ ErrorCode . API_ERROR ,
313
+ "Failed to fetch floor listings" ,
314
+ {
315
+ originalError : error ,
316
+ collection : options . collection ,
317
+ } ,
318
+ true
319
+ ) ;
320
+ this . errorHandler . handleError ( nftError ) ;
321
+
322
+ throw error ;
323
+ }
246
324
}
247
325
248
326
async executeBuy ( options : {
0 commit comments