Skip to content

Commit

Permalink
fix: acm
Browse files Browse the repository at this point in the history
  • Loading branch information
sogipec committed Oct 23, 2024
1 parent cd00966 commit 29e0d05
Show file tree
Hide file tree
Showing 18 changed files with 105 additions and 137 deletions.
6 changes: 3 additions & 3 deletions contracts/DistributionCreator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ contract DistributionCreator is UUPSHelper, ReentrancyGuardUpgradeable {

uint256 public immutable CHAIN_ID = block.chainid;

/// @notice `Core` contract handling access control
ICore public core;
/// @notice Contract handling access control
IAccessControlManager public core;

/// @notice Contract distributing rewards to users
address public distributor;
Expand Down Expand Up @@ -182,7 +182,7 @@ contract DistributionCreator is UUPSHelper, ReentrancyGuardUpgradeable {
CONSTRUCTOR
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/

function initialize(ICore _core, address _distributor, uint256 _fees) external initializer {
function initialize(IAccessControlManager _core, address _distributor, uint256 _fees) external initializer {
if (address(_core) == address(0) || _distributor == address(0)) revert ZeroAddress();
if (_fees >= BASE_9) revert InvalidParam();
distributor = _distributor;
Expand Down
4 changes: 2 additions & 2 deletions contracts/Distributor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ contract Distributor is UUPSHelper {
IERC20 public disputeToken;

/// @notice Contract handling access control
ICore public core;
IAccessControlManager public core;

/// @notice Address which created the last dispute
/// @dev Used to store if there is an ongoing dispute
Expand Down Expand Up @@ -194,7 +194,7 @@ contract Distributor is UUPSHelper {

constructor() initializer {}

function initialize(ICore _core) external initializer {
function initialize(IAccessControlManager _core) external initializer {
if (address(_core) == address(0)) revert ZeroAddress();
core = _core;
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/TokenLocker.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.24;
pragma solidity ^0.8.17;

import { IERC20, IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
Expand Down
8 changes: 3 additions & 5 deletions contracts/deprecated/OldDistributionCreator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.s
import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import { SignatureChecker } from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";

import { IUniswapV3Pool } from "../interfaces/external/uniswap/IUniswapV3Pool.sol";

import "../utils/UUPSHelper.sol";
import { CampaignParameters } from "../struct/CampaignParameters.sol";
import { DistributionParameters } from "../struct/DistributionParameters.sol";
Expand Down Expand Up @@ -71,8 +69,8 @@ contract DistributionCreator is UUPSHelper, ReentrancyGuardUpgradeable {

uint256 public immutable CHAIN_ID = block.chainid;

/// @notice `Core` contract handling access control
ICore public core;
/// @notice Contract handling access control
IAccessControlManager public core;

/// @notice Contract distributing rewards to users
address public distributor;
Expand Down Expand Up @@ -175,7 +173,7 @@ contract DistributionCreator is UUPSHelper, ReentrancyGuardUpgradeable {
CONSTRUCTOR
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/

function initialize(ICore _core, address _distributor, uint256 _fees) external initializer {
function initialize(IAccessControlManager _core, address _distributor, uint256 _fees) external initializer {
if (address(_core) == address(0) || _distributor == address(0)) revert ZeroAddress();
if (_fees >= BASE_9) revert InvalidParam();
distributor = _distributor;
Expand Down
6 changes: 3 additions & 3 deletions contracts/deprecated/OldDistributor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ contract Distributor is UUPSHelper {
/// @notice Token to deposit to freeze the roots update
IERC20 public disputeToken;

/// @notice `Core` contract handling access control
ICore public core;
/// @notice `AccessControlManager` contract handling access control
IAccessControlManager public core;

/// @notice Address which created the dispute
/// @dev Used to store if there is an ongoing dispute
Expand Down Expand Up @@ -147,7 +147,7 @@ contract Distributor is UUPSHelper {

constructor() initializer {}

function initialize(ICore _core) external initializer {
function initialize(IAccessControlManager _core) external initializer {
if (address(_core) == address(0)) revert ZeroAddress();
core = _core;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

pragma solidity ^0.8.17;

/// @title ICore
/// @title IAccessControlManager
/// @author Angle Labs, Inc.
/// @notice Interface for the `Core` contracts of smart contract modules used in Angle Labs contracts
interface ICore {
/// @notice Interface for the `AccessControlManager` contracts of Merkl contracts
interface IAccessControlManager {
/// @notice Checks whether an address is governor
/// @param admin Address to check
/// @return Whether the address has the `GOVERNOR_ROLE` or not
Expand Down
32 changes: 0 additions & 32 deletions contracts/interfaces/external/algebra/IAlgebraPool.sol

This file was deleted.

19 changes: 0 additions & 19 deletions contracts/interfaces/external/uniswap/IUniswapV3Pool.sol

This file was deleted.

4 changes: 2 additions & 2 deletions contracts/middleman/MerklGaugeMiddleman.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ contract MerklGaugeMiddleman {
// ================================= PARAMETERS ================================

/// @notice Contract handling access control
ICore public accessControlManager;
IAccessControlManager public accessControlManager;

/// @notice Maps a gauge to its reward parameters
mapping(address => DistributionParameters) public gaugeParams;
Expand All @@ -61,7 +61,7 @@ contract MerklGaugeMiddleman {

event GaugeSet(address indexed gauge);

constructor(ICore _accessControlManager) {
constructor(IAccessControlManager _accessControlManager) {
if (address(_accessControlManager) == address(0)) revert ZeroAddress();
accessControlManager = _accessControlManager;
IERC20 _angle = angle();
Expand Down
2 changes: 1 addition & 1 deletion contracts/middleman/MerklGaugeMiddlemanPolygon.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "./MerklGaugeMiddleman.sol";
/// @title MerklGaugeMiddlemanPolygon
/// @author Angle Labs, Inc.
contract MerklGaugeMiddlemanPolygon is MerklGaugeMiddleman {
constructor(ICore _accessControlManager) MerklGaugeMiddleman(_accessControlManager) {}
constructor(IAccessControlManager _accessControlManager) MerklGaugeMiddleman(_accessControlManager) {}

function angle() public pure override returns (IERC20) {
return IERC20(0x900F717EA076E1E7a484ad9DD2dB81CEEc60eBF1);
Expand Down
9 changes: 3 additions & 6 deletions contracts/mock/DistributionCreatorUpdatable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,14 @@ import "../DistributionCreator.sol";
/// @author Angle Labs, Inc.
//solhint-disable
contract DistributionCreatorUpdatable is DistributionCreator {

uint8 public coreUpdated;

uint256[49] private __gapUpdatable;


function updateCore(address _newCore) external {
if(coreUpdated == 0) {
core = ICore(_newCore);
if (coreUpdated == 0) {
core = IAccessControlManager(_newCore);
coreUpdated = 1;
}
}

}
}
2 changes: 1 addition & 1 deletion contracts/mock/MockMerklGaugeMiddleman.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ contract MockMerklGaugeMiddleman is MerklGaugeMiddleman {
IERC20 public angleAddress;
DistributionCreator public manager;

constructor(ICore _coreBorrow) MerklGaugeMiddleman(_coreBorrow) {}
constructor(IAccessControlManager _coreBorrow) MerklGaugeMiddleman(_coreBorrow) {}

function angle() public view override returns (IERC20) {
return angleAddress;
Expand Down
6 changes: 3 additions & 3 deletions contracts/tokenWrappers/AaveTokenWrapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ contract AaveTokenWrapper is UUPSHelper, ERC20Upgradeable {
// ================================= VARIABLES =================================

/// @notice `Core` contract handling access control
ICore public core;
IAccessControlManager public core;

// could be put as immutable in non upgradeable contract
address public token;
Expand Down Expand Up @@ -53,11 +53,11 @@ contract AaveTokenWrapper is UUPSHelper, ERC20Upgradeable {
__UUPSUpgradeable_init();
if (underlyingToken == address(0) || _distributor == address(0) || _distributionCreator == address(0))
revert ZeroAddress();
ICore(_core).isGovernor(msg.sender);
IAccessControlManager(_core).isGovernor(msg.sender);
token = underlyingToken;
distributor = _distributor;
distributionCreator = _distributionCreator;
core = ICore(_core);
core = IAccessControlManager(_core);
}

function _beforeTokenTransfer(address from, address to, uint256 amount) internal override {
Expand Down
4 changes: 2 additions & 2 deletions contracts/tokenWrappers/BaseTokenWrapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ abstract contract BaseMerklTokenWrapper is UUPSHelper, ERC20Upgradeable {
// ================================= VARIABLES =================================

/// @notice `Core` contract handling access control
ICore public core;
IAccessControlManager public core;

// =================================== EVENTS ==================================

Expand All @@ -50,7 +50,7 @@ abstract contract BaseMerklTokenWrapper is UUPSHelper, ERC20Upgradeable {
return true;
}

function initialize(ICore _core) public initializer onlyProxy {
function initialize(IAccessControlManager _core) public initializer onlyProxy {
__ERC20_init(
string.concat("Merkl Token Wrapper - ", IERC20Metadata(token()).name()),
string.concat("mtw", IERC20Metadata(token()).symbol())
Expand Down
12 changes: 7 additions & 5 deletions contracts/utils/UUPSHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,23 @@ pragma solidity ^0.8.17;

import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";

import { ICore } from "../interfaces/ICore.sol";
import { IAccessControlManager } from "../interfaces/IAccessControlManager.sol";
import "../utils/Errors.sol";

/// @title UUPSHelper
/// @notice Helper contract for UUPSUpgradeable contracts where the upgradeability is controlled by a specific address
/// @author Angle Labs., Inc
/// @dev The 0 address check in the modifier allows the use of these modifiers during initialization
abstract contract UUPSHelper is UUPSUpgradeable {
modifier onlyGuardianUpgrader(ICore _core) {
if (address(_core) != address(0) && !_core.isGovernorOrGuardian(msg.sender)) revert NotGovernorOrGuardian();
modifier onlyGuardianUpgrader(IAccessControlManager _accessControlManager) {
if (address(_accessControlManager) != address(0) && !_accessControlManager.isGovernorOrGuardian(msg.sender))
revert NotGovernorOrGuardian();
_;
}

modifier onlyGovernorUpgrader(ICore _core) {
if (address(_core) != address(0) && !_core.isGovernor(msg.sender)) revert NotGovernor();
modifier onlyGovernorUpgrader(IAccessControlManager _accessControlManager) {
if (address(_accessControlManager) != address(0) && !_accessControlManager.isGovernor(msg.sender))
revert NotGovernor();
_;
}

Expand Down
4 changes: 2 additions & 2 deletions test/foundry/Fixture.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { DistributionCreator } from "../../contracts/DistributionCreator.sol";
import { MockTokenPermit } from "../../contracts/mock/MockTokenPermit.sol";
import { MockUniswapV3Pool } from "../../contracts/mock/MockUniswapV3Pool.sol";
import { MockCoreBorrow } from "../../contracts/mock/MockCoreBorrow.sol";
import { ICore } from "../../contracts/interfaces/ICore.sol";
import { IAccessControlManager } from "../../contracts/interfaces/IAccessControlManager.sol";
import "../../contracts/utils/UUPSHelper.sol";
import { console } from "forge-std/console.sol";

Expand Down Expand Up @@ -72,7 +72,7 @@ contract Fixture is Test {
pool.setToken(address(token1), 1);
coreBorrow.toggleGuardian(address(guardian));
coreBorrow.toggleGovernor(address(governor));
creator.initialize(ICore(address(coreBorrow)), address(bob), 1e8);
creator.initialize(IAccessControlManager(address(coreBorrow)), address(bob), 1e8);
}

/*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
Loading

0 comments on commit 29e0d05

Please sign in to comment.