Skip to content

Commit

Permalink
OrderWithAmounts return u64
Browse files Browse the repository at this point in the history
  • Loading branch information
skrrb committed Jul 13, 2023
1 parent 9febfe0 commit 11cd336
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions programs/openbook-v2/src/instructions/place_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub fn place_order(ctx: Context<PlaceOrder>, order: Order, limit: u8) -> Result<
Side::Bid => {
let free_quote = position.quote_free_native;
let max_quote_including_fees =
total_quote_taken_native + posted_quote_native as u64 + maker_fees;
total_quote_taken_native + posted_quote_native + maker_fees;

let free_qty_to_lock = cmp::min(max_quote_including_fees, free_quote);
let deposit_amount = max_quote_including_fees - free_qty_to_lock;
Expand All @@ -93,7 +93,7 @@ pub fn place_order(ctx: Context<PlaceOrder>, order: Order, limit: u8) -> Result<

Side::Ask => {
let free_assets_native = position.base_free_native;
let max_base_native = total_base_taken_native + posted_base_native as u64;
let max_base_native = total_base_taken_native + posted_base_native;

let free_qty_to_lock = cmp::min(max_base_native, free_assets_native);
let deposit_amount = max_base_native - free_qty_to_lock;
Expand Down
8 changes: 4 additions & 4 deletions programs/openbook-v2/src/state/orderbook/book.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ pub struct Orderbook<'a> {

pub struct OrderWithAmounts {
pub order_id: Option<u128>,
pub posted_base_native: i64,
pub posted_quote_native: i64,
pub posted_base_native: u64,
pub posted_quote_native: u64,
pub total_base_taken_native: u64,
pub total_quote_taken_native: u64,
pub maker_fees: u64,
Expand Down Expand Up @@ -450,8 +450,8 @@ impl<'a> Orderbook<'a> {

Ok(OrderWithAmounts {
order_id: placed_order_id,
posted_base_native,
posted_quote_native,
posted_base_native: posted_base_native as u64,
posted_quote_native: posted_quote_native as u64,
total_base_taken_native,
total_quote_taken_native,
referrer_amount,
Expand Down

0 comments on commit 11cd336

Please sign in to comment.