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

Commit af5cb3f

Browse files
amityadav0Amit Yadav
andauthored
Swap error fix (#442)
* fix swap error * fix swap error --------- Co-authored-by: Amit Yadav <ay@Amits-MBP.lan>
1 parent 4db5912 commit af5cb3f

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

bindings/src/query_resp.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,6 @@ pub struct LeveragelpPosition {
627627
pub interest_rate_hour_usd: Decimal,
628628
}
629629

630-
631630
#[cw_serde]
632631
pub struct LeveragelpPositionResponse {
633632
pub position: Option<LeveragelpPosition>,

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::str::FromStr;
2+
13
use cosmwasm_std::{
24
from_json, BankMsg, Decimal, OverflowError, OverflowOperation, QuerierWrapper, Response,
35
StdError, StdResult, Storage, SubMsgResult, Uint128,
@@ -41,14 +43,12 @@ pub fn get_discount(
4143
Err(_) => "0".to_string(),
4244
};
4345

44-
let discount = match discount_str.parse::<Decimal>() {
45-
Ok(discount) => discount
46-
.checked_div(Decimal::new(Uint128::from(100u64)))
47-
.unwrap_or_default(),
46+
let val = Uint128::from_str(&discount_str)?;
47+
let discount_str = match Decimal::from_atomics(val, 2) {
48+
Ok(resp) => resp,
4849
Err(_) => Decimal::zero(),
4950
};
50-
51-
Ok(discount)
51+
Ok(discount_str)
5252
}
5353

5454
pub fn remove_spot_order(

0 commit comments

Comments
 (0)