# Functions

## Initialize

```solidity
function initialize(contract IERC20 _asset, string _name, string _symbol, bytes _initParams) public
```

Initializes the Firelight Vault contract with given parameters.

**Parameters**

| Name         | Type             | Description                            |
| ------------ | ---------------- | -------------------------------------- |
| \_asset      | contract IERC20  | The underlying collateral ERC20 token. |
| \_name       | string           | The name of the vault token.           |
| \_symbol     | string           | The symbol of the vault token.         |
| \_initParams | bytes InitParams | Initial parameters.                    |

**InitParams**

Initial parameters needed for the vault's deployment.

```solidity
struct InitParams {
address defaultAdmin;
address limitUpdater;
address blocklister;
address pauser;
address periodConfigurationUpdater;
uint256 depositLimit;
uint48 periodConfigurationDuration;
}
```

**Parameters**

| Name                             | Type    | Description                                                                 |
| -------------------------------- | ------- | --------------------------------------------------------------------------- |
| defaultAdmin                     | address | Vault's admin that grants and revokes roles.                                |
| limitUpdater                     | address | Address assigned the DEPOSIT\_LIMIT\_UPDATE\_ROLE at initialization.        |
| blocklister                      | address | Address assigned the PAUSE\_ROLE at initialization.                         |
| pauser                           | address | Address assigned the PAUSE\_ROLE at initialization.                         |
| paperiodConfigurationUpdateruser | address | Address assigned the PERIOD\_CONFIGURATION\_UPDATE\_ROLE at initialization. |
| depositLimit                     | uint256 | Initial total deposit limit.                                                |
| depositLimit                     | uint48  | Initial period duration of the vault.                                       |

## periodConfigurationAtTimestamp

```solidity
function periodConfigurationAtTimestamp(uint48 timestamp) public view returns (struct PeriodConfiguration)
```

Returns the period configuration corresponding to a given timestamp.

{% hint style="warning" %}
Return value may be unreliable if timestamp given is far away in the future given that new period configurations can be added after nextPeriodEnd().
{% endhint %}

**Parameters**

| Name      | Type   | Description                                         |
| --------- | ------ | --------------------------------------------------- |
| timestamp | uint48 | The timestamp to find the period configuration for. |

**Return Values**

| Name | Type                       | Description                                                    |
| ---- | -------------------------- | -------------------------------------------------------------- |
| \[0] | struct PeriodConfiguration | The period configuration corresponding to the given timestamp. |

## periodConfigurationAtNumber

```solidity
function periodConfigurationAtNumber(uint256 periodNumber) external view returns (struct PeriodConfiguration)
```

Returns the period configuration corresponding to a given period number.

{% hint style="warning" %}
Return value may be unreliable if the period number given is far away in the future given that new period configurations can be added after nextPeriodEnd().
{% endhint %}

\
**Parameters**

| Name         | Type    | Description                                             |
| ------------ | ------- | ------------------------------------------------------- |
| periodNumber | uint256 | The period number to find the period configuration for. |

**Return Values**

| Name | Type                       | Description                                                        |
| ---- | -------------------------- | ------------------------------------------------------------------ |
| \[0] | struct PeriodConfiguration | The period configuration corresponding to the given period number. |

## periodAtTimestamp

```solidity
function periodAtTimestamp(uint48 timestamp) public view returns (uint256)
```

Returns the period number for the timestamp given.

{% hint style="warning" %}
Return value may be unreliable if period number given is far away in the future given that new period configurations can be added after nextPeriodEnd().
{% endhint %}

**Return Values**

| Name | Type    | Description                                             |
| ---- | ------- | ------------------------------------------------------- |
| \[0] | uint256 | The period number corresponding to the given timestamp. |

## currentPeriodConfiguration

```solidity
function currentPeriodConfiguration() public view returns (struct PeriodConfiguration)
```

Returns the period configuration for the current period.

\
**Return Values**

| Name | Type                       | Description                                                   |
| ---- | -------------------------- | ------------------------------------------------------------- |
| \[0] | struct PeriodConfiguration | The period configuration corresponding to the current period. |

## currentPeriod

```solidity
function currentPeriod() public view returns (uint256)
```

Returns the current active period.

**Return Values**

