Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0x5aE0e44DE96885702bD99A6914751C952d284938
Balance 0 ETH
Nonce 1
Code Size 1362 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

1362 bytes
0x608060405260043610610041575f3560e01c80631cff79cd1461004c57806320a0b48f146100725780634a1fe774146100ca578063fbfa77cf146100dd575f80fd5b3661004857005b5f80fd5b61005f61005a366004610386565b610110565b6040519081526020015b60405180910390f35b34801561007d575f80fd5b506100a57f00000000000000000000000097c03f52244e60bb18511cbf03f890d5886f1f4781565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610069565b61005f6100d8366004610386565b61016e565b3480156100e8575f80fd5b506100a57f000000000000000000000000551d155760ae96050439ad24ae98a96c765d761b81565b5f33301461014a576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60205f835160208501866113885a03f45f51915080610167575f80fd5b5092915050565b5f7f00000000000000000000000097c03f52244e60bb18511cbf03f890d5886f1f4773ffffffffffffffffffffffffffffffffffffffff16635731d3b76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156101d8573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906101fc9190610462565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610260576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff83166102ad576040517f625a40e600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f1cff79cd0000000000000000000000000000000000000000000000000000000081523090631cff79cd9034906102ed908790879060040161047d565b60206040518083038185885af1158015610309573d5f803e3d5ffd5b50505050506040513d601f19601f8201168201806040525081019061032e9190610505565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff81168114610356575f80fd5b50565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f8060408385031215610397575f80fd5b82356103a281610335565b9150602083013567ffffffffffffffff808211156103be575f80fd5b818501915085601f8301126103d1575f80fd5b8135818111156103e3576103e3610359565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561042957610429610359565b81604052828152886020848701011115610441575f80fd5b826020860160208301375f6020848301015280955050505050509250929050565b5f60208284031215610472575f80fd5b815161032e81610335565b73ffffffffffffffffffffffffffffffffffffffff831681525f60206040602084015283518060408501525f5b818110156104c6578581018301518582016060015282016104aa565b505f6060828601015260607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f830116850101925050509392505050565b5f60208284031215610515575f80fd5b505191905056fea26469706673582212204987581f1c869afd453118f56dbda6274ff484fa6e39198de7773a0601ab680764736f6c63430008180033

Verified Source Code Full Match

Compiler: v0.8.24+commit.e11b9ed9 EVM: cancun Optimization: Yes (10000 runs)
Strategy.sol 69 lines
// SPDX-License-Identifier: MIT
pragma solidity =0.8.24;

import '@openzeppelin/contracts/interfaces/IERC20.sol';
import { IStrategyStorage } from './StrategyStorage.sol';

interface IStrategy {
  error Failed();
  error Unauthorized();

  function execute(address _target, bytes memory _data) external payable returns (bytes32 _response);

  function callExecute(address _target, bytes memory _data) external payable returns (bytes32 _response);

  function vault() external view returns (address);
}

/**
 * @notice strategy contract instance for Treehouse Protocol
 */
contract Strategy is IStrategy {
  address public immutable vault;
  IStrategyStorage public immutable strategyStorage;

  constructor(IStrategyStorage _strategyStorage, address _vault) {
    strategyStorage = _strategyStorage;
    vault = _vault;
  }

  receive() external payable {
    // noOp
  }

  /**
   * @notice danger. executes arbitrary code
   * @param _target target contract
   * @param _data arbitrary calldata
   * @return _response
   */
  function callExecute(address _target, bytes memory _data) external payable returns (bytes32 _response) {
    if (msg.sender != strategyStorage.strategyExecutor()) revert Unauthorized();
    if (_target == address(0)) revert Failed();

    _response = IStrategy(address(this)).execute{ value: msg.value }(_target, _data);
  }

  /**
   * @notice danger. executes arbitrary code
   * @param _target target contract
   * @param _data arbitrary calldata
   * @return _response
   */
  function execute(address _target, bytes memory _data) external payable returns (bytes32 _response) {
    if (msg.sender != address(this)) revert Unauthorized();

    // call contract in current context
    assembly {
      let succeeded := delegatecall(sub(gas(), 5000), _target, add(_data, 0x20), mload(_data), 0, 32)

      // load delegatecall output
      _response := mload(0)

      // throw if delegatecall failed
      if eq(succeeded, 0) {
        revert(0, 0)
      }
    }
  }
}
StrategyStorage.sol 253 lines
// SPDX-License-Identifier: MIT
pragma solidity =0.8.24;

