Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add owner #43

Merged
merged 8 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/Blue.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {IOracle} from "src/interfaces/IOracle.sol";
import {MathLib} from "src/libraries/MathLib.sol";
import {SafeTransferLib} from "src/libraries/SafeTransferLib.sol";

import {Owned} from "src/dependencies/Owned.sol";

uint constant WAD = 1e18;

uint constant alpha = 0.5e18;
Expand All @@ -29,7 +31,7 @@ function irm(uint utilization) pure returns (uint) {
return utilization / 365 days;
}

contract Blue {
contract Blue is Owned {
using MathLib for uint;
using SafeTransferLib for IERC20;

Expand All @@ -52,6 +54,8 @@ contract Blue {
// Interests last update (used to check if a market has been created).
mapping(Id => uint) public lastUpdate;

constructor(address owner) Owned(owner) {}

// Markets management.

function createMarket(Market calldata market) external {
Expand Down
44 changes: 44 additions & 0 deletions src/dependencies/Owned.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

/// @notice Simple single owner authorization mixin.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Owned.sol)
abstract contract Owned {
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/

event OwnershipTransferred(address indexed user, address indexed newOwner);

/*//////////////////////////////////////////////////////////////
OWNERSHIP STORAGE
//////////////////////////////////////////////////////////////*/

address public owner;

modifier onlyOwner() virtual {
require(msg.sender == owner, "UNAUTHORIZED");

_;
}

/*//////////////////////////////////////////////////////////////
CONSTRUCTOR
//////////////////////////////////////////////////////////////*/

constructor(address _owner) {
owner = _owner;

emit OwnershipTransferred(address(0), _owner);
}

/*//////////////////////////////////////////////////////////////
OWNERSHIP LOGIC
//////////////////////////////////////////////////////////////*/

function transferOwnership(address newOwner) public virtual onlyOwner {
owner = newOwner;

emit OwnershipTransferred(msg.sender, newOwner);
}
}