Public
Script
October 23, 2023
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
import { fetch } from "https://esm.town/v/std/fetch";
import { subtractFromDate } from "https://esm.town/v/alexandre/subtractFromDate";
export let getAaveV2Liquidations = async () => {
const startTimestamp = Math.round(
subtractFromDate(new Date(), { years: 1 }).getTime() /
1000,
);
const result = await fetch(
"https://gateway.thegraph.com/api/6e951d2948be69a241891fb15ec9cefb/deployments/id/QmYN4ofRb5CUg1WdpLhhNTVCuiiAt29hBKGjTnnxYh9zYt",
{
"headers": {
"accept": "application/json, multipart/mixed",
"accept-language": "en-US,en;q=0.9,fr;q=0.8",
"content-type": "application/json",
"origin": "https://thegraph.com",
"sec-ch-ua": '"Chromium";v="115", "Not/A)Brand";v="99"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": '"macOS"',
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-site",
},
"referrer": "https://thegraph.com/",
"referrerPolicy": "strict-origin-when-cross-origin",
"body":
'{"query":"{\\n liquidates(where: {timestamp_gte: 1658741817}, orderBy: timestamp, first: 1000) {\\n id\\n liquidator {\\n id\\n }\\n liquidatee {\\n id\\n }\\n blockNumber\\n timestamp\\n amountUSD\\n profitUS
"method": "POST",
"mode": "cors",
"credentials": "omit",
},
);
return result.json();
};
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
October 23, 2023