Skip to content

Commit

Permalink
[Audit] I-4 - Remove useless checked_as_u64 (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
crypto-vincent authored Jan 1, 2024
1 parent afcd43c commit d102e92
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion programs/uxd/src/instructions/redeem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ pub(crate) fn handler(ctx: Context<Redeem>, redeemable_amount: u64) -> Result<()
let new_epoch_outflow_amount = {
// How long ago was the last outflow
let last_outflow_elapsed_slots = std::cmp::min(
checked_as_u64(checked_sub(current_slot, controller.last_outflow_slot)?)?,
checked_sub(current_slot, controller.last_outflow_slot)?,
controller.slots_per_epoch,
);
// How much was unlocked by waiting since last redeem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use anchor_lang::require;
use crate::error::UxdError;
use crate::utils::calculate_depositories_sum_value;
use crate::utils::checked_add;
use crate::utils::checked_as_u64;
use crate::utils::checked_sub;
use crate::ROUTER_DEPOSITORIES_COUNT;

Expand Down Expand Up @@ -167,7 +166,7 @@ pub fn calculate_depositories_redeemable_amount(
continue;
}
let depository_remaining_after_redeem = checked_sub(
checked_as_u64(depository.redeemable_amount_under_management)?,
depository.redeemable_amount_under_management,
depositories_redeemable_amount[i],
)?;
let depository_rounding_correction =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use anchor_lang::require;
use crate::error::UxdError;
use crate::utils::calculate_depositories_sum_value;
use crate::utils::checked_add;
use crate::utils::checked_as_u64;
use crate::utils::checked_sub;
use crate::BPS_POWER;
use crate::ROUTER_DEPOSITORIES_COUNT;
Expand All @@ -26,8 +25,6 @@ pub fn calculate_depositories_target_redeemable_amount(
UxdError::InvalidDepositoriesVector
);

let redeemable_circulating_supply = checked_as_u64(redeemable_circulating_supply)?;

// Double check that the weights adds up to 100%
let depositories_weights_bps = depositories_info
.iter()
Expand Down Expand Up @@ -66,8 +63,8 @@ pub fn calculate_depositories_target_redeemable_amount(
// Read the minting caps of each depository
let depositories_hard_cap_amount = depositories_info
.iter()
.map(|depository| checked_as_u64(depository.redeemable_amount_under_management_cap))
.collect::<Result<Vec<u64>>>()?;
.map(|depository| depository.redeemable_amount_under_management_cap)
.collect::<Vec<u64>>();

// Compute the depository_overflow amount of raw target that doesn't fit within the cap of each depository
let depositories_overflow_amount = std::iter::zip(
Expand Down

0 comments on commit d102e92

Please sign in to comment.