#[repr(C)]
pub struct SwapCurve { pub curve_type: CurveType, pub calculator: Arc<dyn CurveCalculator + Sync + Send>, }
Expand description

Concrete struct to wrap around the trait object which performs calculation.

Fields

curve_type: CurveType

The type of curve contained in the calculator, helpful for outside queries

calculator: Arc<dyn CurveCalculator + Sync + Send>

The actual calculator, represented as a trait object to allow for many different types of curves

Implementations

Subtract fees and calculate how much destination token will be provided given an amount of source token.

Get the amount of pool tokens for the deposited amount of token A or B

Get the amount of pool tokens for the withdrawn amount of token A or B

Trait Implementations

Formats the value using the given formatter. Read more

Default implementation for SwapCurve cannot be derived because of the contained Arc.

Returns the “default value” for a type. Read more

Size of encoding of all curve parameters, which include fees and any other constants used to calculate swaps, deposits, and withdrawals. This includes 1 byte for the type, and 72 for the calculator to use as it needs. Some calculators may be smaller than 72 bytes.

Get the packed length

Unpack from slice and check if initialized

Unpack from slice without checking if initialized

Pack into slice

Simple implementation for PartialEq which assumes that the output of Pack is enough to guarantee equality

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.