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

# Carbon pool contracts

Toucan's Carbon Pool smart contracts extend the ERC20 standard — carbon reference tokens are ERC20 tokens. Pool contracts are upgradeable. Contract addresses for deployed carbon pools can be found at [app.toucan.earth/contracts](https://app.toucan.earth/contracts).

### calculateDepositFees

```solidity
function calculateDepositFees(address tco2, uint256 amount) external view returns (uint256 feeDistributionTotal)
```

View function to calculate deposit fees pre-execution

*User specifies in front-end the address and amount they want*

#### Parameters

| Name   | Type    | Description           |
| ------ | ------- | --------------------- |
| tco2   | address | TCO2 contract address |
| amount | uint256 | Amount to redeem      |

#### Return Values

| Name                 | Type    | Description                 |
| -------------------- | ------- | --------------------------- |
| feeDistributionTotal | uint256 | Total fee amount to be paid |

### calculateRedemptionOutFees

```solidity
function calculateRedemptionOutFees(address[] tco2s, uint256[] amounts, bool toRetire) external view returns (uint256 feeDistributionTotal)
```

View function to calculate fees pre-execution, according to the amounts of TCO2 to be redeemed.

#### Parameters

| Name     | Type       | Description                                                                                                                                        |
| -------- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| tco2s    | address\[] | Array of TCO2 contract addresses                                                                                                                   |
| amounts  | uint256\[] | Array of TCO2 amounts to redeem The indexes of this array are matching 1:1 with the tco2s array.                                                   |
| toRetire | bool       | Whether the TCO2s will be retired atomically with the redemption. It may be that lower fees will be charged in this case. Currently not supported. |

#### Return Values

| Name                 | Type    | Description                 |
| -------------------- | ------- | --------------------------- |
| feeDistributionTotal | uint256 | Total fee amount to be paid |

### checkEligible

```solidity
function checkEligible(address vintageToken) external view virtual returns (bool isEligible)
```

Checks if token to be deposited is eligible for this pool. Reverts if not. Beware that the revert reason might depend on the underlying implementation of IPoolFilter.checkEligible

#### Parameters

| Name         | Type    | Description           |
| ------------ | ------- | --------------------- |
| vintageToken | address | the contract to check |

#### Return Values

| Name       | Type | Description                                           |
| ---------- | ---- | ----------------------------------------------------- |
| isEligible | bool | true if address is eligible and no other issues occur |

### deposit

```solidity
function deposit(address tco2, uint256 amount, uint256 maxFee) external returns (uint256 mintedPoolTokenAmount)
```

Deposit function for pool that accepts TCO2s and mints pool token 1:1

*Eligibility of the ERC20 token to be deposited is checked via `checkEligible`*

#### Parameters

| Name   | Type    | Description                                                                                                                                                                                                                                                                                     |
| ------ | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| tco2   | address | TCO2 to be deposited. The pool contract needs to be approved in the TCO2 contract by the caller in order to allow the transfer of TCO2 tokens to the pool                                                                                                                                       |
| amount | uint256 | Amount of TCO2 to be deposited                                                                                                                                                                                                                                                                  |
| maxFee | uint256 | Maximum fee to be paid for the deposit. This value cannot be zero. Use `calculateDepositFees(tco2,amount)` to determine the fee that will be charged given the state of the pool during this call. Add a buffer on top of the returned fee amount up to the maximum fee you are willing to pay. |

#### Return Values

| Name                  | Type    | Description                                |
| --------------------- | ------- | ------------------------------------------ |
| mintedPoolTokenAmount | uint256 | Amount of pool tokens minted to the caller |

### redeemOutMany

```solidity
function redeemOutMany(address[] tco2s, uint256[] amounts, uint256 maxFee) external virtual returns (uint256 poolAmountSpent)
```

Redeem TCO2s for pool tokens 1:1 minus fees The amounts provided are the exact amounts of TCO2s to be redeemed.

#### Parameters

| Name    | Type       | Description                                                                                                                                                                                                                                                                                                      |
| ------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| tco2s   | address\[] | Array of TCO2 contract addresses                                                                                                                                                                                                                                                                                 |
| amounts | uint256\[] | Array of TCO2 amounts to redeem The indexes of this array are matching 1:1 with the tco2s array.                                                                                                                                                                                                                 |
| maxFee  | uint256    | Maximum fee to be paid for the redemption. This value cannot be zero. Use `calculateRedemptionOutFees(tco2s,amounts,false)` to determine the fee that will be charged given the state of the pool during this call. Add a buffer on top of the returned fee amount up to the maximum fee you are willing to pay. |

#### Return Values

| Name            | Type    | Description                                   |
| --------------- | ------- | --------------------------------------------- |
| poolAmountSpent | uint256 | The amount of pool tokens spent by the caller |


---

# 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.toucan.earth/developers/smart-contracts/pool-contracts.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.
