@@ -139,6 +139,7 @@ async function stakeValidator({
139139 depositMessageRoot,
140140 forkVersion,
141141 uuid,
142+ consol = false ,
142143} ) {
143144 const signer = await getSigner ( ) ;
144145
@@ -163,6 +164,9 @@ async function stakeValidator({
163164 "CompoundingStakingSSVStrategyProxy" ,
164165 "CompoundingStakingSSVStrategy"
165166 ) ;
167+ const contract = consol
168+ ? await resolveContract ( "ConsolidationController" )
169+ : strategy ;
166170
167171 if ( ! withdrawalCredentials ) {
168172 withdrawalCredentials = calcWithdrawalCredential ( "0x02" , strategy . address ) ;
@@ -207,9 +211,11 @@ async function stakeValidator({
207211 }
208212
209213 log (
210- `About to stake ${ amount } ETH to validator with pubkey ${ pubkey } , deposit root ${ depositDataRoot } and signature ${ sig } `
214+ `About to stake ${ amount } ETH to validator with pubkey ${ pubkey } , deposit root ${ depositDataRoot } and signature ${ sig } via ${
215+ consol ? "ConsolidationController" : "strategy"
216+ } `
211217 ) ;
212- const tx = await strategy
218+ const tx = await contract
213219 . connect ( signer )
214220 . stakeEth ( { pubkey, signature : sig , depositDataRoot } , amountGwei ) ;
215221 const receipt = await logTxDetails ( tx , "stakeETH" ) ;
@@ -421,16 +427,23 @@ async function autoValidatorDeposits({
421427 }
422428}
423429
424- async function withdrawValidator ( { pubkey, amount, signer } ) {
425- const strategy = await resolveContract (
426- "CompoundingStakingSSVStrategyProxy" ,
427- "CompoundingStakingSSVStrategy"
428- ) ;
430+ async function withdrawValidator ( { pubkey, amount, signer, consol = false } ) {
431+ const strategy = consol
432+ ? await resolveContract ( "ConsolidationController" )
433+ : await resolveContract (
434+ "CompoundingStakingSSVStrategyProxy" ,
435+ "CompoundingStakingSSVStrategy"
436+ ) ;
429437
430438 /// Get the validator's balance
431439 const balance = await getValidatorBalance ( pubkey ) ;
432440
433441 const isFullExit = amount === undefined || amount === 0 ;
442+ if ( consol && isFullExit ) {
443+ throw new Error (
444+ "The ConsolidationController only supports partial withdrawals. Set a non-zero amount."
445+ ) ;
446+ }
434447 const amountGwei = isFullExit ? 0 : parseUnits ( amount . toString ( ) , 9 ) ;
435448 if ( isFullExit ) {
436449 log (
@@ -441,13 +454,9 @@ async function withdrawValidator({ pubkey, amount, signer }) {
441454 ) ;
442455 } else {
443456 log (
444- `About to partially withdraw ${ formatUnits (
445- amountGwei ,
446- 9
447- ) } ETH from validator with balance ${ formatUnits (
448- balance ,
449- 9
450- ) } ETH and pubkey ${ pubkey } `
457+ `About to partially withdraw ${ formatUnits ( amountGwei , 9 ) } ETH from ${
458+ consol ? "ConsolidationController" : "validator"
459+ } with balance ${ formatUnits ( balance , 9 ) } ETH and pubkey ${ pubkey } `
451460 ) ;
452461 }
453462 // Send 1 wei of value to cover the request withdrawal fee
0 commit comments