Skip to content

Commit 159d7ce

Browse files
committed
solana: refactor internal accounting
1 parent 823221e commit 159d7ce

File tree

2 files changed

+198
-208
lines changed
  • solana/programs/matching-engine/src

2 files changed

+198
-208
lines changed

solana/programs/matching-engine/src/fallback/processor/execute_order.rs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use solana_program::{instruction::Instruction, program::invoke_signed_unchecked}
99

1010
use crate::{
1111
error::MatchingEngineError,
12-
processor::{get_user_amount_and_new_status_and_penalized, ActiveAuctionAccountInfos},
12+
processor::ExecuteOrderInternalAccounting,
1313
state::{Auction, AuctionStatus, Custodian, MessageProtocol},
1414
ID,
1515
};
@@ -347,24 +347,21 @@ pub(super) fn process(accounts: &[AccountInfo]) -> Result<()> {
347347
// in?
348348

349349
// Prepare the execute order (get the user amount, fill, and order executed event)
350-
let active_auction_accounts = ActiveAuctionAccountInfos {
351-
auction_best_offer_token: auction_best_offer_token_info.to_account_info(),
352-
auction_executor_token: executor_token_info.to_account_info(),
353-
auction_initial_offer_token: auction_initial_offer_token_info.to_account_info(),
354-
auction_custody_token: auction_custody_info.to_account_info(),
355-
active_auction: active_auction_info.to_account_info(),
356-
auction_custodian: custodian_info.to_account_info(),
357-
};
358-
let custody_token =
350+
let auction_custody =
359351
TokenAccount::try_deserialize(&mut &auction_custody_info.data.borrow()[..])?;
360-
let (user_amount, new_status, _penalized) = get_user_amount_and_new_status_and_penalized(
361-
&active_auction,
362-
&custody_token,
363-
&auction_config,
364-
fast_market_order.init_auction_fee,
365-
active_auction_accounts,
366-
accounts,
367-
)?;
352+
353+
let (user_amount, new_status, _penalized) = ExecuteOrderInternalAccounting {
354+
active_auction_key: active_auction_info.key,
355+
active_auction: &active_auction,
356+
auction_custody_key: auction_custody_info.key,
357+
auction_custody: &auction_custody,
358+
best_offer_token_info: auction_best_offer_token_info,
359+
executor_token_key: executor_token_info.key,
360+
initial_offer_token_info: auction_initial_offer_token_info,
361+
custodian_key: custodian_info.key,
362+
auction_config: &auction_config,
363+
}
364+
.into_calculate_and_transfer(fast_market_order.init_auction_fee, accounts)?;
368365

369366
// Set the active auction status
370367
active_auction.status = new_status;

0 commit comments

Comments
 (0)