diff --git a/.changeset/fresh-breads-unite.md b/.changeset/fresh-breads-unite.md
new file mode 100644
index 0000000000..94df566512
--- /dev/null
+++ b/.changeset/fresh-breads-unite.md
@@ -0,0 +1,5 @@
+---
+"@venusprotocol/evm": minor
+---
+
+update how total APYs are displayed
diff --git a/apps/evm/src/libs/errors/handleError/index.ts b/apps/evm/src/libs/errors/handleError/index.ts
index b83c4249f5..d8af3db4bc 100644
--- a/apps/evm/src/libs/errors/handleError/index.ts
+++ b/apps/evm/src/libs/errors/handleError/index.ts
@@ -1,4 +1,4 @@
-import { BaseError } from 'viem';
+import type { BaseError } from 'viem';
import { displayNotification } from 'libs/notifications';
diff --git a/apps/evm/src/libs/translations/translations/en.json b/apps/evm/src/libs/translations/translations/en.json
index e6e801a39e..72362db95f 100644
--- a/apps/evm/src/libs/translations/translations/en.json
+++ b/apps/evm/src/libs/translations/translations/en.json
@@ -245,8 +245,9 @@
"primeApy": "Prime APY",
"supplyApy": "Supply APY",
"totalApy": {
+ "borrowApyLabel": "Total borrow APY",
"borrowApyTooltip": "Borrow APY - Distribution APYs",
- "label": "Total APY",
+ "supplyApyLabel": "Total supply APY",
"supplyApyTooltip": "Supply APY + Distribution APYs"
},
"yieldToMaturityApy": "Yield to maturity APY",
diff --git a/apps/evm/src/libs/translations/translations/ja.json b/apps/evm/src/libs/translations/translations/ja.json
index 06dcb29dde..dbc4a6e877 100644
--- a/apps/evm/src/libs/translations/translations/ja.json
+++ b/apps/evm/src/libs/translations/translations/ja.json
@@ -245,8 +245,9 @@
"primeApy": "Prime APY",
"supplyApy": "供給APY",
"totalApy": {
+ "borrowApyLabel": "総借入APY",
"borrowApyTooltip": "借入APY - 配布APY",
- "label": "合計APY",
+ "supplyApyLabel": "総供給APY",
"supplyApyTooltip": "供給APY + 配布APY"
},
"yieldToMaturityApy": "満期利回りAPY",
diff --git a/apps/evm/src/libs/translations/translations/th.json b/apps/evm/src/libs/translations/translations/th.json
index c801bf84c7..8bcabd7710 100644
--- a/apps/evm/src/libs/translations/translations/th.json
+++ b/apps/evm/src/libs/translations/translations/th.json
@@ -245,8 +245,9 @@
"primeApy": "APY Prime",
"supplyApy": "APY การฝาก",
"totalApy": {
+ "borrowApyLabel": "APY การยืมรวม",
"borrowApyTooltip": "APY การยืม - APY การแจกจ่าย",
- "label": "APY รวม",
+ "supplyApyLabel": "APY การฝากรวม",
"supplyApyTooltip": "APY การฝาก + APY การแจกจ่าย"
},
"yieldToMaturityApy": "APY ถึงกำหนด",
diff --git a/apps/evm/src/libs/translations/translations/tr.json b/apps/evm/src/libs/translations/translations/tr.json
index 61a90b3630..eaca21cf28 100644
--- a/apps/evm/src/libs/translations/translations/tr.json
+++ b/apps/evm/src/libs/translations/translations/tr.json
@@ -245,8 +245,9 @@
"primeApy": "Prime APY",
"supplyApy": "Sağlama APY",
"totalApy": {
+ "borrowApyLabel": "Toplam Borç APY",
"borrowApyTooltip": "Borç APY - Dağıtım APY'leri",
- "label": "Toplam APY",
+ "supplyApyLabel": "Toplam Sağlama APY",
"supplyApyTooltip": "Sağlama APY + Dağıtım APY'leri"
},
"yieldToMaturityApy": "Vade sonu APY",
diff --git a/apps/evm/src/libs/translations/translations/vi.json b/apps/evm/src/libs/translations/translations/vi.json
index 000cdcdfcb..b25aa4e9e4 100644
--- a/apps/evm/src/libs/translations/translations/vi.json
+++ b/apps/evm/src/libs/translations/translations/vi.json
@@ -245,8 +245,9 @@
"primeApy": "APY Prime",
"supplyApy": "APY cung cấp",
"totalApy": {
+ "borrowApyLabel": "Tổng APY vay",
"borrowApyTooltip": "APY vay - APY phân phối",
- "label": "Tổng APY",
+ "supplyApyLabel": "Tổng APY cung cấp",
"supplyApyTooltip": "APY cung cấp + APY phân phối"
},
"yieldToMaturityApy": "APY đến hạn",
diff --git a/apps/evm/src/libs/translations/translations/zh-Hans.json b/apps/evm/src/libs/translations/translations/zh-Hans.json
index 26be0a32d7..6a32d71b0f 100644
--- a/apps/evm/src/libs/translations/translations/zh-Hans.json
+++ b/apps/evm/src/libs/translations/translations/zh-Hans.json
@@ -245,8 +245,9 @@
"primeApy": "Prime APY",
"supplyApy": "存款 APY",
"totalApy": {
+ "borrowApyLabel": "总借款 APY",
"borrowApyTooltip": "借款 APY - 分发 APY",
- "label": "总 APY",
+ "supplyApyLabel": "总存款 APY",
"supplyApyTooltip": "存款 APY + 分发 APY"
},
"yieldToMaturityApy": "到期收益率 APY",
diff --git a/apps/evm/src/libs/translations/translations/zh-Hant.json b/apps/evm/src/libs/translations/translations/zh-Hant.json
index 0b6accfd88..debdfdc1a3 100644
--- a/apps/evm/src/libs/translations/translations/zh-Hant.json
+++ b/apps/evm/src/libs/translations/translations/zh-Hant.json
@@ -245,8 +245,9 @@
"primeApy": "Prime APY",
"supplyApy": "供應 APY",
"totalApy": {
+ "borrowApyLabel": "總借款 APY",
"borrowApyTooltip": "借款 APY - 分發 APY",
- "label": "總 APY",
+ "supplyApyLabel": "總供應 APY",
"supplyApyTooltip": "供應 APY + 分發 APY"
},
"yieldToMaturityApy": "到期收益率 APY",
diff --git a/apps/evm/src/pages/Market/OperationForm/ApyBreakdown/__tests__/__snapshots__/index.spec.tsx.snap b/apps/evm/src/pages/Market/OperationForm/ApyBreakdown/__tests__/__snapshots__/index.spec.tsx.snap
deleted file mode 100644
index 8c308b7521..0000000000
--- a/apps/evm/src/pages/Market/OperationForm/ApyBreakdown/__tests__/__snapshots__/index.spec.tsx.snap
+++ /dev/null
@@ -1,13 +0,0 @@
-// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
-
-exports[`ApyBreakdown > renders correct values: 'borrow' 1`] = `"Borrow APY-4.97%Distribution APY0.52%Total APY6.49%"`;
-
-exports[`ApyBreakdown > renders correct values: 'multiple mutations' 1`] = `"Supply APY0.05%Distribution APY0.11%Borrow APY-4.97%Distribution APY0.52%Net APY7.66%"`;
-
-exports[`ApyBreakdown > renders correct values: 'no mutations' 1`] = `"Total APY0%"`;
-
-exports[`ApyBreakdown > renders correct values: 'repay' 1`] = `"Borrow APY-4.97%Distribution APY0.52%Total APY6.49%"`;
-
-exports[`ApyBreakdown > renders correct values: 'supply' 1`] = `"Supply APY0.05%Distribution APY0.11%Total APY1.16%"`;
-
-exports[`ApyBreakdown > renders correct values: 'withdraw' 1`] = `"Supply APY3.88%Distribution APY1.35%Prime APY0.75%1.75%Total APY7.99%"`;
diff --git a/apps/evm/src/pages/Market/OperationForm/ApyBreakdown/__tests__/index.spec.tsx b/apps/evm/src/pages/Market/OperationForm/ApyBreakdown/__tests__/index.spec.tsx
index 83ce8e003a..1c7e0ae334 100644
--- a/apps/evm/src/pages/Market/OperationForm/ApyBreakdown/__tests__/index.spec.tsx
+++ b/apps/evm/src/pages/Market/OperationForm/ApyBreakdown/__tests__/index.spec.tsx
@@ -61,45 +61,61 @@ const fakeBalanceMutations: BalanceMutation[] = [
];
describe('ApyBreakdown', () => {
+ it('renders a zero total when no mutations are provided', () => {
+ const { container } = renderComponent();
+
+ expect(container.textContent).toBe('Total borrow APY0%');
+ });
+
+ it('ignores VAI mutations and preserves borrow APY signs when calculating net APY', () => {
+ const { container } = renderComponent(
+ ,
+ );
+
+ expect(container.textContent).toBe(
+ 'Supply APY0.05%Distribution APY0.11%Borrow APY-4.97%Distribution APY0.52%Net APY-5.32%',
+ );
+ });
+
it.each([
- { label: 'no mutations', simulatedPool: undefined, balanceMutations: undefined },
- // Actions concerning multiple markets
- {
- label: 'multiple mutations',
- simulatedPool: fakeSimulatedPool,
- balanceMutations: [fakeBalanceMutations[0], fakeBalanceMutations[1], fakeBalanceMutations[3]],
- },
- // Supply to one market
{
label: 'supply',
- simulatedPool: fakeSimulatedPool,
balanceMutations: [fakeBalanceMutations[1]],
+ expectedTextContent: 'Supply APY0.05%Distribution APY0.11%Total supply APY1.16%',
},
- // Withdraw to one market
{
label: 'withdraw',
- simulatedPool: fakeSimulatedPool,
balanceMutations: [fakeBalanceMutations[2]],
+ expectedTextContent:
+ 'Supply APY3.88%Distribution APY1.35%Prime APY0.75%1.75%Total supply APY7.99%',
},
- // Borrow from one market
{
label: 'borrow',
- simulatedPool: fakeSimulatedPool,
balanceMutations: [fakeBalanceMutations[3]],
+ expectedTextContent: 'Borrow APY-4.97%Distribution APY0.52%Total borrow APY-6.49%',
},
- // Repay to one market
{
label: 'repay',
- simulatedPool: fakeSimulatedPool,
balanceMutations: [fakeBalanceMutations[4]],
+ expectedTextContent: 'Borrow APY-4.97%Distribution APY0.52%Total borrow APY-6.49%',
},
] satisfies {
label: string;
- simulatedPool?: Pool;
- balanceMutations?: BalanceMutation[];
- }[])('renders correct values: $label', async props => {
- const { container } = renderComponent();
+ balanceMutations: BalanceMutation[];
+ expectedTextContent: string;
+ }[])('renders the correct single-market breakdown for $label', props => {
+ const { container } = renderComponent(
+ ,
+ );
- expect(container.textContent).toMatchSnapshot();
+ expect(container.textContent).toBe(props.expectedTextContent);
});
});
diff --git a/apps/evm/src/pages/Market/OperationForm/ApyBreakdown/index.tsx b/apps/evm/src/pages/Market/OperationForm/ApyBreakdown/index.tsx
index 66f1e6f312..d2fe59343b 100644
--- a/apps/evm/src/pages/Market/OperationForm/ApyBreakdown/index.tsx
+++ b/apps/evm/src/pages/Market/OperationForm/ApyBreakdown/index.tsx
@@ -65,10 +65,11 @@ export const ApyBreakdown: React.FC = ({
return {
rows: acc.rows.concat(tempRows),
- totalApyPercentage:
+ totalApyPercentage: acc.totalApyPercentage.plus(
balanceMutation.action === 'supply' || balanceMutation.action === 'withdraw'
- ? acc.totalApyPercentage.plus(apys.totalSupplyApyPercentage)
- : acc.totalApyPercentage.minus(apys.totalBorrowApyPercentage),
+ ? apys.totalSupplyApyPercentage
+ : apys.totalBorrowApyPercentage,
+ ),
};
},
{
@@ -79,7 +80,7 @@ export const ApyBreakdown: React.FC = ({
const readableTotalApy = formatPercentageToReadableValue(totalApyPercentage);
- let label = t('apyBreakdown.totalApy.label');
+ let label: undefined | string;
let tooltip: undefined | string;
if (balanceMutations.length > 1) {
@@ -88,6 +89,11 @@ export const ApyBreakdown: React.FC = ({
} else {
const balanceMutationAction = balanceMutations[0]?.action;
+ label =
+ balanceMutationAction === 'supply' || balanceMutationAction === 'withdraw'
+ ? t('apyBreakdown.totalApy.supplyApyLabel')
+ : t('apyBreakdown.totalApy.borrowApyLabel');
+
tooltip =
balanceMutationAction === 'supply' || balanceMutationAction === 'withdraw'
? t('apyBreakdown.totalApy.supplyApyTooltip')
diff --git a/apps/evm/src/pages/Market/__tests__/__snapshots__/index.spec.tsx.snap b/apps/evm/src/pages/Market/__tests__/__snapshots__/index.spec.tsx.snap
index a48374a584..a0ba1e7b52 100644
--- a/apps/evm/src/pages/Market/__tests__/__snapshots__/index.spec.tsx.snap
+++ b/apps/evm/src/pages/Market/__tests__/__snapshots__/index.spec.tsx.snap
@@ -1,3 +1,3 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
-exports[`Market > displays content correctly 1`] = `"Supplying XVS to the Core Pool lets you borrow tokens from this pool exclusively. Show all marketsVisit the mode info section to explore more available groups.SupplyWithdrawBorrowRepayCollateralXVSMAXSupply APY0.05%Distribution APY0.11%Total APY0.16%Connect walletSupply info0%Total supplied> $100T / > $100T> 100T / > 100T XVSCurrent APY0.16%Borrow info< 0.01%Total borrowed$2.36M / > $100T1.85M / > 100T XVSCurrent APY-6.48%Threshold50%Penalty4%Interest Rate ModelUtilization rateBorrow APYSupply APYE-modeStablecoinsCollateralBorrowableMax LTV60%Threshold62%Penalty0%Show all marketsGameFiCollateralBorrowableMax LTV60%Threshold62%Penalty0%Show all marketsGroupCollateralBorrowableMax LTVsorted descendingThresholdPenaltyStablecoins60%62%0%GameFi60%62%0%Sort byMax LTVStablecoinsCollateralBorrowableMax LTV60%Threshold62%Penalty0%GameFiCollateralBorrowableMax LTV60%Threshold62%Penalty0%Market infoDaily supplying interests$3.98Daily borrowing interests-$44.81Daily XVS distributed19.99MReserve factor25%Borrowable (Core)YesCollateral factor (Core)50%Liquidation threshold (Core)50%Liquidation penalty (Core)4%Exchange rate1 XVS=49.589181 vXVS"`;
+exports[`Market > displays content correctly 1`] = `"Supplying XVS to the Core Pool lets you borrow tokens from this pool exclusively. Show all marketsVisit the mode info section to explore more available groups.SupplyWithdrawBorrowRepayCollateralXVSMAXSupply APY0.05%Distribution APY0.11%Total supply APY0.16%Connect walletSupply info0%Total supplied> $100T / > $100T> 100T / > 100T XVSCurrent APY0.16%Borrow info< 0.01%Total borrowed$2.36M / > $100T1.85M / > 100T XVSCurrent APY-6.48%Threshold50%Penalty4%Interest Rate ModelUtilization rateBorrow APYSupply APYE-modeStablecoinsCollateralBorrowableMax LTV60%Threshold62%Penalty0%Show all marketsGameFiCollateralBorrowableMax LTV60%Threshold62%Penalty0%Show all marketsGroupCollateralBorrowableMax LTVsorted descendingThresholdPenaltyStablecoins60%62%0%GameFi60%62%0%Sort byMax LTVStablecoinsCollateralBorrowableMax LTV60%Threshold62%Penalty0%GameFiCollateralBorrowableMax LTV60%Threshold62%Penalty0%Market infoDaily supplying interests$3.98Daily borrowing interests-$44.81Daily XVS distributed19.99MReserve factor25%Borrowable (Core)YesCollateral factor (Core)50%Liquidation threshold (Core)50%Liquidation penalty (Core)4%Exchange rate1 XVS=49.589181 vXVS"`;