Skip to content
This repository was archived by the owner on Nov 15, 2024. It is now read-only.

Commit 249e491

Browse files
authored
Fix: Discount should be within 0-1 range (#435)
* update discount value * update * update
1 parent 0c21a12 commit 249e491

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

contracts/trade-shield-contract/src/helper.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,9 @@ pub fn get_discount(deps: &Deps<ElysQuery>, user_address: String) -> StdResult<D
6262
};
6363

6464
let discount = match discount_str.parse::<Decimal>() {
65-
Ok(discount) => {
66-
let result = match discount.checked_div(Decimal::new(Uint128::from(100u64))) {
67-
Ok(result) => result,
68-
Err(_) => Decimal::zero(),
69-
};
70-
result
71-
}
65+
Ok(discount) => discount
66+
.checked_div(Decimal::new(Uint128::from(100u64)))
67+
.unwrap_or_default(),
7268
Err(_) => Decimal::zero(),
7369
};
7470

0 commit comments

Comments
 (0)