-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from morpho-org/feat/interface
feat(ifc): add urd factory ifc
- Loading branch information
Showing
2 changed files
with
39 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity 0.8.19; | ||
|
||
import {IUrdFactory} from "./interfaces/IUrdFactory.sol"; | ||
import {IUniversalRewardsDistributor} from "./interfaces/IUniversalRewardsDistributor.sol"; | ||
|
||
import {EventsLib} from "./libraries/EventsLib.sol"; | ||
|
||
import {UniversalRewardsDistributor} from "./UniversalRewardsDistributor.sol"; | ||
|
@@ -9,28 +12,26 @@ import {UniversalRewardsDistributor} from "./UniversalRewardsDistributor.sol"; | |
/// @author Morpho Labs | ||
/// @custom:contact [email protected] | ||
/// @notice This contract allows to create UniversalRewardsDistributor (URD) contracts, and to index them easily. | ||
contract UrdFactory { | ||
contract UrdFactory is IUrdFactory { | ||
/* STORAGE */ | ||
|
||
mapping(address => bool) public isUrd; | ||
|
||
/* EXTERNAL */ | ||
|
||
/// @notice Creates a new URD contract using CREATE2 opcode. | ||
/// @param initialOwner The initial owner of the URD. | ||
/// @param initialTimelock The initial timelock of the URD. | ||
/// @param initialRoot The initial merkle root of the URD. | ||
/// @param initialIpfsHash The optional ipfs hash containing metadata about the root (e.g. the merkle tree itself). | ||
/// @param salt The salt used for CREATE2 opcode. | ||
/// @return urd The address of the newly created URD. | ||
/// @inheritdoc IUrdFactory | ||
function createUrd( | ||
address initialOwner, | ||
uint256 initialTimelock, | ||
bytes32 initialRoot, | ||
bytes32 initialIpfsHash, | ||
bytes32 salt | ||
) public returns (UniversalRewardsDistributor urd) { | ||
urd = new UniversalRewardsDistributor{salt: salt}(initialOwner, initialTimelock, initialRoot, initialIpfsHash); | ||
) public returns (IUniversalRewardsDistributor urd) { | ||
urd = IUniversalRewardsDistributor( | ||
address( | ||
new UniversalRewardsDistributor{salt: salt}(initialOwner, initialTimelock, initialRoot, initialIpfsHash) | ||
) | ||
); | ||
|
||
isUrd[address(urd)] = true; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity >=0.5.0; | ||
|
||
import {IUniversalRewardsDistributor} from "./IUniversalRewardsDistributor.sol"; | ||
|
||
/// @title IUrdFactory | ||
/// @author Morpho Labs | ||
/// @custom:contact [email protected] | ||
/// @notice Interface of UniversalRewardsDistributor's factory. | ||
interface IUrdFactory { | ||
/// @notice Whether a UniversalRewardsDistributor was created with the factory. | ||
function isUrd(address target) external view returns (bool); | ||
|
||
/// @notice Creates a new URD contract using CREATE2 opcode. | ||
/// @param initialOwner The initial owner of the URD. | ||
/// @param initialTimelock The initial timelock of the URD. | ||
/// @param initialRoot The initial merkle root of the URD. | ||
/// @param initialIpfsHash The optional ipfs hash containing metadata about the root (e.g. the merkle tree itself). | ||
/// @param salt The salt used for CREATE2 opcode. | ||
/// @return The address of the newly created URD. | ||
function createUrd( | ||
address initialOwner, | ||
uint256 initialTimelock, | ||
bytes32 initialRoot, | ||
bytes32 initialIpfsHash, | ||
bytes32 salt | ||
) external returns (IUniversalRewardsDistributor); | ||
} |