[Archive] Calculations for Euler Wallet VaR

For our wallet value at risk page, we wanted to come up with a simple metric that conveys a decentralized lending position's risk of liquidation. Anthias uses Aave's liquidation health formula for our Aave dashboards in order to show the "health" of a position. However, through our eGP6 grant from the Euler community, we created a bespoke health metric for Euler. The Aave liquidation health metric is great, but it does not always accurately display a position's risk of liquidation. When a position's collateral and liability assets are highly correlated, a position with a liquidation health factor close to 1 may still have a low probability of liquidation. Also, two positions with the same liquidation health factor will differ in actual risk of liquidation depending on the variance and covariance of the value of their collateral and liability.

Therefore, we wanted to create a metric that displays a position's risk of liquidation, taking into account the variance of each of the position's underlying assets' price action, as well as the covariance between each of those assets' price actions. The following walkthrough will show how Anthias derives a probability that a position gets liquidated.

We calculate the daily returns on each token and the average return. Note that the returns for DWBTC are multiplied by -1 as liabilities are considered short positions on the asset. For excess returns we take the returns and subtract them from the average return to get the following results.

Next, the covariance matrix will be an nxn matrix based on the number of tokens, 3 in this case.

Each value represents the covariance of the two tokens in the array corresponding to the cell. For cells that represent two of the same token, the value is the variance. The covariance between any token A and token B is calculated as:

where "days" represents the number of days that you have returns calculated for.

As a matrix operation, the covariance matrix is calculated as:

The portfolio's standard deviation of percent change is calculated as:

where "n" represents the number of tokens and the proportions are calculated as:

The portfolio's standard deviation of price movement over n days is then calculated as:

The liquidation buffer is then calculated as:

Then, the probability of liquidation over the next n days is the inverse normal of \zeta, where \zeta is a z-score given by:

Then the portfolio standard deviation for 1 day is the following:

Here "n" represents the number of tokens and the proportions are based on the tokens held in the portfolio.

For a multi-day standard deviation approximation, we multiply the 1-day standard deviation by the number of days like this:

Finally, based on the standard deviation of the portfolio, and the aggregated collateral and debt positions weighted by the supply and borrow factors of each token, we can derive the value of the wallet's liquidation buffer and use an inverse normal function to get the probability that the portfolio's position drops by that buffer value and reaches liquidation.

Last updated