Skip to content

Commit

Permalink
add celer adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
MHHard committed Mar 27, 2024
1 parent 6520ee1 commit 0cfef9a
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
13 changes: 13 additions & 0 deletions adapters/celer/README.md
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.
25 changes: 25 additions & 0 deletions adapters/celer/package.json
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"
]
}
}
28 changes: 28 additions & 0 deletions adapters/celer/src/index.js
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);

0 comments on commit 0cfef9a

Please sign in to comment.