LybraConfigurator

The Lybra Protocol V2 Configurator contract is used for setting various parameters and control functionalities of the Lybra Protocol. Based on OpenZeppelin's Proxy and AccessControl libraries, it allows the DAO to control contract upgrades. The contract implements three governance roles:

  1. DAO: A time-locked contract initiated by esLBR voting, with a minimum validity of 14 days. After the vote is passed, only developers can execute operations.

  2. TIMELOCK: A time-locked contract controlled by developers, with a minimum validity of 2 days.

  3. ADMIN: A multisignature account controlled by developers.

The Configurator contract provides different levels of call permissions for its setting functions:

  • onlyRole(DAO): Only callable by the DAO for governance purposes.

  • checkRole(TIMELOCK): Callable by both DAO and TIMELOCK contracts.

  • checkRole(ADMIN): Callable by all governance roles.

Function

initToken(address _eusd, address _peusd)

function initEUSD(address _eusd, address _peusd) external onlyRole(DAO)

Description: Initializes the eUSD and peUSD address. This function can only be executed once.

Parameters:

  • _eusd: The address of eUSD.

  • _peusd: The address of peUSD.

setMintVault(address pool, bool isActive)

Controls the activation of a specific eUSD vault.

function setMintVault(address pool, bool isActive) external onlyRole(DAO)
ParameterTypeDescription

pool

Address

The address of the asset pool.

isActive

Boolean

Indicates whether to activate or deactivate the vault.

Restrictions: This function can only be called by the DAO.

setMintVaultMaxSupply(address pool, uint256 maxSupply)

Controls the minting limit of eUSD for an asset pool.

function setMintVaultMaxSupply(address pool, uint256 maxSupply) external onlyRole(DAO)
ParameterTypeDescription

pool

Address

The address of the asset pool.

maxSupply

Uint256

The maximum amount of eUSD that can be minted for the pool.

Restrictions: This function can only be called by the DAO.

setBadCollateralRatio(address pool, uint256 newRatio)

Sets the bad collateral ratio for an asset pool.

function setBadCollateralRatio(address pool, uint256 newRatio) external onlyRole(DAO)
ParameterTypeDescription

pool

Address

The address of the asset pool.

newRatio

Uint256

The new bad collateral ratio to be set for the specified pool.

Restrictions: This function can only be called by the DAO.

setProtocolRewards(address addr)

Sets the address of the protocol rewards pool.

function setProtocolRewards(address addr) external checkRole(TIMELOCK)
ParameterTypeDescription

addr

Address

The new address of the ProtocolRewardsPool.

Restrictions: This function can only be called by accounts with TIMELOCK or higher privilege.

setEUSDMiningIncentives(address addr)

Sets the address of the eUSDMiningIncentives pool.

function setEUSDMiningIncentives(address addr) external checkRole(TIMELOCK)
ParameterTypeDescription

addr

Address

The new address of the eUSDMiningIncentives pool.

Restrictions: This function can only be called by accounts with TIMELOCK or higher privilege.

setVaultWeight(address vault, uint256 weight)

Set the mining weight of the vault.

function setVaultWeight(address vault, uint256 weight) external checkRole(TIMELOCK)
ParameterTypeDescription

vault

Address

The address of the vault.

weight

uint256

The weight of the vault.

Restrictions: This function can only be called by accounts with TIMELOCK or higher privilege.

setPremiumTradingEnabled(bool isActive)

Sets the status of premium trading.


function setPremiumTradingEnabled(bool isActive) external checkRole(TIMELOCK)
ParameterTypeDescription

isActive

Boolean

Boolean value indicating whether premium trading is enabled or disabled.

Restrictions: This function can only be called by accounts with TIMELOCK or higher privilege.

setVaultBurnPaused(address pool, bool isActive)

Enables or disables the repayment functionality for an asset pool.


function setVaultBurnPaused(address vault, bool isActive) external checkRole(TIMELOCK)
ParameterTypeDescription

vault

Address

The address of the vault.

isActive

Boolean

Indicates whether to enable or disable the repayment functionality.

Restrictions: This function can only be called by accounts with TIMELOCK or the DAO.

setVaultMintPaused(address pool, bool isActive)

Enables or disables the mint functionality for an asset pool.

function setVaultMintPaused(address pool, bool isActive) external checkRole(ADMIN)
ParameterTypeDescription

pool

Address

The address of the pool.

isActive

Boolean

Indicates whether to enable or disable the mint functionality.

Restrictions: This function can only be called by accounts with ADMIN or higher privilege.

setRedemptionFee(uint256 newFee)

Sets the redemption fee.

function setRedemptionFee(uint256 newFee) external checkRole(TIMELOCK)
ParameterTypeDescription

newFee

Uint256

The new fee to be set.

Restrictions: This function can only be called by accounts with TIMELOCK or higher privilege.

setSafeCollateralRatio(address pool, uint256 newRatio)

Sets the safe collateral ratio for an asset pool.

function setSafeCollateralRatio(address pool, uint256 newRatio) external checkRole(TIMELOCK)
ParameterTypeDescription

