> For the complete documentation index, see [llms.txt](https://docs.prl.one/buttonwood/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.prl.one/buttonwood/developers/tranche/bondcontroller.md).

# Bond

Controller for a ButtonTranche bond

Invariants:

* `totalDebt` should always equal the sum of all tranche tokens' `totalSupply()`

## API Documentation

## `init(address _trancheFactory, address _collateralToken, address _admin, uint256[] trancheRatios, uint256 _maturityDate)` (external)

Constructor for Tranche ERC20 token

## `deposit(uint256 amount)` (external)

Deposit `amount` tokens from `msg.sender`, get tranche tokens in return Requirements:

* `msg.sender` must have `approved` `amount` collateral tokens to this contract

## `mature()` (external)

Matures the bond. Disables deposits, fixes the redemption ratio, and distributes collateral to redemption pools Requirements:

* The bond is not already mature
* One of:
  * `msg.sender` is `owner`
  * `maturityDate` has passed

## `redeemMature(address tranche, uint256 amount)` (external)

Redeems some tranche tokens Requirements:

* The bond is mature
* `msg.sender` owns at least `amount` tranche tokens from address `tranche`
* `tranche` must be a valid tranche token on this bond

## `redeem(uint256[] amounts)` (external)

Redeems a slice of tranche tokens from all tranches. Returns collateral to the user proportionally to the amount of debt they are removing Requirements

* The bond is not mature
* The number of `amounts` is the same as the number of tranches
* The `amounts` are in equivalent ratio to the tranche order

## `getTrancheName(string collateralSymbol, uint256 index, uint256 _trancheCount) → string` (internal)

Get the string name for a tranche

## `getTrancheSymbol(string collateralSymbol, uint256 index, uint256 _trancheCount) → string` (internal)

Get the string symbol for a tranche

## `getTrancheLetter(uint256 index, uint256 _trancheCount) → string` (internal)

Get the string letter for a tranche index


---

# 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.prl.one/buttonwood/developers/tranche/bondcontroller.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.
