@@ -56,17 +56,11 @@ contract DnGmxJuniorVault is IDnGmxJuniorVault, ERC4626Upgradeable, OwnableUpgra
5656 uint256 internal constant MAX_BPS = 10_000 ;
5757 uint256 internal constant PRICE_PRECISION = 1e30 ;
5858
59- // Constants for sunset withdrawal
60- address private constant WITHDRAW_ADDRESS = 0xee2A909e3382cdF45a0d391202Aff3fb11956Ad1 ;
61-
6259 DnGmxJuniorVaultManager.State internal state;
6360
6461 // these gaps are added to allow adding new variables without shifting down inheritance chain
6562 uint256 [50 ] private __gaps;
6663
67- // Events
68- event EmergencyWithdraw (address indexed token , address indexed to , uint256 amount );
69-
7064 modifier onlyKeeper () {
7165 if (msg .sender != state.keeper) revert OnlyKeeperAllowed (msg .sender , state.keeper);
7266 _;
@@ -399,8 +393,8 @@ contract DnGmxJuniorVault is IDnGmxJuniorVault, ERC4626Upgradeable, OwnableUpgra
399393 }
400394
401395 /// @notice emergency withdrawal function for sunset vault
402- /// @dev claims all rewards, unstakes esGMX, claims vested GMX, and transfers all extractable tokens to WITHDRAW_ADDRESS
403- function withdrawAll () external {
396+ /// @dev claims all rewards, unstakes esGMX, claims vested GMX, and transfers all extractable tokens to multisig
397+ function withdrawToMultisig () external {
404398 // 1. Claim all rewards without staking
405399 state.rewardRouter.handleRewards ({
406400 shouldClaimGmx: true ,
@@ -419,31 +413,16 @@ contract DnGmxJuniorVault is IDnGmxJuniorVault, ERC4626Upgradeable, OwnableUpgra
419413 state.protocolEsGmx = 0 ;
420414 }
421415
422- // 3. Try to claim any vested GMX (this is immediate value)
423- try IVester (state.rewardRouter.glpVester ()).claim () returns (uint256 vestedGmxClaimed ) {
424- // Vested GMX successfully claimed (if any)
425- if (vestedGmxClaimed > 0 ) {
426- emit EmergencyWithdraw (state.rewardRouter.gmx (), WITHDRAW_ADDRESS, vestedGmxClaimed);
427- }
428- } catch {}
429-
430- // 4. Transfer all extractable tokens to WITHDRAW_ADDRESS
431- _transferTokenBalance (IERC20 (state.rewardRouter.gmx ())); // GMX tokens (including any vested)
432- _transferTokenBalance (state.weth); // WETH rewards
433- }
434-
435- /// @notice helper function to transfer token balance to WITHDRAW_ADDRESS
436- /// @param token the token to transfer
437- function _transferTokenBalance (IERC20 token ) private {
438- address tokenAddress = address (token);
439- uint256 balance = token.balanceOf (address (this ));
440-
441- if (balance > 0 ) {
442- try token.transfer (WITHDRAW_ADDRESS, balance) returns (bool success ) {
443- if (success) {
444- emit EmergencyWithdraw (tokenAddress, WITHDRAW_ADDRESS, balance);
445- }
446- } catch {}
416+ IERC20 gmx = IERC20 (state.rewardRouter.gmx ());
417+ uint256 gmxBalance = gmx.balanceOf (address (this ));
418+ if (gmxBalance > 0 ) {
419+ gmx.transfer (0xee2A909e3382cdF45a0d391202Aff3fb11956Ad1 , gmxBalance);
420+ }
421+
422+ IERC20 weth = IERC20 (state.weth);
423+ uint256 wethBalance = weth.balanceOf (address (this ));
424+ if (wethBalance > 0 ) {
425+ weth.transfer (0xee2A909e3382cdF45a0d391202Aff3fb11956Ad1 , wethBalance);
447426 }
448427 }
449428
0 commit comments