# IVaultAdmin

Interface for basic admin functions of the Aria IP Vault

## Functions

### amIAdmin

*Simplest self admin check*

```solidity
function amIAdmin() external view returns (bool);
```

### initFundraise

Initializes the vault for fundraise.

*Can not initialize both a fundraise and a whitelist vault.*

```solidity
function initFundraise(
    address admin,
    StoryAddrs memory storyAddrs,
    AriaIPRWAVaultStorage.FractionalTokenDetails memory tokenDetails,
    VaultFundraiseStorage.Setup memory fundraiseSetup,
    uint48 mintTimelockDuration,
    uint256 claimDeadline,
    address legal
) external;
```

**Parameters**

| Name                   | Type                                           | Description                                                                                        |
| ---------------------- | ---------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| `admin`                | `address`                                      | The address of the admin of the vault                                                              |
| `storyAddrs`           | `StoryAddrs`                                   | The addresses of the Story Protocol's contracts - zero addr check is done in the factory contract. |
| `tokenDetails`         | `AriaIPRWAVaultStorage.FractionalTokenDetails` | The details of the fractional token to be deployed                                                 |
| `fundraiseSetup`       | `VaultFundraiseStorage.Setup`                  | The setup of the fundraise                                                                         |
| `mintTimelockDuration` | `uint48`                                       | The timelock duration (in seconds) for admin fractional token mints.                               |
| `claimDeadline`        | `uint256`                                      | The deadline for the users to claim the fractional token.                                          |
| `legal`                | `address`                                      | The address of the legal contract that checks blacklist and license.                               |

### initWhitelist

Initializes the vault for whitelist.

*Can not initialize both a fundraise and a whitelist vault.*

```solidity
function initWhitelist(
    address admin,
    StoryAddrs memory storyAddrs,
    AriaIPRWAVaultStorage.FractionalTokenDetails memory tokenDetails,
    bytes32 merkleRoot,
    uint48 mintTimelockDuration,
    uint256 claimDeadline,
    address legal
) external;
```

**Parameters**

| Name                   | Type                                           | Description                                                                                        |
| ---------------------- | ---------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| `admin`                | `address`                                      | The address of the admin of the vault                                                              |
| `storyAddrs`           | `StoryAddrs`                                   | The addresses of the Story Protocol's contracts - zero addr check is done in the factory contract. |
| `tokenDetails`         | `AriaIPRWAVaultStorage.FractionalTokenDetails` | The details of the fractional token to be deployed                                                 |
| `merkleRoot`           | `bytes32`                                      | The merkle root of the whitelist                                                                   |
| `mintTimelockDuration` | `uint48`                                       | The timelock duration (in seconds) for admin fractional token mints.                               |
| `claimDeadline`        | `uint256`                                      | The deadline for the users to claim the fractional token.                                          |
| `legal`                | `address`                                      | The address of the legal contract that checks blacklist and license.                               |

### recoverLostTokens

Recovers lost tokens

*Only the admin can recover lost tokens, including fractional tokens as they are minted not sent to the vault.*

```solidity
function recoverLostTokens(address token, address to) external;
```

**Parameters**

| Name    | Type      | Description                              |
| ------- | --------- | ---------------------------------------- |
| `token` | `address` | The address of the token to be recovered |
| `to`    | `address` | The address of the recipient             |

### setClaimDeadline

Sets the claim deadline

*Can only be called by the admin.*

```solidity
function setClaimDeadline(uint256 newClaimDeadline) external;
```

**Parameters**

| Name               | Type      | Description            |
| ------------------ | --------- | ---------------------- |
| `newClaimDeadline` | `uint256` | The new claim deadline |

### initFractionalTokenMint

Initiates a timelocked mint of the vault's fractional tokens by the admin.

*Can only be called by the owner. Records the mint details and sets the unlock timestamp. A mint must be executed via `execFractionalTokenMint` at/after the timelock passes. Reverts if there is already a pending mint.*

```solidity
function initFractionalTokenMint(address recipient, uint256 amount) external;
```

**Parameters**

