Skip to content

Commit

Permalink
update bptprice calc
Browse files Browse the repository at this point in the history
  • Loading branch information
groninge01 committed Dec 20, 2023
1 parent a8adea3 commit a03faba
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { bn, fNum } from '@/lib/shared/utils/numbers'

type Props = {
pool: any
bptPrice: number
bptPrice: string
amount: number
}

export default function RemoveLiquidityBptRow({ pool, bptPrice, amount }: Props) {
const { toCurrency } = useCurrency()
const totalValue = bn(amount).times(bptPrice).toString()
const totalValue = bn(amount).times(bptPrice).toFixed(2)

return (
<HStack width="full" justifyContent="space-between">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function RemoveLiquidityModal({
<Text fontWeight="bold" fontSize="1rem">
You&apos;re removing
</Text>
<RemoveLiquidityBptRow pool={pool} amount={0} bptPrice={bptPrice} />
<RemoveLiquidityBptRow pool={pool} amount={4} bptPrice={bptPrice} />
</VStack>
</Card>
<Card variant="level0" p="md" w="full">
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/pool/usePool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { useSeedApolloCache } from '@/lib/shared/hooks/useSeedApolloCache'
import { usePoolHelpers } from './pool.helpers'
import { usePublicClient } from 'wagmi'
import { usePoolEnrichWithOnChainData } from '@/lib/modules/pool/usePoolEnrichWithOnChainData'
import { bn } from '@/lib/shared/utils/numbers'

export type UsePoolResponse = ReturnType<typeof _usePool> & {
chain: GqlChain
Expand Down Expand Up @@ -50,8 +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 =
parseFloat(pool.dynamicData.totalLiquidity) / parseFloat(pool.dynamicData.totalShares)
const bptPrice = bn(pool.dynamicData.totalLiquidity).div(pool.dynamicData.totalShares).toFixed(2)

return {
pool,
Expand Down

0 comments on commit a03faba

Please sign in to comment.