Description:
Smart contract deployed on Ethereum with Factory features.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"CosigoGuardian.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
import {ICosigoGuardian} from "./ICosigoGuardian.sol";
import {ICosigoSatellite} from "./ICosigoSatellite.sol";
contract CosigoGuardian is ICosigoGuardian {
address public owner;
// Global signals
bool private _marketOpen = true;
bool private _eoaOnly = false;
// Global caps (modifiable by owner)
uint16 private _maxGuardianFeeBps = 100; // 1.00%
uint16 private _maxMaintenanceFeeBps = 200; // 2.00%
uint16 private _maxRedemptionFeeBps = 2000; // 20.0%
uint16 private _maxPremiumBps = 1000; // 10.0%
// Per-satellite config
mapping(address => bool) public approvedSatellite;
mapping(address => address) public feeSink; // sat -> sink
mapping(address => uint16) public guardianFeeBps; // sat -> bps
// Slug registry: keccak256(slug) -> satellite
mapping(bytes32 => address) public satelliteBySlug;
// Optional allowlist of slugs (owner pre-approves)
mapping(bytes32 => bool) public allowedSlug;
// Timelock config (owner-only changes gated by delay)
uint32 public timelockSeconds = 0; // set >0 to enable
mapping(bytes32 => uint64) public eta; // actionId -> earliest time
// ---- Events ----
event OwnershipTransferred(address indexed prev, address indexed next);
event SatelliteApproved(address sat, bool approved);
event SatelliteFeeConfigured(address sat, address sink, uint16 bps);
event SatelliteRegistered(bytes32 indexed slugHash, string slug, address sat);
event SlugAllowed(bytes32 indexed slugHash, string slug, bool allowed);
event MarketOpenSet(bool open);
event EoaOnlySet(bool enabled);
event MaxGuardianFeeSet(uint16 bps);
event MaxMaintenanceFeeSet(uint16 bps);
event MaxRedemptionFeeSet(uint16 bps);
event MaxPremiumFeeSet(uint16 bps);
event TimelockSet(uint32 seconds_);
modifier onlyOwner() {
require(msg.sender == owner, "CosigoGuardian: not owner");
_;
}
constructor(address _owner) {
owner = _owner;
emit OwnershipTransferred(address(0), _owner);
}
// -------- I/F views --------
function isSatelliteApproved(address sat) external view returns (bool) { return approvedSatellite[sat]; }
function feeSinkOf(address sat) external view returns (address) { return feeSink[sat]; }
function guardianFeeBpsOf(address sat) external view returns (uint16) { return guardianFeeBps[sat]; }
function isMarketOpen() external view returns (bool) { return _marketOpen; }
function eoaOnlyEnabled() external view returns (bool) { return _eoaOnly; }
function maxGuardianFeeBps() external view returns (uint16) { return _maxGuardianFeeBps; }
function maxMaintenanceFeeBps() external view returns (uint16) { return _maxMaintenanceFeeBps; }
function maxRedemptionFeeBps() external view returns (uint16) { return _maxRedemptionFeeBps; }
function maxPremiumBps() external view returns (uint16) { return _maxPremiumBps; }
// -------- Timelock internals --------
function _queue(bytes32 actionId) internal {
if (timelockSeconds == 0) return;
eta[actionId] = uint64(block.timestamp) + timelockSeconds;
}
function _check(bytes32 actionId) internal view {
if (timelockSeconds == 0) return;
require(eta[actionId] != 0 && block.timestamp >= eta[actionId], "CG: timelock not ready");
}
function _clear(bytes32 actionId) internal {
if (timelockSeconds == 0) return;
delete eta[actionId];
}
// -------- Owner ops (timelockable) --------
function setTimelock(uint32 seconds_) external onlyOwner {
timelockSeconds = seconds_;
emit TimelockSet(seconds_);
}
function transferOwnership(address next) external onlyOwner {
bytes32 id = keccak256(abi.encode("transferOwnership", next));
_queue(id); _check(id);
address prev = owner;
owner = next;
_clear(id);
emit OwnershipTransferred(prev, next);
}
function setMarketOpen(bool open_) external onlyOwner {
bytes32 id = keccak256(abi.encode("setMarketOpen", open_));
_queue(id); _check(id);
_marketOpen = open_;
_clear(id);
emit MarketOpenSet(open_);
}
function setEoaOnly(bool on) external onlyOwner {
bytes32 id = keccak256(abi.encode("setEoaOnly", on));
_queue(id); _check(id);
_eoaOnly = on;
_clear(id);
emit EoaOnlySet(on);
}
function setMaxGuardianFeeBps(uint16 bps) external onlyOwner {
bytes32 id = keccak256(abi.encode("setMaxGuardianFeeBps", bps));
_queue(id); _check(id);
_maxGuardianFeeBps = bps;
_clear(id);
emit MaxGuardianFeeSet(bps);
}
function setMaxMaintenanceFeeBps(uint16 bps) external onlyOwner {
bytes32 id = keccak256(abi.encode("setMaxMaintenanceFeeBps", bps));
_queue(id); _check(id);
_maxMaintenanceFeeBps = bps;
_clear(id);
emit MaxMaintenanceFeeSet(bps);
}
function setMaxRedemptionFeeBps(uint16 bps) external onlyOwner {
bytes32 id = keccak256(abi.encode("setMaxRedemptionFeeBps", bps));
_queue(id); _check(id);
_maxRedemptionFeeBps = bps;
_clear(id);
emit MaxRedemptionFeeSet(bps);
}
function setMaxPremiumBps(uint16 bps) external onlyOwner {
bytes32 id = keccak256(abi.encode("setMaxPremiumBps", bps));
_queue(id); _check(id);
_maxPremiumBps = bps;
_clear(id);
emit MaxPremiumFeeSet(bps);
}
// -------- Slug allow/registry & satellite config --------
function setSlugAllowed(string calldata slug, bool allowed) external onlyOwner {
bytes32 h = keccak256(bytes(slug));
allowedSlug[h] = allowed;
emit SlugAllowed(h, slug, allowed);
}
function registerSatellite(address sat, string calldata slug, address sink, uint16 feeBps) external onlyOwner {
bytes32 h = keccak256(bytes(slug));
require(allowedSlug[h], "CG: slug not allowed");
require(satelliteBySlug[h] == address(0), "CG: slug taken");
require(ICosigoSatellite(sat).slugHash() == h, "CG: slug mismatch");
satelliteBySlug[h] = sat;
approvedSatellite[sat] = true;
emit SatelliteRegistered(h, slug, sat);
configureSatelliteFee(sat, sink, feeBps);
}
function approveSatellite(address sat, bool ok) external onlyOwner {
approvedSatellite[sat] = ok;
emit SatelliteApproved(sat, ok);
}
function configureSatelliteFee(address sat, address sink, uint16 bps) public onlyOwner {
require(approvedSatellite[sat], "CG: not approved");
require(bps <= _maxGuardianFeeBps, "CG: fee too high");
feeSink[sat] = sink;
guardianFeeBps[sat] = bps;
emit SatelliteFeeConfigured(sat, sink, bps);
}
}"
},
"ICosigoSatellite.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
interface ICosigoSatellite {
function slug() external view returns (string memory);
function slugHash() external view returns (bytes32);
}"
},
"ICosigoGuardian.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
interface ICosigoGuardian {
// Per-satellite policy
function isSatelliteApproved(address sat) external view returns (bool);
function feeSinkOf(address sat) external view returns (address);
function guardianFeeBpsOf(address sat) external view returns (uint16);
// Global signals
function isMarketOpen() external view returns (bool);
function eoaOnlyEnabled() external view returns (bool);
// Global caps
function maxGuardianFeeBps() external view returns (uint16);
function maxMaintenanceFeeBps() external view returns (uint16);
function maxRedemptionFeeBps() external view returns (uint16);
function maxPremiumBps() external view returns (uint16);
// Registry helpers
function satelliteBySlug(bytes32 slugHash) external view returns (address);
}"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 500
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"abi"
]
}
},
"remappings": []
}
}}
Submitted on: 2025-09-30 17:59:32
Comments
Log in to comment.
No comments yet.