From 02f26c5634a5248b383555235236398404ecebb1 Mon Sep 17 00:00:00 2001 From: cryptokage <26vivek06@gmail.com> Date: Thu, 26 Sep 2024 20:47:19 +0530 Subject: [PATCH] fix: remove options (#450) --- bindings-test/src/tests.rs | 2 +- .../trade_shield/types/perpetual_assets.rs | 17 ++++++++----- .../src/trade_shield/types/perpetual_order.rs | 24 ++----------------- .../action/execute/create_perpetual_order.rs | 2 -- 4 files changed, 14 insertions(+), 31 deletions(-) diff --git a/bindings-test/src/tests.rs b/bindings-test/src/tests.rs index c50be252..b5f438e0 100644 --- a/bindings-test/src/tests.rs +++ b/bindings-test/src/tests.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{ coin, coins, Addr, Coin, Decimal, Int128, Int64, SignedDecimal, SignedDecimal256, StdError, - Uint128, Uint64, + Uint128, }; use cw_multi_test::Executor; use elys_bindings::{ diff --git a/bindings/src/trade_shield/types/perpetual_assets.rs b/bindings/src/trade_shield/types/perpetual_assets.rs index 4997c13d..86b27933 100644 --- a/bindings/src/trade_shield/types/perpetual_assets.rs +++ b/bindings/src/trade_shield/types/perpetual_assets.rs @@ -4,8 +4,6 @@ use crate::ElysQuerier; use cosmwasm_schema::cw_serde; use cosmwasm_std::{DecCoin, Decimal, Decimal256, SignedDecimal, StdError, StdResult, Uint128}; -use super::Fee; - #[cw_serde] pub struct PerpetualAssets { pub total_perpetual_asset_balance: DecCoin, @@ -26,8 +24,7 @@ pub struct PerpetualAsset { pub health: SignedDecimal, pub profit_price: DecCoin, pub stop_loss: Option, - pub borrow_fee: Fee, - pub funding_fee: Fee, + pub fees: Decimal, } impl PerpetualAsset { @@ -94,8 +91,16 @@ impl PerpetualAsset { }), None => None, }, - borrow_fee: Fee::default(), - funding_fee: Fee::default(), + fees: Decimal::from_atomics( + Uint128::new(mtp.mtp.borrow_interest_paid_collateral.i128() as u128), + collateral_info.asset_info.decimal as u32, + ) + .map_err(|e| { + StdError::generic_err(format!( + "failed to convert borrow_interest_paid_collateral to Decimal256: {}", + e + )) + })?, }) } } diff --git a/bindings/src/trade_shield/types/perpetual_order.rs b/bindings/src/trade_shield/types/perpetual_order.rs index 124ff896..1be645b6 100644 --- a/bindings/src/trade_shield/types/perpetual_order.rs +++ b/bindings/src/trade_shield/types/perpetual_order.rs @@ -3,10 +3,10 @@ use std::str::FromStr; use crate::{trade_shield::states::PENDING_PERPETUAL_ORDER, types::PerpetualPosition}; use cosmwasm_schema::cw_serde; use cosmwasm_std::{ - Coin, DecCoin, OverflowError, SignedDecimal, SignedDecimal256, StdError, StdResult, Storage, + Coin, OverflowError, SignedDecimal, SignedDecimal256, StdError, StdResult, Storage, }; -use super::{Fee, OrderPrice, PerpetualOrderType, Status}; +use super::{OrderPrice, PerpetualOrderType, Status}; #[cw_serde] pub struct PerpetualOrder { @@ -21,10 +21,6 @@ pub struct PerpetualOrder { pub take_profit_price: Option, pub position_id: Option, pub status: Status, - pub size: DecCoin, - pub liquidation: SignedDecimal, - pub borrow_fee: Fee, - pub funding_fee: Fee, } impl PerpetualOrder { @@ -38,10 +34,6 @@ impl PerpetualOrder { take_profit_price: &Option, trigger_price: &Option, order_vec: &Vec, - size: DecCoin, - liquidation: SignedDecimal, - borrow_fee: Fee, - funding_fee: Fee, ) -> StdResult { let status = if order_type == &PerpetualOrderType::MarketOpen { Status::Executed @@ -63,10 +55,6 @@ impl PerpetualOrder { trigger_price: trigger_price.to_owned(), status, position_id: None, - size, - liquidation, - borrow_fee, - funding_fee, }; return Ok(order); @@ -82,10 +70,6 @@ impl PerpetualOrder { trigger_price: &Option, take_profit_price: &Option, order_vec: &Vec, - size: DecCoin, - liquidation: SignedDecimal, - borrow_fee: Fee, - funding_fee: Fee, ) -> StdResult { let order_id: u64 = get_new_id(&order_vec)?; @@ -109,10 +93,6 @@ impl PerpetualOrder { position_id: Some(position_id), leverage: leverage.to_owned(), take_profit_price: take_profit_price.to_owned(), - size, - liquidation, - borrow_fee, - funding_fee, }; Ok(order) diff --git a/contracts/trade-shield-contract/src/action/execute/create_perpetual_order.rs b/contracts/trade-shield-contract/src/action/execute/create_perpetual_order.rs index e0656687..9ae46c4c 100644 --- a/contracts/trade-shield-contract/src/action/execute/create_perpetual_order.rs +++ b/contracts/trade-shield-contract/src/action/execute/create_perpetual_order.rs @@ -1,5 +1,3 @@ -use std::ops::Sub; - use crate::{helper::get_discount, msg::ReplyType}; use super::*;