Skip to content

Commit

Permalink
feat: display average APYs on Market page
Browse files Browse the repository at this point in the history
  • Loading branch information
therealemjy committed Nov 29, 2024
1 parent d28cda2 commit f7be85a
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 12 deletions.
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
1 change: 1 addition & 0 deletions apps/evm/src/libs/translations/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@
},
"stats": {
"apy": "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-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-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-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-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-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-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-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-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-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-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-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-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

0 comments on commit f7be85a

Please sign in to comment.