From 250d49dd50da278674a40c9b7570ae5f8ea71d14 Mon Sep 17 00:00:00 2001 From: cryptokage <26vivek06@gmail.com> Date: Fri, 27 Sep 2024 02:06:56 +0530 Subject: [PATCH] Dev 1969 v3 bindings fix (#452) * fix: remove options * feat: remove min collateral * feat: update interfaces --- bindings-test/src/multitest.rs | 44 +++--- bindings/src/query_resp.rs | 126 +++++++++--------- bindings/src/types.rs | 35 +++-- ...ssue_create_perpetual_market_open_order.rs | 86 ++++++------ .../pending_limit_open_long_with_price_met.rs | 44 +++--- ...ding_limit_open_long_with_price_not_met.rs | 44 +++--- ...pending_limit_open_short_with_price_met.rs | 44 +++--- ...ing_limit_open_short_with_price_not_met.rs | 44 +++--- 8 files changed, 239 insertions(+), 228 deletions(-) diff --git a/bindings-test/src/multitest.rs b/bindings-test/src/multitest.rs index ad1f49ed..42b390b1 100644 --- a/bindings-test/src/multitest.rs +++ b/bindings-test/src/multitest.rs @@ -361,28 +361,28 @@ impl Module for ElysModule { discount, } => { return Ok(to_json_binary(&PerpetualOpenEstimationRawResponse { - position, - available_liquidity: coin(99999999, &trading_asset), - leverage: leverage.to_string(), - collateral, - trading_asset, - discount: discount.to_string(), - // TODO: Fix - interest_amount: Int128::zero(), - position_size: coin(1, "btc"), - swap_fee: Decimal::zero().to_string(), - open_price: Decimal::zero().to_string(), - take_profit_price: take_profit_price.to_string(), - liquidation_price: Decimal::zero().to_string(), - estimated_pnl: Int128::zero(), - estimated_pnl_denom: "uelys".to_string(), - slippage: Decimal::zero().to_string(), - weight_balance_ratio: Decimal::zero().to_string(), - borrow_interest_rate: Decimal::zero().to_string(), - funding_rate: Decimal::zero().to_string(), - price_impact: Decimal::zero().to_string(), - borrow_fee: Coin::new(0, ""), - funding_fee: Coin::new(0, ""), + position: Some(position), + available_liquidity: Some(coin(99999999, &trading_asset)), + leverage: Some(leverage.to_string()), + collateral: Some(collateral), + trading_asset: Some(trading_asset), + discount: Some(discount.to_string()), + // TODO:Fix + interest_amount: Some(Int128::zero()), + position_size: Some(coin(1, "btc")), + swap_fee: Some(Decimal::zero().to_string()), + open_price: Some(Decimal::zero().to_string()), + take_profit_price: Some(take_profit_price.to_string()), + liquidation_price: Some(Decimal::zero().to_string()), + estimated_pnl: Some(Int128::zero()), + estimated_pnl_denom: Some("uelys".to_string()), + slippage: Some(Decimal::zero().to_string()), + weight_balance_ratio: Some(Decimal::zero().to_string()), + borrow_interest_rate: Some(Decimal::zero().to_string()), + funding_rate: Some(Decimal::zero().to_string()), + price_impact: Some(Decimal::zero().to_string()), + borrow_fee: Some(Coin::new(0, "")), + funding_fee: Some(Coin::new(0, "")), })?); } ElysQuery::AssetProfileEntryAll { .. } => { diff --git a/bindings/src/query_resp.rs b/bindings/src/query_resp.rs index 35482cde..db86a519 100644 --- a/bindings/src/query_resp.rs +++ b/bindings/src/query_resp.rs @@ -102,27 +102,27 @@ pub struct AmmSwapEstimationByDenomResponse { } #[cw_serde] pub struct PerpetualOpenEstimationRawResponse { - pub position: i32, - pub leverage: String, - pub trading_asset: String, - pub collateral: Coin, - pub interest_amount: Int128, - pub position_size: Coin, - pub swap_fee: String, - pub discount: String, - pub open_price: String, - pub take_profit_price: String, - pub liquidation_price: String, - pub estimated_pnl: Int128, - pub estimated_pnl_denom: String, - pub available_liquidity: Coin, - pub slippage: String, - pub weight_balance_ratio: String, - pub borrow_interest_rate: String, - pub funding_rate: String, - pub price_impact: String, - pub borrow_fee: Coin, - pub funding_fee: Coin, + pub position: Option, + pub leverage: Option, + pub trading_asset: Option, + pub collateral: Option, + pub interest_amount: Option, + pub position_size: Option, + pub swap_fee: Option, + pub discount: Option, + pub open_price: Option, + pub take_profit_price: Option, + pub liquidation_price: Option, + pub estimated_pnl: Option, + pub estimated_pnl_denom: Option, + pub available_liquidity: Option, + pub slippage: Option, + pub weight_balance_ratio: Option, + pub borrow_interest_rate: Option, + pub funding_rate: Option, + pub price_impact: Option, + pub borrow_fee: Option, + pub funding_fee: Option, } #[cw_serde] @@ -153,44 +153,46 @@ pub struct PerpetualOpenEstimationResponse { impl Into> for PerpetualOpenEstimationRawResponse { fn into(self) -> StdResult { Ok(PerpetualOpenEstimationResponse { - position: PerpetualPosition::try_from_i32(self.position)?, - leverage: SignedDecimal::from_str(&self.leverage) - .map_or(SignedDecimal::zero(), |leverage| leverage), - interest_amount: self.interest_amount, - trading_asset: self.trading_asset, - collateral: self.collateral, - position_size: self.position_size, - swap_fee: Decimal::from_str(&self.swap_fee) - .map_or(Decimal::zero(), |swap_fee| swap_fee), - discount: Decimal::from_str(&self.discount) - .map_or(Decimal::zero(), |discount| discount), - open_price: Decimal::from_str(&self.open_price) - .map_or(Decimal::zero(), |open_price| open_price), - take_profit_price: SignedDecimal256::from_str(&self.take_profit_price) - .map_or(SignedDecimal256::zero(), |take_profit_price| { - take_profit_price - }), - liquidation_price: SignedDecimal::from_str(&self.liquidation_price) - .map_or(SignedDecimal::zero(), |liquidation_price| liquidation_price), - estimated_pnl: self.estimated_pnl, - estimated_pnl_denom: self.estimated_pnl_denom, - available_liquidity: self.available_liquidity, - slippage: Decimal::from_str(&self.slippage) - .map_or(Decimal::zero(), |slippage| slippage), - weight_balance_ratio: SignedDecimal::from_str(&self.weight_balance_ratio) - .map_or(SignedDecimal::zero(), |weight_balance_ratio| { - weight_balance_ratio - }), - borrow_interest_rate: SignedDecimal::from_str(&self.borrow_interest_rate) - .map_or(SignedDecimal::zero(), |borrow_interest_rate| { - borrow_interest_rate - }), - funding_rate: SignedDecimal::from_str(&self.funding_rate) - .map_or(SignedDecimal::zero(), |funding_rate| funding_rate), - price_impact: SignedDecimal::from_str(&self.price_impact) - .map_or(SignedDecimal::zero(), |price_impact| price_impact), - borrow_fee: self.borrow_fee, - funding_fee: self.funding_fee, + position: PerpetualPosition::try_from_i32(self.position.unwrap_or_default())?, + leverage: SignedDecimal::from_str(self.leverage.unwrap_or_default().as_str()) + .unwrap_or_default(), + trading_asset: self.trading_asset.unwrap_or_default(), + collateral: self.collateral.unwrap_or_default(), + interest_amount: self.interest_amount.unwrap_or_default(), + position_size: self.position_size.unwrap_or_default(), + swap_fee: Decimal::from_str(self.swap_fee.unwrap_or_default().as_str()) + .unwrap_or_default(), + discount: Decimal::from_str(self.discount.unwrap_or_default().as_str()) + .unwrap_or_default(), + open_price: Decimal::from_str(self.open_price.unwrap_or_default().as_str()) + .unwrap_or_default(), + take_profit_price: SignedDecimal256::from_str( + self.take_profit_price.unwrap_or_default().as_str(), + ) + .unwrap_or_default(), + liquidation_price: SignedDecimal::from_str( + self.liquidation_price.unwrap_or_default().as_str(), + ) + .unwrap_or_default(), + estimated_pnl: self.estimated_pnl.unwrap_or_default(), + estimated_pnl_denom: self.estimated_pnl_denom.unwrap_or_default(), + available_liquidity: self.available_liquidity.unwrap_or_default(), + slippage: Decimal::from_str(self.slippage.unwrap_or_default().as_str()) + .unwrap_or_default(), + weight_balance_ratio: SignedDecimal::from_str( + self.weight_balance_ratio.unwrap_or_default().as_str(), + ) + .unwrap_or_default(), + borrow_interest_rate: SignedDecimal::from_str( + self.borrow_interest_rate.unwrap_or_default().as_str(), + ) + .unwrap_or_default(), + funding_rate: SignedDecimal::from_str(self.funding_rate.unwrap_or_default().as_str()) + .unwrap_or_default(), + price_impact: SignedDecimal::from_str(self.price_impact.unwrap_or_default().as_str()) + .unwrap_or_default(), + borrow_fee: self.borrow_fee.unwrap_or_default(), + funding_fee: self.funding_fee.unwrap_or_default(), }) } } @@ -646,10 +648,10 @@ pub struct LeveragelpParams { #[cw_serde] #[derive(Default)] pub struct PerpetualParamsRaw { - pub option: Option, pub leverage_max: Option, pub borrow_interest_rate_max: Option, pub borrow_interest_rate_min: Option, + pub min_borrow_interest_amount: Option, pub borrow_interest_rate_increase: Option, pub borrow_interest_rate_decrease: Option, pub health_gain_factor: Option, @@ -675,10 +677,10 @@ pub struct PerpetualParamsRaw { #[cw_serde] pub struct PerpetualParams { - pub option: bool, pub leverage_max: Decimal, pub borrow_interest_rate_max: Decimal, pub borrow_interest_rate_min: Decimal, + pub min_borrow_interest_amount: Uint128, pub borrow_interest_rate_increase: Decimal, pub borrow_interest_rate_decrease: Decimal, pub health_gain_factor: Decimal, @@ -1264,7 +1266,7 @@ pub struct ParameterParamsResponse { impl Into for PerpetualParamsRaw { fn into(self) -> PerpetualParams { PerpetualParams { - option: self.option.unwrap_or_default(), + min_borrow_interest_amount: self.min_borrow_interest_amount.unwrap_or_default(), leverage_max: self.leverage_max.unwrap_or_default(), borrow_interest_rate_max: self.borrow_interest_rate_max.unwrap_or_default(), borrow_interest_rate_min: self.borrow_interest_rate_min.unwrap_or_default(), diff --git a/bindings/src/types.rs b/bindings/src/types.rs index f8968b7e..ed6bec55 100644 --- a/bindings/src/types.rs +++ b/bindings/src/types.rs @@ -256,36 +256,35 @@ impl FromStr for PerpetualPosition { }) } } - #[cw_serde] pub struct Mtp { pub address: String, - pub amm_pool_id: u64, + pub collateral_asset: String, + pub trading_asset: String, + pub liabilities_asset: String, + pub custody_asset: String, + pub collateral: Int128, + pub liabilities: Int128, pub borrow_interest_paid_collateral: Int128, pub borrow_interest_paid_custody: Int128, pub borrow_interest_unpaid_collateral: Int128, - pub collateral_asset: String, - pub collateral: Int128, - pub consolidate_leverage: SignedDecimal, pub custody: Int128, - pub custody_asset: String, + pub take_profit_liabilities: Int128, + pub take_profit_custody: Int128, + pub leverage: SignedDecimal, + pub mtp_health: SignedDecimal, + pub position: i32, // Assuming Position is an enum or struct defined elsewhere + pub id: u64, + pub amm_pool_id: u64, + pub consolidate_leverage: SignedDecimal, + pub sum_collateral: Int128, + pub take_profit_price: SignedDecimal256, + pub take_profit_borrow_rate: SignedDecimal, pub funding_fee_paid_collateral: Int128, pub funding_fee_paid_custody: Int128, pub funding_fee_received_collateral: Int128, pub funding_fee_received_custody: Int128, - pub id: u64, - pub leverage: SignedDecimal, - pub liabilities: Int128, - pub liabilities_asset: String, - pub mtp_health: SignedDecimal, pub open_price: SignedDecimal, - pub position: i32, - pub sum_collateral: Int128, - pub take_profit_borrow_rate: SignedDecimal, - pub take_profit_custody: Int128, - pub take_profit_liabilities: Int128, - pub take_profit_price: SignedDecimal256, - pub trading_asset: String, pub stop_loss_price: SignedDecimal, pub last_interest_calc_time: Option, pub last_interest_calc_block: Option, diff --git a/contracts/trade-shield-contract/src/tests/create_perpetual_order/reproduce_testnet_issue_create_perpetual_market_open_order.rs b/contracts/trade-shield-contract/src/tests/create_perpetual_order/reproduce_testnet_issue_create_perpetual_market_open_order.rs index 68cbd5eb..c1dde3fc 100644 --- a/contracts/trade-shield-contract/src/tests/create_perpetual_order/reproduce_testnet_issue_create_perpetual_market_open_order.rs +++ b/contracts/trade-shield-contract/src/tests/create_perpetual_order/reproduce_testnet_issue_create_perpetual_market_open_order.rs @@ -112,50 +112,60 @@ impl Module for ElysModule { discount, } => { let resp = PerpetualOpenEstimationRawResponse { - position, - leverage: leverage.clone().to_string(), - trading_asset: trading_asset.clone(), - collateral: collateral.clone(), + position: Some(position), + leverage: Some(leverage.clone().to_string()), + trading_asset: Some(trading_asset.clone()), + collateral: Some(collateral.clone()), // TODO: Fix - interest_amount: Int128::zero(), - position_size: collateral.clone(), - swap_fee: Decimal::zero().to_string(), - discount: discount.clone().to_string(), - open_price: Decimal::from_atomics(Uint128::new(9_440_848_026_817_446_325), 18) - .unwrap() - .to_string(), - take_profit_price: take_profit_price.clone().to_string(), - liquidation_price: Decimal::from_atomics( - Uint128::new(9_240_848_026_817_446_325), - 18, - ) - .unwrap() - .to_string(), - estimated_pnl: Int128::from_str( - // "4_999_999_999_999_999_999_999_999_999_999_999_999_527_957_598_6", - "4999999999999999999999999999999999999", - ) - .unwrap(), - estimated_pnl_denom: + interest_amount: Some(Int128::zero()), + position_size: Some(collateral.clone()), + swap_fee: Some(Decimal::zero().to_string()), + discount: Some(discount.clone().to_string()), + open_price: Some( + Decimal::from_atomics(Uint128::new(9_440_848_026_817_446_325), 18) + .unwrap() + .to_string(), + ), + take_profit_price: Some(take_profit_price.clone().to_string()), + liquidation_price: Some( + Decimal::from_atomics(Uint128::new(9_240_848_026_817_446_325), 18) + .unwrap() + .to_string(), + ), + estimated_pnl: Some( + Int128::from_str( + // "4_999_999_999_999_999_999_999_999_999_999_999_999_527_957_598_6", + "4999999999999999999999999999999999999", + ) + .unwrap(), + ), + estimated_pnl_denom: Some( "ibc/2180E84E20F5679FCC760D8C165B60F42065DEF7F46A72B447CFF1B7DC6C0A65" .to_string(), - available_liquidity: coin( + ), + available_liquidity: Some(coin( 7705931608, "ibc/E2D2F6ADCC68AA3384B2F5DFACCA437923D137C14E86FB8A10207CF3BED0C8D4", + )), + weight_balance_ratio: Some(Decimal::zero().to_string()), + borrow_interest_rate: Some( + Decimal::from_atomics(Uint128::new(323_793_793_684), 18) + .unwrap() + .to_string(), + ), + funding_rate: Some( + Decimal::from_atomics(Uint128::new(1_000_000_000_000_000), 18) + .unwrap() + .to_string(), + ), + price_impact: Some( + Decimal::from_atomics(Uint128::new(6_495_303_442_450), 18) + .unwrap() + .to_string(), ), - weight_balance_ratio: Decimal::zero().to_string(), - borrow_interest_rate: Decimal::from_atomics(Uint128::new(323_793_793_684), 18) - .unwrap() - .to_string(), - funding_rate: Decimal::from_atomics(Uint128::new(1_000_000_000_000_000), 18) - .unwrap() - .to_string(), - price_impact: Decimal::from_atomics(Uint128::new(6_495_303_442_450), 18) - .unwrap() - .to_string(), - slippage: Decimal::zero().to_string(), - borrow_fee: Coin::default(), - funding_fee: Coin::default(), + slippage: Some(Decimal::zero().to_string()), + borrow_fee: Some(Coin::default()), + funding_fee: Some(Coin::default()), }; return Ok(to_json_binary(&resp)?); diff --git a/contracts/trade-shield-contract/src/tests/process_perpetual_order/pending_limit_open_long_with_price_met.rs b/contracts/trade-shield-contract/src/tests/process_perpetual_order/pending_limit_open_long_with_price_met.rs index ea86aebc..82313495 100644 --- a/contracts/trade-shield-contract/src/tests/process_perpetual_order/pending_limit_open_long_with_price_met.rs +++ b/contracts/trade-shield-contract/src/tests/process_perpetual_order/pending_limit_open_long_with_price_met.rs @@ -114,28 +114,28 @@ impl Module for ElysModuleWrapper { take_profit_price, discount, } => Ok(to_json_binary(&PerpetualOpenEstimationRawResponse { - position, - leverage: leverage.to_string(), - trading_asset, - position_size: coin(0, ""), - collateral, - available_liquidity: coin(0, ""), - // TODO: Fix - interest_amount: Int128::zero(), - swap_fee: Decimal::zero().to_string(), - discount: discount.to_string(), - open_price: Decimal::zero().to_string(), - take_profit_price: take_profit_price.to_string(), - liquidation_price: Decimal::zero().to_string(), - estimated_pnl: Int128::zero(), - estimated_pnl_denom: "".to_string(), - slippage: Decimal::zero().to_string(), - weight_balance_ratio: Decimal::zero().to_string(), - borrow_interest_rate: Decimal::zero().to_string(), - funding_rate: Decimal::zero().to_string(), - price_impact: Decimal::zero().to_string(), - borrow_fee: Coin::new(0, ""), - funding_fee: Coin::new(0, ""), + position: Some(position), + available_liquidity: Some(coin(0, &trading_asset)), + leverage: Some(leverage.to_string()), + collateral: Some(collateral), + trading_asset: Some(trading_asset), + discount: Some(discount.to_string()), + // TODO:Fix + interest_amount: Some(Int128::zero()), + position_size: Some(coin(1, "btc")), + swap_fee: Some(Decimal::zero().to_string()), + open_price: Some(Decimal::zero().to_string()), + take_profit_price: Some(take_profit_price.to_string()), + liquidation_price: Some(Decimal::zero().to_string()), + estimated_pnl: Some(Int128::zero()), + estimated_pnl_denom: Some("uelys".to_string()), + slippage: Some(Decimal::zero().to_string()), + weight_balance_ratio: Some(Decimal::zero().to_string()), + borrow_interest_rate: Some(Decimal::zero().to_string()), + funding_rate: Some(Decimal::zero().to_string()), + price_impact: Some(Decimal::zero().to_string()), + borrow_fee: Some(Coin::new(0, "")), + funding_fee: Some(Coin::new(0, "")), })?), //ignoring address here since we only use one user ElysQuery::PerpetualGetPositionsForAddress { .. } => { diff --git a/contracts/trade-shield-contract/src/tests/process_perpetual_order/pending_limit_open_long_with_price_not_met.rs b/contracts/trade-shield-contract/src/tests/process_perpetual_order/pending_limit_open_long_with_price_not_met.rs index 094ee602..e54bb3f7 100644 --- a/contracts/trade-shield-contract/src/tests/process_perpetual_order/pending_limit_open_long_with_price_not_met.rs +++ b/contracts/trade-shield-contract/src/tests/process_perpetual_order/pending_limit_open_long_with_price_not_met.rs @@ -114,28 +114,28 @@ impl Module for ElysModuleWrapper { take_profit_price, discount, } => Ok(to_json_binary(&PerpetualOpenEstimationRawResponse { - position, - leverage: leverage.to_string(), - trading_asset, - // TODO: Fix - interest_amount: Int128::zero(), - position_size: coin(0, ""), - collateral, - available_liquidity: coin(0, ""), - swap_fee: Decimal::zero().to_string(), - discount: discount.to_string(), - open_price: Decimal::zero().to_string(), - take_profit_price: take_profit_price.to_string(), - liquidation_price: Decimal::zero().to_string(), - estimated_pnl: Int128::zero(), - estimated_pnl_denom: "".to_string(), - slippage: Decimal::zero().to_string(), - weight_balance_ratio: Decimal::zero().to_string(), - borrow_interest_rate: Decimal::zero().to_string(), - funding_rate: Decimal::zero().to_string(), - price_impact: Decimal::zero().to_string(), - borrow_fee: Coin::new(0, ""), - funding_fee: Coin::new(0, ""), + position: Some(position), + available_liquidity: Some(coin(0, &trading_asset)), + leverage: Some(leverage.to_string()), + collateral: Some(collateral), + trading_asset: Some(trading_asset), + discount: Some(discount.to_string()), + // TODO:Fix + interest_amount: Some(Int128::zero()), + position_size: Some(coin(1, "btc")), + swap_fee: Some(Decimal::zero().to_string()), + open_price: Some(Decimal::zero().to_string()), + take_profit_price: Some(take_profit_price.to_string()), + liquidation_price: Some(Decimal::zero().to_string()), + estimated_pnl: Some(Int128::zero()), + estimated_pnl_denom: Some("uelys".to_string()), + slippage: Some(Decimal::zero().to_string()), + weight_balance_ratio: Some(Decimal::zero().to_string()), + borrow_interest_rate: Some(Decimal::zero().to_string()), + funding_rate: Some(Decimal::zero().to_string()), + price_impact: Some(Decimal::zero().to_string()), + borrow_fee: Some(Coin::new(0, "")), + funding_fee: Some(Coin::new(0, "")), })?), //ignoring address here since we only use one user ElysQuery::PerpetualGetPositionsForAddress { .. } => { diff --git a/contracts/trade-shield-contract/src/tests/process_perpetual_order/pending_limit_open_short_with_price_met.rs b/contracts/trade-shield-contract/src/tests/process_perpetual_order/pending_limit_open_short_with_price_met.rs index 7ecaafa1..def70da3 100644 --- a/contracts/trade-shield-contract/src/tests/process_perpetual_order/pending_limit_open_short_with_price_met.rs +++ b/contracts/trade-shield-contract/src/tests/process_perpetual_order/pending_limit_open_short_with_price_met.rs @@ -114,28 +114,28 @@ impl Module for ElysModuleWrapper { take_profit_price, discount, } => Ok(to_json_binary(&PerpetualOpenEstimationRawResponse { - position, - leverage: leverage.to_string(), - trading_asset, - position_size: coin(0, ""), - collateral, - available_liquidity: coin(0, ""), - // TODO: Fix - interest_amount: Int128::zero(), - swap_fee: Decimal::zero().to_string(), - discount: discount.to_string(), - open_price: Decimal::zero().to_string(), - take_profit_price: take_profit_price.to_string(), - liquidation_price: Decimal::zero().to_string(), - estimated_pnl: Int128::zero(), - estimated_pnl_denom: "".to_string(), - slippage: Decimal::zero().to_string(), - weight_balance_ratio: Decimal::zero().to_string(), - borrow_interest_rate: Decimal::zero().to_string(), - funding_rate: Decimal::zero().to_string(), - price_impact: Decimal::zero().to_string(), - borrow_fee: Coin::new(0, ""), - funding_fee: Coin::new(0, ""), + position: Some(position), + available_liquidity: Some(coin(0, &trading_asset)), + leverage: Some(leverage.to_string()), + collateral: Some(collateral), + trading_asset: Some(trading_asset), + discount: Some(discount.to_string()), + // TODO:Fix + interest_amount: Some(Int128::zero()), + position_size: Some(coin(1, "btc")), + swap_fee: Some(Decimal::zero().to_string()), + open_price: Some(Decimal::zero().to_string()), + take_profit_price: Some(take_profit_price.to_string()), + liquidation_price: Some(Decimal::zero().to_string()), + estimated_pnl: Some(Int128::zero()), + estimated_pnl_denom: Some("uelys".to_string()), + slippage: Some(Decimal::zero().to_string()), + weight_balance_ratio: Some(Decimal::zero().to_string()), + borrow_interest_rate: Some(Decimal::zero().to_string()), + funding_rate: Some(Decimal::zero().to_string()), + price_impact: Some(Decimal::zero().to_string()), + borrow_fee: Some(Coin::new(0, "")), + funding_fee: Some(Coin::new(0, "")), })?), //ignoring address here since we only use one user ElysQuery::PerpetualGetPositionsForAddress { .. } => { diff --git a/contracts/trade-shield-contract/src/tests/process_perpetual_order/pending_limit_open_short_with_price_not_met.rs b/contracts/trade-shield-contract/src/tests/process_perpetual_order/pending_limit_open_short_with_price_not_met.rs index b81a4c21..a54e9817 100644 --- a/contracts/trade-shield-contract/src/tests/process_perpetual_order/pending_limit_open_short_with_price_not_met.rs +++ b/contracts/trade-shield-contract/src/tests/process_perpetual_order/pending_limit_open_short_with_price_not_met.rs @@ -114,28 +114,28 @@ impl Module for ElysModuleWrapper { take_profit_price, discount, } => Ok(to_json_binary(&PerpetualOpenEstimationRawResponse { - position, - leverage: leverage.to_string(), - trading_asset, - // TODO: Fix - interest_amount: Int128::zero(), - position_size: coin(0, ""), - collateral, - available_liquidity: coin(0, ""), - swap_fee: Decimal::zero().to_string(), - discount: discount.to_string(), - open_price: Decimal::zero().to_string(), - take_profit_price: take_profit_price.to_string(), - liquidation_price: Decimal::zero().to_string(), - estimated_pnl: Int128::zero(), - estimated_pnl_denom: "".to_string(), - slippage: Decimal::zero().to_string(), - weight_balance_ratio: Decimal::zero().to_string(), - borrow_interest_rate: Decimal::zero().to_string(), - funding_rate: Decimal::zero().to_string(), - price_impact: Decimal::zero().to_string(), - borrow_fee: Coin::new(0, ""), - funding_fee: Coin::new(0, ""), + position: Some(position), + available_liquidity: Some(coin(0, &trading_asset)), + leverage: Some(leverage.to_string()), + collateral: Some(collateral), + trading_asset: Some(trading_asset), + discount: Some(discount.to_string()), + // TODO:Fix + interest_amount: Some(Int128::zero()), + position_size: Some(coin(1, "btc")), + swap_fee: Some(Decimal::zero().to_string()), + open_price: Some(Decimal::zero().to_string()), + take_profit_price: Some(take_profit_price.to_string()), + liquidation_price: Some(Decimal::zero().to_string()), + estimated_pnl: Some(Int128::zero()), + estimated_pnl_denom: Some("uelys".to_string()), + slippage: Some(Decimal::zero().to_string()), + weight_balance_ratio: Some(Decimal::zero().to_string()), + borrow_interest_rate: Some(Decimal::zero().to_string()), + funding_rate: Some(Decimal::zero().to_string()), + price_impact: Some(Decimal::zero().to_string()), + borrow_fee: Some(Coin::new(0, "")), + funding_fee: Some(Coin::new(0, "")), })?), //ignoring address here since we only use one user ElysQuery::PerpetualGetPositionsForAddress { .. } => {