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

feat: display average APYs on Market page #3580

Merged
merged 1 commit into from
Dec 2, 2024
Merged
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
5 changes: 5 additions & 0 deletions .changeset/thin-singers-brake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@venusprotocol/evm": minor
---

display average APYs on Market page
3 changes: 2 additions & 1 deletion apps/evm/src/libs/translations/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,8 @@
"thirtyDays": "30D"
},
"stats": {
"apy": "APY",
"apy": "Current APY",
"averageApy": "Average APY",
"distributionApy": "Distribution APY",
"liquidationPenalty": "Liquidation Penalty",
"liquidationThreshold": "Liquidation Threshold"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

exports[`CorePoolMarket > fetches market details and displays them correctly 1`] = `"Interest Rate ModelUtilization rateBorrow APYSupply APY"`;

exports[`CorePoolMarket > fetches market details and displays them correctly 2`] = `"Supply info0%Total supplied> $100T / > $100T> 100T / > 100T XVSAPY0.05%Distribution APY0.11%"`;
exports[`CorePoolMarket > fetches market details and displays them correctly 2`] = `"Supply info0%Total supplied> $100T / > $100T> 100T / > 100T XVSAverage APY-Current APY0.05%Distribution APY0.11%"`;

exports[`CorePoolMarket > fetches market details and displays them correctly 3`] = `"Borrow info0%Total borrowed$2.36M / > $100T1.85M / > 100T XVSAPY-2.3%Distribution APY4.17%Liquidation Threshold50%Liquidation Penalty10%"`;
exports[`CorePoolMarket > fetches market details and displays them correctly 3`] = `"Borrow info0%Total borrowed$2.36M / > $100T1.85M / > 100T XVSAverage APY-Current APY-2.3%Distribution APY4.17%Liquidation Threshold50%Liquidation Penalty10%"`;

exports[`CorePoolMarket > fetches market details and displays them correctly 4`] = `"Market infoPrice$1.278673Market liquidity$80.36MDaily supplying interests$3.98Daily borrowing interests-$44.81Daily XVS distributed19.99MReserves1K XVSReserve factor25%Collateral factor50%vXVS minted> 100TExchange rate1 XVS=49.589181 vXVS"`;
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`CorePoolMarket - Feature flag enabled: apyCharts > fetches market details and displays them correctly 1`] = `"Supply info30D6M1Y0%Total supplied> $100T / > $100T> 100T / > 100T XVSAPY0.05%Distribution APY0.11%Supply APY"`;
exports[`CorePoolMarket - Feature flag enabled: apyCharts > fetches market details and displays them correctly 1`] = `"Supply info30D6M1Y0%Total supplied> $100T / > $100T> 100T / > 100T XVSAverage APY-Current APY0.05%Distribution APY0.11%Supply APY"`;

exports[`CorePoolMarket - Feature flag enabled: apyCharts > fetches market details and displays them correctly 2`] = `"Borrow info30D6M1Y0%Total borrowed$2.36M / > $100T1.85M / > 100T XVSAPY-2.3%Distribution APY4.17%Liquidation Threshold50%Liquidation Penalty10%Borrow APY"`;
exports[`CorePoolMarket - Feature flag enabled: apyCharts > fetches market details and displays them correctly 2`] = `"Borrow info30D6M1Y0%Total borrowed$2.36M / > $100T1.85M / > 100T XVSAverage APY-Current APY-2.3%Distribution APY4.17%Liquidation Threshold50%Liquidation Penalty10%Borrow APY"`;

exports[`CorePoolMarket - Feature flag enabled: apyCharts > fetches market details and displays them correctly 3`] = `"Interest Rate ModelUtilization rateBorrow APYSupply APY"`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

exports[`CorePoolMarket - Feature flag enabled: marketParticipantCounts > fetches market details and displays them correctly 1`] = `"Interest Rate ModelUtilization rateBorrow APYSupply APY"`;

