MultiDepositorVault
Last updated
Last updated
Inherits: IMultiDepositorVault, ERC20, FeeVault
A vault that allows users to deposit and withdraw multiple tokens. This contract just mints and burns unit tokens and all logic and validation is handled by the provisioner
Hooks contract called before unit transfers/mints/burns
IBeforeTransferHook public beforeTransferHook;
Role that can mint/burn vault units
address public provisioner;
Ensures caller is the provisioner
modifier onlyProvisioner();
constructor()
ERC20(IMultiDepositorVaultFactory(msg.sender).getERC20Name(), IMultiDepositorVaultFactory(msg.sender).getERC20Symbol())
FeeVault();
Deposit tokens into the vault and mint units
function enter(address sender, IERC20 token, uint256 tokenAmount, uint256 unitsAmount, address recipient)
external
whenNotPaused
onlyProvisioner;
Parameters
sender
address
The sender of the tokens
token
IERC20
The token to deposit
tokenAmount
uint256
The amount of token to deposit
unitsAmount
uint256
The amount of units to mint
recipient
address
The recipient of the units
Withdraw tokens from the vault and burn units
function exit(address sender, IERC20 token, uint256 tokenAmount, uint256 unitsAmount, address recipient)
external
whenNotPaused
onlyProvisioner;
Parameters
sender
address
The sender of the units
token
IERC20
The token to withdraw
tokenAmount
uint256
The amount of token to withdraw
unitsAmount
uint256
The amount of units to burn
recipient
address
The recipient of the tokens
Sets the provisioner address
function setProvisioner(address provisioner_) external requiresAuth;
Parameters
provisioner_
address
The new provisioner address
Set the before transfer hooks
function setBeforeTransferHook(IBeforeTransferHook hook) external requiresAuth;
Parameters
hook
IBeforeTransferHook
Internal function to update token balances with transfer hook checks
Transfers a value
amount of tokens from from
to to
, or alternatively mints (or burns) if from
(or to
) is the zero address. All customizations to transfers, mints, and burns should be done by overriding this function. Emits a {Transfer} event.
function _update(address from, address to, uint256 amount) internal override;
Parameters
from
address
The address tokens are transferred from
to
address
The address tokens are transferred to
amount
uint256
The amount of tokens to transfer
Set the transfer hook
function _setBeforeTransferHook(IBeforeTransferHook hook_) internal;
Parameters
hook_
IBeforeTransferHook
The transfer hook address
Set the provisioner
function _setProvisioner(address provisioner_) internal;
Parameters
provisioner_
address
The provisioner address