/Daedric

Daedric is a price feed designed to be a component required for a price oracle running on ICON to work.

Primary LanguageShellApache License 2.0Apache-2.0

ICONation logo ICONation logo

Daedric : Price Feed SCORE

License

Introduction

Daedric is a price feed designed to be a component required for a price oracle running on ICON to work. The Daedric SCORE operator can update and share a price associated with a ticker symbol at any time. Once deployed, the Daedric SCORE operator may subscribe its SCORE to a price oracle (such as Hylian) in order to take part of the price consensus needed for the oracle to work in a decentralized manner.

Table of Contents

Quick Start

Here is a checklist you will need to follow in order to deploy your first Daedric SCORE to the Yeouido testnet:

  • Install prerequisites:

    • python3 -m venv ./venv && source ./venv/bin/activate
    • pip install tbears
    • sudo apt install jq
  • Clone the Daedric repository:

    • git clone https://github.com/iconation/Daedric.git && cd Daedric
  • Start tbears using the start_tbears.sh script located at the root folder of the Daedric repository

    • ./start_tbears.sh
  • Install the operator wallets:

    • ./install.sh
    • It will generate 3 operator wallets :
      • A first one on the Yeouido network in ./config/yeouido/keystores/operator.icx
      • A second one on the Euljiro network in ./config/euljiro/keystores/operator.icx
      • A last one on the Mainnet network in ./config/mainnet/keystores/operator.icx
    • Input a password for each network
  • Send few ICX (20 ICX should be enough) to the Yeouido wallet (the newly generated address is displayed after executing the install.sh script)

    • If you don't have some testnet ICX, use the faucet or contact @Spl3en
  • Deploy your SCORE to the testnet (optional) :

    • ./scripts/score/deploy_score.sh -n yeouido -t ICXUSD
  • Test your Daedric SCORE by manually calling the following script (optional) :

    • ./scripts/bots/equalizer/icxusd/post.sh -n yeouido
  • Check the value of your feed using the ICON Yeouido tracker (optional) :

  • Once you've successfully deployed Daedric on TestNet (optional), deploy your SCORE to the MainNet (required) :

    • ./scripts/score/deploy_score.sh -n mainnet -t ICXUSD
    • Please note that this command sometimes displays an error even when the SCORE has been successfully deployed, for an unknown reason. If that happens to you, please check for the contract address in the tracker : tracker.icon.foundation/address/<operator_hx_address> . Also, once you retrieved the SCORE address, write it into ./config/mainnet/score_address.txt.
  • The ICON team may take 3-4 working days for approving your SCORE. Please remain patient, and come back here once your SCORE has been approved!

  • Test your Daedric SCORE by manually calling the following script:

    • ./scripts/bots/equalizer/icxusd/post.sh -n mainnet
  • Check the value of your feed using the ICON MainNet tracker :

  • Install your price bot (Builtin or Marvin):

  • If everything is working as intended, please share your SCORE address with @Spl3en, so your SCORE can be added to Hylian (price oracle).

Deploy Daedric SCORE to localhost, testnet or mainnet

  • In the root folder of the project, run the following command:
./scripts/score/deploy_score.sh
  • It should display the following usage:
> Usage:
 `-> ./scripts/score/deploy_score.sh [options]

> Options:
 -n <network> : Network to use (localhost, yeouido, euljiro or mainnet)
 -t <ticker name> : Standardized name for the ticker (such as ICXUSD)
  • Fill the -n option corresponding to the network you want to deploy to: localhost, yeouido, euljiro or mainnet.
  • Fill the -t option with the name of the ticker, such as ICXUSD. Note that ticker name needs to be the same than the deployed Medianizer SCORE.
  • Example :
$ ./scripts/score/deploy_score.sh -n localhost -t ICXUSD

Update an already deployed Daedric to localhost, testnet or mainnet

  • If you modified the Daedric SCORE source code, you may need to update it.

  • In the root folder of the project, run the following command:

$ ./scripts/score/update_score.sh
  • It should display the following usage:
> Usage:
 `-> ./scripts/score/update_score.sh [options]

> Options:
 -n <network> : Network to use (localhost, yeouido, euljiro or mainnet)
  • Fill the -n option corresponding to the network where your SCORE is deployed to: localhost, yeouido, euljiro or mainnet.

  • Example :

$ ./scripts/score/update_score.sh -n localhost

Post a new price to the feed

  • In the root folder of the project, run the following command:
$ ./scripts/score/post.sh
  • It should display the following usage:
> Usage:
 `-> ./scripts/score/post.sh [options]

> Options:
 -n <network> : Network to use (localhost, yeouido, euljiro or mainnet)
 -p <price value> : Price to be updated
  • Fill the -n option corresponding to the network where your SCORE is deployed to: localhost, yeouido, euljiro or mainnet.
  • Fill the -p option with the price (in loops). Please make sure of the format of the price with the Medianizer SCORE operator. For instance for the ICXUSD, the price value needs to be the amount of loops for 1 USD.
  • Example : Given a ICX price of $0.10, 10000000000000000000 loops (10 ICX) are required to have 1 USD. So the request to the price feed should be the following :
$ ./scripts/score/post.sh -n localhost -p 10000000000000000000

Read the values from a Daedric SCORE

  • In the root folder of the project, run the following command:
$ ./scripts/score/peek.sh
  • It should display the following usage:
> Usage:
 `-> ./scripts/score/peek.sh [options]

> Options:
 -n <network> : Network to use (localhost, yeouido, euljiro or mainnet)
  • Fill the -n option corresponding to the network where your SCORE is deployed to: localhost, yeouido, euljiro or mainnet.

  • Example :

$ ./scripts/score/peek.sh -n localhost

This command shall return the following result:

> Command:
$ tbears call <(python ./scripts/score/dynamic_call/peek.py localhost) -c ./config/localhost/tbears_cli_config.json

> Result:
$ response : {
    "jsonrpc": "2.0",
    "result": "{\"value\": 10000000000000000000, \"timestamp\": 1565044831817071, \"ticker_name\": \"ICXUSD\"}",
    "id": 1
}

Update the price feed using a built-in price bot

Daedric is released with multiple built-in ways to retrieve prices. The Daedric operator is encouraged to build its own price bot in order to avoid a situation where all price feed operators fail to retrieve a price from the same source.

Rhizome made Marvin, a .NET Daedric bot. It is recommanded to use it if you aren't familiar with crontab.

You can also use the one provided in this repository :

The price bots are located in ./scripts/bots. They all work the same way, for example the Binance one:

./scripts/bots/binance/icxusd/post.sh
> Usage:
 `-> ./scripts/bots/binance/icxusd/post.sh [options]

> Options:
 -n <network> : Network to use (localhost, yeouido, euljiro or mainnet)
 [-s <keystore password>] : The keystore password (optional)

You may call this script regularly (using a cron job for exemple) with the -n and the -s switches filled accordingly. Make sure the cron job is launched from the root directory of Daedric, otherwise the bot won't work.

Example using a cron job that launches the script located in /home/daedric/Daedric every hour:

SHELL=/bin/bash
0 * * * * cd /home/daedric/Daedric && . /home/daedric/venv/bin/activate && ./scripts/bots/equalizer/icxusd/post.sh -n mainnet -s my_secret_keystore_password

Alternatively, you can fill the keystore password in the configuration file (config/mainnet/tbears_cli_config.json).