# MentoReserve

## MentoReserve

The contract manages collateral assets for the GoodDollar protocol.&#x20;

### Contract Specs

The MentoReserve contract is a critical component of GoodDollar's reserve-backed token system. GoodDollar (G$) is a Universal Basic Income (UBI) token that provides daily distributions to verified users. The reserve holds collateral assets (such as CUSD on Celo, USDC on XDC, or native tokens) that back the value of GoodDollar tokens and enable the exchange mechanism.

### Events

#### TokenAdded

Emitted when a new token is added to the reserve for stabilization.

| Parameter name | Annotation                                           |
| -------------- | ---------------------------------------------------- |
| `token`        | The address of the token being added to the reserve. |

**When emitted:** This event is emitted when the owner calls `addToken()` to register a new stable token that the reserve will stabilize.

```solidity
event TokenAdded(address indexed token);
```

#### TokenRemoved

Emitted when a token is removed from the reserve and will no longer be stabilized.

| Parameter name | Annotation                                                         |
| -------------- | ------------------------------------------------------------------ |
| `token`        | The address of the token being removed from the reserve.           |
| `index`        | The index of the token in the tokens array at the time of removal. |

**When emitted:** This event is emitted when the owner calls `removeToken()` to deregister a stable token from the reserve.

```solidity
event TokenRemoved(address indexed token, uint256 index);
```

#### CollateralAssetAdded

Emitted when a new collateral asset is added to the reserve.

| Parameter name    | Annotation                                                      |
| ----------------- | --------------------------------------------------------------- |
| `collateralAsset` | The address of the collateral asset being added to the reserve. |

**When emitted:** This event is emitted when the owner calls `addCollateralAsset()` to register a new collateral asset (such as CUSD, USDC, or other ERC20 tokens) that can be used to back GoodDollar tokens.

```solidity
event CollateralAssetAdded(address collateralAsset);
```

#### CollateralAssetRemoved

Emitted when a collateral asset is removed from the reserve.

| Parameter name    | Annotation                                                          |
| ----------------- | ------------------------------------------------------------------- |
| `collateralAsset` | The address of the collateral asset being removed from the reserve. |

**When emitted:** This event is emitted when the owner calls `removeCollateralAsset()` to deregister a collateral asset from the reserve.

```solidity
event CollateralAssetRemoved(address collateralAsset);
```

### Functions

#### getTokens

Returns array of all registered tokens in the reserve.

**Returns:** Array of all registered token addresses in the reserve.

```solidity
function getTokens() external view returns (address[] memory);
```

#### isStableAsset

Checks if an asset is a stable asset.

| Parameter name | Annotation                         |
| -------------- | ---------------------------------- |
| `asset`        | The address of the asset to check. |

**Returns:** True if the asset is a stable asset, false otherwise.

```solidity
function isStableAsset(address asset) external view returns (bool);
```

#### isCollateralAsset

Checks if an asset is a collateral asset.

| Parameter name | Annotation                         |
| -------------- | ---------------------------------- |
| `asset`        | The address of the asset to check. |

**Returns:** True if the asset is a collateral asset, false otherwise.

```solidity
function isCollateralAsset(address asset) external view returns (bool);
```

#### isExchangeSpender

Checks if an address is an authorized exchange spender.

| Parameter name | Annotation            |
| -------------- | --------------------- |
| `exchange`     | The address to check. |

**Returns:** True if the address is an authorized exchange spender, false otherwise.

```solidity
function isExchangeSpender(address exchange) external view returns (bool);
```

#### isSpender

Checks if an address is an authorized spender.

| Parameter name | Annotation            |
| -------------- | --------------------- |
| `spender`      | The address to check. |

**Returns:** True if the address is an authorized spender, false otherwise.

```solidity
function isSpender(address spender) external view returns (bool);
```

#### getExchangeSpenders

Returns array of all exchange spender addresses.

**Returns:** Array of all exchange spender addresses.

```solidity
function getExchangeSpenders() external view returns (address[] memory);
```
