Skip to main content

Vault

Git Source

Methods

DEFAULT_ADMIN_ROLE

function DEFAULT_ADMIN_ROLE() external view returns (bytes32)

Returns

NameTypeDescription
bytes32

DELEGATOR_FACTORY

function DELEGATOR_FACTORY() external view returns (address)

Get the delegator factory's address.

Returns

NameTypeDescription
addressaddress of the delegator factory

DEPOSITOR_WHITELIST_ROLE

function DEPOSITOR_WHITELIST_ROLE() external view returns (bytes32)

Get a depositor whitelist status setter's role.

Returns

NameTypeDescription
bytes32identifier of the depositor whitelist status setter role

DEPOSIT_LIMIT_SET_ROLE

function DEPOSIT_LIMIT_SET_ROLE() external view returns (bytes32)

Get a deposit limit setter's role.

Returns

NameTypeDescription
bytes32identifier of the deposit limit enabler/disabler role

DEPOSIT_WHITELIST_SET_ROLE

function DEPOSIT_WHITELIST_SET_ROLE() external view returns (bytes32)

Get a deposit whitelist enabler/disabler's role.

Returns

NameTypeDescription
bytes32identifier of the whitelist enabler/disabler role

FACTORY

function FACTORY() external view returns (address)

Get the factory's address.

Returns

NameTypeDescription
addressaddress of the factory

IS_DEPOSIT_LIMIT_SET_ROLE

function IS_DEPOSIT_LIMIT_SET_ROLE() external view returns (bytes32)

Get a deposit limit enabler/disabler's role.

Returns

NameTypeDescription
bytes32identifier of the deposit limit enabler/disabler role

SLASHER_FACTORY

function SLASHER_FACTORY() external view returns (address)

Get the slasher factory's address.

Returns

NameTypeDescription
addressaddress of the slasher factory

activeBalanceOf

function activeBalanceOf(address account) external view returns (uint256)

Get an active balance for a particular account.

Parameters

NameTypeDescription
accountaddressaccount to get the active balance for

Returns

NameTypeDescription
uint256active balance for the account

activeBalanceOfAt

function activeBalanceOfAt(address account, uint48 timestamp, bytes hints) external view returns (uint256)

Get an active balance for a particular account at a given timestamp using hints.

Parameters

NameTypeDescription
accountaddressaccount to get the active balance for
timestampuint48time point to get the active balance for the account at
hintsbyteshints for checkpoints' indexes

Returns

NameTypeDescription
uint256active balance for the account at the timestamp

activeShares

function activeShares() external view returns (uint256)

Get a total number of active shares in the vault.

Returns

NameTypeDescription
uint256total number of active shares

activeSharesAt

function activeSharesAt(uint48 timestamp, bytes hint) external view returns (uint256)

Get a total number of active shares in the vault at a given timestamp using a hint.

Parameters

NameTypeDescription
timestampuint48time point to get the total number of active shares at
hintbyteshint for the checkpoint index

Returns

NameTypeDescription
uint256total number of active shares at the timestamp

activeSharesOf

function activeSharesOf(address account) external view returns (uint256)

Get a number of active shares for a particular account.

Parameters

NameTypeDescription
accountaddressaccount to get the number of active shares for

Returns

NameTypeDescription
uint256number of active shares for the account

activeSharesOfAt

function activeSharesOfAt(address account, uint48 timestamp, bytes hint) external view returns (uint256)

Get a total number of active shares for a particular account at a given timestamp using a hint.

Parameters

NameTypeDescription
accountaddressaccount to get the number of active shares for
timestampuint48time point to get the number of active shares for the account at
hintbyteshint for the checkpoint index

Returns

NameTypeDescription
uint256number of active shares for the account at the timestamp

activeStake

function activeStake() external view returns (uint256)

Get a total amount of active stake in the vault.

Returns

NameTypeDescription
uint256total amount of active stake

activeStakeAt

