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:
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.
TIMELOCK: A time-locked contract controlled by developers, with a minimum validity of 2 days.
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)
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.
Parameter | Type | Description |
---|---|---|
| Address | The address of the asset pool. |
| 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.
Parameter | Type | Description |
---|---|---|
| Address | The address of the asset pool. |
| 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.
Parameter | Type | Description |
---|---|---|
| Address | The address of the asset pool. |
| 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.
Parameter | Type | Description |
---|---|---|
| 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.
Parameter | Type | Description |
---|---|---|
| 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.
Parameter | Type | Description |
---|---|---|
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.
Parameter | Type | Description |
---|---|---|
| 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.
Parameter | Type | Description |
---|---|---|
| Address | The address of the vault. |
| 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.
Parameter | Type | Description |
---|---|---|
| Address | The address of the pool. |
| 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.
Parameter | Type | Description |
---|---|---|
| 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.
Parameter | Type | Description |
---|---|---|
| Address | The address of the pool. |
| 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.
Parameter | Type | Description |
---|---|---|
| Address | The address of the pool to set the borrowing APY for. |
| 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.
Parameter | Type | Description |
---|---|---|
| Address | The address of the pool to set the reward ratio for. |
| 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.
Parameter | Type | Description |
---|---|---|
| Address[] | An array of addresses representing the contracts. |
| 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.
Parameter | Type | Description |
---|---|---|
| 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.
Parameter | Type | Description |
---|---|---|
| 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.
Parameter | Type | Description |
---|---|---|
| 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.
Parameter | Type | Description |
---|---|---|
| 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.
getEUSDAddress()
Returns the address of the eUSD token.
getProtocolRewardsPool()
Returns the address of the Lybra protocol rewards pool.
getSafeCollateralRatio(address pool)
Returns the safe collateral ratio for an asset pool.
Parameter | Type | Description |
---|---|---|
| Address | The address of the pool to check the safe collateral ratio. |
getBadCollateralRatio(address pool)
Returns the bad collateral ratio for an asset pool.
Parameter | Type | Description |
---|---|---|
| Address | The address of the pool to check the bad collateral ratio. |
getVaultWeight(address pool)
Returns the safe collateral ratio for an asset pool.
Parameter | Type | Description |
---|---|---|
| Address | The address of the pool to check the weight. |
isRedemptionProvider(address user)
Checks if a user is a redemption provider.
Parameter | Type | Description |
---|---|---|
| Address | The address of the user to check. |
getEUSDMaxLocked()
Return the maximum quantity of PeUSD that can be minted by using eUSD.
hasRole(bytes32 role, address caller)
Checks if a caller has a specific role.
Parameter | Type | Description |
---|---|---|
| Bytes32 | The role to check. |
| Address | The address of the caller to check the role for. |
Note: This function is internal and not intended for general use.
Last updated