TellerWithMultiAssetSupport
Inherits: Auth, BeforeTransferHook, ReentrancyGuard
State Variables
NATIVE
Native address used to tell the contract to handle native asset deposits.
MAX_SHARE_LOCK_PERIOD
The maximum possible share lock period.
isSupported
Mapping ERC20s to an isSupported bool.
depositNonce
The deposit nonce used to map to a deposit hash.
shareLockPeriod
After deposits, shares are locked to the msg.sender's address for shareLockPeriod
.
During this time all transfers from msg.sender will revert, and deposits are refundable.
isPaused
Used to pause calls to deposit
and depositWithPermit
.
publicDepositHistory
Maps deposit nonce to keccak256(address receiver, address depositAsset, uint256 depositAmount, uint256 shareAmount, uint256 timestamp, uint256 shareLockPeriod).
shareUnlockTime
Maps user address to the time their shares will be unlocked.
vault
The BoringVault this contract is working with.
accountant
The AccountantWithRateProviders this contract is working with.
ONE_SHARE
One share of the BoringVault.
Functions
constructor
pause
Pause this contract, which prevents future calls to deposit
and depositWithPermit
.
Callable by MULTISIG_ROLE.
unpause
Unpause this contract, which allows future calls to deposit
and depositWithPermit
.
Callable by MULTISIG_ROLE.
addAsset
Adds this asset as a deposit asset.
The accountant must also support pricing this asset, else the deposit
call will revert.
Callable by OWNER_ROLE.
removeAsset
Removes this asset as a deposit asset.
Callable by OWNER_ROLE.
setShareLockPeriod
Sets the share lock period.
This not only locks shares to the user address, but also serves as the pending deposit period, where deposits can be reverted.
If a new shorter share lock period is set, users with pending share locks could make a new deposit to receive 1 wei shares, and have their shares unlock sooner than their original deposit allows. This state would allow for the user deposit to be refunded, but only if they have not transferred their shares out of there wallet. This is an accepted limitation, and should be known when decreasing the share lock period.
Callable by OWNER_ROLE.
beforeTransfer
Implement beforeTransfer hook to check if shares are locked.
refundDeposit
Allows DEPOSIT_REFUNDER_ROLE to revert a pending deposit.
Once a deposit share lock period has passed, it can no longer be reverted.
It is possible the admin does not setup the BoringVault to call the transfer hook, but this contract can still be saving share lock state. In the event this happens deposits are still refundable if the user has not transferred their shares. But there is no guarantee that the user has not transferred their shares.
Callable by STRATEGIST_MULTISIG_ROLE.
deposit
Allows users to deposit into the BoringVault, if this contract is not paused.
Publicly callable.
depositWithPermit
Allows users to deposit into BoringVault using permit.
Publicly callable.
bulkDeposit
Allows on ramp role to deposit into this contract.
Does NOT support native deposits.
Callable by SOLVER_ROLE.
bulkWithdraw
Allows off ramp role to withdraw from this contract.
Callable by SOLVER_ROLE.
_erc20Deposit
Implements a common ERC20 deposit into BoringVault.
_afterPublicDeposit
Handle share lock logic, and event.