function activeStakeAt(uint48 timestamp, bytes hint) external view returns (uint256)

Get a total amount of active stake in the vault at a given timestamp using a hint.

Parameters

NameTypeDescription
timestampuint48time point to get the total active stake at
hintbyteshint for the checkpoint index

Returns

NameTypeDescription
uint256total amount of active stake at the timestamp

burner

function burner() external view returns (address)

Get a burner to issue debt to (e.g., 0xdEaD or some unwrapper contract).

Returns

NameTypeDescription
addressaddress of the burner

claim

function claim(address recipient, uint256 epoch) external nonpayable returns (uint256 amount)

Claim collateral from the vault.

Parameters

NameTypeDescription
recipientaddressaccount that receives the collateral
epochuint256epoch to claim the collateral for

Returns

NameTypeDescription
amountuint256amount of the collateral claimed

claimBatch

function claimBatch(address recipient, uint256[] epochs) external nonpayable returns (uint256 amount)

Claim collateral from the vault for multiple epochs.

Parameters

NameTypeDescription
recipientaddressaccount that receives the collateral
epochsuint256[]epochs to claim the collateral for

Returns

NameTypeDescription
amountuint256amount of the collateral claimed

collateral

function collateral() external view returns (address)

Get a vault collateral.

Returns

NameTypeDescription
addressaddress of the underlying collateral

currentEpoch

function currentEpoch() external view returns (uint256)

Get a current vault epoch.

Returns

NameTypeDescription
uint256current epoch

currentEpochStart

function currentEpochStart() external view returns (uint48)

Get a start of the current vault epoch.

Returns

NameTypeDescription
uint48start of the current epoch

delegator

function delegator() external view returns (address)

