# Twa

### Functions <a href="#functions" id="functions"></a>

#### updateValue <a href="#updatevalue" id="updatevalue"></a>

Update the TWA (Time-Weighted Average) value in the State memory.

```solidity
function updateValue(IMaverickV2Pool.State memory self, int256 value, uint256 lookback) internal view;
```

**Parameters**

| Name       | Type                    | Description                                         |
| ---------- | ----------------------- | --------------------------------------------------- |
| `self`     | `IMaverickV2Pool.State` | The State memory to update.                         |
| `value`    | `int256`                | The new value to set.                               |
| `lookback` | `uint256`               | The lookback period to use for calculating the TWA. |

#### floor <a href="#floor" id="floor"></a>

Get the floored TWA value from the State memory.

```solidity
function floor(IMaverickV2Pool.State memory self) internal pure returns (int32);
```

**Parameters**

| Name   | Type                    | Description                    |
| ------ | ----------------------- | ------------------------------ |
| `self` | `IMaverickV2Pool.State` | The State memory to read from. |

**Returns**

| Name     | Type    | Description                        |
| -------- | ------- | ---------------------------------- |
| `<none>` | `int32` | The floored TWA value as an int32. |

#### getTwa <a href="#gettwa" id="gettwa"></a>

Get the TWA value from the State memory, considering a lookback period.

```solidity
function getTwa(IMaverickV2Pool.State memory self, uint256 lookback) internal view returns (int256);
```

**Parameters**

| Name       | Type                    | Description                                         |
| ---------- | ----------------------- | --------------------------------------------------- |
| `self`     | `IMaverickV2Pool.State` | The State memory to read from.                      |
| `lookback` | `uint256`               | The lookback period to use for calculating the TWA. |

**Returns**

| Name     | Type     | Description                 |
| -------- | -------- | --------------------------- |
| `<none>` | `int256` | The TWA value as an int256. |

#### getTwaFloor <a href="#gettwafloor" id="gettwafloor"></a>

Get the floored TWA value from the State memory, based on the lookback period.

```solidity
function getTwaFloor(IMaverickV2Pool.State memory self, uint256 lookback) internal view returns (int32);
```

**Parameters**

| Name       | Type                    | Description                                         |
| ---------- | ----------------------- | --------------------------------------------------- |
| `self`     | `IMaverickV2Pool.State` | The State memory to read from.                      |
| `lookback` | `uint256`               | The lookback period to use for calculating the TWA. |

**Returns**

| Name     | Type    | Description                        |
| -------- | ------- | ---------------------------------- |
| `<none>` | `int32` | The floored TWA value as an int32. |


---

# 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.mav.xyz/technical-reference/maverick-v2/v2-contracts/maverick-v2-amm-contracts/poollib/twa.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.