import '@openzeppelin/contracts/access/Ownable2Step.sol';
import '@openzeppelin/contracts/utils/structs/EnumerableSet.sol';

interface IStrategyStorage {
  struct StrategyParameters {
    bool isActive;
    EnumerableSet.Bytes32Set whitelistedActions;
    EnumerableSet.AddressSet whitelistedAssets;
  }

  error AlreadyExist();
  error DoesNotExist();

  event AssetWhitelisted(address _asset);
  event AssetUnwhitelisted(address _asset);
  event ActionWhitelisted(bytes4 _actionId);
  event ActionUnwhitelisted(bytes4 _actionId);
  event StrategyPaused(uint _strategyId);
  event StrategyUnpaused(uint _strategyId);
  event StrategyCreated(uint _index, address[] _allowedAssets, bytes4[] _allowedActions);
  event StrategyExecutorUpdated(address _newExecutor, address _oldExecutor);

  function getStrategyInfo(
    uint _strategyId
  )
    external
    view
    returns (
      address _strategyAddress,
      bool _isActive,
      bytes32[] memory _allowedActions,
      address[] memory _allowedAssets
    );

  function getStrategyCount() external view returns (uint _count);

  function isActiveStrategy(address _strategy) external view returns (bool _isActiveStrategy);

  function isAssetWhitelisted(address _strategy, address _asset) external view returns (bool _isAssetWhitelisted);

  function isActionWhitelisted(address _strategy, bytes4 _actionId) external view returns (bool _isActionWhitelisted);

  function getStrategyAddress(uint _strategyId) external view returns (address _strategyAddress);

  function strategyExecutor() external view returns (address);
}

/**
 * @notice Store created strategies and associated metadata
 */
