Omniscia Astrolab DAO Audit
AsProxy Code Style Findings
AsProxy Code Style Findings
APY-01C: Inefficient Generation of Selector
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | AsProxy.sol:L26 |
Description:
The AsProxy::_delegateWithSignature function will calculate the function selector locally from an input string which is significantly inefficient.
Example:
17/**18 * @notice Delegate a call to an implementation contract using a function signature19 * @param _implementation The address of the implementation contract20 * @param _signature The function signature to delegate21 */22function _delegateWithSignature(23 address _implementation,24 string memory _signature25) internal {26 bytes4 selector = bytes4(keccak256(bytes(_signature)));Recommendation:
Given that the function signatures invoked are known at compile-time, we advise interface declarations for them to be utilized and specifically the selector syntax.
The AsProxy::_delegateWithSignature function is invoked with the StrategyV5Agent::init, StrategyV5Agent::updateAsset, and StrategyV5Abstract::setInputs functions all of which can become part of an interface (i.e. IStrategyV5Agent) and accessed as advised (i.e. IStrategyV5Agent.init.selector).
Alleviation (59b75fbee1d8f3dee807c928f18be41c58b904e1):
The AsProxy implementation was removed from the codebase after consideration of the audit report's outputs and its usage has been replaced by vanilla delegatecall integrations.
As such, all exhibits relevant to it have been marked as no longer applicable.
