pub struct OrderBuilder { /* private fields */ }Expand description
Builder for creating orders with a fluent API.
Provides a convenient way to construct, sign, and convert orders for API submission in a single chain of method calls.
§Example
use lightcone_sdk::prelude::*;
let request = OrderBuilder::new()
.maker(maker_pubkey)
.market(market_pubkey)
.base_mint(yes_token)
.quote_mint(usdc)
.bid()
.nonce(5)
.maker_amount(1_000_000)
.taker_amount(500_000)
.build_and_sign(&keypair)
.to_submit_request("orderbook_id");Implementations§
Source§impl OrderBuilder
impl OrderBuilder
Sourcepub fn nonce(self, nonce: u64) -> Self
pub fn nonce(self, nonce: u64) -> Self
Set the nonce (required).
The nonce must be >= the user’s on-chain nonce for the order to be valid.
Sourcepub fn maker(self, maker: Pubkey) -> Self
pub fn maker(self, maker: Pubkey) -> Self
Set the maker pubkey (required).
This is the public key of the order creator.
Sourcepub fn base_mint(self, base_mint: Pubkey) -> Self
pub fn base_mint(self, base_mint: Pubkey) -> Self
Set the base mint / token being bought or sold (required).
Sourcepub fn quote_mint(self, quote_mint: Pubkey) -> Self
pub fn quote_mint(self, quote_mint: Pubkey) -> Self
Set the quote mint / payment token (required).
Sourcepub fn maker_amount(self, amount: u64) -> Self
pub fn maker_amount(self, amount: u64) -> Self
Set the amount the maker gives.
Sourcepub fn taker_amount(self, amount: u64) -> Self
pub fn taker_amount(self, amount: u64) -> Self
Set the amount the maker wants to receive.
Sourcepub fn expiration(self, expiration: i64) -> Self
pub fn expiration(self, expiration: i64) -> Self
Set expiration timestamp (0 = no expiration).
Sourcepub fn build(self) -> FullOrder
pub fn build(self) -> FullOrder
Build an unsigned FullOrder.
The returned order has an all-zero signature and must be signed before submission.
§Panics
Panics if required fields are missing.
Sourcepub fn build_and_sign(self, keypair: &Keypair) -> FullOrder
pub fn build_and_sign(self, keypair: &Keypair) -> FullOrder
Build and sign the order with the given keypair.
Returns a signed FullOrder ready for API submission.
§Panics
Panics if required fields are missing.
Sourcepub fn to_submit_request(
self,
keypair: &Keypair,
orderbook_id: impl Into<String>,
) -> SubmitOrderRequest
pub fn to_submit_request( self, keypair: &Keypair, orderbook_id: impl Into<String>, ) -> SubmitOrderRequest
Trait Implementations§
Source§impl Clone for OrderBuilder
impl Clone for OrderBuilder
Source§fn clone(&self) -> OrderBuilder
fn clone(&self) -> OrderBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OrderBuilder
impl Debug for OrderBuilder
Source§impl Default for OrderBuilder
impl Default for OrderBuilder
Source§fn default() -> OrderBuilder
fn default() -> OrderBuilder
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<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> 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