Skip to content

Add TR.ENERGY yield adapter (TRON) #1896

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

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/adaptors/trenergy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

const axios = require("axios");


async function getConfig() {
const { data } = await axios.get("https://core.tr.energy/api/config");
return data.data;
}
async function getStats() {
const { data } = await axios.get("https://core.tr.energy/api/energy-stats");
return data.data;
}


async function apy() {
const cfg = await getConfig();
const stats = await getStats();

// TVL
const tvlTrx = stats.total_energy / 10.52;
const tvlUsd = tvlTrx * cfg.trx_usd_rate;

// APY (profit_percent + static_percent) * percent_cef
const baseApy = (cfg.profit_percent + cfg.static_percent) * cfg.percent_cef * 100;

return [
{
pool: "trenergy-trx",
chain: "Tron",
project: "tr-energy",
symbol: "TRX",
tvlUsd,
apyBase: baseApy,
underlyingTokens: ["TRX"],
url: "https://tr.energy",
},
];
}

module.exports = {
project: "tr-energy",
timetravel: false,
apy,
url: "https://tr.energy",
misrepresentedTokens: true,
}
15 changes: 15 additions & 0 deletions utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const axios = require("axios");

async function getTrxPrice() {
try {
const response = await axios.get("https://core.tr.energy/api/config");
return response.data.data.trx_usd_rate;
} catch (error) {
console.error("Failed to fetch TRX price from core.tr.energy:", error);
return 0.27; // fallback value
}
}

module.exports = {
getTrxPrice
};
Loading