|
1 | | -import { Address, UID } from '@cowprotocol/cow-sdk' |
2 | | - |
3 | 1 | import { orderBookSDK } from 'cowSdk' |
4 | 2 |
|
5 | | -import { GetOrderParams, GetTxOrdersParams, RawOrder, RawTrade, WithNetworkId } from './types' |
| 3 | +import { GetOrderParams, GetTxOrdersParams, RawOrder, RawTrade, GetTradesParams } from './types' |
6 | 4 |
|
7 | 5 | export { getAccountOrders } from './accountOrderUtils' |
8 | 6 |
|
@@ -56,20 +54,19 @@ export async function getTxOrders(params: GetTxOrdersParams): Promise<RawOrder[] |
56 | 54 | * Both filters cannot be used at the same time |
57 | 55 | */ |
58 | 56 | export async function getTrades( |
59 | | - params: { |
60 | | - owner?: Address |
61 | | - orderId?: UID |
62 | | - } & WithNetworkId |
| 57 | + params: GetTradesParams |
63 | 58 | ): Promise<RawTrade[]> { |
64 | | - const { networkId, owner, orderId: orderUid } = params |
65 | | - console.log(`[getTrades] Fetching trades on network ${networkId} with filters`, { owner, orderUid }) |
| 59 | + const { networkId, owner, orderId: orderUid, offset, limit } = params |
| 60 | + console.log(`[getTrades] Fetching trades on network ${networkId} with filters`, { owner, orderUid, offset, limit }) |
66 | 61 |
|
67 | | - const tradesPromise = orderBookSDK.getTrades({ owner, orderUid }, { chainId: networkId }).catch((error) => { |
68 | | - console.error('[getTrades] Error getting PROD trades', params, error) |
69 | | - return [] |
70 | | - }) |
| 62 | + const tradesPromise = orderBookSDK |
| 63 | + .getTrades({ owner, orderUid, offset, limit }, { chainId: networkId }) |
| 64 | + .catch((error) => { |
| 65 | + console.error('[getTrades] Error getting PROD trades', params, error) |
| 66 | + return [] |
| 67 | + }) |
71 | 68 | const tradesPromiseBarn = orderBookSDK |
72 | | - .getTrades({ owner, orderUid }, { chainId: networkId, env: 'staging' }) |
| 69 | + .getTrades({ owner, orderUid, offset, limit }, { chainId: networkId, env: 'staging' }) |
73 | 70 | .catch((error) => { |
74 | 71 | console.error('[getTrades] Error getting BARN trades', params, error) |
75 | 72 | return [] |
|
0 commit comments