LybraEUSDVaultBase
The LybraEUSDVaultBase contract is the base implementation for rebasing Lst vaults. This contract is abstract. All rebasing asset pool contracts inherit from LybraEUSDVaultBase.
Contract Overview
This contract defines the logic for asset deposit, eUSD minting, repayment, withdrawal, liquidation, and redemption functions, and more.
The main differences from Lybra V1 are as follows:
This contract is controlled by the configurator contract.
After minting additional eUSD, this contract attempts to distribute dividends by calling the distributeDividends function in the configurator contract without checking the result of the call.
The deposit function can only be used to deposit funds for oneself, and the ability to deposit funds for others has been removed.
The parameters for the fees are read from the configurator contract.
Added a check for withdrawal time, where a 0.1% fee will be charged if withdrawals are made within 3 days of deposit.
Function Documentation
depositEtherToMint
Allows users to deposit ETH and mint a specified amount of eUSD tokens. This function is only defined here and is implemented through override in the specific asset vault contract.
Parameters
mintAmount
: The desired amount of eUSD tokens to mint.
depositAssetToMint
Enables users to deposit asset and mint a specified amount of eUSD tokens. The deposit asset is transferred from the user's account to the contract, and the minted eUSD tokens are transferred to the user.
Parameters
assetAmount
: The amount of asset to deposit.mintAmount
: The desired amount of eUSD tokens to mint.
Requirements
The deposit asset amount should not be less than 1.
The user must have sufficient asset balance and approve the transfer from their account to the contract.
The value of the minted eUSD tokens should be within the acceptable range based on the current asset price.
withdraw
Allows users to withdraw their deposited assets from the contract. The specified asset amount is transferred back to the onBehalfOf's account.
Parameters
onBehalfOf
: The address of the user on whose behalf the withdrawal is made.assetAmount
: The amount of assets to withdraw.
Requirements
The
onBehalfOf
address cannot be the zero address.The asset amount to withdraw must be greater than 0.
The user must have deposited at least the specified asset amount.
liquidation
Allows a liquidation provider to liquidate a borrower's assets if their collateral ratio falls below a certain threshold. The liquidation provider receives a portion of the collateral assets as a reward.
Parameters
provider
: The address of the liquidation provider.onBehalfOf
: The address of the borrower whose assets are being liquidated.assetAmount
: The amount of collateral assets to be liquidated.
Requirements
The liquidation provider must be authorized to provide liquidation eUSD.
The collateral ratio of the borrower must be below the badCollateralRatio.
The maximum collateral that can be liquidated is 50% of the borrower's total deposited assets.
The liquidation provider must have sufficient eUSD allowance to cover the eUSD amount.
superLiquidation
Allows a liquidation provider to perform a super liquidation, fully liquidating a borrower's assets if their collateral ratio falls below a certain threshold. The liquidation provider receives a portion of the collateral assets as a reward.
Parameters
provider
: The address of the liquidation provider.onBehalfOf
: The address of the borrower whose assets are being liquidated.assetAmount
: The amount of collateral assets to be liquidated.
Requirements
The overall collateral ratio of the pool must be below the badCollateralRatio.
The collateral ratio of the borrower must be below 125%.
The amount of collateral assets to be liquidated must not exceed the total deposited assets of the borrower.
The liquidation provider must have sufficient eUSD allowance to cover the eUSD amount.
excessIncomeDistribution
Allows the contract to exchange excess income from asset balance increases for eUSD. The eUSD is then distributed to eUSD holders through the rebase mechanism. This function is only defined here and is implemented through override in the specific asset vault contract.
Parameters
payAmount
: The amount of eUSD to be paid for exchanging the yield.
rigidRedemption
Allows a redemption provider to perform a rigid redemption, where a specific amount of eUSD is rigidly redeemed for an equivalent value of collateral asset.
Parameters
provider
: The address of the redemption provider.eusdAmount
: The amount of eUSD to be rigidly redeemed.
Requirements
The provider must be a redemption provider.
The provider's debt must be equal to or above the requested eUSD amount.
The provider's collateral ratio must be at least 100%.
getAssetPrice
Returns the current USD price of the collateral asset.
getAsset
Returns the address of the collateral asset.
getAsset2EtherExchangeRate
Return the exchange rate of the LST to ETH.
Last updated