Vest Exchange
  • Welcome
    • About Vest
    • Getting started
  • Overview
    • Vest Architecture
      • Overview
      • zkRisk Engine
      • Swaps
      • Clearinghouse
      • Order book
      • Oracle
      • Vest Liquidity Pool
      • Blockchain
      • Decentralization
    • Trading
      • Perpetual contract specifications
      • Fees
      • Order book
      • Order types
      • Funding
      • Margin
      • Liquidations
      • Price Indices
      • Market making
    • Providing Liquidity
  • Points
  • Referrals
  • Risks
  • Audits
  • Media Kit
  • Vest API
  • Resources
    • Research
    • Github
    • Twitter
    • Discord
Powered by GitBook
On this page

Was this helpful?

  1. Overview
  2. Vest Architecture

zkRisk Engine

PreviousOverviewNextSwaps

Last updated 16 days ago

Was this helpful?

Overview

zkRisk is Vest's decentralized risk engine that powers the pricing and risk management across the entire platform. It uses zero-knowledge proofs (ZKPs) to ensure that every trade is priced fairly and that the system remains solvent, without revealing sensitive user data.

Traditional exchanges rely on manual intervention, static risk limits, and reactive liquidations to control systemic risk. In contrast, zkRisk continuously measures the health of the entire ecosystem in real time, using mathematical tools like Expected Shortfall (EVaR) and volatility forecasts. It automatically adjusts prices and funding rates based on how much risk each trade adds to the system, discouraging risky behavior before it becomes a problem.

By embedding these calculations directly on-chain through succinct proofs, zkRisk allows Vest to operate trustlessly: users don't need to rely on the exchange to act fairly — they can verify it for themselves. The result is a decentralized, preventative, and scalable model of risk management designed specifically for next-generation financial ecosystems.

Coherent Risk Measure

Consider nnn markets, where the underlying assets follow a price process

St=(St(1)⋮St(n))∈R++n,S_t = \begin{pmatrix} S_t^{(1)} \\ \vdots \\ S_t^{(n)} \end{pmatrix} \in \mathbb{R}_{++}^n,St​=​St(1)​⋮St(n)​​​∈R++n​,

adapted on a filtered probability space

(Ω,F,Ft0≤t≤T,P)(\Omega, \mathcal{F}, {\mathcal{F_{t0}} \leq t \leq T}, \mathbb{P})(Ω,F,Ft0​≤t≤T,P)

We will define the exchange’s liability at time ttt as a function of StS_tSt​, parameterized by the state of the exchange θ=(q,C,P,L)\theta = (q, C, P, L)θ=(q,C,P,L).

Note the following variables and their corresponding definitions:

q∈Rnq \in \mathbb{R}^nq∈Rn: the vector of long-short imbalances ($q_i > 0$ implies that the $i$th market is long-heavy, hence the AMM is net short)

Then Xt, the net payout to traders if all outstanding positions were to be closed at prices St, is given by

In other words, Xt represents the net payout to traders if all outstanding positions were to be closed at prices St.

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 adopt 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

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

We define our risk measure as

with capital buffer

Premia

Funding

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.

We now define instantaneous funding charged across all open positions as

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

C=q⊤Sˉ∈RC = q^\top \bar{S} \in \mathbb{R}C=q⊤Sˉ∈R: the summation of entry notional sizes (signed) of all open positions

P∈R+P \in \mathbb{R}+P∈R+: capital owned by the AMM

L∈R+L \in \mathbb{R}+L∈R+: capital provided by LPs

Xt(θ):=f(St;θ)=q⊤St−(C+P+L)X_t(\theta) := f(S_t; \theta) = q^\top S_t - (C + P + L)Xt​(θ):=f(St​;θ)=q⊤St​−(C+P+L)

P(X≥a)≤e−zaMX(z)=αP(X \geq a) \leq e^{-za} M_X(z) = \alphaP(X≥a)≤e−zaMX​(z)=α. Solving for α\alphaα,

EVaR1−α(X)=inf⁡z>0{z−1ln⁡(MX(z)α)}\text{EVaR}_{1-\alpha}(X) = \inf_{z > 0} \left\{ z^{-1} \ln \left( \frac{M_X(z)}{\alpha} \right) \right\}EVaR1−α​(X)=infz>0​{z−1ln(αMX​(z)​)}

for a confidence level 1−α1 - \alpha1−α.

Xt+τ<0X_{t + \tau} < 0Xt+τ​<0.

