Hylian is a generic price oracle on ICON working with a list of price feeds such as Daedric. In the current version, it simply returns a median value of the whitelisted price feeds.
- T-Bears should be installed
- T-Bears needs to be launched using the configuration file provided in this repository :
tbears start -c ./config/localhost/tbears_server_config.json
- You also need
jq
. Install it withsudo apt-get install jq
-
Run the
install.sh
script located in the root folder of the repository; -
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
- A first one on the Yeouido network in
-
Make sure to send some funds to these wallets before deploying a SCORE (20 ICX should be good enough).
-
A wallet for localhost development is already pre-generated.
-
If you correctly loaded T-bears using the configuration as described in the prerequisites,
tbears balance hxba2e54b54b695085f31ff1a9b33868b5aea44e33
should return some balance.
- 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> : The name of the medianizer ticker
-m <minimum> : The minimum amount of price feeds required for the oracle to run
- Fill the
-n
option corresponding to the network you want to deploy to:localhost
,yeouido
,euljiro
ormainnet
. - Fill the
-t
option with the name of the ticker, such asICXUSD
. Note that ticker name needs to be the same than the deployed Medianizer SCORE. - Fille the
-m
option with the minimum number of price feeds available for the price oracle to work, otherwise it will raise an error. - Example :
$ ./scripts/score/deploy_score.sh -n localhost -t ICXUSD -m 5
-
If you modified the Hylian 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
ormainnet
. -
Example :
$ ./scripts/score/update_score.sh -n localhost
-
Your Hyalin SCORE needs price feeds in order to work. For doing so, you need to whitelist some price feed SCOREs.
-
In the root folder of the project, run the following command:
$ ./scripts/score/add_feed.sh
- It should display the following usage:
> Usage:
`-> ./scripts/score/add_feed.sh [options]
> Options:
-n <network> : Network to use (localhost, yeouido, euljiro or mainnet)
-a <score address> : SCORE address of the new price feed
- Fill the
-n
option corresponding to the network where your SCORE is deployed to:localhost
,yeouido
,euljiro
ormainnet
. - Fill the
-a
option with the address of the price feed SCORE you want to whitelist. - Example :
$ ./scripts/score/add_feed.sh -n localhost -a cx17fea4a9a01970cc730db9100dee9d1727af11a5
- Once you have enough price feeds subscribed, you may call the oracle with the
value
method:
$ ./scripts/score/value.sh
- It should display the following usage:
> Usage:
`-> ./scripts/score/value.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
ormainnet
. -
Example :
$ ./scripts/score/value.sh -n localhost
If not enough feeds fulfill the conditions declared in the Hylian SCORE, it will return the following error:
{
"jsonrpc": "2.0",
"error": {
"code": -32032,
"message": "NotEnoughFeedsAvailable(0)"
},
"id": 1
}
Otherwise, it will return the following result containing the price value:
> Command:
$ tbears call <(python ./scripts/score/dynamic_call/value.py localhost)
-c ./config/localhost/tbears_cli_config.json
> Result:
$ response : {
"jsonrpc": "2.0",
"result": "0x8ac7230489e80000",
"id": 1
}