Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync FuseFlywheelRewardsPlugin.sol Contract Name #24

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/rewards/FuseFlywheelDynamicRewardsPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ contract FuseFlywheelDynamicRewardsPlugin is FlywheelDynamicRewards {
}
return uint192(rewardAmount);
}
}
}
4 changes: 2 additions & 2 deletions src/rewards/FuseFlywheelRewardsPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ interface IERC4626 {
function claimRewards() external;
}

/**
/**
@title Fuse Flywheel Plugin Reward Stream
@notice Determines rewards based on how many reward tokens appeared in the market itself since last accrual.
All rewards are claimed atomically, so there is no need to use the last reward timestamp.
*/
contract FuseFlywheelDynamicRewards is IFlywheelRewards {
contract FuseFlywheelRewardsPlugin is IFlywheelRewards {
using SafeTransferLib for ERC20;

event Log(string message);
Expand Down
68 changes: 49 additions & 19 deletions src/test/integration/pools/FusePool156test.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,27 @@ import "../../interfaces/IPlugin.sol";

contract FusePool156Test is DSTestPlus, Test {
FuseAdmin fuseAdmin = FuseAdmin(0xa731585ab05fC9f83555cf9Bff8F58ee94e18F85);

// pool 156 comptroller
Comptroller comptroller = Comptroller(0x07cd53380FE9B2a5E64099591b498c73F0EfaA66);
Comptroller comptroller =
Comptroller(0x07cd53380FE9B2a5E64099591b498c73F0EfaA66);
address multisig = 0x5eA4A9a7592683bF0Bc187d6Da706c6c4770976F;
address user = 0xB290f2F3FAd4E540D0550985951Cdad2711ac34A;

address cvxcrvCRV = 0x9D0464996170c6B9e75eED71c68B99dDEDf279e8;
address cvxFXSFXS = 0xF3A43307DcAFa93275993862Aae628fCB50dC768;
address rethstethCRV = 0x447Ddd4960d9fdBF6af9a790560d0AF76795CB08;

ERC20 cvx = ERC20(0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B);
ERC20 crv = ERC20(0xD533a949740bb3306d119CC777fa900bA034cd52);
ERC20 fxs = ERC20(0x3432B6A60D23Ca0dFCa7761B7ab56459D9C964D0);

FlywheelCore cvxFlywheelCore = FlywheelCore(0x18B9aE8499e560bF94Ef581420c38EC4CfF8559C);
FlywheelCore crvFlywheelCore = FlywheelCore(0x65DFbde18D7f12a680480aBf6e17F345d8637829);
FlywheelCore fxsFlywheelCore = FlywheelCore(0x30E9A1Bc6A6a478fC32F9ac900C6530Ad3A1616F);
FlywheelCore cvxFlywheelCore =
FlywheelCore(0x18B9aE8499e560bF94Ef581420c38EC4CfF8559C);
FlywheelCore crvFlywheelCore =
FlywheelCore(0x65DFbde18D7f12a680480aBf6e17F345d8637829);
FlywheelCore fxsFlywheelCore =
FlywheelCore(0x30E9A1Bc6A6a478fC32F9ac900C6530Ad3A1616F);

function setUp() public {
hevm.label(address(fuseAdmin), "fuseAdmin");
Expand All @@ -51,30 +55,41 @@ contract FusePool156Test is DSTestPlus, Test {
require(cvxCRVf.mint(100e18) == 0, "mint failed");

tip(rethstethCRV, user, 100e18);
CErc20 rethstethCRVf = CErc20(0xD88B2E6304d1827e22D2ACC2FbCeD836cd439b85);
CErc20 rethstethCRVf = CErc20(
0xD88B2E6304d1827e22D2ACC2FbCeD836cd439b85
);
require(rethstethCRVf.mint(100e18) == 0, "mint failed");

// cvxFXSFXSf
uint accrue = cvxFlywheelCore.accrue(ERC20(address(cvxFXSf)), user);
uint256 accrue = cvxFlywheelCore.accrue(ERC20(address(cvxFXSf)), user);
require(accrue > 0, "cvxFlywheel accrue");
uint accrued = cvxFlywheelCore.rewardsAccrued(user);
uint prebalance = cvx.balanceOf(user);
uint256 accrued = cvxFlywheelCore.rewardsAccrued(user);
uint256 prebalance = cvx.balanceOf(user);
cvxFlywheelCore.claimRewards(user);
require(cvx.balanceOf(user) == prebalance + accrued, "cvxFlywheel claimRewards");
require(
cvx.balanceOf(user) == prebalance + accrued,
"cvxFlywheel claimRewards"
);

accrue = crvFlywheelCore.accrue(ERC20(address(cvxFXSf)), user);
require(accrue > 0, "crvFlywheel accrue");
accrued = crvFlywheelCore.rewardsAccrued(user);
prebalance = crv.balanceOf(user);
crvFlywheelCore.claimRewards(user);
require(crv.balanceOf(user) == prebalance + accrued, "crvFlywheel claimRewards");
require(
crv.balanceOf(user) == prebalance + accrued,
"crvFlywheel claimRewards"
);

accrue = fxsFlywheelCore.accrue(ERC20(address(cvxFXSf)), user);
require(accrue > 0, "fxsFlywheel accrue");
accrued = fxsFlywheelCore.rewardsAccrued(user);
prebalance = fxs.balanceOf(user);
fxsFlywheelCore.claimRewards(user);
require(fxs.balanceOf(user) == prebalance + accrued, "fxsFlywheel claimRewards");
require(
fxs.balanceOf(user) == prebalance + accrued,
"fxsFlywheel claimRewards"
);

// cvxCRVf
hevm.warp(block.timestamp + 10);
Expand All @@ -83,14 +98,20 @@ contract FusePool156Test is DSTestPlus, Test {
accrued = cvxFlywheelCore.rewardsAccrued(user);
prebalance = cvx.balanceOf(user);
cvxFlywheelCore.claimRewards(user);
require(cvx.balanceOf(user) == prebalance + accrued, "cvxFlywheel claimRewards");
require(
cvx.balanceOf(user) == prebalance + accrued,
"cvxFlywheel claimRewards"
);

accrue = crvFlywheelCore.accrue(ERC20(address(cvxCRVf)), user);
require(accrue > 0, "crvFlywheel accrue");
accrued = crvFlywheelCore.rewardsAccrued(user);
prebalance = crv.balanceOf(user);
crvFlywheelCore.claimRewards(user);
require(crv.balanceOf(user) == prebalance + accrued, "crvFlywheel claimRewards");
require(
crv.balanceOf(user) == prebalance + accrued,
"crvFlywheel claimRewards"
);

// rethstethCRVf
hevm.warp(block.timestamp + 10);
Expand All @@ -99,17 +120,26 @@ contract FusePool156Test is DSTestPlus, Test {
accrued = cvxFlywheelCore.rewardsAccrued(user);
prebalance = cvx.balanceOf(user);
cvxFlywheelCore.claimRewards(user);
require(cvx.balanceOf(user) == prebalance + accrued, "cvxFlywheel claimRewards");
require(
cvx.balanceOf(user) == prebalance + accrued,
"cvxFlywheel claimRewards"
);

accrue = crvFlywheelCore.accrue(ERC20(address(rethstethCRVf)), user);
require(accrue > 0, "crvFlywheel accrue");
accrued = crvFlywheelCore.rewardsAccrued(user);
prebalance = crv.balanceOf(user);
crvFlywheelCore.claimRewards(user);
require(crv.balanceOf(user) == prebalance + accrued, "crvFlywheel claimRewards");
require(
crv.balanceOf(user) == prebalance + accrued,
"crvFlywheel claimRewards"
);

require(cvxFXSf.redeem(cvxFXSf.balanceOf(user)) == 0, "cvxFXS redeem");
require(cvxCRVf.redeem(cvxCRVf.balanceOf(user)) == 0, "cvxCRV redeem");
require(rethstethCRVf.redeem(rethstethCRVf.balanceOf(user)) == 0, "rethstethCRV redeem");
require(
rethstethCRVf.redeem(rethstethCRVf.balanceOf(user)) == 0,
"rethstethCRV redeem"
);
}
}
}
58 changes: 43 additions & 15 deletions src/test/integration/pools/FusePool190test.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ contract Pool190Test is DSTestPlus, Test {
function setUp() public {}

function testPool190() public {

FuseAdmin fuseAdmin = FuseAdmin(0xa731585ab05fC9f83555cf9Bff8F58ee94e18F85);
FuseAdmin fuseAdmin = FuseAdmin(
0xa731585ab05fC9f83555cf9Bff8F58ee94e18F85
);
hevm.label(address(fuseAdmin), "fuseAdmin");
// pool 190 comptroller
Comptroller comptroller = Comptroller(0x4Ba827A642F99773dB5CD39689B410f4646f56E3);
Comptroller comptroller = Comptroller(
0x4Ba827A642F99773dB5CD39689B410f4646f56E3
);
hevm.label(address(comptroller), "comptroller");
address multisig = 0x5eA4A9a7592683bF0Bc187d6Da706c6c4770976F;
hevm.label(multisig, "multisig");
Expand All @@ -34,8 +37,12 @@ contract Pool190Test is DSTestPlus, Test {
address tAlcx = 0xD3B5D9a561c293Fb42b446FE7e237DaA9BF9AA84;
address alcxeth = 0xC3f279090a47e80990Fe3a9c30d24Cb117EF91a8;

FlywheelCore alcxFlywheelCore = FlywheelCore(0x48635Dd90B1d15F3bC60280C36Fb1c7b95108853);
FlywheelCore sushiFlywheelCore = FlywheelCore(0xC78C326Ae403002eC4b328F5314763953fa06e0F);
FlywheelCore alcxFlywheelCore = FlywheelCore(
0x48635Dd90B1d15F3bC60280C36Fb1c7b95108853
);
FlywheelCore sushiFlywheelCore = FlywheelCore(
0xC78C326Ae403002eC4b328F5314763953fa06e0F
);

hevm.startPrank(user);

Expand All @@ -46,12 +53,18 @@ contract Pool190Test is DSTestPlus, Test {
hevm.warp(block.timestamp + 100);

// alEthLpf
uint accrue = alcxFlywheelCore.accrue(ERC20(address(alEthLpf)), user);
uint256 accrue = alcxFlywheelCore.accrue(
ERC20(address(alEthLpf)),
user
);
require(accrue > 0, "alcxFlywheelCore accrue1");
uint accrued = alcxFlywheelCore.rewardsAccrued(user);
uint prebalance = alcx.balanceOf(user);
uint256 accrued = alcxFlywheelCore.rewardsAccrued(user);
uint256 prebalance = alcx.balanceOf(user);
alcxFlywheelCore.claimRewards(user);
require(alcx.balanceOf(user) == prebalance + accrued, "alcxFlywheelCore claimRewards");
require(
alcx.balanceOf(user) == prebalance + accrued,
"alcxFlywheelCore claimRewards"
);

hevm.warp(block.timestamp + 10);

Expand All @@ -65,7 +78,10 @@ contract Pool190Test is DSTestPlus, Test {
accrued = alcxFlywheelCore.rewardsAccrued(user);
prebalance = alcx.balanceOf(user);
alcxFlywheelCore.claimRewards(user);
require(alcx.balanceOf(user) == prebalance + accrued, "alcxFlywheelCore claimRewards");
require(
alcx.balanceOf(user) == prebalance + accrued,
"alcxFlywheelCore claimRewards"
);

tip(alcxeth, user, 100e18);
CErc20 alcxethf = CErc20(0x2C671c44E205147792fb33Ee889fE112e3e34579);
Expand All @@ -77,17 +93,29 @@ contract Pool190Test is DSTestPlus, Test {
accrued = alcxFlywheelCore.rewardsAccrued(user);
prebalance = alcx.balanceOf(user);
alcxFlywheelCore.claimRewards(user);
require(alcx.balanceOf(user) == prebalance + accrued, "alcxFlywheelCore claimRewards");
require(
alcx.balanceOf(user) == prebalance + accrued,
"alcxFlywheelCore claimRewards"
);

accrue = sushiFlywheelCore.accrue(ERC20(address(alcxethf)), user);
require(accrue > 0, "sushiFlywheelCore");
accrued = sushiFlywheelCore.rewardsAccrued(user);
prebalance = sushi.balanceOf(user);
sushiFlywheelCore.claimRewards(user);
require(sushi.balanceOf(user) == prebalance + accrued, "sushiFlywheelCore claimRewards");

require(alEthLpf.redeem(alEthLpf.balanceOf(user)) == 0, "alEthlpf redeem");
require(
sushi.balanceOf(user) == prebalance + accrued,
"sushiFlywheelCore claimRewards"
);

require(
alEthLpf.redeem(alEthLpf.balanceOf(user)) == 0,
"alEthlpf redeem"
);
require(tAlcxf.redeem(tAlcxf.balanceOf(user)) == 0, "tAlcxf redeem");
require(alcxethf.redeem(alcxethf.balanceOf(user)) == 0, "alcxethf redeem");
require(
alcxethf.redeem(alcxethf.balanceOf(user)) == 0,
"alcxethf redeem"
);
}
}
Loading