# Core protocol functions

### Create a contingent pool

```
function createContingentPool(
    PoolParams calldata _poolParams
) 
    external;
```

where `PoolParams` contains the following list of parameters in the corresponding order:

<table><thead><tr><th width="204.37209302325581">Parameter</th><th width="150" align="center">Type</th><th width="150">Category</th><th>Description</th></tr></thead><tbody><tr><td><code>referenceAsset</code></td><td align="center">string</td><td>Event</td><td>The metric or event whose outcome will determine the payout for long and short position tokens.</td></tr><tr><td><code>expiryTime</code></td><td align="center">uint96</td><td>Event</td><td>Expiration time of position tokens expressed as a unix timestamp in seconds. The value of the reference asset observed at that point in time determines the payoffs for long and short position tokens.</td></tr><tr><td><code>floor</code></td><td align="center">uint256</td><td>Payoff</td><td>Value of the reference asset at or below which the long token pays out 0 and the short token 1 (max payout). Input expects an integer with 18 decimals.</td></tr><tr><td><code>inflection</code></td><td align="center">uint256</td><td>Payoff</td><td>Value of the reference asset at which the long token pays out <code>gradient</code> and the short token <code>1-gradient</code>. Input expects an integer with 18 decimals.</td></tr><tr><td><code>cap</code></td><td align="center">uint256</td><td>Payoff</td><td>Value of the reference asset at or above which the long token pays out 1 (max payout) and the short token 0. Input expects an integer with 18 decimals.</td></tr><tr><td><code>gradient</code></td><td align="center">uint256</td><td>Payoff</td><td>Long token payout at inflection (value between 0 and 1). Input expects an integer with 18 decimals.</td></tr><tr><td><code>collateralAmount</code></td><td align="center">uint256</td><td>Payoff</td><td>Collateral amount to be deposited into the pool to back the position tokens. Input expects an integer with collateral token decimals.</td></tr><tr><td><code>collateralToken</code></td><td align="center">address</td><td>Settlement asset</td><td>Address of the ERC20 collateral token.</td></tr><tr><td><code>dataProvider</code></td><td align="center">address</td><td>Oracle</td><td>Ethereum account (EOA or smart contract) that will report the final reference asset value.</td></tr><tr><td><code>capacity</code></td><td align="center">uint256</td><td>Pool size</td><td>Maximum collateral amount that a contingent pool can accept. Choose a large number (e.g., <code>2**256 - 1</code>) for unlimited size. Input expects an integer with collateral token decimals.</td></tr></tbody></table>

### Adding liquidity

Add liquidity to an existing pool using the following function:

```
function addLiquidity(
    uint256 _poolId,                // Id of the pool that a user wants to add collateral to
    uint256 _collateralAmountIncr   // Incremental collateral amount to be added to the pool expressed as an integer with collateral token decimals
) 
    external;
```

### Removing liquidity

Remove liquidity from an existing pool using the following function:

```
function removeLiquidity(
    uint256 _poolId,  // Id of the pool that a user wants to remove collateral from 
    uint256 _amount   // Number of position tokens to return (expressed as an integer with position token decimals)
) 
    external;
```


---

# 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.divaprotocol.io/for-developers/smart-contracts/functions/core-protocol-functions.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.
