Expand description
Precompile interface for asset-conversion (DEX) operations.
Assets are identified by their SCALE-encoded AssetKind (e.g. xcm::v5::Location)
passed as bytes. Contracts can hardcode these as constants or obtain them
off-chain.
interface IAssetConversion {
function swapExactTokensForTokens(bytes[] calldata path, uint256 amountIn, uint256 amountOutMin, address sendTo, bool keepAlive) external returns (uint256 amountOut);
function swapTokensForExactTokens(bytes[] calldata path, uint256 amountOut, uint256 amountInMax, address sendTo, bool keepAlive) external returns (uint256 amountIn);
function quoteExactTokensForTokens(bytes calldata asset1, bytes calldata asset2, uint256 amount, bool includeFee) external view returns (uint256);
function quoteTokensForExactTokens(bytes calldata asset1, bytes calldata asset2, uint256 amount, bool includeFee) external view returns (uint256);
function createPool(bytes calldata asset1, bytes calldata asset2) external;
function addLiquidity(bytes calldata asset1, bytes calldata asset2, uint256 amount1Desired, uint256 amount2Desired, uint256 amount1Min, uint256 amount2Min, address mintTo) external returns (uint256 lpTokensMinted);
function removeLiquidity(bytes calldata asset1, bytes calldata asset2, uint256 lpTokenBurn, uint256 amount1MinReceive, uint256 amount2MinReceive, address withdrawTo) external returns (uint256 amount1, uint256 amount2);
function getReserves(bytes calldata asset1, bytes calldata asset2) external view returns (uint256 reserve1, uint256 reserve2);
}Structs§
- addLiquidity
Call - Add liquidity to an existing pool.
@param asset1 SCALE-encoded identifier of the first asset.
@param asset2 SCALE-encoded identifier of the second asset.
@param amount1Desired Desired amount of the first asset to add.
@param amount2Desired Desired amount of the second asset to add.
@param amount1Min Minimum acceptable amount of the first asset.
@param amount2Min Minimum acceptable amount of the second asset.
@param mintTo Address to receive the LP tokens.
@return lpTokensMinted The amount of LP tokens minted.
Function with signature
addLiquidity(bytes,bytes,uint256,uint256,uint256,uint256,address)and selector0x35e4de25. - addLiquidity
Return - Add liquidity to an existing pool.
@param asset1 SCALE-encoded identifier of the first asset.
@param asset2 SCALE-encoded identifier of the second asset.
@param amount1Desired Desired amount of the first asset to add.
@param amount2Desired Desired amount of the second asset to add.
@param amount1Min Minimum acceptable amount of the first asset.
@param amount2Min Minimum acceptable amount of the second asset.
@param mintTo Address to receive the LP tokens.
@return lpTokensMinted The amount of LP tokens minted.
Container type for the return parameters of the
addLiquidity(bytes,bytes,uint256,uint256,uint256,uint256,address)function. - create
Pool Call - Create an empty liquidity pool for the given asset pair.
@param asset1 SCALE-encoded identifier of the first asset.
@param asset2 SCALE-encoded identifier of the second asset.
Function with signature
createPool(bytes,bytes)and selector0xb242f28d. - create
Pool Return - Create an empty liquidity pool for the given asset pair.
@param asset1 SCALE-encoded identifier of the first asset.
@param asset2 SCALE-encoded identifier of the second asset.
Container type for the return parameters of the
createPool(bytes,bytes)function. - getReserves
Call - Get the reserves (token balances) of a liquidity pool.
@param asset1 SCALE-encoded identifier of the first asset.
@param asset2 SCALE-encoded identifier of the second asset.
@return reserve1 The balance of asset1 in the pool.
@return reserve2 The balance of asset2 in the pool.
Function with signature
getReserves(bytes,bytes)and selector0xcdec1e73. - getReserves
Return - Get the reserves (token balances) of a liquidity pool.
@param asset1 SCALE-encoded identifier of the first asset.
@param asset2 SCALE-encoded identifier of the second asset.
@return reserve1 The balance of asset1 in the pool.
@return reserve2 The balance of asset2 in the pool.
Container type for the return parameters of the
getReserves(bytes,bytes)function. - quote
Exact Tokens ForTokens Call - Quote the expected output for a given exact input swap.
@param asset1 SCALE-encoded identifier of the input asset.
@param asset2 SCALE-encoded identifier of the output asset.
@param amount The input amount to quote for.
@param includeFee Whether to include the pool’s LP fee in the quote.
@return The expected output amount.
Function with signature
quoteExactTokensForTokens(bytes,bytes,uint256,bool)and selector0x19cc41d7. - quote
Exact Tokens ForTokens Return - Quote the expected output for a given exact input swap.
@param asset1 SCALE-encoded identifier of the input asset.
@param asset2 SCALE-encoded identifier of the output asset.
@param amount The input amount to quote for.
@param includeFee Whether to include the pool’s LP fee in the quote.
@return The expected output amount.
Container type for the return parameters of the
quoteExactTokensForTokens(bytes,bytes,uint256,bool)function. - quote
Tokens ForExact Tokens Call - Quote the required input for a given exact output swap.
@param asset1 SCALE-encoded identifier of the input asset.
@param asset2 SCALE-encoded identifier of the output asset.
@param amount The desired output amount to quote for.
@param includeFee Whether to include the pool’s LP fee in the quote.
@return The required input amount.
Function with signature
quoteTokensForExactTokens(bytes,bytes,uint256,bool)and selector0x31c94283. - quote
Tokens ForExact Tokens Return - Quote the required input for a given exact output swap.
@param asset1 SCALE-encoded identifier of the input asset.
@param asset2 SCALE-encoded identifier of the output asset.
@param amount The desired output amount to quote for.
@param includeFee Whether to include the pool’s LP fee in the quote.
@return The required input amount.
Container type for the return parameters of the
quoteTokensForExactTokens(bytes,bytes,uint256,bool)function. - remove
Liquidity Call - Remove liquidity from a pool.
@param asset1 SCALE-encoded identifier of the first asset.
@param asset2 SCALE-encoded identifier of the second asset.
@param lpTokenBurn Amount of LP tokens to burn.
@param amount1MinReceive Minimum amount of the first asset to receive.
@param amount2MinReceive Minimum amount of the second asset to receive.
@param withdrawTo Address to receive the withdrawn assets.
@return amount1 The amount of the first asset withdrawn.
@return amount2 The amount of the second asset withdrawn.
Function with signature
removeLiquidity(bytes,bytes,uint256,uint256,uint256,address)and selector0x530be8fb. - remove
Liquidity Return - Remove liquidity from a pool.
@param asset1 SCALE-encoded identifier of the first asset.
@param asset2 SCALE-encoded identifier of the second asset.
@param lpTokenBurn Amount of LP tokens to burn.
@param amount1MinReceive Minimum amount of the first asset to receive.
@param amount2MinReceive Minimum amount of the second asset to receive.
@param withdrawTo Address to receive the withdrawn assets.
@return amount1 The amount of the first asset withdrawn.
@return amount2 The amount of the second asset withdrawn.
Container type for the return parameters of the
removeLiquidity(bytes,bytes,uint256,uint256,uint256,address)function. - swap
Exact Tokens ForTokens Call - Swap an exact amount of input tokens for as many output tokens as possible.
@param path Ordered list of SCALE-encoded asset identifiers defining the swap route.
@param amountIn Exact amount of the first asset to swap.
@param amountOutMin Minimum acceptable amount of the last asset to receive.
@param sendTo Address to receive the output tokens.
@param keepAlive If true, ensures the sender account stays above existential deposit.
@return amountOut The amount of output tokens received.
Function with signature
swapExactTokensForTokens(bytes[],uint256,uint256,address,bool)and selector0xff277ac9. - swap
Exact Tokens ForTokens Return - Swap an exact amount of input tokens for as many output tokens as possible.
@param path Ordered list of SCALE-encoded asset identifiers defining the swap route.
@param amountIn Exact amount of the first asset to swap.
@param amountOutMin Minimum acceptable amount of the last asset to receive.
@param sendTo Address to receive the output tokens.
@param keepAlive If true, ensures the sender account stays above existential deposit.
@return amountOut The amount of output tokens received.
Container type for the return parameters of the
swapExactTokensForTokens(bytes[],uint256,uint256,address,bool)function. - swap
Tokens ForExact Tokens Call - Swap tokens to receive an exact amount of output tokens.
@param path Ordered list of SCALE-encoded asset identifiers defining the swap route.
@param amountOut Exact amount of the last asset to receive.
@param amountInMax Maximum acceptable amount of the first asset to spend.
@param sendTo Address to receive the output tokens.
@param keepAlive If true, ensures the sender account stays above existential deposit.
@return amountIn The amount of input tokens spent.
Function with signature
swapTokensForExactTokens(bytes[],uint256,uint256,address,bool)and selector0x6581ff14. - swap
Tokens ForExact Tokens Return - Swap tokens to receive an exact amount of output tokens.
@param path Ordered list of SCALE-encoded asset identifiers defining the swap route.
@param amountOut Exact amount of the last asset to receive.
@param amountInMax Maximum acceptable amount of the first asset to spend.
@param sendTo Address to receive the output tokens.
@param keepAlive If true, ensures the sender account stays above existential deposit.
@return amountIn The amount of input tokens spent.
Container type for the return parameters of the
swapTokensForExactTokens(bytes[],uint256,uint256,address,bool)function.
Enums§
- IAsset
Conversion Calls - Container for all the
IAssetConversionfunction calls.