Skip to content

Commit

Permalink
Added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
crnbarr93 committed Feb 27, 2024
1 parent 7f31704 commit a057acb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 4 additions & 1 deletion contracts/orderbook/src/order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,14 @@ pub fn place_limit(
let mut response = Response::default();
// Run order fill if criteria met
if should_fill {
// Convert order to market order for filling
let mut market_order: MarketOrder = limit_order.clone().into();
// Generate vector of fulfillments for current orders and a payment for the placed order
let (fulfillments, placed_order_payment) =
run_market_order(deps.storage, &mut market_order, Some(tick_id))?;
// Resolve given fulfillments and current placed order
let fulfillment_msgs = resolve_fulfillments(deps.storage, fulfillments)?;
// Update limit order quantity to reflect fulfilled amount
limit_order.quantity = market_order.quantity;

response = response
Expand Down Expand Up @@ -299,7 +303,6 @@ pub fn resolve_fulfillments(
ensure_eq!(
fulfillment.order.book_id,
orderbook.book_id,
// TODO: Error not expressive
ContractError::InvalidFulfillment {
order_id: fulfillment.order.order_id,
book_id: fulfillment.order.book_id,
Expand Down
3 changes: 1 addition & 2 deletions contracts/orderbook/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ pub const ORDERBOOKS: Map<&u64, Orderbook> = Map::new("orderbooks");
/// Key: (orderbook_id, tick)
pub const TICK_LIQUIDITY: Map<&(u64, i64), Uint128> = Map::new("tick_liquidity");

// TODO: Check additional gas fee for adding more indexes
pub struct OrderIndexes {
// Index by owner; Generic types: MultiIndex<Index Key: owner, Input Data: LimitOrder, Map Key: (orderbook_id, tick, order_id)>
pub owner: MultiIndex<'static, Addr, LimitOrder, (u64, i64, u64)>,
Expand Down Expand Up @@ -87,7 +86,7 @@ pub fn reduce_tick_liquidity(
TICK_LIQUIDITY.remove(storage, &(book_id, tick_id));
} else {
TICK_LIQUIDITY.save(storage, &(book_id, tick_id), &new_liquidity)?;
}
};
Ok(())
}

Expand Down

0 comments on commit a057acb

Please sign in to comment.