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 DEV-1735-cannot-add-collateral
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptokage1996 authored Sep 19, 2024
2 parents e383696 + 613af4c commit 786470d
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 9 deletions.
7 changes: 6 additions & 1 deletion bindings-test/src/multitest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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 };
Expand Down
12 changes: 11 additions & 1 deletion bindings-test/src/tests.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down
5 changes: 5 additions & 0 deletions bindings/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u64>,
pub last_interest_calc_block: Option<u64>,
pub last_funding_calc_time: Option<u64>,
pub last_funding_calc_block: Option<u64>,
}

#[cw_serde]
Expand Down
Original file line number Diff line number Diff line change
@@ -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::*;
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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,
}],
)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 };
Expand Down
4 changes: 4 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions scripts/queries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -490,6 +499,9 @@ case "$2" in
"parameter_params")
parameter_params
;;
"perpetual_assets")
perpetual_assets
;;
*)
# Default case: run all functions
ts_params
Expand Down

0 comments on commit 786470d

Please sign in to comment.