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

Commit 6092be9

Browse files
feat:add missing fields (#445)
* feat:add missing fields * feat: add toolchain info * feat: add query script for perpetual assets
1 parent 1851fcd commit 6092be9

File tree

12 files changed

+80
-9
lines changed

12 files changed

+80
-9
lines changed

bindings-test/src/multitest.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use cosmwasm_std::{
1111
to_json_binary, Addr, BankMsg, BlockInfo, Coin, Decimal, Empty, Int64, Querier, StdError,
1212
StdResult, Storage,
1313
};
14-
use cosmwasm_std::{Int128, SignedDecimal, Uint128};
14+
use cosmwasm_std::{Int128, SignedDecimal, Uint128, Uint64};
1515
use cw_multi_test::{App, AppResponse, BankKeeper, BankSudo, BasicAppBuilder, Module, WasmKeeper};
1616
use cw_storage_plus::Item;
1717
use elys_bindings::{
@@ -801,6 +801,11 @@ impl Module for ElysModule {
801801
take_profit_borrow_rate: SignedDecimal::zero(),
802802
take_profit_custody: Int128::zero(),
803803
trading_asset,
804+
stop_loss_price: SignedDecimal::zero(),
805+
last_interest_calc_time: Uint64::zero().into(),
806+
last_interest_calc_block: Uint64::zero().into(),
807+
last_funding_calc_time: Uint64::zero().into(),
808+
last_funding_calc_block: Uint64::zero().into(),
804809
};
805810

806811
let msg_resp = PerpetualOpenResponse { id: mtp.id };

bindings-test/src/tests.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use cosmwasm_std::{
22
coin, coins, Addr, Coin, Decimal, Int128, Int64, SignedDecimal, SignedDecimal256, StdError,
3-
Uint128,
3+
Uint128, Uint64,
44
};
55
use cw_multi_test::Executor;
66
use elys_bindings::{
@@ -155,6 +155,11 @@ fn query_positions() {
155155
take_profit_borrow_rate: SignedDecimal::zero(),
156156
take_profit_custody: Int128::zero(),
157157
trading_asset: "".to_string(),
158+
stop_loss_price: SignedDecimal::zero(),
159+
last_interest_calc_time: Uint64::zero().into(),
160+
last_interest_calc_block: Uint64::zero().into(),
161+
last_funding_calc_time: Uint64::zero().into(),
162+
last_funding_calc_block: Uint64::zero().into(),
158163
}];
159164
let mut app = ElysApp::new();
160165

@@ -198,6 +203,11 @@ fn query_single_mtp() {
198203
take_profit_borrow_rate: SignedDecimal::zero(),
199204
take_profit_custody: Int128::zero(),
200205
trading_asset: "".to_string(),
206+
stop_loss_price: SignedDecimal::zero(),
207+
last_interest_calc_time: Uint64::zero().into(),
208+
last_interest_calc_block: Uint64::zero().into(),
209+
last_funding_calc_time: Uint64::zero().into(),
210+
last_funding_calc_block: Uint64::zero().into(),
201211
}];
202212
let mut app = ElysApp::new();
203213

bindings/src/types.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,11 @@ pub struct Mtp {
286286
pub take_profit_liabilities: Int128,
287287
pub take_profit_price: SignedDecimal256,
288288
pub trading_asset: String,
289+
pub stop_loss_price: SignedDecimal,
290+
pub last_interest_calc_time: u64,
291+
pub last_interest_calc_block: u64,
292+
pub last_funding_calc_time: u64,
293+
pub last_funding_calc_block: u64,
289294
}
290295

291296
#[cw_serde]

contracts/trade-shield-contract/src/tests/close_perpetual_position/closing_a_perpetual_position.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use cosmwasm_std::{Int128, SignedDecimal, SignedDecimal256};
1+
use cosmwasm_std::{Int128, SignedDecimal, SignedDecimal256, Uint64};
22
use elys_bindings::{query_resp::PerpetualGetPositionsForAddressResponse, ElysQuery};
33

44
use super::*;
@@ -35,6 +35,11 @@ fn closing_perpetualg_position() {
3535
take_profit_liabilities: Int128::zero(),
3636
take_profit_price: SignedDecimal256::from_str("30").unwrap(),
3737
trading_asset: "uatom".to_string(),
38+
stop_loss_price: SignedDecimal::zero(),
39+
last_interest_calc_time: Uint64::zero().into(),
40+
last_interest_calc_block: Uint64::zero().into(),
41+
last_funding_calc_time: Uint64::zero().into(),
42+
last_funding_calc_block: Uint64::zero().into(),
3843
}];
3944

