Giter Site home page Giter Site logo

apmyp-eth / bnb-zero2hero-hackathon Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 624 KB

BNB Zero2Hero Hackathon Project

Home Page: https://zero2hero-hackathon-oracles-front.vercel.app/

Solidity 22.65% JavaScript 64.35% HTML 13.00%
bnb-chain hackathon solidity zero2hero

bnb-zero2hero-hackathon's Introduction

Decentralized Financial Data Supply Oracle System

Inspired by Chainlink. Made from scratch.

Demo frontend

https://zero2hero-hackathon-oracles-front.vercel.app/

Overview

The scheme could be represented as ASCII-graphics:

                       Client
                         |
                    PriceOracle
                         |
     +-------------------+----------------------------+
     |                   |                            |
   Symbol              Symbol                       Symbol
     |                   |                            |
     |                   |                            |
Aggregator          Aggregator <== Heartbit      Aggregator 
     |                   |                            |
    ...          +-------+-------+                   ...
                /        |        \
         Transmitter Transmitter Transmitter

Description of components

  • Client uses, for example, getLastPrice of PriceOracle to get access to the latest price of some symbol
  • PriceOracle is a proxy for calling Symbols that stores the corresponding symbol code - Symbol address
  • Symbol - a contract that stores the price history of a specific symbol and allows you to access the latest price (main function)
  • Aggregator - a contract that processes and checks incoming prices from Transmitters
  • Heartbit is an external tool (script) that periodically calls the Aggregator to open and close the so-called rounds
  • Transmitter - script that listens for the round opening event in the Aggregator, extracts the price from the price provider and sends it to the Aggregator

Additional information

  • to check transmitters, an ECDSA signature is used, which they attach in a transaction with a price
  • the price deviation from the previous known one is checked, the delay of the response at the level of the timestamp from the transmitter and the timestamp of the response transaction
  • if the average price of the round (from all transmitters that sent the price to the Aggregator) does not differ from the average price of the previous round, then it is not saved in the Symbol
  • all smart contracts are Ownable and allow hot swapping
  • check out CONFIG.md for deployed contracts addresses

Installation and usage

  1. contracts folder contains the Hardhat project, there is a script to deploy all smart-contracts and even two tasks transmitterAdd and transmitterDelete to manipulate allowed transmitters list in the Aggregator contracts (look at the end of CONFIG.md for examples)
  2. front folder is a simple one-page project using HTML and JS to show chart of prices, consider host it everywhere
  3. heartbit folder contains NodeJS project, simply copy it, cd into the folder and start using command node index.js or using PM2 pm2 start -n heartbit index.js
  4. transmitter folder contains NodeJS project aimed to extract prices from price provider and send them every time when heartbit starts new round, simply copy it, cd into the folder and start using command node index.js or using PM2 pm2 start -n transmitter_symbol index.js, do not forgot update .env with correct values (check out .env.example)

Technologies

  • Solidity (+ OpenZeppelin)
  • Hardhat (+ @nomiclabs/hardhat-etherscan, hardhat-gas-reporter, solidity-coverage)
  • Slither to audit smart-contracts
  • PM2, NodeJS, HTML, JS

Thanks

Many thanks for a great opportunity to learn and improve skills to:

  • Center of Blockchain (Astana)
  • Encode Club
  • BNB Chain Community

bnb-zero2hero-hackathon's People

Contributors

apmyp-eth avatar

Watchers

 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.