Predictive modelling of depegging on Cuve.fi.
The price of token at the stableswap Curve.fi is calculated by the the equation below.
The equation describes a curve whose shape depends on the amount of token
The virtual price is given by the negative of the tangent to the point
Changing the number of tokens and/or
The more extreme the ratio of the two tokens become the more the price deviates from
In the figure above, the red line indicates the border between peg
We want to predict depegs
We have data from five Curve.fi pools where depeg occurred (USDN-3CRV, MIM-UST, sETH-ETH, pUSd-3Crv, UST-3Pool). From each pool we have the number of tokens over variable number of days, from 77 (pUSd-3Crv) to 626 (USDN-3CRV) days. We computed the virtual price from the pool data. We defined a depeg as a 1% deviation from a price of
Learners were fitted three times on four of the five pools, each time with a different hold-out pool. We averaged the results across the three different runs and selected the learner and window length resulting in the highest
We compared six different learners and 19 window lengths between 1 and 70 days.
- Logistic Regression
- Naive Bayes Classifier
- Support Vector Classifier
- Decision Tree Classifier
- Random Forest Classifier
- Gradient Boosting Classifier
We got the best results with a Gradient Boosting Classifier and a window length of three days.
The results are surprisingly good and could be used to manage pools.
Paths are relative to the working directory.
Search for the best predictive model:
from model import search_cls
best, results = search_cls()
Fit, predict and plot:
from model import fit_predict
fit_predict()