Skip to content

Commit

Permalink
Merge pull request #217 from stabilitydao/193-dev-silo
Browse files Browse the repository at this point in the history
SiF 1.0.1
  • Loading branch information
a17 authored Feb 4, 2025
2 parents 15229ee + 0931df1 commit be267d7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/integrations/silo/ISilo.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,10 @@ interface ISilo is IERC4626 {
/// @dev Reverts for debt asset type
function withdraw(uint256 _assets, address _receiver, address _owner, CollateralType collateralType) external returns (uint256 shares);

/// @inheritdoc IERC4626
/// @dev For protected (non-borrowable) collateral and debt, use:
/// `convertToAssets(uint256 _shares, AssetType _assetType)` with `AssetType.Protected` or `AssetType.Debt`
function convertToAssets(uint256 _shares) external view returns (uint256 assets);

function asset() view external returns(address assetTokenAddres);
}
17 changes: 15 additions & 2 deletions src/strategies/SiloFarmStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import "../integrations/silo/ISiloIncentivesController.sol";
import "../integrations/silo/ISilo.sol";

/// @title Earns incentives and supply APR on Silo V2
/// Changelog:
/// 1.0.1: claimRevenue bugfix
/// @author 0xhokugava (https://github.com/0xhokugava)
contract SiloFarmStrategy is FarmingStrategyBase {
using SafeERC20 for IERC20;
Expand All @@ -16,7 +18,7 @@ contract SiloFarmStrategy is FarmingStrategyBase {
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

/// @inheritdoc IControllable
string public constant VERSION = "1.0.0";
string public constant VERSION = "1.0.1";

/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* INITIALIZATION */
Expand Down Expand Up @@ -169,7 +171,11 @@ contract SiloFarmStrategy is FarmingStrategyBase {
) internal override returns (uint[] memory amountsOut) {
IFactory.Farm memory farm = _getFarm();
ISilo siloVault = ISilo(farm.addresses[1]);
siloVault.withdraw(value, receiver, address(this), ISilo.CollateralType.Collateral);
uint toWithdraw = value;
if (address(this) == receiver) {
toWithdraw--;
}
siloVault.withdraw(toWithdraw, receiver, address(this), ISilo.CollateralType.Collateral);
amountsOut = new uint[](1);
amountsOut[0] = value;
StrategyBaseStorage storage $base = _getStrategyBaseStorage();
Expand Down Expand Up @@ -199,6 +205,9 @@ contract SiloFarmStrategy is FarmingStrategyBase {
balanceBefore[i] = StrategyLib.balance(__rewardAssets[i]);
}
IFactory.Farm memory farm = _getFarm();
ISilo siloVault = ISilo(farm.addresses[1]);
StrategyBaseStorage storage $base = _getStrategyBaseStorage();
__amounts[0] = siloVault.convertToAssets(siloVault.balanceOf(address(this))) - $base.total;
ISiloIncentivesController(farm.addresses[0]).claimRewards(address(this));
for (uint i; i < rwLen; ++i) {
__rewardAmounts[i] = StrategyLib.balance(__rewardAssets[i]) - balanceBefore[i];
Expand All @@ -219,6 +228,10 @@ contract SiloFarmStrategy is FarmingStrategyBase {
notZero = true;
}
}
IFactory.Farm memory farm = _getFarm();
ISilo siloVault = ISilo(farm.addresses[1]);
StrategyBaseStorage storage $base = _getStrategyBaseStorage();
$base.total = siloVault.convertToAssets(siloVault.balanceOf(address(this)));
if (notZero) {
_depositAssets(amounts, false);
}
Expand Down

0 comments on commit be267d7

Please sign in to comment.