Skip to content

Commit fafe7d4

Browse files
Use Strategizable for strategist functionality (#2740)
* use Strategizable * Add comment --------- Co-authored-by: Shahul Hameed <[email protected]>
1 parent 6a3846d commit fafe7d4

File tree

3 files changed

+23
-32
lines changed

3 files changed

+23
-32
lines changed

contracts/contracts/governance/Strategizable.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ contract Strategizable is Governable {
1515
/**
1616
* @dev Verifies that the caller is either Governor or Strategist.
1717
*/
18-
modifier onlyGovernorOrStrategist() {
18+
modifier onlyGovernorOrStrategist() virtual {
1919
require(
2020
msg.sender == strategistAddr || isGovernor(),
2121
"Caller is not the Strategist or Governor"

contracts/contracts/strategies/crosschain/CrossChainRemoteStrategy.sol

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,19 @@ import { Generalized4626Strategy } from "../Generalized4626Strategy.sol";
1717
import { AbstractCCTPIntegrator } from "./AbstractCCTPIntegrator.sol";
1818
import { CrossChainStrategyHelper } from "./CrossChainStrategyHelper.sol";
1919
import { InitializableAbstractStrategy } from "../../utils/InitializableAbstractStrategy.sol";
20+
import { Strategizable } from "../../governance/Strategizable.sol";
2021

2122
contract CrossChainRemoteStrategy is
2223
AbstractCCTPIntegrator,
23-
Generalized4626Strategy
24+
Generalized4626Strategy,
25+
Strategizable
2426
{
2527
using SafeERC20 for IERC20;
2628
using CrossChainStrategyHelper for bytes;
2729

2830
event DepositUnderlyingFailed(string reason);
2931
event WithdrawalFailed(uint256 amountRequested, uint256 amountAvailable);
3032
event WithdrawUnderlyingFailed(string reason);
31-
event StrategistUpdated(address _address);
32-
33-
/**
34-
* @notice Address of the strategist.
35-
* This is important to have the variable name same as in IVault.
36-
* Because the parent contract (Generalized4626Strategy) uses this
37-
* function to get the strategist address.
38-
*/
39-
address public strategistAddr;
4033

4134
modifier onlyOperatorOrStrategistOrGovernor() {
4235
require(
@@ -48,6 +41,24 @@ contract CrossChainRemoteStrategy is
4841
_;
4942
}
5043

44+
/**
45+
* @dev Overriding this modifier is important because the parent
46+
* contract`Generalized4626Strategy` uses `IVault.strategistAddr()`
47+
* in its implementation and there's no Vault on the remote strategy.
48+
* So, we set the Vault address of remote to be the proxy address and
49+
* inherit from Strategizable to get the same function signature.
50+
* Essentially, any calls to `IVault.strategistAddr()` will be equal to
51+
* calling `address(this).strategistAddr()`.
52+
*/
53+
modifier onlyGovernorOrStrategist()
54+
override(InitializableAbstractStrategy, Strategizable) {
55+
require(
56+
msg.sender == strategistAddr || isGovernor(),
57+
"Caller is not the Strategist or Governor"
58+
);
59+
_;
60+
}
61+
5162
constructor(
5263
BaseStrategyConfig memory _baseConfig,
5364
CCTPIntegrationConfig memory _cctpConfig
@@ -91,26 +102,6 @@ contract CrossChainRemoteStrategy is
91102
);
92103
}
93104

94-
/**
95-
* @notice Set address of Strategist.
96-
* This is important to have the function name same as IVault.
97-
* Because the parent contract (Generalized4626Strategy) uses this
98-
* function to get/set the strategist address.
99-
* @param _address Address of Strategist
100-
*/
101-
function setStrategistAddr(address _address) external onlyGovernor {
102-
_setStrategistAddr(_address);
103-
}
104-
105-
/**
106-
* @dev Set the strategist address
107-
* @param _address Address of the strategist
108-
*/
109-
function _setStrategistAddr(address _address) internal {
110-
strategistAddr = _address;
111-
emit StrategistUpdated(_address);
112-
}
113-
114105
/// @inheritdoc Generalized4626Strategy
115106
function deposit(address _asset, uint256 _amount)
116107
external

contracts/contracts/utils/InitializableAbstractStrategy.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ abstract contract InitializableAbstractStrategy is Initializable, Governable {
8181
/**
8282
* @dev Verifies that the caller is the Governor or Strategist.
8383
*/
84-
modifier onlyGovernorOrStrategist() {
84+
modifier onlyGovernorOrStrategist() virtual {
8585
require(
8686
isGovernor() || msg.sender == IVault(vaultAddress).strategistAddr(),
8787
"Caller is not the Strategist or Governor"

0 commit comments

Comments
 (0)