Aggregates and caches price data feeds from external data providers.
Description of the emeris-price-oracle.toml
setting file.
Key Feature Settings
- interval: The delay time of the function for an external price provider api request.
- whitelistfiats : List of fiats you want to request (default currency is USD)
- coinmarketcapapikey : This is the api-key of the provider.
- fixerapikey : This is the api-key of the provider.
- Provider : The endpoint address of the price provider.
For Binance, apikey does not exist.
example(Local exec)
#kubectl port-forward service/cockroachdb-public 26257
DatabaseConnectionURL = "postgres://[email protected]:26257?sslmode=disable"
ListenAddr = "127.0.0.1:9898"
Debug = true
LogPath = "/home/ubuntu/log"
interval = "10s"
whitelistfiats = ["EUR","KRW","CHF"]
#Not currently used, but may be used in the future
coinmarketcapapikey =""
fixerapikey = ""
database/schema
Set the cockroach DB to the local cluster, connect to the local DB, and run schema as it is.
*The cns version brunch does not require a separate run.
# build
go build
# executable
./navigator-price-oracle
Given an exchange API, the price oracle will periodically check with it prices of the tokens we're interested in monitoring, and cache the result until the next period:
- At startup, oracle will grab data from the API and expose it on
GET /prices
- Once every 10 seconds, new data will be downloaded and cached
- Once every 5minutes, 1 hour and 24 hour historical data will be collected from the Coin-gecko
- Historical data will be exposed via
GET /chart:id
, this api takes one parameter named days and one optional parameter named vs_currency (default usd).
Oracle must return prices of all the tokens that it is configured to fetch.
An API to provide tokens configuration must be provided on POST /tokens
:
{
"tokens": [
"ATOMUSDT",
"KAVAUSDT"
]
}
The same must be done for FIAT currencies on POST /fiats
:
{
"fiats": [
"USDEUR",
"USDKRW"
]
}
If you have multiple copy of in-memory cockroach db, it can happen that when you run
testserver.NewTestServer()
it can stuck at waiting for download of SOME TMP DIR
Solution: if this happens manually delete ALL instances of test server from your machine.
When try to download some private module from emerishq
you can get:
fatal: could not read Username for 'https://github.com': terminal prompts disabled
Solution: Set the goprivate env variable.
go env -w GOPRIVATE="github.com/emerishq/{module}"
The list of non-{Cosmos, AiB, Tendermint} dependencies and their licenses are:
Module | License |
---|---|
alicebob/miniredis | MIT |
gin-contrib/zap | MIT |
gin-gonic/gin | MIT |
go-playground/validator | MIT |
go-playground/validator | MIT |
go.uber.org/zap | MIT |
jackc/pgx | MIT |
jmoiron/sqlx | MIT |
lib/pq | Open use |
sigs.k8s.io/controller-runtime | MIT |
sony/sonyflake | MIT |
superoo7/go-gecko | MIT |