deepsp94 / overlay-risk

Risk metrics for various data streams

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

overlay-risk

Simple on-chain risk metrics to inform our choices for per-market funding constants.

Assumptions

We sample data from on-chain oracles and assume the underlying feed exhibits Geometric Brownian motion of the form

P_j = P_0 * e**(mu * j * T + sig * W(j*T))

where W(j*T) is a Wiener process, j is an int for the number of update intervals that occur after the initial feed value of P_0, and T is the update interval of the respective feed (e.g. sliding window oracles currently maintained by Keep3r Network have T = periodSize = 30 min).

Why?

We need some way to assess the risk to the system. A good approach is to model the underlying feed value as being driven by a stochastic process, which allows us to estimate expected values to be paid out by the protocol for an imbalance in positions on a market in addition to the "VaR" for passive OVL holders, who act as the counterparty to all unbalanced trades.

Calculation of our per-market risk metrics requires estimating distributional parameters for the underlying stochastic model. This repo aims to provide easy to access views on-chain for those parameters (i.e. maximum likelihood estimates for mu and sig above).

Requirements

To run the project you need:

  • Python >=3.7.2 local development environment
  • Brownie local environment setup
  • Set env variables for Etherscan API and Infura: ETHERSCAN_TOKEN and WEB3_INFURA_PROJECT_ID
  • Local Ganache environment installed
  • InfluxDB set up with local environment variables: INFLUXDB_TOKEN, INFLUXDB_ORG, INFLUXDB_URL

Installation

Using Poetry for dependencies. Install with pipx

pipx install poetry

Clone the repo, then

poetry install

within the local dir.

Scripts

To run, for example, the script to ingest stat parameters for historical risk analysis, do

poetry shell
brownie run influx_kv1o --network mainnet

About

Risk metrics for various data streams

License:MIT License


Languages

Language:Solidity 57.6%Language:Python 42.4%