Name of Quantlet: Onchain Insights
Published in: Onchain Insights : a study of Decentralized finance metrics for stablecoin depeg risk
Description: This study focuses on extensive open-access data available on the blockchain, and its use to predict depeg risks for various stablecoins. In particular, we focus on the dynamics of the liquidity curve from Uniswap's popular v3 liquidity pool protocol, focusing on the dominant stablecoin pool, USDC-USDT.
Keywords: Cryptocurrency, Blockchain, Stablecoins, Decentralized Finance, Liquidity, Depeg risk
Author: Owen Chaffard
Submitted: 25.01.2026
Run this command to get up-to-date data:
bash update_data.shInstall python requirements:
pip install -r requirements.txtThis quantlet uses minute OHLC data from binance and block by block metrics on the USDE/USDT Uniswap liquidity pool to plot an animation higlighting the price divergence during the Ethena depeg event on October 10th 2025.
cd 1.\ USDE\ binance\ depeg/ ;
python plot_animation.pyThis quantlet explores the theoretical invariant curve for Curvefi's Stableswap pools. It plots the different invariant curves dpeneding on the amplification parameter, as well as historical partial quotes and pool imbalance.
Run the notebook:
2. Curve liquidity pools/code.ipynbThis quantlet provides plots for viewing the time-varying liquidity distribution in the Uniswap v3 USDC-USDT pool. The liquidity curve is reconstructed from the Uniswap subgraph and we highlight its dynamics, as well as swap size impact curve, whicih are relevant to liqudiity risk for stablecoin depeg.
Run the notebook:
3.\ Uniswap\ liquidity\ curve/code.ipynbThis quantlet analyses ownership graphs of stablecoin liquidity on the 3pool and Uniswap. We first higlight the gap in TVL between the two venues, which is explained in part by Curve's liquidity being 70 owned by a hacker's cold wallet. We further highlight the distribution of whales on Curve's main stablecoin pool and the importance of metapools for the marketcap of the 3CRV LP token. Furthermore, we analyse the rise of MEV activity on the USDC-USDT v3 pool, showing a consistent volume of JIT (Just In Time) liquidity starting sometime in 2024. JIT liquidity is detected through block matching of mint and burn orders and we show it account for a major part of non-NFPM order flow.
Run the notebook:
4.\ Stablecoin\ liquidity\ ownership/code.ipynbThis quantlet contains plots related to the functional PCA analysis of the log-liquidity curve. FPCA is applied in a rolling window manner to study stability of the PCs and reliability of the decomposition through time using cumulative partial variance explained.
Run the notebook:
5. Functional PCA analysis of the liquidity curve/code.ipynbThis quantlet creates plots evaluating the decomposition of the log-Liquidity curve into an interpretable Legendre polynomial basis. We specifically compare the interpretability of a peg and price centered decomposition. Showing that while a price centered decomposition might look more stable it is unfit for stablecoin study due to the static mass of liquidity at and around peg.
Run the notebook:
6. Legendre basis decomposition/code.ipynbThis quantlet documents the extension of the Legendre decomposition into more general Gegenbauer polynomial bases. The effect of the
Run the notebook:
7. Gegenbauer Polynomials/code.ipynbThis quantlet provides code to run full cross-validation analysis of common tree-based architectures on the previously built dataset of stablecoin liquidity data. The binary task is that of predicting a depeg deviation above 15 bps in the next 24 hours. The scripts allow Cross-validation for model selection and final retraining including a full suite of diagnostics for the final model's performance and explanations through internal feature impartance and SHAP explanations.
Final retraining AUC/AUPRC
SHAP correlation scatter plots
View the detailed instructions in the README:
8. Early-Warning Model/README.mdIn this quantlet we evaluate the distribution of stablecoin depeg basis points. ARIMA/GARCH residuals show poor fit against Gaussian/Student's t innovations. In order to circumvent this issue we train a Neural Network to regress the quantile function in a non-distributional manner. We show the use of both Chebyshev and I-spline bases for quantile function regression, and their advantages/drawbacks. We also introduce the threshold weighted CRPS used to favor rare extreme events in the diustributional calibration. Lastly we showcase the addition of spliced GPD tails for modeling extreme events/ closed form VaR+ES estimation.
I spline bases generated with uniform and power-tails knots
Quantile function tail focus based on knot density
Spliced Quantile function with parametric GPD tails
Weight and Chaining function of the threshold weighted CRPS
Run the notebook:
9. Parametric quantile function characterisation/code.ipynbOur custom Neural Network Forecasting architecture
L0 regularisation with hard concrete gating
NHITS encoder stack decomposition
Run the notebook:
10. Forecasting architecture/code.ipynb





























