# Yield Token



The YT ([Yield Token](/docs/glossary#yield-token)) represents the yield that is accrued by an [IBT](/docs/glossary#ibt) (Interest Bearing Token). It is created when an IBT or an underlying asset is deposited into a [PrincipalToken](/docs/technical-reference/contract-functions/principal-token), and the interest bearing token is split into [PT](/docs/glossary#principal-token) and [YT](/docs/glossary#yield-token).

The YT can be traded with other users to hedge or speculate on yields. A user holding a YT can claim his yield by calling [`claimYield`](/docs/technical-reference/contract-functions/principal-token#claimyield) or [`claimYieldInIBT`](/docs/technical-reference/contract-functions/principal-token#claimyieldinibt) on the Principal Token contract.

For more information, see [Tokenising Yield](/docs/guides/tokenizing-yield).

YT.sol code can be found on [GitHub](https://github.com/perspectivefi/spectra-core/blob/main/src/tokens/YieldToken.sol).

## Methods [#methods]

### transfer [#transfer]

```solidity
function transfer(
    address to,
    uint256 value
) public returns (bool success)
```

Standard ERC20 `transfer` function with a pre-transfer yield update.

| Input Parameter | Type    | Description                     |
| --------------- | ------- | ------------------------------- |
| `to`            | address | The address to send the YT `to` |
| `value`         | uint256 | The amount of the YT to send    |

| Return Parameter | Type | Description                                                    |
| ---------------- | ---- | -------------------------------------------------------------- |
| `success`        | bool | A boolean value indicating whether the transfer was successful |

### transferFrom [#transferfrom]

```solidity
function transferFrom(
    address from,
    address to,
    uint256 value
) public returns (bool success)
```

Standard ERC20 `transfer` function with a pre-transfer yield update.

<Callout type="warn">
  `from` must have previously approved `msg.sender` to transfer `value` using the standard ERC20 approval process.
</Callout>

| Input Parameter | Type    | Description                       |
| --------------- | ------- | --------------------------------- |
| `from`          | address | The address to send the YT `from` |
| `to`            | address | The address to send the YT `to`   |
| `value`         | uint256 | The amount of the YT to send      |

| Return Parameter | Type | Description                                                    |
| ---------------- | ---- | -------------------------------------------------------------- |
| `success`        | bool | A boolean value indicating whether the transfer was successful |

## View Methods [#view-methods]

### getPT [#getpt]

```solidity
function getPT() public view returns (address)
```

Get the [Principal Token](/docs/technical-reference/contract-functions/principal-token) associated with the yield token.

### decimals [#decimals]

```solidity
function decimals() public view returns (uint8)
```

Returns the number of decimals of the YT (same as the PrincipalToken's decimals). See [`decimals()`](/docs/technical-reference/contract-functions/principal-token#decimals)

### balanceOf [#balanceof]

```solidity
function balanceOf(address account) public view returns (uint256)
```

Returns the  balance of YT before[ expiry of the principal token](/docs/technical-reference/contract-functions/principal-token#maturity) and return 0 after the expiry of the principal token.

### actualBalanceOf [#actualbalanceof]

```solidity
function actualBalanceOf(address account) public view returns (uint256)
```

Returns the real balance of YT as defined in the balanceOf from ERC20 standard

i.e the sum of incoming YT to the `account` minus the outgoing balance of YT tokens.
