Skip to content
Verified contractPartialGPL-3.0

SettleGeneralDelayedPenalty

Address0xfffefc16231edc6dc9c93e364ff4d4e3f787f416
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.6

 

Same code

1 more contract

 

Details

Compiler
solc 0.8.6+commit.11564f7e
Language
solidity
Optimization
No
EVM version
berlin
License
GPL-3.0
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
25,473,909
Creation transaction
0xd5fd22ed8f…46c17a9c3e

contracts/EVMScriptFactories/SettleGeneralDelayedPenalty.sol

// SPDX-FileCopyrightText: 2026 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.6;

import "contracts/TrustedCaller.sol";
import "contracts/libraries/EVMScriptCreator.sol";
import "contracts/interfaces/IEVMScriptFactory.sol";
import "contracts/interfaces/IBaseModule.sol";
import "contracts/interfaces/IAccounting.sol";

/// @author vgorkavenko
/// @notice Creates EVMScript to settle general delayed penalty for a specific node operators
contract SettleGeneralDelayedPenalty is TrustedCaller, IEVMScriptFactory {
    struct LockInfo {
        uint256 nodeOperatorId;
        uint256 nonce;
    }

    // -------------
    // ERRORS
    // -------------

    string private constant ERROR_EMPTY_LOCK_INFO_LIST = "EMPTY_LOCK_INFO_LIST";
    string private constant ERROR_OUT_OF_RANGE_NODE_OPERATOR_ID = "OUT_OF_RANGE_NODE_OPERATOR_ID";
    string private constant ERROR_NODE_OPERATORS_OUT_OF_ORDER = "NODE_OPERATORS_OUT_OF_ORDER";
    string private constant ERROR_NO_LOCK_TO_SETTLE = "NO_LOCK_TO_SETTLE";
    string private constant ERROR_INVALID_LOCK_NONCE = "INVALID_LOCK_NONCE";

    // -------------
    // VARIABLES
    // -------------

    /// @notice Alias for factory (e.g. "CSMv3")
    string public name;

    /// @notice Address of Module Contract
    IBaseModule public immutable module;
    IAccounting public immutable accounting;

    // -------------
    // CONSTRUCTOR
    // -------------

    constructor(
        address _trustedCaller,
        string memory _name,
        address _module
    ) TrustedCaller(_trustedCaller) {
        name = _name;
        module = IBaseModule(_module);
        accounting = IAccounting(IBaseModule(_module).ACCOUNTING());
    }

    // -------------
    // EXTERNAL METHODS
    // -------------

    /// @notice Creates EVMScript to settle general delayed penalty for the specific node operators
    /// @param _creator Address who creates EVMScript
    /// @param _evmScriptCallData Encoded: LockInfo[]
    function createEVMScript(address _creator, bytes memory _evmScriptCallData)
        external
        view
        override
        onlyTrustedCaller(_creator)
        returns (bytes memory)
    {
        LockInfo[] memory lockInfoList = _decodeEVMScriptCallData(_evmScriptCallData);

        _validateInputData(lockInfoList);

        uint256[] memory nodeOperatorIds = new uint256[](lockInfoList.length);
        uint256[] memory nonces = new uint256[](lockInfoList.length);

        for (uint256 i; i < lockInfoList.length; i++) {
            nodeOperatorIds[i] = lockInfoList[i].nodeOperatorId;
            nonces[i] = lockInfoList[i].nonce;
        }

        return
            EVMScriptCreator.createEVMScript(
                address(module),
                IBaseModule.settleGeneralDelayedPenalty.selector,
                abi.encode(nodeOperatorIds, nonces)
            );
    }

    /// @notice Decodes call data used by createEVMScript method
    /// @param _evmScriptCallData Encoded: LockInfo[]
    /// @return Node operator IDs and max amounts to settle general delayed penalty
    function decodeEVMScriptCallData(bytes memory _evmScriptCallData)
        external
        pure
        returns (LockInfo[] memory)
    {
        return _decodeEVMScriptCallData(_evmScriptCallData);
    }

    // ------------------
    // PRIVATE METHODS
    // ------------------

    function _decodeEVMScriptCallData(bytes memory _evmScriptCallData)
        private
        pure
        returns (LockInfo[] memory)
    {
        return abi.decode(_evmScriptCallData, (LockInfo[]));
    }

    function _validateInputData(LockInfo[] memory lockInfoList) private view {
        require(lockInfoList.length > 0, ERROR_EMPTY_LOCK_INFO_LIST);
        uint256 nodeOperatorsCount = module.getNodeOperatorsCount();
        for (uint256 i = 0; i < lockInfoList.length; ++i) {
            LockInfo memory info = lockInfoList[i];
            require(
                i == 0 || info.nodeOperatorId > lockInfoList[i - 1].nodeOperatorId,
                ERROR_NODE_OPERATORS_OUT_OF_ORDER
            );
            require(info.nodeOperatorId < nodeOperatorsCount, ERROR_OUT_OF_RANGE_NODE_OPERATOR_ID);
            uint256 lockAmount = accounting.getLockedBond(info.nodeOperatorId);
            require(lockAmount > 0, ERROR_NO_LOCK_TO_SETTLE);
            uint256 lockNonce = accounting.getBondLockNonce(info.nodeOperatorId);
            require(info.nonce == lockNonce, ERROR_INVALID_LOCK_NONCE);
        }
    }
}

