pub struct SnapshotBuilder<P> { /* private fields */ }Expand description
Builds a consistent snapshot of the exchange state
that can be then kept up-to-date by the data from crate::stream::raw.
Implementations§
Source§impl<P: Provider + Clone> SnapshotBuilder<P>
impl<P: Provider + Clone> SnapshotBuilder<P>
Sourcepub fn new(chain: &Chain, provider: P) -> Self
pub fn new(chain: &Chain, provider: P) -> Self
Creates a new SnapshotBuilder which fetches the full exchange state
at the latest safe/voted block.
Sourcepub fn at_block(self, block: BlockId) -> Self
pub fn at_block(self, block: BlockId) -> Self
Sets the block number or tag to fetch the state at (default:
alloy::eips::BlockNumberOrTag::Safe). If tag is provided, it gets
converted to a specific block number first to ensure state
consistency.
Sourcepub fn with_perpetuals(self, perpetuals: Vec<PerpetualId>) -> Self
pub fn with_perpetuals(self, perpetuals: Vec<PerpetualId>) -> Self
Sets the list of perpetual contract IDs to fetch the state for.
An empty list (the default, see Chain::perpetuals) means every
perpetual listed on the exchange, discovered on-chain.
Sourcepub fn with_accounts(self, accounts: Vec<AccountAddressOrID>) -> Self
pub fn with_accounts(self, accounts: Vec<AccountAddressOrID>) -> Self
Sets the list of addresses to fetch the state of exchange accounts for. Assumes accounts already exist, snapshot creation will fail otherwise.
Sourcepub fn with_all_positions(self) -> Self
pub fn with_all_positions(self) -> Self
Forces to fetch all available positions, along with corresponding
accounts, but without account state snapshot.
Mutually exclusive with Self::with_accounts.
Sourcepub fn with_orders_per_batch(self, orders_per_batch: usize) -> Self
pub fn with_orders_per_batch(self, orders_per_batch: usize) -> Self
Sets the number of orders to fetch in a single batch via multicall (default: 3000). Use if default does not fit node/provider gas and response size limits.
Sourcepub fn with_positions_per_batch(self, positions_per_batch: usize) -> Self
pub fn with_positions_per_batch(self, positions_per_batch: usize) -> Self
Sets the number of positions to fetch in a single batch (default: 3000). Use if default does not fit node/provider gas and response size limits.
Auto Trait Implementations§
impl<P> Freeze for SnapshotBuilder<P>
impl<P> RefUnwindSafe for SnapshotBuilder<P>
impl<P> Send for SnapshotBuilder<P>
impl<P> Sync for SnapshotBuilder<P>
impl<P> Unpin for SnapshotBuilder<P>
impl<P> UnsafeUnpin for SnapshotBuilder<P>
impl<P> UnwindSafe for SnapshotBuilder<P>
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