Giter Club home page Giter Club logo

solana-flux-aggregator's Introduction

solana-flux-aggregator

Solnana Flux Aggregator

Price Feeds: https://sol.link

Install

yarn install

Admin Wallet Setup

Setup a wallet for the flux aggregator admin:

yarn solink generate-wallet

address: 7YMUUCzZir7AAuoy4CtZih9JFBqYwtQiCxjA5dtqwRxU
mnemonic: wine vault fancy enhance trade dolphin hard traffic social butter client pave
yarn solink airdrop 7YMUUCzZir7AAuoy4CtZih9JFBqYwtQiCxjA5dtqwRxU

Create .env configuration file for the deploy script.

NETWORK=dev
DEPLOY_FILE=deploy.json
ADMIN_MNEMONIC="wine vault fancy enhance trade dolphin hard traffic social butter client pave"

Aggregator Setup

Build and deploy the flux aggregator:

yarn build:program
yarn solink deploy-program

deployed aggregator program. program id: HFHbe2uckzz9Xh633mbJPYcukzpyJRVcwL87fUrVddiq

Create the btc:usd feed (that accepts max and min u64 as valid submission values):

yarn solink add-aggregator \
  --feedName btc:usd \
  --submitInterval 6 \
  --minSubmissionValue 0 \
  --maxSubmissionValue 18446744073709551615

feed initialized, pubkey: 2jReuMRoYi3pKTF8YLnZEvT2bXcw56SdBxvssrVzu41v

Adding an oracle

Next, we create a separate wallet to control oracles:

yarn solink generate-wallet

address: FosLwbttPgkEDv36VJLU3wwXcBSSoUGkh7dyZPsXNtT4
mnemonic: amount smoke bar coil current trial toward minimum model pass moral liberty
yarn solink airdrop FosLwbttPgkEDv36VJLU3wwXcBSSoUGkh7dyZPsXNtT4

Add this wallet to .env:

ORACLE_MNEMONIC="amount smoke bar coil current trial toward minimum model pass moral liberty"

Next we create a new oracle to the feed we've created previously, and set its owner to be the new oracle wallet that we've generated:

yarn solink add-oracle \
  --index 0 \
  --feedAddress 2jReuMRoYi3pKTF8YLnZEvT2bXcw56SdBxvssrVzu41v \
  --oracleName solink-test \
  --oracleOwner FosLwbttPgkEDv36VJLU3wwXcBSSoUGkh7dyZPsXNtT4

added oracle. pubkey: 4jWLbd2Vm98RrqunVvaSXZuP1AFbgQSM2hAHMvZSdNCu

Start submitting data from a price feed (e.g. coinbase BTC-USDT):

yarn solink feed \
  --feedAddress 2jReuMRoYi3pKTF8YLnZEvT2bXcw56SdBxvssrVzu41v \
  --oracleAddress 4jWLbd2Vm98RrqunVvaSXZuP1AFbgQSM2hAHMvZSdNCu

Read price

Poll the latest aggregated (median) value from a feed:

yarn solink feed-poll \
  --feedAddress 2jReuMRoYi3pKTF8YLnZEvT2bXcw56SdBxvssrVzu41v

Remove oracle

yarn solink remove-oracle \
  --index 0 \
  --feedAddress 2jReuMRoYi3pKTF8YLnZEvT2bXcw56SdBxvssrVzu41v

Test Token

For testing purposes, create a test token held by the aggregator program to reward:

yarn solink testToken --amount 10000000000

Program Integration

Refer to the [integration-example][./integration-example].

The gist is to pass in the feed address to the program, and call get_median from the flux_aggregator crate.

use flux_aggregator;

let feed_info = next_account_info(accounts_iter)?;
let value = flux_aggregator::get_median(feed_info)?;

solana-flux-aggregator's People

Contributors

czl1378 avatar defactojob 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.