Skip to content

Vault Contract 📜

This is the main $bHONEY contract, which includes all $HONEY deposit, withdraws, $BGT rewards, and more.

State Variables

manager

solidity
address public manager;
address public manager;

admin

solidity
address public admin;
address public admin;

pnlHandler

solidity
address public pnlHandler;
address public pnlHandler;

rewardsModule

solidity
IRewardsModule public immutable rewardsModule = IRewardsModule(address(0x55684e2cA2bace0aDc512C1AFF880b15b8eA7214));
IRewardsModule public immutable rewardsModule = IRewardsModule(address(0x55684e2cA2bace0aDc512C1AFF880b15b8eA7214));

distributionModule

solidity
address public immutable distributionModule = address(0x0000000000000000000000000000000000000069);
address public immutable distributionModule = address(0x0000000000000000000000000000000000000069);

PRECISION

solidity
uint256 constant PRECISION = 1e18;
uint256 constant PRECISION = 1e18;

PRECISION_2

solidity
uint256 constant PRECISION_2 = 1e40;
uint256 constant PRECISION_2 = 1e40;

MIN_DAILY_ACC_PNL_DELTA

solidity
uint256 constant MIN_DAILY_ACC_PNL_DELTA = PRECISION / 10;
uint256 constant MIN_DAILY_ACC_PNL_DELTA = PRECISION / 10;

MAX_SUPPLY_INCREASE_DAILY_P

solidity
uint256 constant MAX_SUPPLY_INCREASE_DAILY_P = 50 * PRECISION;
uint256 constant MAX_SUPPLY_INCREASE_DAILY_P = 50 * PRECISION;

MAX_LOSSES_BURN_P

solidity
uint256 constant MAX_LOSSES_BURN_P = 25 * PRECISION;
uint256 constant MAX_LOSSES_BURN_P = 25 * PRECISION;

WITHDRAW_EPOCHS_LOCKS

solidity
uint256[] WITHDRAW_EPOCHS_LOCKS;
uint256[] WITHDRAW_EPOCHS_LOCKS;

maxDailyAccPnlDelta

solidity
uint256 public maxDailyAccPnlDelta;
uint256 public maxDailyAccPnlDelta;

withdrawLockThresholdsP

solidity
uint256[2] public withdrawLockThresholdsP;
uint256[2] public withdrawLockThresholdsP;

maxSupplyIncreaseDailyP

solidity
uint256 public maxSupplyIncreaseDailyP;
uint256 public maxSupplyIncreaseDailyP;

lossesBurnP

solidity
uint256 public lossesBurnP;
uint256 public lossesBurnP;

shareToAssetsPrice

solidity
uint256 public shareToAssetsPrice;
uint256 public shareToAssetsPrice;

accPnlPerTokenUsed

solidity
int256 public accPnlPerTokenUsed;
int256 public accPnlPerTokenUsed;

accPnlPerToken

solidity
int256 public accPnlPerToken;
int256 public accPnlPerToken;

accRewardsPerToken

solidity
uint256 public accRewardsPerToken;
uint256 public accRewardsPerToken;

dailyAccPnlDelta

solidity
int256 public dailyAccPnlDelta;
int256 public dailyAccPnlDelta;

lastDailyAccPnlDeltaReset

solidity
uint256 public lastDailyAccPnlDeltaReset;
uint256 public lastDailyAccPnlDeltaReset;

epochLength

solidity
uint256 public epochLength;
uint256 public epochLength;

currentEpoch

solidity
uint256 public currentEpoch;
uint256 public currentEpoch;

currentEpochStart

solidity
uint256 public currentEpochStart;
uint256 public currentEpochStart;

currentEpochPositiveOpenPnl

solidity
uint256 public currentEpochPositiveOpenPnl;
uint256 public currentEpochPositiveOpenPnl;

currentMaxSupply

solidity
uint256 public currentMaxSupply;
uint256 public currentMaxSupply;

lastMaxSupplyUpdate

solidity
uint256 public lastMaxSupplyUpdate;
uint256 public lastMaxSupplyUpdate;

withdrawRequests

solidity
mapping(address => mapping(uint256 => uint256)) public withdrawRequests;
mapping(address => mapping(uint256 => uint256)) public withdrawRequests;

totalDeposited

solidity
uint256 public totalDeposited;
uint256 public totalDeposited;

totalClosedPnl

solidity
int256 public totalClosedPnl;
int256 public totalClosedPnl;

totalRewards

solidity
uint256 public totalRewards;
uint256 public totalRewards;

totalLiability

solidity
int256 public totalLiability;
int256 public totalLiability;

feesToPolP

solidity
uint256 public feesToPolP;
uint256 public feesToPolP;

globalAvailableBGT

