Verified contractExactBUSL-1.1
OpenVault
Address0xa0f1d1b1382fa47c827a5ee45415267b97b4cd7a
- Balance
0 ETH
- Transactions
7
- Compiler
solc 0.8.28
- Same code
Only this contract
Details
- Compiler
- solc 0.8.28+commit.7893614a
- Language
- solidity
- Optimization
- Yes, 20,000 runs
- EVM version
- cancun
- License
- BUSL-1.1
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,351,668
- Creation transaction
- 0xd14db66b9e…64e42ebfa3
2 files
- src/OpenVault.solmain4.34 KB
- src/Roles.sol2.09 KB
src/OpenVault.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.28;
import {Roles} from "./Roles.sol";
/// @title OpenVault
/// @notice The Open[] ledger. One ERC-6909 contract; the token id is the ISO 4217
/// numeric code (840 OpenUSD, 978 OpenEUR, 484 OpenMXN). 6 decimals for every id.
/// Balances are non-transferable: holders cannot send them. Only the Router changes
/// supply (mint/burn) and only authorised movers (the SwapPool) move balances.
contract OpenVault is Roles {
uint8 public constant decimals = 6;
mapping(address owner => mapping(uint256 id => uint256)) public balanceOf;
mapping(uint256 id => uint256) public totalSupply;
address public router;
mapping(address => bool) public isMover;
/// @notice Movers that still work during a pause: the SupplyBook, so suppliers can withdraw and collect
/// fees while the protocol is paused (PRD Earn §5.7). It refuses new supply itself while paused.
mapping(address => bool) public isExitMover;
/// @dev ERC-6909 Transfer event (also used for mint and burn with address(0)).
event Transfer(address caller, address indexed sender, address indexed receiver, uint256 indexed id, uint256 amount);
event RouterSet(address indexed router);
event MoverSet(address indexed mover, bool allowed);
event ExitMoverSet(address indexed mover, bool allowed);
error NotRouter();
error NotMover();
error TransfersDisabled();
error InsufficientBalance();
constructor(address admin_, address guardian_) Roles(admin_, guardian_) {}
// ---------- admin ----------
function setRouter(address r) external onlyAdmin {
router = r;
emit RouterSet(r);
}
function setMover(address m, bool allowed) external onlyAdmin {
isMover[m] = allowed;
emit MoverSet(m, allowed);
}
function setExitMover(address m, bool allowed) external onlyAdmin {
isExitMover[m] = allowed;
emit ExitMoverSet(m, allowed);
}
// ---------- supply (Router only) ----------
function mint(address to, uint256 id, uint256 amount) external whenNotPaused {
if (msg.sender != router) revert NotRouter();
totalSupply[id] += amount;
balanceOf[to][id] += amount;
emit Transfer(msg.sender, address(0), to, id, amount);
}
/// @dev Not pausable: burning only ever backs a withdrawal, which must work during a pause.
function burn(address from, uint256 id, uint256 amount) external {
if (msg.sender != router) revert NotRouter();
uint256 bal = balanceOf[from][id];
if (bal < amount) revert InsufficientBalance();
unchecked {
balanceOf[from][id] = bal - amount;
totalSupply[id] -= amount;
}
emit Transfer(msg.sender, from, address(0), id, amount);
}
// ---------- movement (SwapPool only) ----------
function move(address from, address to, uint256 id, uint256 amount) external {
if (!isMover[msg.sender]) revert NotMover();
if (paused && !isExitMover[msg.sender]) revert IsPaused();
uint256 bal = balanceOf[from][id];
if (bal < amount) revert InsufficientBalance();
unchecked {
balanceOf[from][id] = bal - amount;
}
balanceOf[to][id] += amount;
emit Transfer(msg.sender, from, to, id, amount);
}
// ---------- ERC-6909 surface: holder transfers are off ----------
function transfer(address, uint256, uint256) external pure returns (bool) {
revert TransfersDisabled();
}
function transferFrom(address, address, uint256, uint256) external pure returns (bool) {
revert TransfersDisabled();
}
function approve(address, uint256, uint256) external pure returns (bool) {
revert TransfersDisabled();
}
function setOperator(address, bool) external pure returns (bool) {
revert TransfersDisabled();
}
function allowance(address, address, uint256) external pure returns (uint256) {
return 0;
}
function isOperator(address, address) external pure returns (bool) {
return false;
}
function supportsInterface(bytes4 interfaceId) external pure returns (bool) {
return interfaceId == 0x01ffc9a7 // ERC-165
|| interfaceId == 0x0f632fb3; // ERC-6909
}
}
src/Roles.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.28;
/// @notice Minimal two-role access for the prototype: an admin (the Admin Safe on
/// Sepolia and mainnet, behind the 48h timelock in the pilot build) and a guardian
/// that can only pause. Replaced by OpenZeppelin AccessManager in the pilot build.
abstract contract Roles {
address public admin;
address public pendingAdmin;
address public guardian;
bool public paused;
event AdminTransferStarted(address indexed from, address indexed to);
event AdminTransferred(address indexed from, address indexed to);
event GuardianSet(address indexed guardian);
event Paused(address indexed by);
event Unpaused(address indexed by);
error NotAdmin();
error NotGuardian();
error IsPaused();
error ZeroAddress();
constructor(address admin_, address guardian_) {
if (admin_ == address(0)) revert ZeroAddress();
admin = admin_;
guardian = guardian_;
emit AdminTransferred(address(0), admin_);
emit GuardianSet(guardian_);
}
modifier onlyAdmin() {
if (msg.sender != admin) revert NotAdmin();
_;
}
modifier whenNotPaused() {
if (paused) revert IsPaused();
_;
}
function transferAdmin(address to) external onlyAdmin {
pendingAdmin = to;
emit AdminTransferStarted(admin, to);
}
function acceptAdmin() external {
if (msg.sender != pendingAdmin) revert NotAdmin();
emit AdminTransferred(admin, msg.sender);
admin = msg.sender;
pendingAdmin = address(0);
}
function setGuardian(address g) external onlyAdmin {
guardian = g;
emit GuardianSet(g);
}
/// @notice Guardian or admin can pause. Only the admin can unpause.
function pause() external {
if (msg.sender != guardian && msg.sender != admin) revert NotGuardian();
paused = true;
emit Paused(msg.sender);
}
function unpause() external onlyAdmin {
paused = false;
emit Unpaused(msg.sender);
}
}
Compiler settingsShow
{
"viaIR": false,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"libraries": {},
"optimizer": {
"runs": 20000,
"enabled": true
},
"evmVersion": "cancun",
"remappings": [
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"forge-std/=lib/forge-std/src/",
"ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.