MainPolicyGuardian

Description:

Smart contract deployed on Ethereum.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

/*
 * MainPolicyGuardian (minimal, no inheritance, no interfaces)
 * - Acts like "Main" for satellites: protocolFeeBps()/protocolFeeSink()
 * - Owner-managed setFee()
 * - Can pause/unpause satellites that implement mainPause()/mainUnpause()
 */
contract MainPolicyGuardian {
    address public owner;
    address public feeSink;   // where protocol skim goes
    uint16  public feeBps;    // basis points; e.g., 20 = 0.20%

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
    event FeeUpdated(address indexed sink, uint16 bps);
    event SatellitePaused(address indexed satellite, bool ok);
    event SatelliteUnpaused(address indexed satellite, bool ok);

    modifier onlyOwner() { require(msg.sender == owner, "only owner"); _; }

    constructor(address _owner, address _sink, uint16 _bps) {
        require(_owner != address(0) && _sink != address(0), "zero");
        require(_bps <= 1000, "bps>10%"); // safety rail
        owner  = _owner;
        feeSink = _sink;
        feeBps  = _bps;
        emit OwnershipTransferred(address(0), _owner);
        emit FeeUpdated(_sink, _bps);
    }

    function transferOwnership(address newOwner) external onlyOwner {
        require(newOwner != address(0), "zero");
        emit OwnershipTransferred(owner, newOwner);
        owner = newOwner;
    }

    // --- What satellites read in "Main mode" ---
    function protocolFeeBps() external view returns (uint16)    { return feeBps; }
    function protocolFeeSink() external view returns (address)  { return feeSink; }

    // --- Admin: change fee/sink ---
    function setFee(address sink, uint16 bps) external onlyOwner {
        require(sink != address(0), "zero");
        require(bps <= 1000, "bps>10%");
        feeSink = sink;
        feeBps  = bps;
        emit FeeUpdated(sink, bps);
    }

    // --- Remote control: pause/unpause a satellite via low-level call ---
    function pauseSatellite(address satellite) external onlyOwner {
        (bool ok, ) = satellite.call(abi.encodeWithSignature("mainPause()"));
        emit SatellitePaused(satellite, ok);
        require(ok, "pause failed");
    }

    function unpauseSatellite(address satellite) external onlyOwner {
        (bool ok, ) = satellite.call(abi.encodeWithSignature("mainUnpause()"));
        emit SatelliteUnpaused(satellite, ok);
        require(ok, "unpause failed");
    }
}

Tags:
addr:0xcd79fddca222f877b5925e0265cd4dd0febf9db4|verified:true|block:23413191|tx:0x46a599acad5ad0fb53fcc5aec54821299ffb70350d617814fb6c640e5a3f7756|first_check:1758531017

Submitted on: 2025-09-22 10:50:17

Comments

Log in to comment.

No comments yet.