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

# How TRNCH works under the hood

A high-level view of how TRNCH is built.

TRNCH is a non-custodial trading interface with a game computed off-chain. This page gives the big picture. It leaves out anything that would help someone attack the service.

```mermaid
flowchart TD
    chain["Robinhood Chain"] --> relay["Real-time relay"]
    relay -->|"live prices, trades, the Heat"| browser["Your browser"]
    relay --> servers["TRNCH servers"]
    servers -->|"quotes, transactions to sign"| routers["Third-party swap aggregators"]
    servers --> db["Database"]
    db --> engine["Game engine: volume, packs, scores, rankings"]
    engine -->|"signed ranking"| contract["Settlement contract, coming soon"]
    contract -->|"payouts"| ranks["Paid ranks"]
```

Your wallet signs every transaction itself.

## A non-custodial interface

TRNCH never holds your funds and never sees your keys. The site prepares transactions, and your wallet shows them to you and signs them. Nothing is ever signed automatically on your behalf, and TRNCH cannot move, freeze or recover anything in your wallet.

## A real-time relay

A dedicated service reads Robinhood Chain continuously, through blockchain data providers. It decodes swaps across the main pool families (Uniswap-style pools and bonding curves), values them, keeps the recent history of every active pool in memory, computes the Heat and streams it all to your browser. That is why the race and the charts move trade by trade.

## Reference prices

Wherever a price matters, to check a swap quote or to score a card, TRNCH takes the median of the token's active pools. Pools known to be too thin are left out. With three pools or more, one pool pushed by a large trade cannot drag the median on its own. A token with only one pool deep enough is priced from that pool, which is why swap quotes are also compared with each other. See [Routing and quotes](/trade/routing-and-quotes.md).

## Routing

TRNCH's servers request quotes from four third-party aggregators at once, covering 50+ DEXs on Robinhood Chain, and check them against each other and against the reference price before one is shown. Your browser never talks to the routers directly. The transaction you sign is built by the chosen router's contracts, and approvals are limited to the exact amount of the swap.

## Volume and packs

When you sign a swap, the site records its transaction hash. Once the transaction is confirmed, TRNCH reads it on-chain and credits the net amount you traded, even if you closed the tab in between. Only swaps built through TRNCH count. Packs follow your volume automatically.

## The game is computed off-chain

Scores, rankings, packs and fusions are computed by TRNCH's game engine, not by a smart contract. The time of each lock is set by the server, never by your device. Keeping the game logic off-chain keeps the contract small and lets the rules evolve without redeploying it.

## Settlement

The pot will be held by a smart contract with a single job: hold the funds and pay out according to a ranking signed by TRNCH's backend. Before paying, it checks that the ranking is correctly signed, that payouts never exceed the pot, that a round is never paid twice, that the timing matches the round and that the number of winners stays within bounds. If a check fails, the funds stay in the contract and the round is settled later. They are never lost.

{% hint style="info" %}
**Coming soon.** The settlement contract comes with the game. Its address will be published here before the game opens.
{% endhint %}

## Charts and market data

Charts are drawn with TradingView's Lightweight Charts library, served from TRNCH itself. Their history comes from GeckoTerminal and the live part from the relay. Market statistics, token details and logos come from GeckoTerminal, DexScreener and the Blockscout explorer.

## Automation

Everything that repeats runs as a scheduled job: naming new tokens, checking which tokens can be traded, crediting late swaps, closing rounds, cleaning old data. The back office is for watching, not for computing.


---

# 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.trnch.fun/architecture.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.
