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

# Contracts

> The one contract a swap calls: the Aile order protocol on Base, an unmodified deployment of the audited 1inch Limit Order Protocol v4 under Aile's own EIP-712 domain.

## The order protocol

A swap on Aile calls exactly one Aile contract: the order protocol. You approve it for the token you
sell and send the fill to it. `GET /config` returns its address as `contracts.lop`; read it from there at
runtime.

| | |
| - | - |
| Contract | `AileLimitOrderProtocol` |
| Address on Base | [`0x26110236656013A0d0Bad7e6b926AD9d4568A268`](https://basescan.org/address/0x26110236656013A0d0Bad7e6b926AD9d4568A268) |
| EIP-712 domain | name `Aile Intent Protocol`, version `1`, chain ID `8453`, verifying contract as above |
| Fill method | `fillOrder(order, r, vs, amount, takerTraits)` — the calldata in `fill.data` |
| Events | `OrderFilled(bytes32 orderHash, uint256 remainingAmount)`, `OrderCancelled(bytes32 orderHash)` |
| Owner functions | `pause()`, `unpause()` — stop and resume new fills; they cannot move funds or alter orders |

The same deployment serves staging and production.

## Built on 1inch, not routed through 1inch

The order protocol inherits `OrderMixin` from the 1inch Limit Order Protocol v4
([`@1inch/limit-order-protocol-contract` 4.3.2](https://github.com/1inch/limit-order-protocol)),
**unmodified**. 1inch publishes the security audits of that release in
[1inch/1inch-audits](https://github.com/1inch/1inch-audits/tree/master/Limit%20Order%20Protocol).

What Aile adds is a 23-line wrapper:

* its own EIP-712 domain (`Aile Intent Protocol` / `1`), so an order signed for Aile cannot be replayed
  against 1inch's own deployment or another chain, and vice versa;
* an owner-only pause (OpenZeppelin `Pausable`, `Ownable`).

Nothing else in the inheritance chain is overridden. In a firm-quote swap the order carries no extension
and no fee leg, so the only code that moves funds is 1inch's audited code. Reusing it is not the same as
sending trades to 1inch: no order reaches 1inch's contracts, resolvers or routing, and 1inch has no role
in the trade.

> [!NOTE]
>
> Aile does not claim an audit of its own. The wrapper above is the whole of Aile's code in the swap path,
> and it is small enough to read on Basescan. Aile's other contracts (maker executors, settlement
> extensions for a future partial-fill path) are not called in a firm-quote swap and are not documented
> here.

## What the contract checks

On `fillOrder`, the protocol verifies that:

1. the signature (`r`, `vs`, EIP-2098 compact form) recovers to `order.maker`;
2. `msg.sender` is the taker the order was signed for (`allowedSender` in `makerTraits`);
3. the order has not expired (`expiresAt` in `makerTraits`);
4. the order's nonce bit is unspent (`bitInvalidatorForOrder(maker, nonce)`); a replay reverts
   `BitInvalidatedOrder`;

then transfers `takingAmount` of the sold token from the taker to the maker and `makingAmount` of the
bought token from the maker to the taker, and emits `OrderFilled` with `remainingAmount` 0. The maker
pays from its own wallet under an ERC-20 allowance it granted the protocol; its balance and allowance
are what bound `maxFirmSize`.

The contract does not check the price. The amounts are whatever the maker signed; see
[How it works](https://staging.docs.aile.tech/how-it-works.md#what-the-chain-enforces-and-what-it-does-not).

## Tokens

Token addresses are on [Networks and tokens](https://staging.docs.aile.tech/reference/networks-and-tokens.md). Every token is a standard
ERC-20; approve the order protocol for the one you sell.

## Order format

`quote.order` is the 1inch v4 order struct with decimal-string amounts:

| Field | Meaning |
| - | - |
| `maker` | The market maker's wallet. Informational; do not pin it. |
| `receiver` | Where the taker's token goes; the maker, or the settlement address when an extension is present. |
| `makerAsset`, `takerAsset` | The token you receive and the token you pay. |
| `makingAmount`, `takingAmount` | The exact amounts of the fill. |
| `makerTraits` | Packed flags: allowed sender, expiry, nonce, no partial fills. |
| `salt` | Random per quote; its low 160 bits hash the extension (`0x` today). |

`orderHash` (the key of `GET /orders/{hash}`) is the EIP-712 hash of this struct under the domain above.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.