Trait common::prelude::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)>, 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)>, 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)>, 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