import { Address } from 'viem'; import { fetchGraphData } from './fetch-graph'; import { ORDER_FILLED_HISTORY_QUERY, OrderFilledHistoryEntity, transform, } from './query/order-history'; import { PrexApiService } from '../api'; export async function querySwapHistory( apiService: PrexApiService, query: { user?: Address; }, offset: number, limit: number ) { if (query.user) { const body = await fetchGraphData( apiService, 'swapV1Histories', ORDER_FILLED_HISTORY_QUERY, { offset, limit, address: query.user?.toLowerCase(), } ); const history = body as OrderFilledHistoryEntity; return transform(history); } else { throw new Error('Invalid query'); } }