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§

source

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.

source

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.

source

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.

source

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.

source

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.

source

fn quote_weight() -> Weight

Get weight of quote

source

fn exchange_weight() -> Weight

Get weight of exchange

source

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 ()

source§

fn can_exchange( _target_id: &DEXId, _input_asset_id: &AssetId, _output_asset_id: &AssetId ) -> bool

source§

fn quote( _target_id: &DEXId, _input_asset_id: &AssetId, _output_asset_id: &AssetId, _amount: QuoteAmount<u128>, _deduce_fee: bool ) -> Result<(SwapOutcome<u128>, Weight), DispatchError>

source§

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>

source§

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>

source§

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>

source§

fn quote_weight() -> Weight

source§

fn exchange_weight() -> Weight

source§

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 ()

source§

fn can_exchange( _target_id: &DEXId, _input_asset_id: &AssetId, _output_asset_id: &AssetId ) -> bool

source§

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>

source§

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>

source§

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>

source§

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>

source§

fn quote_weight() -> Weight

source§

fn exchange_weight() -> Weight

source§

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,

source§

fn can_exchange( dex_id: &<T as Config>::DEXId, input_asset_id: &<T as Config>::AssetId, output_asset_id: &<T as Config>::AssetId ) -> bool

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>

source§

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>

source§

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>

source§

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>

source§

fn quote_weight() -> Weight

source§

fn exchange_weight() -> Weight

source§

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,

source§

fn can_exchange( dex_id: &<T as Config>::DEXId, input_asset_id: &<T as Config>::AssetId, output_asset_id: &<T as Config>::AssetId ) -> bool

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>

source§

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>

source§

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>

source§

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>

source§

fn quote_weight() -> Weight

source§

fn exchange_weight() -> Weight

source§

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,

source§

fn can_exchange( dex_id: &<T as Config>::DEXId, input_asset_id: &<T as Config>::AssetId, output_asset_id: &<T as Config>::AssetId ) -> bool

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>

source§

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>

source§

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>

source§

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>

source§

fn quote_weight() -> Weight

source§

fn exchange_weight() -> Weight

source§

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,

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>

Get spot price of synthetic tokens based on desired amount.

source§

fn can_exchange( dex_id: &<T as Config>::DEXId, input_asset_id: &<T as Config>::AssetId, output_asset_id: &<T as Config>::AssetId ) -> bool

source§

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>

source§

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>

source§

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>

source§

fn quote_weight() -> Weight

source§

fn exchange_weight() -> Weight

source§

fn check_rewards_weight() -> Weight

source§

impl<T> LiquiditySource<LiquiditySourceId<<T as Config>::DEXId, LiquiditySourceType>, <T as Config>::AccountId, <T as Config>::AssetId, u128, DispatchError> for Pallet<T>where T: Config,

source§

fn can_exchange( liquidity_source_id: &LiquiditySourceId<<T as Config>::DEXId, LiquiditySourceType>, input_asset_id: &<T as Config>::AssetId, output_asset_id: &<T as Config>::AssetId ) -> bool

source§

fn quote( liquidity_source_id: &LiquiditySourceId<<T as Config>::DEXId, LiquiditySourceType>, 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>

source§

fn exchange( sender: &<T as Config>::AccountId, receiver: &<T as Config>::AccountId, liquidity_source_id: &LiquiditySourceId<<T as Config>::DEXId, LiquiditySourceType>, input_asset_id: &<T as Config>::AssetId, output_asset_id: &<T as Config>::AssetId, swap_amount: SwapAmount<u128> ) -> Result<(SwapOutcome<u128>, Weight), DispatchError>

source§

fn check_rewards( liquidity_source_id: &LiquiditySourceId<<T as Config>::DEXId, LiquiditySourceType>, 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>

source§

fn quote_without_impact( liquidity_source_id: &LiquiditySourceId<<T as Config>::DEXId, LiquiditySourceType>, input_asset_id: &<T as Config>::AssetId, output_asset_id: &<T as Config>::AssetId, amount: QuoteAmount<u128>, deduce_fee: bool ) -> Result<SwapOutcome<u128>, DispatchError>

source§

fn quote_weight() -> Weight

source§

fn exchange_weight() -> Weight

source§

fn check_rewards_weight() -> Weight

source§

impl<T, I> LiquiditySource<<T as Config>::DEXId, <T as Config>::AccountId, <T as Config>::AssetId, u128, DispatchError> for Pallet<T, I>where T: Config<I>, I: 'static,

source§

fn can_exchange( dex_id: &<T as Config>::DEXId, input_asset_id: &<T as Config>::AssetId, output_asset_id: &<T as Config>::AssetId ) -> bool

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>

source§

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>

source§

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>

source§

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>

source§

fn quote_weight() -> Weight

source§

fn exchange_weight() -> Weight

source§

fn check_rewards_weight() -> Weight

Implementors§