Get a delegator (it delegates the vault's stake to networks and operators).

Returns

NameTypeDescription
addressaddress of the delegator

deposit

function deposit(address onBehalfOf, uint256 amount) external nonpayable returns (uint256 depositedAmount, uint256 mintedShares)

Deposit collateral into the vault.

Parameters

NameTypeDescription
onBehalfOfaddressaccount the deposit is made on behalf of
amountuint256amount of the collateral to deposit

Returns

NameTypeDescription
depositedAmountuint256amount of the collateral deposited
mintedSharesuint256amount of the active shares minted

depositLimit

function depositLimit() external view returns (uint256)

Get a deposit limit (maximum amount of the collateral that can be in the vault simultaneously).

Returns

NameTypeDescription
uint256deposit limit

depositWhitelist

function depositWhitelist() external view returns (bool)

Get if the deposit whitelist is enabled.

Returns

NameTypeDescription
boolif the deposit whitelist is enabled

epochAt

function epochAt(uint48 timestamp) external view returns (uint256)

Get an epoch at a given timestamp.

Reverts if the timestamp is less than the start of the epoch 0.

Parameters

NameTypeDescription
timestampuint48time point to get the epoch at

Returns

NameTypeDescription
uint256epoch at the timestamp

epochDuration

function epochDuration() external view returns (uint48)

Get a duration of the vault epoch.

Returns

NameTypeDescription
uint48duration of the epoch

epochDurationInit

function epochDurationInit() external view returns (uint48)

Get a time point of the epoch duration set.

Returns

NameTypeDescription
uint48time point of the epoch duration set

getRoleAdmin

function getRoleAdmin(bytes32 role) external view returns (bytes32)

Returns the admin role that controls role. See grantRole and revokeRole. To change a role's admin, use _setRoleAdmin.

Parameters

NameTypeDescription
rolebytes32

Returns

NameTypeDescription
bytes32

grantRole

function grantRole(bytes32 role, address account) external nonpayable

Grants role to account. If account had not been already granted role, emits a RoleGranted event. Requirements: - the caller must have role's admin role. May emit a RoleGranted event.

Parameters

NameTypeDescription
rolebytes32
accountaddress

hasRole

function hasRole(bytes32 role, address account) external view returns (bool)

Returns true if account has been granted role.

Parameters

NameTypeDescription
rolebytes32
accountaddress

Returns

NameTypeDescription
bool

isDelegatorInitialized

function isDelegatorInitialized() external view returns (bool)

Get if the delegator is initialized.

Returns

NameTypeDescription
boolif the delegator is initialized

isDepositLimit

function isDepositLimit() external view returns (bool)

Get if the deposit limit is set.

Returns

NameTypeDescription
boolif the deposit limit is set

isDepositorWhitelisted

function isDepositorWhitelisted(address account) external view returns (bool value)

Get if a given account is whitelisted as a depositor.

Parameters

NameTypeDescription
accountaddressaddress to check

Returns

NameTypeDescription
boolif the account is whitelisted as a depositor

isInitialized

function isInitialized() external view returns (bool)

Check if the vault is fully initialized (a delegator and a slasher are set).

Returns

NameTypeDescription
boolif the vault is fully initialized

isSlasherInitialized

function isSlasherInitialized() external view returns (bool)

Get if the slasher is initialized.

Returns

NameTypeDescription
boolif the slasher is initialized

isWithdrawalsClaimed

function isWithdrawalsClaimed(uint256 epoch, address account) external view returns (bool value)

Get if the withdrawals are claimed for a particular account at a given epoch.

Parameters

NameTypeDescription
epochuint256epoch to check the withdrawals for the account at
accountaddressaccount to check the withdrawals for

Returns

NameTypeDescription
boolif the withdrawals are claimed for the account at the epoch

migrate

function migrate(uint64 newVersion, bytes data) external nonpayable

Migrate this entity to a particular newer version using a given data.

Parameters

NameTypeDescription
newVersionuint64new version of the entity
databytessome data to use

nextEpochStart

function nextEpochStart() external view returns (uint48)

Get a start of the next vault epoch.

Returns

NameTypeDescription
uint48start of the next epoch

onSlash

function onSlash(uint256 slashedAmount, uint48 captureTimestamp) external nonpayable

Slash callback for burning collateral.

Only the slasher can call this function.

Parameters

NameTypeDescription
slashedAmountuint256amount to slash
captureTimestampuint48time point when the stake was captured

owner

function owner() external view returns (address)

Returns the address of the current owner.

Returns

NameTypeDescription
address

previousEpochStart

function previousEpochStart() external view returns (uint48)

Get a start of the previous vault epoch.

Reverts if the current epoch is 0.

Returns

NameTypeDescription
uint48start of the previous epoch

redeem

function redeem(address claimer, uint256 shares) external nonpayable returns (uint256 withdrawnAssets, uint256 mintedShares)

Redeem collateral from the vault (it will be claimable after the next epoch).

Parameters

NameTypeDescription
claimeraddressaccount that needs to claim the withdrawal
sharesuint256amount of the active shares to redeem

Returns

NameTypeDescription
withdrawnAssetsuint256amount of the collateral withdrawn
mintedSharesuint256amount of the epoch withdrawal shares minted

renounceOwnership

function renounceOwnership() external nonpayable

Leaves the contract without owner. It will not be possible to call onlyOwner functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.

renounceRole

function renounceRole(bytes32 role, address callerConfirmation) external nonpayable

Revokes role from the calling account. Roles are often managed via grantRole and revokeRole: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked role, emits a RoleRevoked event. Requirements: - the caller must be callerConfirmation. May emit a RoleRevoked event.

Parameters

NameTypeDescription
rolebytes32
callerConfirmationaddress

revokeRole

function revokeRole(bytes32 role, address account) external nonpayable

Revokes role from account. If account had been granted role, emits a RoleRevoked event. Requirements: - the caller must have role's admin role. May emit a RoleRevoked event.

Parameters

NameTypeDescription
rolebytes32
accountaddress

setDelegator

function setDelegator(address delegator) external nonpayable

Parameters

NameTypeDescription
delegatoraddressvault's delegator to delegate the stake to networks and operators

setDepositLimit

function setDepositLimit(uint256 limit) external nonpayable

Set a deposit limit.

Only a DEPOSIT_LIMIT_SET_ROLE holder can call this function.

Parameters

NameTypeDescription
limituint256deposit limit (maximum amount of the collateral that can be in the vault simultaneously)

setDepositWhitelist

function setDepositWhitelist(bool status) external nonpayable

Enable/disable deposit whitelist.

Only a DEPOSIT_WHITELIST_SET_ROLE holder can call this function.

Parameters

NameTypeDescription
statusboolif enabling deposit whitelist

setDepositorWhitelistStatus

function setDepositorWhitelistStatus(address account, bool status) external nonpayable

Set a depositor whitelist status.

Only a DEPOSITOR_WHITELIST_ROLE holder can call this function.

Parameters

NameTypeDescription
accountaddressaccount for which the whitelist status is set
statusboolif whitelisting the account

setIsDepositLimit

function setIsDepositLimit(bool status) external nonpayable

Enable/disable deposit limit.

Only a IS_DEPOSIT_LIMIT_SET_ROLE holder can call this function.

Parameters

NameTypeDescription
statusboolif enabling deposit limit

setSlasher

function setSlasher(address slasher) external nonpayable

Parameters

NameTypeDescription
slasheraddressvault's slasher to provide a slashing mechanism to networks

slashableBalanceOf

function slashableBalanceOf(address account) external view returns (uint256)

Get a total amount of the collateral that can be slashed for a given account.

Parameters

NameTypeDescription
accountaddressaccount to get the slashable balance for

Returns

NameTypeDescription
uint256total amount of the slashable collateral

slasher

function slasher() external view returns (address)

Get a slasher (it provides networks a slashing mechanism).

Returns

NameTypeDescription
addressaddress of the slasher

staticDelegateCall

function staticDelegateCall(address target, bytes data) external nonpayable

Make a delegatecall from this contract to a given target contract with a particular data (always reverts with a return data).

It allows to use this contract's storage on-chain.

Parameters

NameTypeDescription
targetaddressaddress of the contract to make a delegatecall to
databytesdata to make a delegatecall with

supportsInterface

function supportsInterface(bytes4 interfaceId) external view returns (bool)

See IERC165-supportsInterface.

Parameters

NameTypeDescription
interfaceIdbytes4

Returns

NameTypeDescription
bool

totalStake

function totalStake() external view returns (uint256)

Get a total amount of the collateral that can be slashed.

Returns

NameTypeDescription
uint256total amount of the slashable collateral

transferOwnership

function transferOwnership(address newOwner) external nonpayable

Transfers ownership of the contract to a new account (newOwner). Can only be called by the current owner.

Parameters

NameTypeDescription
newOwneraddress

version

function version() external view returns (uint64)

Get the entity's version.

Starts from 1.

Returns

NameTypeDescription
uint64version of the entity

withdraw

function withdraw(address claimer, uint256 amount) external nonpayable returns (uint256 burnedShares, uint256 mintedShares)

Withdraw collateral from the vault (it will be claimable after the next epoch).

Parameters

NameTypeDescription
claimeraddressaccount that needs to claim the withdrawal
amountuint256amount of the collateral to withdraw

Returns

NameTypeDescription
burnedSharesuint256amount of the active shares burned
mintedSharesuint256amount of the epoch withdrawal shares minted

withdrawalShares

function withdrawalShares(uint256 epoch) external view returns (uint256 amount)

Get a total number of withdrawal shares at a given epoch.

Parameters

NameTypeDescription
epochuint256epoch to get the total number of withdrawal shares at

Returns

NameTypeDescription
uint256total number of withdrawal shares at the epoch

withdrawalSharesOf

function withdrawalSharesOf(uint256 epoch, address account) external view returns (uint256 amount)

Get a number of withdrawal shares for a particular account at a given epoch (zero if claimed).

Parameters

NameTypeDescription
epochuint256epoch to get the number of withdrawal shares for the account at
accountaddressaccount to get the number of withdrawal shares for

Returns

NameTypeDescription
uint256number of withdrawal shares for the account at the epoch

withdrawals

function withdrawals(uint256 epoch) external view returns (uint256 amount)

Get a total amount of the withdrawals at a given epoch.

Parameters

NameTypeDescription
epochuint256epoch to get the total amount of the withdrawals at

Returns

NameTypeDescription
uint256total amount of the withdrawals at the epoch

withdrawalsOf

function withdrawalsOf(uint256 epoch, address account) external view returns (uint256)

Get withdrawals for a particular account at a given epoch (zero if claimed).

Parameters

NameTypeDescription
epochuint256epoch to get the withdrawals for the account at
accountaddressaccount to get the withdrawals for

Returns

NameTypeDescription
uint256withdrawals for the account at the epoch

Events

Claim

event Claim(address indexed claimer, address indexed recipient, uint256 epoch, uint256 amount)

Emitted when a claim is made.

Parameters

NameTypeDescription
claimer indexedaddressaccount that claimed
recipient indexedaddressaccount that received the collateral
epochuint256epoch the collateral was claimed for
amountuint256amount of the collateral claimed

ClaimBatch

event ClaimBatch(address indexed claimer, address indexed recipient, uint256[] epochs, uint256 amount)

Emitted when a batch claim is made.

Parameters

NameTypeDescription
claimer indexedaddressaccount that claimed
recipient indexedaddressaccount that received the collateral
epochsuint256[]epochs the collateral was claimed for
amountuint256amount of the collateral claimed

Deposit

event Deposit(address indexed depositor, address indexed onBehalfOf, uint256 amount, uint256 shares)

Emitted when a deposit is made.

Parameters

NameTypeDescription
depositor indexedaddressaccount that made the deposit
onBehalfOf indexedaddressaccount the deposit was made on behalf of
amountuint256amount of the collateral deposited
sharesuint256amount of the active shares minted

Initialized

event Initialized(uint64 version)

Triggered when the contract has been initialized or reinitialized.

Parameters

NameTypeDescription
versionuint64

OnSlash

event OnSlash(address indexed slasher, uint256 slashedAmount)

Emitted when a slash happened.

Parameters

NameTypeDescription
slasher indexedaddressaddress of the slasher
slashedAmountuint256amount of the collateral slashed

OwnershipTransferred

event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)

