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

Commit

Permalink
Update Ionic flywheel dynamic rewards
Browse files Browse the repository at this point in the history
  • Loading branch information
antisaa committed Jul 22, 2024
1 parent c6254a1 commit bf99e80
Showing 1 changed file with 18 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,26 @@ import { FlywheelDynamicRewards } from "./FlywheelDynamicRewards.sol";
import { IonicFlywheelCore } from "../IonicFlywheelCore.sol";
import { SafeTransferLib, ERC20 } from "solmate/utils/SafeTransferLib.sol";

interface ICERC20 {
function plugin() external returns (address);
}

interface IPlugin {
function claimRewards() external;
}

contract IonicFlywheelDynamicRewards is FlywheelDynamicRewards {
using SafeTransferLib for ERC20;
using SafeTransferLib for ERC20;

constructor(IonicFlywheelCore _flywheel, uint32 _cycleLength) FlywheelDynamicRewards(_flywheel, _cycleLength) {}
constructor(IonicFlywheelCore _flywheel, uint32 _cycleLength)
FlywheelDynamicRewards(_flywheel, _cycleLength)
{}

function getNextCycleRewards(ERC20 strategy) internal override returns (uint192) {
// make it work for both pulled (claimed) and pushed (transferred some other way) rewards
try ICERC20(address(strategy)).plugin() returns (address plugin) {
try IPlugin(plugin).claimRewards() {} catch {}
} catch {}
uint256 rewardAmount = rewardToken.balanceOf(address(strategy));
if (rewardAmount != 0) {
rewardToken.safeTransferFrom(address(strategy), address(this), rewardAmount);
function getNextCycleRewards(ERC20 strategy)
internal
override
returns (uint192)
{
uint256 rewardAmount = rewardToken.balanceOf(address(strategy));
if (rewardAmount != 0) {
rewardToken.safeTransferFrom(
address(strategy),
address(this),
rewardAmount
);
}
return uint192(rewardAmount);
}
return uint192(rewardAmount);
}
}

0 comments on commit bf99e80

Please sign in to comment.