contracts/TrustedCaller.sol

// SPDX-FileCopyrightText: 2021 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.4;

/// @author psirex
/// @notice A helper contract contains logic to validate that only a trusted caller has access to certain methods.
/// @dev Trusted caller set once on deployment and can't be changed.
contract TrustedCaller {
    string private constant ERROR_TRUSTED_CALLER_IS_ZERO_ADDRESS = "TRUSTED_CALLER_IS_ZERO_ADDRESS";
    string private constant ERROR_CALLER_IS_FORBIDDEN = "CALLER_IS_FORBIDDEN";

    address public immutable trustedCaller;

    constructor(address _trustedCaller) {
        require(_trustedCaller != address(0), ERROR_TRUSTED_CALLER_IS_ZERO_ADDRESS);
        trustedCaller = _trustedCaller;
    }

    modifier onlyTrustedCaller(address _caller) {
        require(_caller == trustedCaller, ERROR_CALLER_IS_FORBIDDEN);
        _;
    }
}

contracts/interfaces/IAccounting.sol

// SPDX-FileCopyrightText: 2026 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.6;

/// @title Lido's accounting interface
interface IAccounting {
    struct BondLockData {
        uint128 amount;
        uint128 until;
    }

    /// @notice Get amount of the locked bond in ETH (stETH) by the given Node Operator
    /// @param nodeOperatorId ID of the Node Operator
    /// @return Amount of the actual locked bond
    function getLockedBond(uint256 nodeOperatorId) external view returns (uint256);

    /// @notice Get bond lock nonce for the given Node Operator
    /// @param nodeOperatorId ID of the Node Operator
    /// @return Bond lock nonce
    function getBondLockNonce(uint256 nodeOperatorId) external view returns (uint256);
}

contracts/interfaces/IBaseModule.sol

// SPDX-FileCopyrightText: 2026 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.6;

struct WithdrawnValidatorInfo {
    uint256 nodeOperatorId;
    uint256 keyIndex;
    uint256 exitBalance;
    uint256 slashingPenalty;
    bool isSlashed;
}

/// @notice Minimal subset of CSM `IBaseModule` used by Easy Track factories.
interface IBaseModule {
    function ACCOUNTING() external view returns (address);

    function settleGeneralDelayedPenalty(
        uint256[] memory nodeOperatorIds,
        uint256[] memory maxAmounts
    ) external;

