# Swap Partner

The Swap Partner system allows integrators to earn referral fees from swaps executed through their platforms. When users swap through a registered partner, a portion of the protocol fees is allocated to that partner.

## 1. How Partner Fee Collection Works <a href="#how-partner-fee-collection-works" id="how-partner-fee-collection-works"></a>

#### Fee Accumulation Mechanism <a href="#fee-accumulation-mechanism" id="fee-accumulation-mechanism"></a>

```
User Swap with Partner
        ↓
Protocol calculates referral_fee = protocol_fee × ref_fee_rate / 10^9
        ↓
Referral fee is stored in Partner.balances (on-chain Bag)
        ↓
Fees accumulate across multiple swaps
        ↓
Partner must manually claim fees using PartnerCap
```

**Important:** Manual Claim Required, referral fees are NOT automatically transferred to the partner's wallet.

* Fees accumulate in the `Partner` object's `balances` field (a `Bag` storing multiple coin types)
* Partners must explicitly call `claim_ref_fee` to withdraw accumulated fees
* Each coin type must be claimed separately
* Only the holder of `PartnerCap` can claim the fees

## 2. Swap with Partner (Earn Referral Fees) <a href="#id-1-swap-with-partner-earn-referral-fees" id="id-1-swap-with-partner-earn-referral-fees"></a>

Integrators earn referral fees by passing `partner_id` when executing swaps.

> For complete swap documentation including Move contract code, see [Swap Guide](https://vscode-remote+ssh-002dremote-002bwork.vscode-resource.vscode-cdn.net/home/bond/github/cetus/cetus-dlmm/docs/swap-guide.md#2-partner-swap-with-referral-fee).

## 3. Claim Referral Fees (For Partners) <a href="#id-2-claim-referral-fees-for-partners" id="id-2-claim-referral-fees-for-partners"></a>

Partners can claim accumulated fees using their `PartnerCap`.

#### Move Contract <a href="#move-contract" id="move-contract"></a>

**Location**: `cetus_dlmm::partner` module

```move
public fun claim_ref_fee<T>(
    partner: &mut Partner,
    partner_cap: &PartnerCap,
    versioned: &Versioned,
    ctx: &mut TxContext,
): Coin<T>
```

<table><thead><tr><th width="121.47265625">Parameter</th><th width="179.953125">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>partner</code></td><td><code>&#x26;mut Partner</code></td><td>Partner object (shared, mutable)</td></tr><tr><td><code>partner_cap</code></td><td><code>&#x26;PartnerCap</code></td><td>PartnerCap object (proves ownership)</td></tr><tr><td><code>versioned</code></td><td><code>&#x26;Versioned</code></td><td>Versioned object for version checking</td></tr><tr><td><code>T</code></td><td>Type Parameter</td><td>The coin type to claim</td></tr></tbody></table>

**Returns**: `Coin<T>` - The claimed fee coins

**Note**: The [SDK ](https://cetus-1.gitbook.io/cetus-developer-docs/via-sdk-v2/sdk-modules/cetusprotocol-dlmm-sdk/partner#id-2-claim-referral-fees-for-partners)automatically handles multiple coin types in a single transaction and can auto-fetch `partner_cap_id` if not provided. &#x20;

## Apply for Partner Swap

Interested in Partner Swap? Submit a request from here:<https://4bx69zjogri.typeform.com/to/UUETIX2f>
