Verified contractExactMIT
BarkMultisigV2
Address0x52edcfbc48af1b74bbf1a476c347aa97c6dc84a0
- Balance
0 ETH
- Transactions
56
- Compiler
solc 0.8.20
- Same code
Only this contract
Details
- Compiler
- solc 0.8.20+commit.a1b79de6
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- paris
- Via IR
- yes
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 24,993,067
- Creation transaction
- 0xde891668fe…18bc204f67
2 files
contracts/v2/BarkMultisigV2.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "./interfaces/IBarkcoinVBARKX.sol";
contract BarkMultisigV2 {
address public admin1;
address public admin2;
address public admin3;
IBarkcoinVBARKX public vbarkxContract;
mapping(bytes32 => mapping(address => bool)) public approvals;
bytes32 public currentPendingAction;
event AdminChanged(address oldAdmin, address newAdmin, uint256 adminIndex);
event ActionApproved(bytes32 indexed actionId, address indexed admin);
event ActionExecuted(bytes32 indexed actionId);
modifier onlyAdmins() {
require(
msg.sender == admin1 || msg.sender == admin2 || msg.sender == admin3,
"Not an admin"
);
_;
}
constructor(
address _admin1,
address _admin2,
address _admin3,
address _vbarkxContract
) {
require(_admin1 != address(0) && _admin2 != address(0) && _admin3 != address(0), "Invalid admin");
require(_admin1 != _admin2 && _admin1 != _admin3 && _admin2 != _admin3, "Duplicate admins");
admin1 = _admin1;
admin2 = _admin2;
admin3 = _admin3;
vbarkxContract = IBarkcoinVBARKX(_vbarkxContract);
}
// ===================== Internal helpers =====================
function _clearPreviousPendingAction(bytes32 actionId) internal {
if (actionId != currentPendingAction && currentPendingAction != bytes32(0)) {
approvals[currentPendingAction][admin1] = false;
approvals[currentPendingAction][admin2] = false;
approvals[currentPendingAction][admin3] = false;
currentPendingAction = bytes32(0);
}
currentPendingAction = actionId;
}
function _resetPendingAction(bytes32 actionId) internal {
approvals[actionId][admin1] = false;
approvals[actionId][admin2] = false;
approvals[actionId][admin3] = false;
currentPendingAction = bytes32(0);
}
function _getApprovalCount(bytes32 actionId) internal view returns (uint256 count) {
if (approvals[actionId][admin1]) count++;
if (approvals[actionId][admin2]) count++;
if (approvals[actionId][admin3]) count++;
}
// ===================== Single-sig operations =====================
function closeOrders(uint256[] calldata orderIds) external onlyAdmins {
vbarkxContract.closeOrders(orderIds);
}
// ===================== Multi-sig operations (2/3) =====================
function withdrawBark(uint256[] calldata orderIds, address to) external onlyAdmins {
require(to != address(0), "Invalid to address");
bytes32 actionId = keccak256(abi.encodePacked("withdrawBark", abi.encode(orderIds), to));
_clearPreviousPendingAction(actionId);
approvals[actionId][msg.sender] = true;
emit ActionApproved(actionId, msg.sender);
if (_getApprovalCount(actionId) >= 2) {
vbarkxContract.withdrawBark(orderIds, to);
_resetPendingAction(actionId);
emit ActionExecuted(actionId);
}
}
function changeVBARKXAdmin(address newAdmin) external onlyAdmins {
require(newAdmin != address(0), "Invalid new admin");
bytes32 actionId = keccak256(abi.encodePacked("changeVBARKXAdmin", newAdmin));
_clearPreviousPendingAction(actionId);
approvals[actionId][msg.sender] = true;
emit ActionApproved(actionId, msg.sender);
if (_getApprovalCount(actionId) >= 2) {
vbarkxContract.changeAdmin(newAdmin);
_resetPendingAction(actionId);
emit ActionExecuted(actionId);
}
}
function changeAdmin(address newAdmin, uint256 adminIndex) external onlyAdmins {
require(adminIndex >= 1 && adminIndex <= 3, "Invalid admin index");
require(newAdmin != address(0), "Invalid new admin");
require(
newAdmin != admin1 && newAdmin != admin2 && newAdmin != admin3,
"New admin already exists"
);
bytes32 actionId = keccak256(abi.encodePacked("changeAdmin", newAdmin, adminIndex));
_clearPreviousPendingAction(actionId);
approvals[actionId][msg.sender] = true;
emit ActionApproved(actionId, msg.sender);
if (_getApprovalCount(actionId) >= 2) {
address oldAdmin;
if (adminIndex == 1) {
oldAdmin = admin1;
admin1 = newAdmin;
} else if (adminIndex == 2) {
oldAdmin = admin2;
admin2 = newAdmin;
} else {
oldAdmin = admin3;
admin3 = newAdmin;
}
_resetPendingAction(actionId);
emit AdminChanged(oldAdmin, newAdmin, adminIndex);
emit ActionExecuted(actionId);
}
}
function setMinBarkAmount(uint256 newAmount) external onlyAdmins {
bytes32 actionId = keccak256(abi.encodePacked("setMinBarkAmount", newAmount));
_clearPreviousPendingAction(actionId);
approvals[actionId][msg.sender] = true;
emit ActionApproved(actionId, msg.sender);
if (_getApprovalCount(actionId) >= 2) {
vbarkxContract.setMinBarkAmount(newAmount);
_resetPendingAction(actionId);
emit ActionExecuted(actionId);
}
}
}
contracts/v2/interfaces/IBarkcoinVBARKX.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IBarkcoinVBARKX {
struct Order {
uint256 orderId;
uint256 blockNumber;
uint256 timestamp;
address sourceAddress;
address targetAddress;
uint256 barkAmount;
uint256 vbarkxAmount;
uint8 status; // 0: pending, 1: completed
bool withdrawn; // true if BARK has been withdrawn by admin
}
event OrderCreated(
uint256 indexed orderId,
address indexed sourceAddress,
address indexed targetAddress,
uint256 barkAmount,
uint256 vbarkxAmount,
uint256 timestamp
);
event OrderClosed(uint256 indexed orderId);
event MinBarkAmountChanged(uint256 oldAmount, uint256 newAmount);
function createOrder(address targetAddress, uint256 barkAmount) external;
function closeOrders(uint256[] calldata orderIds) external;
function withdrawBark(uint256[] calldata orderIds, address to) external;
function getOrder(uint256 orderId) external view returns (Order memory);
function getUserOrders(address user) external view returns (uint256[] memory);
function getPendingOrderCount(address user) external view returns (uint256);
function getAllOrders(uint256 offset, uint256 limit) external view returns (uint256[] memory);
function orderCount() external view returns (uint256);
function changeAdmin(address newAdmin) external;
function setMinBarkAmount(uint256 newAmount) external;
}
Compiler settingsShow
{
"viaIR": true,
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "paris"
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.