| Name | Type    | Description                                          |
| ---- | ------- | ---------------------------------------------------- |
| \[0] | uint256 | The current period number since contract deployment. |

## currentPeriodStart

```solidity
function currentPeriodStart() external view returns (uint48)
```

Returns the start timestamp of the current period.

**Return Values**

| Name | Type   | Description                                   |
| ---- | ------ | --------------------------------------------- |
| \[0] | uint48 | Timestamp of the start of the current period. |

## currentPeriodEnd

```solidity
function currentPeriodEnd() public view returns (uint48)
```

Returns the end timestamp of the current period.

**Return Values**

| Name | Type   | Description                                 |
| ---- | ------ | ------------------------------------------- |
| \[0] | uint48 | Timestamp of the end of the current period. |

## nextPeriodEnd

```solidity
function nextPeriodEnd() public view returns (uint48)
```

Returns the end timestamp of the period following the current period.

\
**Return Values**

| \[0] | uint48 | Timestamp of the next period end. |
| ---- | ------ | --------------------------------- |

## maxDeposit

```solidity
function maxDeposit(address receiver) public view returns (uint256 amount)
```

Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver, through a deposit call.

\
**Parameters**

| Name     | Type    | Description                          |
| -------- | ------- | ------------------------------------ |
| receiver | address | The address of the deposit receiver. |

**Return Values**

| Name   | Type    | Description                                     |
| ------ | ------- | ----------------------------------------------- |
| amount | uint256 | Maximum amount of assets that can be deposited. |

## maxMint

```solidity
function maxMint(address receiver) public view returns (uint256 amount)
```

Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.

**Parameters**

| Name     | Type    | Description                       |
| -------- | ------- | --------------------------------- |
| receiver | address | The address of the mint receiver. |

**Return Values**

| amount | uint256 | Maximum amount of shares that can be minted. |
| ------ | ------- | -------------------------------------------- |

## maxWithdraw

```solidity
function maxWithdraw(address owner) public view returns (uint256 amount)
```

Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the Vault, through a withdraw call.

**Parameters**

| Name  | Type    | Description              |
| ----- | ------- | ------------------------ |
| owner | address | The owner of the assets. |

**Return Values**

| Name   | Type    | Description                                     |
| ------ | ------- | ----------------------------------------------- |
| amount | uint256 | Maximum amount of assets that can be withdrawn. |

## maxRedeem

```solidity
function maxRedeem(address owner) public view returns (uint256 amount)
```

Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, through a redeem call.

**Parameters**

| Name  | Type    | Description              |
| ----- | ------- | ------------------------ |
| owner | address | The owner of the shares. |

## totalAssets

```solidity
function totalAssets() public view returns (uint256)
```

Returns the total assets in the vault excluding those marked for withdrawal.\
**Return Values**

| Name | Type    | Description                         |
| ---- | ------- | ----------------------------------- |
| \[0] | uint256 | The total assets held by the vault. |

## balanceOfAt

```solidity
function balanceOfAt(address account, uint48 timestamp) external view returns (uint256)
```

Returns the effective total shares for account at a specific timestamp.

**Parameters**

| account   | address | The address whose share balance is being queried.         |
| --------- | ------- | --------------------------------------------------------- |
| timestamp | uint48  | The point in time for which the balance is being checked. |

**Return Values**

| Name | Type    | Description                                        |
| ---- | ------- | -------------------------------------------------- |
| \[0] | uint256 | The shares owned by account at the specified time. |

## totalSupplyAt

```solidity
function totalSupplyAt(uint48 timestamp) external view returns (uint256)
```

Returns the total supply of shares at a specific timestamp.

**Parameters**

| Name      | Type   | Description                                                    |
| --------- | ------ | -------------------------------------------------------------- |
| timestamp | uint48 | The point in time for which the total supply is being checked. |

**Return Values**

| Name | Type    | Description                                          |
| ---- | ------- | ---------------------------------------------------- |
| \[0] | uint256 | The total shares in existence at the specified time. |

## totalAssetsAt

```solidity
function totalAssetsAt(uint48 timestamp) external view returns (uint256)
```

Returns the total underlying assets held by the vault at a specific timestamp, excluding any assets marked for withdrawal.

**Parameters**

