# Arena

## setFeeForUnderlying

Assigns a fee ratio to pools created for a specific underlying asset. Can only be set by the owner.

```javascript
function setFeeForUnderlying(string calldata underlying, Fee calldata _fee) external override onlyOwner
```

**Params:**

| **Name**   | **Type** | **Description**                                   |
| ---------- | -------- | ------------------------------------------------- |
| underlying | string   | The symbol of underlying asset                    |
| \_fee      | Fee      | The fee ratio for pools with the underlying asset |

## setCollateralWhitelist

Sets the whitelist status for a collateral token. Can only be set by the owner. This function will no longer be in use when the permissionless mode is enabled. Collateral tokens of 18 decimals are supported by default. Those with other decimal places are not recommended for use as collateral due to possible loss of computational precision.

```javascript
function setCollateralWhitelist(address collateral, bool isSupported) external override onlyOwner
```

**Params:**

| **Name**    | **Type** | **Description**                              |
| ----------- | -------- | -------------------------------------------- |
| collateral  | address  | The address of the collateral token          |
| isSupported | bool     | The whitelist status of the collateral token |

## setUnderlyingWhitelist

Sets the whitelist status and fee for an underlying asset.

```javascript
function setUnderlyingWhitelist(string memory underlying, bool isSupported, Fee calldata fee) external override onlyOwner 
```

**Params:**

| **Name**    | **Type** | **Description**                              |
| ----------- | -------- | -------------------------------------------- |
| underlying  | string   | The symbol or name of the underlying asset   |
| isSupported | bool     | The whitelist status of the underlying asset |
| fee         | Fee      | The fee structure for the underlying asset   |

## setPermissionless

Toggles the permissionless mode of the contract. Permissionless mode is disabled initially, when the contracts begin in production. Only whitelisted collateral tokens can be used in battles. Once the permissionless mode is enabled, battles can be created with any ERC-20 token without the need for a whitelist.

```javascript
function setPermissionless() external override onlyOwner
```

## setManager

Sets the manager address

```javascript
function setManager(address _manager) external override onlyOwner
```

## setOracle

Sets the oracle address

```javascript
function setOracle(address _oracle) external override onlyOwner
```

## createBattle

Creates a new battle, aka an options pool, using the specified parameters. A battle is used for one expiry only. Once options expire, a new battle can be created to extend the expiration cycle.

```javascript
function createBattle(BattleKey memory bk) external override returns (address battle);
```

**Params:**

| **Name** | **Type**  | **Description**                                                                                                                    |
| -------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| bk       | BattleKey | The key containing parameters for a battle, such as the collateral token, underlying asset, expiration timestamp, and strike value |

**Returns:**

| **Name** | **Type** | **Description**             |
| -------- | -------- | --------------------------- |
| battle   | address  | The battle contract address |

## getBattle

Gets the battle address for a given battle key

```javascript
function getBattle(BattleKey memory battleKey) external view override returns (address battle);
```

**Params:**

| **Name**  | **Description**                                                                                                                                                                                                                 |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| BattleKey | The key containing parameters for a battle, such as the collateral token, underlying asset, expiration timestamp, and strike value. See [Types](https://docs.divergence-protocol.com/technical-reference/core/types/#BattleKey) |

**Returns:**

| **Name** | **Type** | **Description**             |
| -------- | -------- | --------------------------- |
| battle   | address  | The battle contract address |

## getAllBattles

Fetches information about all battles

```javascript
function getAllBattles() external view override returns (BattleInfo[] memory);
```

**Returns:**

| **Name**   | **Type** | **Description**                                                                                                                                                                          |
| ---------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| BattleInfo | memory   | Information about all battles, each including the battle address, battle key, sqrtPrice, start and expiry timestamps, Spear and Shield token addresses and balances, and battle outcome. |
