generated from defi-wonderland/solidity-foundry-boilerplate
-
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 branch 'dev' into test/handler-cov
- Loading branch information
Showing
26 changed files
with
972 additions
and
341 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity 0.8.26; | ||
|
||
import { | ||
IAccessModule, | ||
IArbitrable, | ||
IEBOAccessModule, | ||
IHorizonAccountingExtension, | ||
IHorizonStaking, | ||
IOracle | ||
} from 'interfaces/IEBOAccessModule.sol'; | ||
|
||
import {IModule, Module} from '@defi-wonderland/prophet-core/solidity/contracts/Module.sol'; | ||
|
||
contract EBOAccessModule is IEBOAccessModule, Module { | ||
/// @inheritdoc IEBOAccessModule | ||
IArbitrable public immutable ARBITRABLE; | ||
/// @inheritdoc IEBOAccessModule | ||
IHorizonStaking public horizonStaking; | ||
/// @inheritdoc IEBOAccessModule | ||
IHorizonAccountingExtension public horizonAccountingExtension; | ||
|
||
/** | ||
* @notice Constructor | ||
* @param _oracle The address of the Oracle | ||
* @param _arbitrable The address of the Arbitrable contract | ||
* @param _horizonAccountingExtension The address of the Horizon Accounting Extension contract | ||
*/ | ||
constructor( | ||
IOracle _oracle, | ||
IArbitrable _arbitrable, | ||
IHorizonAccountingExtension _horizonAccountingExtension | ||
) Module(_oracle) { | ||
ARBITRABLE = _arbitrable; | ||
_setHorizonAccountingExtension(_horizonAccountingExtension); | ||
} | ||
|
||
/// @inheritdoc IAccessModule | ||
function decodeAccessControlParameters(bytes calldata _data) | ||
public | ||
pure | ||
returns (IAccessModule.AccessControlParameters memory _params) | ||
{ | ||
_params = abi.decode(_data, (IAccessModule.AccessControlParameters)); | ||
} | ||
|
||
/// @inheritdoc IAccessModule | ||
function hasAccess(bytes calldata _data) external view returns (bool _hasAccess) { | ||
IAccessModule.AccessControlParameters memory _params = decodeAccessControlParameters(_data); | ||
_hasAccess = | ||
horizonStaking.isAuthorized(_params.accessControl.user, address(horizonAccountingExtension), _params.sender); | ||
} | ||
|
||
/// @inheritdoc IEBOAccessModule | ||
function setHorizonAccountingExtension(IHorizonAccountingExtension _horizonAccountingExtension) external { | ||
ARBITRABLE.validateArbitrator(msg.sender); | ||
|
||
_setHorizonAccountingExtension(_horizonAccountingExtension); | ||
} | ||
|
||
/// @inheritdoc IModule | ||
function moduleName() external pure returns (string memory _moduleName) { | ||
_moduleName = 'EBOAccessModule'; | ||
} | ||
|
||
/** | ||
* @notice Internal function to set the horizon accounting extension contract. | ||
* @dev It also updates the `horizonStaking` address. | ||
* @param _horizonAccountingExtension The new horizon accounting extension contract. | ||
*/ | ||
function _setHorizonAccountingExtension(IHorizonAccountingExtension _horizonAccountingExtension) internal { | ||
horizonAccountingExtension = _horizonAccountingExtension; | ||
|
||
// also update horizon staking address using the accounting extension view function | ||
horizonStaking = _horizonAccountingExtension.HORIZON_STAKING(); | ||
|
||
emit HorizonAccountingExtensionSet(_horizonAccountingExtension); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity 0.8.26; | ||
|
||
import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; | ||
import {IAccessModule} from '@defi-wonderland/prophet-core/solidity/interfaces/modules/access/IAccessModule.sol'; | ||
|
||
import {IHorizonAccountingExtension} from 'interfaces/IHorizonAccountingExtension.sol'; | ||
|
||
import {IHorizonStaking} from 'interfaces/external/IHorizonStaking.sol'; | ||
|
||
import {IArbitrable} from 'interfaces/IArbitrable.sol'; | ||
|
||
interface IEBOAccessModule is IAccessModule { | ||
/*/////////////////////////////////////////////////////////////// | ||
EVENTS | ||
//////////////////////////////////////////////////////////////*/ | ||
|
||
/** | ||
* @notice Emitted when the Horizon Accounting Extension contract is set | ||
* @param _horizonAccountingExtension The new Horizon Accounting Extension contract | ||
*/ | ||
event HorizonAccountingExtensionSet(IHorizonAccountingExtension indexed _horizonAccountingExtension); | ||
|
||
/*/////////////////////////////////////////////////////////////// | ||
VARIABLES | ||
//////////////////////////////////////////////////////////////*/ | ||
|
||
/** | ||
* @notice The Arbitrable contract | ||
* @return _arbitrable The Arbitrable contract | ||
*/ | ||
function ARBITRABLE() external view returns (IArbitrable _arbitrable); | ||
|
||
/** | ||
* @notice The Horizon Accounting Extension contract | ||
* @return _horizonAccountingExtension The Horizon Accounting Extension contract | ||
*/ | ||
function horizonAccountingExtension() external view returns (IHorizonAccountingExtension _horizonAccountingExtension); | ||
|
||
/** | ||
* @notice The Horizon Staking contract | ||
* @return _horizonStaking The Horizon Staking contract | ||
*/ | ||
function horizonStaking() external view returns (IHorizonStaking _horizonStaking); | ||
|
||
/*/////////////////////////////////////////////////////////////// | ||
LOGIC | ||
//////////////////////////////////////////////////////////////*/ | ||
|
||
/** | ||
* @notice Sets the Horizon Accounting Extension contract | ||
* @param _horizonAccountingExtension The new Horizon Accounting Extension contract | ||
*/ | ||
function setHorizonAccountingExtension(IHorizonAccountingExtension _horizonAccountingExtension) external; | ||
} |
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
Oops, something went wrong.