Skip to content

Commit

Permalink
Bump version.
Browse files Browse the repository at this point in the history
  • Loading branch information
kukabi committed Jun 24, 2024
1 parent 41c0449 commit eb11d48
Show file tree
Hide file tree
Showing 32 changed files with 166 additions and 146 deletions.
208 changes: 101 additions & 107 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _docker/compose/.env.sample
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=0.19.1
VERSION=0.20.1
ENV=production
LOG_LEVEL=debug

Expand Down
2 changes: 1 addition & 1 deletion subvt-app-service/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subvt-app-service"
version = "0.20.0"
version = "0.20.1"
edition = "2021"
rust-version = "1.67.0"

Expand Down
2 changes: 1 addition & 1 deletion subvt-block-processor/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subvt-block-processor"
version = "0.20.0"
version = "0.20.1"
edition = "2021"
rust-version = "1.67.0"

Expand Down
2 changes: 1 addition & 1 deletion subvt-config/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subvt-config"
version = "0.20.0"
version = "0.20.1"
edition = "2021"
rust-version = "1.67.0"

Expand Down
2 changes: 1 addition & 1 deletion subvt-governance/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subvt-governance"
version = "0.20.0"
version = "0.20.1"
edition = "2021"
rust-version = "1.67.0"

Expand Down
2 changes: 1 addition & 1 deletion subvt-kline-updater/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subvt-kline-updater"
version = "0.20.0"
version = "0.20.1"
edition = "2021"
rust-version = "1.67.0"

Expand Down
2 changes: 1 addition & 1 deletion subvt-logging/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subvt-logging"
version = "0.20.0"
version = "0.20.1"
edition = "2021"
rust-version = "1.67.0"

Expand Down
2 changes: 1 addition & 1 deletion subvt-metrics/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subvt-metrics"
version = "0.20.0"
version = "0.20.1"
edition = "2021"
rust-version = "1.67.0"

Expand Down
2 changes: 1 addition & 1 deletion subvt-network-status-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subvt-network-status-server"
version = "0.20.0"
version = "0.20.1"
edition = "2021"
rust-version = "1.67.0"

Expand Down
2 changes: 1 addition & 1 deletion subvt-network-status-updater/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subvt-network-status-updater"
version = "0.20.0"
version = "0.20.1"
edition = "2021"
rust-version = "1.67.0"

Expand Down
2 changes: 1 addition & 1 deletion subvt-nft/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subvt-nft"
version = "0.20.0"
version = "0.20.1"
edition = "2021"
rust-version = "1.67.0"

Expand Down
2 changes: 1 addition & 1 deletion subvt-notification-generator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subvt-notification-generator"
version = "0.20.0"
version = "0.20.1"
edition = "2021"
rust-version = "1.67.0"

Expand Down
2 changes: 1 addition & 1 deletion subvt-notification-processor/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subvt-notification-processor"
version = "0.20.0"
version = "0.20.1"
edition = "2021"
rust-version = "1.67.0"

Expand Down
2 changes: 1 addition & 1 deletion subvt-onekv-updater/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subvt-onekv-updater"
version = "0.20.0"
version = "0.20.1"
edition = "2021"
rust-version = "1.67.0"

Expand Down
2 changes: 1 addition & 1 deletion subvt-persistence/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subvt-persistence"
version = "0.20.0"
version = "0.20.1"
edition = "2021"
rust-version = "1.67.0"

Expand Down
11 changes: 9 additions & 2 deletions subvt-persistence/src/postgres/network/kline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,21 @@ impl PostgreSQLNetworkStorage {
Ok(record_count.0 as u64)
}