contract StrategyStorage is IStrategyStorage, Ownable2Step {
  using EnumerableSet for EnumerableSet.AddressSet;
  using EnumerableSet for EnumerableSet.Bytes32Set;

  mapping(address strategy => StrategyParameters) private parameters;
  EnumerableSet.AddressSet private strategies;
  address public strategyExecutor;

  constructor(address _creator) Ownable(_creator) {}

  /**
   * @notice stores a created strategy and associated metadata
   * @param _strategy strategy address
   * @param _allowedActions list of assets allowed
   * @param _allowedAssets list of assets allowed
   * @return _strategyIndex strategy Id
   */
  function storeStrategy(
    address _strategy,
    bytes4[] calldata _allowedActions,
    address[] calldata _allowedAssets
  ) external onlyOwner returns (uint _strategyIndex) {
    if (strategies.add(_strategy) == false) revert AlreadyExist();
    _strategyIndex = strategies.length() - 1;

    bool success;
    for (uint i; i < _allowedActions.length; ++i) {
      success = parameters[_strategy].whitelistedActions.add(_allowedActions[i]);
      if (!success) revert AlreadyExist();
    }

    for (uint i; i < _allowedAssets.length; ++i) {
      success = parameters[_strategy].whitelistedAssets.add(_allowedAssets[i]);
      if (!success) revert AlreadyExist();
    }

    parameters[_strategy].isActive = true;

    emit StrategyCreated(_strategyIndex, _allowedAssets, _allowedActions);
  }

  /**
   * @notice whitelist actions for given strategy id
   * @param _strategyId strategy id
   * @param _whitelistedActions whitelisted action array
   */
  function whitelistActions(uint _strategyId, bytes4[] calldata _whitelistedActions) external onlyOwner {
    for (uint i; i < _whitelistedActions.length; ++i) {
      if (parameters[_safeGetStrategyAddress(_strategyId)].whitelistedActions.add(_whitelistedActions[i]) == false)
        revert AlreadyExist();

      emit ActionWhitelisted(_whitelistedActions[i]);
    }
  }

  /**
   * @notice un-whitelist actions for given strategy id
   * @param _strategyId strategy id
   * @param _unwhitelistedActions un-whitelisted action array
   */
  function unwhitelistActions(uint _strategyId, bytes4[] calldata _unwhitelistedActions) external onlyOwner {
    for (uint i; i < _unwhitelistedActions.length; ++i) {
      if (parameters[_safeGetStrategyAddress(_strategyId)].whitelistedActions.remove(_unwhitelistedActions[i]) == false)
        revert DoesNotExist();

      emit ActionUnwhitelisted(_unwhitelistedActions[i]);
    }
  }

  /**
   * @notice whitelist assets for given strategy id
   * @param _strategyId strategy id
   * @param _whitelistedAssets whitelisted asset array
   */
  function whitelistAssets(uint _strategyId, address[] calldata _whitelistedAssets) external onlyOwner {
    for (uint i; i < _whitelistedAssets.length; ++i) {
      if (parameters[_safeGetStrategyAddress(_strategyId)].whitelistedAssets.add(_whitelistedAssets[i]) == false)
        revert AlreadyExist();

      emit AssetWhitelisted(_whitelistedAssets[i]);
    }
  }

  /**
   * @notice un-whitelist assets for given strategy id
   * @param _strategyId strategy id
   * @param _unwhitelistedAssets un-whitelisted action array
   */
  function unwhitelistAssets(uint _strategyId, address[] calldata _unwhitelistedAssets) external onlyOwner {
    for (uint i; i < _unwhitelistedAssets.length; ++i) {
      if (parameters[_safeGetStrategyAddress(_strategyId)].whitelistedAssets.remove(_unwhitelistedAssets[i]) == false)
        revert DoesNotExist();

      emit AssetUnwhitelisted(_unwhitelistedAssets[i]);
    }
  }

  /**
   * @notice pause strategy
   * @param _strategyId strategy id to pause
   */
  function pauseStrategy(uint _strategyId) external onlyOwner {
    parameters[_safeGetStrategyAddress(_strategyId)].isActive = false;
    emit StrategyPaused(_strategyId);
  }

  /**
   * @notice unpause strategy
   * @param _strategyId strategy id to unpause
   */
  function unpauseStrategy(uint _strategyId) external onlyOwner {
    parameters[_safeGetStrategyAddress(_strategyId)].isActive = true;
    emit StrategyUnpaused(_strategyId);
  }

  /**
   * @notice get information about specified strategy
   * @param _strategyId strategy Id
   * @return _strategyAddress  address of strategy
   * @return _isActive is strategy active
   * @return _allowedActions list of allowed actions
   * @return _allowedAssets  list of allowed assets
   */
  function getStrategyInfo(
    uint _strategyId
  )
    external
    view
    returns (
      address _strategyAddress,
      bool _isActive,
      bytes32[] memory _allowedActions,
      address[] memory _allowedAssets
    )
  {
    _strategyAddress = _safeGetStrategyAddress(_strategyId);
    _isActive = parameters[_strategyAddress].isActive;
    _allowedActions = parameters[_strategyAddress].whitelistedActions.values();
    _allowedAssets = parameters[_strategyAddress].whitelistedAssets.values();
  }

  /**
   * @notice get address of specified strategy Id
   * @param _strategyId  strategy Id
   */
  function getStrategyAddress(uint _strategyId) external view returns (address _strategyAddress) {
    _strategyAddress = _safeGetStrategyAddress(_strategyId);
  }

  /**
   * @notice get strategy count
   * @return _count  number of strategies
   */
  function getStrategyCount() external view returns (uint _count) {
    _count = strategies.length();
  }

  /**
   * @notice get status of strategy
   * @param _strategy  strategy Id
   * @return _isActiveStrategy is strategy active
   */
  function isActiveStrategy(address _strategy) external view returns (bool _isActiveStrategy) {
    _isActiveStrategy = strategies.contains(_strategy) && parameters[_strategy].isActive;
  }

  /**
   * @notice get status of strategy
   * @param _strategy strategy Id
   * @param _token token that maybe whitelisted
   * @return _isAssetWhitelisted is asset whitelisted
   */
  function isAssetWhitelisted(address _strategy, address _token) external view returns (bool _isAssetWhitelisted) {
    _isAssetWhitelisted = strategies.contains(_strategy) && parameters[_strategy].whitelistedAssets.contains(_token);
  }

  /**
   * @notice get action whitelisted
   * @param _strategy strategy Id
   * @param _actionId action Id
   * @return _isActionWhitelisted is action whitelisted
   */
  function isActionWhitelisted(address _strategy, bytes4 _actionId) external view returns (bool _isActionWhitelisted) {
    _isActionWhitelisted = parameters[_strategy].whitelistedActions.contains(_actionId);
  }

  function _safeGetStrategyAddress(uint _strategyId) internal view returns (address _address) {
    if (_strategyId >= strategies.length()) revert DoesNotExist();
    _address = strategies.at(_strategyId);
  }

  /**
   * @notice set new strategy executor
   * @param _newExecutor set new executor
   */
  function setStrategyExecutor(address _newExecutor) external onlyOwner {
    emit StrategyExecutorUpdated(_newExecutor, strategyExecutor);
    strategyExecutor = _newExecutor;
  }
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is set to the address provided by the deployer. This can
 * later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
IERC20.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../token/ERC20/IERC20.sol";
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 value) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}
Ownable2Step.sol 59 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable2Step.sol)

