-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# CELER - TVL by User | ||
|
||
In this repo you will find the code responsible to get data from the celer pool the TVL by users. | ||
The main scripts is generating a output as CSV | ||
|
||
## How to execute this project? | ||
|
||
``` | ||
npm install // install all packages | ||
npm run start // other terminal tab | ||
``` | ||
|
||
Now you can see the outputData.csv file. That's it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "celer", | ||
"version": "1.0.0", | ||
"private": true, | ||
"type": "module", | ||
"dependencies": { | ||
"fast-csv": "^5.0.1" | ||
}, | ||
"scripts": { | ||
"start": "node dist/index.js", | ||
"dev": "node src/index.js" | ||
}, | ||
"browserslist": { | ||
"production": [ | ||
">0.2%", | ||
"not dead", | ||
"not op_mini all" | ||
], | ||
"development": [ | ||
"last 1 chrome version", | ||
"last 1 firefox version", | ||
"last 1 safari version" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { write } from "fast-csv"; | ||
import fs from "fs"; | ||
|
||
const exportCSV = async (blockNumber, blockTimestamp) => { | ||
console.log("downloading..."); | ||
const csvRows = []; | ||
const res = await fetch( | ||
`https://cbridge-prod2.celer.app/v1/getLineaLiquiditySnapshot?linea_block_number=${blockNumber}&linea_block_timestamp=${blockTimestamp}` | ||
); | ||
const resData = await res.json(); | ||
resData.entries?.forEach((item) => { | ||
csvRows.push({ | ||
user: "0x" + item.user_address, | ||
pool: item.token_address, | ||
block: blockNumber, | ||
lpvalue: item.token_balance, | ||
}); | ||
}); | ||
// Write the CSV output to a file | ||
const ws = fs.createWriteStream("outputData.csv"); | ||
write(csvRows, { headers: true }) | ||
.pipe(ws) | ||
.on("finish", () => { | ||
console.log("CSV file has been written."); | ||
}); | ||
}; | ||
|
||
exportCSV(19506984, 1711429021); |