pool

Address

The address of the pool.

newRatio

Uint256

The new safe collateral ratio to be set for the specified pool.

Restrictions: This function can only be called by accounts with TIMELOCK or higher privilege.

setBorrowApy(address pool, uint256 newApy)

Sets the borrowing Annual Percentage Yield (APY) for an asset pool.

function setBorrowApy(address pool, uint256 newApy) external checkRole(TIMELOCK)
ParameterTypeDescription

pool

Address

The address of the pool to set the borrowing APY for.

newApy

Uint256

The new borrowing APY to be set for the specified pool.

Restrictions: This function can only be called by accounts with TIMELOCK or higher privilege.

setKeeperRatio(address pool, uint256 newRatio)

Sets the reward ratio for the liquidator after liquidation.

function setKeeperRatio(address pool, uint256 newRatio) external checkRole(TIMELOCK)
ParameterTypeDescription

pool

Address

The address of the pool to set the reward ratio for.

newRatio

Uint256

The new reward ratio to be set for the specified pool.

Restrictions: This function can only be called by accounts with TIMELOCK or higher privilege.

setTokenMiner(address[] calldata _contracts, bool[] calldata _bools)

Sets the mining permission for the esLBR & LBR mining pool.

function setTokenMiner(address[] calldata _contracts, bool[] calldata _bools) external checkRole(TIMELOCK)
ParameterTypeDescription

_contracts

Address[]

An array of addresses representing the contracts.

_bools

Boolean[]

An array of booleans indicating whether mining is allowed for each contract.

Restrictions: This function can only be called by accounts with TIMELOCK or higher privilege.

setMaxStableRatio(uint256 _ratio)

Sets the maximum percentage share for PeUSD.

function setMaxStableRatio(uint256 _ratio) external checkRole(TIMELOCK)
ParameterTypeDescription

_ratio

Uint256

The ratio in basis points (1/10_000). The maximum value is 10_000.

Restrictions: This function can only be called by accounts with TIMELOCK or higher privilege.

setFlashloanFee(uint256 fee)

Updates the flashloan fee percentage.

function setFlashloanFee(uint256 fee) external checkRole(TIMELOCK)
ParameterTypeDescription

fee

Uint256

The fee percentage for eUSD, multiplied by 100. For example, 10% is represented as 1000.

Restrictions: This function can only be called by accounts with TIMELOCK or higher privilege.

becomeRedemptionProvider(bool _bool)

User chooses to become a Redemption Provider.

function becomeRedemptionProvider(bool _bool) external
ParameterTypeDescription

_bool

Boolean

Indicates whether the user becomes a Redemption Provider or not.

refreshMintReward(address user)

Updates the mining data for the user's eUSD mining incentives.

function refreshMintReward(address user) external
ParameterTypeDescription

user

Address

The address of the user to update the rewards.

distributeRewards()

Distributes rewards to the LybraProtocolRewardsPool based on the available balance of peUSD and eUSD. If the balance is greater than 1e21, the distribution process is triggered.

First, if the eUSD balance is greater than 1,000 and the premiumTradingEnabled flag is set to true, and the eUSD/USDC premium exceeds 0.5%, eUSD will be exchanged for USDC and added to the LybraProtocolRewardsPool. Otherwise, eUSD will be directly converted to peUSD, and the entire peUSD balance will be transferred to the LybraProtocolRewardsPool.

The protocol rewards amount is notified to the LybraProtocolRewardsPool for proper reward allocation.

function distributeDividends() external

getEUSDAddress()

Returns the address of the eUSD token.

function getEUSDAddress() external view returns (address)

getProtocolRewardsPool()

Returns the address of the Lybra protocol rewards pool.

function getDividendPool() external view returns (address)

getSafeCollateralRatio(address pool)

Returns the safe collateral ratio for an asset pool.

function getSafeCollateralRatio(address pool) external view returns (uint256)
ParameterTypeDescription

pool

Address

The address of the pool to check the safe collateral ratio.

getBadCollateralRatio(address pool)

Returns the bad collateral ratio for an asset pool.

function getBadCollateralRatio(address pool) external view returns (uint256)
ParameterTypeDescription

pool

Address

The address of the pool to check the bad collateral ratio.

getVaultWeight(address pool)

Returns the safe collateral ratio for an asset pool.

function getVaultWeight(address pool) external view returns (uint256)
ParameterTypeDescription

pool

Address

The address of the pool to check the weight.

isRedemptionProvider(address user)

Checks if a user is a redemption provider.

function isRedemptionProvider(address user) external view returns (bool)
ParameterTypeDescription

user

Address

The address of the user to check.

getEUSDMaxLocked()

Return the maximum quantity of PeUSD that can be minted by using eUSD.

function getEUSDMaxLocked() external view returns (uint256)

hasRole(bytes32 role, address caller)

Checks if a caller has a specific role.

function hasRole(bytes32 role, address caller) external view returns (bool)
ParameterTypeDescription

role

Bytes32

The role to check.

caller

Address

The address of the caller to check the role for.

Note: This function is internal and not intended for general use.

Last updated