-
Notifications
You must be signed in to change notification settings - Fork 15
/
Coordinator.sol
50 lines (42 loc) · 1.85 KB
/
Coordinator.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.24;
import { Ownable } from "@equilibria/root/attribute/Ownable.sol";
import { ICoordinator, IMarket, RiskParameter, Token18 } from "./interfaces/ICoordinator.sol";
/// @title Coordinator
/// @notice Manages claiming fees and updating risk parameters for markets
contract Coordinator is ICoordinator, Ownable {
/// @dev The address of the comptroller (who can claim the fee)
address public comptroller;
/// @dev The address of the coordinator (who can update risk parameters)
address public coordinator;
/// @notice Constructs the contract
constructor() {
__Ownable__initialize();
}
/// @notice Updates the comptroller
/// @param comptroller_ The address of the new comptroller
function setComptroller(address comptroller_) external onlyOwner {
comptroller = comptroller_;
emit ComptrollerSet(comptroller_);
}
/// @notice Updates the coordinator
/// @param coordinator_ The address of the new coordinator
function setCoordinator(address coordinator_) external onlyOwner {
coordinator = coordinator_;
emit CoordinatorSet(coordinator_);
}
/// @notice Claims the fee for a market
/// @param market The market to claim the fee for
function claimFee(IMarket market) external {
if (msg.sender != comptroller) revert NotComptroller();
market.claimFee(address(this));
market.token().push(comptroller);
}
/// @notice Updates the risk parameter for a market
/// @param market The market to update the risk parameter for
/// @param riskParameter The new risk parameter
function updateRiskParameter(IMarket market, RiskParameter calldata riskParameter) external {
if (msg.sender != coordinator) revert NotCoordinator();
market.updateRiskParameter(riskParameter);
}
}