---
# System prepended metadata

title: dETH Isolation and savETH Isolation

---

**Workflow for Rage Quit**:
> Latest SDK version: 3.0.6
> Considering that the stakehouse-sdk (v3) has already been initialised in the following manner:
> ```
> const { StakehouseSDK } = require('@blockswaplab/stakehouse-sdk');
> const sdk = new StakehouseSDK(signer);
> ```
> Let's dive into the Ragequit feature.


![](https://i.imgur.com/Jrc7jVD.png)
The user will click on the "Details" button under the "Manage" section.

![](https://i.imgur.com/cfdWqgQ.png)
In order to Rage quit, the user clicks on the 3 dots inside the "Utilities" tab and then on the "Rage Quit" option.

![](https://i.imgur.com/H9OXxDV.png)

Then, the "Eligibility Status" pop-up appears. This is where the UI makes call to the `rageQuitChecks` in the utils class of the `@blockswaplab/stakehouse-sdk`.
The "Eligibility Status" checks for the following cases:
1) Do you have dETH - it must be isolated or in your wallet
2) Do you have free floating SLOT
3) Is your SLOT leaking - if yes no problem ignore the redemption rate. If not leaking, do redemption rate checks
```
sdk.utils.rageQuitChecks(stakehouseAddress, userAddress, authenticatedReport);
```
```
stakehouseAddress: Stakehouse Address that the KNOT is part of.
userAddress: Ethereum Address (Execution Layer) of the KNOT.
authenticatedReport: Authenticated Balance Report of the KNOT, obtained from the sdk.authenticateReport function of the SDK.
```

