Skip to content

Commit

Permalink
chore: rename approved -> cloneable" (#133)
Browse files Browse the repository at this point in the history
fixes #130
  • Loading branch information
thelostone-mc committed Jul 28, 2023
1 parent 3a3bd8f commit 04f84f8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 34 deletions.
28 changes: 14 additions & 14 deletions contracts/core/Allo.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ contract Allo is IAllo, Native, Transfer, Initializable, Ownable, AccessControl
mapping(uint256 => Pool) private pools;

/// @notice Strategy -> bool
mapping(address => bool) private approvedStrategies;
mapping(address => bool) private cloneableStrategies;

/// ====================================
/// =========== Intializer =============
Expand Down Expand Up @@ -127,14 +127,14 @@ contract Allo is IAllo, Native, Transfer, Initializable, Ownable, AccessControl
if (_strategy == address(0)) {
revert ZERO_ADDRESS();
}
if (_isApprovedStrategy(_strategy)) {
if (_isCloneableStrategy(_strategy)) {
revert IS_APPROVED_STRATEGY();
}

return _createPool(_identityId, IStrategy(_strategy), _initStrategyData, _token, _amount, _metadata, _managers);
}

/// @notice Creates a new pool (by cloning an approved strategies)
/// @notice Creates a new pool (by cloning an cloneable strategies)
/// @param _identityId The identityId of the pool
/// @param _initStrategyData The data to initialize the strategy
/// @param _token The address of the token
Expand All @@ -150,7 +150,7 @@ contract Allo is IAllo, Native, Transfer, Initializable, Ownable, AccessControl
Metadata memory _metadata,
address[] memory _managers
) external payable returns (uint256 poolId) {
if (!_isApprovedStrategy(_strategy)) {
if (!_isCloneableStrategy(_strategy)) {
revert NOT_APPROVED_STRATEGY();
}

Expand Down Expand Up @@ -207,19 +207,19 @@ contract Allo is IAllo, Native, Transfer, Initializable, Ownable, AccessControl
/// @notice Add a strategy to the allowlist
/// @param _strategy The address of the strategy
/// @dev Only callable by the owner
function addToApprovedStrategies(address _strategy) external onlyOwner {
function addToCloneableStrategies(address _strategy) external onlyOwner {
if (_strategy == address(0)) {
revert ZERO_ADDRESS();
}
approvedStrategies[_strategy] = true;
cloneableStrategies[_strategy] = true;
emit StrategyApproved(_strategy);
}

/// @notice Remove a strategy from the allowlist
/// @param _strategy The address of the strategy
/// @dev Only callable by the owner
function removeFromApprovedStrategies(address _strategy) external onlyOwner {
approvedStrategies[_strategy] = false;
function removeFromCloneableStrategies(address _strategy) external onlyOwner {
cloneableStrategies[_strategy] = false;
emit StrategyRemoved(_strategy);
}

Expand Down Expand Up @@ -445,10 +445,10 @@ contract Allo is IAllo, Native, Transfer, Initializable, Ownable, AccessControl
emit PoolFunded(_poolId, amountAfterFee, feeAmount);
}

/// @notice Checks if the strategy is approved
/// @notice Checks if the strategy is cloneable
/// @param _strategy The address of the strategy
function _isApprovedStrategy(address _strategy) internal view returns (bool) {
return approvedStrategies[_strategy];
function _isCloneableStrategy(address _strategy) internal view returns (bool) {
return cloneableStrategies[_strategy];
}

/// @notice Checks if the address is a pool admin
Expand Down Expand Up @@ -552,9 +552,9 @@ contract Allo is IAllo, Native, Transfer, Initializable, Ownable, AccessControl
return registry;
}

/// @notice return boolean if strategy is approved
function isApprovedStrategy(address _strategy) external view returns (bool) {
return _isApprovedStrategy(_strategy);
/// @notice return boolean if strategy is cloneable
function isCloneableStrategy(address _strategy) external view returns (bool) {
return _isCloneableStrategy(_strategy);
}

/// @notice return the pool
Expand Down
6 changes: 3 additions & 3 deletions contracts/core/IAllo.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ interface IAllo {
function updateTreasury(address payable _treasury) external;
function updateFeePercentage(uint256 _feePercentage) external;
function updateBaseFee(uint256 _baseFee) external;
function addToApprovedStrategies(address _strategy) external;
function removeFromApprovedStrategies(address _strategy) external;
function addToCloneableStrategies(address _strategy) external;
function removeFromCloneableStrategies(address _strategy) external;
function addPoolManager(uint256 _poolId, address _manager) external;
function removePoolManager(uint256 _poolId, address _manager) external;
function recoverFunds(address _token, address _recipient) external;
Expand All @@ -88,7 +88,7 @@ interface IAllo {

function isPoolAdmin(uint256 _poolId, address _address) external view returns (bool);
function isPoolManager(uint256 _poolId, address _address) external view returns (bool);
function isApprovedStrategy(address) external view returns (bool);
function isCloneableStrategy(address) external view returns (bool);

function getStrategy(uint256 _poolId) external view returns (address);
function getFeePercentage() external view returns (uint256);
Expand Down
34 changes: 17 additions & 17 deletions test/foundry/core/Allo.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ contract AlloTest is Test, AlloSetup, RegistrySetupFull, Native {
}

function test_createPool() public {
allo().addToApprovedStrategies(strategy);
allo().addToCloneableStrategies(strategy);

vm.expectEmit(true, true, false, false);
emit PoolCreated(1, poolIdentity_id(), IStrategy(strategy), NATIVE, 0, metadata);
Expand All @@ -133,7 +133,7 @@ contract AlloTest is Test, AlloSetup, RegistrySetupFull, Native {
}

function testRevert_createPoolWithCustomStrategy_IS_APPROVED_STRATEGY() public {
allo().addToApprovedStrategies(strategy);
allo().addToCloneableStrategies(strategy);
vm.expectRevert(IAllo.IS_APPROVED_STRATEGY.selector);
vm.prank(pool_admin());
allo().createPoolWithCustomStrategy(poolIdentity_id(), strategy, "0x", NATIVE, 0, metadata, pool_managers());
Expand Down Expand Up @@ -328,38 +328,38 @@ contract AlloTest is Test, AlloSetup, RegistrySetupFull, Native {
allo().updateBaseFee(1e16);
}

function test_addToApprovedStrategies() public {
function test_addToCloneableStrategies() public {
address _strategy = makeAddr("strategy");
assertFalse(allo().isApprovedStrategy(_strategy));
allo().addToApprovedStrategies(_strategy);
assertTrue(allo().isApprovedStrategy(_strategy));
assertFalse(allo().isCloneableStrategy(_strategy));
allo().addToCloneableStrategies(_strategy);
assertTrue(allo().isCloneableStrategy(_strategy));
}

function testRevert_addToApprovedStrategies_ZERO_ADDRESS() public {
function testRevert_addToCloneableStrategies_ZERO_ADDRESS() public {
vm.expectRevert(IAllo.ZERO_ADDRESS.selector);
allo().addToApprovedStrategies(address(0));
allo().addToCloneableStrategies(address(0));
}

function testRevert_addToApprovedStrategies_UNAUTHORIZED() public {
function testRevert_addToCloneableStrategies_UNAUTHORIZED() public {
vm.expectRevert();
vm.prank(makeAddr("anon"));
address _strategy = makeAddr("strategy");
allo().addToApprovedStrategies(_strategy);
allo().addToCloneableStrategies(_strategy);
}

function test_removeFromApprovedStrategies() public {
function test_removeFromCloneableStrategies() public {
address _strategy = makeAddr("strategy");
allo().addToApprovedStrategies(_strategy);
assertTrue(allo().isApprovedStrategy(_strategy));
allo().removeFromApprovedStrategies(_strategy);
assertFalse(allo().isApprovedStrategy(_strategy));
allo().addToCloneableStrategies(_strategy);
assertTrue(allo().isCloneableStrategy(_strategy));
allo().removeFromCloneableStrategies(_strategy);
assertFalse(allo().isCloneableStrategy(_strategy));
}

function testRevert_removeFromApprovedStrategies_UNAUTHORIZED() public {
function testRevert_removeFromCloneableStrategies_UNAUTHORIZED() public {
address _strategy = makeAddr("strategy");
vm.expectRevert();
vm.prank(makeAddr("anon"));
allo().removeFromApprovedStrategies(_strategy);
allo().removeFromCloneableStrategies(_strategy);
}

function test_addPoolManager() public {
Expand Down

0 comments on commit 04f84f8

Please sign in to comment.