# CalldataExtractor

Library for extracting specific chunks of calldata based on configured offsets used in configurable hooks to extract 32 byte chunks from calldata and check them against expected values in the merkle tree

## Functions

### extract

Extract 32-byte chunks from calldata based on config offsets

*Number of provided offsets must be <= 16 because that's how many fit in uint256*

*Calldata must be at least 36 bytes long to be considered valid*

*All math is unchecked because we validate everything before doing any operations*

```solidity
function extract(bytes memory callData, uint256 calldataOffsetsPacked, uint256 calldataOffsetsCount)
    internal
    pure
    returns (bytes memory);
```

**Parameters**

| Name                    | Type      | Description                      |
| ----------------------- | --------- | -------------------------------- |
| `callData`              | `bytes`   | The calldata to extract from     |
| `calldataOffsetsPacked` | `uint256` | Packed 16-bit extraction offsets |
| `calldataOffsetsCount`  | `uint256` | Number of extractions to perform |

**Returns**

| Name     | Type    | Description                                         |
| -------- | ------- | --------------------------------------------------- |
| `<none>` | `bytes` | result Concatenated byte values at specific offsets |

## Errors

### Aera\_\_ExtractionNumberTooLarge

```solidity
error Aera__ExtractionNumberTooLarge();
```

### Aera\_\_CalldataTooShort

```solidity
error Aera__CalldataTooShort();
```

### Aera\_\_OffsetOutOfBounds

```solidity
error Aera__OffsetOutOfBounds();
```


---

# 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.aera.finance/the-protocol/core/calldataextractor.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.
