# Slashing Setup

This guide walks you through the process of **enabling and configuring slashing** for your network using the Othentic Stack.

Slashing in the Othentic Stack can be enforced via **Slashing Modules, Custom Slashing, or both.**

#### Read More

* [Slashing and operator Ejection](https://docs.othentic.xyz/main/learn/core-concepts/slashing-and-ejection)
* [Slashing Modules](https://docs.othentic.xyz/main/learn/core-concepts/slashing-and-ejection/modules)
* [Custom Slashing](https://docs.othentic.xyz/main/learn/core-concepts/slashing-and-ejection/custom-logic)

## Prerequisites

* AVS Contract addresses
* Access to AVS governance multisig account

## Enable Slashing Modules

{% stepper %}
{% step %}

#### Unpause Slashing flow

Unpause the Slashing flow to activate the slashing mechanism:

```bash
otcli network unpause-flow
```

Select Slashing flow.
{% endstep %}

{% step %}

#### Update Slashing Modules Configuration

Decide on which [Slashing Modules](https://docs.othentic.xyz/main/learn/core-concepts/slashing-and-ejection/modules) you wish to enable and execute the following command:

```
otcli network set-slashing-config
```

* Select the [Slashing Module](https://docs.othentic.xyz/main/learn/core-concepts/slashing-and-ejection/modules) to activate
  1. [Double Attestation](https://docs.othentic.xyz/main/learn/core-concepts/slashing-and-ejection/modules#id-1.-double-attestations)
  2. [Rejected Task](https://docs.othentic.xyz/main/learn/core-concepts/slashing-and-ejection/modules#id-2.-rejected-task)
  3. [Incorrect Attestation](https://docs.othentic.xyz/main/learn/core-concepts/slashing-and-ejection/modules#id-3.-incorrect-attestations)
* Set whether to eject operators on violation
* Set unique Stake **percentage** to slash for violation
  {% endstep %}

{% step %}

#### Enable Slashing conditions per task definition

For [Rejected Tasks](https://docs.othentic.xyz/main/learn/core-concepts/slashing-and-ejection/modules#id-2.-rejected-task) or  [Incorrect Attestations](https://docs.othentic.xyz/main/learn/core-concepts/slashing-and-ejection/modules#id-3.-incorrect-attestations) conditions, after configuring the module in AVSGovernance, you must enable slashing per Task Definition in AttestationCenter contract.

* **Rejected Task Slashing**\
  Enable using [setIsRejectedTaskSlashingEnabled](https://docs.othentic.xyz/main/reference/contracts/attestation-center#setisrejectedtaskslashingenabled) function in the AttestationCenter contract
* **Incorrect Attestation Slashing**\
  Enable using [setIsIncorrectAttestationSlashingEnabled](https://docs.othentic.xyz/main/reference/contracts/attestation-center#setisincorrectattestationslashingenabled) function in the AttestationCenter contract

{% hint style="warning" %}
Only enable these conditions after ensuring the task execution and validation logic are stable and deterministic.
{% endhint %}
{% endstep %}

{% step %}

#### Set Challenger Rewards

For [Rejected Tasks](https://docs.othentic.xyz/main/learn/core-concepts/slashing-and-ejection/modules#id-2.-rejected-task) or [Incorrect Attestations](https://docs.othentic.xyz/main/learn/core-concepts/slashing-and-ejection/modules#id-3.-incorrect-attestations) conditions, define the reward given to [challengers](https://docs.othentic.xyz/main/learn/core-concepts/slashing-and-ejection/modules#challenger-system) who submit valid proofs of misbehavior.

Use the [setChallengerRewardFee](https://docs.othentic.xyz/main/reference/contracts/attestation-center#setchallengerrewardfee) function in the AttestationCenter contract to set the reward amount for a valid challenge submitted by an operator.

Learn more about the [Challenger System here](https://docs.othentic.xyz/main/learn/core-concepts/slashing-and-ejection/modules#challenger-system).
{% endstep %}

{% step %}

#### \[Optional] Set minimum Slashable Stake &#x20;

Define the [minimum slashable stake](https://docs.othentic.xyz/main/learn/core-concepts/slashing-and-ejection#minimum-slashable-stake) an Operator must maintain to be eligible for slashing:

```
otcli network set-min-slashable-stake
```

{% endstep %}
{% endstepper %}

***

## Enable Custom Slashing

{% stepper %}
{% step %}

#### Unpause Slashing flow

Unpause the Slashing flow to activate the slashing mechanism:

```bash
otcli network unpause-flow
```

Select the **Slashing** flow when prompted.
{% endstep %}

{% step %}

#### Assign Slashing Roles

Assign the required roles using [Slashing Roles Configuration functions](https://docs.othentic.xyz/main/reference/contracts/attestation-center#roles-configuration) in the **AttestationCenter** contract.

* **Set or revoke `SLASHER` :** Use `setSlasher` or `revokeSlasher` functions
* **Set or revoke `Ejector` :** Use `setEjector` or `revokeEjector` functions
  {% endstep %}

{% step %}

#### Use Custom Slashing methods

Customize the logic to trigger the [custom slashing](https://docs.othentic.xyz/main/learn/core-concepts/slashing-and-ejection/custom-logic#functions) functions like [ejectOperatorFromNetwork](https://docs.othentic.xyz/main/reference/contracts/attestation-center#ejectoperatorfromnetwork) and [applyCustomSlashing](https://docs.othentic.xyz/main/reference/contracts/attestation-center#applycustomslashing).
{% endstep %}
{% endstepper %}

***

## Enable Redistribution

To enable Redistribution in an AVS, follow these steps:

{% stepper %}
{% step %}

#### Deploy Redistribution Logic Contract

Create a smart contract that implements the `IRedistribution` interface. This contract defines the logic for how slashed funds will be redistributed.

<details>

<summary>IRedistributionLogic</summary>

```
// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.8.25;

/*______     __      __                              __      __ 
 /      \   /  |    /  |                            /  |    /  |
/$$$$$$  | _$$ |_   $$ |____    ______   _______   _$$ |_   $$/   _______ 
$$ |  $$ |/ $$   |  $$      \  /      \ /       \ / $$   |  /  | /       |
$$ |  $$ |$$$$$$/   $$$$$$$  |/$$$$$$  |$$$$$$$  |$$$$$$/   $$ |/$$$$$$$/ 
$$ |  $$ |  $$ | __ $$ |  $$ |$$    $$ |$$ |  $$ |  $$ | __ $$ |$$ |
$$ \__$$ |  $$ |/  |$$ |  $$ |$$$$$$$$/ $$ |  $$ |  $$ |/  |$$ |$$ \_____ 
$$    $$/   $$  $$/ $$ |  $$ |$$       |$$ |  $$ |  $$  $$/ $$ |$$       |
 $$$$$$/     $$$$/  $$/   $$/  $$$$$$$/ $$/   $$/    $$$$/  $$/  $$$$$$$/
*/

import {IRedistributionManager} from "./IRedistributionManager.sol";

/**
 * @author Othentic Labs LTD.
 * @notice Terms of Service: https://www.othentic.xyz/terms-of-service
 * @notice Depending on the application, it may be necessary to add reentrancy gaurds to hooks
 */

interface IRedistributionLogic {
    function redistribute(uint256 _slashId, IRedistributionManager.SlashDetails calldata _slashDetails) external;
}
```

</details>
{% endstep %}

{% step %}

#### Set Redistribution Logic contract

Once your logic contract is deployed, you must register it with the Redistribution Manager using a two-step governance flow:

* `queueRedistributionLogic`: proposes the new Redistribution Logic contract. This triggers the start of the delay period.
* `completeRedistributionLogic`: finalizes the change after the delay has passed.

{% hint style="warning" %}
On **mainnet**, there is a **7-day delay** between the two function calls
{% endhint %}

```
queueRedistributionLogic(address newLogic);
completeRedistributionLogic();
```

{% endstep %}

{% step %}

#### Verify Setup

To verify whether a Redistribution Logic contract has been set, use the `getRedistributionLogic` read method on the Redistribution Manager contract.
{% endstep %}
{% endstepper %}
