Skip to content

Commit

Permalink
add in api
Browse files Browse the repository at this point in the history
  • Loading branch information
0xjojoex committed Dec 21, 2023
1 parent 1d26908 commit 97b378a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/pools/constants/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface PoolMetrics {
stakingTokenPrice: number;
earningTokenPrice: number;
apr: number;
alpApr?: number;
endTimestamp: number;
}

Expand Down
3 changes: 3 additions & 0 deletions src/pools/service/poolMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { fetchCakeTokenPrice } from "./cakeTokenPrice";
import { fetchEndTimestamp } from "./endTimestamp";
import { fetchTotalStaked } from "./totalStacked";
import { ChainId } from "@pancakeswap/sdk";
import { alpFee } from "./alpFee";

export const calculatePoolMetrics = async (poolsConfigs: SerializedPool[], chainId: ChainId) => {
return await Promise.all(poolsConfigs.map((value) => fillMetric(value, chainId)));
Expand All @@ -21,11 +22,13 @@ const fillMetric = async (poolConfig: SerializedPool, chainId) => {
poolConfig.tokenPerSecond
);
const endTimestamp = await fetchEndTimestamp(poolConfig.contractAddress, chainId);
const alpApr = await alpFee(chainId);

poolConfig.metrics.totalStaked = totalStaked;
poolConfig.metrics.stakingTokenPrice = stakingTokenPrice;
poolConfig.metrics.earningTokenPrice = earningTokenPrice;
poolConfig.metrics.apr = apr;
poolConfig.metrics.alpApr = alpApr;
poolConfig.metrics.endTimestamp = endTimestamp;

return poolConfig;
Expand Down

0 comments on commit 97b378a

Please sign in to comment.