// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/access/AccessControl.sol";
import {IAtomicFulfillerRegistry} from "./interfaces/IAtomicFulfillerRegistry.sol";

contract AtomicSlashingManager is AccessControl {
    bytes32 public constant COORDINATOR_ROLE = keccak256("COORDINATOR_ROLE");

    IAtomicFulfillerRegistry public immutable fulfillerRegistry;

    event ObligationSlashed(bytes32 indexed obligationId, address indexed recipient, bytes32 indexed reason, uint256 amount);

    constructor(address fulfillerRegistry_, address admin) {
        fulfillerRegistry = IAtomicFulfillerRegistry(fulfillerRegistry_);
        _grantRole(DEFAULT_ADMIN_ROLE, admin);
    }

    function slash(bytes32 obligationId, address recipient, bytes32 reason)
        external
        onlyRole(COORDINATOR_ROLE)
        returns (uint256 amount)
    {
        amount = fulfillerRegistry.slashBond(obligationId, recipient);
        emit ObligationSlashed(obligationId, recipient, reason, amount);
    }
}
