> For the complete documentation index, see [llms.txt](https://docs-v4.venus.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-v4.venus.io/technical-reference/reference-core-pool/prime/prime-liquidity-provider.md).

# Prime liquidity provider

## PrimeLiquidityProvider

PrimeLiquidityProvider is used to fund Prime

PrimeLiquidityProvider deployments can accrue per block or per second and can fund either Prime V1 or PrimeV2. See the [Prime version map](/technical-reference/reference-core-pool/prime.md) for current consumer, clock, and pause state by network.

{% hint style="warning" %}
Distribution speeds use the deployment's `isTimeBased()` clock. Read `blocksOrSecondsPerYear()` and `paused()` from the exact proxy before annualizing a speed or assuming funds can be released.
{% endhint %}

## Solidity API

#### constructor

Configures the immutable time basis on the implementation.

```solidity
constructor(bool timeBased_, uint256 blocksPerYear_)
```

When `timeBased_` is true, the contract uses seconds and the annualization constant is 31,536,000; otherwise it uses the supplied block count.

***

#### DEFAULT\_MAX\_DISTRIBUTION\_SPEED

The default max token distribution speed

```solidity
uint256 DEFAULT_MAX_DISTRIBUTION_SPEED
```

***

#### prime

Address of the Prime contract

```solidity
address prime
```

***

#### tokenDistributionSpeeds

The rate at which a token is distributed per block or second

```solidity
mapping(address => uint256) tokenDistributionSpeeds
```

***

#### maxTokenDistributionSpeeds

The max token distribution speed for token

```solidity
mapping(address => uint256) maxTokenDistributionSpeeds
```

***

#### lastAccruedBlock

The last block or second up to which rewards were accrued for the token (view getter over the `lastAccruedBlockOrSecond` storage mapping)

```solidity
function lastAccruedBlock(address token_) external view returns (uint256)
```

***

#### tokenAmountAccrued

The token accrued but not yet transferred to prime contract (view getter over the internal `_tokenAmountAccrued` mapping)

```solidity
function tokenAmountAccrued(address token_) external view returns (uint256)
```

***

#### initialize

PrimeLiquidityProvider initializer

```solidity
function initialize(address accessControlManager_, address[] tokens_, uint256[] distributionSpeeds_, uint256[] maxDistributionSpeeds_, uint256 loopsLimit_) external
```

**Parameters**

| Name                    | Type       | Description                                             |
| ----------------------- | ---------- | ------------------------------------------------------- |
| accessControlManager\_  | address    | AccessControlManager contract address                   |
| tokens\_                | address\[] | Array of addresses of the tokens                        |
| distributionSpeeds\_    | uint256\[] | New distribution speeds for tokens                      |
| maxDistributionSpeeds\_ | uint256\[] |                                                         |
| loopsLimit\_            | uint256    | Maximum number of loops allowed in a single transaction |

**❌ Errors**

* Throw InvalidArguments on different length of tokens and speeds array

***

#### initializeTokens

Initialize the distribution of the token

```solidity
function initializeTokens(address[] tokens_) external
```

**Parameters**

| Name     | Type       | Description                                       |
| -------- | ---------- | ------------------------------------------------- |
| tokens\_ | address\[] | Array of addresses of the tokens to be intialized |

**⛔️ Access Requirements**

* Only Governance

***

#### pauseFundsTransfer

Pause fund transfer of tokens to Prime contract

```solidity
function pauseFundsTransfer() external
```

**⛔️ Access Requirements**

* Controlled by ACM

***

#### resumeFundsTransfer

Resume fund transfer of tokens to Prime contract

```solidity
function resumeFundsTransfer() external
```

**⛔️ Access Requirements**

* Controlled by ACM

***

#### setTokensDistributionSpeed

Set distribution speed per block or second

```solidity
function setTokensDistributionSpeed(address[] tokens_, uint256[] distributionSpeeds_) external
```

**Parameters**

| Name                 | Type       | Description                        |
| -------------------- | ---------- | ---------------------------------- |
| tokens\_             | address\[] | Array of addresses of the tokens   |
| distributionSpeeds\_ | uint256\[] | New distribution speeds for tokens |

**⛔️ Access Requirements**

* Controlled by ACM

**❌ Errors**

* Throw InvalidArguments on different length of tokens and speeds array

***

#### setMaxTokensDistributionSpeed

Set maximum distribution speed per block or second

```solidity
function setMaxTokensDistributionSpeed(address[] tokens_, uint256[] maxDistributionSpeeds_) external
```

**Parameters**

| Name                    | Type       | Description                        |
| ----------------------- | ---------- | ---------------------------------- |
| tokens\_                | address\[] | Array of addresses of the tokens   |
| maxDistributionSpeeds\_ | uint256\[] | New distribution speeds for tokens |

**⛔️ Access Requirements**

* Controlled by ACM

**❌ Errors**

* Throw InvalidArguments on different length of tokens and speeds array

***

#### setPrimeToken

Set the prime token contract address

```solidity
function setPrimeToken(address prime_) external
```

**Parameters**

| Name    | Type    | Description                                 |
| ------- | ------- | ------------------------------------------- |
| prime\_ | address | The new address of the prime token contract |

**📅 Events**

* Emits PrimeTokenUpdated event

**⛔️ Access Requirements**

* Only owner

***

#### setMaxLoopsLimit

Set the limit for the loops can iterate to avoid the DOS

```solidity
function setMaxLoopsLimit(uint256 loopsLimit) external
```

**Parameters**

| Name       | Type    | Description                                   |
| ---------- | ------- | --------------------------------------------- |
| loopsLimit | uint256 | Limit for the max loops can execute at a time |

**📅 Events**

* Emits MaxLoopsLimitUpdated event on success

**⛔️ Access Requirements**

* Controlled by ACM

***

#### releaseFunds

Release the token amount accrued through the latest block or second

```solidity
function releaseFunds(address token_) external
```

**Parameters**

| Name    | Type    | Description                                |
| ------- | ------- | ------------------------------------------ |
| token\_ | address | The token to release to the Prime contract |

**📅 Events**

* Emits TokenTransferredToPrime event

**❌ Errors**

* Throw InvalidArguments on Zero address(token)
* Throw FundsTransferIsPaused is paused
* Throw InvalidCaller if the sender is not the Prime contract

***

#### sweepToken

A public function to sweep accidental ERC-20 transfers to this contract. Tokens are sent to user

```solidity
function sweepToken(contract IERC20Upgradeable token_, address to_, uint256 amount_) external
```

**Parameters**

| Name     | Type                       | Description                              |
| -------- | -------------------------- | ---------------------------------------- |
| token\_  | contract IERC20Upgradeable | The address of the ERC-20 token to sweep |
| to\_     | address                    | The address of the recipient             |
| amount\_ | uint256                    | The amount of tokens needs to transfer   |

**📅 Events**

* Emits SweepToken event

**⛔️ Access Requirements**

* Only Governance

**❌ Errors**

* Throw InsufficientBalance if amount\_ is greater than the available balance of the token in the contract

***

#### getEffectiveDistributionSpeed

Get the effective reward speed per block or second for a token

```solidity
function getEffectiveDistributionSpeed(address token_) external view returns (uint256)
```

**Parameters**

| Name    | Type    | Description          |
| ------- | ------- | -------------------- |
| token\_ | address | Address of the token |

**Return Values**

| Name | Type    | Description                                                     |
| ---- | ------- | --------------------------------------------------------------- |
| \[0] | uint256 | Effective reward speed in the deployment's configured time unit |

***

#### accrueTokens

Accrue token by updating the distribution state

```solidity
function accrueTokens(address token_) public
```

**Parameters**

| Name    | Type    | Description          |
| ------- | ------- | -------------------- |
| token\_ | address | Address of the token |

**📅 Events**

* Emits TokensAccrued event

***

#### getBlockNumberOrTimestamp

Get the current block number (block-based chains) or timestamp (time-based chains). Inherited from `TimeManagerV8`.

```solidity
function getBlockNumberOrTimestamp() public view virtual returns (uint256)
```

**Return Values**

| Name | Type    | Description                                                       |
| ---- | ------- | ----------------------------------------------------------------- |
| \[0] | uint256 | blockNumberOrSecond returns the current block number or timestamp |

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs-v4.venus.io/technical-reference/reference-core-pool/prime/prime-liquidity-provider.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
