Skip to content

Commit

Permalink
only sweep fees is amount gt 0
Browse files Browse the repository at this point in the history
  • Loading branch information
skrrb committed Jul 14, 2023
1 parent 9752024 commit 10f02e2
Showing 1 changed file with 11 additions and 9 deletions.
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 10f02e2

Please sign in to comment.