diff --git a/bindings-test/src/multitest.rs b/bindings-test/src/multitest.rs index a9e7d9dd..9b37ea50 100644 --- a/bindings-test/src/multitest.rs +++ b/bindings-test/src/multitest.rs @@ -11,7 +11,7 @@ use cosmwasm_std::{ to_json_binary, Addr, BankMsg, BlockInfo, Coin, Decimal, Empty, Int64, Querier, StdError, StdResult, Storage, }; -use cosmwasm_std::{Int128, SignedDecimal, Uint128}; +use cosmwasm_std::{Int128, SignedDecimal, Uint128, Uint64}; use cw_multi_test::{App, AppResponse, BankKeeper, BankSudo, BasicAppBuilder, Module, WasmKeeper}; use cw_storage_plus::Item; use elys_bindings::{ @@ -801,6 +801,11 @@ impl Module for ElysModule { take_profit_borrow_rate: SignedDecimal::zero(), take_profit_custody: Int128::zero(), trading_asset, + stop_loss_price: SignedDecimal::zero(), + last_interest_calc_time: None, + last_interest_calc_block: None, + last_funding_calc_time: None, + last_funding_calc_block: None, }; let msg_resp = PerpetualOpenResponse { id: mtp.id }; diff --git a/bindings-test/src/tests.rs b/bindings-test/src/tests.rs index 6dc16ed1..c50be252 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, + Uint128, Uint64, }; use cw_multi_test::Executor; use elys_bindings::{ @@ -155,6 +155,11 @@ fn query_positions() { take_profit_borrow_rate: SignedDecimal::zero(), take_profit_custody: Int128::zero(), trading_asset: "".to_string(), + stop_loss_price: SignedDecimal::zero(), + last_interest_calc_time: None, + last_interest_calc_block: None, + last_funding_calc_time: None, + last_funding_calc_block: None, }]; let mut app = ElysApp::new(); @@ -198,6 +203,11 @@ fn query_single_mtp() { take_profit_borrow_rate: SignedDecimal::zero(), take_profit_custody: Int128::zero(), trading_asset: "".to_string(), + stop_loss_price: SignedDecimal::zero(), + last_interest_calc_time: None, + last_interest_calc_block: None, + last_funding_calc_time: None, + last_funding_calc_block: None, }]; let mut app = ElysApp::new(); diff --git a/bindings/src/types.rs b/bindings/src/types.rs index c123b386..f8968b7e 100644 --- a/bindings/src/types.rs +++ b/bindings/src/types.rs @@ -286,6 +286,11 @@ pub struct Mtp { 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, + pub last_funding_calc_time: Option, + pub last_funding_calc_block: Option, } #[cw_serde] diff --git a/contracts/trade-shield-contract/src/tests/close_perpetual_position/closing_a_perpetual_position.rs b/contracts/trade-shield-contract/src/tests/close_perpetual_position/closing_a_perpetual_position.rs index 939092d9..e7a0fd74 100644 --- a/contracts/trade-shield-contract/src/tests/close_perpetual_position/closing_a_perpetual_position.rs +++ b/contracts/trade-shield-contract/src/tests/close_perpetual_position/closing_a_perpetual_position.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{Int128, SignedDecimal, SignedDecimal256}; +use cosmwasm_std::{Int128, SignedDecimal, SignedDecimal256, Uint64}; use elys_bindings::{query_resp::PerpetualGetPositionsForAddressResponse, ElysQuery}; use super::*; @@ -35,6 +35,11 @@ fn closing_perpetualg_position() { take_profit_liabilities: Int128::zero(), take_profit_price: SignedDecimal256::from_str("30").unwrap(), trading_asset: "uatom".to_string(), + stop_loss_price: SignedDecimal::zero(), + last_interest_calc_time: None, + last_interest_calc_block: None, + last_funding_calc_time: None, + last_funding_calc_block: None, }]; // Create a mock message to instantiate the contract with no initial orders. diff --git a/contracts/trade-shield-contract/src/tests/create_perpetual_order/change_trigger_price.rs b/contracts/trade-shield-contract/src/tests/create_perpetual_order/change_trigger_price.rs index d768b982..b615abe9 100644 --- a/contracts/trade-shield-contract/src/tests/create_perpetual_order/change_trigger_price.rs +++ b/contracts/trade-shield-contract/src/tests/create_perpetual_order/change_trigger_price.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{Addr, Decimal, Int128, SignedDecimal, SignedDecimal256}; +use cosmwasm_std::{Addr, Decimal, Int128, SignedDecimal, SignedDecimal256, Uint64}; use elys_bindings::trade_shield::msg::query_resp::GetPerpetualOrderResp; use std::str::FromStr; @@ -50,6 +50,11 @@ fn successful_create_perpetual_order() { take_profit_liabilities: Int128::zero(), take_profit_price: SignedDecimal256::from_str("0.28").unwrap(), trading_asset: "uelys".to_owned(), + stop_loss_price: SignedDecimal::zero(), + last_interest_calc_time: None, + last_interest_calc_block: None, + last_funding_calc_time: None, + last_funding_calc_block: None, }]; app.init_modules(|router, _, store| router.custom.set_mtp(store, &mtps)) diff --git a/contracts/trade-shield-contract/src/tests/create_perpetual_order/successful_create_perpetual_market_close.rs b/contracts/trade-shield-contract/src/tests/create_perpetual_order/successful_create_perpetual_market_close.rs index 4a7a67f1..7a491123 100644 --- a/contracts/trade-shield-contract/src/tests/create_perpetual_order/successful_create_perpetual_market_close.rs +++ b/contracts/trade-shield-contract/src/tests/create_perpetual_order/successful_create_perpetual_market_close.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{Addr, SignedDecimal, SignedDecimal256}; +use cosmwasm_std::{Addr, SignedDecimal, SignedDecimal256, Uint64}; use std::str::FromStr; use cosmwasm_std::Int128; @@ -63,6 +63,11 @@ fn successful_create_perpetual_market_open_order() { take_profit_borrow_rate: SignedDecimal::one(), take_profit_custody: Int128::zero(), trading_asset: "usdc".to_string(), + stop_loss_price: SignedDecimal::zero(), + last_interest_calc_time: None, + last_interest_calc_block: None, + last_funding_calc_time: None, + last_funding_calc_block: None, }], ) }) 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 f029afea..d328d416 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 @@ -5,7 +5,7 @@ use crate::tests::get_order_id_from_events::get_attr_from_events; use anyhow::{bail, Result as AnyResult}; use cosmwasm_std::{ coin, coins, to_json_binary, Addr, BankMsg, Decimal, Empty, Int128, SignedDecimal, - SignedDecimal256, StdError, + SignedDecimal256, StdError, Uint64, }; use cw_multi_test::{AppResponse, BasicAppBuilder, ContractWrapper, Executor, Module}; use elys_bindings::msg_resp::PerpetualOpenResponse; @@ -230,6 +230,11 @@ impl Module for ElysModuleWrapper { take_profit_borrow_rate: SignedDecimal::zero(), take_profit_custody: Int128::zero(), trading_asset, + stop_loss_price: SignedDecimal::zero(), + last_interest_calc_time: None, + last_interest_calc_block: None, + last_funding_calc_time: None, + last_funding_calc_block: None, }; let msg_resp = PerpetualOpenResponse { id: mtp.id }; 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 5141f7ee..73114a3d 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 @@ -5,7 +5,7 @@ use crate::tests::get_order_id_from_events::get_attr_from_events; use anyhow::{bail, Result as AnyResult}; use cosmwasm_std::{ coin, coins, to_json_binary, Addr, BankMsg, Decimal, Empty, Int128, SignedDecimal, - SignedDecimal256, StdError, + SignedDecimal256, StdError, Uint64, }; use cw_multi_test::{AppResponse, BasicAppBuilder, ContractWrapper, Executor, Module}; use elys_bindings::msg_resp::PerpetualOpenResponse; @@ -230,6 +230,11 @@ impl Module for ElysModuleWrapper { take_profit_borrow_rate: SignedDecimal::zero(), take_profit_custody: Int128::zero(), trading_asset, + stop_loss_price: SignedDecimal::zero(), + last_interest_calc_time: None, + last_interest_calc_block: None, + last_funding_calc_time: None, + last_funding_calc_block: None, }; let msg_resp = PerpetualOpenResponse { id: mtp.id }; 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 5a300ce5..6b056a82 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 @@ -5,7 +5,7 @@ use crate::tests::get_order_id_from_events::get_attr_from_events; use anyhow::{bail, Result as AnyResult}; use cosmwasm_std::{ coin, coins, to_json_binary, Addr, BankMsg, Decimal, Empty, Int128, SignedDecimal, - SignedDecimal256, StdError, + SignedDecimal256, StdError, Uint64, }; use cw_multi_test::{AppResponse, BasicAppBuilder, ContractWrapper, Executor, Module}; use elys_bindings::msg_resp::PerpetualOpenResponse; @@ -230,6 +230,11 @@ impl Module for ElysModuleWrapper { take_profit_borrow_rate: SignedDecimal::zero(), take_profit_custody: Int128::zero(), trading_asset, + stop_loss_price: SignedDecimal::zero(), + last_interest_calc_time: None, + last_interest_calc_block: None, + last_funding_calc_time: None, + last_funding_calc_block: None, }; let msg_resp = PerpetualOpenResponse { id: mtp.id }; 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 c749294d..7a13f3aa 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 @@ -5,7 +5,7 @@ use crate::tests::get_order_id_from_events::get_attr_from_events; use anyhow::{bail, Result as AnyResult}; use cosmwasm_std::{ coin, coins, to_json_binary, Addr, BankMsg, Decimal, Empty, Int128, SignedDecimal, - SignedDecimal256, StdError, + SignedDecimal256, StdError, Uint64, }; use cw_multi_test::{AppResponse, BasicAppBuilder, ContractWrapper, Executor, Module}; use elys_bindings::msg_resp::PerpetualOpenResponse; @@ -230,6 +230,11 @@ impl Module for ElysModuleWrapper { take_profit_borrow_rate: SignedDecimal::zero(), take_profit_custody: Int128::zero(), trading_asset, + stop_loss_price: SignedDecimal::zero(), + last_interest_calc_time: None, + last_interest_calc_block: None, + last_funding_calc_time: None, + last_funding_calc_block: None, }; let msg_resp = PerpetualOpenResponse { id: mtp.id }; diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 00000000..ef0f92b2 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "1.79.0" # or "nightly", "beta", or a specific version like "1.56.0" +components = ["rustfmt", "clippy"] # optional, specify additional components +targets = ["wasm32-unknown-unknown"] # optional, specify additional targets diff --git a/scripts/queries.sh b/scripts/queries.sh index 48e65f16..4a240e99 100755 --- a/scripts/queries.sh +++ b/scripts/queries.sh @@ -362,6 +362,15 @@ query_contract "$ts_contract_address" '{ }' } +function perpetual_assets() { + printf "\n# Get Perpetual Assets" +query_contract "$ts_contract_address" '{ + "get_perpetual_asset": { + "address" : "'"$user_address"'" + } +}' +} + # function(s) to run based on the provided argument case "$2" in "swap_estimation_by_denom_elys_usdc_elys") @@ -490,6 +499,9 @@ case "$2" in "parameter_params") parameter_params ;; +"perpetual_assets") + perpetual_assets + ;; *) # Default case: run all functions ts_params