Skip to content
Merged
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
10 changes: 8 additions & 2 deletions components/pool/graph/GraphModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { Center } from "utils/chakraUtils";
import usePoolData from "hooks/pool/usePoolData";
import useInitialUtilization from "hooks/graph/useInitialUtilization";
import { OneHundred } from "constants/graph";
import { truncateTo3DecimalPlaces } from "utils/bigUtils";

const GraphModel: React.FC<GraphModelProps> = ({
dataKeys,
Expand Down Expand Up @@ -61,11 +62,16 @@ const GraphModel: React.FC<GraphModelProps> = ({
useEffect(() => {
if (rewardAPRValue?.borrow || rewardAPRValue?.borrow === 0) {
setRewardBorrow(
(rewardAPRValue.borrow * hoverData.borrowValue) / OneHundred,
(truncateTo3DecimalPlaces(rewardAPRValue.borrow) *
hoverData.borrowValue) /
OneHundred,
);
}
if (rewardAPRValue?.earn || rewardAPRValue?.earn === 0) {
setRewardEarn((rewardAPRValue?.earn * hoverData.earnValue) / OneHundred);
setRewardEarn(
(truncateTo3DecimalPlaces(rewardAPRValue?.earn) * hoverData.earnValue) /
OneHundred,
);
}
}, [rewardAPRValue, hoverData]);

Expand Down
8 changes: 4 additions & 4 deletions components/pool/graph/RewardGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import React from "react";
import { PoolConfig } from "interfaces/pool";
import GraphModel from "./GraphModel";
import { OneHundred, rateSlopeLow } from "constants/graph";
import useRewardData from "hooks/graph/useRewardData";
import usePoolData from "hooks/pool/usePoolData";

const RewardGraph = ({ poolData }: { poolData: PoolConfig }) => {
const tempRewardData = useRewardData({ poolData });
const { tokenRewardData } = usePoolData();

const rateSlopeHigh = parseFloat(
(OneHundred / (OneHundred - poolData.rewardKink)).toFixed(2),
Expand All @@ -29,8 +29,8 @@ const RewardGraph = ({ poolData }: { poolData: PoolConfig }) => {
dataKeys={dataKeys}
labels={{ borrow: "Borrow Reward", earn: "Earn Reward" }}
rewardAPRValue={{
borrow: tempRewardData.borrow,
earn: tempRewardData.earn,
borrow: tokenRewardData?.borrowRewardAPR ?? 0,
earn: tokenRewardData?.supplyRewardAPR ?? 0,
}}
/>
);
Expand Down
2 changes: 2 additions & 0 deletions constants/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ export const CHAIN_INFO: ChainInfo = {
nativeCurrency: { name: "Sepolia ETH", symbol: "sepoliaETH", decimals: 18 },
},
};

export const AddressZero = "0x0000000000000000000000000000000000000000";
6 changes: 3 additions & 3 deletions constants/pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export const POOL_CONFIG_MAP: PoolConfigMap = {
decimals: 8,
color: "#bc1c4c",
logoURL: "/tokens/PND.png",
priceFeed: "0x0000000000000000000000000000000000000000",
priceFeed: "0x11ff569892Ca55846dACAa2B43C1877424ceB0CB",
priceFeedDecimals: 8,
},
supplyKink: 95,
Expand Down Expand Up @@ -319,7 +319,7 @@ export const POOL_CONFIG_MAP: PoolConfigMap = {
decimals: 8,
color: "#bc1c4c",
logoURL: "/tokens/PND.png",
priceFeed: "0x0000000000000000000000000000000000000000",
priceFeed: "0x11ff569892Ca55846dACAa2B43C1877424ceB0CB",
priceFeedDecimals: 8,
},
supplyKink: 95,
Expand Down Expand Up @@ -424,7 +424,7 @@ export const POOL_CONFIG_MAP: PoolConfigMap = {
decimals: 8,
color: "#bc1c4c",
logoURL: "/tokens/PND.png",
priceFeed: "0x0000000000000000000000000000000000000000",
priceFeed: "0x11ff569892Ca55846dACAa2B43C1877424ceB0CB",
priceFeedDecimals: 8,
},
supplyKink: 60,
Expand Down
54 changes: 0 additions & 54 deletions hooks/graph/useRewardData.ts

This file was deleted.

23 changes: 0 additions & 23 deletions hooks/util/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,26 +103,3 @@ export const getTransform = (
: "translateX(-50%)";
}
};

export const calculateTotalBalance = (
balance: number | undefined,
priceFeedData: PriceFeedData | undefined,
) =>
balance !== undefined &&
balance > 0 &&
priceFeedData?.baseAsset !== undefined &&
priceFeedData.baseAsset > 0
? balance * priceFeedData.baseAsset
: 0;

export const calculateRewardData = (
trackingRewardSpeed: number,
totalBalance: number,
rewardAsset: number | undefined,
) =>
totalBalance > 0
? ((trackingRewardSpeed * DAYS_IN_YEAR * (rewardAsset || 0)) /
totalBalance) *
OneHundred *
REWARD_BONUS_RATE_VALUE
: 0;
2 changes: 2 additions & 0 deletions hooks/util/priceFeedUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from "@wagmi/core";
import priceAbi from "static/price.json";
import { Address } from "abitype";
import { AddressZero } from "constants/chains";

export const getPriceFeedContract = async (
address: Address,
Expand All @@ -24,6 +25,7 @@ export const fetchPriceFeed = async (
configChainId?: number,
): Promise<bigint | undefined> => {
if (!priceFeedAddress) return undefined;
if (priceFeedAddress === AddressZero) return undefined;

const { address } = getAccount();
const network = getNetwork();
Expand Down
5 changes: 0 additions & 5 deletions interfaces/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,3 @@ export interface RenderGraphSectionProps {
GraphComponent: React.FC<{ poolData: PoolConfig }>;
poolData: PoolConfig;
}

export interface RewardDataProps {
borrow: number | undefined;
earn: number | undefined;
}
Loading