Comment on page
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.
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;
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;
STORAGE ///
The address of the vault.
address public vault;
Current day (UTC).
uint256 public currentDay;
Accumulated value multiplier during submit transactions.
uint256 public cumulativeDailyMultiplier;
Allowed target contract and sighash combinations.
mapping(TargetSighash => bool) internal _targetSighashAllowed;
Total value of assets in vault before submission.
Assigned in
beforeSubmit
and used in afterSubmit
.uint256 internal _beforeValue;
MODIFIERS ///
Throws if called by any account other than the vault.
modifier onlyVault();
FUNCTIONS ///
constructor(
address owner_,
address vault_,
uint256 minDailyValue_,
TargetSighashData[] memory targetSighashAllowlist
) Ownable;
Parameters
Name | Type | Description |
---|---|---|
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. |
Add targetSighash pair to allowlist.
function addTargetSighash(
address target,
bytes4 selector
) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
target | address | Address of target. |
selector | bytes4 | Selector of function. |
Remove targetSighash pair from allowlist.
function removeTargetSighash(
address target,
bytes4 selector
) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
target | address | Address of target. |
selector | bytes4 | Selector of function. |
Hook that runs before deposit.
MUST revert if not called by vault.
function beforeDeposit(AssetValue[] memory amounts)
external
override
onlyVault;
Parameters
Name | Type | Description |
---|---|---|
amounts | AssetValue[] | Struct details for assets and amounts to deposit. |
Hook that runs after deposit.
MUST revert if not called by vault.
function afterDeposit(AssetValue[] memory amounts)
external
override
onlyVault;
Parameters
Name | Type | Description |
---|---|---|
amounts | AssetValue[] | Struct details for assets and amounts to deposit. |
Hook that runs before withdraw.
MUST revert if not called by vault.
function beforeWithdraw(AssetValue[] memory amounts)
external
override
onlyVault;
Parameters
Name | Type | Description |
---|---|---|
amounts | AssetValue[] | Struct details for assets and amounts to withdraw. |
Hook that runs after withdraw.
MUST revert if not called by vault.
function afterWithdraw(AssetValue[] memory amounts)
external
override
onlyVault;
Parameters
Name | Type | Description |
---|---|---|
amounts | AssetValue[] | Struct details for assets and amounts to withdraw. |
Hook that runs before submit.
MUST revert if not called by vault.
function beforeSubmit(Operation[] calldata operations)
external
override
onlyVault;
Parameters
Name | Type | Description |
---|---|---|
operations | Operation[] | Array of struct details for target and calldata to submit. |
Hook that runs after submit.
MUST revert if not called by vault.
function afterSubmit(Operation[] calldata operations)
external
override
onlyVault;
Parameters
Name | Type | Description |
---|---|---|
operations | Operation[] | Array of struct details for target and calldata to submit. |
Hook that runs before finalize.
MUST revert if not called by vault.
function beforeFinalize() external override onlyVault;
Hook that runs after finalize.
MUST revert if not called by vault.
function afterFinalize() external override onlyVault;
Take hooks out of use.
function decommission() external override onlyVault;
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);
Check whether target and sighash combination is allowed.
function targetSighashAllowed(
address target,
bytes4 selector
) external view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
target | address | Address of target. |
selector | bytes4 | Selector of function. |
INTERNAL FUNCTIONS ///
Add targetSighash pair to allowlist.
function _addTargetSighash(address target, bytes4 selector) internal;
Parameters
Name | Type | Description |
---|---|---|
target | address | Address of target. |
selector | bytes4 | Selector of function. |
Check whether selector is allowance related selector or not.
function _isAllowanceSelector(bytes4 selector)
internal
pure
returns (bool isAllowanceSelector);
Parameters
Name | Type | Description |
---|---|---|
selector | bytes4 | Selector of calldata to check. |
Returns
Name | Type | Description |
---|---|---|
isAllowanceSelector | bool | True if selector is allowance related selector. |
Check that owner is not the vault or the guardian.
function _checkHooksOwner(address owner_, address vault_) internal view;
Parameters
Name | Type | Description |
---|---|---|
owner_ | address | Hooks owner address. |
vault_ | address | Vault address. |
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 ///
error Aera__CallerIsNotVault();
error Aera__VaultIsZeroAddress();
error Aera__HooksOwnerIsGuardian();
error Aera__HooksOwnerIsVault();
error Aera__MinDailyValueTooLow();
error Aera__MinDailyValueIsNotLessThanOne();
error Aera__NoCodeAtTarget(address target);
error Aera__CallIsNotAllowed(Operation operation);
error Aera__VaultValueBelowMinDailyValue();
error Aera__AllowanceIsNotZero(address asset, address spender);
error Aera__HooksInitialOwnerIsZeroAddress();
error Aera__RemovingNonexistentTargetSighash(TargetSighash targetSighash);
error Aera__AddingDuplicateTargetSighash(TargetSighash targetSighash);
Last modified 1mo ago