NibiruChain/pricefeeder for the Oracle Module
The pricefeeder
is a tool developed for Nibiru's Oracle Module consensus that runs a process to pull data from various external sources and then broadcasts transactions to vote on exchange rates.
Quick Start - Local Development
Configuration for the .env
Running a feeder
requires the setting environment variables in your .env
in like the following:
CHAIN_ID="nibiru-localnet-0"
GRPC_ENDPOINT="localhost:9090"
WEBSOCKET_ENDPOINT="ws://localhost:26657/websocket"
FEEDER_MNEMONIC="guard cream sadness conduct invite crumble clock pudding hole grit liar hotel maid produce squeeze return argue turtle know drive eight casino maze host"
EXCHANGE_SYMBOLS_MAP='{"bitfinex": {"ubtc:unusd": "tBTCUSD", "ueth:unusd": "tETHUSD", "uusd:unusd": "tUSTUSD"}}'
This would allow you to run pricefeeder
using a local instance of the network. To set up a local network, you can run:
git clone git@github.com:NibiruChain/nibiru.git
cd nibiru
git checkout v0.19.2
make localnet
Run
With your environment set to a live network, you can now run the price feeder:
make run
-
Build a docker image for use with docker compose.
make build-docker
-
Run the 'price_feeder' service defined in the docker-compose.yaml
.
make docker-compose up -d price_feeder
Hacking
Connecters for data sources like Binance and Bitfinex are defined in the feeder/priceprovider/sources
directory. Each of these sources must implement a FetchPricesFunc
function for querying external data.
Build
Builds the binary for the package:
make build
Delegating "feeder" consent
Votes for exhange rates in the Oracle Module are posted by validator nodes, however a validator can give consent a feeder
account to post prices on its behalf. This way, the validator won't have to use their validator's mnemonic to send transactions.
In order to be able to delegate consent to post prices, you need to set the
VALIDATOR_ADDRESS
env variable to the "valoper" address the feeder
will represent.
VALIDATOR_ADDRESS="nibivaloper1..."
To delegate consent from a validator node to some feeder
address, you must execute a MsgDelegateFeedConsent
message:
type MsgDelegateFeedConsent struct {
Operator string
Delegate string
}
This is possible using the set-feeder
subcommand of the nibid
CLI:
nibid tx oracle set-feeder [feeder-address] --from validator
Enabling TLS
To enable TLS, you need to set the following env vars:
TLS_ENABLED="true"
Configuring specific exchanges
CoinGecko
Coingecko source allows to use paid api key to get more requests per minute. In order to configure it,
you need to set env var:
DATASOURCE_CONFIG_MAP='{"coingecko": {"api_key": "0123456789"}}'