# Core.sol

### Deposit Function

To deposit `underlying` ERC20 Token into the respective stream.

```
deposit(bytes32 _streamKey,
        uint256 _amountUnderlying) external returns (uint256, uint256);
```

* `_streamKey`: name of the stream, created by hashing protocol, underlying, duration together.
* `_amountUnderlying`: the quantity of underlying tokens user wishes to deposit

### Redeem Yield Function

To Redeem underlying yield for corresponding YT.

```
redeemYield(bytes32 _streamKey, uint256 _epoch) external;
```

* `_streamKey`: name of the stream, created by hashing protocol, underlying, duration together.
* `_epoch`: the index of the future against which yield will be redeemed.

### Redeem Principle Function

To Redeem underlying principle for corresponding OT.

```
redeemPrinciple(bytes32 _streamKey, uint256 _epoch) external;
```

* `_streamKey`: name of the stream, created by hashing protocol, underlying, duration together.
* `_epoch`: the index of the future against which principle will be redeemed.

### Expire Epoch Function

Expires the previous epoch so that the funds can become claimable.

```
expireEpoch(bytes32 _streamKey, uint256 _epoch, address _epochAddress) external;
```

* `_streamKey`: name of the stream, created by hashing protocol, underlying, duration together.
* `_epoch`: the index of the future against which principle will be redeemed.
* `_epochAddress`: address of the expired future instance

### Get Current Epoch Function

Get the current future index for a given stream.

```
getCurrentEpoch(bytes32 _streamKey) public view returns (uint256);
```

* `_streamKey`: name of the stream, created by hashing protocol, underlying, duration together.

### Get Epoch Address Function

Get the address of future for a given stream and index.

```
getEpochAddress(bytes32 _streamKey, uint256 _epoch) public view returns (address);
```

* `_streamKey`: name of the stream, created by hashing protocol, underlying, duration together.
* `_epoch`: the index of the future.

### getOTYTCount Function

Returns the amount of Ot and Yt tokens a user would receive on depositing the money at a given instance.

```
getOTYTCount(bytes32 _streamKey, uint256 _amountUnderlying) public view returns (uint256, uint256);
```

* `_streamKey`: name of the stream, created by hashing protocol, underlying, duration together.
* `_amountUnderlying`: the underlying amount the user is going to deposit.

### IsStreamInitialized Function

Check if a given stream is initialized.

```
isStreamInitialized(bytes32 _streamKey) public view returns (bool);
```

* `_streamKey`: name of the stream, created by hashing protocol, underlying, duration together.

### getYieldRemaining Function

Get the yield generated in a given epoch of a stream.

```
getYieldRemaining(bytes32 _streamKey, uint256 _epoch) public view returns (uint256);
```

* `_streamKey`: name of the stream, created by hashing protocol, underlying, duration together.
* `_epoch`: the index of the future.

### getPrincipleRemaining Function

Get the principle remaining in a given epoch of a stream.

```
getPrincipleRemaining(bytes32 _streamKey, uint256 _epoch) public view returns (uint256);
```

* `_streamKey`: name of the stream, created by hashing protocol, underlying, duration together.
* `_epoch`: the index of the future.

### getStreamKey Function

Get the unique name of the stream, created by hashing protocol, underlying, duration.

```
getStreamKey(string memory _protocol, address _underlying, uint256 _duration) public pure returns (bytes32);
```

* `_protocol`: name of the protocol. eg - AAVE/COMP.
* `_underlying`: address of the token kept as underlying. eg - DAI.
* `_duration`: number of blocks the future will run before renewing.
