Skip to content

Commit

Permalink
feat: enable zero incentivesController and fix constructor assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyonline committed Mar 9, 2024
1 parent 3c3493d commit b256fae
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {AuctionSwapper, Auction} from "@periphery/swappers/AuctionSwapper.sol";
import {IAaveIncentivesController} from "@silo/external/aave/interfaces/IAaveIncentivesController.sol";
import {ISilo} from "@silo/interfaces/ISilo.sol";
import {IShareToken} from "@silo/interfaces/IShareToken.sol";
import {ISiloRepository} from "@silo/interfaces/ISiloRepository.sol";
import {EasyMathV2} from "@silo/lib/EasyMathV2.sol";

/**
Expand All @@ -25,7 +26,7 @@ import {EasyMathV2} from "@silo/lib/EasyMathV2.sol";

// NOTE: To implement permissioned functions you can use the onlyManagement, onlyEmergencyAuthorized and onlyKeepers modifiers

contract SiloLlamaStrategy is AuctionSwapper, BaseStrategy {
contract SiloStrategy is AuctionSwapper, BaseStrategy {

using SafeERC20 for ERC20;
using EasyMathV2 for uint256;
Expand All @@ -50,13 +51,21 @@ contract SiloLlamaStrategy is AuctionSwapper, BaseStrategy {
*/
IShareToken private immutable share;

Check warning on line 52 in src/strategies/silo/SiloStrategy.sol

View workflow job for this annotation

GitHub Actions / solidity

Immutable variables name are set to be in capitalized SNAKE_CASE

/**
* @notice Used to initialize the strategy on deployment.
* @param _siloRepository The address of the SiloRepository.
* @param _incentivesController The address of the IncentivesController. If address(0), the strategy will not claim incentives.
* @param _siloAsset The address of the Silo asset. Used to retrieve the Silo address from the SiloRepository.
* @param _asset The address of the strategy asset.
*/
constructor(
address _silo,
address _siloRepository,
address _incentivesController,
address _siloAsset,
address _asset,
string memory _name
) BaseStrategy(_asset, _name) {
silo = ISilo(_silo);
silo = ISilo(ISiloRepository(_siloRepository).getSilo(_siloAsset));
share = silo.assetStorage(_asset).collateralToken;
require(address(share) != address(0), "wrong silo");

Check warning on line 70 in src/strategies/silo/SiloStrategy.sol

View workflow job for this annotation

GitHub Actions / solidity

Use Custom Errors instead of require statements

Expand All @@ -72,7 +81,7 @@ contract SiloLlamaStrategy is AuctionSwapper, BaseStrategy {
incentivesController = IAaveIncentivesController(_incentivesController);
rewardToken = ERC20(_rewardToken);

ERC20(_asset).forceApprove(_silo, type(uint256).max);
ERC20(_asset).forceApprove(address(silo), type(uint256).max);
}

/*//////////////////////////////////////////////////////////////
Expand Down
26 changes: 15 additions & 11 deletions src/test/utils/Strategies.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,35 @@ pragma solidity 0.8.18;

import {ISilo} from "@silo/interfaces/ISilo.sol";

import {SiloLlamaStrategy} from "../../strategies/crvUSD/SiloLlamaStrategy.sol";
import {SiloStrategy} from "../../strategies/silo/SiloStrategy.sol";

contract Strategies {

address private _crvUSDCRVSilo = 0x96eFdF95Cc47fe90e8f63D2f5Ef9FB8B180dAeB9;
address private _crvUSD = 0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E;
address private constant _crvUSDCRVSilo = 0x96eFdF95Cc47fe90e8f63D2f5Ef9FB8B180dAeB9;
address private constant _siloRepository = 0xBCd67f35c7A2F212db0AD7f68fC773b5aC15377c;
address private constant _crvUSD = 0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E;
address private constant _incentivesController = 0x361384A0d755f972E5Eea26e4F4efBAf976B6461;
address private constant _crv = 0xD533a949740bb3306d119CC777fa900bA034cd52;

function _setUpStrategy() internal returns (address) {
return _setUpSiloLlamaStrategy();
return _setUpSiloStrategy();
}

function _earnInterest() internal {
_earnSiloLlamaInterest();
_earnSiloInterest();
}

function _setUpSiloLlamaStrategy() private returns (address _strategy) {
_strategy = address(new SiloLlamaStrategy(
address(_crvUSDCRVSilo), // _silo
address(0x361384A0d755f972E5Eea26e4F4efBAf976B6461), // _incentivesController
_crvUSD, // _asset
function _setUpSiloStrategy() private returns (address _strategy) {
_strategy = address(new SiloStrategy(
_siloRepository,
_incentivesController,
_crv,
_crvUSD,
"crvUSD/CRV SiloLlamaStrategy"
));
}

function _earnSiloLlamaInterest() private {
function _earnSiloInterest() private {
ISilo(_crvUSDCRVSilo).accrueInterest(_crvUSD);
}
}

0 comments on commit b256fae

Please sign in to comment.