To view this paper in PDF format, visit here.


We present a novel framework to unify the trading experience of digital assets and the money market such that the solvency of an exchange is guaranteed with high probability. This framework serves as the foundation for a trustless, composable financial ecosystem that enables the community to launch their own products while tapping into the deep liquidity of Vest.

This outlines the construction of an AMM for a perpetual futures exchange following this framework. Instead of a limit orderbook, traders trade against a liquidity pool composed of external liquidity providers (LPs) and an automated market maker (AMM) that prices shortfall risk using a coherent risk measure.


Prior attempts to develop trustless and scalable derivative exchanges through mechanisms like Constant Function Market Makers (CFMMs) and Limit Orderbooks (LOBs) have fallen short due to an inherent trade-off between risk management and efficient pricing.

On one hand, some exchanges guarantee solvency but result in less favorable pricing for traders, as observed in CFMMs where a basic formula dictates asset pricing. On the other hand, exchanges prioritizing better pricing often face higher insolvency risk, such as exchanges allowing trading directly on spot prices or LOBs due to the heterogeneity of independent market makers’ risk profiles.

This poses a challenge: how can exchanges ensure liquidity without compromising pricing and risk?


zkRisk is a hybrid model that enforces a single coherent risk framework and responsively prices liquidity. It prices via. risk-indifference pricing, where the potential shortfall of exchange liability is quantified using a coherent risk measure. The control variables are premia and funding, which directly reduce risk and incentivize the reduction of liability. To maintain trustlessness, the resulting risk measure and proof of its computation is posted on-chain via zkSNARKs. This can be accessed and verified by anyone.

Coherent Risk Measure

Consider n markets, where the underlying assets follow price process S_t = \begin{pmatrix} S^{(1)}_t \\ \vdots \\ S^{(n)}_t\end{pmatrix} \in \mathbb{R}^n_{++} adapted on a filtered probability space (\Omega, \mathcal{F}, \{\mathcal{F}_t\}_{0\leq t \leq \tau}, \mathbb{P}).

We define the exchange’s liability at time t as a function of S_t, parameterized by the state of the exchange \theta = (\mathbf{q}, C, P, L)

\begin{equation} X_t(\theta) := f(S_t;\theta)= \mathbf{q}^TS_t-(C+P+L) \end{equation}

where \mathbf{q} \in \mathbb{R}^n is a vector of long-short imbalances ( q_i > 0 implies that the $i$th market is long-heavy, hence AMM is net short), C = \mathbf{q}^T\overline{\mathbf{s}} \in \mathbb{R} is the summation of entry notional sizes (signed) of all open positions, P \in \mathbb{R}_+ is capital owned by the AMM, and L \in \mathbb{R}_+ is capital provided by LPs (see Section Liquidity Providers). In other words, X_t represents the net payout to traders if all outstanding positions were to be closed at prices S_t.

We use a monetary risk measure, a mapping from a set of random variables to the real numbers, to calculate the amount of capital needed to cover the potential shortfall with high probability. In particular, we use an extension of a coherent risk measure called Entropic Value-at-Risk (EVaR).

EVaR is the tightest upper bound to Value-at-Risk (VaR) and Conditional Value-at-Risk (CVaR) derived from the Chernoff bound P(X\geq a) \leq e^{-za}M_X(z)=\alpha, solving for a:

\begin{equation} \text{EVaR}_{1-\alpha}(X) = \inf_{z > 0} \{ z^{-1} \ln \frac{M_X(z)}{\alpha} \} \end{equation}

for a confidence level 1-\alpha.

Using EVaR, zkRisk charges premia and funding to guarantee solvency with respect to rolling windows [t,t+\tau] by ensuring the following invariant holds with high probability at t:

\begin{equation} X_{t+\tau} < 0. \end{equation}

We define our risk measure as

\begin{gather} \rho(X_{t+\tau}|\mathcal{F}_t) := \text{EVaR}_{1-\alpha}(X_{t+\tau}^+ - P_t|\mathcal{F}_t) \\ P_t = \sum_{s=t-\tau}^t \pi^\rho_s + f^\rho_s \end{gather}

where \pi^\rho and f^\rho are premium and funding collected by the AMM respectively (See section premia and funding). We take (\cdot)^+ = \max(0, \cdot) to ignore upside (negative shortfall). This particular construction is coherent (see Appendix A).


For a new trade \mathbf{q}_t \in \mathbb{R}^n, zkRisk charges premium or provides rebate such that the risk before and after accepting the trade remains invariant. In particular, we define the premium as