| Name      | Type   | Text                                                            |
| --------- | ------ | --------------------------------------------------------------- |
| timestamp | uint48 | The point in time for which the total assets are being checked. |

**Return Values**

| Name | Type    | Description                                                          |
| ---- | ------- | -------------------------------------------------------------------- |
| \[0] | uint256 | The total underlying assets held by the vault at the specified time. |

## withdrawalsOf

```solidity
function withdrawalsOf(uint256 period, address account) external view returns (uint256)
```

Gets the amount an account can withdraw for a given period.

**Parameters**

| Name    | Type    | Description             |
| ------- | ------- | ----------------------- |
| period  | uint256 | Period number to check. |
| account | address | Account address.        |

**Return Values**

| Name | Type    | Description                                 |
| ---- | ------- | ------------------------------------------- |
| \[0] | uint256 | Amount of assets claimable for that period. |

## periodConfigurationsLength

```solidity
function periodConfigurationsLength() public view returns (uint256)
```

Returns the length of the <mark style="color:purple;">`periodConfigurations`</mark> array.

**Return Values**

| Name | Type    | Description                               |
| ---- | ------- | ----------------------------------------- |
| \[0] | uint256 | Length of the periodConfigurations array. |

## pause

```solidity
function pause() external
```

Pauses the contract. Requires <mark style="color:purple;">`PAUSE_ROLE`</mark>.

## unpause

```solidity
function unpause() external
```

Unpauses the contract. Requires <mark style="color:purple;">`PAUSE_ROLE`</mark>.

## updateDepositLimit

```solidity
function updateDepositLimit(uint256 newLimit) external
```

Updates the maximum deposit limit for the vault.&#x20;

Requires <mark style="color:purple;">`DEPOSIT_LIMIT_UPDATE_ROLE`</mark>.

**Parameters**

| Name     | Type    | Description            |
| -------- | ------- | ---------------------- |
| newLimit | uint256 | The new deposit limit. |

## addPeriodConfiguration

```solidity
function addPeriodConfiguration(uint48 epoch, uint48 duration) external
```

Adds a period configuration.&#x20;

Requires <mark style="color:purple;">`PERIOD_CONFIGURATION_UPDATE_ROLE`</mark>.

**Parameters**

| Name     | Type   | Description          |
| -------- | ------ | -------------------- |
| epoch    | uint48 | The epoch timestamp. |
| duration | uint48 | The period duration. |

## addToBlocklist

```solidity
function addToBlocklist(address account) external
```

Adds an address to the blocklist.&#x20;

Requires <mark style="color:purple;">`BLOCKLIST_ROLE`</mark>.

\
**Parameters**

| Name    | Type    | Description                                                   |
| ------- | ------- | ------------------------------------------------------------- |
| account | address | Address to blocklist. Cannot be zero address nor blocklisted. |

## removeFromBlocklist

```solidity
function removeFromBlocklist(address account) external
```

Removes an address from the blocklist.&#x20;

Requires <mark style="color:purple;">`BLOCKLIST_ROLE`</mark>.

**Parameters**

| Name    | Type    | Description                                            |
| ------- | ------- | ------------------------------------------------------ |
| account | address | Address to remove from blocklist. Must be blocklisted. |

## transfer

```solidity
function transfer(address to, uint256 shares) public returns (bool)
```

Transfers shares to an address, with blocklist and pause checks.

**Parameters**

| Name   | Type    | Description                   |
| ------ | ------- | ----------------------------- |
| to     | address | Recipient address.            |
| shares | uint256 | Number of shares to transfer. |

**Return Values**

| Name | Type | Description                          |
| ---- | ---- | ------------------------------------ |
| \[0] | bool | Boolean indicating transfer success. |

## transferFrom

```solidity
function transferFrom(address from, address to, uint256 shares) public returns (bool)
```

Transfers shares from one account to another using allowance, with blocklist and pause checks.

**Parameters**

| from   | address | Address sending the shares.   |
| ------ | ------- | ----------------------------- |
| to     | address | Address receiving the shares. |
| shares | uint256 | Number of shares to transfer. |

**Return Values**

| Name | Type | Description                          |
| ---- | ---- | ------------------------------------ |
| \[0] | bool | Boolean indicating transfer success. |

