Skip to content
Verified contractPartialAGPL-3.0-only

NestVaultOperatorLogic

Address0x69809ff5f7184456bc1b5d99da06ef9861b7343c
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.30

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.30+commit.73712a01
Language
solidity
Optimization
Yes, 200 runs
EVM version
osaka
Via IR
yes
License
AGPL-3.0-only
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
25,723,987
Creation transaction
0x46b209d230…bc98de22e9
Libraries
contracts/libraries/nest-vault/NestVaultOperatorLogic.sol:NestVaultCoreValidationLogic0xf5b4…3f9e06

83 files

The source code is large: one file is shown at a time. Choose a file in the list.

contracts/libraries/nest-vault/NestVaultOperatorLogic.sol

// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.30;

import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
import {SignatureChecker} from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
import {Errors} from "contracts/types/Errors.sol";
import {NestVaultCoreTypes} from "contracts/libraries/nest-vault/NestVaultCoreTypes.sol";
import {NestVaultCoreValidationLogic} from "contracts/libraries/nest-vault/NestVaultCoreValidationLogic.sol";

/// @title  NestVaultOperatorLogic
/// @notice Library containing operator-related logic for NestVaultCore
/// @author plumenetwork
/// @custom:oz-upgrades-unsafe-allow external-library-linking
library NestVaultOperatorLogic {
    using NestVaultCoreValidationLogic for NestVaultCoreTypes.NestVaultCoreStorage;
    /*//////////////////////////////////////////////////////////////
                                EVENTS
    //////////////////////////////////////////////////////////////*/

    /// @dev   Emitted when an operator is set or revoked
    /// @param controller address The controller setting the operator
    /// @param operator   address The operator being set
    /// @param approved   bool    Whether the operator is approved
    event OperatorSet(address indexed controller, address indexed operator, bool approved);

    /*//////////////////////////////////////////////////////////////
                          EXECUTE FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    /// @notice Executes the setOperator logic
    /// @param  $         NestVaultCoreTypes.NestVaultCoreStorage The full storage struct
    /// @param  _operator address The operator address
    /// @param  _approved bool    Whether to approve or revoke
    /// @param  _caller   address The caller (msg.sender)
    /// @return _success  bool    Always returns true on success
    function executeSetOperator(
        NestVaultCoreTypes.NestVaultCoreStorage storage $,
        address _operator,
        bool _approved,
        address _caller
    ) external returns (bool _success) {
        $.validateSetOperator(_operator, _caller);
        $.isVaultOperator[_caller][_operator] = _approved;
        emit OperatorSet(_caller, _operator, _approved);
        return true;
    }

    /// @notice Validates and executes an operator authorization
    /// @dev    Validates inputs, verifies via EIP712 signatures, and updates state
    /// @param  $                NestVaultCoreTypes.NestVaultCoreStorage The full storage struct
    /// @param  _controller       address The controller's address
    /// @param  _operator         address The operator's address
    /// @param  _approved         bool    Whether the operator is approved or not
    /// @param  _nonce            bytes32 A unique identifier for the authorization
    /// @param  _deadline         uint256 The deadline for the authorization
    /// @param  _signature        bytes   The signature to validate the authorization
    /// @param  _domainSeparator  bytes32 The EIP712 domain separator
    /// @return _success          bool    Always returns true on success
    function executeAuthorizeOperator(
        NestVaultCoreTypes.NestVaultCoreStorage storage $,
        address _controller,
        address _operator,
        bool _approved,
        bytes32 _nonce,
        uint256 _deadline,
        bytes memory _signature,
        bytes32 _domainSeparator
    ) external returns (bool _success) {
        $.validateAuthorizeOperator(_controller, _operator, _nonce, _deadline);

        bytes32 _structHash = keccak256(
            abi.encode(
                keccak256(
                    "AuthorizeOperator(address controller,address operator,bool approved,bytes32 nonce,uint256 deadline)"
                ),
                _controller,
                _operator,
                _approved,
                _nonce,
                _deadline
            )
        );

        bytes32 _hash = MessageHashUtils.toTypedDataHash(_domainSeparator, _structHash);

        if (!SignatureChecker.isValidSignatureNow(_controller, _hash, _signature)) {
            revert Errors.ERC7540InvalidSigner();
        }

        $.authorizations[_controller][_nonce] = true;
        $.isVaultOperator[_controller][_operator] = _approved;
        emit OperatorSet(_controller, _operator, _approved);
        return true;
    }
}
Compiler settingsShow
{
  "viaIR": true,
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "libraries": {
    "contracts/libraries/nest-vault/NestVaultOperatorLogic.sol": {
      "NestVaultCoreValidationLogic": "0xf5b487f7fcbb7a7623faa7cf5b2a8322303f9e06"
    }
  },
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "osaka",
  "remappings": [
    "@boring-vault/=node_modules/boring-vault/",
    "@layerzerolabs/=node_modules/@layerzerolabs/",
    "@morpho/=node_modules/morpho/src/",
    "@openzeppelin/=node_modules/@openzeppelin/",
    "@pendle/=node_modules/@pendle/",
    "@predicate/=node_modules/@predicate/contracts/",
    "@solmate/=node_modules/solmate/src/",
    "@uniswap/permit2/=node_modules/@uniswap/permit2/src/",
    "boring-vault/=node_modules/boring-vault/",
    "createx/=node_modules/createx/src/",
    "ds-test/=node_modules/@layerzerolabs/toolbox-foundry/lib/ds-test/",
    "forge-std/=node_modules/forge-std/src/",
    "hardhat-deploy/=node_modules/hardhat-deploy/",
    "hardhat/=node_modules/hardhat/",
    "morpho/=node_modules/morpho/",
    "solidity-bytes-utils/contracts/=node_modules/@layerzerolabs/toolbox-foundry/lib/solidity-bytes-utils/",
    "solmate/=node_modules/solmate/",
    "src/=node_modules/boring-vault/src/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.