> For the complete documentation index, see [llms.txt](https://docs.inverter.network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.inverter.network/contracts/technical-reference/modules/funding-manager/bonding-curve/abstracts/virtualcollateralsupplybase_v1.sol.md).

# VirtualCollateralSupplyBase\_v1.sol

[Git Source](https://github.com/InverterNetwork/inverter-contracts/blob/649b450f02fc8b735c128ff0821467e71966c666/src/modules/fundingManager/bondingCurve/abstracts/VirtualCollateralSupplyBase_v1.sol)

**Inherits:** IVirtualCollateralSupplyBase\_v1, ERC165Upgradeable

**Author:** Inverter Network

Manages a virtual collateral supply to facilitate interactions with Inverter's Funding Manager

*Implements {IVirtualCollateralSupplyBase\_v1} for handling virtual collateral. Includes functions to set, get, add, and subtract virtual collateral amounts.*

### State Variables

#### virtualCollateralSupply

*The internal state variable to keep track of the virtual collateral supply.*

```solidity
uint internal virtualCollateralSupply;
```

#### MAX\_UINT

*Maximum unsigned integer value for overflow checks.*

```solidity
uint private constant MAX_UINT = type(uint).max;
```

#### \_\_gap

*Storage gap for future upgrades.*

```solidity
uint[50] private __gap;
```

### Functions

#### supportsInterface

*See {IERC165-supportsInterface}.*

```solidity
function supportsInterface(bytes4 interfaceId)
    public
    view
    virtual
    override(ERC165Upgradeable)
    returns (bool);
```

#### getVirtualCollateralSupply

Returns the current virtual collateral supply.

*This function returns the virtual supply by calling the internal `_getVirtualCollateralSupply` function.*

```solidity
function getVirtualCollateralSupply() external view virtual returns (uint);
```

**Returns**

| Name     | Type      | Description                                      |
| -------- | --------- | ------------------------------------------------ |
| `<none>` | `uint256` | The current virtual collateral supply as a uint. |

#### setVirtualCollateralSupply

Sets the virtual collateral supply to a new value.

*This function should call the internal function `_setVirtualCollateralSupply`. The function must be implemented by the downstream contract. The downstream contract should manage access control for setting the supply.*

```solidity
function setVirtualCollateralSupply(uint _virtualSupply) external virtual;
```

**Parameters**

| Name             | Type      | Description                                             |
| ---------------- | --------- | ------------------------------------------------------- |
| `_virtualSupply` | `uint256` | The new value to set for the virtual collateral supply. |

#### \_addVirtualCollateralAmount

*Adds a specified amount to the virtual collateral supply. Checks for overflow and reverts if an overflow occurs.*

```solidity
function _addVirtualCollateralAmount(uint _amount) internal virtual;
```

**Parameters**

| Name      | Type      | Description                                         |
| --------- | --------- | --------------------------------------------------- |
| `_amount` | `uint256` | The amount to add to the virtual collateral supply. |

#### \_subVirtualCollateralAmount

*Subtracts a specified amount from the virtual collateral supply. Checks for underflow and reverts if an underflow occurs.*

```solidity
function _subVirtualCollateralAmount(uint _amount) internal virtual;
```

**Parameters**

| Name      | Type      | Description                                                |
| --------- | --------- | ---------------------------------------------------------- |
| `_amount` | `uint256` | The amount to subtract from the virtual collateral supply. |

#### \_setVirtualCollateralSupply

*Internal function to directly set the virtual collateral supply to a new value.*

```solidity
function _setVirtualCollateralSupply(uint _virtualSupply) internal virtual;
```

**Parameters**

| Name             | Type      | Description                                             |
| ---------------- | --------- | ------------------------------------------------------- |
| `_virtualSupply` | `uint256` | The new value to set for the virtual collateral supply. |
