Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xenophonlabs/crvUSDrisk
An Agent-Based model for simulating crvUSD market risks.
https://github.com/xenophonlabs/crvUSDrisk
Last synced: 22 days ago
JSON representation
An Agent-Based model for simulating crvUSD market risks.
- Host: GitHub
- URL: https://github.com/xenophonlabs/crvUSDrisk
- Owner: xenophonlabs
- License: mit
- Created: 2023-09-15T15:02:40.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-02T23:31:27.000Z (about 1 year ago)
- Last Synced: 2024-10-02T19:09:11.258Z (5 months ago)
- Language: Jupyter Notebook
- Homepage:
- Size: 177 MB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- defi-risk-modelling-awesome - Curve stablecoin simulation tool
- defi-risk-modelling-awesome - Curve stablecoin simulation tool
README
crvusd Risk Modeling
=======================================[](https://github.com/psf/black)
[](http://mypy-lang.org/)
[](https://github.com/xenophonlabs/crvUSDrisk/actions/workflows/CI.yml/badge.svg)
### Overview
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:
1. `src` contains all the logic for the underlying risk model.
2. `app` contains all the logic for deploying our Plotly Dashboard for viewing results. Find the dashboard [here](https://crvusdrisk-dashboard.up.railway.app/).
3. `scripts` contains all the logic for running the model.
4. `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.
### Table of Contents
1. [Setup](#setup)
2. [Running the Model](#usage)
3. [Dashboard](#dashboard)
4. [Analysis](#analysis)# Setup
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.*
# Running the Model
The model is run via the python and bash scripts in `scripts`.
### Single Model Run
We can perform a single model run with the command:
```
python3 -m scripts.sim -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.
### Parameter Sweeps
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.
### Updating Model Configs
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`.
# Dashboard
Results for the model runs detailed in our report can be analyzed in this Plotly Dashapp: [crvusdrisk.up.railway.app](crvusdrisk.up.railway.app). The dashboard is the best way to easily analyze individual model runs.
# Analysis
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.