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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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

refreshMintReward(address user)

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

function refreshMintReward(address user) external

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)

getBadCollateralRatio(address pool)

Returns the bad collateral ratio for an asset pool.

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

getVaultWeight(address pool)

Returns the safe collateral ratio for an asset pool.

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

isRedemptionProvider(address user)

Checks if a user is a redemption provider.

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

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)

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

Last updated