## deposit

```solidity
function deposit(uint256 assets, address receiver) public returns (uint256)
```

Deposits assets into the vault and receive shares, with blocklist and pause checks.

**Parameters**

| Name     | Type    | Description                   |
| -------- | ------- | ----------------------------- |
| assets   | uint256 | Amount of assets to deposit.  |
| receiver | address | Address receiving the shares. |

**Return Values**

| Name | Type    | Description                |
| ---- | ------- | -------------------------- |
| \[0] | uint256 | Amount of shares received. |

## mint

```solidity
function mint(uint256 shares, address receiver) public returns (uint256)
```

Mints shares by depositing the required amount of assets into the vault, with blocklist and pause checks.

**Parameters**

| Name     | Type    | Description                   |
| -------- | ------- | ----------------------------- |
| shares   | uint256 | Amount of shares to mint.     |
| receiver | address | Address receiving the shares. |

**Return Values**

| \[0] | uint256 | Amount of assets deposited. |
| ---- | ------- | --------------------------- |

## redeem

```solidity
function redeem(uint256 shares, address receiver, address owner) public returns (uint256)
```

Redeems shares from the vault and receives underlying assets, with blocklist and pause checks. Creates a withdrawal request, which will be available in the next period. Shares are burned.

**Parameters**

| Name     | Type    | Description                                       |
| -------- | ------- | ------------------------------------------------- |
| shares   | uint256 | Amount of shares to redeem.                       |
| receiver | address | Address to receive the assets in the next period. |
| owner    | address | Address whose shares are being redeemed.          |

**Return Values**

| Name | Type    | Description                                                |
| ---- | ------- | ---------------------------------------------------------- |
| \[0] | uint256 | Amount of assets that will be received in the next period. |

## withdraw

```solidity
function withdraw(uint256 assets, address receiver, address owner) public returns (uint256)
```

Initiates a withdrawal request from the vault, with blocklist and pause checks. The request becomes claimable starting from the period after the next full period. The calculated shares are burned.

**Parameters**

| Name     | Type    | Description                                           |
| -------- | ------- | ----------------------------------------------------- |
| assets   | uint256 | The amount of assets to withdraw.                     |
| receiver | address | The address to receive the assets in the next period. |
| owner    | address | The address whose shares are being withdrawn.         |

**Return Values**

| Name | Type    | Description                            |
| ---- | ------- | -------------------------------------- |
| \[0] | uint256 | The amount of shares that were burned. |

## claimWithdraw

```solidity
function claimWithdraw(uint256 period) external returns (uint256 assets)
```

Claims a pending withdrawal for a given period. Transfers the corresponding assets to the caller if not already claimed. Can only be called after the specified period has ended. Reverts if the withdrawal has already been claimed or if no withdrawal amount is available for the period.

**Parameters**

| Name   | Type    | Description                                          |
| ------ | ------- | ---------------------------------------------------- |
| period | uint256 | The period number for which to claim the withdrawal. |

**Return Values**

| Name   | Type    | Description                                     |
| ------ | ------- | ----------------------------------------------- |
| assets | uint256 | The amount of assets transferred to the caller. |

## rescueSharesFromBlocklisted

```solidity
function rescueSharesFromBlocklisted(address from, address to) external
```

Rescues shares from a blocklisted address. Requires <mark style="color:purple;">`RESCUER_ROLE`</mark>.

**Parameters**

| Name | Type    | Text                                                         |
| ---- | ------- | ------------------------------------------------------------ |
| from | address | The blocklisted address.                                     |
| to   | address | The address to transfer the shares. Must not be blocklisted. |

## rescueWithdrawFromBlocklisted

```solidity
function rescueWithdrawFromBlocklisted(address from, address to, uint256[] periods) external
```

Rescues pending withdrawals from a blocklisted address. Requires <mark style="color:purple;">`RESCUER_ROLE`</mark>.

**Parameters**

| from    | address    | The blocklisted address.                                        |
| ------- | ---------- | --------------------------------------------------------------- |
| to      | address    | The address to transfer the shares to. Must not be blocklisted. |
| periods | uint256\[] | An array of periods to rescue.                                  |

<br>


---

# 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.firelight.finance/technical-documents/functions.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.