solidity
uint256 private globalAvailableBGT;
uint256 private globalAvailableBGT;

accBGTPerShare

solidity
uint256 private accBGTPerShare;
uint256 private accBGTPerShare;

users

solidity
mapping(address => User) private users;
mapping(address => User) private users;

accBlockWeightedMarketCap

solidity
uint256 public accBlockWeightedMarketCap;
uint256 public accBlockWeightedMarketCap;

accBlockWeightedMarketCapLastStored

solidity
uint256 public accBlockWeightedMarketCapLastStored;
uint256 public accBlockWeightedMarketCapLastStored;

Functions

initialize

solidity
function initialize(
    string memory _name,
    string memory _symbol,
    ContractAddresses memory _contractAddresses,
    uint256 _maxDailyAccPnlDelta,
    uint256 _withdrawLockThresholdsPLow,
    uint256 _withdrawLockThresholdsPHigh,
    uint256 _maxSupplyIncreaseDailyP,
    uint256 _lossesBurnP,
    uint256 _epochLength,
    uint256 _feesToPolP
) external initializer;
function initialize(
    string memory _name,
    string memory _symbol,
    ContractAddresses memory _contractAddresses,
    uint256 _maxDailyAccPnlDelta,
    uint256 _withdrawLockThresholdsPLow,
    uint256 _withdrawLockThresholdsPHigh,
    uint256 _maxSupplyIncreaseDailyP,
    uint256 _lossesBurnP,
    uint256 _epochLength,
    uint256 _feesToPolP
) external initializer;

initializeV2

solidity
function initializeV2() external reinitializer(2);
function initializeV2() external reinitializer(2);

onlyManager

solidity
modifier onlyManager();
modifier onlyManager();

checks

solidity
modifier checks(uint256 assetsOrShares);
modifier checks(uint256 assetsOrShares);

transferOwnership

solidity
function transferOwnership(address newOwner) public override onlyOwner;
function transferOwnership(address newOwner) public override onlyOwner;

updateManager

solidity
function updateManager(address newValue) external onlyOwner;
function updateManager(address newValue) external onlyOwner;

updateAdmin

solidity
function updateAdmin(address newValue) external onlyManager;
function updateAdmin(address newValue) external onlyManager;

updatePnlHandler

solidity
function updatePnlHandler(address newValue) external onlyOwner;
function updatePnlHandler(address newValue) external onlyOwner;

updateMaxDailyAccPnlDelta

solidity
function updateMaxDailyAccPnlDelta(uint256 newValue) external onlyManager;
function updateMaxDailyAccPnlDelta(uint256 newValue) external onlyManager;

updateWithdrawLockThresholdsP

solidity
function updateWithdrawLockThresholdsP(uint256[2] memory newValue) external onlyOwner;
function updateWithdrawLockThresholdsP(uint256[2] memory newValue) external onlyOwner;

updateMaxSupplyIncreaseDailyP

solidity
function updateMaxSupplyIncreaseDailyP(uint256 newValue) external onlyManager;
function updateMaxSupplyIncreaseDailyP(uint256 newValue) external onlyManager;

updateLossesBurnP

solidity
function updateLossesBurnP(uint256 newValue) external onlyManager;
function updateLossesBurnP(uint256 newValue) external onlyManager;

maxAccPnlPerToken

solidity
function maxAccPnlPerToken() public view returns (uint256);
function maxAccPnlPerToken() public view returns (uint256);

currentEpochEnd

solidity
function currentEpochEnd() public view returns (uint256);
function currentEpochEnd() public view returns (uint256);

collateralizationP

solidity
function collateralizationP() public view returns (uint256);
function collateralizationP() public view returns (uint256);

withdrawEpochsTimelock

solidity
function withdrawEpochsTimelock() public view returns (uint256);
function withdrawEpochsTimelock() public view returns (uint256);

totalSharesBeingWithdrawn

solidity
function totalSharesBeingWithdrawn(address owner) public view returns (uint256 shares);
function totalSharesBeingWithdrawn(address owner) public view returns (uint256 shares);

getPendingAccBlockWeightedMarketCap

solidity
function getPendingAccBlockWeightedMarketCap(uint256 currentBlock) public view returns (uint256);
function getPendingAccBlockWeightedMarketCap(uint256 currentBlock) public view returns (uint256);

tryUpdateCurrentMaxSupply

solidity
function tryUpdateCurrentMaxSupply() public;
function tryUpdateCurrentMaxSupply() public;

tryResetDailyAccPnlDelta

solidity
function tryResetDailyAccPnlDelta() public;
function tryResetDailyAccPnlDelta() public;

storeAccBlockWeightedMarketCap

solidity
function storeAccBlockWeightedMarketCap() public;
function storeAccBlockWeightedMarketCap() public;

updateShareToAssetsPrice

