Skip to content

Commit 54405b5

Browse files
committed
feat: initial version bump
1 parent ea2201f commit 54405b5

File tree

13 files changed

+110
-4149
lines changed

13 files changed

+110
-4149
lines changed

Cargo.lock

Lines changed: 0 additions & 4025 deletions
This file was deleted.

Cargo.toml

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,33 @@ incremental = false
99
[workspace.dependencies]
1010
anyhow = { version = "1.0.66" }
1111
base64 = { version = "0.21.5" }
12-
chrono = { version = "0.4.27", default-features = false }
1312
cosmos-sdk-proto = { version = "0.20.0", default-features = false }
1413
cosmwasm-schema = { version = "1.5.0" }
1514
cosmwasm-std = { version = "2.1.0", features = [ "abort", "cosmwasm_1_2", "cosmwasm_1_3", "cosmwasm_1_4", "cosmwasm_2_0", "iterator", "stargate" ] }
16-
cosmwasm-storage = { version = "1.5.2", features = [ "iterator" ] }
1715
cw-multi-test = { version = "2.1.0" }
1816
cw-storage-plus = { version = "2.0.0" }
19-
cw-utils = { version = "2.0.0" }
2017
cw2 = { version = "2.0.0" }
2118
ethereum-types = { version = "0.5.2" }
2219
hex = { version = "0.4.3", features = [ "serde" ] }
23-
injective-cosmwasm = { version = "0.3.0", path = "./packages/injective-cosmwasm" }
24-
injective-math = { version = "0.3.1", path = "./packages/injective-math" }
25-
injective-std = { version = "1.15.0-beta"}
26-
injective-std-derive = { version = "1.13.4"}
27-
injective-test-tube = { version = "1.15.0-beta" }
20+
injective-cosmwasm = { path = "./packages/injective-cosmwasm" }
21+
injective-math = { path = "./packages/injective-math" }
22+
injective-std = { version = "1.16.0-beta.2"}
23+
injective-test-tube = { path = "" }
2824
injective-testing = { version = "1.1.4", path = "./packages/injective-testing" }
29-
itertools = { version = "0.10.3" }
3025
primitive-types = { version = "0.12.2", default-features = false }
31-
proc-macro2 = { version = "1.0.40" }
3226
prost = { version = "0.13.4", features = [ "prost-derive" ] }
33-
prost-types = { version = "0.13.4", default-features = false }
34-
quote = { version = "1.0.20" }
3527
rand = { version = "0.4.6" }
3628
regex = { version = "1.11.1" }
3729
schemars = { version = "0.8.16" }
3830
secp256k1 = { version = "0.30.0", features = [ "rand" ] }
3931
serde = { version = "1.0.196", default-features = false, features = [ "derive" ] }
40-
serde-cw-value = { version = "0.7.0" }
4132
serde-json-wasm = { version = "1.0.0" }
4233
serde_json = { version = "1.0.111" }
4334
serde_repr = { version = "0.1.17" }
4435
serde_test = { version = "1.0.176" }
4536
subtle-encoding = { version = "0.5.1", features = [ "bech32-preview" ] }
4637
syn = { version = "1.0.98" }
47-
test-tube-inj = { version = "2.0.4" }
38+
test-tube-inj = { path = "" }
4839
thiserror = { version = "1.0.56" }
4940
tiny-keccak = { version = "1.2.1" }
5041

