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

Commit

Permalink
Merge branch 'main' into feat/devnet-cw-update
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptokage1996 authored Aug 14, 2024
2 parents 5767b06 + 1851fcd commit 05e1461
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions contracts/trade-shield-contract/src/helper.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::str::FromStr;

use cosmwasm_std::{
from_json, BankMsg, Decimal, OverflowError, OverflowOperation, QuerierWrapper, Response,
StdError, StdResult, Storage, SubMsgResult, Uint128,
Expand Down Expand Up @@ -36,19 +38,21 @@ pub fn get_discount(
user_address: String,
) -> StdResult<Decimal> {
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(),
};

let discount = match discount_str.parse::<Decimal>() {
Ok(discount) => discount
.checked_div(Decimal::new(Uint128::from(100u64)))
.unwrap_or_default(),
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,
Err(_) => Decimal::zero(),
};

Ok(discount)
Ok(discount_str)
}

pub fn remove_spot_order(
Expand Down

0 comments on commit 05e1461

Please sign in to comment.