exports[`CorePoolMarket - Feature flag enabled: marketParticipantCounts > fetches market details and displays them correctly 2`] = `"Supply info0%Total supplied> $100T / > $100T> 100T / > 100T XVSAPY0.05%Distribution APY0.11%"`;
exports[`CorePoolMarket - Feature flag enabled: marketParticipantCounts > fetches market details and displays them correctly 2`] = `"Supply info0%Total supplied> $100T / > $100T> 100T / > 100T XVSAverage APY-Current APY0.05%Distribution APY0.11%"`;

exports[`CorePoolMarket - Feature flag enabled: marketParticipantCounts > fetches market details and displays them correctly 3`] = `"Borrow info0%Total borrowed$2.36M / > $100T1.85M / > 100T XVSAPY-2.3%Distribution APY4.17%Liquidation Threshold50%Liquidation Penalty-"`;
exports[`CorePoolMarket - Feature flag enabled: marketParticipantCounts > fetches market details and displays them correctly 3`] = `"Borrow info0%Total borrowed$2.36M / > $100T1.85M / > 100T XVSAverage APY-Current APY-2.3%Distribution APY4.17%Liquidation Threshold50%Liquidation Penalty-"`;

exports[`CorePoolMarket - Feature flag enabled: marketParticipantCounts > fetches market details and displays them correctly 4`] = `"Market infoPrice$1.278673Market liquidity$80.36M# of suppliers100# of borrowers10Daily supplying interests$3.98Daily borrowing interests-$44.81Daily XVS distributed19.99MReserves1K XVSReserve factor25%Collateral factor50%vXVS minted> 100TExchange rate1 XVS=49.589181 vXVS"`;
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

exports[`IsolatedPoolMarket > fetches market details and displays them correctly 1`] = `"Interest Rate ModelUtilization rateBorrow APYSupply APY"`;

exports[`IsolatedPoolMarket > fetches market details and displays them correctly 2`] = `"Supply info0%Total supplied> $100T / > $100T> 100T / > 100T XVSAPY0.05%Distribution APY0.11%"`;
exports[`IsolatedPoolMarket > fetches market details and displays them correctly 2`] = `"Supply info0%Total supplied> $100T / > $100T> 100T / > 100T XVSAverage APY-Current APY0.05%Distribution APY0.11%"`;

exports[`IsolatedPoolMarket > fetches market details and displays them correctly 3`] = `"Borrow info0%Total borrowed$2.36M / > $100T1.85M / > 100T XVSAPY-2.3%Distribution APY4.17%Liquidation Threshold50%Liquidation Penalty-"`;
exports[`IsolatedPoolMarket > fetches market details and displays them correctly 3`] = `"Borrow info0%Total borrowed$2.36M / > $100T1.85M / > 100T XVSAverage APY-Current APY-2.3%Distribution APY4.17%Liquidation Threshold50%Liquidation Penalty-"`;

exports[`IsolatedPoolMarket > fetches market details and displays them correctly 4`] = `"Market infoPrice$1.278673Market liquidity$80.36MDaily supplying interests$3.98Daily borrowing interests-$44.81Daily XVS distributed19.99MReserves1K XVSReserve factor25%Collateral factor50%vXVS minted> 100TExchange rate1 XVS=49.589181 vXVS"`;
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`IsolatedPoolMarket - Feature flag enabled: marketHistory > fetches market details and displays them correctly 1`] = `"Supply info30D6M1Y0%Total supplied> $100T / > $100T> 100T / > 100T XVSAPY0.05%Distribution APY0.11%Supply APY"`;
exports[`IsolatedPoolMarket - Feature flag enabled: marketHistory > fetches market details and displays them correctly 1`] = `"Supply info30D6M1Y0%Total supplied> $100T / > $100T> 100T / > 100T XVSAverage APY-Current APY0.05%Distribution APY0.11%Supply APY"`;

exports[`IsolatedPoolMarket - Feature flag enabled: marketHistory > fetches market details and displays them correctly 2`] = `"Borrow info30D6M1Y0%Total borrowed$2.36M / > $100T1.85M / > 100T XVSAPY-2.3%Distribution APY4.17%Liquidation Threshold50%Liquidation Penalty-Borrow APY"`;
exports[`IsolatedPoolMarket - Feature flag enabled: marketHistory > fetches market details and displays them correctly 2`] = `"Borrow info30D6M1Y0%Total borrowed$2.36M / > $100T1.85M / > 100T XVSAverage APY-Current APY-2.3%Distribution APY4.17%Liquidation Threshold50%Liquidation Penalty-Borrow APY"`;

