How to define decimal places while using Decimal::percent

Hey guys. Rust newbie here. I am trying to calculate amount deducted from a value based on rate and decimal places in rate.

Without the decimal places, suppose if I want to deduct 2% amount from original (where 2 is the rate), this is how I am accomplishing it:

 let original = token_value[0].amount;
 token_value[0].amount = original * Decimal::percent(98);

What if I want to also define the decimal places in rate and then make the deduction, how will I accomplish that?

Which crate is Decimal from? I assumed it was rust_decimal but that doesn't seem to have a percent method on it.

No this Decimal is from cosmwasm_std crate

I solved this by using from_ratio in the cosmwasm_std::Decimal crate

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.