Parameters

NameTypeDescription
previousOwner indexedaddress
newOwner indexedaddress

Redeem

event Redeem(address indexed redeemer, address indexed claimer, uint256 shares, uint256 withdrawnAssets, uint256 mintedShares)

Emitted when a redemption is made.

Parameters

NameTypeDescription
redeemer indexedaddressaccount that redeemed
claimer indexedaddressaccount that needs to claim the withdrawal
sharesuint256amount of the active shares burned
withdrawnAssetsuint256amount of the collateral withdrawn
mintedSharesuint256amount of the epoch withdrawal shares minted

RoleAdminChanged

event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole)

Emitted when newAdminRole is set as role's admin role, replacing previousAdminRole DEFAULT_ADMIN_ROLE is the starting admin for all roles, despite RoleAdminChanged not being emitted signaling this.

Parameters

NameTypeDescription
role indexedbytes32
previousAdminRole indexedbytes32
newAdminRole indexedbytes32

RoleGranted

event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender)

Emitted when account is granted role. sender is the account that originated the contract call, an admin role bearer except when using AccessControl-\_setupRole.

Parameters

NameTypeDescription
role indexedbytes32
account indexedaddress
sender indexedaddress

RoleRevoked

event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender)

Emitted when account is revoked role. sender is the account that originated the contract call: - if using revokeRole, it is the admin role bearer - if using renounceRole, it is the role bearer (i.e. account)

