# DataStorageOperator

## Modifiers

### onlyPool

## Variables

### struct DataStorage.Timepoint\[65536] timepoints

### struct AdaptiveFee.Configuration feeConfig

## Functions

### constructor

`constructor(address)` public

| Name   | Type    | Description |
| ------ | ------- | ----------- |
| \_pool | address |             |

### initialize

onlyPool

`initialize(uint32,int24)` external

Initialize the dataStorage array by writing the first slot. Called once for the lifecycle of the timepoints array

| Name | Type   | Description                                                                         |
| ---- | ------ | ----------------------------------------------------------------------------------- |
| time | uint32 | The time of the dataStorage initialization, via block.timestamp truncated to uint32 |
| tick | int24  | Initial tick                                                                        |

### changeFeeConfiguration

`changeFeeConfiguration(struct AdaptiveFee.Configuration)` external

Changes fee configuration for the pool

| Name        | Type                             | Description |
| ----------- | -------------------------------- | ----------- |
| \_feeConfig | struct AdaptiveFee.Configuration |             |

### getSingleTimepoint

onlyPool

`getSingleTimepoint(uint32,uint32,int24,uint16,uint128)` view external

| Name       | Type    | Description                                                                        |
| ---------- | ------- | ---------------------------------------------------------------------------------- |
| time       | uint32  | The current block timestamp                                                        |
| secondsAgo | uint32  | The amount of time to look back, in seconds, at which point to return an timepoint |
| tick       | int24   | The current tick                                                                   |
| index      | uint16  | The index of the timepoint that was most recently written to the timepoints array  |
| liquidity  | uint128 | The current in-range pool liquidity                                                |

**Returns:**

| Name                          | Type    | Description |
| ----------------------------- | ------- | ----------- |
| tickCumulative                | int56   |             |
| secondsPerLiquidityCumulative | uint160 |             |
| volatilityCumulative          | uint112 |             |
| volumePerAvgLiquidity         | uint256 |             |

### getTimepoints

onlyPool

`getTimepoints(uint32,uint32[],int24,uint16,uint128)` view external

Returns the accumulator values as of each time seconds ago from the given time in the array of \`secondsAgos\`

| Name        | Type      | Description                                                                         |
| ----------- | --------- | ----------------------------------------------------------------------------------- |
| time        | uint32    | The current block.timestamp                                                         |
| secondsAgos | uint32\[] | Each amount of time to look back, in seconds, at which point to return an timepoint |
| tick        | int24     | The current tick                                                                    |
| index       | uint16    | The index of the timepoint that was most recently written to the timepoints array   |
| liquidity   | uint128   | The current in-range pool liquidity                                                 |

**Returns:**

| Name                           | Type       | Description |
| ------------------------------ | ---------- | ----------- |
| tickCumulatives                | int56\[]   |             |
| secondsPerLiquidityCumulatives | uint160\[] |             |
| volatilityCumulatives          | uint112\[] |             |
| volumePerAvgLiquiditys         | uint256\[] |             |

### getAverages

onlyPool

`getAverages(uint32,int24,uint16,uint128)` view external

Returns average volatility in the range from time-WINDOW to time

| Name      | Type    | Description                                                                       |
| --------- | ------- | --------------------------------------------------------------------------------- |
| time      | uint32  | The current block.timestamp                                                       |
| tick      | int24   | The current tick                                                                  |
| index     | uint16  | The index of the timepoint that was most recently written to the timepoints array |
| liquidity | uint128 | The current in-range pool liquidity                                               |

**Returns:**

| Name                  | Type    | Description |
| --------------------- | ------- | ----------- |
| TWVolatilityAverage   | uint112 |             |
| TWVolumePerLiqAverage | uint256 |             |

### write

onlyPool

`write(uint16,uint32,int24,uint128,uint128)` external

Writes an dataStorage timepoint to the array

| Name               | Type    | Description                                                                       |
| ------------------ | ------- | --------------------------------------------------------------------------------- |
| index              | uint16  | The index of the timepoint that was most recently written to the timepoints array |
| blockTimestamp     | uint32  | The timestamp of the new timepoint                                                |
| tick               | int24   | The active tick at the time of the new timepoint                                  |
| liquidity          | uint128 | The total in-range liquidity at the time of the new timepoint                     |
| volumePerLiquidity | uint128 | The gmean(volumes)/liquidity at the time of the new timepoint                     |

**Returns:**

| Name         | Type   | Description |
| ------------ | ------ | ----------- |
| indexUpdated | uint16 |             |

### calculateVolumePerLiquidity

`calculateVolumePerLiquidity(uint128,int256,int256)` pure external

Calculates gmean(volume/liquidity) for block

| Name      | Type    | Description                         |
| --------- | ------- | ----------------------------------- |
| liquidity | uint128 | The current in-range pool liquidity |
| amount0   | int256  | Total amount of swapped token0      |
| amount1   | int256  | Total amount of swapped token1      |

**Returns:**

| Name               | Type    | Description |
| ------------------ | ------- | ----------- |
| volumePerLiquidity | uint128 |             |

### window

`window()` pure external

**Returns:**

| Name | Type   | Description |
| ---- | ------ | ----------- |
| \[0] | uint32 |             |

### getFee

onlyPool

`getFee(uint32,int24,uint16,uint128)` view external

Calculates fee based on combination of sigmoids

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| \_time      | uint32  |             |
| \_tick      | int24   |             |
| \_index     | uint16  |             |
| \_liquidity | uint128 |             |

**Returns:**

| Name | Type   | Description |
| ---- | ------ | ----------- |
| fee  | uint16 |             |

***


---

# 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.algebra.finance/algebra-integral-documentation/algebra-v1-technical-reference/contracts/api-reference-v1.0/v1.0-core/datastorageoperator.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.
