diff --git a/src/market/market_utils.cairo b/src/market/market_utils.cairo index eb958537..5a52b55d 100644 --- a/src/market/market_utils.cairo +++ b/src/market/market_utils.cairo @@ -2831,8 +2831,8 @@ fn validate_market_token_balance_with_token( .balance_of(market.market_token) .low .into(); + 'Issue here'.print(); let expected_min_balance: u256 = get_expected_min_token_balance(data_store, market, token); - assert(balance >= expected_min_balance, MarketError::INVALID_MARKET_TOKEN_BALANCE); // funding fees can be claimed even if the collateral for positions that should pay funding fees @@ -2882,7 +2882,6 @@ fn get_expected_min_token_balance( .get_u256(keys::claimable_ui_fee_amount_key(market.market_token, token)); let affiliate_reward_amount: u256 = data_store .get_u256(keys::affiliate_reward_key(market.market_token, token)); - // funding fees are excluded from this summation as claimable funding fees // are incremented without a corresponding decrease of the collateral of // other positions, the collateral of other positions is decreased when diff --git a/tests/integration/swap_test.cairo b/tests/integration/swap_test.cairo index 22e836a4..07024a23 100644 --- a/tests/integration/swap_test.cairo +++ b/tests/integration/swap_test.cairo @@ -86,18 +86,19 @@ fn test_deposit_market_integration() { // Set params in data_store data_store.set_address(keys::fee_token(), market.index_token); - data_store.set_u128(keys::max_swap_path_length(), 5); + data_store.set_u256(keys::max_swap_path_length(), 5); // Set max pool amount. data_store - .set_u128( + .set_u256( keys::max_pool_amount_key(market.market_token, market.long_token), 500000000000000000 ); data_store - .set_u128( + .set_u256( keys::max_pool_amount_key(market.market_token, market.short_token), 500000000000000000 ); + oracle.set_price_testing_eth(5000); // Fill the pool. IERC20Dispatcher { contract_address: market.long_token }.mint(market.market_token, 50000000000); IERC20Dispatcher { contract_address: market.short_token } @@ -286,8 +287,18 @@ fn test_deposit_market_integration() { let key = order_handler.create_order(caller_address, order_params); let got_order = data_store.get_order(key); - // data_store.set_u128(keys::pool_amount_key(market.market_token, contract_address_const::<'USDC'>()), ); - // data_store.set_u128(keys::pool_amount_key(market.market_token, contract_address_const::<'ETH'>()), 1000000); + + data_store + .set_u256( + keys::pool_amount_key(market.market_token, contract_address_const::<'USDC'>()), + 10000000000 + ); + data_store + .set_u256( + keys::pool_amount_key(market.market_token, contract_address_const::<'ETH'>()), + 10000000000 + ); + // Execute the swap order. let signatures: Span = array![0].span(); let set_price_params = SetPricesParams { @@ -684,7 +695,7 @@ fn deploy_role_store() -> ContractAddress { let caller_address: ContractAddress = contract_address_const::<'caller'>(); let deployed_contract_address = contract_address_const::<'role_store'>(); start_prank(deployed_contract_address, caller_address); - contract.deploy_at(@array![], deployed_contract_address).unwrap() + contract.deploy_at(@array![caller_address.into()], deployed_contract_address).unwrap() } fn deploy_event_emitter() -> ContractAddress { diff --git a/tests/lib.cairo b/tests/lib.cairo index 21a586ec..c3d00f84 100644 --- a/tests/lib.cairo +++ b/tests/lib.cairo @@ -1,130 +1,129 @@ -// mod adl { -// mod test_adl_utils; -// } -// mod bank { -// mod test_bank; -// mod test_strict_bank; -// } -// mod callback { -// mod test_callback_utils; -// } -// mod config { -// mod test_config; -// } -// mod data { -// mod test_data_store; -// mod test_deposit_store; -// mod test_keys; -// mod test_market; -// mod test_order; -// mod test_position; -// mod test_withdrawal; -// } -// mod deposit { -// mod test_deposit_utils; -// mod test_deposit_vault; -// mod test_execute_deposit_utils; -// } -// mod event { -// mod test_adl_events_emitted; -// mod test_callback_events_emitted; -// mod test_config_events_emitted; -// mod test_gas_events_emitted; -// mod test_market_events_emitted; -// mod test_oracle_events_emitted; -// mod test_order_events_emitted; -// mod test_position_events_emitted; -// mod test_pricing_events_emitted; -// mod test_referral_events_emitted; -// mod test_swap_events_emitted; -// mod test_timelock_events_emitted; -// mod test_withdrawal_events_emitted; -// mod test_event_utils; -// } -// mod exchange { -// mod test_liquidation_handler; -// mod test_withdrawal_handler; -// mod test_deposit_handler; -// mod test_exchange_utils; -// mod test_base_order_handler; -// } -// mod feature { -// mod test_feature_utils; -// } -// mod fee { -// mod test_fee_handler; -// mod test_fee_utils; -// } -// mod market { -// mod test_market_factory; -// mod test_market_token; -// mod test_market_utils; -// } -// mod nonce { -// mod test_nonce_utils; -// } -// mod oracle { -// mod test_oracle; -// } -// mod order { -// mod test_base_order_utils; -// mod test_increase_order_utils; -// mod test_order; -// } -// mod position { -// mod test_decrease_position_utils; -// mod test_decrease_position_swap_utils; -// mod test_position_utils; -// } -// mod price { -// mod test_price; -// } -// mod pricing { -// mod test_position_pricing_utils; -// mod test_swap_pricing_utils; -// } -// mod reader { -// mod test_reader; -// } -// mod role { -// mod test_role_module; -// mod test_role_store; -// } -// mod router { -// mod test_router; -// } -// mod swap { -// mod test_swap_handler; -// } -// mod utils { -// mod test_account_utils; -// mod test_arrays; -// mod test_basic_multicall; -// mod test_calc; -// mod test_enumerable_set; -// mod test_precision; -// mod test_reentrancy_guard; -// mod test_starknet_utils; -// mod test_u128_mask; -// mod test_i128; -// mod test_serializable_dict; -// } -// mod withdrawal { -// mod test_withdrawal_vault; -// } -// mod mock { -// mod test_governable; -// mod test_referral_storage; -// } -// mod referral { -// mod test_referral_utils; -// } -// mod test_create_and_execute_swap; +mod adl { + mod test_adl_utils; +} +mod bank { + mod test_bank; + mod test_strict_bank; +} +mod callback { + mod test_callback_utils; +} +mod config { + mod test_config; +} +mod data { + mod test_data_store; + mod test_deposit_store; + mod test_keys; + mod test_market; + mod test_order; + mod test_position; + mod test_withdrawal; +} +mod deposit { + mod test_deposit_utils; + mod test_deposit_vault; + mod test_execute_deposit_utils; +} +mod event { + mod test_adl_events_emitted; + mod test_callback_events_emitted; + mod test_config_events_emitted; + mod test_gas_events_emitted; + mod test_market_events_emitted; + mod test_oracle_events_emitted; + mod test_order_events_emitted; + mod test_position_events_emitted; + mod test_pricing_events_emitted; + mod test_referral_events_emitted; + mod test_swap_events_emitted; + mod test_timelock_events_emitted; + mod test_withdrawal_events_emitted; + mod test_event_utils; +} +mod exchange { + mod test_liquidation_handler; + mod test_withdrawal_handler; + mod test_deposit_handler; + mod test_exchange_utils; + mod test_base_order_handler; +} +mod feature { + mod test_feature_utils; +} +mod fee { + mod test_fee_handler; + mod test_fee_utils; +} +mod market { + mod test_market_factory; + mod test_market_token; + mod test_market_utils; +} +mod nonce { + mod test_nonce_utils; +} +mod oracle { + mod test_oracle; +} +mod order { + mod test_base_order_utils; + mod test_increase_order_utils; + mod test_order; +} +mod position { + mod test_decrease_position_utils; + mod test_decrease_position_swap_utils; + mod test_position_utils; +} +mod price { + mod test_price; +} +mod pricing { + mod test_position_pricing_utils; + mod test_swap_pricing_utils; +} +mod reader { + mod test_reader; +} +mod role { + mod test_role_module; + mod test_role_store; +} +mod router { + mod test_router; +} +mod swap { + mod test_swap_handler; +} +mod utils { + mod test_account_utils; + mod test_arrays; + mod test_basic_multicall; + mod test_calc; + mod test_enumerable_set; + mod test_precision; + mod test_reentrancy_guard; + mod test_starknet_utils; + // mod test_u128_mask; + // mod test_i128; + mod test_serializable_dict; +} +mod withdrawal { + mod test_withdrawal_vault; +} +mod mock { + mod test_governable; + mod test_referral_storage; +} +mod referral { + mod test_referral_utils; +} mod integration { mod test_deposit_withdrawal; mod test_long_integration; mod test_short_integration; mod test_swap_integration; -//mod swap_test; + mod swap_test; }