Skip to content
Verified contractExactAGPL-3.0-only

VotemarketCampaignExecutor

Address0xf84f3ad311952cd8bd2e777e353f7b9fad899f8a
Balance

0.002326 ETH

 

Transactions

1

 

Compiler

solc 0.8.28

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.28+commit.7893614a
Language
solidity
Optimization
Yes, 200 runs
EVM version
cancun
License
AGPL-3.0-only
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,441,702
Creation transaction
0xce43aaaac1…8cbd8e6a2a

src/executor-guard/VotemarketCampaignExecutor.sol

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

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import {AllMightModule} from "src/executor-guard/AllMightModule.sol";
import {IAllMight} from "src/executor-guard/interfaces/IAllMight.sol";

interface ICampaignFundingRemote {
    struct Creation {
        uint256 chainId;
        address gauge;
        address manager;
        address rewardToken;
        uint8 numberOfPeriods;
        uint256 maxRewardPerVote;
        uint256 totalRewardAmount;
        address[] addresses;
        address hook;
        bool isWhitelist;
    }

    struct Management {
        uint256 campaignId;
        address rewardToken;
        uint8 numberOfPeriods;
        uint256 totalRewardAmount;
        uint256 maxRewardPerVote;
    }

    function whitelistedPlatforms(address platform) external view returns (bool);
    function createCampaign(Creation calldata, uint256, uint256, address) external payable;
    function manageCampaign(Management calldata, uint256, uint256, address) external payable;
}

