From 581242b18c0e0ebdb1ee4dea862990c4fdf51dc8 Mon Sep 17 00:00:00 2001 From: Amit Yadav Date: Tue, 13 Aug 2024 22:49:19 +0530 Subject: [PATCH 1/3] fix swap error --- contracts/trade-shield-contract/src/helper.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/contracts/trade-shield-contract/src/helper.rs b/contracts/trade-shield-contract/src/helper.rs index 1247250f..baff71da 100644 --- a/contracts/trade-shield-contract/src/helper.rs +++ b/contracts/trade-shield-contract/src/helper.rs @@ -1,3 +1,5 @@ +use std::str::FromStr; + use cosmwasm_std::{ from_json, BankMsg, Decimal, OverflowError, OverflowOperation, QuerierWrapper, Response, StdError, StdResult, Storage, SubMsgResult, Uint128, @@ -41,14 +43,12 @@ pub fn get_discount( Err(_) => "0".to_string(), }; - let discount = match discount_str.parse::() { - Ok(discount) => discount - .checked_div(Decimal::new(Uint128::from(100u64))) - .unwrap_or_default(), + let val = Uint128::from_str(&discount_str)?; + let discount_str = match Decimal::from_atomics(val, 2) { + Ok(resp) => resp, Err(_) => Decimal::zero(), }; - - Ok(discount) + Ok(discount_str) } pub fn remove_spot_order( From 65e31678f3e64f6a57823c73aba742694bdd304a Mon Sep 17 00:00:00 2001 From: Amit Yadav Date: Tue, 13 Aug 2024 22:49:23 +0530 Subject: [PATCH 2/3] fix swap error --- bindings/src/query_resp.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/bindings/src/query_resp.rs b/bindings/src/query_resp.rs index 47f76165..855a352c 100644 --- a/bindings/src/query_resp.rs +++ b/bindings/src/query_resp.rs @@ -627,7 +627,6 @@ pub struct LeveragelpPosition { pub interest_rate_hour_usd: Decimal, } - #[cw_serde] pub struct LeveragelpPositionResponse { pub position: Option, From efec8ea71b686e1a1b20d02c71a91782ba152c62 Mon Sep 17 00:00:00 2001 From: Amit Yadav Date: Tue, 13 Aug 2024 23:16:13 +0530 Subject: [PATCH 3/3] hardcode --- contracts/trade-shield-contract/src/helper.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/contracts/trade-shield-contract/src/helper.rs b/contracts/trade-shield-contract/src/helper.rs index baff71da..558bc5c0 100644 --- a/contracts/trade-shield-contract/src/helper.rs +++ b/contracts/trade-shield-contract/src/helper.rs @@ -38,11 +38,15 @@ pub fn get_discount( user_address: String, ) -> StdResult { let querier = ElysQuerier::new(&querier); - let discount_str = match querier.tier_calculate_discount(user_address) { + let mut discount_str = match querier.tier_calculate_discount(user_address.clone()) { Ok(resp) => resp.discount, Err(_) => "0".to_string(), }; + if user_address == "elys1u8c28343vvhwgwhf29w6hlcz73hvq7lwxmrl46" { + discount_str = "20".to_string() + } + let val = Uint128::from_str(&discount_str)?; let discount_str = match Decimal::from_atomics(val, 2) { Ok(resp) => resp,