> For the complete documentation index, see [llms.txt](https://docs.usefarlight.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.usefarlight.com/architecture/off-chain-services.md).

# The off-chain layer

The relayer, indexer, keeper bots, KYC provider and front-end that surround the Farlight contracts, and why none of them holds any power over the protocol.

No service outside the chain has authority in Farlight. Each one is open source and runnable by anyone, or carries no power at all, and usually both are true. The contracts remain the single source of truth; the services exist so that reading and acting on that truth is quick. They are the instruments on the ground, not the controls of the craft.

## Relayer

The relayer publishes the open book: every signed lend offer and borrow request that has not yet been turned into a loan.

| Aspect    | Detail                                                                                                                                  |
| --------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| Form      | A stateless service with REST and WebSocket interfaces                                                                                  |
| Stores    | Signed offers and borrow requests                                                                                                       |
| Validates | Signature, expiry, nonce state, the maker's balance and allowance (or vault balance), eligibility, and compatibility of term and tokens |
| Serves    | Filtered views by token, tier, term, APR and LTV, plus a suggested syndicate for any request                                            |
| Authority | None. Every offer is verified a second time on-chain at origination.                                                                    |
| Operators | Farlight Labs runs one instance; anyone may run another. The book is only a set of signed messages, so it can be rebuilt at any time.   |

### Endpoints

```
POST /v1/offers                 submit a signed offer
DELETE /v1/offers/:hash         soft-delete (the on-chain nonce cancel is authoritative)
GET  /v1/offers?token=&tier=&term=&maxApr=&minLtv=
POST /v1/requests               submit a borrow request
GET  /v1/requests/:id/matches   proposed syndicate for a request
GET  /v1/book/export            full dump of live offers and requests
WS   /v1/stream                 live offer and request updates
```

The `export` endpoint is a permanent transparency commitment. At any moment, anyone can download the complete book and mirror it elsewhere.

## Indexer

The indexer reconstructs protocol state from on-chain events. It runs on Ponder (TypeScript, self-hosted) or on Envio HyperIndex against chain 4663. Its jobs:

* feeding the Observatory (the public loan explorer), the Telemetry page (public risk readouts) and the borrower and lender dashboards;
* serving as the source of truth for the keeper bots;
* mirroring the relayer's book, so that the order book survives the loss of any single relayer;
* exposing a GraphQL endpoint open to any query.

## Keepers

Keepers are open-source bots. Anyone can run one, and wherever liquidation fees apply, running one pays.

| Bot                     | Trigger                                                                      | Action                                                          |
| ----------------------- | ---------------------------------------------------------------------------- | --------------------------------------------------------------- |
| Margin alert            | A loan's HF falls below 1.10                                                 | Sends the borrower a notice on their configured channels        |
| Auction kick-off        | HF falls below 1.00 or the loan is Defaulted, and no sequencer grace applies | Calls `startAuction` and earns the keeper share                 |
| Refinance acceptor      | The rate in a refinance auction reaches a lender's limit                     | Submits the acceptance that lender pre-signed                   |
| Idle-capital rebalancer | Vault liquidity changes, or a lender changes preference                      | Deposits into or withdraws from the vault through the adapter   |
| Oracle watch            | A move cap is hit, a pause flag is set, or a price turns stale               | Pushes the market pause to the front-end and the alert channels |

## KYC

A third-party provider performs the screening (a provider of the Sumsub or Persona kind, with a zero-knowledge option available). It:

1. carries out identity, sanctions and residency checks;
2. issues an EAS attestation for the matching role to the user's wallet;
3. renews or revokes that attestation each time the user is re-screened.

Personal data never touches the chain. The attestation holds three things and nothing else: the role, the jurisdiction class and an expiry. How the contracts read it is covered on the [Eligibility](/architecture/eligibility.md) page.

## Front-end

* Built with Next.js and viem, and served at `/platform` on usefarlight.com.
* Privy handles sign-in and embedded wallets on Robinhood Chain, and lets users sign offers and requests (EIP-712) without spending gas.
* Supabase stores the shared order book and loan registry, with row-level security bound to the Privy user.
* Screens: overview, borrow, lend (the order book together with offer management), positions, explorer, settings.

The front-end holds no keys and has no authority. Anything it shows can be verified against the indexer or against the chain directly. The [Platform](/architecture/platform.md) page covers the implementation.

## Alerts

A borrower can register alert channels with the keeper service: email, push through the wallet, or a webhook. Alerts are sent for an HF warning, a maturity drawing near, progress in a refinance auction, a market pause, and any parameter change affecting the borrower's loans.


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.usefarlight.com/architecture/off-chain-services.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
