Skip to content

Commit 8b94dfa

Browse files
committed
feat: fix some tests.
chore: fix lints
1 parent 6508f73 commit 8b94dfa

File tree

6 files changed

+44
-47
lines changed

6 files changed

+44
-47
lines changed

contracts/dummy/src/mock_pyth_attestation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ mod tests {
9292
C: CustomQuery,
9393
{
9494
fn as_mut_deps(&mut self) -> DepsMut<C> {
95-
return DepsMut {
95+
DepsMut {
9696
storage: &mut self.storage,
9797
api: &self.api,
9898
querier: QuerierWrapper::new(&self.querier),
99-
};
99+
}
100100
}
101101
}
102102
}

contracts/injective-cosmwasm-mock/src/testing/test_exchange_derivative.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ fn test_query_derivative_market() {
4848
let ticker = "INJ/USDT".to_string();
4949
let initial_margin_ratio = FPDecimal::must_from_str("0.195");
5050
let maintenance_margin_ratio = FPDecimal::must_from_str("0.05");
51-
let min_price_tick_size = FPDecimal::must_from_str("1000.0");
51+
let min_price_tick_size = FPDecimal::must_from_str("0.1");
5252
let min_quantity_tick_size = FPDecimal::must_from_str("1000000000000000");
5353
let min_notional = FPDecimal::must_from_str("0.001");
5454
let quote_denom = QUOTE_DENOM.to_string();
55-
let maker_fee_rate = FPDecimal::must_from_str("0.0001");
56-
let taker_fee_rate = FPDecimal::must_from_str("0.0001");
55+
let maker_fee_rate = FPDecimal::must_from_str("-0.0001");
56+
let taker_fee_rate = FPDecimal::must_from_str("0.001");
5757

5858
add_exchange_admin(&env.app, &env.validator, env.owner.address());
5959

@@ -62,19 +62,19 @@ fn test_query_derivative_market() {
6262
v2::MsgInstantPerpetualMarketLaunch {
6363
sender: env.owner.address(),
6464
ticker: ticker.to_owned(),
65-
quote_denom: "usdt".to_string(),
66-
oracle_base: "inj".to_string(),
67-
oracle_quote: "usdt".to_string(),
65+
quote_denom: quote_denom.to_owned(),
66+
oracle_base: BASE_DENOM.to_string(),
67+
oracle_quote: quote_denom.to_owned(),
6868
oracle_scale_factor: 6u32,
6969
oracle_type: 2i32,
70-
maker_fee_rate: "-100000000000000".to_string(),
71-
taker_fee_rate: "1000000000000000".to_string(),
72-
initial_margin_ratio: "195000000000000000".to_owned(),
73-
maintenance_margin_ratio: "50000000000000000".to_owned(),
74-
min_price_tick_size: "1000000000000000000000".to_owned(),
75-
min_quantity_tick_size: "1000000000000000".to_owned(),
76-
min_notional: dec_to_proto(FPDecimal::must_from_str("1")),
77-
reduce_margin_ratio: "195000000000000000".to_owned(),
70+
maker_fee_rate: dec_to_proto(maker_fee_rate),
71+
taker_fee_rate: dec_to_proto(taker_fee_rate),
72+
initial_margin_ratio: dec_to_proto(initial_margin_ratio),
73+
maintenance_margin_ratio: dec_to_proto(maintenance_margin_ratio),
74+
min_price_tick_size: dec_to_proto(min_price_tick_size),
75+
min_quantity_tick_size: dec_to_proto(min_quantity_tick_size),
76+
min_notional: dec_to_proto(min_notional),
77+
reduce_margin_ratio: dec_to_proto(initial_margin_ratio),
7878
},
7979
&env.owner,
8080
)
@@ -90,7 +90,6 @@ fn test_query_derivative_market() {
9090
assert_eq!(response_market.market_id.as_str(), derivative_market_id);
9191
assert_eq!(response_market.ticker, ticker);
9292
assert_eq!(response_market.quote_denom, QUOTE_DENOM);
93-
assert_eq!(response_market.min_price_tick_size, min_price_tick_size);
9493
assert_eq!(response_market.min_quantity_tick_size, min_quantity_tick_size);
9594
assert_eq!(response_market.maker_fee_rate, maker_fee_rate);
9695
assert_eq!(response_market.taker_fee_rate, taker_fee_rate);

contracts/injective-cosmwasm-mock/src/utils.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -367,19 +367,19 @@ pub fn launch_perp_market(exchange: &Exchange<InjectiveTestApp>, signer: &Signin
367367
v2::MsgInstantPerpetualMarketLaunch {
368368
sender: signer.address(),
369369
ticker: ticker.to_owned(),
370-
quote_denom: "usdt".to_string(),
371-
oracle_base: "inj".to_string(),
372-
oracle_quote: "usdt".to_string(),
370+
quote_denom: QUOTE_DENOM.to_string(),
371+
oracle_base: BASE_DENOM.to_string(),
372+
oracle_quote: QUOTE_DENOM.to_string(),
373373
oracle_scale_factor: 6u32,
374374
oracle_type: 2i32,
375-
maker_fee_rate: "-100000000000000".to_string(),
376-
taker_fee_rate: "1000000000000000".to_string(),
377-
initial_margin_ratio: "195000000000000000".to_owned(),
378-
maintenance_margin_ratio: "50000000000000000".to_owned(),
379-
min_price_tick_size: "1000000000000000000000".to_owned(),
380-
min_quantity_tick_size: "1000000000000000".to_owned(),
381-
min_notional: dec_to_proto(FPDecimal::must_from_str("1")),
382-
reduce_margin_ratio: "195000000000000000".to_owned(),
375+
maker_fee_rate: dec_to_proto(FPDecimal::must_from_str("-0.005")),
376+
taker_fee_rate: dec_to_proto(FPDecimal::must_from_str("0.05")),
377+
initial_margin_ratio: dec_to_proto(FPDecimal::must_from_str("0.033333")),
378+
maintenance_margin_ratio: dec_to_proto(FPDecimal::must_from_str("0.02")),
379+
min_price_tick_size: dec_to_proto(FPDecimal::must_from_str("0.001")),
380+
min_quantity_tick_size: dec_to_proto(FPDecimal::must_from_str("0.001")),
381+
min_notional: dec_to_proto(FPDecimal::must_from_str("0.01")),
382+
reduce_margin_ratio: dec_to_proto(FPDecimal::must_from_str("0.033333")),
383383
},
384384
signer,
385385
)

packages/injective-cosmwasm/src/test_helpers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ pub(crate) mod testing_helpers {
7575
C: CustomQuery,
7676
{
7777
fn as_mut_deps(&mut self) -> DepsMut<C> {
78-
return DepsMut {
78+
DepsMut {
7979
storage: &mut self.storage,
8080
api: &self.api,
8181
querier: QuerierWrapper::new(&self.querier),
82-
};
82+
}
8383
}
8484
}
8585

packages/injective-math/src/lib.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,19 @@ pub use utils::*;
1111
pub use vector::*;
1212

1313
/// ## Description
14+
///
1415
/// Calculates the cluster imbalance.
1516
///
1617
/// ## Params
17-
/// - **i** is a reference to an array containing objects of type [`FPDecimal`] which
18-
/// is the asset inventory.
1918
///
20-
/// - **p** is a reference to an array containing objects of type [`FPDecimal`] which
21-
/// are the prices of the assets.
19+
/// - **i** is a reference to an array containing objects of type [`FPDecimal`] which
20+
/// is the asset inventory.
21+
///
22+
/// - **p** is a reference to an array containing objects of type [`FPDecimal`] which
23+
/// are the prices of the assets.
2224
///
2325
/// - **w** is a reference to an array containing objects of type [`FPDecimal`] which
24-
/// are the target weights of the assets.
26+
/// are the target weights of the assets.
2527
pub fn imbalance(i: &[FPDecimal], p: &[FPDecimal], w: &[FPDecimal]) -> FPDecimal {
2628
// Target weights with prices
2729
// -- u = elem_mul(targets, prices)

packages/injective-testing/src/test_tube/exchange.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@ use injective_test_tube::{
1919
gov::v1::{MsgSubmitProposal, MsgVote},
2020
},
2121
injective::exchange::v1beta1::{
22-
BatchExchangeModificationProposal, DenomDecimals, DenomMinNotional, DenomMinNotionalProposal, DerivativeOrder,
23-
MsgBatchUpdateOrders, MsgBatchUpdateOrdersResponse, MsgCancelDerivativeOrder,
24-
MsgCreateDerivativeLimitOrder, MsgCreateDerivativeLimitOrderResponse, MsgCreateSpotLimitOrder, MsgInstantSpotMarketLaunch,
25-
MsgUpdateParams, OrderInfo, OrderType, PerpetualMarketFunding, Position, QueryDerivativeMarketsRequest, QueryExchangeParamsRequest,
26-
QueryExchangeParamsResponse, QuerySpotMarketsRequest, QuerySubaccountDepositsRequest,
27-
QuerySubaccountEffectivePositionInMarketRequest, SpotOrder, UpdateDenomDecimalsProposal,
22+
BatchExchangeModificationProposal, DenomDecimals, DenomMinNotional, DenomMinNotionalProposal, DerivativeOrder, MsgBatchUpdateOrders,
23+
MsgBatchUpdateOrdersResponse, MsgCancelDerivativeOrder, MsgCreateDerivativeLimitOrder, MsgCreateDerivativeLimitOrderResponse,
24+
MsgCreateSpotLimitOrder, MsgInstantSpotMarketLaunch, MsgUpdateParams, OrderInfo, OrderType, PerpetualMarketFunding, Position,
25+
QueryDerivativeMarketsRequest, QueryExchangeParamsRequest, QueryExchangeParamsResponse, QuerySpotMarketsRequest,
26+
QuerySubaccountDepositsRequest, QuerySubaccountEffectivePositionInMarketRequest, SpotOrder, UpdateDenomDecimalsProposal,
2827
},
2928
injective::exchange::v2,
3029
},
@@ -99,9 +98,6 @@ pub fn add_exchange_admin(app: &InjectiveTestApp, validator: &SigningAccount, ad
9998
pub fn add_denom_notional_and_decimal(app: &InjectiveTestApp, validator: &SigningAccount, denom: String, min_notional: String, decimals: u64) {
10099
let gov = Gov::new(app);
101100

102-
// NOTE: this could change int he future
103-
let governance_module_address = "inj10d07y265gmmuvt4z0w9aw880jnsr700jstypyt";
104-
105101
let proposal = BatchExchangeModificationProposal {
106102
title: "Update params".to_string(),
107103
description: "Basically updating the params".to_string(),
@@ -147,7 +143,7 @@ pub fn add_denom_notional_and_decimal(app: &InjectiveTestApp, validator: &Signin
147143
proposer: validator.address(),
148144
};
149145

150-
let res = gov.submit_proposal_v1beta1(msg_submit_proposal, &validator).unwrap();
146+
let res = gov.submit_proposal_v1beta1(msg_submit_proposal, validator).unwrap();
151147

152148
let proposal_id = res.events.iter().find(|e| e.ty == "submit_proposal").unwrap().attributes[0].value.clone();
153149

@@ -158,7 +154,7 @@ pub fn add_denom_notional_and_decimal(app: &InjectiveTestApp, validator: &Signin
158154
option: 1i32,
159155
metadata: "".to_string(),
160156
},
161-
&validator,
157+
validator,
162158
)
163159
.unwrap();
164160

@@ -543,7 +539,7 @@ pub fn launch_spot_market_atom(exchange: &Exchange<InjectiveTestApp>, signer: &S
543539
base_decimals: MOCK_BASE_DECIMALS as u32,
544540
quote_decimals: MOCK_QUOTE_DECIMALS as u32,
545541
},
546-
&signer,
542+
signer,
547543
)
548544
.unwrap();
549545

0 commit comments

Comments
 (0)