crvUSDRisk is a tool for Curve’s researchers and developers to test the resiliency of the crvUSD ecosystem under a variety of market conditions.
The codebase is organized into four components:
src
contains all the logic for the underlying risk model.app
contains all the logic for deploying our Plotly Dashboard for viewing results. Find the dashboard here.scripts
contains all the logic for running the model.notebooks
contains some demos for different aspects of the model.
Our analysis of initial model results can be found in this report: https://xenophonlabs.com/papers/A_Quantitative_Risk_Model_for_crvUSD.pdf.
We use a simple python venv
for package management.
python3 -m venv venv
source venv/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
Only Python3.11 is guaranteed support. Notice that the requirements point to a fork of crvusdsim
. We are working on replacing this dependency with stable release.
The model is run via the python and bash scripts in scripts
.
We can perform a single model run with the command:
python3 -m scripts.sim <scenario> <num_iter> -mp -a
where scenario
is the name of the scenario you want to run (refer to /src/configs/scenarios.py
) and num_iter
is the number of iterations you want to run (e.g. 1000). The optional flags -mp
and -a
will run the scenario using multiprocessing (by default will max out all of your CPUs) and will dumb a profile of the code respectively.
When we run our scenarios under different parameter configurations for the crvUSD protocol (such as varying fees or Chainlink limits) we call this an experiment
. We have configured a few experiments under scripts/experiments
which can be run with:
nohup ./scripts/experiments/run_experiments.sh &
You'll want to run it with nohup
since these experiments can take a very long time, especially without many CPUs.
The prices, liquidities, and other necessary scenario/parameter configurations are all contained in src/configs
. Many of the config files are generated by running the corresponding scripts in scripts
.
Results for the model runs detailed in our report can be analyzed in this Plotly Dashapp: crvusdrisk.up.railway.app. The dashboard is the best way to easily analyze individual model runs.
Our analysis of initial model results can be found in this report: https://xenophonlabs.com/papers/A_Quantitative_Risk_Model_for_crvUSD.pdf.
We used the analysis.ipynb
notebook in notebooks
to compare results across many scenarios.