> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bitrune.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Referral & Rebate

> Earn BITRUNE rewards by referring friends to trade on Bitrune.

Bitrune's referral program rewards users who bring new traders to the platform. Referrers earn **BITRUNE** tokens proportional to their referees' swap volume.

## How It Works

```
Referrer shares invite code → Referee registers & trades → Referrer earns BITRUNE
```

1. Every user receives a unique **6-character invite code** at registration (e.g. `A3K9F2`).
2. Share your invite code or link (`https://bitrune.org?ref=A3K9F2`) with friends.
3. When your referee executes swaps, you earn BITRUNE proportional to their trade volume.
4. Claim accumulated BITRUNE rewards via MuSig2 cooperative signing.

## Invite Code

Each user is assigned a unique invite code at registration. The code uses uppercase alphanumeric characters (`A-Z`, `2-9`), excluding easily confused characters (`I`, `O`, `0`, `1`).

Your invite code and referral link are displayed on the Portfolio page.

## Binding a Referrer

There are two ways to bind a referrer:

<CardGroup cols={2}>
  <Card title="Via invite link" icon="link">
    Visit Bitrune with a `?ref=CODE` parameter in the URL. The code is captured automatically and applied when the user registers.
  </Card>

  <Card title="Manual entry" icon="keyboard">
    Already registered without a referrer? Enter an invite code manually on the Portfolio page. Binding is **one-time and immutable** — once set, it cannot be changed.
  </Card>
</CardGroup>

<Warning>
  You cannot refer yourself. Attempting to enter your own invite code will be rejected.
</Warning>

## Earning Rewards

When a referred user executes a swap, a **trade rebate** is calculated:

```
rebate_amount = btc_volume × rebate_rate
```

* **btc\_volume**: The BTC value of the swap (in satoshis).
* **rebate\_rate**: BITRUNE per BTC, configured by the protocol (e.g. `rebate_bitrune_per_btc`).
* The rebate is credited to the **referrer**, not the trader.
* If the trader has no referrer, the BITRUNE remains in the protocol's rebate reserve.

## Claiming BITRUNE

Accumulated BITRUNE rewards can be claimed at any time via the Portfolio page.

<Steps>
  <Step title="Prepare the claim">
    The platform calculates your pending rebate balance and constructs an on-chain BITRUNE transfer. MuSig2 sighashes are returned for signing.
  </Step>

  <Step title="Sign and finalize">
    Sign with your passkey and submit. The platform aggregates and broadcasts the claim transaction.
  </Step>

  <Step title="Receive BITRUNE">
    BITRUNE tokens arrive at your deposit address. Your pending balance is reset and total claimed is updated.
  </Step>
</Steps>

## Rebate Balance

Your rebate balance is tracked with three fields:

| Field             | Description                                       |
| ----------------- | ------------------------------------------------- |
| **Pending**       | Unclaimed BITRUNE earned from referees' trades    |
| **Total Earned**  | Lifetime BITRUNE earned from all referees         |
| **Total Claimed** | BITRUNE already withdrawn to your deposit address |
