57837 sc low moonwellwethstrategy cant claim reward from moonwell comptroller
Previous57197 sc high incorrect totallocked reductionNext57483 sc medium fees could be skipped when there is not enough collateral
Was this helpful?
Was this helpful?
Was this helpful?
diff --git a/src/test/strategies/MoonwellWETHStrategy.t.sol b/src/test/strategies/MoonwellWETHStrategy.t.sol
index a200fa1..03b95c0 100644
--- a/src/test/strategies/MoonwellWETHStrategy.t.sol
+++ b/src/test/strategies/MoonwellWETHStrategy.t.sol
@@ -10,6 +10,17 @@ contract MockMoonwellWETHStrategy is MoonwellWETHStrategy {
{}
}
+interface IComptroller {
+ function mintAllowed(address mToken, address minter, uint256 amount) external returns (uint);
+ function _setMarketSupplyCaps(address[] calldata mTokens, uint[] calldata newBorrowCaps) external;
+ function claimReward() external;
+}
+
+interface IERC20 {
+ function totalSupply() external returns(uint256);
+ function balanceOf(address user) external returns(uint256);
+}
+
contract MoonwellWETHStrategyTest is BaseStrategyTest {
address public constant MOONWELL_WETH_MTOKEN = 0xb4104C02BBf4E9be85AAa41a62974E4e28D59A33;
address public constant WETH = 0x4200000000000000000000000000000000000006;
@@ -45,6 +56,43 @@ contract MoonwellWETHStrategyTest is BaseStrategyTest {
return vm.envString("OPTIMISM_RPC_URL");
}
+ function test_cantClaimMoonwellRewardWETH() public {
+ uint256 amountToAllocate = 10e18;
+
+ address comptroller = 0xCa889f40aae37FFf165BccF69aeF1E82b5C511B9;
+ address wellToken = 0xA88594D404727625A9437C3f886C7643872296AE;
+
+ deal(testConfig.vaultAsset, strategy, amountToAllocate);
+ bytes memory prevAllocationAmount = abi.encode(0);
+
+ vm.startPrank(vault);
+ IMYTStrategy(strategy).allocate(prevAllocationAmount, amountToAllocate, "", address(vault));
+ uint256 initialRealAssets = IMYTStrategy(strategy).realAssets();
+ require(initialRealAssets > 0, "Initial real assets is 0");
+ vm.stopPrank();
+
+ vm.warp(block.timestamp + 365 days);
+
+ uint256 id = vm.snapshot();
+
+ // we prank as strategy and claim reward, to check that its indeed accrued reward of WELL token
+ vm.startPrank(strategy);
+ uint256 balBefore = IERC20(wellToken).balanceOf(address(strategy));
+ IComptroller(comptroller).claimReward();
+ uint256 balAfter = IERC20(wellToken).balanceOf(address(strategy));
+ console.log("reward accrued that can be claimed");
+ console.log(balAfter - balBefore);
+ vm.stopPrank();
+
+ vm.revertTo(id);
+ // now we use claim reward function from the strategy itself
+ balBefore = IERC20(wellToken).balanceOf(address(strategy));
+ IMYTStrategy(strategy).claimRewards();
+ balAfter = IERC20(wellToken).balanceOf(address(strategy));
+ console.log("actual reward claimed via MYTStrategy");
+ console.log(balAfter - balBefore);
+ }
+
// Add any strategy-specific tests here
function test_strategy_full_deallocate_does_not_revert_due_to_rounding(uint256 amountToAllocate, uint256 amountToDeallocate) public {
amountToAllocate = bound(amountToAllocate, 1 * 10 ** testConfig.decimals, testConfig.vaultInitialDeposit);
[PASS] test_cantClaimMoonwellRewardWETH() (gas: 3757691)
Logs:
reward accrued that can be claimed
583334320865371875484
actual reward claimed via MYTStrategy
0
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 258.30ms (12.06ms CPU time)
Ran 1 test suite in 260.77ms (258.30ms CPU time): 1 tests passed, 0 failed, 0 skipped (1 total tests)