From f51c47434525a5f67510fe7228cd44deafdf80a0 Mon Sep 17 00:00:00 2001 From: trxadm Date: Mon, 2 Jun 2025 11:41:58 +0300 Subject: [PATCH 01/11] Add TR.ENERGY yield adapter (TRON) --- src/adaptors/trenergy.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/adaptors/trenergy.js diff --git a/src/adaptors/trenergy.js b/src/adaptors/trenergy.js new file mode 100644 index 0000000000..713c2c17e6 --- /dev/null +++ b/src/adaptors/trenergy.js @@ -0,0 +1,22 @@ +const utils = require('../utils'); + +module.exports = { + timetravel: false, + apy: async () => { + const priceData = await utils.getPrices(['tron']); + const trxPrice = priceData['tron'].price; + const stakedTRX = 42968491; + const tvlUsd = stakedTRX * trxPrice; + + return [ + { + pool: 'trenergy-trx', + chain: 'Tron', + project: 'trenergy', + symbol: 'TRX', + tvlUsd: tvlUsd, + apyBase: 20.0, // твоя ставка + }, + ]; + }, +}; From 05984da0a3fe2cbb37d986c627a9b9ac2951d634 Mon Sep 17 00:00:00 2001 From: trxadm Date: Wed, 4 Jun 2025 13:44:15 +0300 Subject: [PATCH 02/11] Debag trenergy.js --- src/adaptors/trenergy.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/adaptors/trenergy.js b/src/adaptors/trenergy.js index 713c2c17e6..f0f0cd1b7f 100644 --- a/src/adaptors/trenergy.js +++ b/src/adaptors/trenergy.js @@ -1,12 +1,13 @@ -const utils = require('../utils'); +const utils = require('../../utils'); module.exports = { timetravel: false, apy: async () => { - const priceData = await utils.getPrices(['tron']); - const trxPrice = priceData['tron'].price; - const stakedTRX = 42968491; - const tvlUsd = stakedTRX * trxPrice; + const price = await utils.getPrices(['tron']); + const trxPrice = price['tron'].price; + + //TRX Stacked + const totalTRX = 168153490; return [ { @@ -14,8 +15,8 @@ module.exports = { chain: 'Tron', project: 'trenergy', symbol: 'TRX', - tvlUsd: tvlUsd, - apyBase: 20.0, // твоя ставка + tvlUsd: totalTRX * trxPrice, + apyBase: 18.36, // APY Average per 1 Year }, ]; }, From 924bb393bc8f55225bf73811dac10060a75b0913 Mon Sep 17 00:00:00 2001 From: trxadm Date: Wed, 4 Jun 2025 13:45:54 +0300 Subject: [PATCH 03/11] Create utils.js --- utils.js | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 utils.js diff --git a/utils.js b/utils.js new file mode 100644 index 0000000000..425fc1bcee --- /dev/null +++ b/utils.js @@ -0,0 +1,8 @@ +module.exports = { + getPrices: async (tokens) => { + // Пример: возвращает цену TRX = 0.26$ + return { + tron: { price: 0.26 }, + }; + }, +}; From a15e78c7d30ee0beb2350b6ee227b593350c8db8 Mon Sep 17 00:00:00 2001 From: trxadm Date: Wed, 4 Jun 2025 13:46:42 +0300 Subject: [PATCH 04/11] Create test.js --- test.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 test.js diff --git a/test.js b/test.js new file mode 100644 index 0000000000..d0d3a29809 --- /dev/null +++ b/test.js @@ -0,0 +1,9 @@ +const adapter = require('./src/adaptors/trenergy'); + +adapter.apy() + .then(data => { + console.log('TR.ENERGY APY output:\n', data); + }) + .catch(err => { + console.error('Error running TR.ENERGY adapter:\n', err); + }); From 872d19735d061de75c9287cd3c5e6a1ac8779b0c Mon Sep 17 00:00:00 2001 From: trxadm Date: Fri, 13 Jun 2025 14:00:13 +0300 Subject: [PATCH 05/11] Update trenergy.js Add dynamic TRX price from core.tr.energy and calculate TVL from total_energy. --- src/adaptors/trenergy.js | 43 +++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/src/adaptors/trenergy.js b/src/adaptors/trenergy.js index f0f0cd1b7f..fdefd32cbc 100644 --- a/src/adaptors/trenergy.js +++ b/src/adaptors/trenergy.js @@ -1,23 +1,30 @@ -const utils = require('../../utils'); +const axios = require("axios"); +const { getTrxPrice } = require("../../utils"); -module.exports = { - timetravel: false, - apy: async () => { - const price = await utils.getPrices(['tron']); - const trxPrice = price['tron'].price; +async function tvl() { + try { + const stats = await axios.get("https://core.tr.energy/api/energy-stats"); + const trxPrice = await getTrxPrice(); + + const totalEnergy = stats.data.data.total_energy; + const tvlInTrx = totalEnergy / 10.52; + const tvlInUsd = tvlInTrx * trxPrice; - //TRX Stacked - const totalTRX = 168153490; + return { + tron: tvlInUsd + }; + } catch (error) { + console.error("Failed to fetch TR.ENERGY TVL data:", error); + return {}; + } +} - return [ - { - pool: 'trenergy-trx', - chain: 'Tron', - project: 'trenergy', - symbol: 'TRX', - tvlUsd: totalTRX * trxPrice, - apyBase: 18.36, // APY Average per 1 Year - }, - ]; +module.exports = { + timetravel: false, + misrepresentedTokens: true, + tron: { + tvl, }, + methodology: + "TVL is calculated as the total amount of delegated energy divided by the coefficient 10.52 (representing the TRX-to-energy rate). The resulting TRX value is then converted to USD using the TRX price obtained from https://core.tr.energy/api/config", }; From 188b6de40992ff99a91f2367d67945981d854525 Mon Sep 17 00:00:00 2001 From: trxadm Date: Fri, 13 Jun 2025 14:03:23 +0300 Subject: [PATCH 06/11] Update utils.js Fetch TRX/USDT rate from core.tr.energy instead of hardcoding --- utils.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/utils.js b/utils.js index 425fc1bcee..45cbd88896 100644 --- a/utils.js +++ b/utils.js @@ -1,8 +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 = { - getPrices: async (tokens) => { - // Пример: возвращает цену TRX = 0.26$ - return { - tron: { price: 0.26 }, - }; - }, + getTrxPrice }; From 7283e30d581a10ceab97b42c6ba7869e595b680b Mon Sep 17 00:00:00 2001 From: trxadm Date: Fri, 13 Jun 2025 14:09:16 +0300 Subject: [PATCH 07/11] Update test.js Delete test.js --- test.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/test.js b/test.js index d0d3a29809..8b13789179 100644 --- a/test.js +++ b/test.js @@ -1,9 +1 @@ -const adapter = require('./src/adaptors/trenergy'); -adapter.apy() - .then(data => { - console.log('TR.ENERGY APY output:\n', data); - }) - .catch(err => { - console.error('Error running TR.ENERGY adapter:\n', err); - }); From 5552d88c30f8ebcc28ac0e0636ca8a1f124f2e35 Mon Sep 17 00:00:00 2001 From: trxadm Date: Thu, 26 Jun 2025 15:54:11 +0300 Subject: [PATCH 08/11] Update trenergy.js --- src/adaptors/trenergy.js | 62 ++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/src/adaptors/trenergy.js b/src/adaptors/trenergy.js index fdefd32cbc..092a794e24 100644 --- a/src/adaptors/trenergy.js +++ b/src/adaptors/trenergy.js @@ -1,30 +1,44 @@ +// src/adaptors/trenergy/trenergy.js const axios = require("axios"); -const { getTrxPrice } = require("../../utils"); - -async function tvl() { - try { - const stats = await axios.get("https://core.tr.energy/api/energy-stats"); - const trxPrice = await getTrxPrice(); - - const totalEnergy = stats.data.data.total_energy; - const tvlInTrx = totalEnergy / 10.52; - const tvlInUsd = tvlInTrx * trxPrice; - - return { - tron: tvlInUsd - }; - } catch (error) { - console.error("Failed to fetch TR.ENERGY TVL data:", error); - return {}; - } + + +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: "trenergy", + symbol: "TRX", + tvlUsd, + apyBase: baseApy, + underlyingTokens: ["TRX"], + url: "https://tr.energy", + }, + ]; } module.exports = { timetravel: false, - misrepresentedTokens: true, - tron: { - tvl, - }, - methodology: - "TVL is calculated as the total amount of delegated energy divided by the coefficient 10.52 (representing the TRX-to-energy rate). The resulting TRX value is then converted to USD using the TRX price obtained from https://core.tr.energy/api/config", + apy, + url: "https://tr.energy", }; From c1b2c105d19b7eb12f4186e02f899f9e3b3260a5 Mon Sep 17 00:00:00 2001 From: trxadm Date: Thu, 26 Jun 2025 15:54:42 +0300 Subject: [PATCH 09/11] Delete test.js --- test.js | 1 - 1 file changed, 1 deletion(-) delete mode 100644 test.js diff --git a/test.js b/test.js deleted file mode 100644 index 8b13789179..0000000000 --- a/test.js +++ /dev/null @@ -1 +0,0 @@ - From 854503f7b72b3e455575383f75ed5e5824995363 Mon Sep 17 00:00:00 2001 From: trxadm Date: Fri, 27 Jun 2025 19:03:43 +0300 Subject: [PATCH 10/11] Update trenergy.js Changed project: "trenergy" to project: "tr-energy" --- src/adaptors/trenergy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/adaptors/trenergy.js b/src/adaptors/trenergy.js index 092a794e24..1d2624555b 100644 --- a/src/adaptors/trenergy.js +++ b/src/adaptors/trenergy.js @@ -1,4 +1,4 @@ -// src/adaptors/trenergy/trenergy.js + const axios = require("axios"); @@ -27,7 +27,7 @@ async function apy() { { pool: "trenergy-trx", chain: "Tron", - project: "trenergy", + project: "tr-energy", symbol: "TRX", tvlUsd, apyBase: baseApy, From 1e531b32aa754cbe0fdbe7a1e3895ee65487459f Mon Sep 17 00:00:00 2001 From: trxadm Date: Fri, 27 Jun 2025 19:06:20 +0300 Subject: [PATCH 11/11] Update trenergy.js edited index.js --- src/adaptors/trenergy.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/adaptors/trenergy.js b/src/adaptors/trenergy.js index 1d2624555b..0421026e0d 100644 --- a/src/adaptors/trenergy.js +++ b/src/adaptors/trenergy.js @@ -31,14 +31,16 @@ async function apy() { symbol: "TRX", tvlUsd, apyBase: baseApy, - underlyingTokens: ["TRX"], + underlyingTokens: ["TRX"], url: "https://tr.energy", }, ]; } module.exports = { + project: "tr-energy", timetravel: false, - apy, + apy, url: "https://tr.energy", -}; + misrepresentedTokens: true, +}