Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyonline committed Jun 24, 2024
1 parent f2c201d commit 169b928
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 45 deletions.
3 changes: 1 addition & 2 deletions script/DeploySiloFactory.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ contract DeploySiloFactory is Script {

// address private constant MANAGEMENT = 0x16388463d60FFE0661Cf7F1f31a7D658aC790ff7; // mainnet
address private constant MANAGEMENT = 0x1dcAD21ccD74b7A8A7BC7D19894de8Af41D9ea03; // arbitrum
address private constant GOVERNANCE = MANAGEMENT; // @TODO: change this to a governance address
address private constant PERFORMANCE_FEE_RECIPIENT = 0x5C1E6bA712e9FC3399Ee7d5824B6Ec68A0363C02; // artemis wallet

// ISiloRepository private constant REPO = ISiloRepository(0xBCd67f35c7A2F212db0AD7f68fC773b5aC15377c); // https://devdocs.silo.finance/security/smart-contracts#silo-llama-ethereum
Expand All @@ -27,7 +26,7 @@ contract DeploySiloFactory is Script {
function run() external {
vm.startBroadcast(vm.envUint("PRIVATE_KEY"));

SiloStrategyFactory _factory = new SiloStrategyFactory(REPO, MANAGEMENT, GOVERNANCE, PERFORMANCE_FEE_RECIPIENT);
SiloStrategyFactory _factory = new SiloStrategyFactory(REPO, MANAGEMENT, PERFORMANCE_FEE_RECIPIENT);

console.log("-----------------------------");
console.log("factory deployed at: ", address(_factory));
Expand Down
29 changes: 14 additions & 15 deletions src/strategies/silo/SiloStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";

import {BaseHealthCheck, ERC20} from "@periphery/Bases/HealthCheck/BaseHealthCheck.sol";
import {TradeFactorySwapper} from "@periphery/swappers/TradeFactorySwapper.sol";
import {Governance2Step} from "@periphery/utils/Governance2Step.sol";

import {IAaveIncentivesController} from "@silo/external/aave/interfaces/IAaveIncentivesController.sol";
import {IGuardedLaunch} from "@silo/interfaces/IGuardedLaunch.sol";
Expand All @@ -33,7 +32,8 @@ import {EasyMathV2} from "@silo/lib/EasyMathV2.sol";
* @author johnnyonline
* @notice A strategy that deposits funds into a Silo and harvests incentives.
*/
contract SiloStrategy is BaseHealthCheck, TradeFactorySwapper, Governance2Step {
contract SiloStrategy is BaseHealthCheck, TradeFactorySwapper {

using SafeERC20 for ERC20;
using EasyMathV2 for uint256;

Expand All @@ -57,9 +57,13 @@ contract SiloStrategy is BaseHealthCheck, TradeFactorySwapper, Governance2Step {
*/
IShareToken public immutable share;

/**
* @dev The dust threshold for the strategy. Any amount below this will not be deposited.
*/
uint256 private constant DUST_THRESHOLD = 10_000;

/**
* @notice Used to initialize the strategy on deployment.
* @param _governance Address of the governance contract.
* @param _repository Address of the Silo repository.
* @param _silo Address of the Silo that the strategy is using.
* @param _share Address of the share token that represents the strategy's share of the Silo.
Expand All @@ -68,14 +72,13 @@ contract SiloStrategy is BaseHealthCheck, TradeFactorySwapper, Governance2Step {
* @param _name Name the strategy will use.
*/
constructor(
address _governance,
address _repository,
address _silo,
address _share,
address _asset,
address _incentivesController,
string memory _name
) BaseHealthCheck(_asset, _name) Governance2Step(_governance) {
) BaseHealthCheck(_asset, _name) {
repository = ISiloRepository(_repository);
silo = ISilo(_silo);
share = IShareToken(_share);
Expand All @@ -84,15 +87,6 @@ contract SiloStrategy is BaseHealthCheck, TradeFactorySwapper, Governance2Step {
ERC20(_asset).forceApprove(_silo, type(uint256).max);
}

/*//////////////////////////////////////////////////////////////
GOVERNANCE FUNCTIONS
//////////////////////////////////////////////////////////////*/

function setIncentivesController(address _incentivesController) external onlyGovernance {
require(_incentivesController != address(0), "!incentivesController");
incentivesController = IAaveIncentivesController(_incentivesController);
}

/*//////////////////////////////////////////////////////////////
MANAGEMENT FUNCTIONS
//////////////////////////////////////////////////////////////*/
Expand All @@ -101,6 +95,11 @@ contract SiloStrategy is BaseHealthCheck, TradeFactorySwapper, Governance2Step {
_setTradeFactory(_tradeFactory, address(asset));
}

function setIncentivesController(address _incentivesController) external onlyManagement {
require(_incentivesController != address(0), "!incentivesController");
incentivesController = IAaveIncentivesController(_incentivesController);
}

function addToken(
address _from,
address _to
Expand Down Expand Up @@ -193,7 +192,7 @@ contract SiloStrategy is BaseHealthCheck, TradeFactorySwapper, Governance2Step {
// Only harvest and redeploy if the strategy is not shutdown.
if (!TokenizedStrategy.isShutdown()) {
uint256 _toDeploy = asset.balanceOf(address(this));
if (_toDeploy > 0) {
if (_toDeploy > DUST_THRESHOLD) {
uint256 _availableDepositLimit = availableDepositLimit(address(0));
if (_toDeploy <= _availableDepositLimit) {
_deployFunds(_toDeploy);
Expand Down
27 changes: 1 addition & 26 deletions src/strategies/silo/SiloStrategyFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ contract SiloStrategyFactory {
*/
event ManagementSet(address management);

/**
* @notice Emitted when the governance address is set.
*/
event GovernanceSet(address governance);

/**
* @notice Emitted when the performance fee recipient address is set.
*/
Expand All @@ -47,11 +42,6 @@ contract SiloStrategyFactory {
*/
address public management;

/**
* @dev The governance address.
*/
address public governance;

/**
* @dev The performance fee recipient.
*/
Expand All @@ -66,18 +56,15 @@ contract SiloStrategyFactory {
* @notice Used to initialize the strategy factory on deployment.
* @param _repository Address of the Silo repository.
* @param _management Address of the management account.
* @param _governance Address of the governance account.
* @param _performanceFeeRecipient Address of the performance fee recipient.
*/
constructor(ISiloRepository _repository, address _management, address _governance, address _performanceFeeRecipient) {
constructor(ISiloRepository _repository, address _management, address _performanceFeeRecipient) {
require(Ping.pong(_repository.siloRepositoryPing), "invalid silo repository");
require(_management != address(0), "invalid management");
require(_governance != address(0), "invalid governance");
require(_performanceFeeRecipient != address(0), "invalid performance fee recipient");

repository = _repository;
management = _management;
governance = _governance;
performanceFeeRecipient = _performanceFeeRecipient;
}

Expand Down Expand Up @@ -110,7 +97,6 @@ contract SiloStrategyFactory {

_strategy = IStrategyInterface(address(
new SiloStrategy(
governance,
address(repository),
_silo,
_share,
Expand Down Expand Up @@ -145,17 +131,6 @@ contract SiloStrategyFactory {
emit ManagementSet(_management);
}

/**
* @notice Set the governance address.
* @dev This is the address that can call the governance functions.
* @param _governance The address to set as the governance address.
*/
function setGovernance(address _governance) external onlyManagement {
require(_governance != address(0), "ZERO_ADDRESS");
governance = _governance;
emit GovernanceSet(_governance);
}

/**
* @notice Set the performance fee recipient address.
* @dev This is the address that will receive the performance fee.
Expand Down
2 changes: 0 additions & 2 deletions src/test/utils/Strategies.sol
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,12 @@ contract Strategies is ExtendedTest {
new SiloStrategyFactory(
ISiloRepository(address(0)),
management,
governance,
performanceFeeRecipient
);

SiloStrategyFactory factory = new SiloStrategyFactory(
ISiloRepository(siloRepository),
management,
governance,
performanceFeeRecipient
);

Expand Down

0 comments on commit 169b928

Please sign in to comment.