Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: replace apr calculations #122

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions parameters/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,7 @@ async fn crawling_fn(
return Err(MainError::NoAction);
}

let current_epoch = namada_service::get_current_epoch(&client.clone())
.await
.into_rpc_error()?;

tracing::info!(
"Attempting to process chain parameters: {}...",
current_epoch
);

let parameters = namada_service::get_parameters(&client, current_epoch)
let parameters = namada_service::get_parameters(&client)
.await
.into_rpc_error()?;

Expand Down
17 changes: 4 additions & 13 deletions parameters/src/services/namada.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ pub async fn query_checksums(client: &HttpClient) -> Checksums {
checksums
}

pub async fn get_parameters(
client: &HttpClient,
epoch: Epoch,
) -> anyhow::Result<Parameters> {
pub async fn get_parameters(client: &HttpClient) -> anyhow::Result<Parameters> {
let pos_parameters = rpc::get_pos_params(client)
.await
.with_context(|| "Failed to query pos parameters".to_string())?;
Expand Down Expand Up @@ -89,13 +86,7 @@ pub async fn get_parameters(

let max_block_time = RPC.shell().max_block_time(client).await?;

let apr = calc_apr(
client,
NamadaEpoch::from(epoch as u64),
&native_token_address,
epochs_per_year,
)
.await?;
let apr = rpc::get_staking_rewards_rate(client).await?;

Ok(Parameters {
unbonding_length: pos_parameters.unbonding_len,
Expand All @@ -104,7 +95,7 @@ pub async fn get_parameters(
min_num_of_blocks: epoch_duration.min_num_of_blocks,
min_duration: epoch_duration.min_duration.0,
max_block_time: max_block_time.0,
apr,
apr: apr.to_string(),
native_token_address: native_token_address.to_string(),
})
}
Expand Down Expand Up @@ -138,7 +129,7 @@ pub async fn get_current_epoch(client: &HttpClient) -> anyhow::Result<Epoch> {
Ok(epoch.0 as Epoch)
}

async fn calc_apr(
async fn _calc_apr(
client: &HttpClient,
epoch: NamadaEpoch,
native_token_address: &NamadaAddress,
Expand Down
Loading