Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add idliemine revenue #1484

Closed
wants to merge 16 commits into from
57 changes: 57 additions & 0 deletions fees/idlemine/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { Adapter, FetchOptions } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import fetchURL from "../../utils/fetchURL";

// Define the interface for the data you expect to receive from the API.
interface DailyStats {
timestamp: number;
totalFees: number;
totalRevenue: number;
dailyFees: number;
dailyRevenue: number;
}

/**
* Fetches and processes daily stats from a specific endpoint.
* @param timestampSeconds The timestamp at the start of the day in seconds.
* @returns A promise that resolves to the daily stats.
*/
const fetchDailyStats = async (timestampSeconds: number): Promise<DailyStats> => {
const url = "https://newdemoback.stringmetaverse.com/idlemine/api/revenuedata";
try {
const response = await fetchURL(url);
const idleminedata = response.data; // Adjust these keys based on the actual API response structure



return {
timestamp: timestampSeconds,
dailyRevenue: idleminedata.dailyrevenue,
dailyFees: idleminedata.dailyfees,
totalRevenue: idleminedata.Totalrevenue,
totalFees: idleminedata.Fee,

};
} catch (error) {
console.error("Failed to fetch daily stats:", error);
throw new Error("Error fetching daily stats");
}
};

/**
* Adapter configuration for fetching daily fees and revenues.
*/
const adapter: Adapter = {
version: 2,
adapter: {
[CHAIN.BSC]: {
fetch: fetchDailyStats,
start: 1709251200, // Example start timestamp in seconds.
meta: {
methodology: "Calculates revenues and fees from IdleMine thumb game and IdleMine battle games.",
},
},
},
};

export default adapter;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
"tron-format-address": "^0.1.11"
},
"devDependencies": {
"glob": "^10.3.10",
"@types/node": "^18.7.23",
"glob": "^10.3.10",
"inquirer": "^8.0.0",
"inquirer-fuzzy-path": "^2.3.0",
"ts-node": "^10.9.1",
Expand Down
Loading