Coder Social home page Coder Social logo

volatility-oracle's Introduction

Yield Volatility Oracle

This repository contains the external adapter application code for Yield Volatility Oracle. Reference to this project here

This project started as a submission to the 2021 Hack Money Hackathon

This external adapter can provide a volatility rating for short-term (10 days), mid-term (50 days), and long-term (100 days) of various yield farming pools. Currently the external adapter supports Uniswap V2 but we plan to expand upon this in the future.

Our metrics for the uniswap v2 integration work by calculating the daily APY for the supplied days in the day range and then calculating the standard deviation of the daily apy vector. See a comprehensive historical analysis here for context around yield volatility.

Job Usage

The Uniswap v2 job takes two parameters the pool (address of the pool in question) and the day range (10, 50, 100).

    Chainlink.Request memory req = buildChainlinkRequest(stringToBytes32(_jobId), this, this.fulfillPoolApyStd.selector);
    req.add("pool", _pool);
    req.add("range", _range);
    sendChainlinkRequestTo(_oracle, req, ORACLE_PAYMENT);

For testing this job against a deployment you can use our example consumer contract

Addresses

Kovan: 0x20cD09897ddc1682f14eb6E55C46223f615426d7 

Deployment

In order to deploy this external adapter on a Chainlink node a bridge must be created within the node pointing to the URL of the running external adapter.

Once the bridge is created, a job can be created with this job spec, be sure to update the address to your own oracle contract address

Chainlink Node deployment

For our Chainlink node deployment we used our AWS CDK application for easily deployments into AWS.

Development and running

The development environment is managed by docker-compose. The application code is mounted in a volume using docker compose meaning while running the application you're able edit the code while the application is running thanks to the use of uvicorn

echo 'API_KEY=${DESIRED API KEY}' > .env.local
docker-compose build  
~~
docker-compose up 

The external-adapter/api can then be accessed at http://localhost:8000/docs Currently there is an empty .env.local file, in the future this file may contain secrets for The Graph sub graphs

Python dependencies

Python dependencies are managed by poetry. In order to add a new python dependency or package run the following:

poetry add $PACKAGE

This will require that you have poetry installed locally. In order to get your newly added dependency into the container you will need to run a docker-compose build again, luckily this should take less than 2 minutes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.