| Name        | Type      | Description                               |
| ----------- | --------- | ----------------------------------------- |
| `recipient` | `address` | The address to receive the minted tokens. |
| `amount`    | `uint256` | The amount of fractional tokens to mint.  |

### execFractionalTokenMint

Executes a previously initiated fractional token mint after the timelock duration.

*Can be triggered by anyone. Checks if the timelock has passed and transfers the tokens. Resets the pending mint state. Reverts if no mint is pending or the timelock has not been reached.*

```solidity
function execFractionalTokenMint() external;
```

### initTimelockUpdate

Initiates a timelocked update for the admin fractional token mint duration.

*Can only be called by the owner. Uses the current timelock duration for the delay. A duration update must be executed via `execTimelockUpdate` after the timelock passes. Reverts if there is already a duration update pending.*

```solidity
function initTimelockUpdate(uint48 newDuration) external;
```

**Parameters**

| Name          | Type     | Description                           |
| ------------- | -------- | ------------------------------------- |
| `newDuration` | `uint48` | The proposed new duration in seconds. |

### execTimelockUpdate

Executes a previously initiated update to the admin fractional token mint duration.

*Can only be called by anyone. Checks if the timelock has passed and updates the duration. Resets the pending duration update state. Reverts if no duration update is pending or the timelock has not been reached.*

```solidity
function execTimelockUpdate() external;
```

## Events

### ClaimDeadlineUpdated

Emitted when the claim deadline is updated

```solidity
event ClaimDeadlineUpdated(uint256 oldClaimDeadline, uint256 newClaimDeadline);
```

**Parameters**

| Name               | Type      | Description            |
| ------------------ | --------- | ---------------------- |
| `oldClaimDeadline` | `uint256` | The old claim deadline |
| `newClaimDeadline` | `uint256` | The new claim deadline |

### LostTokensRecovered

Emitted when lost tokens are recovered

*Accounts for funds deposited through fundraise. These funds are not recoverable.*

```solidity
event LostTokensRecovered(address indexed token, address indexed to, uint256 indexed amount);
```

**Parameters**

| Name     | Type      | Description                        |
| -------- | --------- | ---------------------------------- |
| `token`  | `address` | The address of the token recovered |
| `to`     | `address` | The address of the recipient       |
| `amount` | `uint256` | The amount of the token recovered  |

### MintInitiated

Emitted when a fractional token mint is initiated by the admin.

```solidity
event MintInitiated(address indexed recipient, uint256 amount, uint48 mintExec);
```

**Parameters**

| Name        | Type      | Description                                         |
| ----------- | --------- | --------------------------------------------------- |
| `recipient` | `address` | The address that will receive the tokens.           |
| `amount`    | `uint256` | The amount of fractional tokens requested for mint. |
| `mintExec`  | `uint48`  | The timestamp when the mint can be executed.        |

### MintExecuted

Emitted when a fractional token mint is executed at/after the timelock.

```solidity
event MintExecuted(address indexed recipient, uint256 amount);
```

**Parameters**

| Name        | Type      | Description                             |
| ----------- | --------- | --------------------------------------- |
| `recipient` | `address` | The address that received the tokens.   |
| `amount`    | `uint256` | The amount of fractional tokens minted. |

### TimelockDurationUpdateInitiated

Emitted when an update to the fractional token mint timelock duration is initiated.

```solidity
event TimelockDurationUpdateInitiated(uint48 newDuration, uint48 mintExec);
```

**Parameters**

| Name          | Type     | Description                                             |
| ------------- | -------- | ------------------------------------------------------- |
| `newDuration` | `uint48` | The proposed new duration in seconds.                   |
| `mintExec`    | `uint48` | The timestamp when the duration update can be executed. |

### TimelockDurationUpdateExecuted

Emitted when a fractional token mint timelock duration update is executed.

```solidity
event TimelockDurationUpdateExecuted(uint48 oldDuration, uint48 newDuration);
```

**Parameters**

| Name          | Type     | Description                       |
| ------------- | -------- | --------------------------------- |
| `oldDuration` | `uint48` | The previous duration in seconds. |
| `newDuration` | `uint48` | The new duration in seconds.      |
