Verified contractExactMIT
OFTPauserSafeModuleOnEthereum
Address0xaefb790cc539fcdbcc85c3be881e8bbc5cb6c68c
- Balance
0 ETH
- Transactions
3
- Compiler
solc 0.8.35
- Same code
Only this contract
Details
- Compiler
- solc 0.8.35+commit.47b9dedd
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- prague
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 25,544,733
- Creation transaction
- 0x1adec26a93…60d59ef227
7 files
src/OFTPauserSafeModuleOnEthereum.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.35;
import {ISafe} from "./interfaces/ISafe.sol";
import {OFTPauserSafeModule} from "./abstract/OFTPauserSafeModule.sol";
contract OFTPauserSafeModuleOnEthereum is OFTPauserSafeModule {
address public constant USDC_OFT = 0xdaa289CC487Cf95Ba99Db62f791c7E2d2a4b868E;
address public constant USDT_OFT = 0x6925ccD29e3993c82a574CED4372d8737C6dbba6;
address public constant WBTC_OFT = 0x2c01390E10e44C968B73A7BcFF7E4b4F50ba76Ed;
constructor()
OFTPauserSafeModule(
// Safe that is owner / delegate of OFTs
ISafe(0xC85c827133913ddA49f642eC9100F5B6B2cd2bb3),
// LayerZero EndpointV2 on Ethereum
0x1a44076050125825900e736c501f859c50fE728c,
// BlockedMsgLib on Ethereum
0x1ccBf0db9C192d969de57E25B3fF09A25bb1D862,
// SendLib on Ethereum
0xbB2Ea70C9E858123480642Cf96acbcCE1372dCe1,
// ReceiveLib on Ethereum
0xc02Ab410f0734EFa3F14628780e6e695156024C2,
// Citrea EID, dstEid for Ethereum side
30403
)
{}
/// @notice Attempts to pause all OFT contracts (USDC, USDT, WBTC).
/// @dev This function do not revert if any pause operation fail so that other OFTs can still be paused.
/// @return success True if all OFT contracts are paused, false otherwise.
function pauseAll() external onlySafeOrKeeper returns (bool success) {
bool usdcPaused = _tryPause(USDC_OFT);
bool usdtPaused = _tryPause(USDT_OFT);
bool wbtcPaused = _tryPause(WBTC_OFT);
return usdcPaused && usdtPaused && wbtcPaused;
}
/// @notice Attempts to unpause all OFT contracts (USDC, USDT, WBTC).
/// @dev This function do not revert if any unpause operation fail so that other OFTs can still be unpaused.
/// @return success True if all OFT contracts are unpaused, false otherwise.
function unpauseAll() external onlySafe returns (bool success) {
bool usdcUnpaused = _tryUnpause(USDC_OFT);
bool usdtUnpaused = _tryUnpause(USDT_OFT);
bool wbtcUnpaused = _tryUnpause(WBTC_OFT);
return usdcUnpaused && usdtUnpaused && wbtcUnpaused;
}
function pauseUSDC() external onlySafeOrKeeper {
_pause(USDC_OFT);
}
function pauseUSDT() external onlySafeOrKeeper {
_pause(USDT_OFT);
}
function pauseWBTC() external onlySafeOrKeeper {
_pause(WBTC_OFT);
}
function unpauseUSDC() external onlySafe {
_unpause(USDC_OFT);
}
function unpauseUSDT() external onlySafe {
_unpause(USDT_OFT);
}
function unpauseWBTC() external onlySafe {
_unpause(WBTC_OFT);
}
}
src/abstract/OFTPauserSafeModule.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.35;
import {ISafe} from "../interfaces/ISafe.sol";
import {Enum} from "../interfaces/Enum.sol";
import {IMessageLibManager} from "../interfaces/IMessageLibManager.sol";
import {PauserSafeModule} from "./PauserSafeModule.sol";
abstract contract OFTPauserSafeModule is PauserSafeModule {
address public immutable LZ_ENDPOINT;
address public immutable BLOCKED_MSG_LIB;
address public immutable SEND_LIB;
address public immutable RECEIVE_LIB;
uint32 public immutable DST_EID;
constructor(
ISafe safe,
address lzEndpoint,
address blockedMsgLib,
address sendLib,
address receiveLib,
uint32 dstEid
) PauserSafeModule(safe) {
LZ_ENDPOINT = lzEndpoint;
BLOCKED_MSG_LIB = blockedMsgLib;
SEND_LIB = sendLib;
RECEIVE_LIB = receiveLib;
DST_EID = dstEid;
}
/// @inheritdoc PauserSafeModule
function _tryPause(address target) internal override returns (bool success) {
success = _trySetLibraries(target, BLOCKED_MSG_LIB, BLOCKED_MSG_LIB);
if (success) {
emit Paused(msg.sender, target);
} else {
emit PauseFailed(msg.sender, target);
}
}
/// @inheritdoc PauserSafeModule
function _tryUnpause(address target) internal override returns (bool success) {
success = _trySetLibraries(target, SEND_LIB, RECEIVE_LIB);
if (success) {
emit Unpaused(msg.sender, target);
} else {
emit UnpauseFailed(msg.sender, target);
}
}
/// @notice Tries to set the send and receive libraries for the target OFT contract.
/// @param target The address of the OFT contract.
/// @param newSendLib The address of the new send library.
/// @param newReceiveLib The address of the new receive library.
/// @return success True if both libraries were successfully set, false otherwise.
function _trySetLibraries(address target, address newSendLib, address newReceiveLib)
internal
returns (bool success)
{
bool sendSuccess = _trySetSendLibrary(target, newSendLib);
bool receiveSuccess = _trySetReceiveLibrary(target, newReceiveLib);
return sendSuccess && receiveSuccess;
}
/// @notice Tries to set the send library for the target OFT contract.
/// @dev Avoids reverts as `_tryPause` and `_tryUnpause` should not have a revert condition other than Safe's GS104 (module not enabled).
/// @param target The address of the OFT contract.
/// @param newLib The address of the new send library.
/// @return success True if the send library was successfully set, false otherwise.
function _trySetSendLibrary(address target, address newLib) internal returns (bool success) {
// Avoid revert on `getSendLibrary`, attempt the `setSendLibrary` call in any case.
try IMessageLibManager(LZ_ENDPOINT).getSendLibrary(target, DST_EID) returns (address currentLib) {
// If already set return early to avoid revert on LZ_SameValue so it doesn't lead to a false failure.
if (currentLib == newLib) {
return true;
}
} catch {}
return SAFE.execTransactionFromModule(
LZ_ENDPOINT,
0,
abi.encodeCall(IMessageLibManager.setSendLibrary, (target, DST_EID, newLib)),
Enum.Operation.Call
);
}
/// @notice Tries to set the receive library for the target OFT contract.
/// @dev Avoids reverts as `_tryPause` and `_tryUnpause` should not have a revert condition other than Safe's GS104 (module not enabled).
/// @param target The address of the OFT contract.
/// @param newLib The address of the new receive library.
/// @return success True if the receive library was successfully set, false otherwise.
function _trySetReceiveLibrary(address target, address newLib) internal returns (bool success) {
// Avoid revert on `getReceiveLibrary`, attempt the `setReceiveLibrary` call in any case.
try IMessageLibManager(LZ_ENDPOINT).getReceiveLibrary(target, DST_EID) returns (address currentLib, bool) {
// If already set return early to avoid revert on LZ_SameValue so it doesn't lead to a false failure.
if (currentLib == newLib) {
return true;
}
} catch {}
return SAFE.execTransactionFromModule(
LZ_ENDPOINT,
0,
abi.encodeCall(IMessageLibManager.setReceiveLibrary, (target, DST_EID, newLib, 0)),
Enum.Operation.Call
);
}
}
src/abstract/PauserSafeModule.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.35;
import {ISafe} from "../interfaces/ISafe.sol";
abstract contract PauserSafeModule {
ISafe public immutable SAFE;
mapping(address => bool) public keepers;
event KeeperAdded(address indexed keeper);
event KeeperRemoved(address indexed keeper);
event Paused(address indexed caller, address indexed target);
event PauseFailed(address indexed caller, address indexed target);
event Unpaused(address indexed caller, address indexed target);
event UnpauseFailed(address indexed caller, address indexed target);
modifier onlySafe() {
require(msg.sender == address(SAFE), "PauserSafeModule: caller is not the Safe");
_;
}
modifier onlyKeeper() {
require(keepers[msg.sender], "PauserSafeModule: caller is not a keeper");
_;
}
modifier onlySafeOrKeeper() {
require(
msg.sender == address(SAFE) || keepers[msg.sender], "PauserSafeModule: caller is not the Safe or a keeper"
);
_;
}
constructor(ISafe safe) {
SAFE = safe;
}
/// @param keeper The address of the keeper to be added.
/// @dev Keepers are automated entities that can pause the contracts as a reaction to an on-chain event.
function addKeeper(address keeper) external onlySafe {
keepers[keeper] = true;
emit KeeperAdded(keeper);
}
/// @param keeper The address of the keeper to be removed.
/// @dev Keepers are automated entities that can pause the contracts as a reaction to an on-chain event.
function removeKeeper(address keeper) external onlySafe {
keepers[keeper] = false;
emit KeeperRemoved(keeper);
}
/// @notice Allows a keeper to renounce its own keeper status.
/// @dev Keepers are automated entities that can pause the contracts as a reaction to an on-chain event.
function renounceKeeper() external onlyKeeper {
keepers[msg.sender] = false;
emit KeeperRemoved(msg.sender);
}
/// @notice Pauses the target contract.
/// @param target The address of the contract to be paused.
function _pause(address target) internal {
require(_tryPause(target), "PauserSafeModule: pause failed");
}
/// @notice Unpauses the target contract.
/// @param target The address of the contract to be unpaused.
function _unpause(address target) internal {
require(_tryUnpause(target), "PauserSafeModule: unpause failed");
}
/// @notice Tries to pause the target contract.
/// @dev Should not have a revert condition other than Safe's GS104 (module not enabled).
/// @param target The address of the contract to be paused.
/// @return success True if the pause operation was successful or if the target is already paused, false otherwise.
function _tryPause(address target) internal virtual returns (bool success);
/// @notice Tries to unpause the target contract.
/// @dev Should not have a revert condition other than Safe's GS104 (module not enabled).
/// @param target The address of the contract to be unpaused.
/// @return success True if the unpause operation was successful or if the target is already unpaused, false otherwise.
function _tryUnpause(address target) internal virtual returns (bool success);
}
src/interfaces/Enum.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;
/**
* @title Enum
* @notice Collection of enums used in Safe Smart Account contracts.
* @author @safe-global/safe-protocol
*/
library Enum {
/**
* @notice A Safe transaction operation.
* @custom:variant Call The Safe transaction is executed with the `CALL` opcode.
* @custom:variant Delegatecall The Safe transaction is executed with the `DELEGATECALL` opcode.
*/
enum Operation {
Call,
DelegateCall
}
}
src/interfaces/IMessageLibManager.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
struct SetConfigParam {
uint32 eid;
uint32 configType;
bytes config;
}
interface IMessageLibManager {
struct Timeout {
address lib;
uint256 expiry;
}
event LibraryRegistered(address newLib);
event DefaultSendLibrarySet(uint32 eid, address newLib);
event DefaultReceiveLibrarySet(uint32 eid, address newLib);
event DefaultReceiveLibraryTimeoutSet(uint32 eid, address oldLib, uint256 expiry);
event SendLibrarySet(address sender, uint32 eid, address newLib);
event ReceiveLibrarySet(address receiver, uint32 eid, address newLib);
event ReceiveLibraryTimeoutSet(address receiver, uint32 eid, address oldLib, uint256 timeout);
function registerLibrary(address _lib) external;
function isRegisteredLibrary(address _lib) external view returns (bool);
function getRegisteredLibraries() external view returns (address[] memory);
function setDefaultSendLibrary(uint32 _eid, address _newLib) external;
function defaultSendLibrary(uint32 _eid) external view returns (address);
function setDefaultReceiveLibrary(uint32 _eid, address _newLib, uint256 _timeout) external;
function defaultReceiveLibrary(uint32 _eid) external view returns (address);
function setDefaultReceiveLibraryTimeout(uint32 _eid, address _lib, uint256 _expiry) external;
function defaultReceiveLibraryTimeout(uint32 _eid) external view returns (address lib, uint256 expiry);
function isSupportedEid(uint32 _eid) external view returns (bool);
function isValidReceiveLibrary(address _receiver, uint32 _eid, address _lib) external view returns (bool);
/// ------------------- OApp interfaces -------------------
function setSendLibrary(address _oapp, uint32 _eid, address _newLib) external;
function getSendLibrary(address _sender, uint32 _eid) external view returns (address lib);
function isDefaultSendLibrary(address _sender, uint32 _eid) external view returns (bool);
function setReceiveLibrary(address _oapp, uint32 _eid, address _newLib, uint256 _gracePeriod) external;
function getReceiveLibrary(address _receiver, uint32 _eid) external view returns (address lib, bool isDefault);
function setReceiveLibraryTimeout(address _oapp, uint32 _eid, address _lib, uint256 _gracePeriod) external;
function receiveLibraryTimeout(address _receiver, uint32 _eid) external view returns (address lib, uint256 expiry);
function setConfig(address _oapp, address _lib, SetConfigParam[] calldata _params) external;
function getConfig(address _oapp, address _lib, uint32 _eid, uint32 _configType)
external
view
returns (bytes memory config);
}
src/interfaces/IModuleManager.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;
import {Enum} from "../interfaces/Enum.sol";
/**
* @title Module Manager Interface
* @notice Interface for managing Safe modules.
* @dev Modules are extensions with unlimited access to a Safe that can be added to a Safe by its owners.
* ⚠️⚠️⚠️ WARNING: Modules are a security risk since they can execute arbitrary transactions,
* so only trusted and audited modules should be added to a Safe. A malicious module can
* completely takeover a Safe. ⚠️⚠️⚠️
* @author @safe-global/safe-protocol
*/
interface IModuleManager {
/**
* @notice A module was enabled.
* @param module The address of the enabled module.
*/
event EnabledModule(address indexed module);
/**
* @notice A module was disabled.
* @param module The address of the disabled module.
*/
event DisabledModule(address indexed module);
/**
* @notice A module transaction successfully executed.
* @param module The address of the module that executed the transaction.
*/
event ExecutionFromModuleSuccess(address indexed module);
/**
* @notice A module transaction reverted during executed.
* @param module The address of the module that executed the transaction.
*/
event ExecutionFromModuleFailure(address indexed module);
/**
* @notice The module transaction guard changed.
* @param moduleGuard The address of the new module transaction guard.
*/
event ChangedModuleGuard(address indexed moduleGuard);
/**
* @notice Enables the module `module` for the Safe.
* @dev This can only be done via a Safe transaction.
* @param module Module to be whitelisted.
*/
function enableModule(address module) external;
/**
* @notice Disables the module `module` for the Safe.
* @dev This can only be done via a Safe transaction.
* @param prevModule Previous module in the modules linked list. If the module to be
* disabled is the first (or only) element of the list, `prevModule` MUST be
* set to the sentinel address `0x1` (referred to as `SENTINEL_MODULES` in the
* implementation).
* @param module Module to be removed.
*/
function disableModule(address prevModule, address module) external;
/**
* @notice Execute `operation` to `to` with native token `value`.
* @param to Destination address of the module transaction.
* @param value Native token value of the module transaction.
* @param data Data payload of the module transaction.
* @param operation Operation type of the module transaction: 0 for `CALL` and 1 for `DELEGATECALL`.
* @return success Boolean flag indicating if the call succeeded.
*/
function execTransactionFromModule(address to, uint256 value, bytes memory data, Enum.Operation operation)
external
returns (bool success);
/**
* @notice Execute `operation` to `to` with native token `value` and return data.
* @param to Destination address of the module transaction.
* @param value Native token value of the module transaction.
* @param data Data payload of the module transaction.
* @param operation Operation type of the module transaction: 0 for `CALL` and 1 for `DELEGATECALL`.
* @return success Boolean flag indicating if the call succeeded.
* @return returnData Data returned by the call.
*/
function execTransactionFromModuleReturnData(address to, uint256 value, bytes memory data, Enum.Operation operation)
external
returns (bool success, bytes memory returnData);
/**
* @notice Returns whether or not a module is enabled.
* @return True if the module is enabled, false otherwise.
*/
function isModuleEnabled(address module) external view returns (bool);
/**
* @notice Returns an array of modules.
* @dev If all entries fit into a single page, the next pointer will be `address(0x1)`.
* If another page is present, next will be the last element of the returned array.
* @param start Start of the page. Has to be a module or start pointer (`address(0x1)`).
* @param pageSize Maximum number of modules that should be returned. Must be greater than 0.
* @return array Array of modules.
* @return next Start of the next page.
*/
function getModulesPaginated(address start, uint256 pageSize)
external
view
returns (address[] memory array, address next);
/**
* @notice Set Module Guard `moduleGuard` for the Safe. Make sure you trust the module guard.
* @dev Set a module guard that checks transactions initiated by the module before and after execution.
* This can only be done via a Safe transaction.
* ⚠️⚠️⚠️ IMPORTANT: Since a module guard has full power to block Safe transaction execution initiated via a
* module, a broken module guard can cause a denial of service for the Safe modules. Make sure to carefully
* audit the module guard code and design recovery mechanisms. ⚠️⚠️⚠️
* @param moduleGuard The address of the module guard to be used or the zero address to disable the module guard.
*/
function setModuleGuard(address moduleGuard) external;
}
src/interfaces/ISafe.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;
import {Enum} from "./../interfaces/Enum.sol";
import {IModuleManager} from "./IModuleManager.sol";
// NOTE: Trimmed from safe-global/safe-smart-account's ISafe. The upstream interface
// also inherits IFallbackManager, IGuardManager, INativeCurrencyPaymentFallback,
// IOwnerManager and IStorageAccessible; those are omitted here as this module only
// uses the module-execution surface from IModuleManager.
/**
* @title Safe Interface
* @notice A multi-signature wallet with support for confirmations using signed messages based on EIP-712.
* @dev This is a Solidity interface definition to the Safe account.
* @author @safe-global/safe-protocol
*/
interface ISafe is IModuleManager {
event SafeSetup(
address indexed initiator, address[] owners, uint256 threshold, address initializer, address fallbackHandler
);
event ApproveHash(bytes32 indexed approvedHash, address indexed owner);
event SignMsg(bytes32 indexed msgHash);
event ExecutionFailure(bytes32 indexed txHash, uint256 payment);
event ExecutionSuccess(bytes32 indexed txHash, uint256 payment);
function setup(
address[] calldata _owners,
uint256 _threshold,
address to,
bytes calldata data,
address fallbackHandler,
address paymentToken,
uint256 payment,
address payable paymentReceiver
) external;
function execTransaction(
address to,
uint256 value,
bytes calldata data,
Enum.Operation operation,
uint256 safeTxGas,
uint256 baseGas,
uint256 gasPrice,
address gasToken,
address payable refundReceiver,
bytes memory signatures
) external payable returns (bool success);
function checkSignatures(address executor, bytes32 dataHash, bytes memory signatures) external view;
function checkNSignatures(address executor, bytes32 dataHash, bytes memory signatures, uint256 requiredSignatures)
external
view;
function approveHash(bytes32 hashToApprove) external;
function domainSeparator() external view returns (bytes32);
function getTransactionHash(
address to,
uint256 value,
bytes calldata data,
Enum.Operation operation,
uint256 safeTxGas,
uint256 baseGas,
uint256 gasPrice,
address gasToken,
address refundReceiver,
uint256 _nonce
) external view returns (bytes32);
function VERSION() external view returns (string memory);
function nonce() external view returns (uint256);
function signedMessages(bytes32 messageHash) external view returns (uint256);
function approvedHashes(address owner, bytes32 messageHash) external view returns (uint256);
}
Compiler settingsShow
{
"viaIR": false,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "prague",
"remappings": [
"forge-std/=lib/forge-std/src/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.