Skip to content

Commit

Permalink
Merge pull request #1120 from TempleDAO/stage
Browse files Browse the repository at this point in the history
stage -> main
  • Loading branch information
marshall2112 authored Nov 20, 2024
2 parents 22a8e6f + 449c5aa commit b8fd7d7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import env from 'constants/env';
import { useConnectWallet } from '@web3-onboard/react';
import Tooltip from 'components/Tooltip/Tooltip';
import { estimateAndMine } from 'utils/ethers';
import { aprToApy } from 'utils/helpers';

export type State = {
supplyValue: string;
Expand Down Expand Up @@ -184,8 +185,9 @@ export const BorrowPage = () => {
const maxLtv = debtTokenConfig.maxLtvRatio;

// current borrow apy
const currentBorrowInterestRate =
Math.pow(1 + fromAtto(debtTokenData.interestRate) / 365, 365) - 1;
const currentBorrowInterestRate = aprToApy(
fromAtto(debtTokenData.interestRate)
);

const circuitBreakers = await getCircuitBreakers();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
TrvBalancesResp,
TrvDataResp,
} from 'utils/subgraph';
import { aprToApy } from 'utils/helpers';

export enum TokenSymbols {
DAI = 'DAI',
Expand Down Expand Up @@ -131,9 +132,10 @@ export default function useDashboardV2Metrics(dashboardData: DashboardData) {
benchmarkedEquity: parseFloat(
externalBalancesData!.benchmarkedEquityUSD
),
interestRate:
interestRate: aprToApy(
parseFloat(daiStrategyTokenData!.rate) +
parseFloat(daiStrategyTokenData!.premiumRate),
parseFloat(daiStrategyTokenData!.premiumRate)
),
debtShare: parseFloat(daiStrategyTokenData!.debtShare),
debtCeiling: parseFloat(daiStrategyTokenData!.debtCeiling),
debtCeilingUtilization: parseFloat(
Expand Down Expand Up @@ -197,7 +199,7 @@ export default function useDashboardV2Metrics(dashboardData: DashboardData) {
spotPrice: parseFloat(templeSpotPrice as string),
treasuryPriceIndex: parseFloat(trvSubgraphData.treasuryPriceIndex),
circulatingSupply: parseFloat(templeCirculatingSupply as string),
benchmarkRate: parseFloat(benchmarkRate as string),
benchmarkRate: aprToApy(parseFloat(benchmarkRate as string)),
principal: parseFloat(trvSubgraphData.principalUSD),
accruedInterest: parseFloat(trvSubgraphData.accruedInterestUSD),
benchmarkedEquity: parseFloat(
Expand Down Expand Up @@ -239,7 +241,7 @@ export default function useDashboardV2Metrics(dashboardData: DashboardData) {
};

const formatPercent = (input: number) => {
return Math.round(input * 100).toFixed(2);
return (Math.round(input * 10_000) / 100).toFixed(2);
};

/**
Expand Down
5 changes: 5 additions & 0 deletions apps/dapp/src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ export const asyncNoop = async () => {};
export const isDevelopmentEnv = () => {
return ENV.VITE_ENV === 'preview' || ENV.VITE_ENV === 'local';
};

// Continuously compounded rate
export const aprToApy = (rate: number) => {
return Math.pow(1 + rate / 365, 365) - 1;
};

0 comments on commit b8fd7d7

Please sign in to comment.