# 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 |
