From f7be85abacd3e043e4d68c6597a142f49e7fb0f0 Mon Sep 17 00:00:00 2001 From: therealemjy Date: Fri, 29 Nov 2024 12:11:57 +0100 Subject: [PATCH] feat: display average APYs on Market page --- .changeset/thin-singers-brake.md | 5 +++++ apps/evm/src/libs/translations/translations/en.json | 1 + .../__tests__/__snapshots__/index.spec.tsx.snap | 4 ++-- .../__snapshots__/indexApyCharts.spec.tsx.snap | 4 ++-- .../indexMarketParticipantCounts.spec.tsx.snap | 4 ++-- .../__tests__/__snapshots__/index.spec.tsx.snap | 4 ++-- .../__snapshots__/indexMarketHistory.spec.tsx.snap | 4 ++-- .../indexMarketParticipantCounts.spec.tsx.snap | 4 ++-- .../src/pages/Market/Page/MarketHistory/Card/index.tsx | 10 ++++++++++ 9 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 .changeset/thin-singers-brake.md diff --git a/.changeset/thin-singers-brake.md b/.changeset/thin-singers-brake.md new file mode 100644 index 0000000000..3c17f9908d --- /dev/null +++ b/.changeset/thin-singers-brake.md @@ -0,0 +1,5 @@ +--- +"@venusprotocol/evm": minor +--- + +display average APYs on Market page diff --git a/apps/evm/src/libs/translations/translations/en.json b/apps/evm/src/libs/translations/translations/en.json index c16fb79b83..2bf4606e41 100644 --- a/apps/evm/src/libs/translations/translations/en.json +++ b/apps/evm/src/libs/translations/translations/en.json @@ -410,6 +410,7 @@ }, "stats": { "apy": "APY", + "averageApy": "Average APY", "distributionApy": "Distribution APY", "liquidationPenalty": "Liquidation Penalty", "liquidationThreshold": "Liquidation Threshold" diff --git a/apps/evm/src/pages/Market/CorePoolMarket/__tests__/__snapshots__/index.spec.tsx.snap b/apps/evm/src/pages/Market/CorePoolMarket/__tests__/__snapshots__/index.spec.tsx.snap index 447c074479..ca12c5b86d 100644 --- a/apps/evm/src/pages/Market/CorePoolMarket/__tests__/__snapshots__/index.spec.tsx.snap +++ b/apps/evm/src/pages/Market/CorePoolMarket/__tests__/__snapshots__/index.spec.tsx.snap @@ -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"`; diff --git a/apps/evm/src/pages/Market/CorePoolMarket/__tests__/__snapshots__/indexApyCharts.spec.tsx.snap b/apps/evm/src/pages/Market/CorePoolMarket/__tests__/__snapshots__/indexApyCharts.spec.tsx.snap index 23b40f312d..a055fad893 100644 --- a/apps/evm/src/pages/Market/CorePoolMarket/__tests__/__snapshots__/indexApyCharts.spec.tsx.snap +++ b/apps/evm/src/pages/Market/CorePoolMarket/__tests__/__snapshots__/indexApyCharts.spec.tsx.snap @@ -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"`; diff --git a/apps/evm/src/pages/Market/CorePoolMarket/__tests__/__snapshots__/indexMarketParticipantCounts.spec.tsx.snap b/apps/evm/src/pages/Market/CorePoolMarket/__tests__/__snapshots__/indexMarketParticipantCounts.spec.tsx.snap index 4886c7fb52..3eb1a9c63d 100644 --- a/apps/evm/src/pages/Market/CorePoolMarket/__tests__/__snapshots__/indexMarketParticipantCounts.spec.tsx.snap +++ b/apps/evm/src/pages/Market/CorePoolMarket/__tests__/__snapshots__/indexMarketParticipantCounts.spec.tsx.snap @@ -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"`; diff --git a/apps/evm/src/pages/Market/IsolatedPoolMarket/__tests__/__snapshots__/index.spec.tsx.snap b/apps/evm/src/pages/Market/IsolatedPoolMarket/__tests__/__snapshots__/index.spec.tsx.snap index a4512bf9b3..59292487f8 100644 --- a/apps/evm/src/pages/Market/IsolatedPoolMarket/__tests__/__snapshots__/index.spec.tsx.snap +++ b/apps/evm/src/pages/Market/IsolatedPoolMarket/__tests__/__snapshots__/index.spec.tsx.snap @@ -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"`; diff --git a/apps/evm/src/pages/Market/IsolatedPoolMarket/__tests__/__snapshots__/indexMarketHistory.spec.tsx.snap b/apps/evm/src/pages/Market/IsolatedPoolMarket/__tests__/__snapshots__/indexMarketHistory.spec.tsx.snap index dd41c0fc03..a16051deeb 100644 --- a/apps/evm/src/pages/Market/IsolatedPoolMarket/__tests__/__snapshots__/indexMarketHistory.spec.tsx.snap +++ b/apps/evm/src/pages/Market/IsolatedPoolMarket/__tests__/__snapshots__/indexMarketHistory.spec.tsx.snap @@ -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"`; diff --git a/apps/evm/src/pages/Market/IsolatedPoolMarket/__tests__/__snapshots__/indexMarketParticipantCounts.spec.tsx.snap b/apps/evm/src/pages/Market/IsolatedPoolMarket/__tests__/__snapshots__/indexMarketParticipantCounts.spec.tsx.snap index dfffb93a51..8ee3eedf1e 100644 --- a/apps/evm/src/pages/Market/IsolatedPoolMarket/__tests__/__snapshots__/indexMarketParticipantCounts.spec.tsx.snap +++ b/apps/evm/src/pages/Market/IsolatedPoolMarket/__tests__/__snapshots__/indexMarketParticipantCounts.spec.tsx.snap @@ -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"`; diff --git a/apps/evm/src/pages/Market/Page/MarketHistory/Card/index.tsx b/apps/evm/src/pages/Market/Page/MarketHistory/Card/index.tsx index 59c42f95b1..3589f48f96 100644 --- a/apps/evm/src/pages/Market/Page/MarketHistory/Card/index.tsx +++ b/apps/evm/src/pages/Market/Page/MarketHistory/Card/index.tsx @@ -81,9 +81,18 @@ export const Card: React.FC = ({ 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( @@ -116,6 +125,7 @@ export const Card: React.FC = ({ return tmpStats; }, [ asset, + data, t, type, liquidationIncentivePercentage,