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§

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)>, 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<Balance>, _deduce_fee: bool ) -> Result<(SwapOutcome<Balance>, Weight), DispatchError>

source§

fn exchange( _sender: &AccountId, _receiver: &AccountId, _target_id: &DEXId, _input_asset_id: &AssetId, _output_asset_id: &AssetId, _swap_amount: SwapAmount<Balance> ) -> Result<(SwapOutcome<Balance>, Weight), DispatchError>

source§

fn check_rewards( _target_id: &DEXId, _input_asset_id: &AssetId, _output_asset_id: &AssetId, _input_amount: Balance, _output_amount: Balance ) -> Result<(Vec<(Balance, AssetId, RewardReason)>, Weight), DispatchError>

source§

fn quote_without_impact( _target_id: &DEXId, _input_asset_id: &AssetId, _output_asset_id: &AssetId, _amount: QuoteAmount<Balance>, _deduce_fee: bool ) -> Result<SwapOutcome<Balance>, 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<Fixed>, _deduce_fee: bool ) -> Result<(SwapOutcome<Fixed>, Weight), DispatchError>

source§

fn exchange( _sender: &AccountId, _receiver: &AccountId, _target_id: &DEXId, _input_asset_id: &AssetId, _output_asset_id: &AssetId, _swap_amount: SwapAmount<Fixed> ) -> Result<(SwapOutcome<Fixed>, Weight), DispatchError>

source§

fn check_rewards( _target_id: &DEXId, _input_asset_id: &AssetId, _output_asset_id: &AssetId, _input_amount: Fixed, _output_amount: Fixed ) -> Result<(Vec<(Fixed, AssetId, RewardReason)>, Weight), DispatchError>

source§

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

source§

fn quote_weight() -> Weight

source§

fn exchange_weight() -> Weight

source§

fn check_rewards_weight() -> Weight

Implementors§