# HistoricalBalance

**Inherits:** ERC20Votes, [IHistoricalBalance](https://docs.mav.xyz/technical-reference/maverick-v2/v2-contracts/maverick-v2-reward-contracts/votingescrowbase/ihistoricalbalance)

Adds support for tracking historical balance on ERC20Votes (not just historical voting power) and adds support for contributing and retrieving incentives pro-rata of historical balanceOf.

Uses a timestamp-based clock for checkpoints as opposed to the default OZ implementation that is blocknumber based.

### State Variables <a href="#state-variables" id="state-variables"></a>

#### \_balanceOfCheckpoints <a href="#balanceofcheckpoints" id="balanceofcheckpoints"></a>

```solidity
mapping(address account => Checkpoints.Trace208) private _balanceOfCheckpoints;
```

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

#### getPastBalanceOf <a href="#getpastbalanceof" id="getpastbalanceof"></a>

This function retrieves the historical balance of an account at a specific point in time.

```solidity
function getPastBalanceOf(address account, uint256 timepoint) public view returns (uint256 balance);
```

**Parameters**

| Name        | Type      | Description                                                                                                    |
| ----------- | --------- | -------------------------------------------------------------------------------------------------------------- |
| `account`   | `address` | The address of the account for which to retrieve the historical balance.                                       |
| `timepoint` | `uint256` | The timepoint (block number or timestamp depending on implementation) at which to query the balance (uint256). |

**Returns**

| Name      | Type      | Description                                            |
| --------- | --------- | ------------------------------------------------------ |
| `balance` | `uint256` | The balance of the account at the specified timepoint. |

#### \_update <a href="#update" id="update"></a>

```solidity
function _update(address from, address to, uint256 amount) internal virtual override;
```

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

```solidity
function clock() public view override returns (uint48);
```

#### CLOCK\_MODE <a href="#clock_mode" id="clock_mode"></a>

Machine-readable description of the clock as specified in ERC-6372.

```solidity
function CLOCK_MODE() public pure override returns (string memory);
```

#### \_\_push <a href="#push" id="push"></a>

```solidity
function __push(Checkpoints.Trace208 storage store, function(uint208, uint208) view returns (uint208) op, uint208 delta)
    private
    returns (uint208, uint208);
```

#### \_\_add <a href="#add" id="add"></a>

```solidity
function __add(uint208 a, uint208 b) private pure returns (uint208);
```

#### \_\_subtract <a href="#subtract" id="subtract"></a>

```solidity
function __subtract(uint208 a, uint208 b) private pure returns (uint208);
```

<br>
