import { ethers } from "ethers"; import { evolve, pick, pipe } from "ramda"; import { bigNumAsInt, weiBigNumAsFloat } from "../utils/parse/parse"; type PoolInfo = { accOathPerShare: number; allocPoint: number; lastRewardTime: number; lpAddress: string; lpDecimalPlaces: number; name: string; poolId: number; }; export const getPoolInfo = async ( reliquaryContract: ethers.Contract, poolId: number ) => { const [poolInfo, lpAddress] = await Promise.all([ reliquaryContract.getPoolInfo(poolId), reliquaryContract.poolToken(poolId), ]); return pipe( pick(["accOathPerShare", "allocPoint", "lastRewardTime", "name", "poolId"]), evolve({ accOathPerShare: weiBigNumAsFloat, allocPoint: bigNumAsInt, lastRewardTime: bigNumAsInt, }) )({ ...poolInfo, poolId, lpAddress, lpDecimalPlaces: 6, }) as PoolInfo; };