# Base

Facilitators of core and periphery contracts.

## BattleInitializer

### createAndInitializeBattle

```javascript
function createAndInitializeBattle(CreateAndInitBattleParams memory params)  external  override  returns  (address battle)  
```

**Params:**

| **Name** | **Type**                  | **Description**                                                                                                                                                    |
| -------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| params   | CreateAndInitBattleParams | Parameters for creating and initializing a pool. See [Params](https://docs.divergence-protocol.com/technical-reference/periphery/params#createandinitbattleparams) |

**Returns:**

| **Name** | **Type** | **Description**                            |
| -------- | -------- | ------------------------------------------ |
| battle   | address  | The address of the created battle contract |

## LiquidityManagement

### mintCallback

Called to msg.sender after minting liquidity to a position

```javascript
function mintCallback(uint256 amountOwed,  bytes  calldata data)  external  override  
```

**Params:**

| **Name**   | **Type** | **Description**                                    |
| ---------- | -------- | -------------------------------------------------- |
| amountOwed | uint256  | The amount of tokens owed for the minted liquidity |
| data       | bytes    | Any data passed through by the caller              |

### \_addLiquidity

Add liquidity to an initialized pool

```javascript
function _addLiquidity(AddLiqParams memory params) internal returns (uint128 liquidityAmount, address battleAddr)
```

**Params:**

| **Name**     | **Type** | **Description**                                                                                                                                  |
| ------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| AddLiqParams | params   | Params required for adding liquidity. See [Params](https://docs.divergence-protocol.com/technical-reference/periphery/params#addliquidityparams) |

**Returns:**

| **Name**        | **Type** | **Description**                             |
| --------------- | -------- | ------------------------------------------- |
| liquidityAmount | uint128  | The amount of liquidity to add              |
| battleAddr      | address  | The address to which an AMM pool is created |

## PeripheryPayments

### pay

Handles the payment of tokens or ETH from one address to another

```javascript
function pay(address tokenAddr,  address payer,  address recipient,  uint256 value)  internal  
```

**Params:**

| **Name**  | **Type** | **Description**                            |
| --------- | -------- | ------------------------------------------ |
| tokenAddr | address  | The address of the token to pay            |
| payer     | address  | The account that should pay the tokens     |
| recipient | address  | The account that should receive the tokens |
| value     | uint256  | The amount to pay                          |


---

# 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/base.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.
