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

# Execution and risk

> How execution-service, execution-contracts, and risk-core turn orders into settled futures trades

## Execution service

`execution-service` is a thin HTTP wrapper around the trusted executor.

It exposes:

* `GET /healthz`
* `POST /`
* `POST /execute`

The payload contains:

* `market`
* `asset_address`
* `module_address`
* `maker_order_id`
* `taker_order_id`
* `actions`
* `signatures`
* `order_data`

The service validates payload shape with Zod before submitting anything onchain.

## Execution contracts

`execution-contracts` contains the `Matching` and action-verification contracts used by the backend.

These contracts are responsible for:

* verifying signed user actions
* constraining which modules can execute those actions
* forwarding matched transfers into the account system

The execution path is trusted-backend driven. The orderbook does not send raw orders directly onchain.

## Risk core

`risk-core` is the account and margin layer underneath the orderbook.

Important concepts:

* `SubAccounts` stores `{asset, subId, balance}` state per account
* managers validate final account state and can handle settlement and liquidation
* assets define transfer semantics and settlement hooks
* `CashAsset` is the main cash accounting rail
* `PerpAsset` tracks unsettled PnL, funding, and price state for perpetual-style instruments

## Why this split exists

This architecture keeps concerns separate:

* `markets-service` handles order intake and market data
* `execution-service` handles verified transaction submission
* `execution-contracts` handles onchain match execution
* `risk-core` handles solvency, settlement, and liquidation
