Skip to content

Commit

Permalink
fix sunpump data
Browse files Browse the repository at this point in the history
  • Loading branch information
dtmkeng committed Sep 3, 2024
1 parent 62daf4f commit c120fea
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions fees/sunpump.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
import { time } from "console";
import { Adapter, FetchOptions, } from "../adapters/types";
import { CHAIN } from "../helpers/chains";
import { httpGet } from "../utils/fetchURL";

const api = "https://openapi.sunpump.meme/pump-api/api/feeData"
interface IResponse {
date: number;
count: number;
amount: number;
}

const adapter: Adapter = {
version: 2,
version: 1,
adapter: {
[CHAIN.TRON]: {
fetch: (async (options: FetchOptions) => {
fetch: (async (_t: any, _a: any ,options: FetchOptions) => {
const start = options.startOfDay * 1000;
const end = start + 86400;
const startStr = new Date(start).toISOString().split("T")[0];
const endStr = new Date(end).toISOString().split("T")[0];
const url = `${api}?fromDate=${startStr}&toDate=${endStr}`;
const res: IResponse[] = (await httpGet(url)).data;
const dailyFees = options.createBalances();
const start = await options.getFromBlock();
const end = await options.getToBlock();
const logs = []
for(let i = start; i <= end; i+=2000) {
const _logs = await options.getLogs({
target: 'TG9nDZMUtC4LBmrWSdNXNi8xrKzXTMMSKT',
eventAbi: "event TRXReceived(address indexed from,uint256 amount)",
fromBlock: start,
toBlock: start + 2000,
})
logs.push(..._logs)
}
logs.map((tx: any) => {
dailyFees.addGasToken(tx.amount)
})
return { dailyFees, dailyRevenue: dailyFees, }
const dayItem = res.find((item) => item.date === start);
dailyFees.addGasToken((dayItem?.amount || 0) * 1e6);
return { dailyFees, dailyRevenue: dailyFees, timestamp: options.startOfDay };
}) as any,
start: 0
start: 1723334400
},
},

Expand Down

0 comments on commit c120fea

Please sign in to comment.