referrerpolicy=no-referrer-when-downgrade

Module IAssetConversion

Module IAssetConversion 

Source
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§

addLiquidityCall
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 selector 0x35e4de25.
addLiquidityReturn
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.
createPoolCall
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 selector 0xb242f28d.
createPoolReturn
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.
getReservesCall
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 selector 0xcdec1e73.
getReservesReturn
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.
quoteExactTokensForTokensCall
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 selector 0x19cc41d7.
quoteExactTokensForTokensReturn
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.
quoteTokensForExactTokensCall
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 selector 0x31c94283.
quoteTokensForExactTokensReturn
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.
removeLiquidityCall
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 selector 0x530be8fb.
removeLiquidityReturn
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.
swapExactTokensForTokensCall
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 selector 0xff277ac9.
swapExactTokensForTokensReturn
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.
swapTokensForExactTokensCall
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 selector 0x6581ff14.
swapTokensForExactTokensReturn
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§

IAssetConversionCalls
Container for all the IAssetConversion function calls.