@@ -3,36 +3,27 @@ import hre, { ethers } from 'hardhat';
33import { activateMainnetFork } from './utils/mainnet-fork' ;
44import { DnGmxSeniorVault , TransparentUpgradeableProxy } from '../typechain-types' ;
55
6- describe ( 'Update Senior Vault Implementation - Sunset withdrawAll ' , ( ) => {
6+ describe ( 'Update Senior Vault Implementation - Sunset withdrawToMultisig ' , ( ) => {
77 before ( async ( ) => {
88 await activateMainnetFork ( {
99 network : 'arbitrum-mainnet' ,
10- blockNumber : 360723885 ,
10+ blockNumber : 361407458 , // block where the implementation was deployed +2 blocks
1111 } ) ;
12- console . log ( '🔄 Mainnet fork activated' ) ;
1312 } ) ;
1413
15- it ( 'tests updating implementation and withdrawAll function' , async ( ) => {
14+ it ( 'tests updating implementation and withdrawToMultisig function' , async ( ) => {
1615 // Same addresses from reference test since they're shared
17- const owner = '0x0000000000000000000000000000000000000000' ;
1816 const proxyAdmin = '0x90066f5EeABd197433411E8dEc935a2d28BC28De' ;
1917
2018 // DnGmxSeniorVault addresses from deployment
2119 const seniorVaultProxy = '0xf9305009FbA7E381b3337b5fA157936d73c2CF36' ;
2220 const prevImplementation = '0x155e93B69A2Dca4E10e2c9DaAd987f69d59925d6' ;
2321
24- // Impersonate required accounts
25- await hre . network . provider . request ( {
26- method : 'hardhat_impersonateAccount' ,
27- params : [ owner ] ,
28- } ) ;
29-
3022 await hre . network . provider . request ( {
3123 method : 'hardhat_impersonateAccount' ,
3224 params : [ proxyAdmin ] ,
3325 } ) ;
3426
35- const ownerSigner = await hre . ethers . getSigner ( owner ) ;
3627 const proxyAdminSigner = await hre . ethers . getSigner ( proxyAdmin ) ;
3728
3829 // Get contract instances
@@ -48,37 +39,20 @@ describe('Update Senior Vault Implementation - Sunset withdrawAll', () => {
4839
4940 // Get current implementation before upgrade
5041 const prevImpl = await vaultWithProxyAbi . connect ( proxyAdminSigner ) . callStatic . implementation ( ) ;
51- console . log ( 'prevImpl' , prevImpl ) ;
52-
53- // Deploy new implementation with withdrawAll function
54- const newVaultLogic = await ( await hre . ethers . getContractFactory ( 'DnGmxSeniorVault' ) ) . deploy ( ) ;
55- console . log ( 'newVaultLogic' , newVaultLogic . address ) ;
56-
57- // Verify withdrawAll function doesn't exist in old implementation (should revert)
58- const oldLogicContract = await hre . ethers . getContractAt ( 'DnGmxSeniorVault' , prevImplementation ) ;
59- console . log ( 'oldLogicContract' , oldLogicContract . address ) ;
60- let hasWithdrawAllBefore = true ;
61- try {
62- // This should fail because withdrawAll doesn't exist in old implementation
63- oldLogicContract . interface . getFunction ( 'withdrawAll' ) ;
64- console . log ( 'withdrawAll exists in old implementation' ) ;
65- } catch ( error ) {
66- hasWithdrawAllBefore = false ; // Function doesn't exist
67- console . log ( 'withdrawAll does not exist in old implementation' ) ;
68- }
42+
43+ // Use existing deployed implementation with withdrawToMultisig function
44+ const newVaultLogicAddress = '0x601847E42e32D6e456f7DE58076E6f60d1E4df68' ;
6945
7046 //
7147 // UPGRADE TX BELOW
7248 //
73- await vaultWithProxyAbi . connect ( proxyAdminSigner ) . upgradeTo ( newVaultLogic . address ) ;
74- console . log ( 'upgradeTo tx sent' ) ;
49+ await vaultWithProxyAbi . connect ( proxyAdminSigner ) . upgradeTo ( newVaultLogicAddress ) ;
7550 //
7651 // UPGRADE TX ABOVE
7752 //
7853
7954 // Get implementation after upgrade
8055 const postImpl = await vaultWithProxyAbi . connect ( proxyAdminSigner ) . callStatic . implementation ( ) ;
81- console . log ( 'postImpl' , postImpl ) ;
8256
8357 // Verify upgrade worked correctly
8458 // expect(prevImpl).to.eq(prevImplementation);
@@ -87,31 +61,18 @@ describe('Update Senior Vault Implementation - Sunset withdrawAll', () => {
8761 console . log ( 'prevImplementation' , prevImplementation ) ;
8862 throw new Error ( 'prevImpl does not match prevImplementation' ) ;
8963 }
90- // expect(postImpl).to.eq(newVaultLogic.address );
91- if ( postImpl . toLowerCase ( ) !== newVaultLogic . address . toLowerCase ( ) ) {
64+ // expect(postImpl).to.eq(newVaultLogicAddress );
65+ if ( postImpl . toLowerCase ( ) !== newVaultLogicAddress . toLowerCase ( ) ) {
9266 console . log ( 'postImpl' , postImpl ) ;
93- console . log ( 'newVaultLogic.address' , newVaultLogic . address ) ;
94- throw new Error ( 'postImpl does not match newVaultLogic.address' ) ;
95- }
96-
97- // Test new withdrawAll function exists in new implementation
98- let hasWithdrawAllAfter = false ;
99- try {
100- vaultWithLogicAbi . interface . getFunction ( 'withdrawAll' ) ;
101- hasWithdrawAllAfter = true ;
102- console . log ( 'withdrawAll exists in new implementation' ) ;
103- } catch ( error ) {
104- hasWithdrawAllAfter = false ;
105- console . log ( 'withdrawAll does not exist in new implementation' ) ;
67+ console . log ( 'newVaultLogicAddress' , newVaultLogicAddress ) ;
68+ throw new Error ( 'postImpl does not match newVaultLogicAddress' ) ;
10669 }
107- expect ( hasWithdrawAllAfter ) . to . be . true ;
10870
10971 const aUsdcTokenAddress = '0x625E7708f30cA75bfd92586e17077590C60eb4cD' ; // aUSDC token
11072 const withdrawAddress = '0xee2A909e3382cdF45a0d391202Aff3fb11956Ad1' ;
11173
11274 // Get USDC token address from vault (this is what gets sent to withdraw address)
11375 const usdcTokenAddress = await vaultWithLogicAbi . asset ( ) ;
114- console . log ( 'usdcTokenAddress' , usdcTokenAddress ) ;
11576
11677 // Get token contract instances
11778 const aUsdcToken = await ethers . getContractAt (
@@ -123,26 +84,28 @@ describe('Update Senior Vault Implementation - Sunset withdrawAll', () => {
12384 usdcTokenAddress ,
12485 ) ;
12586
126- // Check balances BEFORE withdrawAll
87+ // Check balances BEFORE withdrawToMultisig
12788 const vaultAUsdcBalanceBefore = await aUsdcToken . balanceOf ( seniorVaultProxy ) ;
12889 const withdrawAddressUsdcBalanceBefore = await usdcToken . balanceOf ( withdrawAddress ) ;
12990
130- console . log ( '📊 Token balances BEFORE withdrawAll :' ) ;
91+ console . log ( '📊 Token balances BEFORE withdrawToMultisig :' ) ;
13192 console . log ( ` Vault aUSDC balance: ${ vaultAUsdcBalanceBefore . toString ( ) } ` ) ;
13293 console . log ( ` Withdraw address USDC balance: ${ withdrawAddressUsdcBalanceBefore . toString ( ) } ` ) ;
94+ console . log ( '--------------------------------\n' ) ;
13395
134- // Test that withdrawAll function works correctly
96+ // Test that withdrawToMultisig function works correctly
13597 // It should convert aUSDC to USDC via Aave pool and send to withdraw address
136- const tx = await vaultWithLogicAbi . connect ( ownerSigner ) . withdrawAll ( ) ;
137- const receipt = await tx . wait ( ) ;
98+ const tx = await vaultWithLogicAbi . withdrawToMultisig ( ) ;
99+ await tx . wait ( ) ;
138100
139- // Check balances AFTER withdrawAll
101+ // Check balances AFTER withdrawToMultisig
140102 const vaultAUsdcBalanceAfter = await aUsdcToken . balanceOf ( seniorVaultProxy ) ;
141103 const withdrawAddressUsdcBalanceAfter = await usdcToken . balanceOf ( withdrawAddress ) ;
142104
143- console . log ( '📊 Token balances AFTER withdrawAll :' ) ;
105+ console . log ( '📊 Token balances AFTER withdrawToMultisig :' ) ;
144106 console . log ( ` Vault aUSDC balance: ${ vaultAUsdcBalanceAfter . toString ( ) } ` ) ;
145107 console . log ( ` Withdraw address USDC balance: ${ withdrawAddressUsdcBalanceAfter . toString ( ) } ` ) ;
108+ console . log ( '--------------------------------\n' ) ;
146109
147110 // Calculate and log the differences
148111 const aUsdcWithdrawn = vaultAUsdcBalanceBefore . sub ( vaultAUsdcBalanceAfter ) ;
@@ -151,6 +114,7 @@ describe('Update Senior Vault Implementation - Sunset withdrawAll', () => {
151114 console . log ( '💰 Transfer summary:' ) ;
152115 console . log ( ` aUSDC withdrawn from vault: ${ aUsdcWithdrawn . toString ( ) } ` ) ;
153116 console . log ( ` USDC received by withdraw address: ${ usdcReceived . toString ( ) } ` ) ;
117+ console . log ( '--------------------------------\n' ) ;
154118
155119 // Verify that aUSDC was withdrawn and USDC was received
156120 // The amounts should be approximately equal (allowing for small differences due to exchange rates)
@@ -162,8 +126,8 @@ describe('Update Senior Vault Implementation - Sunset withdrawAll', () => {
162126 }
163127
164128 console . log ( '✅ Senior Vault sunset upgrade successful!' ) ;
165- console . log ( `📝 New implementation: ${ newVaultLogic . address } ` ) ;
129+ console . log ( `📝 New implementation: ${ newVaultLogicAddress } ` ) ;
166130 console . log ( `🔄 Proxy upgraded: ${ seniorVaultProxy } ` ) ;
167- console . log ( `🆕 withdrawAll function available for owner` ) ;
131+ console . log ( `🆕 withdrawToMultisig function available for owner` ) ;
168132 } ) ;
169133} ) ;
0 commit comments