Trait framenode_runtime::LiquiditySource
source · pub trait LiquiditySource<TargetId, AccountId, AssetId, Amount, Error> {
// Required methods
fn can_exchange(
target_id: &TargetId,
input_asset_id: &AssetId,
output_asset_id: &AssetId
) -> bool;
fn quote(
target_id: &TargetId,
input_asset_id: &AssetId,
output_asset_id: &AssetId,
amount: QuoteAmount<Amount>,
deduce_fee: bool
) -> Result<(SwapOutcome<Amount>, Weight), DispatchError>;
fn exchange(
sender: &AccountId,
receiver: &AccountId,
target_id: &TargetId,
input_asset_id: &AssetId,
output_asset_id: &AssetId,
swap_amount: SwapAmount<Amount>
) -> Result<(SwapOutcome<Amount>, Weight), DispatchError>;
fn check_rewards(
target_id: &TargetId,
input_asset_id: &AssetId,
output_asset_id: &AssetId,
input_amount: Amount,
output_amount: Amount
) -> Result<(Vec<(Amount, AssetId, RewardReason), Global>, Weight), DispatchError>;
fn quote_without_impact(
target_id: &TargetId,
input_asset_id: &AssetId,
output_asset_id: &AssetId,
amount: QuoteAmount<Amount>,
deduce_fee: bool
) -> Result<SwapOutcome<Amount>, DispatchError>;
fn quote_weight() -> Weight;
fn exchange_weight() -> Weight;
fn check_rewards_weight() -> Weight;
}
Expand description
Indicates that particular object can be used to perform exchanges.
Required Methods§
sourcefn can_exchange(
target_id: &TargetId,
input_asset_id: &AssetId,
output_asset_id: &AssetId
) -> bool
fn can_exchange( target_id: &TargetId, input_asset_id: &AssetId, output_asset_id: &AssetId ) -> bool
Check if liquidity source provides an exchange from given input asset to output asset.
sourcefn quote(
target_id: &TargetId,
input_asset_id: &AssetId,
output_asset_id: &AssetId,
amount: QuoteAmount<Amount>,
deduce_fee: bool
) -> Result<(SwapOutcome<Amount>, Weight), DispatchError>
fn quote( target_id: &TargetId, input_asset_id: &AssetId, output_asset_id: &AssetId, amount: QuoteAmount<Amount>, deduce_fee: bool ) -> Result<(SwapOutcome<Amount>, Weight), DispatchError>
Get spot price of tokens based on desired amount.
sourcefn exchange(
sender: &AccountId,
receiver: &AccountId,
target_id: &TargetId,
input_asset_id: &AssetId,
output_asset_id: &AssetId,
swap_amount: SwapAmount<Amount>
) -> Result<(SwapOutcome<Amount>, Weight), DispatchError>
fn exchange( sender: &AccountId, receiver: &AccountId, target_id: &TargetId, input_asset_id: &AssetId, output_asset_id: &AssetId, swap_amount: SwapAmount<Amount> ) -> Result<(SwapOutcome<Amount>, Weight), DispatchError>
Perform exchange based on desired amount.
sourcefn check_rewards(
target_id: &TargetId,
input_asset_id: &AssetId,
output_asset_id: &AssetId,
input_amount: Amount,
output_amount: Amount
) -> Result<(Vec<(Amount, AssetId, RewardReason), Global>, Weight), DispatchError>
fn check_rewards( target_id: &TargetId, input_asset_id: &AssetId, output_asset_id: &AssetId, input_amount: Amount, output_amount: Amount ) -> Result<(Vec<(Amount, AssetId, RewardReason), Global>, Weight), DispatchError>
Get rewards that are given for perfoming given exchange.
sourcefn quote_without_impact(
target_id: &TargetId,
input_asset_id: &AssetId,
output_asset_id: &AssetId,
amount: QuoteAmount<Amount>,
deduce_fee: bool
) -> Result<SwapOutcome<Amount>, DispatchError>
fn quote_without_impact( target_id: &TargetId, input_asset_id: &AssetId, output_asset_id: &AssetId, amount: QuoteAmount<Amount>, deduce_fee: bool ) -> Result<SwapOutcome<Amount>, DispatchError>
Get spot price of tokens based on desired amount, ignoring non-linearity of underlying liquidity source.
sourcefn quote_weight() -> Weight
fn quote_weight() -> Weight
Get weight of quote
sourcefn exchange_weight() -> Weight
fn exchange_weight() -> Weight
Get weight of exchange
sourcefn check_rewards_weight() -> Weight
fn check_rewards_weight() -> Weight
Get weight of exchange
Implementations on Foreign Types§
source§impl<DEXId, AccountId, AssetId> LiquiditySource<DEXId, AccountId, AssetId, u128, DispatchError> for ()
impl<DEXId, AccountId, AssetId> LiquiditySource<DEXId, AccountId, AssetId, u128, DispatchError> for ()
fn can_exchange( _target_id: &DEXId, _input_asset_id: &AssetId, _output_asset_id: &AssetId ) -> bool
fn quote( _target_id: &DEXId, _input_asset_id: &AssetId, _output_asset_id: &AssetId, _amount: QuoteAmount<u128>, _deduce_fee: bool ) -> Result<(SwapOutcome<u128>, Weight), DispatchError>
fn exchange( _sender: &AccountId, _receiver: &AccountId, _target_id: &DEXId, _input_asset_id: &AssetId, _output_asset_id: &AssetId, _swap_amount: SwapAmount<u128> ) -> Result<(SwapOutcome<u128>, Weight), DispatchError>
fn check_rewards( _target_id: &DEXId, _input_asset_id: &AssetId, _output_asset_id: &AssetId, _input_amount: u128, _output_amount: u128 ) -> Result<(Vec<(u128, AssetId, RewardReason), Global>, Weight), DispatchError>
fn quote_without_impact( _target_id: &DEXId, _input_asset_id: &AssetId, _output_asset_id: &AssetId, _amount: QuoteAmount<u128>, _deduce_fee: bool ) -> Result<SwapOutcome<u128>, DispatchError>
fn quote_weight() -> Weight
fn exchange_weight() -> Weight
fn check_rewards_weight() -> Weight
source§impl<DEXId, AccountId, AssetId> LiquiditySource<DEXId, AccountId, AssetId, FixedPoint<i128, UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>, B0>>, DispatchError> for ()
impl<DEXId, AccountId, AssetId> LiquiditySource<DEXId, AccountId, AssetId, FixedPoint<i128, UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>, B0>>, DispatchError> for ()
fn can_exchange( _target_id: &DEXId, _input_asset_id: &AssetId, _output_asset_id: &AssetId ) -> bool
fn quote( _target_id: &DEXId, _input_asset_id: &AssetId, _output_asset_id: &AssetId, _amount: QuoteAmount<FixedPoint<i128, UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>, B0>>>, _deduce_fee: bool ) -> Result<(SwapOutcome<FixedPoint<i128, UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>, B0>>>, Weight), DispatchError>
fn exchange( _sender: &AccountId, _receiver: &AccountId, _target_id: &DEXId, _input_asset_id: &AssetId, _output_asset_id: &AssetId, _swap_amount: SwapAmount<FixedPoint<i128, UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>, B0>>> ) -> Result<(SwapOutcome<FixedPoint<i128, UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>, B0>>>, Weight), DispatchError>
fn check_rewards( _target_id: &DEXId, _input_asset_id: &AssetId, _output_asset_id: &AssetId, _input_amount: FixedPoint<i128, UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>, B0>>, _output_amount: FixedPoint<i128, UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>, B0>> ) -> Result<(Vec<(FixedPoint<i128, UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>, B0>>, AssetId, RewardReason), Global>, Weight), DispatchError>
fn quote_without_impact( _target_id: &DEXId, _input_asset_id: &AssetId, _output_asset_id: &AssetId, _amount: QuoteAmount<FixedPoint<i128, UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>, B0>>>, _deduce_fee: bool ) -> Result<SwapOutcome<FixedPoint<i128, UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>, B0>>>, DispatchError>
fn quote_weight() -> Weight
fn exchange_weight() -> Weight
fn check_rewards_weight() -> Weight
source§impl<T> LiquiditySource<<T as Config>::DEXId, <T as Config>::AccountId, <T as Config>::AssetId, u128, DispatchError> for Pallet<T>where
T: Config,
impl<T> LiquiditySource<<T as Config>::DEXId, <T as Config>::AccountId, <T as Config>::AssetId, u128, DispatchError> for Pallet<T>where T: Config,
fn can_exchange( dex_id: &<T as Config>::DEXId, input_asset_id: &<T as Config>::AssetId, output_asset_id: &<T as Config>::AssetId ) -> bool
fn quote( dex_id: &<T as Config>::DEXId, input_asset_id: &<T as Config>::AssetId, output_asset_id: &<T as Config>::AssetId, amount: QuoteAmount<u128>, deduce_fee: bool ) -> Result<(SwapOutcome<u128>, Weight), DispatchError>
fn exchange( sender: &<T as Config>::AccountId, receiver: &<T as Config>::AccountId, dex_id: &<T as Config>::DEXId, input_asset_id: &<T as Config>::AssetId, output_asset_id: &<T as Config>::AssetId, desired_amount: SwapAmount<u128> ) -> Result<(SwapOutcome<u128>, Weight), DispatchError>
fn check_rewards( dex_id: &<T as Config>::DEXId, input_asset_id: &<T as Config>::AssetId, output_asset_id: &<T as Config>::AssetId, input_amount: u128, output_amount: u128 ) -> Result<(Vec<(u128, <T as Config>::AssetId, RewardReason), Global>, Weight), DispatchError>
fn quote_without_impact( dex_id: &<T as Config>::DEXId, input_asset_id: &<T as Config>::AssetId, output_asset_id: &<T as Config>::AssetId, amount: QuoteAmount<u128>, deduce_fee: bool ) -> Result<SwapOutcome<u128>, DispatchError>
fn quote_weight() -> Weight
fn exchange_weight() -> Weight
fn check_rewards_weight() -> Weight
source§impl<T> LiquiditySource<<T as Config>::DEXId, <T as Config>::AccountId, <T as Config>::AssetId, u128, DispatchError> for Pallet<T>where
T: Config,
impl<T> LiquiditySource<<T as Config>::DEXId, <T as Config>::AccountId, <T as Config>::AssetId, u128, DispatchError> for Pallet<T>where T: Config,
fn can_exchange( dex_id: &<T as Config>::DEXId, input_asset_id: &<T as Config>::AssetId, output_asset_id: &<T as Config>::AssetId ) -> bool
fn quote( dex_id: &<T as Config>::DEXId, input_asset_id: &<T as Config>::AssetId, output_asset_id: &<T as Config>::AssetId, amount: QuoteAmount<u128>, deduce_fee: bool ) -> Result<(SwapOutcome<u128>, Weight), DispatchError>
fn exchange( sender: &<T as Config>::AccountId, receiver: &<T as Config>::AccountId, dex_id: &<T as Config>::DEXId, input_asset_id: &<T as Config>::AssetId, output_asset_id: &<T as Config>::AssetId, swap_amount: SwapAmount<u128> ) -> Result<(SwapOutcome<u128>, Weight), DispatchError>
fn check_rewards( _target_id: &<T as Config>::DEXId, _input_asset_id: &<T as Config>::AssetId, _output_asset_id: &<T as Config>::AssetId, _input_amount: u128, _output_amount: u128 ) -> Result<(Vec<(u128, <T as Config>::AssetId, RewardReason), Global>, Weight), DispatchError>
fn quote_without_impact( dex_id: &<T as Config>::DEXId, input_asset_id: &<T as Config>::AssetId, output_asset_id: &<T as Config>::AssetId, amount: QuoteAmount<u128>, deduce_fee: bool ) -> Result<SwapOutcome<u128>, DispatchError>
fn quote_weight() -> Weight
fn exchange_weight() -> Weight
fn check_rewards_weight() -> Weight
source§impl<T> LiquiditySource<<T as Config>::DEXId, <T as Config>::AccountId, <T as Config>::AssetId, u128, DispatchError> for Pallet<T>where
T: Config,
impl<T> LiquiditySource<<T as Config>::DEXId, <T as Config>::AccountId, <T as Config>::AssetId, u128, DispatchError> for Pallet<T>where T: Config,
fn can_exchange( dex_id: &<T as Config>::DEXId, input_asset_id: &<T as Config>::AssetId, output_asset_id: &<T as Config>::AssetId ) -> bool
fn quote( dex_id: &<T as Config>::DEXId, input_asset_id: &<T as Config>::AssetId, output_asset_id: &<T as Config>::AssetId, amount: QuoteAmount<u128>, _deduce_fee: bool ) -> Result<(SwapOutcome<u128>, Weight), DispatchError>
fn exchange( sender: &<T as Config>::AccountId, receiver: &<T as Config>::AccountId, dex_id: &<T as Config>::DEXId, input_asset_id: &<T as Config>::AssetId, output_asset_id: &<T as Config>::AssetId, desired_amount: SwapAmount<u128> ) -> Result<(SwapOutcome<u128>, Weight), DispatchError>
fn check_rewards( _dex_id: &<T as Config>::DEXId, _input_asset_id: &<T as Config>::AssetId, _output_asset_id: &<T as Config>::AssetId, _input_amount: u128, _output_amount: u128 ) -> Result<(Vec<(u128, <T as Config>::AssetId, RewardReason), Global>, Weight), DispatchError>
fn quote_without_impact( dex_id: &<T as Config>::DEXId, input_asset_id: &<T as Config>::AssetId, output_asset_id: &<T as Config>::AssetId, amount: QuoteAmount<u128>, _deduce_fee: bool ) -> Result<SwapOutcome<u128>, DispatchError>
fn quote_weight() -> Weight
fn exchange_weight() -> Weight
fn check_rewards_weight() -> Weight
source§impl<T> LiquiditySource<<T as Config>::DEXId, <T as Config>::AccountId, <T as Config>::AssetId, u128, DispatchError> for Pallet<T>where
T: Config,
impl<T> LiquiditySource<<T as Config>::DEXId, <T as Config>::AccountId, <T as Config>::AssetId, u128, DispatchError> for Pallet<T>where T: Config,
source§fn quote(
dex_id: &<T as Config>::DEXId,
input_asset_id: &<T as Config>::AssetId,
output_asset_id: &<T as Config>::AssetId,
amount: QuoteAmount<u128>,
deduce_fee: bool
) -> Result<(SwapOutcome<u128>, Weight), DispatchError>
fn quote( dex_id: &<T as Config>::DEXId, input_asset_id: &<T as Config>::AssetId, output_asset_id: &<T as Config>::AssetId, amount: QuoteAmount<u128>, deduce_fee: bool ) -> Result<(SwapOutcome<u128>, Weight), DispatchError>
Get spot price of synthetic tokens based on desired amount.