Skip to content

Conversation

@luchobonatti
Copy link
Member

🚀 Add getPosition and usePosition to retrieve individual Uniswap V4 positions

Summary

This PR adds two new utilities to simplify querying a single Uniswap V4 LP position:

  • getPosition(tokenId, chainId?) – returns detailed on-chain data for a given position
  • usePosition(tokenId, options?) – a React hook built on top of react-query for reactive usage

✅ Features

  • Fetches position metadata via:
    • getPoolAndPositionInfo
    • getPositionLiquidity
    • getSlot0
    • getLiquidity
  • Constructs Token, Pool, and Position objects using the official Uniswap V4 SDK
  • Returns:
    • token0 / token1 metadata
    • Amounts of each token in the position
    • Fee tier, tick spacing, current tick
    • Pool liquidity and slot0 data
    • Pool ID

🧠 Why

Before:

  • Manually call 3–4 contracts
  • Decode ABI bytes manually
  • Build Pool and Position instances yourself

After:

const position = await getPosition(tokenId)
// Or with the hook:
const { data, isLoading } = usePosition(tokenId)

@luchobonatti luchobonatti self-assigned this May 23, 2025
@luchobonatti luchobonatti merged commit 8bdcc42 into main May 23, 2025
1 check passed
@luchobonatti luchobonatti deleted the feat/usePosition branch May 23, 2025 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants