Skip to content

Commit

Permalink
Add more Rootstock data
Browse files Browse the repository at this point in the history
  • Loading branch information
MirthFutures committed Sep 30, 2024
1 parent 3813518 commit d2e5acf
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions src/api/cowcentrated/getCowClms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Partial<Record<ApiChain, CowClm[]>>> = {
optimism: validateCowClms(optimismPools),
base: validateCowClms(basePools),
Expand All @@ -25,6 +26,7 @@ const chainToClms: Readonly<Partial<Record<ApiChain, CowClm[]>>> = {
sei: validateCowClms(seiPools),
bsc: validateCowClms(bscPools),
avax: validateCowClms(avaxPools),
rootstock: validateCowClms(rootstockPools),
};

const chainsWithClms = (Object.keys(chainToClms) as ReadonlyArray<ApiChain>).filter(
Expand Down
23 changes: 6 additions & 17 deletions src/api/offchain-rewards/providers/merkl/MerklProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const supportedChains = new Set<AppChain>([
'fraxtal',
'celo',
'sei',
'rootstock',
]);
const campaignCreatorToType: Record<Address, CampaignTypeSetting> = {
'0xb1F1000b4FCae7CD07370cE1A3E3b11270caC0dE': 'test',
Expand Down Expand Up @@ -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 {
Expand All @@ -149,9 +148,7 @@ export class MerklProvider implements IOffchainRewardProvider {
};
}

protected async fetchCampaignsForChain(
chainId: AppChain
): Promise<MerklApiCampaignsResponse[string]> {
protected async fetchCampaignsForChain(chainId: AppChain): Promise<MerklApiCampaignsResponse[string]> {
const numericChainId = toChainId(chainId);

try {
Expand All @@ -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 {};
}
Expand All @@ -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
);
Expand Down
2 changes: 2 additions & 0 deletions src/api/stats/getAmmPrices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ const coinGeckoCoins: Record<string, string[]> = {
shezmueth: ['ShezETH'],
'knox-dollar': ['KNOX'],
'gogopool-ggavax': ['ggAVAX'],
'rif-token': ['RIF'],
'dollar-on-chain': ['DOC'],
};

/**
Expand Down
2 changes: 2 additions & 0 deletions src/api/stats/getApys.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -81,6 +82,7 @@ const updateApys = async () => {
getMantaApys(),
getRealApys(),
getSeiApys(),
getRootstockApys(),
]);

for (const result of results) {
Expand Down
2 changes: 2 additions & 0 deletions src/api/stats/getNonAmmPrices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -226,6 +227,7 @@ export async function getNonAmmPrices(tokenPrices: Record<string, number>): 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),
Expand Down
5 changes: 5 additions & 0 deletions src/api/stats/rootstock/getBeefyCowRootstockApys.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { getCowApys } from '../common/getCowVaultApys';

export const getBeefyCowRootstockApys = async () => {
return await getCowApys('rootstock');
};
5 changes: 5 additions & 0 deletions src/api/stats/rootstock/getBeefyRootstockCowPrices.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { getBeefyCowcentratedVaultPrices } from '../common/getBeefyCowcentratedVaultPrices';

export const getBeefyCowRootstockPrices = async tokenPrices => {
return await getBeefyCowcentratedVaultPrices('rootstock', tokenPrices);
};
53 changes: 53 additions & 0 deletions src/api/stats/rootstock/index.js
Original file line number Diff line number Diff line change
@@ -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 };
14 changes: 14 additions & 0 deletions src/data/rootstock/beefyCowVaults.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
]

0 comments on commit d2e5acf

Please sign in to comment.