    function getNodeOperatorsCount() external view returns (uint256);

    function getNodeOperatorIsActive(uint256 nodeOperatorId) external view returns (bool);

    function isValidatorSlashed(uint256 nodeOperatorId, uint256 keyIndex) external view returns (bool);

    function reportValidatorSlashing(uint256 nodeOperatorId, uint256 keyIndex) external;

    function reportSlashedWithdrawnValidators(WithdrawnValidatorInfo[] calldata validatorInfos) external;
}

contracts/interfaces/IEVMScriptFactory.sol

// SPDX-FileCopyrightText: 2021 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.4;

/// @author psirex
/// @notice Interface which every EVMScript factory used in EasyTrack contract has to implement
interface IEVMScriptFactory {
    function createEVMScript(address _creator, bytes memory _evmScriptCallData)
        external
        returns (bytes memory);
}

contracts/libraries/EVMScriptCreator.sol

// SPDX-FileCopyrightText: 2021 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.4;

/// @author psirex
/// @notice Contains methods for convenient creation
/// of EVMScripts in EVMScript factories contracts
library EVMScriptCreator {
    // Id of default CallsScript Aragon's executor.
    bytes4 private constant SPEC_ID = hex"00000001";

    /// @notice Encodes one method call as EVMScript
    function createEVMScript(
        address _to,
        bytes4 _methodId,
        bytes memory _evmScriptCallData
    ) internal pure returns (bytes memory _commands) {
        return
            abi.encodePacked(
                SPEC_ID,
                _to,
                uint32(_evmScriptCallData.length) + 4,
                _methodId,
                _evmScriptCallData
            );
    }

    /// @notice Encodes multiple calls of the same method on one contract as EVMScript
    function createEVMScript(
        address _to,
        bytes4 _methodId,
        bytes[] memory _evmScriptCallData
    ) internal pure returns (bytes memory _evmScript) {
        for (uint256 i = 0; i < _evmScriptCallData.length; ++i) {
            _evmScript = bytes.concat(
                _evmScript,
                abi.encodePacked(
                    _to,
                    uint32(_evmScriptCallData[i].length) + 4,
                    _methodId,
                    _evmScriptCallData[i]
                )
            );
        }
        _evmScript = bytes.concat(SPEC_ID, _evmScript);
    }

    /// @notice Encodes multiple calls to different methods within the same contract as EVMScript
    function createEVMScript(
        address _to,
        bytes4[] memory _methodIds,
        bytes[] memory _evmScriptCallData
    ) internal pure returns (bytes memory _evmScript) {
        require(_methodIds.length == _evmScriptCallData.length, "LENGTH_MISMATCH");

        for (uint256 i = 0; i < _methodIds.length; ++i) {
            _evmScript = bytes.concat(
                _evmScript,
                abi.encodePacked(
                    _to,
                    uint32(_evmScriptCallData[i].length) + 4,
                    _methodIds[i],
                    _evmScriptCallData[i]
                )
            );
        }
        _evmScript = bytes.concat(SPEC_ID, _evmScript);
    }

    /// @notice Encodes multiple calls to different contracts as EVMScript
    function createEVMScript(
        address[] memory _to,
        bytes4[] memory _methodIds,
        bytes[] memory _evmScriptCallData
    ) internal pure returns (bytes memory _evmScript) {
        require(_to.length == _methodIds.length, "LENGTH_MISMATCH");
        require(_to.length == _evmScriptCallData.length, "LENGTH_MISMATCH");

        for (uint256 i = 0; i < _to.length; ++i) {
            _evmScript = bytes.concat(
                _evmScript,
                abi.encodePacked(
                    _to[i],
                    uint32(_evmScriptCallData[i].length) + 4,
                    _methodIds[i],
                    _evmScriptCallData[i]
                )
            );
        }
        _evmScript = bytes.concat(SPEC_ID, _evmScript);
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": false
  },
  "evmVersion": "berlin"
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.