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

Commit

Permalink
Update flywheel contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
antisaa committed Jul 10, 2024
1 parent d4b4eca commit 0457af0
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 9 deletions.
2 changes: 1 addition & 1 deletion contracts/ionic/strategies/flywheel/IIonicFlywheel.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.10;
pragma solidity ^0.8.10;

import { ERC20 } from "solmate/tokens/ERC20.sol";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.10;
pragma solidity ^0.8.10;

import { ICErc20 } from "../../../compound/CTokenInterfaces.sol";

Expand All @@ -16,7 +16,7 @@ import { ICErc20 } from "../../../compound/CTokenInterfaces.sol";
SECURITY NOTE: similar to how Core needs to be notified any time the strategy user composition changes, the booster would need to be notified of any conditions which change the boosted balances atomically.
This prevents gaming of the reward calculation function by using manipulated balances when accruing.
*/
interface IFlywheelBorrowBooster {
interface IIonicFlywheelBorrowBooster {
/**
@notice calculate the boosted supply of a strategy.
@param strategy the strategy to calculate boosted supply of
Expand Down
2 changes: 1 addition & 1 deletion contracts/ionic/strategies/flywheel/IonicFlywheel.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.10;
pragma solidity ^0.8.10;

import { ERC20 } from "solmate/tokens/ERC20.sol";
import { IonicFlywheelCore } from "./IonicFlywheelCore.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ERC20 } from "solmate/tokens/ERC20.sol";
import { IonicFlywheelCore } from "./IonicFlywheelCore.sol";
import "./IIonicFlywheel.sol";

contract IonicBorrowFlywheel is IonicFlywheelCore, IIonicFlywheel {
contract IonicFlywheelBorrow is IonicFlywheelCore, IIonicFlywheel {
bool public constant isRewardsDistributor = true;
bool public constant isFlywheel = true;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.10;
pragma solidity ^0.8.10;

import { ICErc20 } from "../../../compound/CTokenInterfaces.sol";
import "./IFlywheelBorrowBooster.sol";
import "./IIonicFlywheelBorrowBooster.sol";

contract FlywheelBorrowBooster is IFlywheelBorrowBooster {
contract IonicFlywheelBorrowBooster is IIonicFlywheelBorrowBooster {
string public constant BOOSTER_TYPE = "FlywheelBorrowBooster";

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.10;

import { FlywheelDynamicRewards } from "flywheel-v2/rewards/FlywheelDynamicRewards.sol";
import { FlywheelCore } from "flywheel-v2/FlywheelCore.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;

constructor(
FlywheelCore _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);
}
return uint192(rewardAmount);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.10;
pragma solidity ^0.8.10;

import { FlywheelDynamicRewards } from "flywheel-v2/rewards/FlywheelDynamicRewards.sol";
import { BaseFlywheelRewards } from "flywheel-v2/rewards/BaseFlywheelRewards.sol";
Expand Down

0 comments on commit 0457af0

Please sign in to comment.