Enum pallet_asset_conversion::pallet::Call
source · pub enum Call<T: Config> {
create_pool {
asset1: Box<T::AssetKind>,
asset2: Box<T::AssetKind>,
},
add_liquidity {
asset1: Box<T::AssetKind>,
asset2: Box<T::AssetKind>,
amount1_desired: T::Balance,
amount2_desired: T::Balance,
amount1_min: T::Balance,
amount2_min: T::Balance,
mint_to: T::AccountId,
},
remove_liquidity {
asset1: Box<T::AssetKind>,
asset2: Box<T::AssetKind>,
lp_token_burn: T::Balance,
amount1_min_receive: T::Balance,
amount2_min_receive: T::Balance,
withdraw_to: T::AccountId,
},
swap_exact_tokens_for_tokens {
path: Vec<Box<T::AssetKind>>,
amount_in: T::Balance,
amount_out_min: T::Balance,
send_to: T::AccountId,
keep_alive: bool,
},
swap_tokens_for_exact_tokens {
path: Vec<Box<T::AssetKind>>,
amount_out: T::Balance,
amount_in_max: T::Balance,
send_to: T::AccountId,
keep_alive: bool,
},
touch {
asset1: Box<T::AssetKind>,
asset2: Box<T::AssetKind>,
},
// some variants omitted
}
Expand description
Pallet’s callable functions.
Variants§
create_pool
Creates an empty liquidity pool and an associated new lp_token
asset
(the id of which is returned in the Event::PoolCreated
event).
Once a pool is created, someone may Pallet::add_liquidity
to it.
add_liquidity
Provide liquidity into the pool of asset1
and asset2
.
NOTE: an optimal amount of asset1 and asset2 will be calculated and
might be different than the provided amount1_desired
/amount2_desired
thus you should provide the min amount you’re happy to provide.
Params amount1_min
/amount2_min
represent that.
mint_to
will be sent the liquidity tokens that represent this share of the pool.
NOTE: when encountering an incorrect exchange rate and non-withdrawable pool liquidity,
batch an atomic call with Pallet::add_liquidity
and
Pallet::swap_exact_tokens_for_tokens
or Pallet::swap_tokens_for_exact_tokens
calls to render the liquidity withdrawable and rectify the exchange rate.
Once liquidity is added, someone may successfully call
Pallet::swap_exact_tokens_for_tokens
successfully.
Fields
remove_liquidity
Allows you to remove liquidity by providing the lp_token_burn
tokens that will be
burned in the process. With the usage of amount1_min_receive
/amount2_min_receive
it’s possible to control the min amount of returned tokens you’re happy with.
Fields
swap_exact_tokens_for_tokens
Swap the exact amount of asset1
into asset2
.
amount_out_min
param allows you to specify the min amount of the asset2
you’re happy to receive.
AssetConversionApi::quote_price_exact_tokens_for_tokens
runtime call can be called
for a quote.
Fields
swap_tokens_for_exact_tokens
Swap any amount of asset1
to get the exact amount of asset2
.
amount_in_max
param allows to specify the max amount of the asset1
you’re happy to provide.
AssetConversionApi::quote_price_tokens_for_exact_tokens
runtime call can be called
for a quote.
Fields
touch
Touch an existing pool to fulfill prerequisites before providing liquidity, such as ensuring that the pool’s accounts are in place. It is typically useful when a pool creator removes the pool’s accounts and does not provide a liquidity. This action may involve holding assets from the caller as a deposit for creating the pool’s accounts.
The origin must be Signed.
asset1
: The asset ID of an existing pool with a pair (asset1, asset2).asset2
: The asset ID of an existing pool with a pair (asset1, asset2).
Emits Touched
event when successful.
Implementations§
source§impl<T: Config> Call<T>
impl<T: Config> Call<T>
sourcepub fn new_call_variant_create_pool(
asset1: Box<T::AssetKind>,
asset2: Box<T::AssetKind>
) -> Self
pub fn new_call_variant_create_pool( asset1: Box<T::AssetKind>, asset2: Box<T::AssetKind> ) -> Self
Create a call with the variant create_pool
.
sourcepub fn new_call_variant_add_liquidity(
asset1: Box<T::AssetKind>,
asset2: Box<T::AssetKind>,
amount1_desired: T::Balance,
amount2_desired: T::Balance,
amount1_min: T::Balance,
amount2_min: T::Balance,
mint_to: T::AccountId
) -> Self
pub fn new_call_variant_add_liquidity( asset1: Box<T::AssetKind>, asset2: Box<T::AssetKind>, amount1_desired: T::Balance, amount2_desired: T::Balance, amount1_min: T::Balance, amount2_min: T::Balance, mint_to: T::AccountId ) -> Self
Create a call with the variant add_liquidity
.
sourcepub fn new_call_variant_remove_liquidity(
asset1: Box<T::AssetKind>,
asset2: Box<T::AssetKind>,
lp_token_burn: T::Balance,
amount1_min_receive: T::Balance,
amount2_min_receive: T::Balance,
withdraw_to: T::AccountId
) -> Self
pub fn new_call_variant_remove_liquidity( asset1: Box<T::AssetKind>, asset2: Box<T::AssetKind>, lp_token_burn: T::Balance, amount1_min_receive: T::Balance, amount2_min_receive: T::Balance, withdraw_to: T::AccountId ) -> Self
Create a call with the variant remove_liquidity
.
sourcepub fn new_call_variant_swap_exact_tokens_for_tokens(
path: Vec<Box<T::AssetKind>>,
amount_in: T::Balance,
amount_out_min: T::Balance,
send_to: T::AccountId,
keep_alive: bool
) -> Self
pub fn new_call_variant_swap_exact_tokens_for_tokens( path: Vec<Box<T::AssetKind>>, amount_in: T::Balance, amount_out_min: T::Balance, send_to: T::AccountId, keep_alive: bool ) -> Self
Create a call with the variant swap_exact_tokens_for_tokens
.
Trait Implementations§
source§impl<T: Config> CheckIfFeeless for Call<T>
impl<T: Config> CheckIfFeeless for Call<T>
§type Origin = <T as Config>::RuntimeOrigin
type Origin = <T as Config>::RuntimeOrigin
source§fn is_feeless(&self, origin: &Self::Origin) -> bool
fn is_feeless(&self, origin: &Self::Origin) -> bool
#[pallet::feeless_if]
source§impl<T: Config> Decode for Call<T>
impl<T: Config> Decode for Call<T>
source§fn decode<__CodecInputEdqy: Input>(
__codec_input_edqy: &mut __CodecInputEdqy
) -> Result<Self, Error>
fn decode<__CodecInputEdqy: Input>( __codec_input_edqy: &mut __CodecInputEdqy ) -> Result<Self, Error>
source§fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>
) -> Result<DecodeFinished, Error>where
I: Input,
fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>
) -> Result<DecodeFinished, Error>where
I: Input,
source§impl<T: Config> Encode for Call<T>
impl<T: Config> Encode for Call<T>
source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
source§fn encode_to<__CodecOutputEdqy: Output + ?Sized>(
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy
)
fn encode_to<__CodecOutputEdqy: Output + ?Sized>( &self, __codec_dest_edqy: &mut __CodecOutputEdqy )
source§fn using_encoded<R, F>(&self, f: F) -> R
fn using_encoded<R, F>(&self, f: F) -> R
source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
source§impl<T: Config> GetCallIndex for Call<T>
impl<T: Config> GetCallIndex for Call<T>
source§fn get_call_index(&self) -> u8
fn get_call_index(&self) -> u8
source§fn get_call_indices() -> &'static [u8] ⓘ
fn get_call_indices() -> &'static [u8] ⓘ
GetCallName
.source§impl<T: Config> GetCallName for Call<T>
impl<T: Config> GetCallName for Call<T>
source§fn get_call_name(&self) -> &'static str
fn get_call_name(&self) -> &'static str
source§fn get_call_names() -> &'static [&'static str]
fn get_call_names() -> &'static [&'static str]
GetCallIndex
.source§impl<T: Config> GetDispatchInfo for Call<T>
impl<T: Config> GetDispatchInfo for Call<T>
source§fn get_dispatch_info(&self) -> DispatchInfo
fn get_dispatch_info(&self) -> DispatchInfo
DispatchInfo
, containing relevant information of this dispatch. Read moresource§impl<T: Config> PartialEq for Call<T>
impl<T: Config> PartialEq for Call<T>
source§impl<T: Config> UnfilteredDispatchable for Call<T>
impl<T: Config> UnfilteredDispatchable for Call<T>
§type RuntimeOrigin = <T as Config>::RuntimeOrigin
type RuntimeOrigin = <T as Config>::RuntimeOrigin
frame_system::Config::RuntimeOrigin
).source§fn dispatch_bypass_filter(
self,
origin: Self::RuntimeOrigin
) -> DispatchResultWithPostInfo
fn dispatch_bypass_filter( self, origin: Self::RuntimeOrigin ) -> DispatchResultWithPostInfo
impl<T: Config> EncodeLike for Call<T>
impl<T: Config> Eq for Call<T>
Auto Trait Implementations§
impl<T> Freeze for Call<T>
impl<T> RefUnwindSafe for Call<T>where
<T as Config>::Balance: RefUnwindSafe,
<T as Config>::AccountId: RefUnwindSafe,
T: RefUnwindSafe,
<T as Config>::AssetKind: RefUnwindSafe,
impl<T> Send for Call<T>
impl<T> Sync for Call<T>
impl<T> Unpin for Call<T>
impl<T> UnwindSafe for Call<T>where
<T as Config>::Balance: UnwindSafe,
<T as Config>::AccountId: UnwindSafe,
T: UnwindSafe,
<T as Config>::AssetKind: 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
source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
source§impl<T> DecodeLimit for Twhere
T: Decode,
impl<T> DecodeLimit for Twhere
T: Decode,
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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 moresource§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T
. Read moresource§impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
type Error = <U as TryFromKey<T>>::Error
fn try_into_key(self) -> Result<U, <U as TryFromKey<T>>::Error>
source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.source§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.