Skip to content

Prime liquidity provider

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 for current consumer, clock, and pause state by network.

Configures the immutable time basis on the implementation.

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.


The default max token distribution speed

uint256 DEFAULT_MAX_DISTRIBUTION_SPEED

Address of the Prime contract

address prime

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

mapping(address => uint256) tokenDistributionSpeeds

The max token distribution speed for token

mapping(address => uint256) maxTokenDistributionSpeeds

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

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

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

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

PrimeLiquidityProvider initializer

function initialize(address accessControlManager_, address[] tokens_, uint256[] distributionSpeeds_, uint256[] maxDistributionSpeeds_, uint256 loopsLimit_) external
NameTypeDescription
accessControlManager_addressAccessControlManager contract address
tokens_address[]Array of addresses of the tokens
distributionSpeeds_uint256[]New distribution speeds for tokens
maxDistributionSpeeds_uint256[]
loopsLimit_uint256Maximum number of loops allowed in a single transaction
  • Throw InvalidArguments on different length of tokens and speeds array

Initialize the distribution of the token

function initializeTokens(address[] tokens_) external
NameTypeDescription
tokens_address[]Array of addresses of the tokens to be intialized
  • Only Governance

Pause fund transfer of tokens to Prime contract

function pauseFundsTransfer() external
  • Controlled by ACM

Resume fund transfer of tokens to Prime contract

function resumeFundsTransfer() external
  • Controlled by ACM

Set distribution speed per block or second

function setTokensDistributionSpeed(address[] tokens_, uint256[] distributionSpeeds_) external
NameTypeDescription
tokens_address[]Array of addresses of the tokens
distributionSpeeds_uint256[]New distribution speeds for tokens
  • Controlled by ACM
  • Throw InvalidArguments on different length of tokens and speeds array

Set maximum distribution speed per block or second

function setMaxTokensDistributionSpeed(address[] tokens_, uint256[] maxDistributionSpeeds_) external
NameTypeDescription
tokens_address[]Array of addresses of the tokens
maxDistributionSpeeds_uint256[]New distribution speeds for tokens
  • Controlled by ACM
  • Throw InvalidArguments on different length of tokens and speeds array

Set the prime token contract address

function setPrimeToken(address prime_) external
NameTypeDescription
prime_addressThe new address of the prime token contract
  • Emits PrimeTokenUpdated event
  • Only owner

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

function setMaxLoopsLimit(uint256 loopsLimit) external
NameTypeDescription
loopsLimituint256Limit for the max loops can execute at a time
  • Emits MaxLoopsLimitUpdated event on success
  • Controlled by ACM

Release the token amount accrued through the latest block or second

function releaseFunds(address token_) external
NameTypeDescription
token_addressThe token to release to the Prime contract
  • Emits TokenTransferredToPrime event
  • Throw InvalidArguments on Zero address(token)
  • Throw FundsTransferIsPaused is paused
  • Throw InvalidCaller if the sender is not the Prime contract

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

function sweepToken(contract IERC20Upgradeable token_, address to_, uint256 amount_) external
NameTypeDescription
token_contract IERC20UpgradeableThe address of the ERC-20 token to sweep
to_addressThe address of the recipient
amount_uint256The amount of tokens needs to transfer
  • Emits SweepToken event
  • Only Governance
  • Throw InsufficientBalance if amount_ is greater than the available balance of the token in the contract

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

function getEffectiveDistributionSpeed(address token_) external view returns (uint256)
NameTypeDescription
token_addressAddress of the token
NameTypeDescription
[0]uint256Effective reward speed in the deployment’s configured time unit

Accrue token by updating the distribution state

function accrueTokens(address token_) public
NameTypeDescription
token_addressAddress of the token
  • Emits TokensAccrued event

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

function getBlockNumberOrTimestamp() public view virtual returns (uint256)
NameTypeDescription
[0]uint256blockNumberOrSecond returns the current block number or timestamp