-
Notifications
You must be signed in to change notification settings - Fork 2
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 #70 from valory-xyz/service_reward
refactor: reward function for protocol-owned services
- Loading branch information
Showing
8 changed files
with
82 additions
and
44 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 |
---|---|---|
|
@@ -6,16 +6,23 @@ import "@openzeppelin/contracts/security/Pausable.sol"; | |
import "./interfaces/IErrors.sol"; | ||
import "./interfaces/IStructs.sol"; | ||
import "./interfaces/IService.sol"; | ||
import "./interfaces/ITreasury.sol"; | ||
|
||
/// @title Service Manager - Periphery smart contract for managing services | ||
/// @author Aleksandr Kuperman - <[email protected]> | ||
contract ServiceManager is IErrors, IStructs, Ownable, Pausable { | ||
event TreasuryUpdated(address treasury); | ||
event MultisigCreate(address multisig); | ||
event RewardService(uint256 serviceId, uint256 amount); | ||
|
||
// Service registry address | ||
address public immutable serviceRegistry; | ||
// Treasury address | ||
address public treasury; | ||
|
||
constructor(address _serviceRegistry) { | ||
constructor(address _serviceRegistry, address _treasury) { | ||
serviceRegistry = _serviceRegistry; | ||
treasury = _treasury; | ||
} | ||
|
||
/// @dev Fallback function | ||
|
@@ -28,6 +35,13 @@ contract ServiceManager is IErrors, IStructs, Ownable, Pausable { | |
revert WrongFunction(); | ||
} | ||
|
||
/// @dev Changes the treasury address. | ||
/// @param newTreasury Address of a new treasury. | ||
function changeTreasury(address newTreasury) external onlyOwner { | ||
treasury = newTreasury; | ||
emit TreasuryUpdated(newTreasury); | ||
} | ||
|
||
/// @dev Creates a new service. | ||
/// @param owner Individual that creates and controls a service. | ||
/// @param name Name of the service. | ||
|
@@ -130,6 +144,14 @@ contract ServiceManager is IErrors, IStructs, Ownable, Pausable { | |
success = IService(serviceRegistry).destroy(msg.sender, serviceId); | ||
} | ||
|
||
/// @dev Rewards the protocol-owned service with an ETH payment. | ||
/// @param serviceId Service Id. | ||
function serviceReward(uint256 serviceId) external payable | ||
{ | ||
ITreasury(treasury).depositETHFromService{value: msg.value}(serviceId); | ||
emit RewardService(serviceId, msg.value); | ||
} | ||
|
||
/// @dev Pauses the contract. | ||
function pause() external onlyOwner { | ||
_pause(); | ||
|
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
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
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
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
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
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
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