# Libraries

### DiverLiquidityAmounts

#### getLiquidityFromCs

Computes the amount of liquidity to be received by the pool, for a given amount of collateral and price range

```javascript
function getLiquidityFromCs(
        uint160 sqrtRatioX96,
        uint160 sqrtRatioAX96,
        uint160 sqrtRatioBX96,
        uint256 amount
    )
        internal
        pure
        returns (uint128 liquidity)
```

**Params:**

| **Name**      | **Type** | **Description**                                               |
| ------------- | -------- | ------------------------------------------------------------- |
| sqrtRatioX96  | uint160  | The current square root ratio                                 |
| sqrtRatioAX96 | uint160  | A sqrt ratio                                                  |
| sqrtRatioBX96 | uint160  | Another sqrt ratio                                            |
| amount        | uint256  | The seed collateral amount for minting the liquidity position |

**Returns:**

| **Name**  | **Type** | **Description**                                    |
| --------- | -------- | -------------------------------------------------- |
| liquidity | uint128  | The amount of liquidity to be received by the pool |

#### getLiquidityFromSToken

Computes the amount of liquidity to be received by the pool, for a given amount of Spear or Shield tokens and price range

```javascript
function getLiquidityFromSToken(uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount) internal pure returns (uint128 liquidity)
```

**Params:**

| **Name**      | **Type** | **Description**                                                    |
| ------------- | -------- | ------------------------------------------------------------------ |
| sqrtRatioAX96 | uint160  | A sqrt ratio                                                       |
| sqrtRatioBX96 | uint160  | Another sqrt ratio                                                 |
| amount        | uint256  | The seed Spear or Shield amount for minting the liquidity position |

**Returns:**

| **Name**  | **Type** | **Description**                 |
| --------- | -------- | ------------------------------- |
| liquidity | uint128  | The calculated liquidity amount |

### CallbackValidation

Provides validation for callbacks from battle

#### verifyCallback

Verifies the arena address of the battle

```javascript
function verifyCallback(address arenaAddr, BattleKey memory battleKey) internal view
```

**Params:**

| **Name**  | **Type**  | **Description**                                     |
| --------- | --------- | --------------------------------------------------- |
| arenaAddr | address   | The address for the arena contract                  |
| battleKey | BattleKey | The battle Key containing a battle's specifications |


---

# 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://docs.divergence-protocol.com/technical-reference/periphery/libraries.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.
