Files
zeekay abf99d05fc papers: reorganize into per-paper dirs, add Antje Worring as co-author
Restructured from flat .tex/.pdf files into per-paper subdirectories.
Added Antje Worring as co-author on all papers.
Synced PDFs to pdfs/ for download site.
2026-04-18 21:50:07 -07:00

70 lines
2.5 KiB
TeX

\section{Formal Model}
\label{sec:model}
%% =====================================================================
\subsection{System State}
\begin{definition}[Chain State]
The chain state at block $h$ is a function
$\mathcal{C}_h : \text{Address} \times \text{Token} \rightarrow
\mathbb{N}$ mapping each (address, token) pair to a balance.
The genesis state $\mathcal{C}_0$ is defined by the genesis
configuration. For $h > 0$:
\[
\mathcal{C}_h = \mathcal{T}_h(\mathcal{C}_{h-1})
\]
where $\mathcal{T}_h$ is the deterministic state transition function
defined by the transactions in block $h$.
\end{definition}
\begin{definition}[Cache State]
The cache state $\mathcal{D}_h$ is maintained by the indexer. For
each chain event $e$ emitted by block $h$, the indexer applies a
deterministic update $\delta(e)$ to the cache:
\[
\mathcal{D}_h = \delta(e_1) \circ \delta(e_2) \circ \cdots \circ
\delta(e_k)(\mathcal{D}_{h-1})
\]
where $e_1, \ldots, e_k$ are the events in block $h$.
\end{definition}
\begin{definition}[Consistency]
The system is \emph{consistent at block $h$} if and only if:
\[
\forall \, (a, t) : \mathcal{D}_h(a, t) = \mathcal{C}_h(a, t)
\]
That is, the cache reflects the chain state for every address and
token.
\end{definition}
\subsection{Settlement Pipeline}
The pipeline from API request to on-chain settlement:
\begin{enumerate}[nosep]
\item \textbf{API receives order.} The order is validated
(authentication, authorization, compliance checks) and
recorded in the \texttt{pending\_orders} table.
\item \textbf{Matching engine matches order.} The matched trade
is recorded in the \texttt{trades} table and the
\texttt{pending\_settlements} table.
\item \textbf{Settlement cron fires (30s interval).} For each
pending settlement:
\begin{enumerate}[nosep]
\item Construct the on-chain transaction (mint target token,
burn source token).
\item Initiate MPC signing (2-of-3 threshold).
\item Broadcast the signed transaction.
\end{enumerate}
\item \textbf{Chain confirms transaction.} The transaction is
included in a block.
\item \textbf{Indexer processes block.} The indexer reads the
block's events and updates the cache. The
\texttt{pending\_settlements} entry is marked as confirmed.
\item \textbf{Cache serves reads.} The API layer reads balances,
positions, and transaction history from the cache.
\end{enumerate}
%% =====================================================================