pub struct OstiumClient { /* private fields */ }Expand description
Main client for interacting with the Ostium platform
Implementations§
Source§impl OstiumClient
impl OstiumClient
Sourcepub fn builder(network: Network) -> OstiumClientBuilder
pub fn builder(network: Network) -> OstiumClientBuilder
Create a new client builder for the specified network
Sourcepub fn builder_with_config(config: NetworkConfig) -> OstiumClientBuilder
pub fn builder_with_config(config: NetworkConfig) -> OstiumClientBuilder
Create a new client builder with custom configuration
Sourcepub async fn new(network: Network) -> Result<Self>
pub async fn new(network: Network) -> Result<Self>
Create a new client with default configuration (no signer)
Sourcepub fn config(&self) -> &NetworkConfig
pub fn config(&self) -> &NetworkConfig
Get the network configuration
Sourcepub fn signer_address(&self) -> Option<Address>
pub fn signer_address(&self) -> Option<Address>
Get the signer address if available
Sourcepub fn has_signer(&self) -> bool
pub fn has_signer(&self) -> bool
Check if the client has a signer configured
Sourcepub fn map_contract_error(
&self,
error: &str,
) -> (String, String, HashMap<String, String>)
pub fn map_contract_error( &self, error: &str, ) -> (String, String, HashMap<String, String>)
Maps Ethereum contract error selectors to human-readable messages
This function takes a contract error and attempts to decode it into a more meaningful error message based on known Ostium contract error selectors.
§Arguments
error- The error object or string containing the contract error
§Returns
A tuple containing (error_message, error_type, error_data)
Sourcepub fn extract_error_selector(&self, error: &str) -> Option<String>
pub fn extract_error_selector(&self, error: &str) -> Option<String>
Extracts error selector (0x + 8 hex chars) from error message
Sourcepub fn get_error_description(&self, selector: &str) -> Option<&'static str>
pub fn get_error_description(&self, selector: &str) -> Option<&'static str>
Get human-readable error message for a specific error selector
Sourcepub fn map_contract_error_with_suggestions(
&self,
error: &str,
) -> (String, String, HashMap<String, String>, Option<String>)
pub fn map_contract_error_with_suggestions( &self, error: &str, ) -> (String, String, HashMap<String, String>, Option<String>)
Enhanced error mapping that includes suggestions for common issues
Sourcepub async fn get_minimum_position_size(&self, symbol: &str) -> Result<Decimal>
pub async fn get_minimum_position_size(&self, symbol: &str) -> Result<Decimal>
Get minimum position size for a given symbol Returns the minimum position size in the base asset units
Sourcepub async fn validate_trading_constraints(
&self,
symbol: &str,
side: PositionSide,
size: Decimal,
leverage: Decimal,
) -> Result<()>
pub async fn validate_trading_constraints( &self, symbol: &str, side: PositionSide, size: Decimal, leverage: Decimal, ) -> Result<()>
Validate trading constraints before executing a trade Checks: 1) Trading hours, 2) Minimum position size, 3) Open interest caps
Source§impl OstiumClient
impl OstiumClient
Sourcepub async fn open_position(&self, params: OpenPositionParams) -> Result<TxHash>
pub async fn open_position(&self, params: OpenPositionParams) -> Result<TxHash>
Open a new trading position
Sourcepub async fn close_position(
&self,
params: ClosePositionParams,
) -> Result<TxHash>
pub async fn close_position( &self, params: ClosePositionParams, ) -> Result<TxHash>
Close an existing position
Sourcepub async fn update_tp_sl(&self, params: UpdateTPSLParams) -> Result<TxHash>
pub async fn update_tp_sl(&self, params: UpdateTPSLParams) -> Result<TxHash>
Update take profit and stop loss for a position
Sourcepub async fn open_position_unsigned(
&self,
params: OpenPositionParams,
trader_address: Address,
tx_params: UnsignedTransactionParams,
) -> Result<UnsignedTransaction>
pub async fn open_position_unsigned( &self, params: OpenPositionParams, trader_address: Address, tx_params: UnsignedTransactionParams, ) -> Result<UnsignedTransaction>
Build unsigned transaction for opening a position
Sourcepub async fn close_position_unsigned(
&self,
params: ClosePositionParams,
tx_params: UnsignedTransactionParams,
) -> Result<UnsignedTransaction>
pub async fn close_position_unsigned( &self, params: ClosePositionParams, tx_params: UnsignedTransactionParams, ) -> Result<UnsignedTransaction>
Build unsigned transaction for closing a position
Sourcepub async fn update_tp_sl_unsigned(
&self,
params: UpdateTPSLParams,
tx_params: UnsignedTransactionParams,
) -> Result<Vec<UnsignedTransaction>>
pub async fn update_tp_sl_unsigned( &self, params: UpdateTPSLParams, tx_params: UnsignedTransactionParams, ) -> Result<Vec<UnsignedTransaction>>
Build unsigned transactions for updating TP/SL
Sourcepub async fn place_advanced_order_unsigned(
&self,
params: AdvancedOrderParams,
trader_address: Address,
tx_params: UnsignedTransactionParams,
) -> Result<UnsignedTransaction>
pub async fn place_advanced_order_unsigned( &self, params: AdvancedOrderParams, trader_address: Address, tx_params: UnsignedTransactionParams, ) -> Result<UnsignedTransaction>
Build unsigned transaction for placing an advanced order
Sourcepub async fn cancel_order_unsigned(
&self,
params: CancelOrderParams,
tx_params: UnsignedTransactionParams,
) -> Result<UnsignedTransaction>
pub async fn cancel_order_unsigned( &self, params: CancelOrderParams, tx_params: UnsignedTransactionParams, ) -> Result<UnsignedTransaction>
Build unsigned transaction for canceling an order
Source§impl OstiumClient
impl OstiumClient
Sourcepub async fn place_advanced_order(
&self,
params: AdvancedOrderParams,
) -> Result<TxHash>
pub async fn place_advanced_order( &self, params: AdvancedOrderParams, ) -> Result<TxHash>
Place an advanced order (market, limit, or stop)
Sourcepub async fn place_limit_order(
&self,
params: LimitOrderParams,
) -> Result<TxHash>
pub async fn place_limit_order( &self, params: LimitOrderParams, ) -> Result<TxHash>
Place a limit order
Sourcepub async fn place_stop_order(&self, params: StopOrderParams) -> Result<TxHash>
pub async fn place_stop_order(&self, params: StopOrderParams) -> Result<TxHash>
Place a stop order
Sourcepub async fn cancel_order(&self, params: CancelOrderParams) -> Result<TxHash>
pub async fn cancel_order(&self, params: CancelOrderParams) -> Result<TxHash>
Cancel an open limit or stop order
Sourcepub async fn update_limit_order(
&self,
params: UpdateLimitOrderParams,
) -> Result<TxHash>
pub async fn update_limit_order( &self, params: UpdateLimitOrderParams, ) -> Result<TxHash>
Update an existing limit order
Sourcepub async fn validate_order_price(
&self,
symbol: &str,
order_type: OrderExecutionType,
price: Decimal,
) -> Result<bool>
pub async fn validate_order_price( &self, symbol: &str, order_type: OrderExecutionType, price: Decimal, ) -> Result<bool>
Get current market price for validation purposes
Source§impl OstiumClient
impl OstiumClient
Sourcepub async fn get_pairs(&self) -> Result<Vec<TradingPair>>
pub async fn get_pairs(&self) -> Result<Vec<TradingPair>>
Get all available trading pairs
Sourcepub async fn get_price(&self, symbol: &str) -> Result<Price>
pub async fn get_price(&self, symbol: &str) -> Result<Price>
Get current price for a trading pair
Sourcepub async fn get_trading_hours(&self, symbol: &str) -> Result<TradingHours>
pub async fn get_trading_hours(&self, symbol: &str) -> Result<TradingHours>
Get trading hours for a symbol
Trait Implementations§
Source§impl AccountApi for OstiumClient
impl AccountApi for OstiumClient
Source§impl AdvancedOrderApi for OstiumClient
impl AdvancedOrderApi for OstiumClient
Source§async fn place_advanced_order(
&self,
params: AdvancedOrderParams,
) -> Result<TxHash>
async fn place_advanced_order( &self, params: AdvancedOrderParams, ) -> Result<TxHash>
Source§async fn place_limit_order(&self, params: LimitOrderParams) -> Result<TxHash>
async fn place_limit_order(&self, params: LimitOrderParams) -> Result<TxHash>
Source§async fn place_stop_order(&self, params: StopOrderParams) -> Result<TxHash>
async fn place_stop_order(&self, params: StopOrderParams) -> Result<TxHash>
Source§async fn cancel_order(&self, params: CancelOrderParams) -> Result<TxHash>
async fn cancel_order(&self, params: CancelOrderParams) -> Result<TxHash>
Source§async fn update_limit_order(
&self,
params: UpdateLimitOrderParams,
) -> Result<TxHash>
async fn update_limit_order( &self, params: UpdateLimitOrderParams, ) -> Result<TxHash>
Source§async fn validate_order_price(
&self,
symbol: &str,
order_type: OrderExecutionType,
price: Decimal,
) -> Result<bool>
async fn validate_order_price( &self, symbol: &str, order_type: OrderExecutionType, price: Decimal, ) -> Result<bool>
Source§impl Clone for OstiumClient
impl Clone for OstiumClient
Source§fn clone(&self) -> OstiumClient
fn clone(&self) -> OstiumClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl MarketDataApi for OstiumClient
impl MarketDataApi for OstiumClient
Source§impl TradingApi for OstiumClient
impl TradingApi for OstiumClient
Source§async fn open_position(&self, params: OpenPositionParams) -> Result<TxHash>
async fn open_position(&self, params: OpenPositionParams) -> Result<TxHash>
Source§async fn close_position(&self, params: ClosePositionParams) -> Result<TxHash>
async fn close_position(&self, params: ClosePositionParams) -> Result<TxHash>
Source§async fn update_tp_sl(&self, params: UpdateTPSLParams) -> Result<TxHash>
async fn update_tp_sl(&self, params: UpdateTPSLParams) -> Result<TxHash>
Source§impl UnsignedTransactionApi for OstiumClient
impl UnsignedTransactionApi for OstiumClient
Source§async fn open_position_unsigned(
&self,
params: OpenPositionParams,
trader_address: Address,
tx_params: UnsignedTransactionParams,
) -> Result<UnsignedTransaction>
async fn open_position_unsigned( &self, params: OpenPositionParams, trader_address: Address, tx_params: UnsignedTransactionParams, ) -> Result<UnsignedTransaction>
Source§async fn close_position_unsigned(
&self,
params: ClosePositionParams,
tx_params: UnsignedTransactionParams,
) -> Result<UnsignedTransaction>
async fn close_position_unsigned( &self, params: ClosePositionParams, tx_params: UnsignedTransactionParams, ) -> Result<UnsignedTransaction>
Source§async fn update_tp_sl_unsigned(
&self,
params: UpdateTPSLParams,
tx_params: UnsignedTransactionParams,
) -> Result<Vec<UnsignedTransaction>>
async fn update_tp_sl_unsigned( &self, params: UpdateTPSLParams, tx_params: UnsignedTransactionParams, ) -> Result<Vec<UnsignedTransaction>>
Source§async fn place_advanced_order_unsigned(
&self,
params: AdvancedOrderParams,
trader_address: Address,
tx_params: UnsignedTransactionParams,
) -> Result<UnsignedTransaction>
async fn place_advanced_order_unsigned( &self, params: AdvancedOrderParams, trader_address: Address, tx_params: UnsignedTransactionParams, ) -> Result<UnsignedTransaction>
Source§async fn cancel_order_unsigned(
&self,
params: CancelOrderParams,
tx_params: UnsignedTransactionParams,
) -> Result<UnsignedTransaction>
async fn cancel_order_unsigned( &self, params: CancelOrderParams, tx_params: UnsignedTransactionParams, ) -> Result<UnsignedTransaction>
Auto Trait Implementations§
impl Freeze for OstiumClient
impl !RefUnwindSafe for OstiumClient
impl Send for OstiumClient
impl Sync for OstiumClient
impl Unpin for OstiumClient
impl !UnwindSafe for OstiumClient
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> 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 more