solidity
function updateShareToAssetsPrice() private;
function updateShareToAssetsPrice() private;

_assetIERC20

solidity
function _assetIERC20() private view returns (IERC20Upgradeable);
function _assetIERC20() private view returns (IERC20Upgradeable);

transfer

solidity
function transfer(address to, uint256 amount) public override(ERC20Upgradeable, IERC20Upgradeable) returns (bool);
function transfer(address to, uint256 amount) public override(ERC20Upgradeable, IERC20Upgradeable) returns (bool);

transferFrom

solidity
function transferFrom(address from, address to, uint256 amount)
    public
    override(ERC20Upgradeable, IERC20Upgradeable)
    returns (bool);
function transferFrom(address from, address to, uint256 amount)
    public
    override(ERC20Upgradeable, IERC20Upgradeable)
    returns (bool);

decimals

solidity
function decimals() public view override(ERC20Upgradeable, ERC4626Upgradeable) returns (uint8);
function decimals() public view override(ERC20Upgradeable, ERC4626Upgradeable) returns (uint8);

_convertToShares

solidity
function _convertToShares(uint256 assets, MathUpgradeable.Rounding rounding)
    internal
    view
    override
    returns (uint256 shares);
function _convertToShares(uint256 assets, MathUpgradeable.Rounding rounding)
    internal
    view
    override
    returns (uint256 shares);

_convertToAssets

solidity
function _convertToAssets(uint256 shares, MathUpgradeable.Rounding rounding)
    internal
    view
    override
    returns (uint256 assets);
function _convertToAssets(uint256 shares, MathUpgradeable.Rounding rounding)
    internal
    view
    override
    returns (uint256 assets);

maxMint

solidity
function maxMint(address) public view override returns (uint256);
function maxMint(address) public view override returns (uint256);

maxDeposit

solidity
function maxDeposit(address owner) public view override returns (uint256);
function maxDeposit(address owner) public view override returns (uint256);

maxRedeem

solidity
function maxRedeem(address owner) public view override returns (uint256);
function maxRedeem(address owner) public view override returns (uint256);

maxWithdraw

solidity
function maxWithdraw(address owner) public view override returns (uint256);
function maxWithdraw(address owner) public view override returns (uint256);

isDepositEnabled

solidity
function isDepositEnabled() public view returns (bool);
function isDepositEnabled() public view returns (bool);

deposit

solidity
function deposit(uint256 assets, address receiver) public override checks(assets) returns (uint256);
function deposit(uint256 assets, address receiver) public override checks(assets) returns (uint256);

mint

solidity
function mint(uint256 shares, address receiver) public override checks(shares) returns (uint256);
function mint(uint256 shares, address receiver) public override checks(shares) returns (uint256);

withdraw

solidity
function withdraw(uint256 assets, address receiver, address owner) public override checks(assets) returns (uint256);
function withdraw(uint256 assets, address receiver, address owner) public override checks(assets) returns (uint256);

redeem

solidity
function redeem(uint256 shares, address receiver, address owner) public override checks(shares) returns (uint256);
function redeem(uint256 shares, address receiver, address owner) public override checks(shares) returns (uint256);

scaleVariables

solidity
function scaleVariables(uint256 shares, uint256 assets, bool isDeposit) private;
function scaleVariables(uint256 shares, uint256 assets, bool isDeposit) private;

makeWithdrawRequest

solidity
function makeWithdrawRequest(uint256 shares, address owner) external;
function makeWithdrawRequest(uint256 shares, address owner) external;

cancelWithdrawRequest

solidity
function cancelWithdrawRequest(uint256 shares, address owner, uint256 unlockEpoch) external;
function cancelWithdrawRequest(uint256 shares, address owner, uint256 unlockEpoch) external;

pendingBGT

solidity
function pendingBGT(address owner) external view returns (uint256);
function pendingBGT(address owner) external view returns (uint256);

claimBGT

solidity
function claimBGT(uint256 amount, address recipient) external;
function claimBGT(uint256 amount, address recipient) external;

distributeReward

solidity
function distributeReward(uint256 assets) external;
function distributeReward(uint256 assets) external;

sendAssets

solidity
function sendAssets(uint256 assets, address receiver) external;
function sendAssets(uint256 assets, address receiver) external;

receiveAssets

solidity
function receiveAssets(uint256 assets, address user) external;
function receiveAssets(uint256 assets, address user) external;

newEpochRequest

solidity
function newEpochRequest() private;
function newEpochRequest() private;

forceNewEpoch

solidity
function forceNewEpoch() external;
function forceNewEpoch() external;

startNewEpoch

solidity
function startNewEpoch() private;
function startNewEpoch() private;

tvl

solidity
function tvl() public view returns (uint256);
function tvl() public view returns (uint256);

