# Fixed-Term Teller

The  Fixed Term Teller is an implementation of the Bond Base Teller contract specific to handling user bond transactions and tokenizing bond markets where purchases vest in a fixed amount of time (rounded to the day) as ERC1155 tokens.It implements the functions required by the [Fixed-Term Teller Interface](/smart-contracts/bond-system/teller/teller-interfaces.md#fixed-term-teller-interface) and the [Base Teller](/smart-contracts/bond-system/teller/base-teller.md) Abstract Contract.&#x20;

It also inherits the ERC1155 standard and is itself the contract which provides information on the Bond Tokens it issues.&#x20;

Specifically, it implements the `_handlePayout` function to mint ERC1155 tokens to the user to represent their bond position during a purchase.&#x20;

Additionally, it implements the `deploy` (*i.e. stores the metadata for a new ERC1155 token if one does not exist for a combination of underlying token and the maturity date*), `create` (*allows anyone to mint ERC1155 Bond Tokens for a combination of an underlying token and maturity date by paying a fee to the protocol*), and `redeem` (*redeems ERC1155 Bond Tokens that have vested for the underlying token*).&#x20;

By design, the tokenization of the Teller is not permissioned. This allows other market participants  to use the same Bond Tokens that Bond Protocol is issuing to create a standard in the market and drive additional liquidity (*less likely for ERC1155, but it is an option*).

## Methods

This section only includes methods not inherited from [Base Teller](/smart-contracts/bond-system/teller/base-teller.md) or [ERC1155](https://github.com/transmissions11/solmate/blob/bff24e835192470ed38bf15dbed6084c2d723ace/src/tokens/ERC1155.sol).

### batchRedeem

```solidity
function batchRedeem(uint256[] tokenIds_, uint256[] amounts_) external nonpayable
```

Redeem multiple fixed-term bond tokens for the underlying tokens (bond tokens must have matured)

#### Parameters

| Name       | Type       | Description                               |
| ---------- | ---------- | ----------------------------------------- |
| tokenIds\_ | uint256\[] | Array of bond token ids                   |
| amounts\_  | uint256\[] | Array of amounts of bond tokens to redeem |

### create

```solidity
function create(contract ERC20 underlying_, uint48 expiry_, uint256 amount_) external nonpayable returns (uint256, uint256)
```

Deposit an ERC20 token and mint a future-dated ERC1155 bond token

#### Parameters

| Name         | Type           | Description                                                                |
| ------------ | -------------- | -------------------------------------------------------------------------- |
| underlying\_ | contract ERC20 | ERC20 token redeemable when the bond token vests                           |
| expiry\_     | uint48         | Timestamp at which the bond token can be redeemed for the underlying token |
| amount\_     | uint256        | Amount of underlying tokens to deposit                                     |

#### Returns

| Name      | Type    | Description                               |
| --------- | ------- | ----------------------------------------- |
| tokenId   | uint256 | ID of the ERC1155 bond token received     |
| amountOut | uint256 | Amount of the ERC1155 bond token received |

### createFeeDiscount

```solidity
function createFeeDiscount() external view returns (uint48)
```

'Create' function fee discount. Amount standard fee is reduced by for partners who just want to use the 'create' function to issue bond tokens. Configurable by policy.

#### Returns

| Name        | Type   | Description |
| ----------- | ------ | ----------- |
| feeDiscount | uint48 | undefined   |

### deploy

```solidity
function deploy(contract ERC20 underlying_, uint48 expiry_) external nonpayable returns (uint256)
```

"Deploy" a new ERC1155 bond token for an (underlying, expiry) pair and return its ID.

#### Parameters

| Name         | Type           | Description                                                                |
| ------------ | -------------- | -------------------------------------------------------------------------- |
| underlying\_ | contract ERC20 | ERC20 token redeemable when the bond token vests                           |
| expiry\_     | uint48         | Timestamp at which the bond token can be redeemed for the underlying token |

#### Returns

| Name    | Type    | Description                                |
| ------- | ------- | ------------------------------------------ |
| tokenId | uint256 | ID of the ERC1155 bond token being created |

### getTokenId

```solidity
function getTokenId(contract ERC20 underlying_, uint48 expiry_) external pure returns (uint256)
```

Get token ID from token and expiry

#### Parameters

| Name         | Type           | Description                     |
| ------------ | -------------- | ------------------------------- |
| underlying\_ | contract ERC20 | Address of the underlying token |
| expiry\_     | uint48         | Expiry of the bond              |

#### Returns

| Name    | Type    | Description          |
| ------- | ------- | -------------------- |
| tokenId | uint256 | ID of the bond token |

### getTokenNameAndSymbol

```solidity
function getTokenNameAndSymbol(uint256 tokenId_) external view returns (string, string)
```

Get the token name and symbol for a bond token

#### Parameters

| Name      | Type    | Description          |
| --------- | ------- | -------------------- |
| tokenId\_ | uint256 | ID of the bond token |

#### Returns

| Name   | Type   | Description       |
| ------ | ------ | ----------------- |
| name   | string | Bond token name   |
| symbol | string | Bond token symbol |

### redeem

```solidity
function redeem(uint256 tokenId_, uint256 amount_) external nonpayable
```

Redeem a fixed-term bond token for the underlying token (bond token must have matured)

#### Parameters

| Name      | Type    | Description                    |
| --------- | ------- | ------------------------------ |
| tokenId\_ | uint256 | ID of the bond token to redeem |
| amount\_  | uint256 | Amount of bond token to redeem |

### tokenMetadata

```solidity
function tokenMetadata(uint256) external view returns (bool active, contract ERC20 payoutToken, uint48 expiry, uint256 supply)
```

#### Parameters

| Name      | Type    | Description          |
| --------- | ------- | -------------------- |
| tokenId\_ | uint256 | ID of the bond token |

#### Returns

| Name        | Type           | Description                                                             |
| ----------- | -------------- | ----------------------------------------------------------------------- |
| active      | bool           | Whether the bond token has been created                                 |
| payoutToken | contract ERC20 | Address of the underlying token                                         |
| expiry      | uint48         | Timestamp when the bond token can be exchanged for the underlying token |
| supply      | uint256        | Total supply of the bond token                                          |

## Events

### ERC1155BondTokenCreated

```solidity
event ERC1155BondTokenCreated(uint256 tokenId, contract ERC20 indexed payoutToken, uint48 indexed expiry)
```

#### Parameters

| Name                  | Type           | Description                                                            |
| --------------------- | -------------- | ---------------------------------------------------------------------- |
| tokenId               | uint256        | ID of the ERC1155 bond token                                           |
| payoutToken `indexed` | contract ERC20 | Address of the underlying token                                        |
| expiry `indexed`      | uint48         | Timestamp when the bond token can be redeemed for the underlying token |


---

# Agent Instructions: 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:

```
GET https://dev.bondprotocol.finance/smart-contracts/bond-system/teller/fixed-term-teller.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
