# Liquidity and coin amounts calculation

## 1. Liquidity to CoinAmount

use `ClmmPoolUtil.getCoinAmountFromLiquidity` method.

#### Example

this is an example shows how to calculate coin amounts about one position.

```ts
import BN from 'bn.js'
import { TickMath, ClmmPoolUtil } from '@cetusprotocol/cetus-sui-clmm-sdk'

const pool = await sdk.Pool.getPool(poolAddress)
const position = await sdk.Position.getSimplePosition(positionAddress)\
const lowerSqrtPrice = TickMath.tickIndexToSqrtPriceX64(position.tick_lower_index)
const upperSqrtPrice = TickMath.tickIndexToSqrtPriceX64(position.tick_upper_index)

const liquidity = new BN(position.liquidity)
const curSqrtPrice = new BN(pool.current_sqrt_price)

const lowerSqrtPrice = TickMath.tickIndexToSqrtPriceX64(position.tick_lower_index)
const upperSqrtPrice = TickMath.tickIndexToSqrtPriceX64(position.tick_upper_index)
const amounts = ClmmPoolUtil.getCoinAmountFromLiquidity(
  liquidity,
  curSqrtPrice,
  lowerSqrtPrice,
  upperSqrtPrice,
  false
)

const {coinA, coinB} = amounts
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cetus-1.gitbook.io/cetus-developer-docs/developer/via-sdk/features-available/liquidity-and-coin-amounts-calculation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
