Skip to content
Open
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/fresh-breads-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@venusprotocol/evm": minor
---

update how total APYs are displayed
2 changes: 1 addition & 1 deletion apps/evm/src/libs/errors/handleError/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BaseError } from 'viem';
import type { BaseError } from 'viem';

import { displayNotification } from 'libs/notifications';

Expand Down
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 @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion apps/evm/src/libs/translations/translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,9 @@
"primeApy": "Prime APY",
"supplyApy": "供給APY",
"totalApy": {
"borrowApyLabel": "総借入APY",
"borrowApyTooltip": "借入APY - 配布APY",
"label": "合計APY",
"supplyApyLabel": "総供給APY",
"supplyApyTooltip": "供給APY + 配布APY"
},
"yieldToMaturityApy": "満期利回りAPY",
Expand Down
3 changes: 2 additions & 1 deletion apps/evm/src/libs/translations/translations/th.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,9 @@
"primeApy": "APY Prime",
"supplyApy": "APY การฝาก",
"totalApy": {
"borrowApyLabel": "APY การยืมรวม",
"borrowApyTooltip": "APY การยืม - APY การแจกจ่าย",
"label": "APY รวม",
"supplyApyLabel": "APY การฝากรวม",
"supplyApyTooltip": "APY การฝาก + APY การแจกจ่าย"
},
"yieldToMaturityApy": "APY ถึงกำหนด",
Expand Down
3 changes: 2 additions & 1 deletion apps/evm/src/libs/translations/translations/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion apps/evm/src/libs/translations/translations/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion apps/evm/src/libs/translations/translations/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,9 @@
"primeApy": "Prime APY",
"supplyApy": "存款 APY",
"totalApy": {
"borrowApyLabel": "总借款 APY",
"borrowApyTooltip": "借款 APY - 分发 APY",
"label": " APY",
"supplyApyLabel": "总存款 APY",
"supplyApyTooltip": "存款 APY + 分发 APY"
},
"yieldToMaturityApy": "到期收益率 APY",
Expand Down
3 changes: 2 additions & 1 deletion apps/evm/src/libs/translations/translations/zh-Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,9 @@
"primeApy": "Prime APY",
"supplyApy": "供應 APY",
"totalApy": {
"borrowApyLabel": "總借款 APY",
"borrowApyTooltip": "借款 APY - 分發 APY",
"label": " APY",
"supplyApyLabel": "總供應 APY",
"supplyApyTooltip": "供應 APY + 分發 APY"
},
"yieldToMaturityApy": "到期收益率 APY",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -61,45 +61,61 @@ const fakeBalanceMutations: BalanceMutation[] = [
];

describe('ApyBreakdown', () => {
it('renders a zero total when no mutations are provided', () => {
const { container } = renderComponent(<ApyBreakdown pool={fakePool} />);

expect(container.textContent).toBe('Total borrow APY0%');
});

it('ignores VAI mutations and preserves borrow APY signs when calculating net APY', () => {
const { container } = renderComponent(
<ApyBreakdown
pool={fakePool}
simulatedPool={fakeSimulatedPool}
balanceMutations={[
fakeBalanceMutations[0],
fakeBalanceMutations[1],
fakeBalanceMutations[3],
]}
/>,
);

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(<ApyBreakdown pool={fakePool} {...props} />);
balanceMutations: BalanceMutation[];
expectedTextContent: string;
}[])('renders the correct single-market breakdown for $label', props => {
const { container } = renderComponent(
<ApyBreakdown pool={fakePool} simulatedPool={fakeSimulatedPool} {...props} />,
);

expect(container.textContent).toMatchSnapshot();
expect(container.textContent).toBe(props.expectedTextContent);
});
});
14 changes: 10 additions & 4 deletions apps/evm/src/pages/Market/OperationForm/ApyBreakdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ export const ApyBreakdown: React.FC<ApyBreakdownProps> = ({

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,
),
};
},
{
Expand All @@ -79,7 +80,7 @@ export const ApyBreakdown: React.FC<ApyBreakdownProps> = ({

const readableTotalApy = formatPercentageToReadableValue(totalApyPercentage);

let label = t('apyBreakdown.totalApy.label');
let label: undefined | string;
let tooltip: undefined | string;

if (balanceMutations.length > 1) {
Expand All @@ -88,6 +89,11 @@ export const ApyBreakdown: React.FC<ApyBreakdownProps> = ({
} 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')
Expand Down
Original file line number Diff line number Diff line change
@@ -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"`;
Loading