diff --git a/lib/modules/pool/pool.helpers.ts b/lib/modules/pool/pool.helpers.ts index 1f15ed751..a83326b64 100644 --- a/lib/modules/pool/pool.helpers.ts +++ b/lib/modules/pool/pool.helpers.ts @@ -7,6 +7,7 @@ import { GqlPoolMinimalType, } from '@/lib/shared/services/api/generated/graphql' import { getAddressBlockExplorerLink, isSameAddress } from '@/lib/shared/utils/addresses' +import { bn } from '@/lib/shared/utils/numbers' import { MinimalToken, PoolStateInput } from '@balancer/sdk' import BigNumber from 'bignumber.js' import { Address, Hex, getAddress } from 'viem' @@ -107,6 +108,10 @@ export function preMintedBptIndex(pool: GqlPoolBase): number | void { return pool.allTokens.findIndex(token => isSameAddress(token.address, pool.address)) } +export function calcBptPrice(pool: GetPoolQuery['pool']): string { + return bn(pool.dynamicData.totalLiquidity).div(pool.dynamicData.totalShares).toString() +} + export function createdAfterTimestamp(pool: GqlPoolBase): boolean { // Pools should always have valid createTime so, for safety, we block the pool in case we don't get it // (createTime should probably not be treated as optional in the SDK types) diff --git a/lib/modules/pool/usePool.tsx b/lib/modules/pool/usePool.tsx index 69c261cac..1875d550e 100644 --- a/lib/modules/pool/usePool.tsx +++ b/lib/modules/pool/usePool.tsx @@ -13,7 +13,7 @@ import { FetchPoolProps } from './pool.types' import { getNetworkConfig } from '@/lib/config/app.config' import { useMandatoryContext } from '@/lib/shared/utils/contexts' import { useSeedApolloCache } from '@/lib/shared/hooks/useSeedApolloCache' -import { usePoolHelpers } from './pool.helpers' +import { calcBptPrice, usePoolHelpers } from './pool.helpers' import { usePublicClient } from 'wagmi' import { usePoolEnrichWithOnChainData } from '@/lib/modules/pool/usePoolEnrichWithOnChainData' import { bn } from '@/lib/shared/utils/numbers' @@ -51,7 +51,7 @@ export function _usePool({ // fallbacks to ensure the pool is always present. We prefer the pool with on chain data const pool = poolWithOnChainData || data?.pool || initialData.pool - const bptPrice = bn(pool.dynamicData.totalLiquidity).div(pool.dynamicData.totalShares).toFixed(2) + const bptPrice = calcBptPrice(pool) return { pool,