# BBSubscriptionsFactory

## Functions

### deploySubscriptions

```solidity
function deploySubscriptions(
    address currency
) external override returns (address)
```

Deploy a BBSubscriptions contract for an ERC20 token.

#### Parameters

| Name     | Type    | Description                         |
| -------- | ------- | ----------------------------------- |
| currency | address | Address of an ERC20 token (eg WBTC) |

#### Return Values

| Name                  | Type    | Description                                           |
| --------------------- | ------- | ----------------------------------------------------- |
| deployedSubscriptions | address | Address of the new deployed BBSubscriptions contract. |

### isSubscriptionsDeployed

```solidity
function isSubscriptionsDeployed(
    address currency
) external view override returns (bool)
```

Check if a currency has been used to deploy a BBSubscriptions contract.

#### Parameters

| Name     | Type    | Description                  |
| -------- | ------- | ---------------------------- |
| currency | address | ERC20 token to inquire about |

#### Return Values

| Name                    | Type | Description                                           |
| ----------------------- | ---- | ----------------------------------------------------- |
| isSubscriptionsDeployed | bool | True if ERC20 has a deployed BBSubscriptions contract |

### getDeployedSubscriptions

```solidity
function getDeployedSubscriptions(
    address currency
) external view override returns (address)
```

Get the BBSubscriptions contract for a given ERC20.

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| currency | address | ERC20 token |

#### Return Values

| Name                  | Type    | Description                                             |
| --------------------- | ------- | ------------------------------------------------------- |
| deployedSubscriptions | address | BBSubscriptions contract address for the given currency |

### getGracePeriod

```solidity
function getGracePeriod(
) external pure returns (uint256 gracePeriod)
```

Gets the amount of time between when a subscription expires, and when a subscriber no longer has access to a profiles content.

#### Return Values

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| gracePeriod | uint256 |             |

### getContributionBounds

```solidity
function getContributionBounds(
) external pure returns (uint256 lower, uint256 upper)
```

TODO

#### Return Values

| Name  | Type    | Description |
| ----- | ------- | ----------- |
| lower | uint256 |             |
| upper | uint256 |             |

### getSubscriptionCurrency

```solidity
function getSubscriptionCurrency(
    uint256 profileId, 
    uint256 tierId, 
    address account
) external view returns (address currency)
```

TODO

#### Parameters

| Name      | Type    | Description |
| --------- | ------- | ----------- |
| profileId | uint256 |             |
| tierId    | uint256 |             |
| account   | address |             |

#### Return Values

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| currency | address |             |

### createSubscriptionProfile

```solidity
function createSubscriptionProfile(
    uint256 profileId, 
    uint256 tierSetId, 
    uint256 contribution
) external
```

TODO

#### Parameters

| Name         | Type    | Description |
| ------------ | ------- | ----------- |
| profileId    | uint256 |             |
| tierSetId    | uint256 |             |
| contribution | uint256 |             |

### setContribution

```solidity
function setContribution(
    uint256 profileId, 
    uint256 contribution
) external
```

TODO

#### Parameters

| Name         | Type    | Description |
| ------------ | ------- | ----------- |
| profileId    | uint256 |             |
| contribution | uint256 |             |

### getSubscriptionProfile

```solidity
function getSubscriptionProfile(
    uint256 profileId
) external view returns (uint256 tierSetId, uint256 contribution)
```

Returns a profiles subscription profile.

#### Parameters

| Name      | Type    | Description                            |
| --------- | ------- | -------------------------------------- |
| profileId | uint256 | Profile ID of the subscription profile |

#### Return Values

| Name         | Type    | Description                                              |
| ------------ | ------- | -------------------------------------------------------- |
| tierSetId    | uint256 | The subscription profiles tier set ID                    |
| contribution | uint256 | The subscription profiles BackedBy treasury contribution |

### isSubscriptionProfileCreated

```solidity
function isSubscriptionProfileCreated(
    uint256 profileId
) external view returns (bool created)
```

Returns true if a profile has created a subscription profile.

#### Parameters

| Name      | Type    | Description                            |
| --------- | ------- | -------------------------------------- |
| profileId | uint256 | Profile ID of the subscription profile |

#### Return Values

| Name    | Type | Description                                  |
| ------- | ---- | -------------------------------------------- |
| created | bool | State of the subscription profiles existance |

### isSubscriptionActive

```solidity
function isSubscriptionActive(
    uint256 profileId, 
    uint256 tierId, 
    address account
) external view returns (bool active)
```

Returns true if an address is subscribed to a profile's tier.

#### Parameters

| Name      | Type    | Description                    |
| --------- | ------- | ------------------------------ |
| profileId | uint256 | Profile ID of the subscription |
| tierId    | uint256 | Tier ID of the subscription    |
| account   | address | Address of the subscriber      |

#### Return Values

| Name   | Type | Description               |
| ------ | ---- | ------------------------- |
| active | bool | Subscription active state |
