From 143cd73b9d945d24c9e3c5589b5f0f601bc074e4 Mon Sep 17 00:00:00 2001 From: Britt Cyr Date: Thu, 10 Oct 2024 16:23:28 -0400 Subject: [PATCH] Fix withdraw 22 (#173) * fix withdraw 22 * fmt --- .../manifest/src/program/processor/withdraw.rs | 4 ++-- programs/manifest/tests/cases/token22.rs | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) 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(