Skip to main content

withdrawal sub-class

The following readme describes all the functions and their parameters exposed by the withdrawal class of the Stakehouse SDK.

reportSweeps function

Report sweeps to the contract.

Input Parameters

shanghaiReport: Sweep report in the ShanghaiReport structure
authenticatedReport: Authenticated Shanghai sweep report

Using reportSweeps function

await sdk.withdrawal.reportSweeps(shanghaiReport, authenticatedReport);

Return Parameter

Transaction hash if the transaction is successful.

isValidShanghaiReport function

Check if the shanghai sweep report is valid or not.

Input Parameters

shanghaiReport: Shanghai sweep report
authenticatedReport: Authenticated shanghai sweep report

Using isValidShanghaiReport function

await sdk.withdrawal.isValidShanghaiReport(shanghaiReport, authenticatedReport);

Return Parameter

Transaction hash if the transaction is successful.

previewTotalMintableDETH function

Preview the amount of dETH that will be minted after reporting the shanghai sweeps.

Input Parameters

shanghaiReport: Shanghai sweep reports to calculate mintable dETH for

Using previewTotalMintableDETH function

await sdk.withdrawal.previewTotalMintableDETH(shanghaiReport);

Return Parameter

Amount of mintable dETH in Big Numbers

getSumOfUnreportedSweeps function

Calculate sum of all the unreported sweep reports.

Input Parameters

sweeps: Unreported shanghai sweep reports

Using getSumOfUnreportedSweeps function

await sdk.withdrawal.getSumOfUnreportedSweeps(sweeps);

Return Parameter

Sum of the reports in Big Numbers

totalReportedUnknownTopUpsForBlsPublicKey function

Get the sum of all the top-ups made to the BLS public key.

Input Parameters

blsPublicKey: BLS public key to get unknown top-ups for

Using totalReportedUnknownTopUpsForBlsPublicKey function

await sdk.withdrawal.totalReportedUnknownTopUpsForBlsPublicKey(blsPublicKey);

Return Parameter

Total top-ups in Big Numbers

reportFinalSweepAndWithdraw function

After exiting the consensus layer and performing rage quit on the Stakehouse or LSD protocol, report the final sweep report and withdraw all the ETH for the BLS public key along with the accrued ETH rewards from reporting the sweeps. The final sweep differs from all the other sweep reports. It usually amounts to 32ETH that is sent from the consensus layer to the Stakehouse account manager, but can be less if the validator was leaking or slashed.

Input Parameters

totalETHSentToBLSPublicKey: amount of ETH sent to the BLS public key in string format
unreportedSweeps: list of unreported sweeps associated with the BLS public key
finalReport: The final sweep report associated with the BLS public key

Using reportFinalSweepAndWithdraw function

await sdk.withdrawal.reportFinalSweepAndWithdraw(totalETHSentToBLSPublicKey, unreportedSweeps, finalReport);

Return Parameter

Transaction hash

isValidFinalSweep function

Check if the final sweep is valid, before reporting it to the contracts.

Input Parameters

totalETHSentToBLSPublicKey: total amount of ETH sent to the BLS public key in the string format
unreportedSweeps: list of unreported sweeps
finalSweep: final sweep report
authenticatedReport: authenticated final sweep report

Using isValidFinalSweep function

await sdk.withdrawal.isValidFinalSweep(totalETHSentToBLSPublicKey, unreportedSweeps, finalSweep, authenticatedReport);

Return Parameter

Transaction hash

broadcastVoluntaryWithdrawal function

In case the node operator decides to no longer continue running the validator, this function can be used to broadcast an exit message on the consensus layer.

Input Parameters

beaconNodeURL: consensus layer node URL in string format
keystore: BLS keystore of the respective BLS public key
keystorePassword: password of the respective BLS keystore

Using broadcastVoluntaryWithdrawal function

await sdk.withdrawal.broadcastVoluntaryWithdrawal(beaconNodeURL, keystore, keystorePassword);

reportVoluntaryWithdrawal function

After the voluntary withdrawal has been reported, the contracts need to know about the BLS public key's exit. This step is necessary only for all the validators staked directly via the Stakehouse protocol.

Input Parameters

stakehouseAddress: Stakehouse address of the BLS public key to which it belongs
authenticatedReport: authenticated finalised epoch report of the BLS public key

Using reportVoluntaryWithdrawal function

await sdk.withdrawal.reportVoluntaryWithdrawal(stakehouseAddress, authenticatedReport);

Return Parameter

Transaction hash

getValidatorsEligibleForPartialWithdrawal function

