AeraVaultHooks
AeraVaultHooks
Inherits: IHooks, IAeraVaultHooksEvents, Sweepable, ERC165
Default hooks contract which implements several safeguards.
Connected vault MUST only call submit with tokens that can increase allowances with approve and increaseAllowance.
State Variables
_LOWEST_MIN_DAILY_VALUE
Min bound on minimum fraction of vault value that the vault has to retain between submissions during a single day.
Loose bound to mitigate initialization error.
uint256 private constant _LOWEST_MIN_DAILY_VALUE = ONE / 2;
minDailyValue
The minimum fraction of vault value that the vault has to retain per day during submit transactions. e.g. 0.9 (in 18-decimal form) allows the vault to lose up to 10% in value across consecutive submissions.
uint256 public immutable minDailyValue;
vault
STORAGE ///
The address of the vault.
address public vault;
currentDay
Current day (UTC).
uint256 public currentDay;
cumulativeDailyMultiplier
Accumulated value multiplier during submit transactions.
uint256 public cumulativeDailyMultiplier;
_targetSighashAllowed
Allowed target contract and sighash combinations.
mapping(TargetSighash => bool) internal _targetSighashAllowed;
_beforeValue
Total value of assets in vault before submission.
Assigned in beforeSubmit
and used in afterSubmit
.
uint256 internal _beforeValue;
Functions
onlyVault
MODIFIERS ///
Throws if called by any account other than the vault.
modifier onlyVault();
constructor
FUNCTIONS ///
constructor(
address owner_,
address vault_,
uint256 minDailyValue_,
TargetSighashData[] memory targetSighashAllowlist
) Ownable;
Parameters
owner_
address
Initial owner address.
vault_
address
Vault address.
minDailyValue_
uint256
The minimum fraction of value that the vault has to retain during the day in the course of submissions.
targetSighashAllowlist
TargetSighashData[]
Array of target contract and sighash combinations to allow.
addTargetSighash
Add targetSighash pair to allowlist.
function addTargetSighash(
address target,
bytes4 selector
) external onlyOwner;
Parameters
target
address
Address of target.
selector
bytes4
Selector of function.
removeTargetSighash
Remove targetSighash pair from allowlist.
function removeTargetSighash(
address target,
bytes4 selector
) external onlyOwner;
Parameters
target
address
Address of target.
selector
bytes4
Selector of function.
beforeDeposit
Hook that runs before deposit.
MUST revert if not called by vault.
function beforeDeposit(AssetValue[] memory amounts)
external
override
onlyVault;
Parameters
amounts
AssetValue[]
Struct details for assets and amounts to deposit.
afterDeposit
Hook that runs after deposit.
MUST revert if not called by vault.
function afterDeposit(AssetValue[] memory amounts)
external
override
onlyVault;
Parameters
amounts
AssetValue[]
Struct details for assets and amounts to deposit.
beforeWithdraw
Hook that runs before withdraw.
MUST revert if not called by vault.
function beforeWithdraw(AssetValue[] memory amounts)
external
override
onlyVault;
Parameters
amounts
AssetValue[]
Struct details for assets and amounts to withdraw.
afterWithdraw
Hook that runs after withdraw.
MUST revert if not called by vault.
function afterWithdraw(AssetValue[] memory amounts)
external
override
onlyVault;
Parameters
amounts
AssetValue[]
Struct details for assets and amounts to withdraw.
beforeSubmit
Hook that runs before submit.
MUST revert if not called by vault.
function beforeSubmit(Operation[] calldata operations)
external
override
onlyVault;
Parameters
operations
Operation[]
Array of struct details for target and calldata to submit.
afterSubmit
Hook that runs after submit.
MUST revert if not called by vault.
function afterSubmit(Operation[] calldata operations)
external
override
onlyVault;
Parameters
operations
Operation[]
Array of struct details for target and calldata to submit.
beforeFinalize
Hook that runs before finalize.
MUST revert if not called by vault.
function beforeFinalize() external override onlyVault;
afterFinalize
Hook that runs after finalize.
MUST revert if not called by vault.
function afterFinalize() external override onlyVault;
decommission
Take hooks out of use.
function decommission() external override onlyVault;
supportsInterface
Returns true if this contract implements the interface defined by interfaceId
. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.
function supportsInterface(bytes4 interfaceId)
public
view
override
returns (bool);
targetSighashAllowed
Check whether target and sighash combination is allowed.
function targetSighashAllowed(
address target,
bytes4 selector
) external view returns (bool);
Parameters
target
address
Address of target.
selector
bytes4
Selector of function.
_addTargetSighash
INTERNAL FUNCTIONS ///
Add targetSighash pair to allowlist.
function _addTargetSighash(address target, bytes4 selector) internal;
Parameters
target
address
Address of target.
selector
bytes4
Selector of function.
_isAllowanceSelector
Check whether selector is allowance related selector or not.
function _isAllowanceSelector(bytes4 selector)
internal
pure
returns (bool isAllowanceSelector);
Parameters
selector
bytes4
Selector of calldata to check.
Returns
isAllowanceSelector
bool
True if selector is allowance related selector.
_checkHooksOwner
Check that owner is not the vault or the guardian.
function _checkHooksOwner(address owner_, address vault_) internal view;
Parameters
owner_
address
Hooks owner address.
vault_
address
Vault address.
transferOwnership
Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner.
function transferOwnership(address newOwner) public override onlyOwner;
Errors
Aera__CallerIsNotVault
ERRORS ///
error Aera__CallerIsNotVault();
Aera__VaultIsZeroAddress
error Aera__VaultIsZeroAddress();
Aera__HooksOwnerIsGuardian
error Aera__HooksOwnerIsGuardian();
Aera__HooksOwnerIsVault
error Aera__HooksOwnerIsVault();
Aera__MinDailyValueTooLow
error Aera__MinDailyValueTooLow();
Aera__MinDailyValueIsNotLessThanOne
error Aera__MinDailyValueIsNotLessThanOne();
Aera__NoCodeAtTarget
error Aera__NoCodeAtTarget(address target);
Aera__CallIsNotAllowed
error Aera__CallIsNotAllowed(Operation operation);
Aera__VaultValueBelowMinDailyValue
error Aera__VaultValueBelowMinDailyValue();
Aera__AllowanceIsNotZero
error Aera__AllowanceIsNotZero(address asset, address spender);
Aera__HooksInitialOwnerIsZeroAddress
error Aera__HooksInitialOwnerIsZeroAddress();
Aera__RemovingNonexistentTargetSighash
error Aera__RemovingNonexistentTargetSighash(TargetSighash targetSighash);
Aera__AddingDuplicateTargetSighash
error Aera__AddingDuplicateTargetSighash(TargetSighash targetSighash);
Last updated