Skip to content

fix: Refactor APR calculations to APY for Rezerve's lstRZR #2001

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

Merged
merged 2 commits into from
Jul 28, 2025
Merged
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
17 changes: 13 additions & 4 deletions src/adaptors/rezerve-money/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,13 @@ async function calcErc4626PoolApy(vault, prices) {
const sharePriceNow = await calcSharePrice(vault, prices);

const sharePriceYesterday = await calcSharePrice(vault, prices, 1);
const apyBase = calcApy(sharePriceNow, sharePriceYesterday, 1);
const aprBase = calcApr(sharePriceNow, sharePriceYesterday, 1);

const sharePriceWeekBefore = await calcSharePrice(vault, prices, 7);
const apyBase7d = calcApy(sharePriceNow, sharePriceWeekBefore, 7);
const aprBase7d = calcApr(sharePriceNow, sharePriceWeekBefore, 7);

const apyBase = convertAprToApy(aprBase);
const apyBase7d = convertAprToApy(aprBase7d);

return {
pool: `${vault}-${chain}`,
Expand All @@ -103,7 +106,7 @@ async function calcErc4626PoolApy(vault, prices) {
apyBase7d,
apyReward: 0,
poolMeta: vaultMeta[vault].name,
url: 'https://rezerve.money/stake?tab=vaults',
url: 'https://rezerve.money/liquid-staking?utm_source=defillama',
};
}

Expand Down Expand Up @@ -137,7 +140,7 @@ const totalAssets = async (vault, block = 'latest') => {
return new BigNumber(await callAbi(vault, abi.totalAssets, null, block));
};

function calcApy(sharePriceNow, sharePriceBefore, daysBetween) {
function calcApr(sharePriceNow, sharePriceBefore, daysBetween) {
return sharePriceBefore.isZero()
? 0
: sharePriceNow
Expand All @@ -148,6 +151,12 @@ function calcApy(sharePriceNow, sharePriceBefore, daysBetween) {
.toNumber();
}

function convertAprToApy(apr) {
const aprNormalized = apr / 100;
const n = 365 * 3;
return (Math.pow(1 + aprNormalized / n, n) - 1) * 100;
}

async function getShares(vault, block = 'latest') {
return new BigNumber(await totalSupply(vault, block));
}
Expand Down
Loading