Module 0x5::order_match_types
- Enum
OrderMatchDetails - Enum
OrderMatch - Enum
ActiveMatchedOrder - Constants
- Function
new_single_order_match_details - Function
new_bulk_order_match_details - Function
new_order_match - Function
new_order_match_details_with_modified_size - Function
new_active_matched_order - Function
get_matched_size - Function
get_account_from_match_details - Function
get_order_id_from_match_details - Function
get_unique_priority_idx_from_match_details - Function
get_price_from_match_details - Function
get_orig_size_from_match_details - Function
get_remaining_size_from_match_details - Function
get_time_in_force_from_match_details - Function
get_metadata_from_match_details - Function
get_client_order_id_from_match_details - Function
is_bid_from_match_details - Function
get_book_type_from_match_details - Function
is_bulk_order_from_match_details - Function
is_single_order_from_match_details - Function
get_sequence_number_from_match_details - Function
get_creation_time_micros_from_match_details - Function
destroy_order_match - Function
destroy_single_order_match_details - Function
validate_single_order_reinsertion_request - Function
validate_bulk_order_reinsertion_request - Function
destroy_active_matched_order - Function
is_active_matched_book_type_single_order
use 0x1::option;
use 0x1::string;
use 0x5::order_book_types;
Enum OrderMatchDetails
Represents the details of a matched order.
Contains information about an order that was matched, including its identifier, account, priority index, price, sizes, and side.
Fields:
order_id: Unique identifier for the orderaccount: Account that placed the orderunique_priority_idx: Priority index for time-based orderingprice: Price at which the order was matchedorig_size: Original size of the orderremaining_size: Remaining size after the matchis_bid: True if this was a bid order, false if ask order
enum OrderMatchDetails<M: copy, drop, store> has copy, drop
Variants
SingleOrder
Fields
-
order_id: order_book_types::OrderId -
account: address -
client_order_id: option::Option<string::String> -
unique_priority_idx: order_book_types::IncreasingIdx -
price: u64 -
orig_size: u64 -
remaining_size: u64 -
is_bid: bool -
time_in_force: order_book_types::TimeInForce -
creation_time_micros: u64 -
metadata: M
BulkOrder
Fields
-
order_id: order_book_types::OrderId -
account: address -
unique_priority_idx: order_book_types::IncreasingIdx -
price: u64 -
remaining_size: u64 -
is_bid: bool -
sequence_number: u64 -
creation_time_micros: u64 -
metadata: M
Enum OrderMatch
Represents a single match between a taker order and a maker order.
Contains the matched order details and the size that was matched in this particular match operation.
Fields:
order: The matched order resultmatched_size: The size that was matched in this operation
enum OrderMatch<M: copy, drop, store> has copy, drop
Variants
V1
Fields
-
order: order_match_types::OrderMatchDetails<M> -
matched_size: u64
Enum ActiveMatchedOrder
enum ActiveMatchedOrder has copy, drop
Variants
V1
Fields
-
order_id: order_book_types::OrderId -
matched_size: u64 -
remaining_size: u64 - Remaining size of the maker order
-
order_book_type: order_book_types::OrderType
Constants
const E_REINSERT_ORDER_MISMATCH: u64 = 8;
Function new_single_order_match_details
public fun new_single_order_match_details<M: copy, drop, store>(order_id: order_book_types::OrderId, account: address, client_order_id: option::Option<string::String>, unique_priority_idx: order_book_types::IncreasingIdx, price: u64, orig_size: u64, remaining_size: u64, is_bid: bool, time_in_force: order_book_types::TimeInForce, creation_time_micros: u64, metadata: M): order_match_types::OrderMatchDetails<M>
Implementation
public fun new_single_order_match_details<M: store + copy + drop>(
order_id: OrderId,
account: address,
client_order_id: Option<String>,
unique_priority_idx: IncreasingIdx,
price: u64,
orig_size: u64,
remaining_size: u64,
is_bid: bool,
time_in_force: TimeInForce,
creation_time_micros: u64,
metadata: M
): OrderMatchDetails<M> {
OrderMatchDetails::SingleOrder {
order_id,
account,
client_order_id,
unique_priority_idx,
price,
orig_size,
remaining_size,
is_bid,
time_in_force,
creation_time_micros,
metadata
}
}
Function new_bulk_order_match_details
public fun new_bulk_order_match_details<M: copy, drop, store>(order_id: order_book_types::OrderId, account: address, unique_priority_idx: order_book_types::IncreasingIdx, price: u64, remaining_size: u64, is_bid: bool, sequence_number: u64, creation_time_micros: u64, metadata: M): order_match_types::OrderMatchDetails<M>
Implementation
public fun new_bulk_order_match_details<M: store + copy + drop>(
order_id: OrderId,
account: address,
unique_priority_idx: IncreasingIdx,
price: u64,
remaining_size: u64,
is_bid: bool,
sequence_number: u64,
creation_time_micros: u64,
metadata: M
): OrderMatchDetails<M> {
OrderMatchDetails::BulkOrder {
order_id,
account,
unique_priority_idx,
price,
remaining_size,
is_bid,
sequence_number,
creation_time_micros,
metadata
}
}
Function new_order_match
public fun new_order_match<M: copy, drop, store>(order: order_match_types::OrderMatchDetails<M>, matched_size: u64): order_match_types::OrderMatch<M>
Implementation
public fun new_order_match<M: store + copy + drop>(
order: OrderMatchDetails<M>, matched_size: u64
): OrderMatch<M> {
OrderMatch::V1 { order, matched_size }
}
Function new_order_match_details_with_modified_size
public fun new_order_match_details_with_modified_size<M: copy, drop, store>(self: &order_match_types::OrderMatchDetails<M>, remaining_size: u64): order_match_types::OrderMatchDetails<M>
Implementation
public fun new_order_match_details_with_modified_size<M: store + copy + drop>(
self: &OrderMatchDetails<M>, remaining_size: u64
): OrderMatchDetails<M> {
let res = *self;
res.remaining_size = remaining_size;
res
}
Function new_active_matched_order
public fun new_active_matched_order(order_id: order_book_types::OrderId, matched_size: u64, remaining_size: u64, order_book_type: order_book_types::OrderType): order_match_types::ActiveMatchedOrder
Implementation
public fun new_active_matched_order(
order_id: OrderId,
matched_size: u64,
remaining_size: u64,
order_book_type: OrderType
): ActiveMatchedOrder {
ActiveMatchedOrder::V1 { order_id, matched_size, remaining_size, order_book_type }
}
Function get_matched_size
public fun get_matched_size<M: copy, drop, store>(self: &order_match_types::OrderMatch<M>): u64
Implementation
public fun get_matched_size<M: store + copy + drop>(self: &OrderMatch<M>): u64 {
self.matched_size
}
Function get_account_from_match_details
Validates that a reinsertion request is valid for the given original order.
public fun get_account_from_match_details<M: copy, drop, store>(self: &order_match_types::OrderMatchDetails<M>): address
Implementation
public fun get_account_from_match_details<M: store + copy + drop>(
self: &OrderMatchDetails<M>
): address {
self.account
}
Function get_order_id_from_match_details
public fun get_order_id_from_match_details<M: copy, drop, store>(self: &order_match_types::OrderMatchDetails<M>): order_book_types::OrderId
Implementation
public fun get_order_id_from_match_details<M: store + copy + drop>(
self: &OrderMatchDetails<M>
): OrderId {
self.order_id
}
Function get_unique_priority_idx_from_match_details
public fun get_unique_priority_idx_from_match_details<M: copy, drop, store>(self: &order_match_types::OrderMatchDetails<M>): order_book_types::IncreasingIdx
Implementation
public fun get_unique_priority_idx_from_match_details<M: store + copy + drop>(
self: &OrderMatchDetails<M>
): IncreasingIdx {
self.unique_priority_idx
}
Function get_price_from_match_details
public fun get_price_from_match_details<M: copy, drop, store>(self: &order_match_types::OrderMatchDetails<M>): u64
Implementation
public fun get_price_from_match_details<M: store + copy + drop>(
self: &OrderMatchDetails<M>
): u64 {
self.price
}
Function get_orig_size_from_match_details
public fun get_orig_size_from_match_details<M: copy, drop, store>(self: &order_match_types::OrderMatchDetails<M>): u64
Implementation
public fun get_orig_size_from_match_details<M: store + copy + drop>(
self: &OrderMatchDetails<M>
): u64 {
self.orig_size
}
Function get_remaining_size_from_match_details
public fun get_remaining_size_from_match_details<M: copy, drop, store>(self: &order_match_types::OrderMatchDetails<M>): u64
Implementation
public fun get_remaining_size_from_match_details<M: store + copy + drop>(
self: &OrderMatchDetails<M>
): u64 {
self.remaining_size
}
Function get_time_in_force_from_match_details
public fun get_time_in_force_from_match_details<M: copy, drop, store>(self: &order_match_types::OrderMatchDetails<M>): order_book_types::TimeInForce
Implementation
public fun get_time_in_force_from_match_details<M: store + copy + drop>(
self: &OrderMatchDetails<M>
): TimeInForce {
if (self is OrderMatchDetails::SingleOrder) {
self.time_in_force
} else {
good_till_cancelled()
}
}
Function get_metadata_from_match_details
public fun get_metadata_from_match_details<M: copy, drop, store>(self: &order_match_types::OrderMatchDetails<M>): M
Implementation
public fun get_metadata_from_match_details<M: store + copy + drop>(
self: &OrderMatchDetails<M>
): M {
self.metadata
}
Function get_client_order_id_from_match_details
public fun get_client_order_id_from_match_details<M: copy, drop, store>(self: &order_match_types::OrderMatchDetails<M>): option::Option<string::String>
Implementation
public fun get_client_order_id_from_match_details<M: store + copy + drop>(
self: &OrderMatchDetails<M>
): Option<String> {
if (self is OrderMatchDetails::SingleOrder) {
self.client_order_id
} else {
option::none()
}
}
Function is_bid_from_match_details
public fun is_bid_from_match_details<M: copy, drop, store>(self: &order_match_types::OrderMatchDetails<M>): bool
Implementation
public fun is_bid_from_match_details<M: store + copy + drop>(
self: &OrderMatchDetails<M>
): bool {
self.is_bid
}
Function get_book_type_from_match_details
public fun get_book_type_from_match_details<M: copy, drop, store>(self: &order_match_types::OrderMatchDetails<M>): order_book_types::OrderType
Implementation
public fun get_book_type_from_match_details<M: store + copy + drop>(
self: &OrderMatchDetails<M>
): OrderType {
if (self is OrderMatchDetails::SingleOrder) {
single_order_type()
} else {
bulk_order_type()
}
}
Function is_bulk_order_from_match_details
public fun is_bulk_order_from_match_details<M: copy, drop, store>(self: &order_match_types::OrderMatchDetails<M>): bool
Implementation
public fun is_bulk_order_from_match_details<M: store + copy + drop>(
self: &OrderMatchDetails<M>
): bool {
self is OrderMatchDetails::BulkOrder
}
Function is_single_order_from_match_details
public fun is_single_order_from_match_details<M: copy, drop, store>(self: &order_match_types::OrderMatchDetails<M>): bool
Implementation
public fun is_single_order_from_match_details<M: store + copy + drop>(
self: &OrderMatchDetails<M>
): bool {
self is OrderMatchDetails::SingleOrder
}
Function get_sequence_number_from_match_details
This should only be called on bulk orders, aborts if called for non-bulk order.
public fun get_sequence_number_from_match_details<M: copy, drop, store>(self: &order_match_types::OrderMatchDetails<M>): u64
Implementation
public fun get_sequence_number_from_match_details<M: store + copy + drop>(
self: &OrderMatchDetails<M>
): u64 {
self.sequence_number
}
Function get_creation_time_micros_from_match_details
public fun get_creation_time_micros_from_match_details<M: copy, drop, store>(self: &order_match_types::OrderMatchDetails<M>): u64
Implementation
public fun get_creation_time_micros_from_match_details<M: store + copy + drop>(
self: &OrderMatchDetails<M>
): u64 {
self.creation_time_micros
}
Function destroy_order_match
public fun destroy_order_match<M: copy, drop, store>(self: order_match_types::OrderMatch<M>): (order_match_types::OrderMatchDetails<M>, u64)
Implementation
public fun destroy_order_match<M: store + copy + drop>(
self: OrderMatch<M>
): (OrderMatchDetails<M>, u64) {
let OrderMatch::V1 { order, matched_size } = self;
(order, matched_size)
}
Function destroy_single_order_match_details
public fun destroy_single_order_match_details<M: copy, drop, store>(self: order_match_types::OrderMatchDetails<M>): (order_book_types::OrderId, address, option::Option<string::String>, order_book_types::IncreasingIdx, u64, u64, u64, bool, order_book_types::TimeInForce, u64, M)
Implementation
public fun destroy_single_order_match_details<M: store + copy + drop>(
self: OrderMatchDetails<M>
): (
OrderId,
address,
Option<String>,
IncreasingIdx,
u64,
u64,
u64,
bool,
TimeInForce,
u64,
M
) {
let OrderMatchDetails::SingleOrder {
order_id,
account,
client_order_id,
unique_priority_idx,
price,
orig_size,
remaining_size,
is_bid,
time_in_force,
creation_time_micros,
metadata
} = self;
(
order_id,
account,
client_order_id,
unique_priority_idx,
price,
orig_size,
remaining_size,
is_bid,
time_in_force,
creation_time_micros,
metadata
)
}
Function validate_single_order_reinsertion_request
public fun validate_single_order_reinsertion_request<M: copy, drop, store>(self: &order_match_types::OrderMatchDetails<M>, other: &order_match_types::OrderMatchDetails<M>): bool
Implementation
public fun validate_single_order_reinsertion_request<M: store + copy + drop>(
self: &OrderMatchDetails<M>, other: &OrderMatchDetails<M>
): bool {
assert!(self is OrderMatchDetails::SingleOrder, E_REINSERT_ORDER_MISMATCH);
assert!(other is OrderMatchDetails::SingleOrder, E_REINSERT_ORDER_MISMATCH);
self.order_id == other.order_id
&& self.account == other.account
&& self.unique_priority_idx == other.unique_priority_idx
&& self.price == other.price
&& self.orig_size == other.orig_size
&& self.is_bid == other.is_bid
}
Function validate_bulk_order_reinsertion_request
public fun validate_bulk_order_reinsertion_request<M: copy, drop, store>(self: &order_match_types::OrderMatchDetails<M>, other: &order_match_types::OrderMatchDetails<M>): bool
Implementation
public fun validate_bulk_order_reinsertion_request<M: store + copy + drop>(
self: &OrderMatchDetails<M>, other: &OrderMatchDetails<M>
): bool {
assert!(self is OrderMatchDetails::BulkOrder, E_REINSERT_ORDER_MISMATCH);
assert!(other is OrderMatchDetails::BulkOrder, E_REINSERT_ORDER_MISMATCH);
self.order_id == other.order_id
&& self.account == other.account
&& self.unique_priority_idx == other.unique_priority_idx
&& self.price == other.price
&& self.is_bid == other.is_bid
&& self.sequence_number == other.sequence_number
}
Function destroy_active_matched_order
public fun destroy_active_matched_order(self: order_match_types::ActiveMatchedOrder): (order_book_types::OrderId, u64, u64, order_book_types::OrderType)
Implementation
public fun destroy_active_matched_order(self: ActiveMatchedOrder)
: (OrderId, u64, u64, OrderType) {
let ActiveMatchedOrder::V1 {
order_id,
matched_size,
remaining_size,
order_book_type
} = self;
(order_id, matched_size, remaining_size, order_book_type)
}
Function is_active_matched_book_type_single_order
public fun is_active_matched_book_type_single_order(self: &order_match_types::ActiveMatchedOrder): bool
Implementation
public fun is_active_matched_book_type_single_order(
self: &ActiveMatchedOrder
): bool {
is_single_order_type(&self.order_book_type)
}