\begin{equation} \pi^\rho_t := (\rho(X_{t+\tau}(\theta') | \mathcal{F}_t) - \rho(X_{t+\tau}(\theta)|\mathcal{F}_t))^+ \end{equation}

where \theta = (\mathbf{q}, C, P, L) and \theta' = (\mathbf{q}+\mathbf{q}_t, C+\mathbf{q}_t^TS_t, P, L) represent states before and after accepting the trade. At t+\tau, exchange-owned capital P is incremented by \pi_t^\rho.


While premia charges for marginal change in risk from the change in liability, zkRisk needs to collect funding from open positions to cover the market risk.

Given our risk measure is 1-positive homogenous (see Appendix A), we use a risk attribution mechanism called Euler allocation to define per-market funding rate. Let X_{t}^{(i)} be the liability arising from $i$th market. We calculate the amount of funding assigned to the $i$th market as

\begin{equation} \rho_{Euler}(X_{t+\tau}^{(i)}|\mathcal{F}_{t}):= \frac{\partial\rho(\sum_{i=1}^n u_i X_{t+\tau}^{(i)} |\mathcal{F}_t)}{\partial u_i}|_{(1,\dots,1)}. \end{equation}

This represents the marginal risk added by long-short imbalance in the $i$th market. We now define instantaneous funding charged across all open positions as

\begin{equation} f^\rho_t(X^{(i)}_{t+\tau}|\mathcal{F}_t) := \frac{\partial \rho_{Euler}(X_{t+\tau}^{(i)}|\mathcal{F}_t)}{\partial \tau} |_{\tau} \end{equation}

which corresponds to the marginal change in risk with respect to time.

Now, for each trader j \in I_i with position size q_{i_j} \in \mathbb{R} where \sum_{j\in I_i}q_{i_j}=q_{i}, they are responsible for covering

\begin{equation} f^\rho_t(X^{(i)}_{t+\tau}|\mathcal{F}_t)\frac{q_{i_j}}{q_{i}}. \end{equation}

f^\rho_t(X^{(i)}_{t+\tau}|\mathcal{F}_t)\frac{q_{i_j}}{q_{i}} > 0 means trader j pays the funding and they receive it otherwise.

Similar to premium, P will be incremented at time t+\tau with funding charged at time t. Derivation of the exact formulas are deferred to Appendix B.

Liquidity Providers


LPs receive rewards for underwriting potential shortfall by committing capital $L$.

Suppose LPs commit aggregate capital L. Given the AMM’s state \theta = (\mathbf{q}, C, P, L), we represent the inventory \mathbf{q} as a single virtual asset whose price follows a univariate normal distribution S^v_{t} \sim \mathcal{N}(\mathbf{q}^T \boldsymbol{\mu}_{t}, \mathbf{q}^T \mathbf{\Sigma}_{t} \mathbf{q}), where S_t \sim \mathcal{N}(\boldsymbol{\mu}_{t}, \boldsymbol{\Sigma}_{t}). With respect to such contract, the AMM has average entry price \bar{s}^v = C and default price d^v = \bar{s}^v + P + L.

Figure 1: Exchange payoff graph|594x500

Observe that LPs take on the entire liability after the AMM has run out of capital P by taking on a bounded payoff Y_t where

\begin{equation} Y_t := -(S^v_t - (\bar{s}^v + P))^+ + (S^v_t - (\bar{s}^v+P+L))^+ \end{equation}

which is equivalent to the payoff of selling a call spread on the virtual asset.


We can view the total exchange risk as being composed of an unhedgeable component taken on by the AMM and a hedgeable component taken on by the LPs.

Thus, we define the premium given to LPs of a new trade \mathbf{q}_t as

\begin{equation} \pi_t^L := (C_{K_1(\theta'), K_2(\theta')}(t,t+\tau) - C_{K_1(\theta), K_2(\theta)}(t,t+\tau))^+ \end{equation}

where C_{K_1, K_2}(t, T) is the price of a call spread with strikes K_1 < K_2 at t expiring at T, K_1(\theta) = C + P and K_2(\theta) = C+P+L.


Similar to risk-indiff-funding, LPs will collect funding from traders. We define total instantaneous funding f^L_t charged across all open positions per unit time as

\begin{equation} f^L_t := \frac{\partial C_{K_1,K_2}(t,t+\tau)}{\partial \tau} |_{\tau} \end{equation}

This is distributed among all markets using Euler allocation.


An LP may declare to withdraw capital l at t by keeping it locked until t+\tau. Otherwise, one may force withdraw without waiting, say at s < t+\tau,
with a risk-indifference fee:

\begin{equation} \rho(X_{t+\tau}(\theta')|\mathcal{F}_{s}) -\rho(X_{t+\tau}(\theta)|\mathcal{F}_{s}) \end{equation}

where \theta = (\mathbf{q}, C, P, L) and \theta' = (\mathbf{q}, C, P, L - l). This ensures that the force withdrawal of capital does not impact the risk level of the AMM.

Risk Engine

Volatility Forecast

First, we cluster assets into groups with cointegrated time series of log returns. Then, we forecast the covariance within each group. Let \{\mathbf{r}_t\} \in \mathbb{R}^n be a vector stochastic process of standardized log returns. We assume the following model:

\begin{equation} \mathbf{r}_t \mid \mathcal{F}_{s} \sim \mathcal{N}(0, \mathbf{\Sigma}_t) \end{equation}

for s \leq t where \mathcal{F}_{s} is the information up to time s and \mathbf{\Sigma}_t is the covariance matrix that we wish to forecast.

We assume that there exist unobservable factors \mathbf{f}_t that are conditionally heteroscedastic and generate the log returns \mathbf{r}_t for a set of assets. That is,

\begin{equation} \mathbf{r}_t = \mathbf{Z} \mathbf{f}_t \end{equation}

where \mathbf{Z} is a time-invariant linear map. We argue that such an assumption is justified in the speculative context of cryptocurrencies where price movements are often highly correlated.

We use Generalized Orthogonal-GARCH (GO-GARCH), because it outperforms other models such as univariate GARCH and DCC-GARCH in our backtests. GO-GARCH allows \mathbf{Z} to be (left) invertible and parameterizes \mathbf{Z} with singular value decomposition:

\begin{equation} \mathbf{\Sigma}_t = \mathbf{Z} \mathbf{D}_t \mathbf{Z}^T,\ \mathbf{Z} = \mathbf{Q} \boldsymbol{\Lambda} \mathbf{U}^T \end{equation}

where \mathbf{D}_t = diag(\sigma^2_{f_{t,1}}, \ldots, \sigma^2_{f_{t, n}}) is a diagonal matrix of the conditional variances of each factor modeled by univariate GARCH. \mathbf{Z} = \mathbf{Q}\boldsymbol{\Lambda}\mathbf{U}^T is the n \times n mixing matrix outputted by Independent Component Analysis.


If the portfolio value for a trader becomes less than the maintenance margin requirement, open positions will be closed partially or fully in order to bring the account value back to a healthy level (above the initial margin requirement).

Currently the liquidator runs an optimal liquidation solver in order to prevent excessive liquidations for traders as well as to minimize the negative externalities such as liquidation cascades.

In particular, liquidation of a portfolio \mathbf{q}_j is formalized as a convex optimization problem:
\begin{align} \underset{\mathbf{w}}{\text{minimize}} \quad & \sum_{i=1}^nw_iq_j^{(i)}S_{t}^{(i)} \\ \text{subject to} \quad &\mathbf{0} \preceq \mathbf{w} \preceq \mathbf{1} \\ & (r + \epsilon)\sum_{i=1}^n(1-w_i)|q_j^{(i)}|S_{t}^{(i)} \leq c - \pi + \sum_{i=1}^n(S_{t}^{(i)}-s_{entry}^{(i)})q_j^{(i)} \\ &\pi = (\rho(X_{t+\tau}(\theta')|\mathcal{F}_t)-\rho(X_{t+\tau}(\theta)|\mathcal{F}_t))^+\\ &\theta = (\mathbf{q}, C, P, L) \\ &\theta' = (\mathbf{q}-(\mathbf{1}-\mathbf{w})\mathbf{q}_j, C-(\mathbf{1}-\mathbf{w})\mathbf{q}_j^TS_t, P, L) \end{align}

where \mathbf{w} is the optimal liquidation weight that we solve for, S_{entry}^{(i)} and \mathbf{q}_j^{(i)} are entry price and signed position size for position i, c is the collateral, and \pi is the liquidation fee. Note that the liquidation fee (23) is convex in \mathbf{w}, as it is determined by risk measure \rho which is convex in \mathbf{w}, and the second term \rho(X_{t+\tau}(\theta)|\mathcal{F}_t) is a constant.

Verifying Off-Chain Computation via. zkSNARKs

Due to the computational complexity of the pricing mechanism and risk engine, we offload computations off-chain and produce proof of correctness that can be verified on-chain.

Proof of Computation

Using zkSNARKs, we prove correctness of the pricing by first proving that the forecasted covariance matrix is outputted by the declared model given a vector of market prices. Then, given the forecasted covariance matrix, we prove that the pricing of premia and funding is computed according to their respective risk-indifference formulas. The resulting risk measure is also be posted on chain.

Proof of Optimality

Liquidations are formulated as convex optimization problems. By exploiting strong duality, we prove that a given solution is optimal with zkSNARKs by proving that it is feasible for both the [primal and dual problems](https://www.usenix.org/system/files/sec22-angel.pdf) and that the duality gap is zero (up to some precision errors). We then leverage state-of-the-art solvers off-chain. This also implies we can decentralize the running of these solvers and reward solutions based on speed.