Skip to content

Commit

Permalink
fixed swap issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Sk8erboi84 committed Mar 30, 2024
1 parent 311c5ed commit 7fbd42b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
14 changes: 12 additions & 2 deletions src/market/market_utils.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -2833,7 +2833,6 @@ fn validate_market_token_balance_with_token(
.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
Expand Down Expand Up @@ -2883,7 +2882,18 @@ 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));

'pool_amount'.print();
pool_amount.print();
'swap_impact_pool_amount'.print();
swap_impact_pool_amount.print();
'claimable_collateral_amount'.print();
claimable_collateral_amount.print();
'claimable_fee_amount'.print();
claimable_fee_amount.print();
'claimable_ui_fee_amount'.print();
claimable_ui_fee_amount.print();
'affiliate_reward_amount'.print();
affiliate_reward_amount.print();
// 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
Expand Down
6 changes: 4 additions & 2 deletions tests/integration/swap_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,10 @@ 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<felt252> = array![0].span();
let set_price_params = SetPricesParams {
Expand Down
10 changes: 5 additions & 5 deletions tests/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@
// mod test_create_and_execute_swap;

mod integration {
mod test_deposit_withdrawal;
mod test_long_integration;
mod test_short_integration;
mod test_swap_integration;
//mod swap_test;
// mod test_deposit_withdrawal;
// mod test_long_integration;
// mod test_short_integration;
// mod test_swap_integration;
mod swap_test;
}

0 comments on commit 7fbd42b

Please sign in to comment.