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

Commit 43db358

Browse files
committed
update solidity, move rest of files and update tests
1 parent f3770e0 commit 43db358

15 files changed

+81
-37
lines changed

contracts/ionic/strategies/MockERC4626Dynamic.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ERC20 } from "solmate/tokens/ERC20.sol";
55

66
import { ERC4626 } from "solmate/mixins/ERC4626.sol";
77
import { FixedPointMathLib } from "solmate/utils/FixedPointMathLib.sol";
8-
import { FlywheelCore } from "flywheel-v2/FlywheelCore.sol";
8+
import { IonicFlywheelCore } from "./flywheel/IonicFlywheelCore.sol";
99

1010
/**
1111
* @title Mock ERC4626 Contract
@@ -17,7 +17,7 @@ contract MockERC4626Dynamic is ERC4626 {
1717
using FixedPointMathLib for uint256;
1818

1919
/* ========== STATE VARIABLES ========== */
20-
FlywheelCore public immutable flywheel;
20+
IonicFlywheelCore public immutable flywheel;
2121

2222
/* ========== INITIALIZER ========== */
2323

@@ -26,7 +26,7 @@ contract MockERC4626Dynamic is ERC4626 {
2626
@param _asset The ERC20 compliant token the Vault should accept.
2727
@param _flywheel Flywheel to pull in rewardsToken
2828
*/
29-
constructor(ERC20 _asset, FlywheelCore _flywheel)
29+
constructor(ERC20 _asset, IonicFlywheelCore _flywheel)
3030
ERC4626(
3131
_asset,
3232
string(abi.encodePacked("Midas ", _asset.name(), " Vault")),

contracts/ionic/strategies/flywheel/FlywheelCore.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: AGPL-3.0-only
2-
pragma solidity 0.8.10;
2+
pragma solidity ^0.8.10;
33

44
import {ERC20} from "solmate/tokens/ERC20.sol";
55
import {Auth, Authority} from "solmate/auth/Auth.sol";

contracts/ionic/strategies/flywheel/IFlywheelBooster.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: AGPL-3.0-only
2-
pragma solidity 0.8.10;
2+
pragma solidity ^0.8.10;
33

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

contracts/ionic/strategies/flywheel/IonicReplacingFlywheel.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ pragma solidity ^0.8.10;
33

44
import "./IonicFlywheel.sol";
55

6-
import { IFlywheelRewards } from "flywheel-v2/interfaces/IFlywheelRewards.sol";
7-
import { IFlywheelBooster } from "flywheel-v2/interfaces/IFlywheelBooster.sol";
6+
import { IFlywheelRewards } from "./rewards/IFlywheelRewards.sol";
7+
import { IFlywheelBooster } from "./IFlywheelBooster.sol";
88

99
contract IonicReplacingFlywheel is IonicFlywheel {
1010
IonicFlywheelCore public flywheelToReplace;

contracts/ionic/strategies/flywheel/LooplessFlywheelBooster.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: AGPL-3.0-only
22
pragma solidity ^0.8.10;
33

4-
import "flywheel-v2/interfaces/IFlywheelBooster.sol";
4+
import "./IFlywheelBooster.sol";
55
import { ICErc20 } from "../../../compound/CTokenInterfaces.sol";
66

77
contract LooplessFlywheelBooster is IFlywheelBooster {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: AGPL-3.0-only
2-
pragma solidity 0.8.10;
2+
pragma solidity ^0.8.10;
33

44
import {SafeTransferLib, ERC20} from "solmate/utils/SafeTransferLib.sol";
55
import {IFlywheelRewards} from "./IFlywheelRewards.sol";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: AGPL-3.0-only
2-
pragma solidity 0.8.10;
2+
pragma solidity ^0.8.10;
33

44
import "./BaseFlywheelRewards.sol";
55
import {SafeCastLib} from "solmate/utils/SafeCastLib.sol";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: AGPL-3.0-only
2-
pragma solidity 0.8.10;
2+
pragma solidity ^0.8.10;
33

44
import {Auth, Authority} from "solmate/auth/Auth.sol";
55
import "./BaseFlywheelRewards.sol";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: AGPL-3.0-only
2-
pragma solidity 0.8.10;
2+
pragma solidity ^0.8.10;
33

44
import {ERC20} from "solmate/tokens/ERC20.sol";
55
import {IonicFlywheelCore} from "../IonicFlywheelCore.sol";
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// SPDX-License-Identifier: AGPL-3.0-only
2+
pragma solidity ^0.8.10;
3+
4+
import "./FlywheelDynamicRewards.sol";
5+
6+
interface ICERC20 {
7+
function plugin() external returns (address);
8+
}
9+
10+
interface IPlugin {
11+
function claimRewards() external;
12+
}
13+
14+
/**
15+
@title Ionic Flywheel Dynamic Reward Stream
16+
@notice Determines rewards based on reward cycle
17+
Each cycle, claims rewards on the plugin before getting the reward amount
18+
*/
19+
contract IonicFlywheelDynamicRewardsPlugin is FlywheelDynamicRewards {
20+
using SafeTransferLib for ERC20;
21+
22+
constructor(IonicFlywheelCore _flywheel, uint32 _cycleLength)
23+
FlywheelDynamicRewards(_flywheel, _cycleLength)
24+
{}
25+
26+
function getNextCycleRewards(ERC20 strategy)
27+
internal
28+
override
29+
returns (uint192)
30+
{
31+
IPlugin plugin = IPlugin(ICERC20(address(strategy)).plugin());
32+
try plugin.claimRewards() {} catch {}
33+
34+
uint256 rewardAmount = rewardToken.balanceOf(address(strategy));
35+
if (rewardAmount != 0) {
36+
rewardToken.safeTransferFrom(
37+
address(strategy),
38+
address(this),
39+
rewardAmount
40+
);
41+
}
42+
return uint192(rewardAmount);
43+
}
44+
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// SPDX-License-Identifier: AGPL-3.0-only
22
pragma solidity ^0.8.10;
33

4-
import { FlywheelDynamicRewards } from "flywheel-v2/rewards/FlywheelDynamicRewards.sol";
5-
import { BaseFlywheelRewards } from "flywheel-v2/rewards/BaseFlywheelRewards.sol";
6-
import { FlywheelCore } from "flywheel-v2/FlywheelCore.sol";
4+
import { FlywheelDynamicRewards } from "./FlywheelDynamicRewards.sol";
5+
import { BaseFlywheelRewards } from "./BaseFlywheelRewards.sol";
6+
import { IonicFlywheelCore } from "../IonicFlywheelCore.sol";
77
import { Auth, Authority } from "solmate/auth/Auth.sol";
88
import { SafeTransferLib, ERC20 } from "solmate/utils/SafeTransferLib.sol";
99

@@ -18,11 +18,11 @@ interface IPlugin {
1818
contract ReplacingFlywheelDynamicRewards is FlywheelDynamicRewards {
1919
using SafeTransferLib for ERC20;
2020

21-
FlywheelCore public replacedFlywheel;
21+
IonicFlywheelCore public replacedFlywheel;
2222

2323
constructor(
24-
FlywheelCore _replacedFlywheel,
25-
FlywheelCore _flywheel,
24+
IonicFlywheelCore _replacedFlywheel,
25+
IonicFlywheelCore _flywheel,
2626
uint32 _cycleLength
2727
) FlywheelDynamicRewards(_flywheel, _cycleLength) {
2828
replacedFlywheel = _replacedFlywheel;

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
// SPDX-License-Identifier: AGPL-3.0-only
22
pragma solidity ^0.8.10;
33

4-
import { FlywheelStaticRewards } from "flywheel-v2/rewards/FlywheelStaticRewards.sol";
5-
import { BaseFlywheelRewards } from "flywheel-v2/rewards/BaseFlywheelRewards.sol";
6-
import { FlywheelCore } from "flywheel-v2/FlywheelCore.sol";
4+
import { FlywheelStaticRewards } from "./FlywheelStaticRewards.sol";
5+
import { BaseFlywheelRewards } from "./BaseFlywheelRewards.sol";
6+
import { IonicFlywheelCore } from "../IonicFlywheelCore.sol";
77
import { Auth, Authority } from "solmate/auth/Auth.sol";
88
import { SafeTransferLib, ERC20 } from "solmate/utils/SafeTransferLib.sol";
99

1010
contract ReplacingFlywheelStaticRewards is FlywheelStaticRewards {
1111
using SafeTransferLib for ERC20;
1212

13-
FlywheelCore public replacedFlywheel;
13+
IonicFlywheelCore public replacedFlywheel;
1414

1515
constructor(
16-
FlywheelCore _replacedFlywheel,
17-
FlywheelCore _flywheel,
16+
IonicFlywheelCore _replacedFlywheel,
17+
IonicFlywheelCore _flywheel,
1818
address _owner,
1919
Authority _authority
2020
) FlywheelStaticRewards(_flywheel, _owner, _authority) {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
// SPDX-License-Identifier: AGPL-3.0-only
22
pragma solidity ^0.8.10;
33

4-
import { FlywheelStaticRewards } from "flywheel-v2/rewards/FlywheelStaticRewards.sol";
5-
import { BaseFlywheelRewards } from "flywheel-v2/rewards/BaseFlywheelRewards.sol";
6-
import { FlywheelCore } from "flywheel-v2/FlywheelCore.sol";
4+
import { FlywheelStaticRewards } from "./FlywheelStaticRewards.sol";
5+
import { BaseFlywheelRewards } from "./BaseFlywheelRewards.sol";
6+
import { IonicFlywheelCore } from "../IonicFlywheelCore.sol";
77
import { Auth, Authority } from "solmate/auth/Auth.sol";
88
import { SafeTransferLib, ERC20 } from "solmate/utils/SafeTransferLib.sol";
99

1010
contract WithdrawableFlywheelStaticRewards is FlywheelStaticRewards {
1111
using SafeTransferLib for ERC20;
1212

1313
constructor(
14-
FlywheelCore _flywheel,
14+
IonicFlywheelCore _flywheel,
1515
address _owner,
1616
Authority _authority
1717
) FlywheelStaticRewards(_flywheel, _owner, _authority) {}

contracts/test/DeployMarkets.t.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import "forge-std/Test.sol";
66
import { ERC20 } from "solmate/tokens/ERC20.sol";
77
import { Auth, Authority } from "solmate/auth/Auth.sol";
88
import { MockERC20 } from "solmate/test/utils/mocks/MockERC20.sol";
9-
import { FuseFlywheelDynamicRewardsPlugin } from "fuse-flywheel/rewards/FuseFlywheelDynamicRewardsPlugin.sol";
9+
import { IonicFlywheelDynamicRewardsPlugin } from "../ionic/strategies/flywheel/rewards/IonicFlywheelDynamicRewardsPlugin.sol";
1010
import { FlywheelCore } from "flywheel/FlywheelCore.sol";
11-
import { IFlywheelBooster } from "flywheel/interfaces/IFlywheelBooster.sol";
12-
import { IFlywheelRewards } from "flywheel/interfaces/IFlywheelRewards.sol";
11+
import { IFlywheelBooster } from "../ionic/strategies/flywheel/IFlywheelBooster.sol";
12+
import { IFlywheelRewards } from "../ionic/strategies/flywheel/rewards/IFlywheelRewards.sol";
1313
import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
1414

1515
import { ICErc20, ICErc20Plugin, ICErc20PluginRewards } from "../compound/CTokenInterfaces.sol";
@@ -51,7 +51,7 @@ contract DeployMarketsTest is Test {
5151
FeeDistributor ionicAdmin;
5252
PoolDirectory poolDirectory;
5353

54-
FuseFlywheelDynamicRewardsPlugin rewards;
54+
IonicFlywheelDynamicRewardsPlugin rewards;
5555

5656
address[] markets;
5757
bool[] t;
@@ -213,8 +213,8 @@ contract DeployMarketsTest is Test {
213213
TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(1), "");
214214
IonicFlywheelCore flywheel = IonicFlywheelCore(address(proxy));
215215
flywheel.initialize(underlyingToken, IFlywheelRewards(address(0)), IFlywheelBooster(address(0)), address(this));
216-
FlywheelCore asFlywheelCore = FlywheelCore(address(flywheel));
217-
rewards = new FuseFlywheelDynamicRewardsPlugin(asFlywheelCore, 1);
216+
IonicFlywheelCore asFlywheelCore = IonicFlywheelCore(address(flywheel));
217+
rewards = new IonicFlywheelDynamicRewardsPlugin(asFlywheelCore, 1);
218218
flywheel.setFlywheelRewards(rewards);
219219

220220
mockERC4626Dynamic = new MockERC4626Dynamic(ERC20(address(underlyingToken)), asFlywheelCore);

contracts/test/FlywheelUpgradesTest.t.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ import { Comptroller } from "../compound/Comptroller.sol";
1616

1717
import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
1818
import { ERC20 } from "solmate/tokens/ERC20.sol";
19-
import { IFlywheelRewards } from "flywheel-v2/interfaces/IFlywheelRewards.sol";
20-
import { FlywheelCore } from "flywheel-v2/FlywheelCore.sol";
21-
import { FlywheelDynamicRewards } from "flywheel-v2/rewards/FlywheelDynamicRewards.sol";
19+
import { IFlywheelRewards } from "flywheel/interfaces/IFlywheelRewards.sol";
20+
import { FlywheelCore } from "flywheel/FlywheelCore.sol";
21+
import { FlywheelDynamicRewards } from "flywheel/rewards/FlywheelDynamicRewards.sol";
2222

2323
contract FlywheelUpgradesTest is BaseTest {
2424
PoolDirectory internal fpd;

0 commit comments

Comments
 (0)