> 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/api-reference.md).

# Contract Reference

Solidity interfaces for the LiquidCore Router and pool contracts.

Use the **Router** for execution. Direct pool calls are optional when you already know the pool address.

## Router

| Chain           | `chainId` | Router                                       |
| --------------- | --------- | -------------------------------------------- |
| HyperEVM        | `999`     | `0x625aC1D165c776121A52ff158e76e3544B4a0b8B` |
| Robinhood Chain | `4663`    | `0x322F277BfB7Ba9c196194ad18011377A0fF55Fb3` |

Prefer the `routerAddress` returned by the [quote API](/liquidcore-integration/api-endpoints.md#get-quote).

### Discovery functions

```solidity
function getPools() external pure returns (address[] memory pools)
function getPoolForPair(address tokenA, address tokenB) public view returns (address)
```

Off-chain, list pools with [`GET /liquidcore/pools?chainId=...`](/liquidcore-integration/api-endpoints.md#list-pools).

### Execution functions

```solidity
function swap(
    address tokenIn,
    address tokenOut,
    uint256 amountIn,
    uint256 minAmountOut
) external returns (uint256 amountOut)
```

```solidity
function swap(
    address tokenIn,
    address tokenOut,
    uint256 amountIn,
    uint256 minAmountOut,
    bytes32 refCode
) external returns (uint256 amountOut)
```

`refCode` is checked against an on-chain allowlist (`RefCodeRegistry`). Invalid codes do not accrue referral allocation and do not block the swap.

### Quote functions

```solidity
function estimateSwap(
    address tokenIn,
    address tokenOut,
    uint256 amountIn
) external view returns (uint256 amountOut)

function estimateSwapBatch(
    address tokenIn,
    address tokenOut,
    uint256[] calldata amountsIn
) external view returns (uint256[] memory amountsOut)

function getReserves(address tokenA, address tokenB)
    external view returns (uint256 reserve0, uint256 reserve1)
```

`estimateSwapBatch` is used by the [REST API quote endpoint](/liquidcore-integration/api-endpoints.md#get-quote) for CSV `amountIn` inputs. `getReserves` reverts with `NoPoolForPair` if no pool exists.

### Referral functions

```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
```

See [Referrals](/liquidcore-integration/referrals.md) for usage details.

### Router errors

```solidity
error NoPoolForPair();
error TransferFailed();
```

***

## Direct pool interface

Discover pool addresses via [`GET /liquidcore/pools?chainId=...`](/liquidcore-integration/api-endpoints.md#list-pools). Do not hardcode them — they differ by chain and change over time.

```solidity
function getTokens() external view returns (address token0, address token1)
function getReserves() external view returns (uint256 reserve0, uint256 reserve1)
function swap(address tokenIn, address tokenOut, uint256 amountIn, uint256 minAmountOut) external returns (uint256 amountOut)
function swap(address tokenIn, address tokenOut, uint256 amountIn, uint256 minAmountOut, bytes32 refCode) external returns (uint256 amountOut)
function estimateSwap(address tokenIn, address tokenOut, uint256 amountIn) external view returns (uint256 amountOut)
function estimateSwapBatch(address tokenIn, address tokenOut, uint256[] calldata amountsIn) external view returns (uint256[] memory amountsOut)
function getRefClaimable(bytes32 refCode) external view returns (uint256 amount0, uint256 amount1)
function claimRefFees(bytes32 refCode) external returns (uint256 amount0, uint256 amount1)
```

### Common direct-pool errors

```solidity
error InvalidToken();
error ZeroAmount();
error SlippageExceeded();
error InsufficientReserve();
error TransferFailed();
error InvalidRefCode();
error UnauthorizedRefCodeClaim();
error RefCodeClaimLocked();
```

Referral usage details are documented in [Referrals](/liquidcore-integration/referrals.md).


---

# 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/api-reference.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.