![](https://i.imgur.com/pGT9ahC.jpg)

Balance Reporting (or the Report Balance) is done in the following steps:
When the user clicks on "Submit" button then:
Firstly, the `getFinalisedEpochReport` function from the SDK is called.
```
sdk.getFinalisedEpochReport(beaconNodeURL, blsPublicKey);
```
```
beaconNodeURL: URL of the Beacon Node. Provided in the config.ts file of UI.
blsPublicKey: BLS Public Key of the KNOT.
```
This returns `finalisedBeaconChainReport` which is needed by our 2nd function i.e. `authenticateReport`.
```
sdk.authenticateReport(finalisedBeaconChainReport);
```
![](https://i.imgur.com/LkSBQ2K.jpg)
Then the `calculateExitFee` function from the utils class of the `@blockswaplab/stakehouse-sdk` is called.
```
sdk.utils.calculateExitFee(authenticatedReport);
```
```
authenticatedReport: Authenticated Balance Report of the KNOT, obtained from the sdk.authenticateReport function of the SDK.
```
The `calculateExitFee` returns `wei` units which needs to be paid by the KNOT before they can successully Rage Quit. This is shown in the "Supply" section that you can see towards the right of the "Burn" section.

Then the user clicks on "Confirm" button of "Remove Knot" section.

![](https://i.imgur.com/I2bqSj7.jpg)
During this pop-up, the `rageQuitKnot` function of the SDK (`@blockswaplab/stakehouse-sdk`) is called.
```
sdk.rageQuitKnot(stakehouseAddress, authenticatedReport, topUpAmountInWei);
```
```
stakehouseAddress: Stakehouse Address the KNOT is part of.
authenticatedReport: Authenticated Balance Report of the KNOT, obtained from the sdk.authenticateReport function of the SDK.
topUpAmountInWei: wei value returned by the calculateExitFee function.
```

## Withdraw all dETH
![](https://i.imgur.com/2LW0NMX.png)
When the user clicks on "Withdraw all dETH", the first check that should happen is `lifecyclestatus` check. 
The UI already does this here https://github.com/bsn-eng/Stakehouse_UI/blob/live/graphql/queries/validators.ts 
Ignore all the validators with `lifecyclestatus` NOT `3`.
Apart from the KNOTs with `lifecyclestatus` not equal to 3, the KNOTs who have `knotMetadata.savETHIndexId` equal to zero should also be excluded. `knotMetadata.savETHIndexId` is a field in response returned from the validators.ts query.

![](https://i.imgur.com/zrpMVkr.png)
Once you have the list of eligible validators, add all the dETH available to be withdrawn.
When the user clicks on "Confirm" button, the function to be called in the SDK is
`batchAddKnotToOpenIndexAndWithdraw` which you can call in the following manner
```
await sdk.batchAddKnotToOpenIndexAndWithdraw(stakehouses, memberIDs, recipient);

stakehouses: List of Stakehouse of the validators
memberIDs: List of BLS Public Keys of the validators
recipient: ECDSA address of the user
```

## Withdraw dETH
![](https://i.imgur.com/r6330t1.png)
Withdraw dETH option is available when the user clicks on the 3 dots after going on "Details" page of a valdiator.
Again, the `lifecyclestatus` should be `3` if not, the "Withdraw dETH" option should be disabled. Here again, the button should be disabled if the KNOT has `savETHIndexId` equal to zero.
If the user is eligible to withdraw from this validator, then call the `addKnotToOpenIndexAndWithdraw` function of the SDK in the following manner:
```
await sdk.addKnotToOpenIndexAndWithdraw(stakehouseAddress, memberID, recipientAddress);

stakehouseAddress: Stakehouse Address of the validator
memberID: BLS Public Key of the validator
recipientAddress: ECDSA address of the user
```

# dETH Isolation and savETH Isolation
Either dETH or savETH can be used to isolate a KNOT. If the KNOT doesn't have sufficient dETH, it's savETH can be used for the isolation.

## dETH Isolation
`depositAndIsolateKnotIntoIndex`: This function is used to isolate the dETH.
```
await sdk.depositAndIsolateKnotIntoIndex(stakehouseAddress, blsPublicKey, indexID);
```
### Input parameters:
```
stakehouseAddress: Stakehouse address of the KNOT
blsPublicKey: BLS Public Key of the KNOT
indexID: index ID to be isolated in
```
## Other related functions that might come handy
`dETHRequiredForIsolation`: This function is used to calculate the amount of dETH required for a KNOT's isolation.
The input parameter required is `blsPublicKey`.
```
await sdk.utils.dETHRequiredForIsolation(blsPublicKey);
```
It returns the dETH amount in BigNumbers.

## savETH Isolation
`savETHRequiredForIsolation`: this function is used to calculate the amount of savETH required for the KNOT's isolation.
The input parameter required is `blsPublicKey`.
```
await sdk.utils.savETHRequiredForIsolation(blsPublicKey);
```
It returns the savETH amount in BigNumbers.

### Converting dETH to savETH
This function helps to convert the dETH amount to equivalent savETH.
```
await sdk.utils.dETHToSavETH(amount);
```
Input parameter:
```
amount: The amount of dETH to be converted to savETH
```
Returns:
```
savETH amount in BigNumbers
```

### Converting savETH to dETH
This function helps to convert savETH amount to equivalent dETH.
```
await sdk.utils.savETHToDETH(amount);
```
Input parameter:
```
amount: The amount of savETH to be converted to dETH
```
Returns:
```
dETH amount in BigNumbers
```

# Report Balance
When the user clicks on "Report Balance", following pop-up should appear:
![](https://i.imgur.com/lmvx7W9.png)

When the user clicks on "Confirm" button, the `reportBalance` function is called as shown below:
```
await sdk.reportBalance(beaconNodeURL, blsPublicKey, stakehouseAddress);
```
![](https://i.imgur.com/GdSXerl.png)

In case, any error is thrown, following pop-up should be displayed. (You will receive figma with updated message in the pop-up description)
![](https://i.imgur.com/cPf2KAu.png)

Once the report balance is successful, a pop-up as appears as shown below:
![](https://i.imgur.com/jZchkay.png)
In the description "Your validator has 32.0000056 ETH", `32.0000056 ETH` is the KNOT's balance which you should shown in the message

## Input parameters:
```
beaconNodeURL: Beacon Node URL
blsPublicKey: BLS Public Key of the KNOT
stakehouseAddress: Stakehouse address of the KNOT
```
# Top Up

The "Top up" button should be enabled ONLY if the `SLOT` balance of the user is less than `4`.
To get this value, you will just have to add `totalCollateralizedSLOTInVaultFormatted` field in the `stakehouseAccounts` query (which you already have here https://github.com/bsn-eng/Stakehouse_UI/blob/live/graphql/queries/validators.ts) (If already added, then no worries). So, the logic looks like this:
```
// THIS IS A PSEUDO CODE
slotBalance = response.stakehouseAccounts.totalCollateralizedSLOTInVaultFormatted

if(slotBalance < 4) {
    Enable "Top up" button
}
else {
    Disable "Top up" button
}

```

When the user clicks on "Top up" button, a pop-up appears. In the pop-up, the user can input the amount of ETH to top-up.
![](https://i.imgur.com/m2xzAbA.png)

The "Confirm" button should be disabled if the input amount is `0` or if it's more than the slashedAmount.
To get slashedAmount, call the `currentSlashedAmountOfSLOTForKnot` function as shown below:
```
await sdk.utils.currentSlashedAmountOfSLOTForKnot(blsPublicKey);
```
So, to recap:
```
slashedAmount = await sdk.utils.currentSlashedAmountOfSLOTForKnot(blsPublicKey)

if(inputAmount == 0 || inputAmount > slashedAmount) {
    Disable "Confirm" button
}
```

Now, when the "Confirm" button is enabled.
The "Confirm" button when clicked should call the `topUpSlashedSlot` function of the `utils` sub-class of the `stakehouse-sdk`.
```
await sdk.utils.topUpSlashedSlot(stakehouseAddress, blsPublicKey, recipient, inputAmount, inputAmount);
```
> You have to provide `inputAmount` twice in the above function as the input parameter.

Input params:
```
stakehouseAddress: Stakehouse address of the KNOT
blsPublicKey: BLS Public Key of the KNOT
recipient: ECDSA wallet address of the user
inputAmount: ETH value to top-up (provided as user input)
```

Once the top-up is successful, following pop-up should be displayed
![](https://i.imgur.com/648RKx6.png)
Instead of the message "Your new validator's balance is now 32.0067 ETH", you should show "You have topped up your validator with 0.01 ETH". (Where, `0.01` is just the inputAmount of top-up.)
> You will most likely receive an updated figma which contains correct message to display.