Get a list of BLS public keys eligible for partial withdrawal of dETH.

Input Parameters

beaconNodeURL: consensus node url in string format
batchReportLimit: batch size for the number of BLS public keys to fetch finalised epoch report for. By default, set to 5.

Using getValidatorsEligibleForPartialWithdrawal function

await sdk.withdrawal.getValidatorsEligibleForPartialWithdrawal(beaconNodeURL, batchReportLimit);

Return Parameter

Returns an object of the format:

{
eligibleValidatorsBeaconChainReports, // list of beacon chain reports for the eligible BLS public keys
validatorsForReporting // list of BLS public keys to be reported
}

getDAOValidatorsForReporting function

Get the list of all the validators (that can be reported) belonging to the Stakehouses owned by the user.

Input Parameters

beaconNodeURL: consensus node url in string format
userAddress: user's ETH address in string format
batchReportLimit: batch size for reporting the BLS public keys. By default, set to 5.

Using getDAOValidatorsForReporting function

await sdk.withdrawal.getDAOValidatorsForReporting(beaconNodeURL, userAddress, batchReportLimit);

Return Parameter

List of BLS public keys part of the user owned stakehouses that need to be reported.

getOpenIndexValidatorsForPartialWithdrawal function

Get a list of object for all the BLS public keys that are in open index and eligible for partial withdrawals.

Input Parameters

user: ETH address of the user that wants to burn dETH for ETH
unwrapAmount: amount of dETH that the user wants to partially withdraw in exchange of ETH
eligibleValidators: list of BLS public keys in the open index
maxNumberOfValidators: maximum number of BLS public keys

Using getOpenIndexValidatorsForPartialWithdrawal function

await sdk.withdrawal.getOpenIndexValidatorsForPartialWithdrawal(user, unwrapAmount, eligibleValidators, maxNumberOfValidators);

Return Parameter

Returns an object

{
validatorsInOpenIndex, // list of eligible BLS public keys
finalisedReportsForPartialWithdrawal, // finalised epoch report for each of the eligible BLS public keys
unwrapAmounts, // list of amount of ETH that can be partially withdrawn for each of the BLS public keys
totalAvailableETH // total amount of ETH that can be partially withdrawn
}

getGiantPoolValidatorsForPartialWithdrawal function

Fetch list of details related to the validators who are a part of the giant pool and eligible for partial withdrawal.

Input Parameters

userAddress: ETH address of the user trying to attempt partial withdrawal

Using getGiantPoolValidatorsForPartialWithdrawal function

await sdk.withdrawal.getGiantPoolValidatorsForPartialWithdrawal(userAddress);

Return Parameter

A list of object of the format:

{
withdrawable: {
"savETHPoolAddresses", // list of savETH pool addresses associated with the BLS public keys
"lpTokenAddresses", // LP tokens minted for each of the BLS public keys
"claimAmounts" // claimable ETH for each of the BLS public keys
},
claimable: {
"savETHPoolAddresses", // list of savETH pool addresses associated with the BLS public keys
"lpTokenAddresses" // LP tokens minted for each of the BLS public keys
}
}

unwrapDETH function

Contract function to partially withdraw dETH in exchange for ETH.

Input Parameters

blsPublicKey: BLS public key to partially withdraw from
unwrapAmount: Amount of dETH to be burned in exchange of ETH. uint256 value should be provided as a string

Using unwrapDETH function

await sdk.withdrawal.unwrapDETH(blsPublicKey, unwrapAmount);

Return Parameter

Transaction hash

batchUnwrapDETH function

Partially withdraw dETH for ETh from multiple BLS public keys in a single transaction.

Input Parameters

blsPublicKeys: List of BLS public keys to partially withdraw from
unwrapAmounts: List of amount of dETh to partially withdraw per BLS public key

Using batchUnwrapDETH function

await sdk.withdrawal.batchUnwrapDETH(blsPublicKeys, unwrapAmounts);

Return Parameter

Transaction hash

getListOfUnreportedWithdrawalIndexes function

Check the contract if the provided list of withdrawal indexes has been reported or not.

Input Parameters

withdrawalIndexes: List of withdrawal indexes.

Using getListOfUnreportedWithdrawalIndexes function

await sdk.withdrawal.getListOfUnreportedWithdrawalIndexes(withdrawalIndexes);

Return Parameter

List of unreported withdrawal indexes.

filterUnreportedSweepReports function

Filter out the unreported sweep reports from the given list of sweep reports.

Input Parameters

unformattedSweepReports: List of unformatted sweep reports

Using filterUnreportedSweepReports function

await sdk.withdrawal.filterUnreportedSweepReports(unformattedSweepReports);

