GithubHelp home page GithubHelp logo

isabella232 / makerdao-scd-subgraph Goto Github PK

View Code? Open in Web Editor NEW

This project forked from protofire/makerdao-scd-subgraph

0.0 0.0 0.0 148 KB

MakerDAO Single-Collateral Dai subgraph

Home Page: https://thegraph.com/explorer/subgraph/protofire/makerdao

License: GNU Lesser General Public License v3.0

JavaScript 0.38% TypeScript 99.62%

makerdao-scd-subgraph's Introduction

MakerDAO subgraph

The goal of this subgraph is to provide information about CDPs. This information can be queried via GraphQL in a simplest and more user-friendly way than consulting the contracts directly.

The MakerDAO subgraph currently only tracks CDPs for Single Collateral Dai contracts. It's important to note that the stability fee is not yet being calculated correctly for some operations that involve returning debt. That is why collateral might not be consistent after a BITE action.

This subgraph is already deployed to The Graph hosted service.

What is MakerDAO

The Dai Stablecoin is a collateral-backed cryptocurrency whose value is stable relative to the US Dollar. We believe that stable digital assets like Dai are essential to realizing the full potential of blockchain technology. Unlike other Stablecoins, Dai is completely decentralized3. Users can obtain Dai by buying it from brokers or exchanges, and Dai holders can utilize a special mechanic known as the Dai Savings Rate to earn a steady, low-risk return on their holdings. MakerDao is a smart contract platform on Ethereum that backs and stabilizes the value of Dai through a dynamic system of Collateralized Debt Positions (CDPs), autonomous feedback mechanisms, and appropriately incentivized external actors. MakerDao enables anyone to leverage their Ethereum assets to generate Dai on the Maker Platform. Once generated, Dai can be used in the same manner as any other cryptocurrency: it can be freely sent to others, used as payments for goods and services, or held as long term savings. Importantly, the generation of Dai also creates the components needed for a robust decentralized lending platform.

More information about MakerDAO.

What is The Graph

The Graph is a decentralized protocol for indexing and querying data from blockchains, starting with Ethereum. It makes it possible to query data that is difficult to query directly.

The Graph indexes blockchain data. Theses indexes ("subgraphs") can then be queried with a standard GraphQL API.

More information about The Graph.

Technical Overview

This subgraph indexes the following contracts:

  • SaiTub: simplified CDP engine
  • Pip: collateral price oracle (ETH)
  • Pep: governance token price oracle (MKR)

There are other contracts related but they are not in the scope of this subgraph.

The main entities defined for this subgraph are:

  • Cdp: contains information about all the Cdp created
  • CdpAction: represents any action done in a Cdp
  • EthPrice: tracks ETH price in USD
  • MkrPrice: tracks MKR token price in USD

Each CDP action belong to one of these types:

  • OPEN: emitted when a CDP is created
  • GIVE: emitted when the ownership of the CDP is transferred
  • LOCK: emitted when collateral is added to a CDP
  • FREE: emitted when collateral is removed from a CDP
  • DRAW: emitted when DAI is created from a CDP (increase debt)
  • WIPE: emitted when DAI is returned to a CDP (cancel debt)
  • BITE: emitted when a CDP is liquidated (wipe all debt but CDP remains open)
  • SHUT: emitted when a CDP is closed (wipe all debt, free all collateral and delete the CDP). After that CDP will never be used again.

Working locally

This project can be git clone and then you will be able to run the subgraph locally by following this instructions. Note that you won't need to create the subgraph by running graph init, instead you only need to create the subgraph with yarn create-local and then deploying it with yarn deploy-local.

# Each subgraph modification will require to run the next commands

$ yarn codegen       # only needed if the schema or ABI have been modified

$ yarn create-local  # only the first time

$ yarn deploy-local  # after any change in the subgraph

Running subgraph on Kovan network

You can opt by running this subgraph in the MainNet or in the Kovan Testnet . If you want to work with Kovan you will need to comment/uncomment the network and address attributes in the subgraph.yaml file:

dataSources:
  - kind: ethereum/contract
    name: sai
    network: kovan
    source:
      address: '0xa71937147b55Deb8a530C7229C442Fd3F31b7db2'

Important note: you will also have to use the appropriate adresses in the contracts configuration but be aware of Medianizer's prices are outdated on Kovan network and they might not make sense.

makerdao-scd-subgraph's People

Contributors

nicosampler avatar sistemico avatar

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.