Skip to content

Commit

Permalink
fix: pragma api query
Browse files Browse the repository at this point in the history
  • Loading branch information
EvolveArt committed Jan 25, 2024
1 parent ab7f6b1 commit 8a38b41
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/processing/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub async fn process_data_by_pair(pair: String) -> Result<(), MonitoringError> {
let config = get_config(None).await;
let network_env = &config.network_str();

let result = query_pragma_api(&pair, network_env).await?;
let result = query_pragma_api(&pair, network_env, "median", "1min").await?;

log::info!("Processing data for pair: {}", pair);

Expand Down Expand Up @@ -56,7 +56,7 @@ pub async fn process_sequencer_data() -> Result<(), MonitoringError> {
let config = get_config(None).await;
let network_env = config.network_str();

let result = query_pragma_api(&pair, network_env).await?;
let result = query_pragma_api(&pair, network_env, "twap", "15min").await?;

log::info!("Processing sequencer data");

Expand Down
8 changes: 6 additions & 2 deletions src/processing/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,19 @@ pub struct PragmaDataDTO {
pub async fn query_pragma_api(
pair: &str,
network_env: &str,
aggregation: &str,
interval: &str,
) -> Result<PragmaDataDTO, MonitoringError> {
let request_url = match network_env {
"Testnet" => format!(
"https://api.dev.pragma.build/node/v1/data/{pair}?aggregation=median&interval=1min&routing=true",
"https://api.dev.pragma.build/node/v1/data/{pair}?aggregation={aggregation}&interval={interval}&routing=true",
pair = pair,
),
"Mainnet" => format!(
"https://api.prod.pragma.build/node/v1/data/{pair}?aggregation=median&interval=1min&routing=true",
"https://api.prod.pragma.build/node/v1/data/{pair}?aggregation={aggregation}&interval={interval}&routing=true",
pair = pair,
aggregation = aggregation,
interval = interval,
),
_ => panic!("Invalid network env"),
};
Expand Down

0 comments on commit 8a38b41

Please sign in to comment.