From 0d7a8315ab4caf6079f7f1091509cbd684760c36 Mon Sep 17 00:00:00 2001 From: Tom Beynon Date: Mon, 12 Feb 2024 15:47:00 +0000 Subject: [PATCH] Add dYdX APR from Apybara --- chains/chainMonitor.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/chains/chainMonitor.js b/chains/chainMonitor.js index 2808e16..1988289 100644 --- a/chains/chainMonitor.js +++ b/chains/chainMonitor.js @@ -266,7 +266,18 @@ function ChainMonitor() { async function calculateApr(chain, annualProvision, bondedTokens, communityTax, blocksPerYear, actualBlocksPerYear) { const path = chain.path try { - if (path === 'sifchain') { + if (path === 'dydx' && process.env.APYBARA_API_KEY) { + const opts = { + headers: { + 'X-ACCESS-KEY': `${process.env.APYBARA_API_KEY}` + }, + ...gotOpts + } + const aprRequest = await got.get("https://api.protocolstaking.info/v0/protocols/dydx", opts).json(); + return { + calculatedApr: aprRequest[0]?.rewardRate + } + } else if (path === 'sifchain') { const aprRequest = await got.get("https://data.sifchain.finance/beta/validator/stakingRewards", gotOpts).json(); return { calculatedApr: aprRequest.rate