Parameters

NameTypeDescription
role indexedbytes32
account indexedaddress
sender indexedaddress

SetDelegator

event SetDelegator(address indexed delegator)

Emitted when a delegator is set.

Can be set only once.

Parameters

NameTypeDescription
delegator indexedaddressvault's delegator to delegate the stake to networks and operators

SetDepositLimit

event SetDepositLimit(uint256 limit)

Emitted when a deposit limit is set.

Parameters

NameTypeDescription
limituint256deposit limit (maximum amount of the collateral that can be in the vault simultaneously)

SetDepositWhitelist

event SetDepositWhitelist(bool status)

Emitted when a deposit whitelist status is enabled/disabled.

Parameters

NameTypeDescription
statusboolif enabled deposit whitelist

SetDepositorWhitelistStatus

event SetDepositorWhitelistStatus(address indexed account, bool status)

Emitted when a depositor whitelist status is set.

Parameters

NameTypeDescription
account indexedaddressaccount for which the whitelist status is set
statusboolif whitelisted the account

SetIsDepositLimit

event SetIsDepositLimit(bool status)

Emitted when a deposit limit status is enabled/disabled.

Parameters

NameTypeDescription
statusboolif enabled deposit limit

SetSlasher

event SetSlasher(address indexed slasher)

Emitted when a slasher is set.

