> For the complete documentation index, see [llms.txt](https://docs.mav.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mav.xyz/technical-reference/maverick-v2/v2-contracts/maverick-v2-amm-contracts/poollib/twa.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.mav.xyz/technical-reference/maverick-v2/v2-contracts/maverick-v2-amm-contracts/poollib/twa.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
