> For the complete documentation index, see [llms.txt](https://docs.gooddollar.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gooddollar.org/for-developers/core-contracts/mentoreserve.md).

# 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);
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.gooddollar.org/for-developers/core-contracts/mentoreserve.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
