Skip to content

Commit

Permalink
fix: min quantity order size
Browse files Browse the repository at this point in the history
  • Loading branch information
j0nl1 committed Feb 5, 2024
1 parent 2dfb84b commit d3c9630
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 27 deletions.
6 changes: 4 additions & 2 deletions contracts/pair_concentrated_inj/src/orderbook/sudo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ fn begin_blocker(
return leave_orderbook(&ob_state, balances, &env);
}

let base_trade_size = base_order_size / Decimal256::from_integer(total_order_size);
let quote_trade_size = quote_order_size / Decimal256::from_integer(total_order_size);
let base_trade_size =
(base_order_size / Decimal256::from_integer(total_order_size)).floor();
let quote_trade_size =
(quote_order_size / Decimal256::from_integer(total_order_size)).floor();

let amp_gamma = config.pool_state.get_amp_gamma(&env);
let mut ixs = pools.to_vec();
Expand Down
4 changes: 2 additions & 2 deletions contracts/pair_concentrated_inj/tests/helper/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ impl Helper {
orderbook_config: OrderbookConfig {
market_id,
orders_number: 5,
min_base_order_size: 100,
min_quote_order_size: 100,
min_base_order_size: 1000,
min_quote_order_size: 500,
liquidity_percent: Decimal::percent(10),
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use std::cell::RefCell;
use std::rc::Rc;
use std::str::FromStr;

use astroport_pcl_common::consts::{AMP_MAX, AMP_MIN, MA_HALF_TIME_LIMITS};
use cosmwasm_std::{coins, Addr, Coin, Decimal, Decimal256, StdError, Uint128};
Expand Down Expand Up @@ -891,14 +890,6 @@ fn check_orderbook_integration() {
let querier_wrapper = helper.app.wrap();
let inj_querier = InjectiveQuerier::new(&querier_wrapper);

let pools = helper
.query_pool()
.unwrap()
.assets
.iter()
.map(|asset| asset.amount)
.collect_vec();

let inj_deposit: u128 = inj_querier
.query_subaccount_deposit(&ob_config.subaccount, &"inj".to_string())
.unwrap()
Expand All @@ -912,27 +903,18 @@ fn check_orderbook_integration() {
.total_balance
.into();

/* let expected_inj =
Decimal::from_str(&pools[0].to_string()).unwrap() * Decimal::from_ratio(5u128, 100u128); */
println!(
"expected_inj: {} total: {} deposited: {}",
Decimal256::from_str(&pools[0].to_string()).unwrap() * Decimal256::from_str("0.1").unwrap(),
pools[0],
inj_deposit
);

assert_eq!(astro_deposit, 4979_051501);

assert_eq!(inj_deposit, 16540_551000000000000000);
assert_eq!(astro_deposit, 32844_980113);
let inj_pool = helper.coin_balance(&test_coins[0], &helper.pair_addr);
let astro_pool = helper.coin_balance(&test_coins[1], &helper.pair_addr);

assert_eq!(inj_pool, 497542_933893233248565365);
assert_eq!(astro_pool, 995085_325039);
assert_eq!(inj_pool, 483492_363893233248386874);
assert_eq!(astro_pool, 967219_396427);

// total liquidity is close to initial provided liquidity
let total_inj = inj_deposit + inj_pool;
let total_astro = astro_deposit + astro_pool;
assert_eq!(total_inj, 500032_914893233248565365);
assert_eq!(total_inj, 500032_914893233248386874);
assert_eq!(total_astro, 100006_4376540);

let random_user = generate_inj_address();
Expand Down

0 comments on commit d3c9630

Please sign in to comment.