# Protocol Rewards

SatLayer is a coordination layer which enables individuals to restake their Bitcoin and secure a set of **Bitcoin Validated Services (BVSs)**. The functions required to secure the BVSs are carried out by operators, who receive staked Bitcoin assets and use that capital to validate BVSs on behalf of restakers.

To ensure a robust amount of Bitcoin assets for security and proper operator functioning, BVSs must reward good behavior in the form of payments made to restakers and operators. This page describes how these payments function.

## BVS Payments Workflow

{% stepper %}
{% step %}

#### **Calculate rewards to restakers/operators off-chain**

BVSs calculate and disperse rewards to restakers and operators at their discretion. These rewards must be formatted as a `distribution.json` file, adhering to the following [**schema**](https://github.com/satlayer/satlayer-rewards/blob/main/schema/distribution.schema.json). An example JSON file is shown below:

```json
{
    "token": "[REWARD TOKEN ADDRESS]",
    "earners": [
        {
            "earner": "[EARNER ADDRESS]",
            "reward": "[REWARD AMOUNT]"
        },
        ...
    ],
}
```

{% endstep %}

{% step %}

#### **Submit distribution via GitHub**

Once the rewards are computed, the service submits the `distribution.json` file as a Pull Request (PR) to a public GitHub repository managed by SatLayer (TBD).
{% endstep %}

{% step %}

#### **Generate Merkle tree over the rewards**

The BVS then computes a Merkle tree of the rewards owed using the data from the `distribution.json` file they originally generated (details of the Merkle tree format and a generation script will be released in Phase II).\
\
If the BVS submits the rewards distribution file to GitHub in step 2, the merkle tree will be computed automatically via GitHub actions on behalf of the BVS.
{% endstep %}

{% step %}

#### Distributing rewards

The service then calls the `distributeRewards` function in the `bvs-rewards` contract with the `merkleRoot` and the `totalAmount` to distribute.

The service must ensure it holds a sufficient balance of tokens to complete the transfer from the its account to the `bvs-rewards` contract.
{% endstep %}
{% endstepper %}

## Restaker and Operator Rewards Claiming

Operators can receive their rewards from services rendered from the `bvs-rewards` contract. They can do so by calling the `claimRewards` function on the `bvs-rewards` contract. When calling this function, they must provide the following information:

* Merkle root
* Merkle proof
* Claimant address
* Total amount of rewards
* Merkle index

This information can be computed by calling the SatLayer CLI (**not yet released**) using the Merkle tree and claimant address of the restaker/operator.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.satlayer.xyz/protocol-rewards.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