Return Parameter

List of unreported and unformatted sweep reports.

reportSweepsPostRageQuit function

Report sweeps to the contract after the BLS public has rage quitted from the Stakehouse Protocol.

Input Parameters

formattedShanghaiSweepReport: Formatted unreported sweep reports
verifiedSweepReportSignature: Signature received from the deposit contract after verifying the sweep reports
finalisedBeaconChainReport: Finalised beacon chain report of the BLS public key

Using reportSweepsPostRageQuit function

await sdk.withdrawal.reportSweepsPostRageQuit(formattedShanghaiSweepReport, verifiedSweepReportSignature, finalisedBeaconChainReport);

Return Parameter

Transaction hash

batchReportSweepsPostRageQuit function

Report sweeps post rage quit for multiple BLS public keys at once.

Input Parameters

formattedShanghaiSweepReports: List of formatted sweep reports for all of the BLS public keys
verifiedSweepReportSignatures: List of signatures for all the sweep reports
finalisedBeaconChainReports: List of finalised beacon chain reports for all the BLS public keys

Using batchReportSweepsPostRageQuit function

await sdk.withdrawal.batchReportSweepsPostRageQuit(formattedShanghaiSweepReports, verifiedSweepReportSignatures, finalisedBeaconChainReports);

Return Parameter

Transaction hash

verifyAndReportAllSweepsAtOnce function

One stop function for filtering unreported sweep reports, formatting them, getting signatures for the reports, and reporting to the contract. Once done, the BLS public key is ready to withdraw ETH from the account manager.

Input Parameters

stakehouseAddress: Stakehouse address of the associated BLS public key,
totalETHSentToBLSPublicKey: Total amount of ETH sent to the consensus layer for this BLS public key,
unformattedSweepReports: List of unformatted sweep reports for the BLS public key,
finalisedBeaconChainReport: Finalised beacon chain report,
postRageQuit: Boolean. true if the sweep reports are being reported after a rage quit. false otherwise

Using verifyAndReportAllSweepsAtOnce function

await sdk.withdrawal.verifyAndReportAllSweepsAtOnce(stakehouseAddress, totalETHSentToBLSPublicKey, unformattedSweepReports, finalisedBeaconChainReport, postRageQuit);

Return Parameter

An object of the format:

{ 
tx, // transaction hash of the reported sweeps
listOfUnverifiedReports // list of reports that couldn't be verified and reported to the contracts
}

verifyAndReportSweepsForMultipleBLSKeys function

Verify and report sweeps for multiple BLS public keys at once.

Input Parameters

stakehouseAddresses: A list of stakehouse addresses associated with each of the BLS public keys,
totalETHSentToEachBLSKey: Total amount of ETH sent to the consensus layer for each of the BLS public key,
unformattedSweepReports: List of unformatted sweep reports for each of the BLS public key,
finalisedBeaconChainReports: Finalised beacon chain reports of the respective BLS public keys,
maxNumberOfBLSKeys: Number of BLS public keys being reported. Defaults to 20.

Using verifyAndReportSweepsForMultipleBLSKeys function

await sdk.withdrawal.verifyAndReportSweepsForMultipleBLSKeys(stakehouseAddresses, totalETHSentToEachBLSKey, unformattedSweepReports, finalisedBeaconChainReports, maxNumberOfBLSKeys = 20);

Return Parameter

An object of the format:

{
tx, // Transaction hash of the sweep report
listOfUnverifiedReports: [{
validatorIndex, // validator index for the BLS public key which couldn't report all the sweeps
sweep // list of sweeps which couldn't be reported for this validator index
}]
}

getListOfBlsKeysForRageQuitDETH function

Fetch list of BLS public keys which need dETH to rage quit.

Input Parameters

beaconNodeURL: Beacon node URL

Using getListOfBlsKeysForRageQuitDETH function

await sdk.withdrawal.getListOfBlsKeysForRageQuitDETH(beaconNodeURL);

Return Parameter

List of objects of the format:

{
"blsPublicKey", // BLS public key of the validator
"exitEpoch", // exit epoch of the BLS public key
"rageQuitAssistantAddress", // associated rage quit assistant of the BLS public key
"dETHRequired", // dET required to rage quit
"stakehouseAddress", // stakehouse address associated with the BLS public key
"pushToOpenIndex", // set to 'false' if BLS public key is not part of open index, 'true' otherwise
"status", // set to 'facilitated' if dETH has been deposited and set to 'deploy' if not
"borrowFundsAvailable" // set to true if no rage quit assistant deployed and the key is not in open index
}