Skip to main content

Order

Struct Order 

Source
pub struct Order { /* private fields */ }
Expand description

A single swap intent submitted to the Fynd solver.

Addresses are raw 20-byte values (bytes::Bytes). The amount is denominated in the smallest unit of the input token (e.g. wei for ETH, atomic units for ERC-20).

Implementations§

Source§

impl Order

Source

pub fn new( token_in: Bytes, token_out: Bytes, amount: BigUint, side: OrderSide, sender: Bytes, receiver: Option<Bytes>, ) -> Self

Construct a new order.

  • token_in: 20-byte ERC-20 address of the token to sell.
  • token_out: 20-byte ERC-20 address of the token to receive.
  • amount: exact amount to sell (token units, not wei unless the token is WETH).
  • side: must be OrderSide::Sell; buy orders are not yet supported.
  • sender: 20-byte address of the wallet sending token_in.
  • receiver: 20-byte address that receives token_out. Defaults to sender if None.
Source

pub fn token_in(&self) -> &Bytes

The address of the token being sold (20 raw bytes).

Source

pub fn token_out(&self) -> &Bytes

The address of the token being bought (20 raw bytes).

Source

pub fn amount(&self) -> &BigUint

The amount to sell, in token units.

Source

pub fn side(&self) -> OrderSide

Whether this is a sell (exact-input) or buy (exact-output) order.

Source

pub fn sender(&self) -> &Bytes

The address that will send token_in (20 raw bytes).

Source

pub fn receiver(&self) -> Option<&Bytes>

The address that will receive token_out (20 raw bytes), or None if it defaults to sender.

Trait Implementations§

Source§

impl TryFrom<Order> for Order

Source§

type Error = FyndError

The type returned in the event of a conversion error.
Source§

fn try_from(order: Order) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl !Freeze for Order

§

impl RefUnwindSafe for Order

§

impl Send for Order

§

impl Sync for Order

§

impl Unpin for Order

§

impl UnsafeUnpin for Order

§

impl UnwindSafe for Order

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more