Skip to content

Commit

Permalink
remove oracles from place_take_order
Browse files Browse the repository at this point in the history
  • Loading branch information
binyebarwe committed Jan 26, 2024
1 parent d1f2744 commit ec513b2
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 25 deletions.
4 changes: 0 additions & 4 deletions lib/client/src/jup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,6 @@ impl Amm for OpenBookMarket {
market_base_vault: self.market.market_base_vault,
market_quote_vault: self.market.market_quote_vault,
event_heap: self.market.event_heap,
oracle_a: None,
oracle_b: None,
token_program: Token::id(),
system_program: System::id(),
open_orders_admin: None,
Expand Down Expand Up @@ -415,8 +413,6 @@ mod test {
market_base_vault: market_data.market_base_vault,
market_quote_vault: market_data.market_quote_vault,
event_heap: market_data.event_heap,
oracle_a: None,
oracle_b: None,
token_program: Token::id(),
system_program: System::id(),
open_orders_admin: None,
Expand Down
2 changes: 0 additions & 2 deletions programs/openbook-v2/fuzz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,6 @@ impl FuzzContext {
market_base_vault: self.market_base_vault,
market_quote_vault: self.market_quote_vault,
event_heap: self.event_heap,
oracle_a: self.oracle_a,
oracle_b: self.oracle_b,
token_program: spl_token::ID,
system_program: system_program::ID,
open_orders_admin: None,
Expand Down
7 changes: 0 additions & 7 deletions programs/openbook-v2/src/accounts_ix/place_take_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ pub struct PlaceTakeOrder<'info> {
has_one = market_base_vault,
has_one = market_quote_vault,
has_one = market_authority,
constraint = market.load()?.oracle_a == oracle_a.non_zero_key(),
constraint = market.load()?.oracle_b == oracle_b.non_zero_key(),
constraint = market.load()?.open_orders_admin == open_orders_admin.non_zero_key() @ OpenBookError::InvalidOpenOrdersAdmin
)]
pub market: AccountLoader<'info, Market>,
Expand Down Expand Up @@ -48,11 +46,6 @@ pub struct PlaceTakeOrder<'info> {
)]
pub user_quote_account: Box<Account<'info, TokenAccount>>,

/// CHECK: The oracle can be one of several different account types and the pubkey is checked above
pub oracle_a: Option<UncheckedAccount<'info>>,
/// CHECK: The oracle can be one of several different account types and the pubkey is checked above
pub oracle_b: Option<UncheckedAccount<'info>>,

pub token_program: Program<'info, Token>,
pub system_program: Program<'info, System>,
pub open_orders_admin: Option<Signer<'info>>,
Expand Down
9 changes: 1 addition & 8 deletions programs/openbook-v2/src/instructions/place_take_order.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use anchor_lang::prelude::*;

use crate::accounts_ix::*;
use crate::accounts_zerocopy::AccountInfoRef;
use crate::error::*;
use crate::state::*;
use crate::token_utils::*;
Expand Down Expand Up @@ -33,12 +32,6 @@ pub fn place_take_order(ctx: Context<PlaceTakeOrder>, order: Order, limit: u8) -

let now_ts: u64 = clock.unix_timestamp.try_into().unwrap();

let oracle_price = market.oracle_price(
AccountInfoRef::borrow_some(ctx.accounts.oracle_a.as_ref())?.as_ref(),
AccountInfoRef::borrow_some(ctx.accounts.oracle_b.as_ref())?.as_ref(),
clock.slot,
)?;

let side = order.side;

let OrderWithAmounts {
Expand All @@ -51,7 +44,7 @@ pub fn place_take_order(ctx: Context<PlaceTakeOrder>, order: Order, limit: u8) -
&order,
&mut market,
&mut event_heap,
oracle_price,
None,
None,
&ctx.accounts.signer.key(),
now_ts,
Expand Down
2 changes: 0 additions & 2 deletions programs/openbook-v2/tests/program_test/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,6 @@ impl ClientInstruction for PlaceTakeOrderInstruction {
bids: market.bids,
asks: market.asks,
event_heap: market.event_heap,
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,
Expand Down
2 changes: 0 additions & 2 deletions ts/client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -735,8 +735,6 @@ export class OpenBookV2Client {
bids: market.bids,
eventHeap: market.eventHeap,
market: marketPublicKey,
oracleA: market.oracleA.key,
oracleB: market.oracleB.key,
userBaseAccount,
userQuoteAccount,
marketBaseVault: market.marketBaseVault,
Expand Down

0 comments on commit ec513b2

Please sign in to comment.