ρ(Xt+τ∣Ft):=EVaR1−α(Xt+τ+−Pt∣Ft)\rho(X_{t+\tau} \mid \mathcal{F}_t) := \text{EVaR}_{1-\alpha}(X_{t+\tau}^{+} - P_t \mid \mathcal{F}_t)ρ(Xt+τ​∣Ft​):=EVaR1−α​(Xt+τ+​−Pt​∣Ft​)

Pt=∑s=t−τtπsp+fspP_t = \sum_{s = t - \tau}^{t} \pi_s^p + f_s^pPt​=∑s=t−τt​πsp​+fsp​.

Here, πp\pi^pπp and fpf^pfp are premium and funding collected by the AMM respectively.

We define (⋅)+:=max⁡(0,⋅)(\cdot)^+ := \max(0, \cdot)(⋅)+:=max(0,⋅) to ignore upside (i.e., negative shortfall only).

For a new trade qt∈Rn\mathbf{q}_t \in \mathbb{R}^nqt​∈Rn, 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

πtρ:=(ρ(Xt+τ(θ′)∣Ft)−ρ(Xt+τ(θ)∣Ft))+\pi_t^{\rho} := \left( \rho(X_{t+\tau}(\theta') \mid \mathcal{F}_t) - \rho(X_{t+\tau}(\theta) \mid \mathcal{F}_t) \right)^+πtρ​:=(ρ(Xt+τ​(θ′)∣Ft​)−ρ(Xt+τ​(θ)∣Ft​))+

where θ=(q,C,P,L)\theta = (\mathbf{q}, C, P, L)θ=(q,C,P,L) and θ′=(q+qt,C+qt⊤St,P,L)\theta' = (\mathbf{q} + \mathbf{q}_t, C + \mathbf{q}_t^\top S_t, P, L)θ′=(q+qt​,C+qt⊤​St​,P,L) represent states before and after accepting the trade.

At t+τt + \taut+τ, AMM-owned capital PPP is incremented by πtρ\pi_t^{\rho}πtρ​.

Given our risk measure is 1-positive homogeneous, we use a risk attribution mechanism called Euler allocation to define per-market funding rate. Let Xt(i)X_t^{(i)}Xt(i)​ be the liability arising from the iiith market. We calculate the amount of funding assigned to the iiith market as

ρEuler(Xt+τ(i)∣Ft):=∂ρ(∑i=1nuiXt+τ(i)∣Ft)∂ui∣(1,…,1)\rho_{\text{Euler}}(X_{t+\tau}^{(i)} \mid \mathcal{F}_t) := \left. \frac{\partial \rho\left(\sum_{i=1}^n u_i X_{t+\tau}^{(i)} \mid \mathcal{F}_t\right)}{\partial u_i} \right|_{(1, \ldots, 1)}ρEuler​(Xt+τ(i)​∣Ft​):=∂ui​∂ρ(∑i=1n​ui​Xt+τ(i)​∣Ft​)​​(1,…,1)​

This represents the marginal risk added by long-short imbalance in the iiith market.

ftρ(Xt+τ(i)∣Ft):=∂ρEuler(Xt+τ(i)∣Ft)∂τ∣τf_t^{\rho}(X_{t+\tau}^{(i)} \mid \mathcal{F}_t) := \left. \frac{\partial \rho_{\text{Euler}}(X_{t+\tau}^{(i)} \mid \mathcal{F}_t)}{\partial \tau} \right|_{\tau}ftρ​(Xt+τ(i)​∣Ft​):=∂τ∂ρEuler​(Xt+τ(i)​∣Ft​)​​τ​

Now, for each trader j∈Iij \in I_ij∈Ii​ with position size qij∈Rq_{ij} \in \mathbb{R}qij​∈R where ∑j∈Iiqij=qi\sum_{j \in I_i} q_{ij} = q_i∑j∈Ii​​qij​=qi​, they are responsible for covering

ftρ(Xt+τ(i)∣Ft)⋅qijqi.f_t^{\rho}(X_{t+\tau}^{(i)} \mid \mathcal{F}_t) \cdot \frac{q_{ij}}{q_i}.ftρ​(Xt+τ(i)​∣Ft​)⋅qi​qij​​.

ftρ(Xt+τ(i)∣Ft)⋅qijqi>0f_t^{\rho}(X_{t+\tau}^{(i)} \mid \mathcal{F}t) \cdot \frac{q{ij}}{q_i} > 0ftρ​(Xt+τ(i)​∣Ft)⋅qi​qij​>0 means trader jjj pays the funding, and they receive it otherwise.

Similar to premium, PPP will be incremented at time t+τt + \taut+τ with funding charged at time ttt.