Skip to main content

BLVaultManagerLusd

Git Source

Inherits: Policy, IBLVaultManager, RolesConsumer

Constants​

MAX_FEE​

uint32 public constant MAX_FEE = 10_000;

_ohmIndex​

uint8 private constant _ohmIndex = 1;

_lusdIndex​

uint8 private constant _lusdIndex = 0;

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;

lusdUsdPriceFeed​

OracleFeed public lusdUsdPriceFeed;

implementation​

BLVaultLusd public implementation;

vaultOwners​

mapping(BLVaultLusd => address) public vaultOwners;

userVaults​

mapping(address => BLVaultLusd) 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

isLusdBLVaultActive​

bool public isLusdBLVaultActive;

Functions​

constructor​

constructor(
Kernel kernel_,
TokenData memory tokenData_,
BalancerData memory balancerData_,
AuraData memory auraData_,
address auraMiningLib_,
OracleFeed memory ohmEthPriceFeed_,
OracleFeed memory ethUsdPriceFeed_,
OracleFeed memory lusdUsdPriceFeed_,
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
lusdUsdPriceFeed_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 the pair token

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 the pair token

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 pair token deposit based on the limit and current amount of OHM minted

function getMaxDeposit() external view override returns (uint256);

Returns

NameTypeDescription
<none>uint256uint256 The max pair token deposit

getExpectedLpAmount​

Calculates the amount of LP tokens that will be generated for a given amount of pair tokens

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 pair tokens 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

This is an external function but should only be used in a callstatic from an external source like the frontend.

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 pair token using oracle prices

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

Returns

NameTypeDescription
<none>uint256uint256 OHM per 1 pair token (9 decimals)

getTknOhmPrice​

Gets the number of pair tokens per 1 OHM using oracle prices

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

Returns

NameTypeDescription
<none>uint256uint256 Pair tokens per 1 OHM (18 decimals)

getOhmTknPoolPrice​

Gets the number of OHM per 1 pair token using pool prices

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

Returns

NameTypeDescription
<none>uint256uint256 OHM per 1 pair token (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​

function changeUpdateThresholds(
uint48 ohmEthUpdateThreshold_,
uint48 ethUsdUpdateThreshold_,
uint48 lusdUsdUpdateThreshold_
) external onlyRole("liquidityvault_admin");

Parameters

NameTypeDescription
ohmEthUpdateThreshold_uint48
ethUsdUpdateThreshold_uint48
lusdUsdUpdateThreshold_uint48

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​

BLManagerLusd_AlreadyActive​

error BLManagerLusd_AlreadyActive();

BLManagerLusd_AlreadyInactive​

error BLManagerLusd_AlreadyInactive();

BLManagerLusd_Inactive​

error BLManagerLusd_Inactive();

BLManagerLusd_InvalidVault​

error BLManagerLusd_InvalidVault();

BLManagerLusd_LimitViolation​

error BLManagerLusd_LimitViolation();

BLManagerLusd_InvalidLpAmount​

error BLManagerLusd_InvalidLpAmount();

BLManagerLusd_InvalidLimit​

error BLManagerLusd_InvalidLimit();

BLManagerLusd_InvalidFee​

error BLManagerLusd_InvalidFee();

BLManagerLusd_BadPriceFeed​

error BLManagerLusd_BadPriceFeed();

BLManagerLusd_VaultAlreadyExists​

error BLManagerLusd_VaultAlreadyExists();

BLManagerLusd_NoUserVault​

error BLManagerLusd_NoUserVault();