pub struct OrderBuilder { /* private fields */ }Expand description
Main OrderBuilder struct for creating and signing orders
This is the primary interface for interact with predict.fun’s CTF Exchange
Implementations§
Source§impl OrderBuilder
impl OrderBuilder
Sourcepub fn new(
chain_id: ChainId,
signer: Option<PrivateKeySigner>,
options: Option<OrderBuilderOptions>,
) -> Result<Self>
pub fn new( chain_id: ChainId, signer: Option<PrivateKeySigner>, options: Option<OrderBuilderOptions>, ) -> Result<Self>
Sourcepub fn with_predict_account(
chain_id: ChainId,
signer: PrivateKeySigner,
predict_account: &str,
options: Option<OrderBuilderOptions>,
) -> Result<Self>
pub fn with_predict_account( chain_id: ChainId, signer: PrivateKeySigner, predict_account: &str, options: Option<OrderBuilderOptions>, ) -> Result<Self>
Create a new OrderBuilder with Predict Account support
Use this constructor when trading via a Predict Smart Wallet (Kernel-based).
The predict_account address will be used as the order maker, and
signatures will use Kernel EIP-712 wrapping.
§Arguments
chain_id- The chain ID (BNB Mainnet or Testnet)signer- The Privy private key signerpredict_account- The Predict Account (smart wallet) addressoptions- Optional configuration options
§Returns
A new OrderBuilder instance configured for Predict Account signing
Sourcepub fn uses_predict_account(&self) -> bool
pub fn uses_predict_account(&self) -> bool
Check if this OrderBuilder uses Predict Account signing
Sourcepub fn predict_account(&self) -> Option<Address>
pub fn predict_account(&self) -> Option<Address>
Get the Predict Account address if set
Sourcepub fn signer_address(&self) -> Result<Address>
pub fn signer_address(&self) -> Result<Address>
Sourcepub fn signer(&self) -> Option<PrivateKeySigner>
pub fn signer(&self) -> Option<PrivateKeySigner>
Get a clone of the signer (for on-chain operations)
§Returns
A clone of the signer, or None if no signer is configured
Sourcepub fn get_limit_order_amounts(
&self,
data: LimitOrderData,
) -> Result<LimitOrderAmounts>
pub fn get_limit_order_amounts( &self, data: LimitOrderData, ) -> Result<LimitOrderAmounts>
Sourcepub fn build_order(
&self,
strategy: OrderStrategy,
input: BuildOrderInput,
) -> Result<Order>
pub fn build_order( &self, strategy: OrderStrategy, input: BuildOrderInput, ) -> Result<Order>
Sourcepub fn get_verifying_contract(
&self,
is_neg_risk: bool,
is_yield_bearing: bool,
) -> Address
pub fn get_verifying_contract( &self, is_neg_risk: bool, is_yield_bearing: bool, ) -> Address
Sourcepub fn build_typed_data_hash(
&self,
order: &Order,
is_neg_risk: bool,
is_yield_bearing: bool,
) -> Result<String>
pub fn build_typed_data_hash( &self, order: &Order, is_neg_risk: bool, is_yield_bearing: bool, ) -> Result<String>
Sourcepub async fn sign_typed_data_order(
&self,
order: Order,
is_neg_risk: bool,
is_yield_bearing: bool,
) -> Result<SignedOrder>
pub async fn sign_typed_data_order( &self, order: Order, is_neg_risk: bool, is_yield_bearing: bool, ) -> Result<SignedOrder>
Sign an order using EIP-712
This method automatically uses the appropriate signing method:
- For regular EOA wallets: Standard EIP-712 signing
- For Predict Account (Kernel): Kernel-wrapped EIP-712 signing
§Arguments
order- The order to signis_neg_risk- Whether this is a neg risk marketis_yield_bearing- Whether this market has yield enabled
§Returns
A signed order with signature
§Errors
Returns an error if no signer is configured or signing fails
Sourcepub async fn sign_typed_data_order_eoa(
&self,
order: Order,
is_neg_risk: bool,
is_yield_bearing: bool,
) -> Result<SignedOrder>
pub async fn sign_typed_data_order_eoa( &self, order: Order, is_neg_risk: bool, is_yield_bearing: bool, ) -> Result<SignedOrder>
Sign an order using standard EOA EIP-712 (never Kernel-wrapped)
This is used for REST API order placement, where the server does plain ecrecover to verify the signature. Kernel-wrapped signatures are only needed for on-chain settlement, which the platform handles internally.
Sourcepub fn signer_address_string(&self) -> Result<String>
pub fn signer_address_string(&self) -> Result<String>
Get the EOA signer address as a formatted string
Auto Trait Implementations§
impl Freeze for OrderBuilder
impl RefUnwindSafe for OrderBuilder
impl Send for OrderBuilder
impl Sync for OrderBuilder
impl Unpin for OrderBuilder
impl UnwindSafe for OrderBuilder
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> 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