# VaultAssetRegistryAdmin

**Inherits:** IVaultAssetRegistryAdmin, AccessControlInternal

Handles IP asset registry and other admin functions related to IP assets

## Functions

### registerIPAndFractionalize

Admin registers the IP and fractionalizes it, only when the vault is Closed

\*Aria must deploy an SPG NFT before calling this function + grant MINTER\_ROLE to the AriaIPRWAVault contract on the SPG NFT contract. The registration is made through `REGISTRATION_WORKFLOWS.createCollection(...)`, see <https://docs.story.foundation/developers/smart-contracts-guide/register-ip-asset#scenario-%232%3A-you-want-to-create-an-spg-nft-contract-to-do-minting-for-you> There are different sorts of IP on Aria:

* financialized IP: partial copyright and income streams
* remixable IP: programmable assets Either two SPG NFT will be created to handle these differents cases OR an SPG NFT will be created per tokenised IP\*

```solidity
function registerIPAndFractionalize(
    address spgNftContract,
    WorkflowStructs.IPMetadata memory ipMetadata,
    WorkflowStructs.LicenseTermsData[] memory licenseTermsData,
    address fractionalTokenTemplate,
    address fractionalTokenReceiver
)
    external
    onlyRole(AccessControlStorage.DEFAULT_ADMIN_ROLE)
    returns (uint256 tokenId, address ipId, uint256[] memory licenseTermsIds, address fractionalToken);
```

**Parameters**

| Name                      | Type                                 | Description                                                                                                                                          |
| ------------------------- | ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `spgNftContract`          | `address`                            | The address of the SPG NFT contract The spgNFTContract used here has to have 0 mint fee and have MINTER\_ROLE granted to the AriaIPRWAVault contract |
| `ipMetadata`              | `WorkflowStructs.IPMetadata`         | The metadata of the IP                                                                                                                               |
| `licenseTermsData`        | `WorkflowStructs.LicenseTermsData[]` | The license terms data to be attached to the IP                                                                                                      |
| `fractionalTokenTemplate` | `address`                            | The template of the fractional token                                                                                                                 |
| `fractionalTokenReceiver` | `address`                            | The receiver of the fractional token - usually staking contract, to collect royalties and distributed to stakers.                                    |

**Returns**

| Name              | Type        | Description                              |
| ----------------- | ----------- | ---------------------------------------- |
| `tokenId`         | `uint256`   | The token ID of the IP                   |
| `ipId`            | `address`   | The IP ID                                |
| `licenseTermsIds` | `uint256[]` | The license terms IDs attached to the IP |
| `fractionalToken` | `address`   | The address of the fractional token      |

### setAllIpMetadata

*Call AFTER setTokenURI as it calls under the hood SPGNFT.tokenURI(tokenId)*

```solidity
function setAllIpMetadata(
    address coreMetadataModule,
    address ipId,
    string memory metadataURI,
    bytes32 metadataHash,
    bytes32 nftMetadataHash
) external onlyRole(AccessControlStorage.DEFAULT_ADMIN_ROLE);
```

**Parameters**

| Name                 | Type      | Description                                                                                                                                                                                                 |
| -------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `coreMetadataModule` | `address` |                                                                                                                                                                                                             |
| `ipId`               | `address` |                                                                                                                                                                                                             |
| `metadataURI`        | `string`  |                                                                                                                                                                                                             |
| `metadataHash`       | `bytes32` | The hash of metadata at metadataURI. Use bytes32(0) to indicate that the metadata is not available.                                                                                                         |
| `nftMetadataHash`    | `bytes32` | A bytes32 hash representing the metadata of the NFT. This metadata is associated with the IP Asset and is accessible via the NFT's TokenURI. Use bytes32(0) to indicate that the metadata is not available. |

### setTokenURI

*Call BEFORE setAllIpMetadata*

```solidity
function setTokenURI(address spgNftContract, uint256 tokenId, string memory tokenURI)
    external
    onlyRole(AccessControlStorage.DEFAULT_ADMIN_ROLE);
```

### updateFractionalTokenTotalSupply

Admin updates the total supply of the fractional token

```solidity
function updateFractionalTokenTotalSupply(uint104 newTotalSupply)
    external
    override
    onlyRole(AccessControlStorage.DEFAULT_ADMIN_ROLE);
```

**Parameters**

| Name             | Type      | Description                                                                                                                                                                                           |
| ---------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `newTotalSupply` | `uint104` | The new total supply of the fractional token - capped to uint104 to avoid overflow in `_fundraiseCalculateClaim(...)`. A fractional token with 18 decimals can have a max supply of \~20T (trillion). |

### \_deployFractionalToken

*deploy fractional token*

```solidity
function _deployFractionalToken(address ipId, address fractionalTokenTemplate)
    internal
    returns (address fractionalToken);
```

**Parameters**

| Name                      | Type      | Description                          |
| ------------------------- | --------- | ------------------------------------ |
| `ipId`                    | `address` | The IP ID                            |
| `fractionalTokenTemplate` | `address` | The template of the fractional token |

**Returns**

| Name              | Type      | Description                         |
| ----------------- | --------- | ----------------------------------- |
| `fractionalToken` | `address` | The address of the fractional token |

### \_emitIPRegisteredAndFractionalized

```solidity
function _emitIPRegisteredAndFractionalized(
    address ipId,
    address spgNftContract,
    uint256 tokenId,
    uint256[] memory licenseTermsIds,
    address fractionalToken,
    address fractionalTokenReceiver
) internal;
```

### \_getScaledTotalDeposits

*Scales the total USDC deposits to a target number of decimals. This is used to compare USDC amounts (typically 6 decimals) with fractional token amounts (typically 18 decimals).*

```solidity
function _getScaledTotalDeposits(address usdcContract, uint8 targetDecimals) internal view returns (uint256);
```

**Parameters**

| Name             | Type      | Description                                         |
| ---------------- | --------- | --------------------------------------------------- |
| `usdcContract`   | `address` |                                                     |
| `targetDecimals` | `uint8`   | The target decimals to scale the total deposits to. |

**Returns**

| Name     | Type      | Description                                   |
| -------- | --------- | --------------------------------------------- |
| `<none>` | `uint256` | The total deposits, scaled to targetDecimals. |

### \_registerIpAndAttachTermsAndCollectRoyaltyTokens

*register IP and attach terms and collect royalty tokens*

```solidity
function _registerIpAndAttachTermsAndCollectRoyaltyTokens(
    address spgNftContract,
    WorkflowStructs.IPMetadata memory ipMetadata,
    WorkflowStructs.LicenseTermsData[] memory licenseTermsData
) internal returns (address ipId, uint256 tokenId, uint256[] memory licenseTermsIds);
```

**Parameters**

| Name               | Type                                 | Description                                     |
| ------------------ | ------------------------------------ | ----------------------------------------------- |
| `spgNftContract`   | `address`                            | The address of the SPG NFT contract             |
| `ipMetadata`       | `WorkflowStructs.IPMetadata`         | The metadata of the IP                          |
| `licenseTermsData` | `WorkflowStructs.LicenseTermsData[]` | The license terms data to be attached to the IP |

**Returns**

| Name              | Type        | Description                              |
| ----------------- | ----------- | ---------------------------------------- |
| `ipId`            | `address`   | The IP ID                                |
| `tokenId`         | `uint256`   | The token ID of the IP                   |
| `licenseTermsIds` | `uint256[]` | The license terms IDs attached to the IP |


---

# 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://docs.ariaprotocol.xyz/technical-docs/contract-docs/iprwa/vault/admin/children/vaultassetregistryadmin.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.
