diff --git a/programs/manifest/src/program/processor/withdraw.rs b/programs/manifest/src/program/processor/withdraw.rs index 98ad495e1..cbf3d3b7e 100644 --- a/programs/manifest/src/program/processor/withdraw.rs +++ b/programs/manifest/src/program/processor/withdraw.rs @@ -73,14 +73,14 @@ pub(crate) fn process_withdraw( invoke_signed( &spl_token_2022::instruction::transfer_checked( token_program.key, - trader_token.key, + vault.key, if is_base { dynamic_account.fixed.get_base_mint() } else { dynamic_account.get_quote_mint() }, + trader_token.key, vault.key, - payer.key, &[], amount_atoms, if is_base { diff --git a/programs/manifest/tests/cases/token22.rs b/programs/manifest/tests/cases/token22.rs index c2f04f832..c10dfa876 100644 --- a/programs/manifest/tests/cases/token22.rs +++ b/programs/manifest/tests/cases/token22.rs @@ -204,6 +204,20 @@ async fn token22_base() -> anyhow::Result<()> { &[&payer_keypair.insecure_clone()], ) .await?; + { + let market_account: solana_sdk::account::Account = context + .borrow_mut() + .banks_client + .get_account(market_keypair.pubkey()) + .await + .unwrap() + .unwrap(); + + let market: manifest::state::MarketValue = + manifest::program::get_dynamic_value(market_account.data.as_slice()); + let balance = market.get_trader_balance(&payer); + assert_eq!(balance.0.as_u64(), 999999000); + } // Place orders on both sides to let place_order_ix: Instruction = batch_update_instruction(