diff --git a/contracts/interfaces/gmx/IRewardRouterV2.sol b/contracts/interfaces/gmx/IRewardRouterV2.sol index 7bc40eb9..06c2f88b 100644 --- a/contracts/interfaces/gmx/IRewardRouterV2.sol +++ b/contracts/interfaces/gmx/IRewardRouterV2.sol @@ -9,6 +9,10 @@ interface IRewardRouterV2 { event StakeGlp(address account, uint256 amount); event UnstakeGlp(address account, uint256 amount); + function feeGmxTracker() external view returns (address); + + function feeGlpTracker() external view returns (address); + function batchStakeGmxForAccount(address[] memory _accounts, uint256[] memory _amounts) external; function stakeGmxForAccount(address _account, uint256 _amount) external; diff --git a/contracts/yieldStrategy/gmx/GlpStakingManager.sol b/contracts/yieldStrategy/gmx/GlpStakingManager.sol index e9c9e840..c48709f0 100644 --- a/contracts/yieldStrategy/gmx/GlpStakingManager.sol +++ b/contracts/yieldStrategy/gmx/GlpStakingManager.sol @@ -9,6 +9,7 @@ import { IERC20Metadata } from '@openzeppelin/contracts/interfaces/IERC20Metadat import { IGlpManager } from 'contracts/interfaces/gmx/IGlpManager.sol'; import { IVault as IGMXVault } from 'contracts/interfaces/gmx/IVault.sol'; import { ISGLPExtended } from 'contracts/interfaces/gmx/ISGLPExtended.sol'; +import { IRewardTracker } from 'contracts/interfaces/gmx/IRewardTracker.sol'; import { IRewardRouterV2 } from 'contracts/interfaces/gmx/IRewardRouterV2.sol'; import { IGMXBatchingManager } from 'contracts/interfaces/gmx/IGMXBatchingManager.sol'; import { FullMath } from '@uniswap/v3-core-0.8-support/contracts/libraries/FullMath.sol'; @@ -152,7 +153,7 @@ contract GlpStakingManager is RageERC4626, OwnableUpgradeable { } /// @notice stakes the rewards from the staked Glp and claims WETH to buy glp - function _harvestFees() internal { + function harvestFees() public { rewardRouter.handleRewards( false, // _shouldClaimGmx false, // _shouldStakeGmx @@ -185,7 +186,7 @@ contract GlpStakingManager is RageERC4626, OwnableUpgradeable { function _beforeShareAllocation() internal override { /// @dev check if the msg.sender is vault if (!isVault[msg.sender]) revert GSM_CALLER_NOT_VAULT(); - _harvestFees(); + harvestFees(); } /* solhint-disable no-empty-blocks */ @@ -207,6 +208,17 @@ contract GlpStakingManager is RageERC4626, OwnableUpgradeable { return fsGlp.balanceOf(address(this)) + batchingManager.stakingManagerGlpBalance(); } + /// @notice unclaimed WETH rewards of sGlp, esGmx & bnGmx + function unclaimedFees() external view returns (uint256) { + IRewardTracker feeGmxTracker = IRewardTracker(rewardRouter.feeGmxTracker()); + IRewardTracker feeGlpTracker = IRewardTracker(rewardRouter.feeGlpTracker()); + + uint256 wethGmx = feeGmxTracker.claimable(address(this)); + uint256 wethGlp = feeGlpTracker.claimable(address(this)); + + return wethGmx + wethGlp; + } + /// @notice converts input token to sGLP /// @dev only works for usdc and weth because approval is only given for those tokens /// @param token address of token