Skip to main content

BLVaultManagerLido

Git Source

Inherits: Policy, IBLVaultManagerLido, RolesConsumer

Constants​

MAX_FEE​

uint32 public constant MAX_FEE = 10_000;

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​

The minimum length of time between a deposit and a withdrawal

uint48 public minWithdrawalDelay;

Returns

NameTypeDescription
<none>uint48

isLidoBLVaultActive​

bool public isLidoBLVaultActive;

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_);

Parameters

NameTypeDescription
kernel_Kernel
tokenData_TokenData
balancerData_BalancerData
auraData_AuraData
auraMiningLib_address
ohmEthPriceFeed_OracleFeed
ethUsdPriceFeed_OracleFeed
stethUsdPriceFeed_OracleFeed
implementation_address
ohmLimit_uint256
fee_uint64
minWithdrawalDelay_uint48

configureDependencies​

Define module dependencies for this policy.

function configureDependencies() external override returns (Keycode[] memory dependencies);

Returns

NameTypeDescription
dependenciesKeycode[]- 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

NameTypeDescription
permissionsPermissions[]- 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

NameTypeDescription
vaultaddressvault 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

NameTypeDescription
amount_uint256The 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

NameTypeDescription
amount_uint256The 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

NameTypeDescription
amount_uint256The 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

NameTypeDescription
amount_uint256The 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

NameTypeDescription
user_addressThe user to check the vault of

Returns

NameTypeDescription
<none>boolbool 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

NameTypeDescription
user_addressThe user to check the vault of

Returns

NameTypeDescription
<none>uint256uint256 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

NameTypeDescription
user_addressThe user to check the vault of

Returns

NameTypeDescription
<none>uint256uint256 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

NameTypeDescription
user_addressThe user to check the vault of

Returns

NameTypeDescription
<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

NameTypeDescription
<none>uint256uint256 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

NameTypeDescription
amount_uint256The amount of wstETH to calculate the LP tokens for

Returns

NameTypeDescription
bptAmountuint256uint256 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

NameTypeDescription
lpAmount_uint256The amount of LP tokens to calculate the OHM and pair tokens for

Returns

NameTypeDescription
expectedTokenAmountsuint256[]The amount of OHM and pair tokens that should be received

getExpectedPairTokenOutUser​

Calculates the amount of pair tokens that should be received by the user for withdrawing a given amount of LP tokens after the treasury takes any arbs

function getExpectedPairTokenOutUser(
uint256 lpAmount_
) external override returns (uint256 expectedTknAmount);

Parameters

NameTypeDescription
lpAmount_uint256The amount of LP tokens to calculate the pair tokens for

Returns

NameTypeDescription
expectedTknAmountuint256The amount of pair tokens that should be received

getRewardTokens​

Gets all the reward tokens from the Aura pool

function getRewardTokens() external view override returns (address[] memory);

Returns

NameTypeDescription
<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);

Parameters

NameTypeDescription
rewardToken_address

Returns

NameTypeDescription
rewardRateuint256uint256 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

NameTypeDescription
<none>uint256uint256 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

NameTypeDescription
poolOhmShareuint256uint256 Vault system's current claim on OHM from the Balancer pool
mintedOhmuint256uint256 Current amount of OHM minted by the system into the Balancer pool
netBurnedOhmuint256uint256 OHM that wasn't minted, but was previously circulating that has been burned by the system

getOhmTknPrice​

Gets the number of OHM per 1 wstETH using oracle prices

function getOhmTknPrice() public view override returns (uint256);

Returns

NameTypeDescription
<none>uint256uint256 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

NameTypeDescription
<none>uint256uint256 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

NameTypeDescription
<none>uint256uint256 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

NameTypeDescription
amount_uint256The 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

NameTypeDescription
newLimit_uint256The 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

NameTypeDescription
newFee_uint64The 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

NameTypeDescription
newDelay_uint48The 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

NameTypeDescription
ohmEthUpdateThreshold_uint48The new time threshold for the OHM-ETH oracle
ethUsdUpdateThreshold_uint48The new time threshold for the ETH-USD oracle
stethUsdUpdateThreshold_uint48The 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);

Parameters

NameTypeDescription
priceFeed_AggregatorV3Interface
updateThreshold_uint48

Returns

NameTypeDescription
<none>uint256

Events​

VaultDeployed​

event VaultDeployed(address vault, address owner, uint64 fee);

Parameters

NameTypeDescription
vaultaddress
owneraddress
feeuint64

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();