Skip to content
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

Update: Show supplyApr for lending strats #1323

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion src/api/stats/common/aave/getAaveV3Apys.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ const getAaveV3ApyData = async (config, pools, chainId) => {
Object.fromEntries(pools.map((p, i) => [p.name, lendingApys[i]])),
rewardApys,
0,
lsApys
lsApys,
[],
'supplyApr'
);
};

Expand Down
23 changes: 7 additions & 16 deletions src/api/stats/common/getApyBreakdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface ApyBreakdown {
totalApy?: number;
liquidStakingApr?: number;
composablePoolApr?: number;
supplyApr?: number;
}

export interface ApyBreakdownResult {
Expand All @@ -29,7 +30,8 @@ export const getApyBreakdown = (
farmAprs: BigNumber[],
providerFee?: number | BigNumber[],
liquidStakingAprs?: number[],
composablePoolAprs?: number[]
composablePoolAprs?: number[],
mainLabel: 'tradingApr' | 'supplyApr' = 'tradingApr'
): ApyBreakdownResult => {
const result: ApyBreakdownResult = {
apys: {},
Expand All @@ -41,22 +43,11 @@ export const getApyBreakdown = (
}

pools.forEach((pool, i) => {
const liquidStakingApr: number | undefined = liquidStakingAprs
? liquidStakingAprs[i]
: undefined;
const liquidStakingApr: number = liquidStakingAprs?.[i] || 0;

const composablePoolApr: number | undefined = composablePoolAprs
? composablePoolAprs[i]
: undefined;
const composablePoolApr: number = composablePoolAprs?.[i] || 0;

const extraApr =
liquidStakingAprs && composablePoolAprs
? liquidStakingApr + composablePoolApr
: liquidStakingAprs
? liquidStakingApr
: composablePoolAprs
? composablePoolApr
: 0;
const extraApr: number = liquidStakingApr + composablePoolApr;

const provFee = providerFee[i] == undefined ? providerFee : providerFee[i].toNumber();
const simpleApr = farmAprs[i]?.toNumber();
Expand Down Expand Up @@ -87,7 +78,7 @@ export const getApyBreakdown = (
beefyPerformanceFee: beefyPerformanceFee,
vaultApy: vaultApy,
lpFee: provFee,
tradingApr: tradingApr,
[mainLabel]: tradingApr,
liquidStakingApr: liquidStakingApr,
composablePoolApr: composablePoolApr,
totalApy: totalApy,
Expand Down
4 changes: 3 additions & 1 deletion src/api/stats/common/getCompoundV2Apys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ const getCompoundV2ApyData = async (params: CompoundV2ApyParams) => {
Object.fromEntries(params.pools.map((p, i) => [p.name, supplyApys[i]])),
supplyCompApys,
0,
liquidStakingApys
liquidStakingApys,
[],
'supplyApr'
);
};

Expand Down
4 changes: 3 additions & 1 deletion src/api/stats/common/getSiloApys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ const getSiloApyData = async (params: SiloApyParams) => {
Object.fromEntries(params.pools.map((p, i) => [p.name, supplyApys[i]])),
supplySiloApys,
0,
liquidStakingApys
liquidStakingApys,
[],
'supplyApr'
);
};

Expand Down
10 changes: 9 additions & 1 deletion src/api/stats/common/hop/getHopCommonApys.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ export const getHopCommonApys = async params => {
getLsAprs(params),
]);

return getApyBreakdown(params.pools, tradingAprs, farmApys, 0.0004, liquidStakingAprs);
return getApyBreakdown(
params.pools,
tradingAprs,
farmApys,
0.0004,
liquidStakingAprs,
[],
'supplyApr'
);
};

const getTradingAprs = async params => {
Expand Down
4 changes: 2 additions & 2 deletions src/api/stats/getApys.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const { fetchBoostAprs } = require('./getBoostAprs');

const INIT_DELAY = process.env.INIT_DELAY || 30 * 1000;
const BOOST_APR_INIT_DELAY = 30 * 1000;
var REFRESH_INTERVAL = 15 * 60 * 1000;
const REFRESH_INTERVAL = 15 * 60 * 1000;
const BOOST_REFRESH_INTERVAL = 2 * 60 * 1000;

let apys = {};
Expand Down Expand Up @@ -89,7 +89,7 @@ const updateApys = async () => {
}

// Break out to apy and breakdowns if possible
let hasApyBreakdowns = 'apyBreakdowns' in result.value;
const hasApyBreakdowns = 'apyBreakdowns' in result.value;
if (hasApyBreakdowns) {
mappedApyValues = result.value.apys;
mappedApyBreakdownValues = result.value.apyBreakdowns;
Expand Down
4 changes: 3 additions & 1 deletion src/api/stats/optimism/getExactlyApys.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ const getExactlyApys = async () => {
Object.fromEntries(pools.map((p, i) => [p.name, lendingApys[i]])),
rewardApys,
0,
lsApys
lsApys,
[],
'supplyApr'
);
};

Expand Down