/// @notice Permissioned, shared SDT campaign funding from Ethereum to Arbitrum through AllMight.
/// @dev The KMS enters through ExecutorGuard, never directly. Governance must verify the destination
///      campaign identity and platform.remote() before approving an ID; L1 cannot read L2 state.
contract VotemarketCampaignExecutor is AllMightModule, ReentrancyGuard {
    struct Source {
        uint256 gaugeChainId;
        address gauge;
        address platform;
        address remoteManager;
        address hook;
        address[] addresses;
        bool isWhitelist;
    }

    struct Limits {
        uint256 minInterval;
        uint256 maxFee;
        uint256 createGasLimit;
        uint256 manageGasLimit;
        uint8 minCreatePeriods;
        uint8 maxPeriods;
        bool enabled;
    }

    /// @dev abi.encode(Funding) is carried as bytes so a guarded Weiroll CALL needs only 2–3 inputs.
    ///      Retries must reuse the same nonce. A config change invalidates plans, not economic-only ID approvals.
    struct Funding {
        uint256 nonce;
        uint256 configVersion;
        uint256 amount;
        uint8 periods;
        uint256 maxRewardPerVote;
        uint256 fee;
    }

    uint256 public constant DESTINATION_CHAIN_ID = 42161;
    address public immutable SDT;
    mapping(address => Source) private _sources;
    mapping(address => Limits) public limits;
    mapping(address => uint256) public sourceRevision;
    mapping(address => uint256) public configVersion;
    mapping(address => uint256) public nextNonce;
    mapping(address => uint256) public lastFundedAt;
    mapping(address => mapping(uint256 => uint256)) private _campaignRevisions;

    error INVALID_SOURCE();
    error INVALID_LIMITS();
    error INVALID_FUNDING();
    error CAMPAIGN_NOT_APPROVED();
    error STALE_PLAN();
    error NONCE_USED();
    error TOO_SOON();
    error BALANCE_MISMATCH();

    event SourceSet(address indexed source, uint256 revision, uint256 version);
    event LimitsSet(address indexed source, Limits limits, uint256 version);
    event CampaignSet(address indexed source, uint256 indexed campaignId, bool allowed);
    event Funded(
        address indexed source,
        uint256 indexed nonce,
        uint256 indexed campaignId,
        bool created,
        uint256 amount,
        uint256 fee
    );

    constructor(address allMight, address governance_, address sdt) payable AllMightModule(allMight, governance_) {
        if (block.chainid != 1 || allMight.code.length == 0 || sdt.code.length == 0) revert INVALID_SOURCE();
        SDT = sdt;
    }

    function source(address account) external view returns (Source memory) {
        return _sources[account];
    }

    function setSource(address account, Source calldata policy) external onlyGovernance {
        if (
            account.code.length == 0 || policy.gaugeChainId == 0 || policy.gauge == address(0)
                || policy.platform == address(0) || policy.remoteManager.code.length == 0
                || !ICampaignFundingRemote(policy.remoteManager).whitelistedPlatforms(policy.platform)
        ) revert INVALID_SOURCE();
        if (keccak256(abi.encode(_sources[account])) != keccak256(abi.encode(policy))) {
            ++sourceRevision[account];
            _sources[account] = policy;
        }
        emit SourceSet(account, sourceRevision[account], ++configVersion[account]);
    }

    function setLimits(address account, Limits calldata policy) external onlyGovernance {
        if (sourceRevision[account] == 0) revert INVALID_SOURCE();
        if (
            policy.maxFee == 0 || policy.createGasLimit == 0 || policy.manageGasLimit == 0
                || policy.minCreatePeriods == 0 || policy.maxPeriods < policy.minCreatePeriods
        ) revert INVALID_LIMITS();
        limits[account] = policy;
        emit LimitsSet(account, policy, ++configVersion[account]);
    }

    /// @notice Approve an existing or newly delivered L2 ID, without creating or funding it again.
    function setCampaign(address account, uint256 campaignId, bool allowed) external onlyGovernance {
        if (sourceRevision[account] == 0) revert INVALID_SOURCE();
        _campaignRevisions[account][campaignId] = allowed ? sourceRevision[account] : 0;
        ++configVersion[account];
        emit CampaignSet(account, campaignId, allowed);
    }

    function campaigns(address account, uint256 campaignId) public view returns (bool) {
        uint256 revision = sourceRevision[account];
        return revision != 0 && _campaignRevisions[account][campaignId] == revision;
    }

    function create(address account, bytes calldata request) external onlyAllMight nonReentrant {
        Funding memory funding = abi.decode(request, (Funding));
        Source memory policy = _begin(account, funding, true);
        ICampaignFundingRemote.Creation memory params = ICampaignFundingRemote.Creation({
            chainId: policy.gaugeChainId,
            gauge: policy.gauge,
            manager: ALL_MIGHT,
            rewardToken: SDT,
            numberOfPeriods: funding.periods,
            maxRewardPerVote: funding.maxRewardPerVote,
            totalRewardAmount: funding.amount,
            addresses: policy.addresses,
            hook: policy.hook,
            isWhitelist: policy.isWhitelist
        });
        _fund(
            account,
            policy.remoteManager,
            funding,
            abi.encodeCall(
                ICampaignFundingRemote.createCampaign,
                (params, DESTINATION_CHAIN_ID, limits[account].createGasLimit, policy.platform)
            )
        );
        emit Funded(account, funding.nonce, 0, true, funding.amount, funding.fee);
    }

    function manage(address account, uint256 campaignId, bytes calldata request) external onlyAllMight nonReentrant {
        if (!campaigns(account, campaignId)) revert CAMPAIGN_NOT_APPROVED();
        Funding memory funding = abi.decode(request, (Funding));
        Source memory policy = _begin(account, funding, false);
        ICampaignFundingRemote.Management memory params = ICampaignFundingRemote.Management({
            campaignId: campaignId,
            rewardToken: SDT,
            numberOfPeriods: funding.periods,
            totalRewardAmount: funding.amount,
            maxRewardPerVote: funding.maxRewardPerVote
        });
        _fund(
            account,
            policy.remoteManager,
            funding,
            abi.encodeCall(
                ICampaignFundingRemote.manageCampaign,
                (params, DESTINATION_CHAIN_ID, limits[account].manageGasLimit, policy.platform)
            )
        );
        emit Funded(account, funding.nonce, campaignId, false, funding.amount, funding.fee);
    }

    function rescueNative(uint256 amount) external onlyGovernance nonReentrant {
        Address.sendValue(payable(governance), amount);
    }

    function _begin(address account, Funding memory funding, bool creating) internal returns (Source memory) {
        Limits memory policy = limits[account];
        if (sourceRevision[account] == 0 || !policy.enabled) revert INVALID_SOURCE();
        if (funding.configVersion != configVersion[account]) revert STALE_PLAN();
        if (funding.nonce != nextNonce[account]) revert NONCE_USED();
        if (funding.nonce != 0 && block.timestamp - lastFundedAt[account] < policy.minInterval) revert TOO_SOON();
        if (
            funding.amount == 0 || funding.periods > policy.maxPeriods || funding.fee == 0
                || funding.fee > policy.maxFee || funding.fee > address(this).balance
                || (creating && (funding.periods < policy.minCreatePeriods || funding.maxRewardPerVote == 0))
        ) revert INVALID_FUNDING();
        ++nextNonce[account];
        lastFundedAt[account] = block.timestamp;
        return _sources[account];
    }

    function _fund(address account, address remote, Funding memory funding, bytes memory data) internal {
        uint256 balance = IERC20(SDT).balanceOf(ALL_MIGHT);
        uint256 nativeBalance = ALL_MIGHT.balance;
        _call(
            account, 0, abi.encodeWithSignature("rescueERC20(address,address,uint256)", SDT, ALL_MIGHT, funding.amount)
        );
        if (IERC20(SDT).balanceOf(ALL_MIGHT) != balance + funding.amount) revert BALANCE_MISMATCH();
        _call(SDT, 0, abi.encodeCall(IERC20.approve, (remote, 0)));
        _call(SDT, 0, abi.encodeCall(IERC20.approve, (remote, funding.amount)));
        _call(remote, funding.fee, data);
        _call(SDT, 0, abi.encodeCall(IERC20.approve, (remote, 0)));
        if (IERC20(SDT).balanceOf(ALL_MIGHT) != balance || IERC20(SDT).allowance(ALL_MIGHT, remote) != 0) {
            revert BALANCE_MISMATCH();
        }
        // LaPoste refunds the remote's caller (AllMight). Return only this call's surplus to the shared reserve.
        if (ALL_MIGHT.balance < nativeBalance) revert BALANCE_MISMATCH();
        uint256 refund = ALL_MIGHT.balance - nativeBalance;
        if (refund != 0) _call(address(this), refund, "");
    }

    function _call(address target, uint256 value, bytes memory data) internal {
        bytes32[] memory commands = new bytes32[](1);
        bytes[] memory state = new bytes[](3);
        state[0] = abi.encode(target);
        state[1] = abi.encode(value);
        bytes memory encoded = abi.encode(data);
        bytes memory dynamic = new bytes(encoded.length - 32);
        for (uint256 i = 32; i < encoded.length; ++i) {
            dynamic[i - 32] = encoded[i];
        }
        state[2] = dynamic;
        commands[0] = bytes32(
            (uint256(uint32(bytes4(keccak256("planCall(address,uint256,bytes)")))) << 224) | (uint256(1) << 216)
                | (uint256(0x000182ffffff) << 168) | (uint256(255) << 160) | uint256(uint160(ALL_MIGHT))
        );
        // Native already held by AllMight (refunds) must not be funded a second time by the helper.
        try IAllMight(ALL_MIGHT).execute{value: target == address(this) ? 0 : value}(commands, state) {}
        catch {
            // The outer Weiroll VM expects Error(string); nesting ExecutionFailed would exhaust its gas.
            revert("CAMPAIGN_CALL_FAILED");
        }
    }

    receive() external payable {}
}

