> ## Documentation Index
> Fetch the complete documentation index at: https://docs.story.foundation/llms.txt
> Use this file to discover all available pages before exploring further.

# GroupingModule

The Grouping Module is the main entry point for the IPA grouping on Story. It is responsible for:

* Registering a group
* Adding IP to group
* Removing IP from group
* Claiming reward

## State Variables

### name

```solidity theme={null}
string public constant override name = GROUPING_MODULE_KEY
```

Returns the name of the module.

### ROYALTY\_MODULE

```solidity theme={null}
IRoyaltyModule public immutable ROYALTY_MODULE
```

Returns the canonical protocol-wide RoyaltyModule.

### LICENSE\_TOKEN

```solidity theme={null}
ILicenseToken public immutable LICENSE_TOKEN
```

Returns the canonical protocol-wide LicenseToken.

### GROUP\_NFT

```solidity theme={null}
IGroupNFT public immutable GROUP_NFT
```

Returns the address GROUP NFT contract.

### GROUP\_IP\_ASSET\_REGISTRY

```solidity theme={null}
IGroupIPAssetRegistry public immutable GROUP_IP_ASSET_REGISTRY
```

Returns the canonical protocol-wide Group IP Asset Registry.

### LICENSE\_REGISTRY

```solidity theme={null}
ILicenseRegistry public immutable LICENSE_REGISTRY
```

Returns the canonical protocol-wide LicenseRegistry.

### DISPUTE\_MODULE

```solidity theme={null}
IDisputeModule public immutable DISPUTE_MODULE
```

Returns the protocol-wide dispute module.

## Functions

### initialize

```solidity theme={null}
function initialize(address accessManager) public initializer
```

Initializer for this implementation contract.

**Parameters:**

* `accessManager`: The address of the protocol admin roles contract.

### registerGroup

```solidity theme={null}
function registerGroup(address groupPool) external nonReentrant whenNotPaused returns (address groupId)
```

Registers a Group IPA.

**Parameters:**

* `groupPool`: The address of the group pool.

**Returns:**

* `groupId`: The address of the newly registered Group IPA.

### whitelistGroupRewardPool

```solidity theme={null}
function whitelistGroupRewardPool(address rewardPool, bool allowed) external restricted
```

Whitelists a group reward pool.

**Parameters:**

* `rewardPool`: The address of the group reward pool.
* `allowed`: Whether the group reward pool is whitelisted.

### addIp

```solidity theme={null}
function addIp(
    address groupIpId,
    address[] calldata ipIds,
    uint256 maxAllowedRewardShare
) external nonReentrant whenNotPaused verifyPermission(groupIpId)
```

Adds IP to group. The function must be called by the Group IP owner or an authorized operator.

**Parameters:**

* `groupIpId`: The address of the group IP.
* `ipIds`: The IP IDs.
* `maxAllowedRewardShare`: The maximum reward share percentage that can be allocated to each member IP.

### removeIp

```solidity theme={null}
function removeIp(
    address groupIpId,
    address[] calldata ipIds
) external nonReentrant whenNotPaused verifyPermission(groupIpId)
```

Removes IP from group. The function must be called by the Group IP owner or an authorized operator.

**Parameters:**

* `groupIpId`: The address of the group IP.
* `ipIds`: The IP IDs.

### claimReward

```solidity theme={null}
function claimReward(address groupId, address token, address[] calldata ipIds) external nonReentrant whenNotPaused
```

Claims reward.

**Parameters:**

* `groupId`: The address of the group.
* `token`: The address of the token.
* `ipIds`: The IP IDs.

### collectRoyalties

```solidity theme={null}
function collectRoyalties(
    address groupId,
    address token
) external nonReentrant whenNotPaused returns (uint256 royalties)
```

Collects royalties into the pool, making them claimable by group member IPs.

**Parameters:**

* `groupId`: The address of the group.
* `token`: The address of the token.

**Returns:**

* `royalties`: The amount of royalties collected.

### name

```solidity theme={null}
function name() external pure override returns (string memory)
```

Returns the name of the module.

**Returns:**

* `string`: The name of the module.

### getClaimableReward

```solidity theme={null}
function getClaimableReward(
    address groupId,
    address token,
    address[] calldata ipIds
) external view returns (uint256[] memory)
```

Returns the available reward for each IP in the group.

**Parameters:**

* `groupId`: The address of the group.
* `token`: The address of the token.
* `ipIds`: The IP IDs.

**Returns:**

* `uint256[] memory`: The rewards for each IP.
