pub struct OrderBookManager<W: Account + Clone> {
pub proxy: OrderBookProxy<W>,
pub contract: OrderBook<W>,
pub gas_payer_wallet: W,
pub config: OrderbookConfig,
}Fields§
§proxy: OrderBookProxy<W>The OrderBook contract instance
contract: OrderBook<W>The OrderBook contract instance
gas_payer_wallet: WThe wallet used for creating transactions
config: OrderbookConfigConfguration
Implementations§
Source§impl<W: Account + Clone> OrderBookManager<W>
impl<W: Account + Clone> OrderBookManager<W>
Sourcepub fn new(
gas_payer_wallet: &W,
base_decimals: u64,
quote_decimals: u64,
order_book_deploy: &OrderBookDeploy<W>,
) -> Self
pub fn new( gas_payer_wallet: &W, base_decimals: u64, quote_decimals: u64, order_book_deploy: &OrderBookDeploy<W>, ) -> Self
Creates a new OrderBookManager instance.
§Arguments
contract_id- The deployed OrderBook contract IDwallet- The wallet to use for transactionsbase_asset- The base asset ID for the trading pairquote_asset- The quote asset ID for the trading pair
pub fn create_call_params( &self, params: &CreateOrderParams, gas: Option<u64>, ) -> CallParams
pub fn get_order_side_asset(&self, order_side: &Side) -> AssetId
pub fn get_order_side_amount( &self, quantity: u64, price: u64, side: &Side, ) -> u64
pub async fn balances_of(&self, identity: &Identity) -> Result<(u128, u128)>
pub async fn emit_config(&self) -> Result<()>
pub async fn upgrade(&self, deploy_config: &OrderBookDeployConfig) -> Result<()>
pub async fn accumulated_fees(&self) -> Result<(u64, u64)>
pub async fn get_whitelist_id(&self) -> Result<Option<ContractId>>
pub async fn get_blacklist_id(&self) -> Result<Option<ContractId>>
pub fn base_asset(&self) -> AssetId
pub fn base_decimals(&self) -> u64
pub fn quote_asset(&self) -> AssetId
pub fn quote_decimals(&self) -> u64
pub fn config(&self) -> OrderbookConfig
Sourcepub async fn create_trigger_order(
&self,
params: CreateTriggerOrderParams,
expected_parent_quantity: Option<u64>,
) -> Result<Bits256>
pub async fn create_trigger_order( &self, params: CreateTriggerOrderParams, expected_parent_quantity: Option<u64>, ) -> Result<Bits256>
Creates a single trigger order. When params.quantity is
TriggerQuantity::ParentOrder(spot_id), the trigger is attached to that resting spot
order. If the parent already has one child trigger, this trigger is registered as its
OCO sibling (one stop-loss, one take-profit). A parent may have at most two triggers.
If expected_parent_quantity is Some, the call reverts unless the parent spot order’s
remaining quantity exactly matches the provided value.
Sourcepub async fn create_trigger_orders(
&self,
params_1: CreateTriggerOrderParams,
params_2: CreateTriggerOrderParams,
expected_parent_quantity: Option<u64>,
) -> Result<(Bits256, Bits256)>
pub async fn create_trigger_orders( &self, params_1: CreateTriggerOrderParams, params_2: CreateTriggerOrderParams, expected_parent_quantity: Option<u64>, ) -> Result<(Bits256, Bits256)>
Creates two OCO-linked trigger orders in a single call. Both params must use the same
TriggerQuantity variant; if both are ParentOrder, they must reference the same
spot order. params_1 is canonical and its lock covers both orders.
If expected_parent_quantity is Some, the call reverts unless the parent spot order’s
remaining quantity exactly matches the provided value.
Sourcepub async fn execute_trigger_order(&self) -> Result<()>
pub async fn execute_trigger_order(&self) -> Result<()>
Executes the next trigger order at the head of the global queue.
Sourcepub async fn eject_trigger_order(&self) -> Result<()>
pub async fn eject_trigger_order(&self) -> Result<()>
Admin: ejects the stuck trigger at the head of the queue.
Sourcepub async fn get_trigger_order(
&self,
order_id: Bits256,
) -> Result<Option<TriggerOrder>>
pub async fn get_trigger_order( &self, order_id: Bits256, ) -> Result<Option<TriggerOrder>>
Returns the trigger order with the given ID, or None if it doesn’t exist.
Sourcepub async fn get_trigger_orders_at_price(
&self,
trigger_price: u64,
) -> Result<Vec<TriggerOrder>>
pub async fn get_trigger_orders_at_price( &self, trigger_price: u64, ) -> Result<Vec<TriggerOrder>>
Returns all trigger orders registered at the given trigger price.
Sourcepub async fn get_locked_balance_of(
&self,
trader: Identity,
order_id: Bits256,
) -> Result<u64>
pub async fn get_locked_balance_of( &self, trader: Identity, order_id: Bits256, ) -> Result<u64>
Returns the locked balance for a trader under a given trigger order ID.
Sourcepub async fn get_trigger_order_sibling(
&self,
order_id: Bits256,
) -> Result<Option<Bits256>>
pub async fn get_trigger_order_sibling( &self, order_id: Bits256, ) -> Result<Option<Bits256>>
Returns the sibling trigger order ID for an OCO pair, or None if no sibling exists.
Sourcepub async fn get_trigger_order_parent(
&self,
order_id: Bits256,
) -> Result<Option<Bits256>>
pub async fn get_trigger_order_parent( &self, order_id: Bits256, ) -> Result<Option<Bits256>>
Returns the parent spot order ID for a trigger order, or None if not attached.
Sourcepub async fn get_head_trigger_order(&self) -> Result<Option<TriggerOrder>>
pub async fn get_head_trigger_order(&self) -> Result<Option<TriggerOrder>>
Returns the trigger order at the head of the global execution queue, or None if empty.
pub async fn is_paused(&self) -> Result<bool>
Trait Implementations§
Auto Trait Implementations§
impl<W> Freeze for OrderBookManager<W>where
W: Freeze,
impl<W> RefUnwindSafe for OrderBookManager<W>where
W: RefUnwindSafe,
impl<W> Send for OrderBookManager<W>
impl<W> Sync for OrderBookManager<W>
impl<W> Unpin for OrderBookManager<W>where
W: Unpin,
impl<W> UnsafeUnpin for OrderBookManager<W>where
W: UnsafeUnpin,
impl<W> UnwindSafe for OrderBookManager<W>where
W: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> IsFieldType<T> for T
Source§impl<S> IteratorOverTable for S
impl<S> IteratorOverTable for S
Source§fn iter_all_keys<M>(
&self,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<<M as Mappable>::OwnedKey, Error>>where
M: Mappable,
Self: IterableTable<M>,
fn iter_all_keys<M>(
&self,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<<M as Mappable>::OwnedKey, Error>>where
M: Mappable,
Self: IterableTable<M>,
Source§fn iter_all_by_prefix_keys<M, P>(
&self,
prefix: Option<P>,
) -> BoxedIter<'_, Result<<M as Mappable>::OwnedKey, Error>>
fn iter_all_by_prefix_keys<M, P>( &self, prefix: Option<P>, ) -> BoxedIter<'_, Result<<M as Mappable>::OwnedKey, Error>>
Source§fn iter_all_by_start_keys<M>(
&self,
start: Option<&<M as Mappable>::Key>,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<<M as Mappable>::OwnedKey, Error>>where
M: Mappable,
Self: IterableTable<M>,
fn iter_all_by_start_keys<M>(
&self,
start: Option<&<M as Mappable>::Key>,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<<M as Mappable>::OwnedKey, Error>>where
M: Mappable,
Self: IterableTable<M>,
Source§fn iter_all_filtered_keys<M, P>(
&self,
prefix: Option<P>,
start: Option<&<M as Mappable>::Key>,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<<M as Mappable>::OwnedKey, Error>>
fn iter_all_filtered_keys<M, P>( &self, prefix: Option<P>, start: Option<&<M as Mappable>::Key>, direction: Option<IterDirection>, ) -> BoxedIter<'_, Result<<M as Mappable>::OwnedKey, Error>>
Source§fn iter_all<M>(
&self,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>where
M: Mappable,
Self: IterableTable<M>,
fn iter_all<M>(
&self,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>where
M: Mappable,
Self: IterableTable<M>,
Source§fn iter_all_by_prefix<M, P>(
&self,
prefix: Option<P>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>
fn iter_all_by_prefix<M, P>( &self, prefix: Option<P>, ) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>
Source§fn iter_all_by_start<M>(
&self,
start: Option<&<M as Mappable>::Key>,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>where
M: Mappable,
Self: IterableTable<M>,
fn iter_all_by_start<M>(
&self,
start: Option<&<M as Mappable>::Key>,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>where
M: Mappable,
Self: IterableTable<M>,
Source§fn iter_all_filtered<M, P>(
&self,
prefix: Option<P>,
start: Option<&<M as Mappable>::Key>,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>
fn iter_all_filtered<M, P>( &self, prefix: Option<P>, start: Option<&<M as Mappable>::Key>, direction: Option<IterDirection>, ) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>
impl<T> JsonSchemaMaybe for T
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> StorageAsMut for T
impl<T> StorageAsMut for T
fn storage<Type>(&mut self) -> StorageMut<'_, Self, Type>where
Type: Mappable,
fn storage_as_mut<Type>(&mut self) -> StorageMut<'_, Self, Type>where
Type: Mappable,
Source§impl<T> StorageAsRef for T
impl<T> StorageAsRef for T
fn storage<Type>(&self) -> StorageRef<'_, Self, Type>where
Type: Mappable,
fn storage_as_ref<Type>(&self) -> StorageRef<'_, Self, Type>where
Type: Mappable,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.