contracts/atomic-order-example/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ optimize = """docker run --rm -v "$(pwd)":/code \
2828

2929
[dependencies]
3030
cosmwasm-std = { workspace = true }
31-
cosmwasm-storage = { workspace = true }
3231
cw-storage-plus = { workspace = true }
33-
cw-utils = { workspace = true }
3432
cw2 = { workspace = true }
3533
injective-cosmwasm = { path = "../../packages/injective-cosmwasm" }
3634
injective-math = { path = "../../packages/injective-math" }
@@ -42,4 +40,3 @@ thiserror = { workspace = true }
4240

4341
[dev-dependencies]
4442
cosmwasm-schema = { workspace = true }
45-
cw-multi-test = { workspace = true }

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ use cosmwasm_std::{Addr, Coin};
1010
use injective_cosmwasm::{
1111
checked_address_to_subaccount_id,
1212
exchange::{response::QueryOrderbookResponse, types::VolumeByType},
13-
CancellationStrategy, ExchangeParamsResponse, MarketId, MarketMidPriceAndTOBResponse, MarketVolatilityResponse, OrderSide, PriceLevel,
14-
QueryAggregateVolumeResponse, QueryMarketAtomicExecutionFeeMultiplierResponse, SpotMarketResponse, SubaccountDepositResponse, SubaccountId,
15-
TraderSpotOrdersResponse, TrimmedSpotLimitOrder,
13+
get_default_subaccount_id_for_checked_address, CancellationStrategy, ExchangeParamsResponse, MarketId, MarketMidPriceAndTOBResponse,
14+
MarketVolatilityResponse, OrderSide, PriceLevel, QueryAggregateVolumeResponse, QueryMarketAtomicExecutionFeeMultiplierResponse,
15+
SpotMarketResponse, SubaccountDepositResponse, SubaccountId, TraderSpotOrdersResponse, TrimmedSpotLimitOrder,
1616
};
1717
use injective_math::FPDecimal;
1818
use injective_test_tube::{
19-
injective_cosmwasm::get_default_subaccount_id_for_checked_address,
2019
injective_std::types::{
2120
cosmos::base::v1beta1::Coin as BaseCoin,
2221
injective::exchange::v1beta1::{
@@ -58,7 +57,7 @@ fn test_exchange_params() {
5857
assert!(res.params.is_some());
5958
let params = res.params.unwrap();
6059

61-
let listing_fee_coin = str_coin("1000", BASE_DENOM, BASE_DECIMALS);
60+
let listing_fee_coin = str_coin("20", BASE_DENOM, BASE_DECIMALS);
6261
assert_eq!(params.spot_market_instant_listing_fee, listing_fee_coin);
6362
assert_eq!(params.derivative_market_instant_listing_fee, listing_fee_coin);
6463
assert_eq!(params.trading_rewards_vesting_duration, 604800);

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

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,15 @@ use crate::{
88
};
99
use cosmwasm_std::Addr;
1010
use injective_cosmwasm::{
11-
checked_address_to_subaccount_id, exchange::response::QueryOrderbookResponse, CancellationStrategy, DerivativeMarketResponse, MarketId,
12-
MarketMidPriceAndTOBResponse, PerpetualMarketFundingResponse, PerpetualMarketInfoResponse, PriceLevel,
13-
SubaccountEffectivePositionInMarketResponse, SubaccountId, SubaccountPositionInMarketResponse, TraderDerivativeOrdersResponse,
14-
TrimmedDerivativeLimitOrder,
11+
checked_address_to_subaccount_id, exchange::response::QueryOrderbookResponse, get_default_subaccount_id_for_checked_address,
12+
CancellationStrategy, DerivativeMarketResponse, MarketId, MarketMidPriceAndTOBResponse, PerpetualMarketFundingResponse,
13+
PerpetualMarketInfoResponse, PriceLevel, SubaccountEffectivePositionInMarketResponse, SubaccountId, SubaccountPositionInMarketResponse,
14+
TraderDerivativeOrdersResponse, TrimmedDerivativeLimitOrder,
1515
};
1616
use injective_math::FPDecimal;
17-
use injective_test_tube::{
18-
injective_cosmwasm::get_default_subaccount_id_for_checked_address,
19-
injective_std::types::injective::exchange::v1beta1::{MsgInstantPerpetualMarketLaunch, OrderType},
20-
Account, Exchange, Module, Wasm,
21-
};
17+
use injective_std::types::injective::exchange::v2;
18+
use injective_test_tube::{injective_std::types::injective::exchange::v1beta1::OrderType, Account, Exchange, Module, Wasm};
19+
use injective_testing::test_tube::exchange::add_exchange_admin;
2220

2321
#[test]
2422
#[cfg_attr(not(feature = "integration"), ignore)]
@@ -52,30 +50,33 @@ fn test_query_derivative_market() {
5250
let maintenance_margin_ratio = FPDecimal::must_from_str("0.05");
5351
let min_price_tick_size = FPDecimal::must_from_str("1000.0");
5452
let min_quantity_tick_size = FPDecimal::must_from_str("1000000000000000");
55-
let min_notional = FPDecimal::must_from_str("1");
53+
let min_notional = FPDecimal::must_from_str("0.001");
5654
let quote_denom = QUOTE_DENOM.to_string();
57-
let maker_fee_rate = FPDecimal::ZERO;
58-
let taker_fee_rate = FPDecimal::ZERO;
55+
let maker_fee_rate = FPDecimal::must_from_str("0.0001");
56+
let taker_fee_rate = FPDecimal::must_from_str("0.0001");
57+
58+
add_exchange_admin(&env.app, &env.validator, env.owner.address());
5959

6060
exchange
61-
.instant_perpetual_market_launch(
62-
MsgInstantPerpetualMarketLaunch {
63-
sender: env.signer.address(),
61+
.instant_perpetual_market_launch_v2(
62+
v2::MsgInstantPerpetualMarketLaunch {
63+
sender: env.owner.address(),
6464
ticker: ticker.to_owned(),
65-
quote_denom: quote_denom.to_owned(),
66-
oracle_base: BASE_DENOM.to_owned(),
67-
oracle_quote: quote_denom.to_owned(),
65+
quote_denom: "usdt".to_string(),
66+
oracle_base: "inj".to_string(),
67+
oracle_quote: "usdt".to_string(),
6868
oracle_scale_factor: 6u32,
6969
oracle_type: 2i32,
70-
maker_fee_rate: dec_to_proto(maker_fee_rate).to_string(),
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),
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(),
7778
},
78-
&env.signer,
79+
&env.owner,
7980
)
8081
.unwrap();
8182

@@ -88,7 +89,7 @@ fn test_query_derivative_market() {
8889
let response_market = res.market.unwrap().market.unwrap();
8990
assert_eq!(response_market.market_id.as_str(), derivative_market_id);
9091
assert_eq!(response_market.ticker, ticker);
91-
assert_eq!(response_market.quote_denom, quote_denom);
92+
assert_eq!(response_market.quote_denom, QUOTE_DENOM);
9293
assert_eq!(response_market.min_price_tick_size, min_price_tick_size);
9394
assert_eq!(response_market.min_quantity_tick_size, min_quantity_tick_size);
9495
assert_eq!(response_market.maker_fee_rate, maker_fee_rate);

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
use crate::msg::QueryMsg;
22
use crate::utils::{str_coin, ExchangeType, Setup, BASE_DECIMALS, BASE_DENOM};
33
use cosmwasm_std::Uint128;
4-
use injective_test_tube::{
5-
injective_cosmwasm::tokenfactory::response::{TokenFactoryCreateDenomFeeResponse, TokenFactoryDenomSupplyResponse},
6-
injective_std::types::injective::tokenfactory::v1beta1::MsgCreateDenom,
7-
Account, Module, TokenFactory, Wasm,
8-
};
4+
use injective_cosmwasm::tokenfactory::response::{TokenFactoryCreateDenomFeeResponse, TokenFactoryDenomSupplyResponse};
5+
use injective_test_tube::{injective_std::types::injective::tokenfactory::v1beta1::MsgCreateDenom, Account, Module, TokenFactory, Wasm};
96

107
#[test]
118
#[cfg_attr(not(feature = "integration"), ignore)]

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

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use crate::msg::{InstantiateMsg, MSG_CREATE_DERIVATIVE_LIMIT_ORDER_ENDPOINT, MSG_CREATE_SPOT_LIMIT_ORDER_ENDPOINT};
22
use cosmwasm_std::{coin, Addr, Coin};
3-
use injective_cosmwasm::{checked_address_to_subaccount_id, SubaccountId};
3+
use injective_cosmwasm::{checked_address_to_subaccount_id, get_default_subaccount_id_for_checked_address, SubaccountId};
44
use injective_math::{scale::Scaled, FPDecimal};
5+
use injective_std::types::injective::exchange::v2;
56
use injective_test_tube::{
6-
injective_cosmwasm::get_default_subaccount_id_for_checked_address,
77
injective_std::{
88
shim::{Any, Timestamp},
99
types::{
@@ -18,8 +18,8 @@ use injective_test_tube::{
1818
},
1919
injective::{
2020
exchange::v1beta1::{
21-
DerivativeOrder, MsgCreateDerivativeLimitOrder, MsgCreateSpotLimitOrder, MsgInstantPerpetualMarketLaunch,
22-
MsgInstantSpotMarketLaunch, OrderInfo, OrderType, QueryDerivativeMarketsRequest, QuerySpotMarketsRequest, SpotOrder,
21+
DerivativeOrder, MsgCreateDerivativeLimitOrder, MsgCreateSpotLimitOrder, MsgInstantSpotMarketLaunch, OrderInfo, OrderType,
22+
QueryDerivativeMarketsRequest, QuerySpotMarketsRequest, SpotOrder,
2323
},
2424
insurance::v1beta1::MsgCreateInsuranceFund,
2525
oracle::v1beta1::{
@@ -31,6 +31,7 @@ use injective_test_tube::{
3131
},
3232
Account, Authz, Bank, Exchange, ExecuteResponse, Gov, InjectiveTestApp, Insurance, Module, Oracle, Runner, SigningAccount, Wasm,
3333
};
34+
use injective_testing::test_tube::exchange::{add_denom_notional_and_decimal, add_exchange_admin};
3435
use injective_testing::utils::human_to_i64;
3536
use prost::Message;
3637
use std::{collections::HashMap, ops::Neg, str::FromStr};
@@ -73,6 +74,7 @@ impl Setup {
7374
pub fn new(exchange_type: ExchangeType) -> Self {
7475
let app = InjectiveTestApp::new();
7576
let wasm = Wasm::new(&app);
77+
let exchange = Exchange::new(&app);
7678
let mut market_id = None;
7779

7880
let mut denoms = HashMap::new();
@@ -81,7 +83,6 @@ impl Setup {
8183
denoms.insert("base".to_string(), BASE_DENOM.to_string());
8284

8385
let signer = app.init_account(&[str_coin("1000000", BASE_DENOM, BASE_DECIMALS)]).unwrap();
84-
8586
let validator = app.get_first_validator_signing_account(BASE_DENOM.to_string(), 1.2f64).unwrap();
8687

8788
let owner = app
@@ -91,8 +92,12 @@ impl Setup {
9192
str_coin("1000000", QUOTE_DENOM, QUOTE_DECIMALS),
9293
])
9394
.unwrap();
95+
send(&Bank::new(&app), "1000000000000000000000", BASE_DENOM, &owner, &validator);
96+
add_denom_notional_and_decimal(&app, &validator, QUOTE_DENOM.to_string(), "1".to_string(), QUOTE_DECIMALS as u64);
9497

98+
add_denom_notional_and_decimal(&app, &validator, BASE_DENOM.to_string(), "1".to_string(), BASE_DECIMALS as u64);
9599
let mut users: Vec<UserInfo> = Vec::new();
100+
96101
for _ in 0..10 {
97102
let user = app
98103
.init_account(&[
@@ -122,8 +127,6 @@ impl Setup {
122127

123128
assert!(!contract_address.is_empty(), "Contract address is empty");
124129

125-
send(&Bank::new(&app), "1000000000000000000000", BASE_DENOM, &owner, &validator);
126-
127130
launch_insurance_fund(
128131
&app,
129132
&owner,
@@ -145,11 +148,10 @@ impl Setup {
145148

146149
match exchange_type {
147150
ExchangeType::Spot => {
148-
let exchange = Exchange::new(&app);
149151
market_id = Some(launch_spot_market(&exchange, &owner, "INJ/USDT".to_string()));
150152
}
151153
ExchangeType::Derivative => {
152-
let exchange = Exchange::new(&app);
154+
add_exchange_admin(&app, &validator, owner.address());
153155
market_id = Some(launch_perp_market(&exchange, &owner, "INJ/USDT".to_string()));
154156
}
155157
ExchangeType::None => {}
@@ -353,22 +355,23 @@ pub fn get_spot_market_id(exchange: &Exchange<InjectiveTestApp>, ticker: String)
353355

354356
pub fn launch_perp_market(exchange: &Exchange<InjectiveTestApp>, signer: &SigningAccount, ticker: String) -> String {
355357
exchange
356-
.instant_perpetual_market_launch(
357-
MsgInstantPerpetualMarketLaunch {
358+
.instant_perpetual_market_launch_v2(
359+
v2::MsgInstantPerpetualMarketLaunch {
358360
sender: signer.address(),
359361
ticker: ticker.to_owned(),
360362
quote_denom: "usdt".to_string(),
361363
oracle_base: "inj".to_string(),
362364
oracle_quote: "usdt".to_string(),
363365
oracle_scale_factor: 6u32,
364366
oracle_type: 2i32,
365-
maker_fee_rate: "0".to_owned(),
366-
taker_fee_rate: "0".to_owned(),
367+
maker_fee_rate: "-100000000000000".to_string(),
368+
taker_fee_rate: "1000000000000000".to_string(),
367369
initial_margin_ratio: "195000000000000000".to_owned(),
368370
maintenance_margin_ratio: "50000000000000000".to_owned(),
369371
min_price_tick_size: "1000000000000000000000".to_owned(),
370372
min_quantity_tick_size: "1000000000000000".to_owned(),
371373
min_notional: dec_to_proto(FPDecimal::must_from_str("1")),
374+
reduce_margin_ratio: "195000000000000000".to_owned(),
372375
},
373376
signer,
374377
)

contracts/injective-cosmwasm-stargate-example/src/testing/test_exchange_derivative.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ use injective_cosmwasm::{
1515
SubaccountEffectivePositionInMarketResponse, SubaccountPositionInMarketResponse, TraderDerivativeOrdersResponse, TrimmedDerivativeLimitOrder,
1616
};
1717
use injective_math::FPDecimal;
18+
use injective_std::types::injective::exchange::v2;
1819
use injective_test_tube::{
1920
injective_cosmwasm::get_default_subaccount_id_for_checked_address,
2021
injective_std::types::injective::exchange::v1beta1::{
21-
MsgInstantPerpetualMarketLaunch, OrderType, QueryDerivativeMarketRequest, QueryDerivativeMidPriceAndTobRequest,
22-
QueryDerivativeOrderbookRequest, QueryPerpetualMarketFundingRequest, QueryPerpetualMarketInfoRequest,
23-
QuerySubaccountEffectivePositionInMarketRequest, QuerySubaccountPositionInMarketRequest, QueryTraderDerivativeOrdersRequest,
22+
OrderType, QueryDerivativeMarketRequest, QueryDerivativeMidPriceAndTobRequest, QueryDerivativeOrderbookRequest,
23+
QueryPerpetualMarketFundingRequest, QueryPerpetualMarketInfoRequest, QuerySubaccountEffectivePositionInMarketRequest,
24+
QuerySubaccountPositionInMarketRequest, QueryTraderDerivativeOrdersRequest,
2425
},
2526
Account, Exchange, Module, Wasm,
2627
};
@@ -70,8 +71,8 @@ fn test_query_derivative_market() {
7071
let taker_fee_rate = FPDecimal::must_from_str("0.0005");
7172

7273
exchange
73-
.instant_perpetual_market_launch(
74-
MsgInstantPerpetualMarketLaunch {
74+
.instant_perpetual_market_launch_v2(
75+
v2::MsgInstantPerpetualMarketLaunch {
7576
sender: env.owner.address(),
7677
ticker: ticker.to_owned(),
7778
quote_denom: quote_denom.to_owned(),
@@ -86,6 +87,7 @@ fn test_query_derivative_market() {
8687
min_price_tick_size: dec_to_proto(min_price_tick_size),
8788
min_quantity_tick_size: dec_to_proto(min_quantity_tick_size),
8889
min_notional: dec_to_proto(min_notional),
90+
reduce_margin_ratio: dec_to_proto(initial_margin_ratio),
8991
},
9092
&env.owner,
9193
)

packages/injective-cosmwasm/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ license = "Apache-2.0"
66
name = "injective-cosmwasm"
77
readme = "README.md"
88
repository = "https://github.com/InjectiveLabs/cw-injective/tree/dev/packages/injective-cosmwasm"
9-
version = "0.3.2"
9+
version = "0.3.3"
1010
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1111

1212
[dependencies]
1313
cosmwasm-std = { workspace = true }
1414
cw-storage-plus = { workspace = true }
1515
ethereum-types = { workspace = true }
1616
hex = { workspace = true }
17-
injective-math = { version = "0.3.1", path = "../../packages/injective-math" }
17+
injective-math = { path = "../../packages/injective-math" }
1818
schemars = { workspace = true }
1919
serde = { workspace = true }
2020
serde_repr = { workspace = true }

packages/injective-math/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,17 @@ license = "Apache-2.0"
66
name = "injective-math"
77
readme = "README.md"
88
repository = "https://github.com/InjectiveLabs/cw-injective/tree/dev/packages/injective-math"
9-
version = "0.3.1"
9+
version = "0.3.3"
1010

1111
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1212

1313
[features]
1414

1515
[dependencies]
1616
cosmwasm-std = { workspace = true }
17-
ethereum-types = { workspace = true }
1817
primitive-types = { workspace = true }
1918
schemars = { workspace = true }
2019
serde = { workspace = true }
21-
subtle-encoding = { workspace = true }
2220

2321
[dev-dependencies]
2422
cosmwasm-schema = { workspace = true }

packages/injective-testing/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2021"
55
license = "Apache-2.0"
66
name = "injective-testing"
77
repository = "https://github.com/InjectiveLabs/cw-injective/tree/dev/packages/injective-testing"
8-
version = "1.1.7"
8+
version = "1.1.8"
99

1010
[dependencies]
1111
anyhow = { workspace = true }

0 commit comments

Comments
 (0)