From d2e5acf76fb0b0e6f06da408c1dd2ddba2fa7e84 Mon Sep 17 00:00:00 2001 From: MirthFutures Date: Mon, 30 Sep 2024 11:11:32 -0400 Subject: [PATCH] Add more Rootstock data --- .../rootstock/platforms/beefyfinance.ts | 4 +- .../address-book/rootstock/tokens/tokens.ts | 4 +- src/api/cowcentrated/getCowClms.ts | 2 + .../providers/merkl/MerklProvider.ts | 23 +++----- src/api/stats/getAmmPrices.ts | 2 + src/api/stats/getApys.js | 2 + src/api/stats/getNonAmmPrices.ts | 2 + .../rootstock/getBeefyCowRootstockApys.ts | 5 ++ .../rootstock/getBeefyRootstockCowPrices.ts | 5 ++ src/api/stats/rootstock/index.js | 53 +++++++++++++++++++ src/data/rootstock/beefyCowVaults.json | 14 +++++ 11 files changed, 95 insertions(+), 21 deletions(-) create mode 100644 src/api/stats/rootstock/getBeefyCowRootstockApys.ts create mode 100644 src/api/stats/rootstock/getBeefyRootstockCowPrices.ts create mode 100644 src/api/stats/rootstock/index.js create mode 100644 src/data/rootstock/beefyCowVaults.json diff --git a/packages/address-book/src/address-book/rootstock/platforms/beefyfinance.ts b/packages/address-book/src/address-book/rootstock/platforms/beefyfinance.ts index 062374ad8..399b95225 100644 --- a/packages/address-book/src/address-book/rootstock/platforms/beefyfinance.ts +++ b/packages/address-book/src/address-book/rootstock/platforms/beefyfinance.ts @@ -17,8 +17,8 @@ export const beefyfinance = { voter: '0x5e1caC103F943Cd84A1E92dAde4145664ebf692A', beefyFeeConfig: '0xfc69704cC3cAac545cC7577009Ea4AA04F1a61Eb', vaultFactory: '0xe103ab2f922aa1a56EC058AbfDA2CeEa1e95bCd7', - //zap: '0x6f66F246Bb436B6f4E66A992C2218b57cD906109', - //zapTokenManager: '0xD3D46FF34cD495d5B91b8F3C5C552E81E5e3eab5', + zap: '0x2E0A7064A5bA7B9b7499997D91885BaDd5FC45f6', + zapTokenManager: '0xC01cE221D1da322A5B8322fC195b407FEa32240E', /// CLM Contracts clmFactory: '0xC2cEE7cf27D2Eda09fEc1743f3953dA77Bf1DA61', diff --git a/packages/address-book/src/address-book/rootstock/tokens/tokens.ts b/packages/address-book/src/address-book/rootstock/tokens/tokens.ts index 6c3461a1a..c102f391c 100644 --- a/packages/address-book/src/address-book/rootstock/tokens/tokens.ts +++ b/packages/address-book/src/address-book/rootstock/tokens/tokens.ts @@ -4,12 +4,12 @@ const RBTC = { name: 'Wrapped Rootstock BTC', address: '0x542fDA317318eBF1d3DEAf76E0b632741A7e677d', symbol: 'WRBTC', - oracleId: 'WRBTC', + oracleId: 'WBTC', decimals: 18, chainId: 30, website: 'https://rootstock.io/rbtc/', description: - 'RBTC, the smart version of Bitcoin.Allowing BTC owners to interact with DeFi protocols and dApps on Rootstock network for minting, swaps, gas fees and more.', + 'RBTC, the smart version of Bitcoin. Allowing BTC owners to interact with DeFi protocols and dApps on Rootstock network for minting, swaps, gas fees and more.', bridge: 'rootstock-canonical', logoURI: '', documentation: diff --git a/src/api/cowcentrated/getCowClms.ts b/src/api/cowcentrated/getCowClms.ts index 16a6e7cfb..b74bbd568 100644 --- a/src/api/cowcentrated/getCowClms.ts +++ b/src/api/cowcentrated/getCowClms.ts @@ -12,6 +12,7 @@ import mantlePools from '../../data/mantle/beefyCowVaults.json'; import seiPools from '../../data/sei/beefyCowVaults.json'; import bscPools from '../../data/bsc/beefyCowVaults.json'; import avaxPools from '../../data/avax/beefyCowVaults.json'; +import rootstockPools from '../../data/rootstock/beefyCowVaults.json'; const chainToClms: Readonly>> = { optimism: validateCowClms(optimismPools), base: validateCowClms(basePools), @@ -25,6 +26,7 @@ const chainToClms: Readonly>> = { sei: validateCowClms(seiPools), bsc: validateCowClms(bscPools), avax: validateCowClms(avaxPools), + rootstock: validateCowClms(rootstockPools), }; const chainsWithClms = (Object.keys(chainToClms) as ReadonlyArray).filter( diff --git a/src/api/offchain-rewards/providers/merkl/MerklProvider.ts b/src/api/offchain-rewards/providers/merkl/MerklProvider.ts index 5fe517e2e..c6dc8010e 100644 --- a/src/api/offchain-rewards/providers/merkl/MerklProvider.ts +++ b/src/api/offchain-rewards/providers/merkl/MerklProvider.ts @@ -30,6 +30,7 @@ const supportedChains = new Set([ 'fraxtal', 'celo', 'sei', + 'rootstock', ]); const campaignCreatorToType: Record = { '0xb1F1000b4FCae7CD07370cE1A3E3b11270caC0dE': 'test', @@ -123,9 +124,7 @@ export class MerklProvider implements IOffchainRewardProvider { }; }); - const computeChain = apiCampaign.computeChainId - ? fromChainNumber(apiCampaign.computeChainId) - : undefined; + const computeChain = apiCampaign.computeChainId ? fromChainNumber(apiCampaign.computeChainId) : undefined; const claimChain = apiCampaign.chainId ? fromChainNumber(apiCampaign.chainId) : undefined; return { @@ -149,9 +148,7 @@ export class MerklProvider implements IOffchainRewardProvider { }; } - protected async fetchCampaignsForChain( - chainId: AppChain - ): Promise { + protected async fetchCampaignsForChain(chainId: AppChain): Promise { const numericChainId = toChainId(chainId); try { @@ -162,18 +159,12 @@ export class MerklProvider implements IOffchainRewardProvider { }, }); if (!data || typeof data !== 'object') { - throw new ProviderApiError( - `fetchCampaignsForChain(${chainId}): response error`, - providerId - ); + throw new ProviderApiError(`fetchCampaignsForChain(${chainId}): response error`, providerId); } if (Object.keys(data).length === 0) { if (throwIfNoData) { - throw new ProviderApiError( - `fetchCampaignsForChain(${chainId}): no data returned`, - providerId - ); + throw new ProviderApiError(`fetchCampaignsForChain(${chainId}): no data returned`, providerId); } return {}; } @@ -192,9 +183,7 @@ export class MerklProvider implements IOffchainRewardProvider { throw err; } throw new ProviderApiError( - `fetchCampaignsForChain(${chainId}): ${ - err && err instanceof Error ? err.message : 'unknown error' - }`, + `fetchCampaignsForChain(${chainId}): ${err && err instanceof Error ? err.message : 'unknown error'}`, providerId, err && err instanceof Error ? err : undefined ); diff --git a/src/api/stats/getAmmPrices.ts b/src/api/stats/getAmmPrices.ts index b2591f418..68f7c583b 100644 --- a/src/api/stats/getAmmPrices.ts +++ b/src/api/stats/getAmmPrices.ts @@ -249,6 +249,8 @@ const coinGeckoCoins: Record = { shezmueth: ['ShezETH'], 'knox-dollar': ['KNOX'], 'gogopool-ggavax': ['ggAVAX'], + 'rif-token': ['RIF'], + 'dollar-on-chain': ['DOC'], }; /** diff --git a/src/api/stats/getApys.js b/src/api/stats/getApys.js index 5f9edae04..72368c9be 100644 --- a/src/api/stats/getApys.js +++ b/src/api/stats/getApys.js @@ -26,6 +26,7 @@ const { getModeApys } = require('./mode'); const { getMantaApys } = require('./manta'); const { getRealApys } = require('./real'); const { getSeiApys } = require('./sei'); +const { getRootstockApys } = require('./rootstock'); const { getKey, setKey } = require('../../utils/cache'); const { fetchBoostAprs, BOOST_APR_EXPIRED } = require('./getBoostAprs'); const { serviceEventBus } = require('../../utils/ServiceEventBus'); @@ -81,6 +82,7 @@ const updateApys = async () => { getMantaApys(), getRealApys(), getSeiApys(), + getRootstockApys(), ]); for (const result of results) { diff --git a/src/api/stats/getNonAmmPrices.ts b/src/api/stats/getNonAmmPrices.ts index 4e9bef7f1..dbf3d2154 100644 --- a/src/api/stats/getNonAmmPrices.ts +++ b/src/api/stats/getNonAmmPrices.ts @@ -105,6 +105,7 @@ import { getBeefyCowMantlePrices } from './mantle/getBeefyMantleCowPrices'; import { getBeefyCowSeiPrices } from './sei/getBeefySeiCowPrices'; import { getBeefyCowBscPrices } from './bsc/getBeefyCowBscPrices'; import { getBeefyCowAvaxPrices } from './avax/getBeefyCowAvaxPrices'; +import { getBeefyCowRootstockPrices } from './rootstock/getBeefyRootstockCowPrices'; import { getPendleCommonPrices } from './common/getPendleCommonPrices'; import { getMellowVeloPrices } from './common/getMellowVeloPrices'; @@ -226,6 +227,7 @@ export async function getNonAmmPrices(tokenPrices: Record): Prom getBeefyCowSeiPrices(tokenPrices), getBeefyCowBscPrices(tokenPrices), getBeefyCowAvaxPrices(tokenPrices), + getBeefyCowRootstockPrices(tokenPrices), getFtmIchiPrices(tokenPrices), getPendleCommonPrices(ARB_CHAIN_ID, require('../../data/arbitrum/equilibriaPools.json'), tokenPrices), getPendleCommonPrices(ETH_CHAIN_ID, require('../../data/ethereum/pendlePools.json'), tokenPrices), diff --git a/src/api/stats/rootstock/getBeefyCowRootstockApys.ts b/src/api/stats/rootstock/getBeefyCowRootstockApys.ts new file mode 100644 index 000000000..7725cedc3 --- /dev/null +++ b/src/api/stats/rootstock/getBeefyCowRootstockApys.ts @@ -0,0 +1,5 @@ +import { getCowApys } from '../common/getCowVaultApys'; + +export const getBeefyCowRootstockApys = async () => { + return await getCowApys('rootstock'); +}; diff --git a/src/api/stats/rootstock/getBeefyRootstockCowPrices.ts b/src/api/stats/rootstock/getBeefyRootstockCowPrices.ts new file mode 100644 index 000000000..ea0bfb7f7 --- /dev/null +++ b/src/api/stats/rootstock/getBeefyRootstockCowPrices.ts @@ -0,0 +1,5 @@ +import { getBeefyCowcentratedVaultPrices } from '../common/getBeefyCowcentratedVaultPrices'; + +export const getBeefyCowRootstockPrices = async tokenPrices => { + return await getBeefyCowcentratedVaultPrices('rootstock', tokenPrices); +}; diff --git a/src/api/stats/rootstock/index.js b/src/api/stats/rootstock/index.js new file mode 100644 index 000000000..41dbe21dc --- /dev/null +++ b/src/api/stats/rootstock/index.js @@ -0,0 +1,53 @@ +const { getBeefyCowRootstockApys } = require('./getBeefyCowRootstockApys'); + +const getApys = [getBeefyCowRootstockApys]; + +const getRootstockApys = async () => { + const start = Date.now(); + let apys = {}; + let apyBreakdowns = {}; + + let promises = []; + getApys.forEach(getApy => promises.push(getApy())); + const results = await Promise.allSettled(promises); + + for (const result of results) { + if (result.status !== 'fulfilled') { + console.warn('getRootstockApys error', result.reason); + continue; + } + + // Set default APY values + let mappedApyValues = result.value; + let mappedApyBreakdownValues = {}; + + // Loop through key values and move default breakdown format + // To require totalApy key + for (const [key, value] of Object.entries(result.value)) { + mappedApyBreakdownValues[key] = { + totalApy: value, + }; + } + + // Break out to apy and breakdowns if possible + let hasApyBreakdowns = 'apyBreakdowns' in result.value; + if (hasApyBreakdowns) { + mappedApyValues = result.value.apys; + mappedApyBreakdownValues = result.value.apyBreakdowns; + } + + apys = { ...apys, ...mappedApyValues }; + + apyBreakdowns = { ...apyBreakdowns, ...mappedApyBreakdownValues }; + } + + const end = Date.now(); + console.log(`> [APY] Sei finished updating in ${(end - start) / 1000}s`); + + return { + apys, + apyBreakdowns, + }; +}; + +module.exports = { getRootstockApys }; diff --git a/src/data/rootstock/beefyCowVaults.json b/src/data/rootstock/beefyCowVaults.json new file mode 100644 index 000000000..d843f9a3d --- /dev/null +++ b/src/data/rootstock/beefyCowVaults.json @@ -0,0 +1,14 @@ +[ + { + "address": "0x7AB03a37822014f4aba762F0a622bF0cc8A32F47", + "lpAddress": "0xCbA7aBe98fd6A65259837d76a3409841C1DD4288", + "tokens": ["0x1D931Bf8656d795E50eF6D639562C5bD8Ac2B78f", "0x542fDA317318eBF1d3DEAf76E0b632741A7e677d"], + "tokenOracleIds": ["WETH", "WBTC"], + "decimals": [18, 18], + "oracleId": "uniswap-cow-rootstock-eths-wrbtc", + "rewardPool": { + "address": "0xd9BcDF03D03D1F36d2B6dAf6b30b9eE6C014F610", + "oracleId": "uniswap-cow-rootstock-eths-wrbtc-rp" + } + } +]