node_modules/@openzeppelin/contracts/security/ReentrancyGuard.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == _ENTERED;
    }
}

node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @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 amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

    /**
     * @dev Moves `amount` 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 amount) 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 `amount` 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 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` 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 amount) external returns (bool);
}

node_modules/@openzeppelin/contracts/utils/Address.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

src/executor-guard/AllMightModule.sol

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

import {Governed} from "src/executor-guard/Governed.sol";

abstract contract AllMightModule is Governed {
    address public immutable ALL_MIGHT;

    error NOT_ALL_MIGHT();

    constructor(address allMight, address governance_) Governed(governance_) {
        ALL_MIGHT = allMight;
    }

    modifier onlyAllMight() {
        if (msg.sender != ALL_MIGHT) revert NOT_ALL_MIGHT();
        if (paused) revert PAUSED();
        _;
    }
}

src/executor-guard/Governed.sol

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

/// @title  Governed
/// @notice Two-step governance with a guardian one-way pause.
/// @dev    Shared by ExecutorGuard and SwapExecutor. ReplayExecutor predates this base and keeps
///         its own copy: it is already deployed and its runtime code is pinned by codehash.
/// @author Stake DAO
/// @custom:contact [email protected]
abstract contract Governed {
    address public governance;
    address public futureGovernance;
    address public guardian;
    bool public paused;

    event GovernanceProposed(address indexed newGovernance);
    event GovernanceChanged(address indexed newGovernance);
    event GuardianSet(address indexed guardian);
    event Paused(address indexed by);
    event Unpaused();

    error GOVERNANCE();
    error NOT_GUARDIAN();
    error ZERO_ADDRESS();
    error PAUSED();

    modifier onlyGovernance() {
        if (msg.sender != governance) revert GOVERNANCE();
        _;
    }

    constructor(address _governance) {
        if (_governance == address(0)) revert ZERO_ADDRESS();
        governance = _governance;
    }

    function transferGovernance(address _governance) external onlyGovernance {
        emit GovernanceProposed(futureGovernance = _governance);
    }

    function acceptGovernance() external {
        if (msg.sender != futureGovernance) revert GOVERNANCE();
        emit GovernanceChanged(governance = msg.sender);
        futureGovernance = address(0);
    }

    function setGuardian(address _guardian) external onlyGovernance {
        guardian = _guardian;
        emit GuardianSet(_guardian);
    }

    function pause() external {
        if (msg.sender != guardian && msg.sender != governance) revert NOT_GUARDIAN();
        paused = true;
        emit Paused(msg.sender);
    }

    function unpause() external onlyGovernance {
        paused = false;
        emit Unpaused();
    }
}

src/executor-guard/interfaces/IAllMight.sol

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

/// @title  IAllMight
/// @notice Minimal surface of the live AllMight V2 weiroll VM the guard forwards to.
interface IAllMight {
    function execute(bytes32[] calldata commands, bytes[] memory state) external payable returns (bytes[] memory);

    function governance() external view returns (address);

    function isAllowed(address target) external view returns (bool);
}
Compiler settingsShow
{
  "viaIR": false,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "cancun",
  "remappings": [
    "solady/=node_modules/solady/",
    "solmate/=node_modules/solmate/",
    "forge-std/=node_modules/forge-std/",
    "@address-book/=node_modules/@stake-dao/address-book/",
    "@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/",
    "solidity-examples/=node_modules/@layerzerolabs/solidity-examples/contracts/",
    "murky.git/=node_modules/murky.git/",
    "murky/=node_modules/murky.git/src/",
    "weiroll/=node_modules/weiroll/contracts/",
    "@interfaces/=node_modules/@stake-dao/interfaces/src/interfaces/",
    "@shared/=node_modules/@stake-dao/interfaces/src/interfaces/",
    "node_modules/@stake-dao/shared/:src/=node_modules/@stake-dao/shared/src/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.