BLVaultManagerLido
Inherits: Policy, IBLVaultManagerLido, RolesConsumer
State Variables
MINTR
MINTRv1 public MINTR
TRSRY
TRSRYv1 public TRSRY
BLREG
BLREGv1 public BLREG
ohm
address public ohm
pairToken
address public pairToken
aura
address public aura
bal
address public bal
exchangeName
string public exchangeName
balancerData
BalancerData public balancerData
auraData
AuraData public auraData
auraMiningLib
IAuraMiningLib public auraMiningLib
ohmEthPriceFeed
OracleFeed public ohmEthPriceFeed
ethUsdPriceFeed
OracleFeed public ethUsdPriceFeed
stethUsdPriceFeed
OracleFeed public stethUsdPriceFeed
implementation
BLVaultLido public implementation
vaultOwners
mapping(BLVaultLido => address) public vaultOwners
userVaults
mapping(address => BLVaultLido) public userVaults
totalLp
uint256 public totalLp
deployedOhm
uint256 public deployedOhm
circulatingOhmBurned
uint256 public circulatingOhmBurned
ohmLimit
uint256 public ohmLimit
currentFee
uint64 public currentFee
minWithdrawalDelay
uint48 public minWithdrawalDelay
isLidoBLVaultActive
bool public isLidoBLVaultActive
MAX_FEE
uint32 public constant MAX_FEE = 10_000
Functions
constructor
constructor(
Kernel kernel_,
TokenData memory tokenData_,
BalancerData memory balancerData_,
AuraData memory auraData_,
address auraMiningLib_,
OracleFeed memory ohmEthPriceFeed_,
OracleFeed memory ethUsdPriceFeed_,
OracleFeed memory stethUsdPriceFeed_,
address implementation_,
uint256 ohmLimit_,
uint64 fee_,
uint48 minWithdrawalDelay_
) Policy(kernel_);
configureDependencies
Define module dependencies for this policy.
function configureDependencies() external override returns (Keycode[] memory dependencies);
Returns
| Name | Type | Description |
|---|---|---|
dependencies | Keycode[] | - Keycode array of module dependencies. |
requestPermissions
Function called by kernel to set module function permissions.
function requestPermissions() external view override returns (Permissions[] memory permissions);
Returns
| Name | Type | Description |
|---|---|---|
permissions | Permissions[] | requests - Array of keycodes and function selectors for requested permissions. |
onlyWhileActive
modifier onlyWhileActive() ;
onlyVault
modifier onlyVault() ;
deployVault
Deploys a personal single sided vault for the user
The vault is deployed with the user as the owner
function deployVault() external override onlyWhileActive returns (address vault);
Returns
| Name | Type | Description |
|---|---|---|
vault | address | The address of the deployed vault |
mintOhmToVault
Mints OHM to the caller
Can only be called by an approved vault
function mintOhmToVault(uint256 amount_) external override onlyWhileActive onlyVault;
Parameters
| Name | Type | Description |
|---|---|---|
amount_ | uint256 | The amount of OHM to mint |
burnOhmFromVault
Burns OHM from the caller
Can only be called by an approved vault. The caller must have an OHM approval for the MINTR.
function burnOhmFromVault(uint256 amount_) external override onlyWhileActive onlyVault;
Parameters
| Name | Type | Description |
|---|---|---|
amount_ | uint256 | The amount of OHM to burn |
increaseTotalLp
Increases the tracked value for totalLP
Can only be called by an approved vault
function increaseTotalLp(uint256 amount_) external override onlyWhileActive onlyVault;
Parameters
| Name | Type | Description |
|---|---|---|
amount_ | uint256 | The amount of LP tokens to add to the total |
decreaseTotalLp
Decreases the tracked value for totalLP
Can only be called by an approved vault
function decreaseTotalLp(uint256 amount_) external override onlyWhileActive onlyVault;
Parameters
| Name | Type | Description |
|---|---|---|
amount_ | uint256 | The amount of LP tokens to remove from the total |
canWithdraw
Returns whether enough time has passed since the last deposit for the user to be ale to withdraw
function canWithdraw(address user_) external view override returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
user_ | address | The user to check the vault of |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | bool Whether enough time has passed since the last deposit for the user to be ale to withdraw |
getLpBalance
Returns the user's vault's LP balance
function getLpBalance(address user_) external view override returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
user_ | address | The user to check the vault of |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | uint256 The user's vault's LP balance |
getUserPairShare
Returns the user's vault's claim on wstETH
function getUserPairShare(address user_) external view override returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
user_ | address | The user to check the vault of |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | uint256 The user's vault's claim on wstETH |
getOutstandingRewards
Returns the user's vault's unclaimed rewards in Aura
function getOutstandingRewards(address user_) external view override returns (RewardsData[] memory);
Parameters
| Name | Type | Description |
|---|---|---|
user_ | address | The user to check the vault of |
Returns
| Name | Type | Description |
|---|---|---|
<none> | RewardsData[] | RewardsData[] The user's vault's unclaimed rewards in Aura |
getMaxDeposit
Calculates the max wstETH deposit based on the limit and current amount of OHM minted
function getMaxDeposit() external view override returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | uint256 The max wstETH deposit |
getExpectedLpAmount
Calculates the amount of LP tokens that will be generated for a given amount of wstETH
This is an external function but should only be used in a callstatic from an external source like the frontend.
function getExpectedLpAmount(uint256 amount_) external override returns (uint256 bptAmount);
Parameters
| Name | Type | Description |
|---|---|---|
amount_ | uint256 | The amount of wstETH to calculate the LP tokens for |
Returns
| Name | Type | Description |
|---|---|---|
bptAmount | uint256 | uint256 The amount of LP tokens that will be generated |
getExpectedTokensOutProtocol
Calculates the amount of OHM and pair tokens that should be received by the vault for withdrawing a given amount of LP tokens
This is an external function but should only be used in a callstatic from an external source like the frontend.
function getExpectedTokensOutProtocol(uint256 lpAmount_)
external
override
returns (uint256[] memory expectedTokenAmounts);
Parameters
| Name | Type | Description |
|---|---|---|
lpAmount_ | uint256 | The amount of LP tokens to calculate the OHM and pair tokens for |
Returns
| Name | Type | Description |
|---|---|---|
expectedTokenAmounts | uint256[] | The amount of OHM and pair tokens that should be received |
getExpectedPairTokenOutUser
function getExpectedPairTokenOutUser(uint256 lpAmount_) external override returns (uint256 expectedTknAmount);
getRewardTokens
Gets all the reward tokens from the Aura pool
function getRewardTokens() external view override returns (address[] memory);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address[] | address[] The addresses of the reward tokens |
getRewardRate
Gets the reward rate (tokens per second) of the passed reward token
function getRewardRate(address rewardToken_) external view override returns (uint256 rewardRate);
Returns
| Name | Type | Description |
|---|---|---|
rewardRate | uint256 | uint256 The reward rate (tokens per second) |
getPoolOhmShare
Returns the amount of OHM in the pool that is owned by this vault system.
function getPoolOhmShare() public view override returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | uint256 The amount of OHM in the pool that is owned by this vault system. |
getOhmSupplyChangeData
Gets the net OHM emitted or removed by the system since inception
function getOhmSupplyChangeData()
external
view
override
returns (uint256 poolOhmShare, uint256 mintedOhm, uint256 netBurnedOhm);
Returns
| Name | Type | Description |
|---|---|---|
poolOhmShare | uint256 | uint256 Vault system's current claim on OHM from the Balancer pool |
mintedOhm | uint256 | |
netBurnedOhm | uint256 |
getOhmTknPrice
Gets the number of OHM per 1 wstETH using oracle prices
function getOhmTknPrice() public view override returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | uint256 OHM per 1 wstETH (9 decimals) |
getTknOhmPrice
Gets the number of wstETH per 1 OHM using oracle prices
function getTknOhmPrice() public view override returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | uint256 wstETH per 1 OHM (18 decimals) |
getOhmTknPoolPrice
Gets the number of OHM per 1 wstETH using pool prices
function getOhmTknPoolPrice() public view override returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | uint256 OHM per 1 wstETH (9 decimals) |
emergencyBurnOhm
Emergency burns OHM that has been sent to the manager in the event a user had to emergency withdraw
Can only be called by the admin
function emergencyBurnOhm(uint256 amount_) external override onlyRole("liquidityvault_admin");
Parameters
| Name | Type | Description |
|---|---|---|
amount_ | uint256 | The amount of OHM to burn |
setLimit
Updates the limit on minting OHM
Can only be called by the admin. Cannot be set lower than the current outstanding minted OHM.
function setLimit(uint256 newLimit_) external override onlyRole("liquidityvault_admin");
Parameters
| Name | Type | Description |
|---|---|---|
newLimit_ | uint256 | The new OHM limit (9 decimals) |
setFee
Updates the fee on reward tokens
Can only be called by the admin. Cannot be set beyond 10_000 (100%). Only is used by vaults deployed after the update.
function setFee(uint64 newFee_) external override onlyRole("liquidityvault_admin");
Parameters
| Name | Type | Description |
|---|---|---|
newFee_ | uint64 | The new fee (in basis points) |
setWithdrawalDelay
Updates the minimum holding period before a user can withdraw
Can only be called by the admin
function setWithdrawalDelay(uint48 newDelay_) external override onlyRole("liquidityvault_admin");
Parameters
| Name | Type | Description |
|---|---|---|
newDelay_ | uint48 | The new minimum holding period (in seconds) |
changeUpdateThresholds
Updates the time threshold for oracle staleness checks
Can only be called by the admin
function changeUpdateThresholds(
uint48 ohmEthUpdateThreshold_,
uint48 ethUsdUpdateThreshold_,
uint48 stethUsdUpdateThreshold_
) external onlyRole("liquidityvault_admin");
Parameters
| Name | Type | Description |
|---|---|---|
ohmEthUpdateThreshold_ | uint48 | The new time threshold for the OHM-ETH oracle |
ethUsdUpdateThreshold_ | uint48 | The new time threshold for the ETH-USD oracle |
stethUsdUpdateThreshold_ | uint48 | The new time threshold for the stETH-USD oracle |
activate
Activates the vault manager and all approved vaults
Can only be called by the admin
function activate() external override onlyRole("liquidityvault_admin");
deactivate
Deactivates the vault manager and all approved vaults
Can only be called by the admin
function deactivate() external override onlyRole("emergency_admin");
_validatePrice
function _validatePrice(AggregatorV3Interface priceFeed_, uint48 updateThreshold_) internal view returns (uint256);
Events
VaultDeployed
event VaultDeployed(address vault, address owner, uint64 fee);
Errors
BLManagerLido_AlreadyActive
error BLManagerLido_AlreadyActive();
BLManagerLido_AlreadyInactive
error BLManagerLido_AlreadyInactive();
BLManagerLido_Inactive
error BLManagerLido_Inactive();
BLManagerLido_InvalidVault
error BLManagerLido_InvalidVault();
BLManagerLido_LimitViolation
error BLManagerLido_LimitViolation();
BLManagerLido_InvalidLpAmount
error BLManagerLido_InvalidLpAmount();
BLManagerLido_InvalidLimit
error BLManagerLido_InvalidLimit();
BLManagerLido_InvalidFee
error BLManagerLido_InvalidFee();
BLManagerLido_BadPriceFeed
error BLManagerLido_BadPriceFeed();
BLManagerLido_VaultAlreadyExists
error BLManagerLido_VaultAlreadyExists();
BLManagerLido_NoUserVault
error BLManagerLido_NoUserVault();