Skip to content

Commit

Permalink
Revert "remove penalty fee payer"
Browse files Browse the repository at this point in the history
This reverts commit 47e1b5e.
  • Loading branch information
binyebarwe committed Dec 27, 2023
1 parent 47e1b5e commit 2e3bd75
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 13 deletions.
1 change: 1 addition & 0 deletions lib/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ impl OpenBookClient {
anchor_lang::ToAccountMetas::to_account_metas(
&openbook_v2::accounts::SettleFunds {
owner: self.owner(),
penalty_payer: self.owner(),
open_orders_account: self.open_orders_account,
market: market_address,
market_authority: market.market_authority,
Expand Down
1 change: 1 addition & 0 deletions lib/client/src/jup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ impl Amm for OpenBookMarket {

let accounts = PlaceTakeOrder {
signer: *user_transfer_authority,
penalty_payer: *user_transfer_authority,
market: self.key,
market_authority: self.market.market_authority,
bids: self.market.bids,
Expand Down
12 changes: 0 additions & 12 deletions programs/openbook-v2/fuzz/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions programs/openbook-v2/fuzz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ impl FuzzContext {

let accounts = openbook_v2::accounts::PlaceTakeOrder {
signer: user.owner,
penalty_payer: user.owner,
user_base_account: user.base_vault,
user_quote_account: user.quote_vault,
market: self.market,
Expand Down Expand Up @@ -764,6 +765,7 @@ impl FuzzContext {

let accounts = openbook_v2::accounts::SettleFunds {
owner: user.owner,
penalty_payer: user.owner,
open_orders_account: user.open_orders,
user_base_account: user.base_vault,
user_quote_account: user.quote_vault,
Expand Down
2 changes: 2 additions & 0 deletions programs/openbook-v2/src/accounts_ix/place_take_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use anchor_spl::token::{Token, TokenAccount};
pub struct PlaceTakeOrder<'info> {
#[account(mut)]
pub signer: Signer<'info>,
#[account(mut)]
pub penalty_payer: Signer<'info>,

#[account(
mut,
Expand Down
2 changes: 2 additions & 0 deletions programs/openbook-v2/src/accounts_ix/settle_funds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use anchor_spl::token::{Token, TokenAccount};
pub struct SettleFunds<'info> {
#[account(mut)]
pub owner: Signer<'info>,
#[account(mut)]
pub penalty_payer: Signer<'info>,

#[account(
mut,
Expand Down
3 changes: 3 additions & 0 deletions programs/openbook-v2/src/accounts_ix/settle_funds_expired.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ pub struct SettleFundsExpired<'info> {
pub close_market_admin: Signer<'info>,
#[account(mut)]
pub owner: Signer<'info>,
#[account(mut)]
pub penalty_payer: Signer<'info>,
#[account(
mut,
has_one = market,
Expand Down Expand Up @@ -54,6 +56,7 @@ impl<'info> SettleFundsExpired<'info> {
pub fn to_settle_funds_accounts(&self) -> SettleFunds<'info> {
SettleFunds {
owner: self.owner.clone(),
penalty_payer: self.penalty_payer.clone(),
open_orders_account: self.open_orders_account.clone(),
market: self.market.clone(),
market_authority: self.market_authority.clone(),
Expand Down
10 changes: 10 additions & 0 deletions programs/openbook-v2/src/instructions/settle_funds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ pub fn settle_funds<'info>(ctx: Context<'_, '_, '_, 'info, SettleFunds<'info>>)

drop(market);

if pa.penalty_heap_count > 0 {
system_program_transfer(
pa.penalty_heap_count * PENALTY_EVENT_HEAP,
&ctx.accounts.system_program,
&ctx.accounts.penalty_payer,
&ctx.accounts.market,
)?;
pa.penalty_heap_count = 0;
}

if let Some(referrer_account) = &ctx.accounts.referrer_account {
token_transfer_signed(
referrer_rebate,
Expand Down
3 changes: 2 additions & 1 deletion programs/openbook-v2/src/state/open_orders_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ pub struct Position {

pub locked_maker_fees: u64,
pub referrer_rebates_available: u64,
/// Not implemented at the moment
/// Count of ixs when events are added to the heap
/// To avoid this, send remaining accounts in order to process the events
pub penalty_heap_count: u64,

/// Cumulative maker volume in quote native units (display only)
Expand Down
3 changes: 3 additions & 0 deletions programs/openbook-v2/tests/program_test/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ impl ClientInstruction for PlaceTakeOrderInstruction {
oracle_a: market.oracle_a.into(),
oracle_b: market.oracle_b.into(),
signer: self.signer.pubkey(),
penalty_payer: self.signer.pubkey(),
user_base_account: self.user_base_account,
user_quote_account: self.user_quote_account,
market_base_vault: self.market_base_vault,
Expand Down Expand Up @@ -833,6 +834,7 @@ impl ClientInstruction for SettleFundsInstruction {
let market: Market = account_loader.load(&self.market).await.unwrap();
let accounts = Self::Accounts {
owner: self.owner.pubkey(),
penalty_payer: self.owner.pubkey(),
open_orders_account: self.open_orders_account,
market: self.market,
market_authority: market.market_authority,
Expand Down Expand Up @@ -880,6 +882,7 @@ impl ClientInstruction for SettleFundsExpiredInstruction {
let accounts = Self::Accounts {
close_market_admin: self.close_market_admin.pubkey(),
owner: self.owner.pubkey(),
penalty_payer: self.owner.pubkey(),
open_orders_account: self.open_orders_account,
market: self.market,
market_authority: market.market_authority,
Expand Down

0 comments on commit 2e3bd75

Please sign in to comment.