e81e8a8f71
* Revert "Revert "Merge branch 'main' of https://github.com/Uniswap/interface" (#2912)" This reverts commit 7d343dcfbdf75a2f91d28cefce84e4b1bace7b87. * Revert "deleted files" This reverts commit 097b8361d4c09afd3cb681c4622145c555ced884.
32 lines
885 B
TypeScript
32 lines
885 B
TypeScript
import { Pool, Position } from '@uniswap/v3-sdk'
|
|
import { usePool } from 'hooks/usePools'
|
|
import { PositionDetails } from 'types/position'
|
|
|
|
import { useCurrency } from './Tokens'
|
|
|
|
export function useDerivedPositionInfo(positionDetails: PositionDetails | undefined): {
|
|
position: Position | undefined
|
|
pool: Pool | undefined
|
|
} {
|
|
const currency0 = useCurrency(positionDetails?.token0)
|
|
const currency1 = useCurrency(positionDetails?.token1)
|
|
|
|
// construct pool data
|
|
const [, pool] = usePool(currency0 ?? undefined, currency1 ?? undefined, positionDetails?.fee)
|
|
|
|
let position = undefined
|
|
if (pool && positionDetails) {
|
|
position = new Position({
|
|
pool,
|
|
liquidity: positionDetails.liquidity.toString(),
|
|
tickLower: positionDetails.tickLower,
|
|
tickUpper: positionDetails.tickUpper,
|
|
})
|
|
}
|
|
|
|
return {
|
|
position,
|
|
pool: pool ?? undefined,
|
|
}
|
|
}
|