-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkyberSwapCrawler.js
41 lines (35 loc) · 930 Bytes
/
kyberSwapCrawler.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import React from 'react';
import { useQuery } from '@apollo/react-hooks';
import ApolloClient, { gql } from 'apollo-boost';
const ENDPOINT = "https://api.thegraph.com/subgraphs/name/blocklytics/kyberswap"
const client = new ApolloClient({
uri: ENDPOINT,
});
const QUERY = gql`
{
proxyTrades(
first: 5, skip: 0,
orderBy: createdAtBlockTimestamp,
orderDirection: desc) {
id
trader {
id
}
src
dest
actualSrcAmount
actualDestAmount
createdAtBlockTimestamp
createdAtBlockNumber
createdAtLogIndex
}
}
`;
function tradeRates() {
const { loading, error, data } = useQuery(QUERY);
if (loading) return "Loading now...";
if (error) return "Error response";
return data.proxyTrades.map(({ id, actualSrcAmount, actualDestAmount }) => (
{id}: {actualSrcAmount / actualDestAmount}
));
}