> For the complete documentation index, see [llms.txt](https://docs.enoxswap.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.enoxswap.com/developers/enoxswap-reference.md). Agents can also search and read this documentation through its [MCP server](https://docs.enoxswap.com/~gitbook/mcp).

# EnoxSwap contract reference

`EnoxSwap` inherits `Ownable` and `ReentrancyGuard` and is built on Uniswap V2 style routers.

## Constants

| Name                    | Value                               | Meaning                                                           |
| ----------------------- | ----------------------------------- | ----------------------------------------------------------------- |
| `BPS`                   | 10 000                              | Basis-point denominator.                                          |
| `MAX_FEE_BPS`           | 100                                 | Swap fee can never exceed 1%.                                     |
| `MAX_REFERRAL_BPS`      | 5 000                               | Referral share can never exceed 50% of the fee.                   |
| `MAX_ROUTERS`           | 10                                  | Maximum number of routers.                                        |
| `MAX_ADD_LIQUIDITY_FEE` | 1 ether                             | Cap for the flat add-liquidity fee.                               |
| `routerDelay`           | 24 hours (set at deploy, immutable) | Timelock before a queued router can be activated. Maximum 7 days. |

## Swapping

```solidity
function swapTokens(
    address _tokenA,          // input token, address(0) = native coin
    address _tokenB,          // output token, address(0) = native coin
    uint256 _amountIn,
    uint256 _amountOutMin,    // slippage protection
    uint256 _deadline,
    bool    _feeOnTransfer,   // use the *SupportingFeeOnTransferTokens router calls
    uint256 _preferredRouter, // router index, or type(uint256).max for best price
    address _referrer         // optional referral address
) external payable;
```

Behaviour:

* For native input, `msg.value` must equal `_amountIn`. For token input, `msg.value` must be 0.
* The fee is taken from the amount actually received (correct for taxed tokens).
* Output is measured from balances and must be at least `_amountOutMin`.
* Emits `Swapped(user, tokenIn, tokenOut, amountIn, amountOut, routerIndex)`.

## Quoting

```solidity
function getBestPrice(uint256 _amountIn, address[] calldata _path)
    external view returns (PriceResult[] memory results, bool found, uint256 bestIndex, uint256 bestAmount);
```

`_path` must be exactly `[tokenIn, tokenOut]`. Use `address(0)` for the native coin. Routers that revert on the pair are skipped.

## Liquidity

* `addLiquidity(AddLiquidityParams calldata p)` - token/token.
* `addLiquidityETH(routerIndex, token, amountTokenDesired, amountTokenMin, amountETHMin, deadline)` - token/native.

## Router management (owner)

| Function                                               | Notes                                      |
| ------------------------------------------------------ | ------------------------------------------ |
| `queueRouter(router, name)`                            | Starts the timelock. Emits `RouterQueued`. |
| `executeQueuedRouter(id)`                              | Only after `eta`. Adds the router.         |
| `cancelQueuedRouter(id)`                               | Cancels a queued router.                   |
| `setRouterActive(index, active)`                       | Disabling is instant.                      |
| `getRoutersCount()`, `getRouter(i)`, `getAllRouters()` | Views.                                     |

## Fees and referrals

| Function                                                             | Notes                             |
| -------------------------------------------------------------------- | --------------------------------- |
| `setFeeBps(bps)`                                                     | Owner, at most 100.               |
| `setFeeAccount(addr)`                                                | Owner.                            |
| `setAddLiquidityFee(wei)`                                            | Owner, at most 1 ether.           |
| `setReferralShare(bps)`                                              | Owner, at most 5000.              |
| `registerReferral(referrer)`                                         | Anyone, once.                     |
| `claimETH()` / `claimToken(token)`                                   | Withdraw accrued fees or rewards. |
| `pendingETH(a)` / `pendingToken(a, t)`                               | Views.                            |
| `referrerOf(a)`, `referralEarnedETH(a)`, `referralEarnedToken(a, t)` | Views.                            |

## Rescue (owner)

`rescueToken(token, amount)` and `rescueETH(amount)` can only move funds **not owed to anyone**. They revert if the balance would drop below the accrued, unclaimed fees (`totalPendingToken` / `totalPendingETH`).

## Ownership

* `transferOwnership(newOwner)` - standard.
* `renounceOwnership()` - **disabled** (always reverts), so router and fee configuration can never be frozen.

## Events

`RouterQueued`, `RouterQueueCancelled`, `RouterAdded`, `RouterUpdated`, `Swapped`, `LiquidityAdded`, `FeeBpsUpdated`, `FeeAccountUpdated`, `AddLiquidityFeeUpdated`, `ReferralRegistered`, `ReferralRewardAccrued`, `ReferralShareUpdated`, `Claimed`, `Rescued`.


---

# 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.enoxswap.com/developers/enoxswap-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.
