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.

currentDay

Current day (UTC).

cumulativeDailyMultiplier

Accumulated value multiplier during submit transactions.

_targetSighashAllowed

Allowed target contract and sighash combinations.

_beforeValue

Total value of assets in vault before submission.

Assigned in beforeSubmit and used in afterSubmit.

Functions

onlyVault

MODIFIERS ///

Throws if called by any account other than the vault.

constructor

FUNCTIONS ///

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.

addTargetSighash

Add targetSighash pair to allowlist.

Parameters

Name
Type
Description

target

address

Address of target.

selector

bytes4

Selector of function.

removeTargetSighash

Remove targetSighash pair from allowlist.

Parameters

Name
Type
Description

target

address

Address of target.

selector

bytes4

Selector of function.

beforeDeposit

Hook that runs before deposit.

MUST revert if not called by vault.

Parameters

Name
Type
Description

amounts

AssetValue[]

Struct details for assets and amounts to deposit.

afterDeposit

Hook that runs after deposit.

MUST revert if not called by vault.

Parameters

Name
Type
Description

amounts

AssetValue[]

Struct details for assets and amounts to deposit.

beforeWithdraw

Hook that runs before withdraw.

MUST revert if not called by vault.

Parameters

Name
Type
Description

amounts

AssetValue[]

Struct details for assets and amounts to withdraw.

afterWithdraw

Hook that runs after withdraw.

MUST revert if not called by vault.

Parameters

Name
Type
Description

amounts

AssetValue[]

Struct details for assets and amounts to withdraw.

beforeSubmit

Hook that runs before submit.

MUST revert if not called by vault.

Parameters

Name
Type
Description

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.

Parameters

Name
Type
Description

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.

afterFinalize

Hook that runs after finalize.

MUST revert if not called by vault.

decommission

Take hooks out of use.

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.

targetSighashAllowed

Check whether target and sighash combination is allowed.

Parameters

Name
Type
Description

target

address

Address of target.

selector

bytes4

Selector of function.

_addTargetSighash

INTERNAL FUNCTIONS ///

Add targetSighash pair to allowlist.

Parameters

Name
Type
Description

target

address

Address of target.

selector

bytes4

Selector of function.

_isAllowanceSelector

Check whether selector is allowance related selector or not.

Parameters

Name
Type
Description

selector

bytes4

Selector of calldata to check.

Returns

Name
Type
Description

isAllowanceSelector

bool

True if selector is allowance related selector.

_checkHooksOwner

Check that owner is not the vault or the guardian.

Parameters

Name
Type
Description

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.

Errors

Aera__CallerIsNotVault

ERRORS ///

Aera__VaultIsZeroAddress

Aera__HooksOwnerIsGuardian

Aera__HooksOwnerIsVault

Aera__MinDailyValueTooLow

Aera__MinDailyValueIsNotLessThanOne

Aera__NoCodeAtTarget

Aera__CallIsNotAllowed

Aera__VaultValueBelowMinDailyValue

Aera__AllowanceIsNotZero

Aera__HooksInitialOwnerIsZeroAddress

Aera__RemovingNonexistentTargetSighash

Aera__AddingDuplicateTargetSighash

Last updated