# Monetization

## How Rango affiliate system works?

{% content-ref url="../../technical/monetization" %}
[monetization](https://docs.rango.exchange/technical/monetization)
{% endcontent-ref %}

## How to set affiliate parameters?

In main api, it's enough to pass affiliate parameters only in routing methods e.g. in [getBestRoute](https://docs.rango.exchange/api-integration/main-api-multi-step/api-reference/get-best-route) or `getAllRoutes` methods.

In these methods, several fields could be used for participating in the affiliate program: `affiliateRef`, `affiliateWallets`, `affiliatePercent`. You could use combination of`affiliateRef` and `affiliatePercent`, or `affiliateWallets` and `affiliatePercent`:

* `affiliateRef`: The referral code you could generate on our Affiliate Program Page. If you use this, we will send the affiliate fees to the wallet that created this link.
* `affiliatePercent`: The fee percentage you want to charge the users (1.5 means 1.5 percent). The maximum fee you could charge users is 3 percent. The default value is 0.1 percent or 10 bps.
* `affiliateWallets`: A map of blockchains to wallet addresses, allowing you to specify which wallet you want to receive the fee.

Sample code for fetching the route preview:

{% tabs %}
{% tab title="Typescript" %}

<pre class="language-typescript"><code class="lang-typescript">const bestRoute = await rango.getBestRoute({
    from: {"blockchain": "BSC", "symbol": "BNB", "address": null},
    to: {"blockchain": "AVAX_CCHAIN", "symbol": "USDT.E", "address": "0xc7198437980c041c805a1edcba50c1ce5db95118"},    
    amount: "1",
    slippage: 1,
<strong>    checkPrerequisites: false,
</strong><strong>    affiliatePercent: 0.3,
</strong><strong>    affiliateWallets: {
</strong><strong>        "BSC": "0x6f33bb1763eebead07cf8815a62fcd7b30311fa3"
</strong><strong>    },
</strong>})
</code></pre>

{% endtab %}

{% tab title="cURL" %}

```bash
curl --request POST \
     --url 'https://api.rango.exchange/routing/best?apiKey=c6381a79-2817-4602-83bf-6a641a409e32' \
     --header 'content-type: application/json' \
     --data '
{
  "from": {
    "blockchain": "BSC",
    "symbol": "BNB"
  },
  "to": {
    "blockchain": "AVAX_CCHAIN",
    "symbol": "USDT.E",
    "address": "0xc7198437980c041c805a1edcba50c1ce5db95118"
  },
  "checkPrerequisites": false,
  "affiliateWallets": {
    "BSC": "0x6f33bb1763eebead07cf8815a62fcd7b30311fa3"
  },
  "amount": "1",
  "affiliatePercent": 0.3,
  "slippage": 1
}
'
```

{% endtab %}
{% endtabs %}

Example code for the moment the user confirms the route:

{% tabs %}
{% tab title="Typescript" %}

<pre class="language-typescript"><code class="lang-typescript">const bestRoute = await rango.getBestRoute({
    from: {"blockchain": "BSC", "symbol": "BNB", "address": null},
    to: {"blockchain": "AVAX_CCHAIN", "symbol": "USDT.E", "address": "0xc7198437980c041c805a1edcba50c1ce5db95118"},    
    amount: "1",
    slippage: 1,
<strong>    checkPrerequisites: true,
</strong><strong>    selectedWallets: {
</strong><strong>        "BSC": "0xeae6d42093eae057e770010ffd6f4445f7956613",
</strong><strong>        "AVAX_CCHAIN": "0xeae6d42093eae057e770010ffd6f4445f7956613",
</strong><strong>    },
</strong><strong>    affiliatePercent: 0.3,
</strong><strong>    affiliateWallets: {
</strong><strong>        "BSC": "0x6f33bb1763eebead07cf8815a62fcd7b30311fa3"
</strong><strong>    },
</strong>})
</code></pre>

{% endtab %}

{% tab title="cURL" %}

```bash
curl --request POST \
     --url 'https://api.rango.exchange/routing/best?apiKey=c6381a79-2817-4602-83bf-6a641a409e32' \
     --header 'content-type: application/json' \
     --data '
{
  "from": {
    "blockchain": "BSC",
    "symbol": "BNB"
  },
  "to": {
    "blockchain": "AVAX_CCHAIN",
    "symbol": "USDT.E",
    "address": "0xc7198437980c041c805a1edcba50c1ce5db95118"
  },
  "selectedWallets": {
    "BSC": "0xeae6d42093eae057e770010ffd6f4445f7956613",
    "AVAX_CCHAIN": "0xeae6d42093eae057e770010ffd6f4445f7956613"
  },
  "checkPrerequisites": true,
  "affiliateWallets": {
    "BSC": "0x6f33bb1763eebead07cf8815a62fcd7b30311fa3"
  },
  "amount": "1",
  "affiliatePercent": 0.3,
  "slippage": 1
}
'
```

{% endtab %}
{% endtabs %}