4045
// Create a mock message to instantiate the contract with no initial orders.

contracts/trade-shield-contract/src/tests/create_perpetual_order/change_trigger_price.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use cosmwasm_std::{Addr, Decimal, Int128, SignedDecimal, SignedDecimal256};
1+
use cosmwasm_std::{Addr, Decimal, Int128, SignedDecimal, SignedDecimal256, Uint64};
22
use elys_bindings::trade_shield::msg::query_resp::GetPerpetualOrderResp;
33
use std::str::FromStr;
44

@@ -50,6 +50,11 @@ fn successful_create_perpetual_order() {
5050
take_profit_liabilities: Int128::zero(),
5151
take_profit_price: SignedDecimal256::from_str("0.28").unwrap(),
5252
trading_asset: "uelys".to_owned(),
53+
stop_loss_price: SignedDecimal::zero(),
54+
last_interest_calc_time: Uint64::zero().into(),
55+
last_interest_calc_block: Uint64::zero().into(),
56+
last_funding_calc_time: Uint64::zero().into(),
57+
last_funding_calc_block: Uint64::zero().into(),
5358
}];
5459

5560
app.init_modules(|router, _, store| router.custom.set_mtp(store, &mtps))

contracts/trade-shield-contract/src/tests/create_perpetual_order/successful_create_perpetual_market_close.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use cosmwasm_std::{Addr, SignedDecimal, SignedDecimal256};
1+
use cosmwasm_std::{Addr, SignedDecimal, SignedDecimal256, Uint64};
22
use std::str::FromStr;
33

44
use cosmwasm_std::Int128;
@@ -63,6 +63,11 @@ fn successful_create_perpetual_market_open_order() {
6363
take_profit_borrow_rate: SignedDecimal::one(),
6464
take_profit_custody: Int128::zero(),
6565
trading_asset: "usdc".to_string(),
66+
stop_loss_price: SignedDecimal::zero(),
67+
last_interest_calc_time: Uint64::zero().into(),
68+
last_interest_calc_block: Uint64::zero().into(),
69+
last_funding_calc_time: Uint64::zero().into(),
70+
last_funding_calc_block: Uint64::zero().into(),
6671
}],
6772
)
6873
})

contracts/trade-shield-contract/src/tests/process_perpetual_order/pending_limit_open_long_with_price_met.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::tests::get_order_id_from_events::get_attr_from_events;
55
use anyhow::{bail, Result as AnyResult};
66
use cosmwasm_std::{
77
coin, coins, to_json_binary, Addr, BankMsg, Decimal, Empty, Int128, SignedDecimal,
8-
SignedDecimal256, StdError,
8+
SignedDecimal256, StdError, Uint64,
99
};
1010
use cw_multi_test::{AppResponse, BasicAppBuilder, ContractWrapper, Executor, Module};
1111
use elys_bindings::msg_resp::PerpetualOpenResponse;
@@ -230,6 +230,11 @@ impl Module for ElysModuleWrapper {
230230
take_profit_borrow_rate: SignedDecimal::zero(),
231231
take_profit_custody: Int128::zero(),
232232
trading_asset,
233+
stop_loss_price: SignedDecimal::zero(),
234+
last_interest_calc_time: Uint64::zero().into(),
235+
last_interest_calc_block: Uint64::zero().into(),
236+
last_funding_calc_time: Uint64::zero().into(),
237+
last_funding_calc_block: Uint64::zero().into(),
233238
};
234239

