-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for token-price conversion
- Temp update Cargo.toml and Cargo.lock - Update file info and dump cli - Add docker-compose.yml for local testing
- Loading branch information
Showing
16 changed files
with
809 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
[package] | ||
name = "price" | ||
version = "0.1.0" | ||
description = "Price Oracle for the Helium Network" | ||
edition.workspace = true | ||
authors.workspace = true | ||
license.workspace = true | ||
|
||
[dependencies] | ||
anyhow = {workspace = true} | ||
config = {workspace = true} | ||
clap = {workspace = true} | ||
thiserror = {workspace = true} | ||
serde = {workspace = true} | ||
serde_json = {workspace = true} | ||
tonic = {workspace = true} | ||
futures = {workspace = true} | ||
futures-util = {workspace = true} | ||
prost = {workspace = true} | ||
tracing = { workspace = true } | ||
tracing-subscriber = { workspace = true } | ||
metrics = {workspace = true } | ||
metrics-exporter-prometheus = { workspace = true } | ||
tokio = { workspace = true } | ||
chrono = { workspace = true } | ||
helium-proto = { workspace = true } | ||
file-store = { path = "../file_store" } | ||
poc-metrics = { path = "../metrics" } | ||
triggered = {workspace = true} | ||
pyth-sdk-solana = "0.7.1" | ||
solana-client = ">= 1.9, < 1.15" | ||
solana-program = ">= 1.9, < 1.15" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Price Oracle Server | ||
|
||
The price oracle server serves up price data for helium token(s) acquired from | ||
the [pyth.network](https://pyth.network). | ||
|
||
The supported tokens are: | ||
- HNT | ||
- HST | ||
- MOBILE | ||
- IOT | ||
|
||
The price oracle server: | ||
|
||
- Requests price for HNT token at a regular interval (60s) from pyth. | ||
- Stores and uploads [price_report](TODO) to a bucket. | ||
- TODO: Acquire price for MOBILE and IOT token(s) when available on pyth. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
version: "2.4" | ||
services: | ||
minio: | ||
image: minio/minio:latest | ||
environment: | ||
MINIO_ROOT_USER: oracleadmin | ||
MINIO_ROOT_PASSWORD: oracleadmin | ||
ports: | ||
- "9000:9000" | ||
- "9090:9090" | ||
volumes: | ||
- bucket-data:/data | ||
command: server /data --console-address ":9090" | ||
healthcheck: | ||
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"] | ||
interval: 30s | ||
timeout: 20s | ||
retries: 3 | ||
minio-setup: | ||
image: minio/mc:latest | ||
depends_on: | ||
- minio | ||
environment: | ||
MINIO_ROOT_USER: oracleadmin | ||
MINIO_ROOT_PASSWORD: oracleadmin | ||
MINIO_BUCKETS: > | ||
price | ||
ORACLE_ID: oraclesecretid | ||
ORACLE_KEY: oraclesecretkey | ||
entrypoint: | ||
- /bin/bash | ||
- -c | ||
- | | ||
cat > /bucket-policy.json <<EOF | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Sid": "ListObjectsInBucket", | ||
"Effect": "Allow", | ||
"Action": ["s3:ListBucket"], | ||
"Resource": ["arn:aws:s3:::*"] | ||
}, | ||
{ | ||
"Sid": "AllObjectActions", | ||
"Effect": "Allow", | ||
"Action": "s3:*Object", | ||
"Resource": ["arn:aws:s3:::*"] | ||
} | ||
] | ||
} | ||
EOF | ||
sleep 2 | ||
/usr/bin/mc alias set localminio http://minio:9000 $${MINIO_ROOT_USER} $${MINIO_ROOT_PASSWORD} | ||
for bucket in $${MINIO_BUCKETS[@]} | ||
do | ||
if ! /usr/bin/mc ls localminio/$${bucket} > /dev/null 2>&1 ; then | ||
echo "creating bucket $${bucket}" | ||
/usr/bin/mc mb localminio/$${bucket} | ||
fi | ||
done | ||
/usr/bin/mc admin policy add localminio fullaccess /bucket-policy.json | ||
/usr/bin/mc admin user add localminio $${ORACLE_ID} $${ORACLE_KEY} | ||
/usr/bin/mc admin policy set localminio fullaccess user=$${ORACLE_ID} | ||
volumes: | ||
bucket-data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# log settings for the application (RUST_LOG format). Default below | ||
# | ||
# log = "price=debug" | ||
|
||
# RPC Endpoint for price oracles. Required. | ||
rpc_endpoint = "https://api.devnet.solana.com" | ||
|
||
# Price sink roll time (mins). Default = 3 mins. Optional. | ||
sink_roll_mins = 3 | ||
|
||
# Price tick interval (secs). Default = 60s. Optional. | ||
tick_interval = 60 | ||
|
||
# Price age (get price as long as it was updated within `age` seconds of current time) (in secs). Optional. | ||
age = 60 | ||
|
||
[cluster] | ||
name = "devnet" | ||
hnt_price_key = "6Eg8YdfFJQF2HHonzPUBSCCmyUEhrStg9VBLK957sBe6" | ||
# mobile_price_key = | ||
# hst_price_key = | ||
# iot_price_key = | ||
|
||
# Listen addresses for public api. Default below | ||
# | ||
# hnt_listen = "0.0.0.0:8080" | ||
# mobile_listen = "0.0.0.0:8081" | ||
# iot_listen = "0.0.0.0:8082" | ||
# hst_listen = "0.0.0.0:8082" | ||
|
||
# Cache folder to use. Default blow | ||
# | ||
# cache = "/var/data/price" | ||
|
||
[output] | ||
# Output bucket for price | ||
|
||
# Name of bucket to write details to. Required | ||
# | ||
bucket = "price" | ||
|
||
# Region for bucket. Defaults to below | ||
# | ||
# region = "us-west-2" | ||
|
||
# Optional URL for AWS api endpoint. Inferred from aws config settings or aws | ||
# IAM context by default | ||
# | ||
# endpoint = "https://aws-s3-bucket.aws.com" | ||
|
||
|
||
[metrics] | ||
|
||
# Endpoint for metrics. Default below | ||
# | ||
# endpoint = "127.0.0.1:19000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#[derive(thiserror::Error, Debug)] | ||
pub enum PriceError { | ||
#[error("unsupported token type: {0}")] | ||
UnsupportedTokenType(i32), | ||
#[error("unable to fetch price")] | ||
UnableToFetch, | ||
#[error("unknown price account key, token_type: {0}")] | ||
UnknownKey(String), | ||
} |
Oops, something went wrong.