Crate pallet_asset_conversion

Source
Expand description

§Substrate Asset Conversion pallet

Substrate Asset Conversion pallet based on the Uniswap V2 logic.

§Overview

This pallet allows you to:

The quote_price_exact_tokens_for_tokens and quote_price_tokens_for_exact_tokens functions both take a path parameter of the route to take. If you want to swap from native asset to non-native asset 1, you would pass in a path of [DOT, 1] or [1, DOT]. If you want to swap from non-native asset 1 to non-native asset 2, you would pass in a path of [1, DOT, 2].

(For an example of configuring this pallet to use Location as an asset id, see the cumulus repo).

Here is an example state_call that asks for a quote of a pool of native versus asset 1:

curl -sS -H "Content-Type: application/json" -d \
'{"id":1, "jsonrpc":"2.0", "method": "state_call", "params": ["AssetConversionApi_quote_price_tokens_for_exact_tokens", "0x0101000000000000000000000011000000000000000000"]}' \
http://localhost:9933/

(This can be run against the kitchen sync node in the node folder of this repo.)

Re-exports§

pub use weights::WeightInfo;
pub use pallet::*;

Modules§

pallet
The pallet module in each FRAME pallet hosts the most important items needed to construct this pallet.
weights
Autogenerated weights for pallet_asset_conversion

Macros§

_runtime_benchmarks_enabled
runtime_benchmarks_enabled
Enable/disable the given code depending on feature = "runtime-benchmarks" being enabled for the crate or not.

Structs§

AccountIdConverter
PoolId to AccountId conversion.
AccountIdConverterNoSeed
PoolId to AccountId conversion without an addition arguments to the seed.
Ascending
Pool locator where the PoolId is a tuple of AssetKinds arranged in ascending order.
Chain
Pool locator that chains the First and Second implementations of PoolLocator.
PoolInfo
Stores the lp_token asset id a particular pool has been assigned.
WithFirstAsset
Pool locator that mandates the inclusion of the specified FirstAsset in every asset pair.

Traits§

AssetConversionApi
This runtime api allows people to query the size of the liquidity pools and quote prices for swaps.
PoolLocator
Provides means to resolve the PoolId and AccountId from a pair of assets.
QuotePrice
Trait providing methods to quote swap prices between asset classes.
Swap
Trait for providing methods to swap between the various asset classes.
SwapCredit
Trait providing methods to swap between the various asset classes.

Type Aliases§

BalancePath
Represents a swap path with associated asset amounts indicating how much of the asset needs to be deposited to get the following asset’s amount withdrawn (this is inclusive of fees).
CreditOf
Credit of Config::Assets.