Skip to content

Commit

Permalink
Merge pull request #103 from openbook-dex/feature/minor-improvemets
Browse files Browse the repository at this point in the history
Feature/minor improvemets
  • Loading branch information
binyebarwe authored Jul 14, 2023
2 parents ffbfc6a + 10f02e2 commit 3ddec40
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
6 changes: 1 addition & 5 deletions programs/openbook-v2/src/instructions/settle_funds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ pub fn settle_funds<'info>(ctx: Context<'_, '_, '_, 'info, SettleFunds<'info>>)

let mut roundoff_maker_fees = 0;

if market.maker_fee.is_positive()
&& !open_orders_account
.all_orders_in_use()
.any(|oo| oo.side_and_tree().side() == Side::Bid)
{
if market.maker_fee.is_positive() && open_orders_account.position.bids_base_lots == 0 {
roundoff_maker_fees = open_orders_account.position.locked_maker_fees;
open_orders_account.position.locked_maker_fees = 0;
}
Expand Down
20 changes: 11 additions & 9 deletions programs/openbook-v2/src/instructions/sweep_fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ pub fn sweep_fees(ctx: Context<SweepFees>) -> Result<()> {

drop(market);

let cpi_context = CpiContext::new(
ctx.accounts.token_program.to_account_info(),
Transfer {
from: ctx.accounts.quote_vault.to_account_info(),
to: ctx.accounts.token_receiver_account.to_account_info(),
authority: ctx.accounts.market.to_account_info(),
},
);
token::transfer(cpi_context.with_signer(signer), amount)?;
if amount > 0 {
let cpi_context = CpiContext::new(
ctx.accounts.token_program.to_account_info(),
Transfer {
from: ctx.accounts.quote_vault.to_account_info(),
to: ctx.accounts.token_receiver_account.to_account_info(),
authority: ctx.accounts.market.to_account_info(),
},
);
token::transfer(cpi_context.with_signer(signer), amount)?;
}

Ok(())
}

0 comments on commit 3ddec40

Please sign in to comment.