Skip to content

Latest commit

 

History

History
269 lines (169 loc) · 6.71 KB

File metadata and controls

269 lines (169 loc) · 6.71 KB

DEX

Acala Developers

IDEX Predeploy Contract

You can use this predeploy contract to call dex pallet

This contracts will interact with dex pallet

Methods

addLiquidity

function addLiquidity(address tokenA, address tokenB, uint256 maxAmountA, uint256 maxAmountB, uint256 minShareIncrement) external nonpayable returns (bool)

Add liquidity to the trading pair.

It'll emit an {AddedLiquidity} event.

Parameters

Name Type Description
tokenA address The ERC20 address of the currency_id_a.
tokenB address The ERC20 address of the currency_id_b.
maxAmountA uint256 The maximum amount of currency_id_a is allowed to inject to liquidity pool.
maxAmountB uint256 The maximum amount of currency_id_b is allowed to inject to liquidity pool.
minShareIncrement uint256 The minimum acceptable share amount.

Returns

Name Type Description
_0 bool Returns a boolean value indicating whether the operation succeeded.

getLiquidityPool

function getLiquidityPool(address tokenA, address tokenB) external view returns (uint256, uint256)

Get liquidity pool of the currency_id_a and currency_id_b.

Parameters

Name Type Description
tokenA address The ERC20 address of the currency_id_a.
tokenB address The ERC20 address of the currency_id_b.

Returns

Name Type Description
_0 uint256 Returns (liquidity_a, liquidity_b).
_1 uint256 undefined

getLiquidityTokenAddress

function getLiquidityTokenAddress(address tokenA, address tokenB) external view returns (address)

Get liquidity token address.

Parameters

Name Type Description
tokenA address The ERC20 address of the currency_id_a.
tokenB address The ERC20 address of the currency_id_b.

Returns

Name Type Description
_0 address Returns (liquidity_token_address). Return address(0x0) if the liquidity token address is not mapped.

getSwapSupplyAmount

function getSwapSupplyAmount(address[] path, uint256 targetAmount) external view returns (uint256)

Get swap supply amount.

Parameters

Name Type Description
path address[] The trading path of the transaction.
targetAmount uint256 The exact target amount.

Returns

Name Type Description
_0 uint256 Returns (supply_amount). Returns 0 if getting the supply amount fails.

getSwapTargetAmount

function getSwapTargetAmount(address[] path, uint256 supplyAmount) external view returns (uint256)

Get swap target amount.

Parameters

Name Type Description
path address[] The trading path of the transaction.
supplyAmount uint256 The exact supply amount.

Returns

Name Type Description
_0 uint256 Returns (target_amount). Returns 0 if getting the target amount fails.

removeLiquidity

function removeLiquidity(address tokenA, address tokenB, uint256 removeShare, uint256 minWithdrawnA, uint256 minWithdrawnB) external nonpayable returns (bool)

Remove liquidity from the trading pair.

It'll emit an {RemovedLiquidity} event.

Parameters

Name Type Description
tokenA address The ERC20 address of the currency_id_a.
tokenB address The ERC20 address of the currency_id_b.
removeShare uint256 The liquidity amount to remove.
minWithdrawnA uint256 The minimum acceptable withrawn for currency_id_a.
minWithdrawnB uint256 The minimum acceptable withrawn for currency_id_b.

Returns

Name Type Description
_0 bool Returns a boolean value indicating whether the operation succeeded.

swapWithExactSupply

function swapWithExactSupply(address[] path, uint256 supplyAmount, uint256 minTargetAmount) external nonpayable returns (bool)

Swap with exact supply.

It'll emit an {Swapped} event.

Parameters

Name Type Description
path address[] The trading path of the swap transaction.
supplyAmount uint256 The exact gsupply amount.
minTargetAmount uint256 The acceptable minimum target amount.

Returns

Name Type Description
_0 bool Returns a boolean value indicating whether the operation succeeded.

swapWithExactTarget

function swapWithExactTarget(address[] path, uint256 targetAmount, uint256 maxSupplyAmount) external nonpayable returns (bool)

Swap with exact target.

It'll emit an {Swapped} event.

Parameters

Name Type Description
path address[] The trading path of the swap transaction.
targetAmount uint256 The exact target amount.
maxSupplyAmount uint256 The acceptable maximum supply amount.

Returns

Name Type Description
_0 bool Returns a boolean value indicating whether the operation succeeded.

Events

AddedLiquidity

event AddedLiquidity(address indexed sender, address indexed tokenA, address indexed tokenB, uint256 maxAmountA, uint256 maxAmountB)

Added liquidity event.

Parameters

Name Type Description
sender indexed address The sender of the transaction.
tokenA indexed address The ERC20 address of the currency_id_a.
tokenB indexed address The ERC20 address of the currency_id_b.
maxAmountA uint256 The maximum amount of currency_id_a is allowed to inject to liquidity pool.
maxAmountB uint256 The maximum amount of currency_id_b is allowed to inject to liquidity pool.

RemovedLiquidity

event RemovedLiquidity(address indexed sender, address indexed tokenA, address indexed tokenB, uint256 removeShare)

Removed liquidity event.

Parameters

Name Type Description
sender indexed address The sender of the transaction.
tokenA indexed address The ERC20 address of the currency_id_a.
tokenB indexed address The ERC20 address of the currency_id_b.
removeShare uint256 The liquidity amount has been removed.

Swapped

event Swapped(address indexed sender, address[] path, uint256 supplyAmount, uint256 targetAmount)

Swapped event with DEX.

Parameters

Name Type Description
sender indexed address The sender of the transaction.
path address[] The trading path of the swap transaction.
supplyAmount uint256 The exact supply amount.
targetAmount uint256 The exact target amount.