pub struct FeeParams<T> { /* private fields */ }
Expand description
Fee Parameters.
Implementations§
Source§impl<T> FeeParams<T>
impl<T> FeeParams<T>
Sourcepub fn builder() -> FeeParamsBuilder<T, ((), (), (), ())>
pub fn builder() -> FeeParamsBuilder<T, ((), (), (), ())>
Create a builder for building FeeParams
.
On the builder, call .positive_impact_fee_factor(...)
, .negative_impact_fee_factor(...)
, .fee_receiver_factor(...)
, .discount_factor(...)
(optional) to set the values of the fields.
Finally, call .build()
to create the instance of FeeParams
.
Source§impl<T> FeeParams<T>
impl<T> FeeParams<T>
Sourcepub fn with_discount_factor(self, factor: T) -> Self
pub fn with_discount_factor(self, factor: T) -> Self
Set discount factor.
Sourcepub fn receiver_factor(&self) -> &T
pub fn receiver_factor(&self) -> &T
Get receiver factor.
Sourcepub fn fee<const DECIMALS: u8>(
&self,
is_positive_impact: bool,
amount: &T,
) -> Option<T>where
T: FixedPointOps<DECIMALS>,
pub fn fee<const DECIMALS: u8>(
&self,
is_positive_impact: bool,
amount: &T,
) -> Option<T>where
T: FixedPointOps<DECIMALS>,
Get basic fee.
Sourcepub fn receiver_fee<const DECIMALS: u8>(&self, fee_amount: &T) -> Option<T>where
T: FixedPointOps<DECIMALS>,
pub fn receiver_fee<const DECIMALS: u8>(&self, fee_amount: &T) -> Option<T>where
T: FixedPointOps<DECIMALS>,
Get receiver fee.
Sourcepub fn apply_fees<const DECIMALS: u8>(
&self,
is_positive_impact: bool,
amount: &T,
) -> Option<(T, Fees<T>)>where
T: FixedPointOps<DECIMALS>,
pub fn apply_fees<const DECIMALS: u8>(
&self,
is_positive_impact: bool,
amount: &T,
) -> Option<(T, Fees<T>)>where
T: FixedPointOps<DECIMALS>,
Apply fees to amount
.
DECIMALS
is the decimals of the parameters.
Returns None
if the computation fails, otherwise amount
after fees and the fees are returned.
Sourcepub fn base_position_fees<const DECIMALS: u8>(
&self,
collateral_token_price: &Price<T>,
size_delta_usd: &T,
is_positive_impact: bool,
) -> Result<PositionFees<T>>where
T: FixedPointOps<DECIMALS>,
pub fn base_position_fees<const DECIMALS: u8>(
&self,
collateral_token_price: &Price<T>,
size_delta_usd: &T,
is_positive_impact: bool,
) -> Result<PositionFees<T>>where
T: FixedPointOps<DECIMALS>,
Get position fees with only order fees considered.
Trait Implementations§
impl<T: Copy> Copy for FeeParams<T>
Auto Trait Implementations§
impl<T> Freeze for FeeParams<T>where
T: Freeze,
impl<T> RefUnwindSafe for FeeParams<T>where
T: RefUnwindSafe,
impl<T> Send for FeeParams<T>where
T: Send,
impl<T> Sync for FeeParams<T>where
T: Sync,
impl<T> Unpin for FeeParams<T>where
T: Unpin,
impl<T> UnwindSafe for FeeParams<T>where
T: UnwindSafe,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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