# GoDex Referral Codes

### &#x20;<a href="#overview" id="overview"></a>

### Overview <a href="#overview" id="overview"></a>

Referral codes will also allow for platforms such as wallets or exchanges to monetize the swap volume from their user base by registering a partner fee connected to their referral code. The fee will then be charged by the GoDex router and deposited into the specified beneficiary address, allowing for a simple and easy monetization process.

## Register A Code <a href="#register-a-code" id="register-a-code"></a>

#### [ Register](https://godex.ai/godex-affiliate/)

Codes are registered on the router via the `registerReferralCode` function. You will need to register your code on **each chain** that you wish to use it on. We have created a frontend for transacting with this function and registering codes. Anyone integrating or using the GoDex API can use this frontend to register a referral code for inclusion in all API quote requests they make.

#### &#x20;Info

Referral codes can only be registered once. If you need to change something, you will need to register a new code.

### Setting Fees <a href="#setting-fees" id="setting-fees"></a>

When registering a referral code, there is an option to add an additional fee. This additional fee will be removed from the output amount of the swap by the router when the registered referral code is used. Of the removed fee, 20% will be retained by the router as protocol revenue while the other 80% will be sent to the specified beneficiary address at the time of the transaction. This mechanism provides an easy way for partners to monetize their swap volume without making, auditing, or, maintaining any of their own smart contracts.

<table><thead><tr><th width="171">Function</th><th>Owner Take</th><th>Referrer Take</th></tr></thead><tbody><tr><td>Swap</td><td>Positive Slippage + 20% of fee</td><td>20% of fee</td></tr><tr><td>SwapMulti</td><td>0.01% + 20% of fee</td><td>20% of fee</td></tr><tr><td>CopyWhale</td><td>6% Profit + 20% of fee</td><td></td></tr></tbody></table>

### Code Types <a href="#code-types" id="code-types"></a>

For the purposes of smart contract optimization, referral codes are split into two ranges/types. Codes with no additional fees (tracking/attribution only) are restricted to the range from 0 to 2147483648 (highest bit of uint32 is 0), while codes with an additional fee are restricted to the range from 2147483648 to 4294967296 (highest bit of uint32 is 1). This allows for the router contract to only make an additional storage read when the code used charges an additional fee.

| Codes                          | Use                      |
| ------------------------------ | ------------------------ |
| 0 - AGD\_18920f8               | Tracking and Attribution |
| AGD\_18920f9 - AGD\_4294967296 | Additional Fee           |


---

# 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.godex.ai/godex-trading-engine/godex-referral-codes.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.