235240
let msg_resp = PerpetualOpenResponse { id: mtp.id };

contracts/trade-shield-contract/src/tests/process_perpetual_order/pending_limit_open_long_with_price_not_met.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::tests::get_order_id_from_events::get_attr_from_events;
55
use anyhow::{bail, Result as AnyResult};
66
use cosmwasm_std::{
77
coin, coins, to_json_binary, Addr, BankMsg, Decimal, Empty, Int128, SignedDecimal,
8-
SignedDecimal256, StdError,
8+
SignedDecimal256, StdError, Uint64,
99
};
1010
use cw_multi_test::{AppResponse, BasicAppBuilder, ContractWrapper, Executor, Module};
1111
use elys_bindings::msg_resp::PerpetualOpenResponse;
@@ -230,6 +230,11 @@ impl Module for ElysModuleWrapper {
230230
take_profit_borrow_rate: SignedDecimal::zero(),
231231
take_profit_custody: Int128::zero(),
232232
trading_asset,
233+
stop_loss_price: SignedDecimal::zero(),
234+
last_interest_calc_time: Uint64::zero().into(),
235+
last_interest_calc_block: Uint64::zero().into(),
236+
last_funding_calc_time: Uint64::zero().into(),
237+
last_funding_calc_block: Uint64::zero().into(),
233238
};
234239

235240
let msg_resp = PerpetualOpenResponse { id: mtp.id };

contracts/trade-shield-contract/src/tests/process_perpetual_order/pending_limit_open_short_with_price_met.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::tests::get_order_id_from_events::get_attr_from_events;
55
use anyhow::{bail, Result as AnyResult};
66
use cosmwasm_std::{
77
coin, coins, to_json_binary, Addr, BankMsg, Decimal, Empty, Int128, SignedDecimal,
8-
SignedDecimal256, StdError,
8+
SignedDecimal256, StdError, Uint64,
99
};
1010
use cw_multi_test::{AppResponse, BasicAppBuilder, ContractWrapper, Executor, Module};
1111
use elys_bindings::msg_resp::PerpetualOpenResponse;
@@ -230,6 +230,11 @@ impl Module for ElysModuleWrapper {
230230
take_profit_borrow_rate: SignedDecimal::zero(),
231231
take_profit_custody: Int128::zero(),
232232
trading_asset,
233+
stop_loss_price: SignedDecimal::zero(),
234+
last_interest_calc_time: Uint64::zero().into(),
235+
last_interest_calc_block: Uint64::zero().into(),
236+
last_funding_calc_time: Uint64::zero().into(),
237+
last_funding_calc_block: Uint64::zero().into(),
233238
};
234239

235240
let msg_resp = PerpetualOpenResponse { id: mtp.id };

contracts/trade-shield-contract/src/tests/process_perpetual_order/pending_limit_open_short_with_price_not_met.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::tests::get_order_id_from_events::get_attr_from_events;
55
use anyhow::{bail, Result as AnyResult};
66
use cosmwasm_std::{
77
coin, coins, to_json_binary, Addr, BankMsg, Decimal, Empty, Int128, SignedDecimal,
8-
SignedDecimal256, StdError,
8+
SignedDecimal256, StdError, Uint64,
99
};
1010
use cw_multi_test::{AppResponse, BasicAppBuilder, ContractWrapper, Executor, Module};
1111
use elys_bindings::msg_resp::PerpetualOpenResponse;
@@ -230,6 +230,11 @@ impl Module for ElysModuleWrapper {
230230
take_profit_borrow_rate: SignedDecimal::zero(),
231231
take_profit_custody: Int128::zero(),
232232
trading_asset,
233+
stop_loss_price: SignedDecimal::zero(),
234+
last_interest_calc_time: Uint64::zero().into(),
235+
last_interest_calc_block: Uint64::zero().into(),
236+
last_funding_calc_time: Uint64::zero().into(),
237+
last_funding_calc_block: Uint64::zero().into(),
233238
};
234239

235240
let msg_resp = PerpetualOpenResponse { id: mtp.id };

0 commit comments

Comments
 (0)