Can be set only once.

Parameters

NameTypeDescription
slasher indexedaddressvault's slasher to provide a slashing mechanism to networks

Withdraw

event Withdraw(address indexed withdrawer, address indexed claimer, uint256 amount, uint256 burnedShares, uint256 mintedShares)

Emitted when a withdrawal is made.

Parameters

NameTypeDescription
withdrawer indexedaddressaccount that made the withdrawal
claimer indexedaddressaccount that needs to claim the withdrawal
amountuint256amount of the collateral withdrawn
burnedSharesuint256amount of the active shares burned
mintedSharesuint256amount of the epoch withdrawal shares minted

Structs

InitParams

struct InitParams {
address collateral;
address burner;
uint48 epochDuration;
bool depositWhitelist;
bool isDepositLimit;
uint256 depositLimit;
address defaultAdminRoleHolder;
address depositWhitelistSetRoleHolder;
address depositorWhitelistRoleHolder;
address isDepositLimitSetRoleHolder;
address depositLimitSetRoleHolder;
}

Initial parameters needed for a vault deployment.

Parameters

NameTypeDescription
collateraladdressvault's underlying collateral
burneraddressvault's burner to issue debt to (e.g., 0xdEaD or some unwrapper contract)
epochDurationuint48duration of the vault epoch (it determines sync points for withdrawals)
depositWhitelistboolif enabling deposit whitelist
isDepositLimitboolif enabling deposit limit
depositLimituint256deposit limit (maximum amount of the collateral that can be in the vault simultaneously)
defaultAdminRoleHolderaddressaddress of the initial DEFAULT_ADMIN_ROLE holder
depositWhitelistSetRoleHolderaddressaddress of the initial DEPOSIT_WHITELIST_SET_ROLE holder
depositorWhitelistRoleHolderaddressaddress of the initial DEPOSITOR_WHITELIST_ROLE holder
isDepositLimitSetRoleHolderaddressaddress of the initial IS_DEPOSIT_LIMIT_SET_ROLE holder
depositLimitSetRoleHolderaddressaddress of the initial DEPOSIT_LIMIT_SET_ROLE holder

ActiveBalanceOfHints

struct ActiveBalanceOfHints {
bytes activeSharesOfHint;
bytes activeStakeHint;
bytes activeSharesHint;
}

Hints for an active balance.

Parameters

NameTypeDescription
activeSharesOfHintbyteshint for the active shares of checkpoint
activeStakeHintbyteshint for the active stake checkpoint
activeSharesHintbyteshint for the active shares checkpoint