pub async fn get_kline(&self, timestamp: u64) -> anyhow::Result<KLine> {
pub async fn get_kline(
&self,
source_ticker: &str,
target_ticker: &str,
timestamp: u64,
) -> anyhow::Result<KLine> {
let db_kline: DBKline = sqlx::query_as(
r#"
SELECT id, open_time, source_ticker, target_ticker, "open", high, low, "close", volume, close_time, quote_volume, "count", taker_buy_volume, taker_buy_quote_volume
FROM sub_kline_historical
WHERE open_time = $1
WHERE source_ticker = $1 AND target_ticker= $2 AND open_time = $3
"#,
)
.bind(source_ticker)
.bind(target_ticker)
.bind(timestamp as i64)
.fetch_one(&self.connection_pool)
.await?;
Expand Down
2 changes: 1 addition & 1 deletion subvt-plotter/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subvt-plotter"
version = "0.20.0"
version = "0.20.1"
edition = "2021"
rust-version = "1.67.0"

Expand Down
2 changes: 1 addition & 1 deletion subvt-proc-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ proc-macro = true

[package]
name = "subvt-proc-macro"
version = "0.20.0"
version = "0.20.1"
edition = "2021"
rust-version = "1.67.0"

Expand Down
2 changes: 1 addition & 1 deletion subvt-referendum-updater/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subvt-referendum-updater"
version = "0.20.0"
version = "0.20.1"
edition = "2021"
rust-version = "1.67.0"

Expand Down
2 changes: 1 addition & 1 deletion subvt-report-service/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subvt-report-service"
version = "0.20.0"
version = "0.20.1"
edition = "2021"
rust-version = "1.67.0"

Expand Down
30 changes: 21 additions & 9 deletions subvt-report-service/src/validator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use subvt_types::crypto::AccountId;
use subvt_types::err::ServiceError;
use subvt_types::report::{
BlockSummary, EraValidatorPayoutReport, EraValidatorRewardReport, MonthlyIncome,
ValidatorDetailsReport, ValidatorListReport, ValidatorSummaryReport,
MonthlyIncomeReport, ValidatorDetailsReport, ValidatorListReport, ValidatorSummaryReport,
ValidatorTotalRewardChartData,
};
use subvt_types::subvt::{ValidatorSearchSummary, ValidatorSummary};
Expand Down Expand Up @@ -324,6 +324,7 @@ pub(crate) async fn validator_monhtly_income_service(
path: web::Path<ValidatorPathParameter>,
data: web::Data<ServiceState>,
) -> ResultResponse {
let token_symbol = "USDT";
let account_id = match validate_path_param(&path.into_inner().ss58_address_or_account_id) {
Ok(account_id) => account_id,
Err(response) => return Ok(response),
Expand All @@ -341,7 +342,7 @@ pub(crate) async fn validator_monhtly_income_service(
.postgres
.get_rewards_in_time_range(&account_id, start_timestamp as u64, end_timestamp as u64)
.await?;
let mut monthly_incomes: Vec<MonthlyIncome> = Vec::new();
let mut monthly_income: Vec<MonthlyIncome> = Vec::new();
let denominator = f64::powi(10.0, CONFIG.substrate.token_decimals as i32);
for reward in rewards.iter() {
let reward_day = DateTime::from_timestamp_millis(reward.block_timestamp as i64)
Expand All @@ -353,22 +354,33 @@ pub(crate) async fn validator_monhtly_income_service(
NaiveDateTime::from(reward_day).and_utc().timestamp_millis();
let kline_close = data
.postgres
.get_kline(reward_day_begin_timestamp as u64)
.get_kline(
&CONFIG.substrate.token_ticker,
token_symbol,
reward_day_begin_timestamp as u64,
)
.await?
.close_to_f64()
.unwrap();
let reward = (reward.amount as f64) * kline_close / denominator;
if let Some(monthly_income) = monthly_incomes.iter_mut().find(|monthly_income| {
monthly_income.month == reward_month && monthly_income.year == reward_year
}) {
monthly_income.income += reward;
if let Some(monthly_income_instance) =
monthly_income.iter_mut().find(|monthly_income_instance| {
monthly_income_instance.month == reward_month
&& monthly_income_instance.year == reward_year
})
{
monthly_income_instance.income += reward;
} else {
monthly_incomes.push(MonthlyIncome {
monthly_income.push(MonthlyIncome {
year: reward_year,
month: reward_month,
income: reward,
});
}
}
Ok(HttpResponse::Ok().json(monthly_incomes))
Ok(HttpResponse::Ok().json(MonthlyIncomeReport {
rewardee: account_id,
token_symbol: token_symbol.to_string(),
monthly_income,
}))
}
2 changes: 1 addition & 1 deletion subvt-service-common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subvt-service-common"
version = "0.20.0"
version = "0.20.1"
edition = "2021"
rust-version = "1.67.0"

Expand Down
2 changes: 1 addition & 1 deletion subvt-substrate-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subvt-substrate-client"
version = "0.20.0"
version = "0.20.1"
edition = "2021"
rust-version = "1.67.0"

Expand Down
2 changes: 1 addition & 1 deletion subvt-telegram-bot/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subvt-telegram-bot"
version = "0.20.0"
version = "0.20.1"
edition = "2021"
rust-version = "1.67.0"

Expand Down
2 changes: 1 addition & 1 deletion subvt-telemetry-processor/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subvt-telemetry-processor"
version = "0.20.0"
version = "0.20.1"
edition = "2021"
rust-version = "1.67.0"

Expand Down
2 changes: 1 addition & 1 deletion subvt-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subvt-types"
version = "0.20.0"
version = "0.20.1"
edition = "2021"
rust-version = "1.67.0"

Expand Down
7 changes: 7 additions & 0 deletions subvt-types/src/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,10 @@ pub struct MonthlyIncome {
pub month: u32,
pub income: f64,
}

#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct MonthlyIncomeReport {
pub rewardee: AccountId,
pub token_symbol: String,
pub monthly_income: Vec<MonthlyIncome>,
}
2 changes: 1 addition & 1 deletion subvt-utility/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subvt-utility"
version = "0.20.0"
version = "0.20.1"
edition = "2021"
rust-version = "1.67.0"

Expand Down
2 changes: 1 addition & 1 deletion subvt-validator-details-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subvt-validator-details-server"
version = "0.20.0"
version = "0.20.1"
edition = "2021"
rust-version = "1.67.0"

Expand Down
2 changes: 1 addition & 1 deletion subvt-validator-list-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subvt-validator-list-server"
version = "0.20.0"
version = "0.20.1"
edition = "2021"
rust-version = "1.67.0"

Expand Down
2 changes: 1 addition & 1 deletion subvt-validator-list-updater/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subvt-validator-list-updater"
version = "0.20.0"
version = "0.20.1"
edition = "2021"
rust-version = "1.67.0"

Expand Down

0 comments on commit eb11d48

Please sign in to comment.