Dex
Calls
addLiquidity
Add liquidity to Enabled trading pair, or add provision to Provisioning trading pair.
Add liquidity success will issue shares in current price which decided by the liquidity scale. Shares are temporarily not allowed to transfer and trade, it represents the proportion of assets in liquidity pool.
Add provision success will record the provision, issue shares to caller in the initial price when trading pair convert to Enabled.
Creates and enables TradingPair LP token if it does not exist for trading pair.
Fails to add liquidity for
NotEnabled
trading pair.token_a
: Asset id A.token_b
: Asset id B.amount_a_desired
: amount a desired to add.amount_b_desired
: amount b desired to add.amount_a_min
: amount a minimum willing to add.amount_b_min
: amount b minimum willing to add.to
: The recipient of the LP token. The caller is the default recipient if it is set to None.deadline
: The deadline of executing this extrinsic. The deadline won't be checked if it is set to None
Namespace
Type
disableTradingPair
Disable an Enabled
trading pair.
Requires LP token to be created and in the
Enabled
statusOnly root can disable trading pair
token_a
: Asset id A.token_b
: Asset id B.
Namespace
Type
reenableTradingPair
Re enable a NotEnabled
trading pair.
Requires LP token to be created and in the
NotEnabled
statusOnly root can enable a disabled trading pair
token_a
: Asset id A.token_b
: Asset id B.
Namespace
Type
removeLiquidity
Remove liquidity from specific liquidity pool in the form of burning shares, and withdrawing currencies in trading pairs from liquidity pool in proportion, and withdraw liquidity incentive interest.
note: liquidity can still be withdrawn for
NotEnabled
trading pairs.token_a
: Asset id A.token_b
: Asset id B.liquidity
: liquidity amount to remove.amount_a_min
: minimum amount of asset A to be withdrawn from LP token.amount_b_min
: minimum amount of asset B to be withdrawn from LP token.to
: The recipient of the withdrawn token assets. The caller is the default recipient if it is set to None.deadline
: The deadline of executing this extrinsic. The deadline won't be checked if it is set to None
Namespace
Type
setFeeTo
Set the FeeTo
account. This operation requires root access.
note: analogous to Uniswapv2
setFeeTo
fee_to
: the new account or None assigned to FeeTo.
Namespace
Type
swapWithExactSupply
Trading with DEX, swap with exact supply amount. Specify your input; retrieve variable output.
note: analogous to Uniswapv2
swapExactTokensForTokens
path
: trading path.amount_in
: exact supply amount.amount_out_min
: acceptable minimum target amount.to
: The recipient of the swapped token asset. The caller is the default recipient if it is set to None.deadline
: The deadline of executing this extrinsic. The deadline won't be checked if it is set to None
Namespace
Type
swapWithExactTarget
Trading with DEX, swap with exact target amount. Specify your output; supply variable input.
note: analogous to Uniswapv2
swapTokensForExactTokens
amount_out
: exact target amount.amount_in_max
: acceptable maximum supply amount.path
: trading path.to
: The recipient of the swapped token asset. The caller is the default recipient if it is set to None.deadline
: The deadline of executing this extrinsic. The deadline won't be checked if it is set to None
Namespace
Type
Storage
feeTo
FeeTo account where network fees are deposited
Namespace
Type
liquidityPool
Namespace
Type
liquidityPoolLastK
Namespace
Type
tradingPairLPToken
Namespace
Type
tradingPairStatuses
Namespace
Type
Events
AddLiquidity
Add liquidity success. [who, asset_id_0, reserve_0_increment, asset_id_1, reserve_1_increment, share_increment, to]
Namespace
Type
AddProvision
Add provision success. [who, asset_id_0, contribution_0, asset_id_1, contribution_1]
Namespace
Type
DisableTradingPair
Disable trading pair. [trading_pair]
Namespace
Type
EnableTradingPair
Enable trading pair. [trading_pair]
Namespace
Type
FeeToSet
Set FeeTo account success. [fee_to]
Namespace
Type
ProvisioningToEnabled
Provisioning trading pair convert to Enabled. [trading_pair, pool_0_amount, pool_1_amount, total_share_amount]
Namespace
Type
RemoveLiquidity
Remove liquidity from the trading pool success. [who, asset_id_0, reserve_0_decrement, asset_id_1, reserve_1_decrement, share_decrement, to]
Namespace
Type
Swap
Use supply Asset to swap target Asset. [trader, trading_path, supply_Asset_amount, target_Asset_amount, to]
Namespace
Type
Errors
ExcessiveSupplyAmount
Supply amount is more than max_supply_amount
Namespace
ExpiredDeadline
The deadline has been missed
Namespace
IdenticalTokenAddress
Namespace
InsufficientAmount
Insufficent amount
Namespace
InsufficientAmountA
Insufficient asset_a liquidity amount
Namespace
InsufficientAmountB
Insufficient asset_b liquidity amount
Namespace
InsufficientInputAmount
Insufficient input amount
Namespace
InsufficientLiquidity
Liquidity is not enough
Namespace
InsufficientLiquidityBurnt
Insufficient liquidity burnt
Namespace
InsufficientOutputAmount
Insufficient output amount
Namespace
InsufficientTargetAmount
Target amount is less to min_target_amount
Namespace
InsufficientWithdrawnAmountA
Insufficient withdraw amount for token A
Namespace
InsufficientWithdrawnAmountB
Insufficient withdraw amount for token B
Namespace
InvalidAssetId
Invalid Asset id
Namespace
InvalidConstantProduct
Invalid constant product K
Namespace
InvalidInputAmounts
Must provide non-zero amount of liquidity
Namespace
InvalidLiquidityIncrement
The increment of liquidity is invalid
Namespace
InvalidTradingPathLength
Invalid trading path length
Namespace
LiquidityProviderTokenNotCreated
The Liquidity Provider token does not exist
Namespace
MustBeEnabled
Trading pair must be in Enabled status
Namespace
MustBeNotEnabled
Trading pair must be in NotEnabled status
Namespace
ZeroSupplyAmount
The supply amount is zero
Namespace
ZeroTargetAmount
The target amount is zero
Namespace
Constants
defaultFeeTo
The default FeeTo account
Namespace
Type
dexBurnPalletId
The DEX's burn id, to provide for a redundant, unredeemable minter/burner address.
Namespace
Type
getExchangeFee
Trading fee rate The first item of the tuple is the numerator of the fee rate, second item is the denominator, fee_rate = numerator / denominator, use (u32, u32) over Rate
type to minimize internal division operation.
Namespace
Type
lpTokenDecimals
Liquidity pair default token decimals
Namespace
Type
tradingPathLimit
The limit for length of trading path
Namespace
Type
JSON-RPC Methods
getAmountsIn
getAmountsIn
Given an array of AssetIds, return amounts in for an amount out
Interface
JSON
getAmountsOut
getAmountsOut
Given an array of AssetIds, return amounts out for an amount in
Interface
JSON
getLPTokenID
getLPTokenID
Given two AssetIds, return liquidity token created for the pair
Interface
JSON
getLiquidity
getLiquidity
Given two AssetIds, return liquidity
Interface
JSON
getTradingPairStatus
getTradingPairStatus
Given two AssetIds, return whether trading pair is enabled or disabled
Interface
JSON
quote
quote
Given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
Interface
JSON
Last updated