exports[`IsolatedPoolMarket - Feature flag enabled: marketHistory > fetches market details and displays them correctly 3`] = `"Interest Rate ModelUtilization rateBorrow APYSupply APY"`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

exports[`IsolatedPoolMarket - Feature flag enabled: marketParticipantCounts > fetches market details and displays them correctly 1`] = `"Interest Rate ModelUtilization rateBorrow APYSupply APY"`;

exports[`IsolatedPoolMarket - Feature flag enabled: marketParticipantCounts > fetches market details and displays them correctly 2`] = `"Supply info0%Total supplied> $100T / > $100T> 100T / > 100T XVSAPY0.05%Distribution APY0.11%"`;
exports[`IsolatedPoolMarket - Feature flag enabled: marketParticipantCounts > fetches market details and displays them correctly 2`] = `"Supply info0%Total supplied> $100T / > $100T> 100T / > 100T XVSAverage APY-Current APY0.05%Distribution APY0.11%"`;

exports[`IsolatedPoolMarket - Feature flag enabled: marketParticipantCounts > fetches market details and displays them correctly 3`] = `"Borrow info0%Total borrowed$2.36M / > $100T1.85M / > 100T XVSAPY-2.3%Distribution APY4.17%Liquidation Threshold50%Liquidation Penalty-"`;
exports[`IsolatedPoolMarket - Feature flag enabled: marketParticipantCounts > fetches market details and displays them correctly 3`] = `"Borrow info0%Total borrowed$2.36M / > $100T1.85M / > 100T XVSAverage APY-Current APY-2.3%Distribution APY4.17%Liquidation Threshold50%Liquidation Penalty-"`;

exports[`IsolatedPoolMarket - Feature flag enabled: marketParticipantCounts > fetches market details and displays them correctly 4`] = `"Market infoPrice$1.278673Market liquidity$80.36M# of suppliers100# of borrowers10Daily supplying interests$3.98Daily borrowing interests-$44.81Daily XVS distributed19.99MReserves1K XVSReserve factor25%Collateral factor50%vXVS minted> 100TExchange rate1 XVS=49.589181 vXVS"`;
10 changes: 10 additions & 0 deletions apps/evm/src/pages/Market/Page/MarketHistory/Card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,18 @@ export const Card: React.FC<CardProps> = ({
return [];
}

const averageApy =
data.length > 0
? data.reduce((acc, item) => acc + item.apyPercentage, 0) / data.length
: undefined;

const distributionApys = getCombinedDistributionApys({ asset });

const tmpStats: MarketCardProps['stats'] = [
{
label: t('market.stats.averageApy'),
value: formatPercentageToReadableValue(averageApy),
},
{
label: t('market.stats.apy'),
value: formatPercentageToReadableValue(
Expand Down Expand Up @@ -116,6 +125,7 @@ export const Card: React.FC<CardProps> = ({
return tmpStats;
}, [
asset,
data,
t,
type,
liquidationIncentivePercentage,
Expand Down
6 changes: 3 additions & 3 deletions apps/evm/src/pages/Market/Page/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Card, Page as PaceComp } from 'components';
import { Card, Page as PageComp } from 'components';
import type { Asset, Pool } from 'types';

import AssetWarning from './AssetWarning';
Expand All @@ -13,7 +13,7 @@ export interface PageProps {
}

export const Page: React.FC<PageProps> = ({ asset, pool }) => (
<PaceComp indexWithSearchEngines={false}>
<PageComp indexWithSearchEngines={false}>
<div className="py-6 md:py-8 xl:py-12">
<AssetWarning
token={asset.vToken.underlyingToken}
Expand All @@ -37,5 +37,5 @@ export const Page: React.FC<PageProps> = ({ asset, pool }) => (
</div>
</div>
</div>
</PaceComp>
</PageComp>
);