Skip to content
This repository was archived by the owner on Aug 26, 2024. It is now read-only.

Commit 34ace4a

Browse files
committed
revert last commit and fix code style
1 parent 18ee388 commit 34ace4a

File tree

4 files changed

+23
-82
lines changed

4 files changed

+23
-82
lines changed

contracts/ionic/strategies/flywheel/IIonicFlywheelBorrowBooster.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ import { ICErc20 } from "../../../compound/CTokenInterfaces.sol";
1717
This prevents gaming of the reward calculation function by using manipulated balances when accruing.
1818
*/
1919
interface IIonicFlywheelBorrowBooster {
20-
/**
20+
/**
2121
@notice calculate the boosted supply of a strategy.
2222
@param strategy the strategy to calculate boosted supply of
2323
@return the boosted supply
2424
*/
25-
function boostedTotalSupply(ICErc20 strategy) external view returns (uint256);
25+
function boostedTotalSupply(ICErc20 strategy) external view returns (uint256);
2626

27-
/**
27+
/**
2828
@notice calculate the boosted balance of a user in a given strategy.
2929
@param strategy the strategy to calculate boosted balance of
3030
@param user the user to calculate boosted balance of
3131
@return the boosted balance
3232
*/
33-
function boostedBalanceOf(ICErc20 strategy, address user) external view returns (uint256);
33+
function boostedBalanceOf(ICErc20 strategy, address user) external view returns (uint256);
3434
}

contracts/ionic/strategies/flywheel/IonicFlywheelBorrowBooster.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,3 @@ contract IonicFlywheelBorrowBooster is IIonicFlywheelBorrowBooster {
2626
return strategy.borrowBalanceCurrent(user);
2727
}
2828
}
29-

contracts/ionic/strategies/flywheel/rewards/IonicFlywheelDynamicRewards.sol

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,28 @@ import { FlywheelDynamicRewards } from "flywheel-v2/rewards/FlywheelDynamicRewar
55
import { FlywheelCore } from "flywheel-v2/FlywheelCore.sol";
66
import { SafeTransferLib, ERC20 } from "solmate/utils/SafeTransferLib.sol";
77

8-
contract IonicFlywheelDynamicRewards is FlywheelDynamicRewards {
9-
using SafeTransferLib for ERC20;
10-
11-
address public owner;
12-
mapping(address => address) public strategyVaults;
8+
interface ICERC20 {
9+
function plugin() external returns (address);
10+
}
1311

14-
modifier onlyOwner() {
15-
require(msg.sender == owner, "Only owner can call this function");
16-
_;
17-
}
12+
interface IPlugin {
13+
function claimRewards() external;
14+
}
1815

19-
constructor(
20-
FlywheelCore _flywheel,
21-
uint32 _cycleLength
22-
) FlywheelDynamicRewards(_flywheel, _cycleLength) {
23-
owner = msg.sender;
24-
}
16+
contract IonicFlywheelDynamicRewards is FlywheelDynamicRewards {
17+
using SafeTransferLib for ERC20;
2518

26-
function setVaults(address[] calldata _strategies, address[] calldata _vaults) external onlyOwner {
27-
uint256 length = _strategies.length;
28-
require(length == _vaults.length, "INVALID_ARGUMENTS");
29-
for(uint256 i=0; i<length; i++) {
30-
strategyVaults[_strategies[i]] = _vaults[i];
31-
}
32-
}
19+
constructor(FlywheelCore _flywheel, uint32 _cycleLength) FlywheelDynamicRewards(_flywheel, _cycleLength) {}
3320

34-
function getNextCycleRewards(ERC20 strategy) internal override returns (uint192) {
35-
address vault = strategyVaults[address(strategy)];
36-
uint256 rewardAmount = rewardToken.balanceOf(vault);
37-
if (rewardAmount != 0) {
38-
rewardToken.safeTransferFrom(
39-
vault,
40-
address(this),
41-
rewardAmount
42-
);
43-
}
44-
return uint192(rewardAmount);
21+
function getNextCycleRewards(ERC20 strategy) internal override returns (uint192) {
22+
// make it work for both pulled (claimed) and pushed (transferred some other way) rewards
23+
try ICERC20(address(strategy)).plugin() returns (address plugin) {
24+
try IPlugin(plugin).claimRewards() {} catch {}
25+
} catch {}
26+
uint256 rewardAmount = rewardToken.balanceOf(address(strategy));
27+
if (rewardAmount != 0) {
28+
rewardToken.safeTransferFrom(address(strategy), address(this), rewardAmount);
4529
}
30+
return uint192(rewardAmount);
31+
}
4632
}

contracts/ionic/strategies/flywheel/rewards/IonicFlywheelVault.sol

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)