pragma solidity ^0.8.20;

import {Ownable} from "./Ownable.sol";

/**
 * @dev Contract module which provides access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is specified at deployment time in the constructor for `Ownable`. This
 * can later be changed with {transferOwnership} and {acceptOwnership}.
 *
 * This module is used through inheritance. It will make available all functions
 * from parent (Ownable).
 */
abstract contract Ownable2Step is Ownable {
    address private _pendingOwner;

    event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Returns the address of the pending owner.
     */
    function pendingOwner() public view virtual returns (address) {
        return _pendingOwner;
    }

    /**
     * @dev 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 virtual override onlyOwner {
        _pendingOwner = newOwner;
        emit OwnershipTransferStarted(owner(), newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual override {
        delete _pendingOwner;
        super._transferOwnership(newOwner);
    }

    /**
     * @dev The new owner accepts the ownership transfer.
     */
    function acceptOwnership() public virtual {
        address sender = _msgSender();
        if (pendingOwner() != sender) {
            revert OwnableUnauthorizedAccount(sender);
        }
        _transferOwnership(sender);
    }
}
EnumerableSet.sol 378 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.

pragma solidity ^0.8.20;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```solidity
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 *
 * [WARNING]
 * ====
 * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
 * unusable.
 * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
 *
 * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
 * array of EnumerableSet.
 * ====
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position is the index of the value in the `values` array plus 1.
        // Position 0 is used to mean a value is not in the set.
        mapping(bytes32 value => uint256) _positions;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._positions[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We cache the value's position to prevent multiple reads from the same storage slot
        uint256 position = set._positions[value];

        if (position != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 valueIndex = position - 1;
            uint256 lastIndex = set._values.length - 1;

            if (valueIndex != lastIndex) {
                bytes32 lastValue = set._values[lastIndex];

                // Move the lastValue to the index where the value to delete is
                set._values[valueIndex] = lastValue;
                // Update the tracked position of the lastValue (that was just moved)
                set._positions[lastValue] = position;
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the tracked position for the deleted slot
            delete set._positions[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._positions[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        bytes32[] memory store = _values(set._inner);
        bytes32[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }
}

Read Contract

strategyStorage 0x20a0b48f → address
vault 0xfbfa77cf → address

Write Contract 2 functions

These functions modify contract state and require a wallet transaction to execute.

callExecute 0x4a1fe774
address _target
bytes _data
returns: bytes32
execute 0x1cff79cd
address _target
bytes _data
returns: bytes32

Recent Transactions

No transactions found for this address