> For the complete documentation index, see [llms.txt](https://docs.ferra.ag/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ferra.ag/integration/dlmm/typescript-sdk/fees-and-analytics/position-value.md).

# Position Value

## Position Value

Calculate the current total value of your position including liquidity and accumulated fees.

### Basic Value Calculation

```typescript
// Get total position value
async function getPositionValue(
  pair: LBPair,
  positionId: string
) {
  // Get amounts from all bins (includes fees)
  const amounts = await sdk.Position.getPositionBinsAmount(pair, positionId);
  
  // Sum totals
  const totals = amounts.reduce((sum, bin) => ({
    x: sum.x + bin.amountX,
    y: sum.y + bin.amountY
  }), { x: 0n, y: 0n });
  
  return totals;
}
```

### Calculate USD Value

```typescript
// Convert to USD
async function getPositionValueUSD(
  pair: LBPair,
  positionId: string
) {
  const totals = await getPositionValue(pair, positionId);
  
  // Get current price
  const price = getPriceFromBinId(
    pair.parameters.active_id,
    Number(pair.binStep)
  );
  
  // Calculate USD value
  const valueUSD = 
    Number(totals.x) * price + // Token X value
    Number(totals.y);          // Token Y value
  
  return {
    tokenX: totals.x,
    tokenY: totals.y,
    totalUSD: valueUSD
  };
}
```

### Quick Value Check

```typescript
// One-liner value check
const amounts = await sdk.Position.getPositionBinsAmount(pair, positionId);
const total = amounts.reduce((sum, b) => ({
  x: sum.x + b.amountX,
  y: sum.y + b.amountY
}), { x: 0n, y: 0n });
```

### What's Included

The value includes:

* Original liquidity amounts
* Accumulated trading fees
* Current market prices
* All bins in the position

### Display Format

```typescript
// Format for display
const value = await getPositionValueUSD(pair, positionId);

console.log("Position Value:", {
  tokenX: formatUnits(value.tokenX, 18),
  tokenY: formatUnits(value.tokenY, 6),
  totalUSD: `$${value.totalUSD.toFixed(2)}`
});
```

### Track Changes

```typescript
// Compare values over time
const before = await getPositionValueUSD(pair, positionId);

// ... later ...

const after = await getPositionValueUSD(pair, positionId);
const change = after.totalUSD - before.totalUSD;
const changePercent = (change / before.totalUSD) * 100;

console.log(`Change: $${change.toFixed(2)} (${changePercent.toFixed(2)}%)`);
```

### Important Notes

* Value changes with price movements
* Includes all accumulated fees
* No need for manual fee calculations
* Updates in real-time with market

### Related Topics

* [Get Position Bins](/integration/dlmm/typescript-sdk/position-management/get-position-bins.md) - Detailed amounts
* [Calculate Position Fees](/integration/dlmm/typescript-sdk/fees-and-analytics/calculate-position-fees.md) - Fee tracking
* [Calculate APR](/integration/dlmm/typescript-sdk/fees-and-analytics/calculate-apr.md) - Return rates