availableAssets

solidity
function availableAssets() public view returns (uint256);
function availableAssets() public view returns (uint256);

marketCap

solidity
function marketCap() public view returns (uint256);
function marketCap() public view returns (uint256);

balanceOfAssets

solidity
function balanceOfAssets(address owner) public view returns (uint256);
function balanceOfAssets(address owner) public view returns (uint256);

updateGlobalBGT

solidity
function updateGlobalBGT() private;
function updateGlobalBGT() private;

updateUserBGT

solidity
function updateUserBGT(address receiver, uint256 sharesDelta, bool isMint) private;
function updateUserBGT(address receiver, uint256 sharesDelta, bool isMint) private;

getAvailableBGT

solidity
function getAvailableBGT() private view returns (uint256 availableBGT, uint256 newAvailableBGT);
function getAvailableBGT() private view returns (uint256 availableBGT, uint256 newAvailableBGT);

Events

AddressParamUpdated

solidity
event AddressParamUpdated(string name, address newValue);
event AddressParamUpdated(string name, address newValue);

NumberParamUpdated

solidity
event NumberParamUpdated(string name, uint256 newValue);
event NumberParamUpdated(string name, uint256 newValue);

WithdrawLockThresholdsPUpdated

solidity
event WithdrawLockThresholdsPUpdated(uint256[2] newValue);
event WithdrawLockThresholdsPUpdated(uint256[2] newValue);

CurrentMaxSupplyUpdated

solidity
event CurrentMaxSupplyUpdated(uint256 newValue);
event CurrentMaxSupplyUpdated(uint256 newValue);

DailyAccPnlDeltaReset

solidity
event DailyAccPnlDeltaReset();
event DailyAccPnlDeltaReset();

ShareToAssetsPriceUpdated

solidity
event ShareToAssetsPriceUpdated(uint256 newValue);
event ShareToAssetsPriceUpdated(uint256 newValue);

OpenTradesPnlFeedCallFailed

solidity
event OpenTradesPnlFeedCallFailed();
event OpenTradesPnlFeedCallFailed();

NewEpoch

solidity
event NewEpoch(uint256 indexed newEpoch, uint256 newEpochPositiveOpenPnl);
event NewEpoch(uint256 indexed newEpoch, uint256 newEpochPositiveOpenPnl);

NewEpochForced

solidity
event NewEpochForced(uint256 indexed newEpoch);
event NewEpochForced(uint256 indexed newEpoch);

WithdrawRequested

solidity
event WithdrawRequested(
    address indexed sender, address indexed owner, uint256 shares, uint256 currEpoch, uint256 indexed unlockEpoch
);
event WithdrawRequested(
    address indexed sender, address indexed owner, uint256 shares, uint256 currEpoch, uint256 indexed unlockEpoch
);

WithdrawCanceled

solidity
event WithdrawCanceled(
    address indexed sender, address indexed owner, uint256 shares, uint256 currEpoch, uint256 indexed unlockEpoch
);
event WithdrawCanceled(
    address indexed sender, address indexed owner, uint256 shares, uint256 currEpoch, uint256 indexed unlockEpoch
);

FeesDistributed

solidity
event FeesDistributed(uint256 assetsToHoney, uint256 assetsToBGT, uint256 assetsTotal, uint256 vaultTVL);
event FeesDistributed(uint256 assetsToHoney, uint256 assetsToBGT, uint256 assetsTotal, uint256 vaultTVL);

AssetsSent

solidity
event AssetsSent(address indexed sender, address indexed receiver, uint256 assets);
event AssetsSent(address indexed sender, address indexed receiver, uint256 assets);

AssetsReceived

solidity
event AssetsReceived(address indexed sender, address indexed user, uint256 assets, uint256 assetsLessDeplete);
event AssetsReceived(address indexed sender, address indexed user, uint256 assets, uint256 assetsLessDeplete);

AccPnlPerTokenUsedUpdated

solidity
event AccPnlPerTokenUsedUpdated(
    uint256 indexed newEpoch, uint256 newEpochPositiveOpenPnl, int256 newAccPnlPerTokenUsed
);
event AccPnlPerTokenUsedUpdated(
    uint256 indexed newEpoch, uint256 newEpochPositiveOpenPnl, int256 newAccPnlPerTokenUsed
);

AccBlockWeightedMarketCapStored

solidity
event AccBlockWeightedMarketCapStored(uint256 newAccValue);
event AccBlockWeightedMarketCapStored(uint256 newAccValue);

Structs

ContractAddresses

solidity
struct ContractAddresses {
    address asset;
    address owner;
    address manager;
    address admin;
    address pnlHandler;
}
struct ContractAddresses {
    address asset;
    address owner;
    address manager;
    address admin;
    address pnlHandler;
}