> For the complete documentation index, see [llms.txt](https://docs.liqd.ag/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.liqd.ag/liquidcore-integration/referrals.md).

# Referrals

Integrator guide for using a referral code and checking/claiming referral fees.

LiquidCore is live on HyperEVM (`999`) and Robinhood Chain (`4663`). Use the router for the chain you are trading on — see the [router table](https://docs.liqd.ag/liquidcore-integration/overview.md#supported-chains), or the `routerAddress` from the [quote API](https://docs.liqd.ag/liquidcore-integration/api-endpoints.md#get-quote). Claims must be made on the same chain where the fees accrued.

## Get a code

Referral codes are issued by Liquid Labs. Request your code from the team on Discord.

## Ref code format

`refCode` is a `bytes32` hash, not a plain text string.

It should be the keccak256 hash of your issued code text (for example, hash `"mycode"` and pass that `bytes32` value on-chain).

Example in ethers:

```typescript
import { keccak256, toUtf8Bytes } from "ethers";

const refCode = keccak256(toUtf8Bytes("your-issued-code"));
```

## Use your code in swaps

Router and pool both support the referral swap overload:

```solidity
swap(tokenIn, tokenOut, amountIn, minAmountOut, refCode)
```

* Keep your normal execution flow the same (`minAmountOut`, approvals, quote/estimate checks).
* Use your issued `refCode` as the 5th parameter.

## Check and claim referral fees

The core referral functions are available on the **router** — pass the token pair and the router resolves the pool automatically.

### Via the router (recommended)

```solidity
function getRefClaimable(address tokenA, address tokenB, bytes32 refCode)
    external view returns (uint256 amount0, uint256 amount1)

function claimRefFees(address tokenA, address tokenB, bytes32 refCode)
    external returns (uint256 amount0, uint256 amount1)

function distributeRefFees() external
```

* `getRefClaimable` — check currently claimable amounts per pool token.
* `claimRefFees` — claim accrued fees for a specific ref code. Must be called by the configured claim wallet for that code.
* `distributeRefFees` — batch-distributes all pending referral fees across all pools. Iterates over every registered ref code and pays out accrued fees to each code's configured claim wallet. Anyone can call this.

### Via pool contracts (alternative)

`getRefClaimable` and `claimRefFees` are also available directly on pool contracts (without the `tokenA`/`tokenB` pair parameters). See the [Contract Reference](https://docs.liqd.ag/liquidcore-integration/api-reference.md#direct-pool-interface) for pool-level signatures.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.liqd.ag/liquidcore-integration/referrals.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
