# BaseModule

## Overview

`BaseModule` is an abstract contract that acts as a foundational layer for modules within the system. It integrates shared logic such as initializer protection, reentrancy guard, IERC721Receiver compliance and low level storage access.

This module is intended to be inherited and extended by other functional modules.

## Constructor

```solidity
constructor() {
    _disableInitializers();
}
```

Prevents the contract from being initialized outside of proxy context. Ensures secure upgradeable deployments.

## Public & External Functions

### `getStorageAt(bytes32 slot)`

```solidity
function getStorageAt(bytes32 slot) external pure returns (StorageSlot.Bytes32Slot memory)
```

Returns a reference to a custom storage slot. Enables advanced access to shared storage across upgradeable modules using the `StorageSlot` pattern.

**Parameters:**

* `slot` — The `bytes32` identifier of the storage slot.

**Returns:**

* A `StorageSlot.Bytes32Slot` struct pointing to the slot.

### `onERC721Received(...)`

```solidity
function onERC721Received(address, address, uint256, bytes calldata) external pure returns (bytes4)
```

ERC721 receiver hook implementation to support safe transfers of NFTs to the module. Returns the selector as required by `IERC721Receiver`.

**Returns:**

* `IERC721Receiver.onERC721Received.selector` — confirms compliance.

### `receive()`

```solidity
receive() external payable {}
```

Allows the contract to receive native ETH transfers. This is typically used for vaults handling native tokens directly.

## Internal Functions

### `__BaseModule_init()`

```solidity
function __BaseModule_init() internal onlyInitializing
```

Initializes internal dependencies and base upgradeable components. Should be called from derived contract initializers.

**Side Effects:**

* Calls `__ReentrancyGuard_init()` to initialize reentrancy protection.


---

# 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.mellow.finance/core-vaults/architecture/modules/basemodule.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.
