> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rondo.finance/llms.txt
> Use this file to discover all available pages before exploring further.

# Contract API

> The user and integration-facing EVM interface for Rondo markets.

<Note>
  **ABI is the correct term here.** This is the human-readable reference for the deployed
  Application Binary Interface, not an HTTP API. JPYC, IDRX and IDRP use the same ABI at different
  proxy addresses.
</Note>

The Swapper ABI contains
**87 functions, 25 events and 45 custom errors**, including inherited OpenZeppelin entries.
`baseToken()` returns the selected market's JPYC, IDRX or IDRP, and `quoteToken()` returns Kaia
USDT. Copy-ready minimal viem ABIs for taker and maker integrations are provided in
[Contract integration](/build/contract-integration#obtain-the-abi), and the complete machine-readable
arrays are provided on [ABI JSON](/reference/abi-json).

## ABI types

```solidity theme={"system"}
enum OrderStatus { None, Open, Filled, Cancelled, Expired }
enum OrderKind { Fixed, Pegged }

struct Order {
  address maker;
  uint64 expiry;
  uint16 feeBps;
  OrderStatus status;
  OrderKind kind;
  address sellToken;
  uint16 premiumBps;
  address buyToken;
  uint256 sellAmount;
  uint256 buyAmount;
  uint256 sellRemaining;
  uint256 minRate;
}
```

Enums are ABI-encoded as `uint8`. `getOrder` returns this tuple in exactly the field order above.

## Maker

| Function                                                                             | Notes                                                    |
| ------------------------------------------------------------------------------------ | -------------------------------------------------------- |
| `createOrder(address,uint256,address,uint256,uint64) returns (uint256 orderId)`      | Fixed. `whenNotPaused nonReentrant onlyRole(MAKER_ROLE)` |
| `createPeggedOrder(address,uint256,uint16,uint256,uint64) returns (uint256 orderId)` | Pegged. Same modifiers. `minRate` may not be 0           |
| `cancelOrder(uint256 orderId)`                                                       | Maker only. **Never blocked by pause**                   |

## Taker

| Function                                                                                                                    | Notes                                                                                                                                               |
| --------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `fillOrder(uint256 orderId,uint256 sellAmountOut,uint256 maxAmountIn)`                                                      | `whenNotPaused nonReentrant`. `TAKER_ROLE` is checked inline only while `takerWhitelistEnabled` is on; the deployed instances currently have it off |
| `previewFill(uint256,uint256) returns (uint256 amountIn,uint256 fee,uint256 netOut)`                                        | Pricing only — see the warning below                                                                                                                |
| `previewFillForAmountIn(uint256,uint256) returns (uint256 sellAmountOut,uint256 actualAmountIn,uint256 fee,uint256 netOut)` | Caps the output at the order remainder                                                                                                              |

<Warning>
  **`previewFill` is not a dry run of `fillOrder`.** It shares `_quote`, so its arithmetic — and its
  stale-oracle and maker-floor reverts — cannot drift from the real fill. But everything `fillOrder`
  checks *around* that is absent: pause, expiry, `sellAmountOut > sellRemaining`, the minimum-fill and
  dust rules, and the caller's balance and allowance.

  It can return a quote while the desk is paused or for a size larger than the order holds. A
  successful preview therefore does not mean the fill will go through.
</Warning>

## Sweeper — no role

| Function                                                                                   | Notes                                              |
| ------------------------------------------------------------------------------------------ | -------------------------------------------------- |
| `expireOrders(uint256[] ids) returns (uint256 closed)`                                     | Permissionless. Skips ids that are not expirable   |
| `expiredOrderIds(uint256 offset,uint256 limit) returns (uint256[] ids,uint256 nextOffset)` | Scans one open-set window; intended for `eth_call` |

## Views

| Function                                                                                                                          | Returns                                                                    |
| --------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| `isMaker(addr)` · `isTaker(addr)`                                                                                                 | Maker and taker eligibility                                                |
| `canTake(addr)`                                                                                                                   | Whether `addr` may fill **now**, accounting for the taker-whitelist switch |
| `getOrder(uint256)` / `getOrders(uint256[])`                                                                                      | `Order` tuple / tuple array                                                |
| `orderStatus(uint256) returns (uint8)`                                                                                            | `OrderStatus`; reports `Expired` for open-but-lapsed orders                |
| `openOrderCount()` · `openOrderIds(uint256,uint256)`                                                                              | `uint256` count / `uint256[]` ids                                          |
| `makerOpenOrderCount(address)` · `makerOpenOrderIds(address,uint256,uint256)`                                                     | `uint256` count / `uint256[]` ids                                          |
| `getOraclePrice()`                                                                                                                | Five-minute Orakl TWAP as `(uint256 answer,uint256 updatedAt,bool stale)`  |
| `baseToken()` · `quoteToken()`                                                                                                    | Immutable `address` pair for this market                                   |
| `peggedRateNow(address,uint16,uint16) returns (uint256)`                                                                          | The rate a pegged order settles at right now — rounded **down**            |
| `minOrderAmount(token)` · `feeBps()` · `bandBps()` · `maxOracleAge()` · `maxOrderDuration()` · `maxPremiumBps()` · `priceScale()` | Trading configuration                                                      |
| `ORACLE_TWAP_INTERVAL()` · `ORACLE_TWAP_MIN_COUNT()`                                                                              | Fixed oracle policy: `300` seconds and `5` observations                    |
| `version()`                                                                                                                       | Deployed interface identifier as `string`                                  |

<Note>
  `openOrderIds` and `expiredOrderIds` clamp a caller-supplied `limit` that would overflow
  `offset + limit`, rather than panicking. Passing `type(uint256).max` is safe. For
  `expiredOrderIds`, keep following `nextOffset` even when the filtered `ids` page is empty.
</Note>

## Additional ABI entries

The complete ABI also contains inherited entries. Typical integrations need only `hasRole`,
`supportsInterface` and `paused` in addition to the functions above. The exact machine-readable
surface remains available on [ABI JSON](/reference/abi-json), while user-facing events and errors
are listed in [Events & errors](/reference/events-errors).
